Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Highlight logic incorrect for checking author set text color
https://bugs.webkit.org/show_bug.cgi?id=258943
rdar://111706100

Reviewed by Megan Gardner and Aditya Keerthi.

Before logic to determine whether to take a text color of a
StyledMarkedText was to compare to canvasText color.
This causes aproblem if author set color to canvasText or if the color
black was considered as canvasText.
Now, we check if a flag was set indicating the author explicitly
specified a text color.
Updated TestExpectations due to passing test.
Part of priority in spec: https://www.w3.org/TR/css-highlight-api-1/#priorities

* LayoutTests/TestExpectations:
* Source/WebCore/rendering/StyledMarkedText.cpp:
(WebCore::resolveStyleForMarkedText):
(WebCore::coalesceAdjacentWithSameRanges):
* Source/WebCore/rendering/TextPaintStyle.cpp:
(WebCore::computeTextSelectionPaintStyle):
* Source/WebCore/rendering/TextPaintStyle.h:

Canonical link: https://commits.webkit.org/266117@main
  • Loading branch information
jesxilin authored and nt1m committed Jul 17, 2023
1 parent bde6731 commit ec22e07
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion LayoutTests/TestExpectations
Expand Up @@ -4905,7 +4905,6 @@ imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-
imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-inheritance-002.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-invalidation-003.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-invalidation-006.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-017.html [ ImageOnlyFailure ]

http/tests/webgl/1.0.x/conformance/textures/misc/origin-clean-conformance-offscreencanvas.html [ Skip ]
http/tests/webgl/2.0.y/conformance/textures/misc/origin-clean-conformance-offscreencanvas.html [ Skip ]
Expand Down
6 changes: 3 additions & 3 deletions Source/WebCore/rendering/StyledMarkedText.cpp
Expand Up @@ -54,6 +54,7 @@ static StyledMarkedText resolveStyleForMarkedText(const MarkedText& markedText,
style.backgroundColor = renderStyle->colorResolvingCurrentColor(renderStyle->backgroundColor());
style.textStyles.fillColor = renderStyle->computedStrokeColor();
style.textStyles.strokeColor = renderStyle->computedStrokeColor();
style.textStyles.hasExplicitlySetFillColor = renderStyle->hasExplicitlySetColor();

auto color = TextDecorationPainter::decorationColor(*renderStyle.get());
auto decorationStyle = renderStyle->textDecorationStyle();
Expand Down Expand Up @@ -136,9 +137,8 @@ static Vector<StyledMarkedText> coalesceAdjacentWithSameRanges(Vector<StyledMark
|| !it->style.backgroundColor.isOpaque()
|| (it->highlightName.isNull() && it->style.backgroundColor.isVisible())))
previousStyledMarkedText.style.backgroundColor = blendSourceOver(previousStyledMarkedText.style.backgroundColor, it->style.backgroundColor);
// Take text color of the StyledMarkedText that has set it, maintaining insertion order.
// FIXME: Case of user setting color to CanvasText, will not choose CanvasText as prioritized color to paint.
if (it->type != MarkedText::Type::Unmarked && it->style.textStyles.fillColor != RenderTheme::singleton().systemColor(CSSValueCanvastext, { }))
// Take text color of StyledMarkedText, maintaining insertion and priority order.
if (it->type != MarkedText::Type::Unmarked && it->style.textStyles.hasExplicitlySetFillColor)
previousStyledMarkedText.style.textStyles.fillColor = it->style.textStyles.fillColor;
// Take the highlightName of the latest StyledMarkedText, regardless of priority.
if (!it->highlightName.isNull())
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/rendering/TextPaintStyle.cpp
Expand Up @@ -149,6 +149,7 @@ TextPaintStyle computeTextSelectionPaintStyle(const TextPaintStyle& textPaintSty
selectionPaintStyle.emphasisMarkColor = emphasisMarkForeground;

if (auto pseudoStyle = renderer.selectionPseudoStyle()) {
selectionPaintStyle.hasExplicitlySetFillColor = pseudoStyle->hasExplicitlySetColor();
selectionShadow = ShadowData::clone(paintInfo.forceTextColor() ? nullptr : pseudoStyle->textShadow());
auto viewportSize = renderer.frame().view() ? renderer.frame().view()->size() : IntSize();
float strokeWidth = pseudoStyle->computedStrokeWidth(viewportSize);
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/rendering/TextPaintStyle.h
Expand Up @@ -48,6 +48,8 @@ struct TextPaintStyle {
Color strokeColor;
Color emphasisMarkColor;
float strokeWidth { 0 };
// This is not set for -webkit-text-fill-color.
bool hasExplicitlySetFillColor { false };
#if HAVE(OS_DARK_MODE_SUPPORT)
bool useDarkAppearance { false };
#endif
Expand Down

0 comments on commit ec22e07

Please sign in to comment.