Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Stop propagating text decorations on outermost SVG roots
https://bugs.webkit.org/show_bug.cgi?id=248567
rdar://problem/103093226

Reviewed by Antti Koivisto.

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.

Merge: https://src.chromium.org/viewvc/blink?view=revision&revision=199132

Outermost SVG roots should be consider atomic inline-level, and hence
text decorations should not propagate into them from the outside.

* Source/WebCore/style/StyleAdjuster.cpp:
(isOutermostSVGElement): Add new static function
(shouldInheritTextDecorationsInEffect): Update as per commit
* LayoutTests/svg/text/text-decoration-propagation.html: Add Test Case
* LayoutTests/svg/text/text-decoration-propagation-expected.html: Add Test Case Expectation
* LayoutTests/svg/text/text-decoration-propagation-2.html: Add Test Case
* LayoutTests/svg/text/text-decoration-propagation-2-expected.html: Add Test Case Expectation

Canonical link: https://commits.webkit.org/264894@main
  • Loading branch information
Ahmad-S792 authored and Ahmad Saleem committed Jun 6, 2023
1 parent 5b9c48e commit b3a3c58
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<style>
#outer { text-decoration: underline; }
</style>
<svg id=outer>
<text y="20">Text which does have an underline</text>
</svg>
9 changes: 9 additions & 0 deletions LayoutTests/svg/text/text-decoration-propagation-2.html
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<style>
#outer { text-decoration: underline; }
</style>
<svg id=outer>
<svg>
<text y="20">Text which does have an underline</text>
</svg>
</svg>
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<span>
<svg>
<text y="20">Text which does NOT have an underline</text>
</svg>
</span>
9 changes: 9 additions & 0 deletions LayoutTests/svg/text/text-decoration-propagation.html
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<style>
span { text-decoration: underline; }
</style>
<span>
<svg>
<text y="20">Text which does NOT have an underline</text>
</svg>
</span>
11 changes: 10 additions & 1 deletion Source/WebCore/style/StyleAdjuster.cpp
Expand Up @@ -8,7 +8,7 @@
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
* Copyright (C) Research In Motion Limited 2011. All rights reserved.
* Copyright (C) 2012, 2013 Google Inc. All rights reserved.
* Copyright (C) 2012-2015 Google Inc. All rights reserved.
* Copyright (C) 2014, 2020, 2022 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -155,6 +155,11 @@ static DisplayType equivalentBlockDisplay(const RenderStyle& style)
return DisplayType::Block;
}

static bool isOutermostSVGElement(const Element* element)
{
return element && element->isSVGElement() && downcast<SVGElement>(*element).isOutermostSVGSVGElement();
}

static bool shouldInheritTextDecorationsInEffect(const RenderStyle& style, const Element* element)
{
if (style.isFloating() || style.hasOutOfFlowPosition())
Expand All @@ -167,6 +172,10 @@ static bool shouldInheritTextDecorationsInEffect(const RenderStyle& style, const
return parentNode && parentNode->isUserAgentShadowRoot();
}();

// Outermost <svg> roots are considered to be atomic inline-level.
if (isOutermostSVGElement(element))
return false;

// There is no other good way to prevent decorations from affecting user agent shadow trees.
if (isAtUserAgentShadowBoundary)
return false;
Expand Down

0 comments on commit b3a3c58

Please sign in to comment.