Closed Bug 1783430 Opened 4 years ago Closed 4 years ago

[wpt-sync] Sync PR 35356 - HighlightInheritance: fix ‘currentColor’ for all other properties

Categories

(Core :: Layout: Generated Content, Lists, and Counters, task, P4)

task

Tracking

()

RESOLVED FIXED
106 Branch
Tracking Status
firefox106 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 35356 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/35356
Details from upstream follow.

Delan Azabani <dazabani@igalia.com> wrote:

HighlightInheritance: fix ‘currentColor’ for all other properties

Highlight pseudos have a special case for ‘color:currentColor’, where
it means the ‘color’ of the next active highlight layer below, rather
than being equivalent to ‘color:inherit’. This not only means that the
‘color’ of a highlight might be unknown until paint determines where
the highlights are active, but so can any other property with \<color>
values, thanks to ‘currentColor’.

HighlightPaintingUtils contains the logic for this, but currently only
for ‘color’ and ‘background-color’, and even then the latter is bugged
since it always checks whether the unvisited value is currentColor.
The general approach of having only Color-returning methods plus bool
methods telling you whether to use them is also prone to bugs, since
we can just blindly use the Color without checking.

The ideal interface for highlights is for VisitedDependentColor and
the ColorIncludingFallback methods to return optional\<Color>, but we
also don’t want to penalise non-highlight code with all of these extra
optional checks, nor do we want to maintain two copies of the code.

This patch adds an optional bool out parameter to

• ComputedStyle::VisitedDependentColor
• Longhand::ColorIncludingFallback
• StyleColor::Resolve

and the helper functions

• ComputedStyle::ResolvedColor
• ComputedStyle::GetCurrentColor
• ComputedStyle::GetInternalVisitedCurrentColor
• ComputedStyle::GetInternalForcedCurrentColor
• ComputedStyle::GetInternalForcedVisitedCurrentColor
• ComputedStyleUtils::BorderSideColor
• StyleColor::ResolveWithAlpha

that (if present) indicates whether the property that was ultimately
chosen was ‘currentColor’, while resolving the color as usual. We also
remove the old functions for handling ‘currentColor’ in highlights:

• ComputedStyle::IsBackgroundColorCurrentColor
• ComputedStyle::VisitedDependentColorIsCurrentColor

This in turn allows us to create HighlightPaintingUtils::ResolveColor,
which encapsulates the “property color or this layer currentColor or
previous layer currentColor or originating currentColor” dance.

While this patch won’t completely prevent misuse of the Color-based
interface, the new helper in HighlightPaintingUtils should at least
make the correct logic easy enough to discourage it.

Bug: 1295264
Change-Id: Ic0e5ee6787162b33172b9f7023e404c82be1b14d
Reviewed-on: https://chromium-review.googlesource.com/3781986
WPT-Export-Revision: f4dc39af293ef1ac854682382af7959f974aad82

Component: web-platform-tests → Layout: Generated Content, Lists, and Counters
Product: Testing → Core
Whiteboard: [wptsync downstream] → [wptsync downstream error]
Whiteboard: [wptsync downstream error] → [wptsync downstream]
Pushed by wptsync@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9da8753bcd7c [wpt PR 35356] - HighlightInheritance: fix ‘currentColor’ for all other properties, a=testonly https://hg.mozilla.org/integration/autoland/rev/8f5085fcfe16 [wpt PR 35356] - Update wpt metadata, a=testonly
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
You need to log in before you can comment on or make changes to this bug.