Title: [278602] trunk
Revision
278602
Author
[email protected]
Date
2021-06-08 05:11:32 -0700 (Tue, 08 Jun 2021)

Log Message

`text-decoration: underline` is not applied to web component
https://bugs.webkit.org/show_bug.cgi?id=226724
<rdar://problem/78987286>

Reviewed by Ryosuke Niwa.

Source/WebCore:

'text-decoration' is not an inherited property in itself but its effective value
behaves as it was. We fail to inherit this effective value into author shadow trees.

Test case by Jeroen Zwartepoorte.

Test: fast/shadow-dom/effective-text-decoration-inheritance.html

* style/StyleAdjuster.cpp:
(WebCore::Style::shouldInheritEffectiveTextDecorations):

Test for user agent shadow tree, not a shadow tree in general.
Also inverse the logic and refactor a bit.

(WebCore::Style::Adjuster::adjust const):
(WebCore::Style::isAtShadowBoundary): Deleted.
(WebCore::Style::doesNotInheritTextDecoration): Deleted.

LayoutTests:

* fast/shadow-dom/effective-text-decoration-inheritance-expected.html: Added.
* fast/shadow-dom/effective-text-decoration-inheritance.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (278601 => 278602)


--- trunk/LayoutTests/ChangeLog	2021-06-08 12:02:43 UTC (rev 278601)
+++ trunk/LayoutTests/ChangeLog	2021-06-08 12:11:32 UTC (rev 278602)
@@ -1,3 +1,14 @@
+2021-06-08  Antti Koivisto  <[email protected]>
+
+        `text-decoration: underline` is not applied to web component
+        https://bugs.webkit.org/show_bug.cgi?id=226724
+        <rdar://problem/78987286>
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/shadow-dom/effective-text-decoration-inheritance-expected.html: Added.
+        * fast/shadow-dom/effective-text-decoration-inheritance.html: Added.
+
 2021-06-08  Fujii Hironori  <[email protected]>
 
         [WinCairo] Unreviewed test gardening

Added: trunk/LayoutTests/fast/shadow-dom/effective-text-decoration-inheritance-expected.html (0 => 278602)


--- trunk/LayoutTests/fast/shadow-dom/effective-text-decoration-inheritance-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/effective-text-decoration-inheritance-expected.html	2021-06-08 12:11:32 UTC (rev 278602)
@@ -0,0 +1 @@
+<div style="text-decoration: underline">This should be underlined</div>

Added: trunk/LayoutTests/fast/shadow-dom/effective-text-decoration-inheritance.html (0 => 278602)


--- trunk/LayoutTests/fast/shadow-dom/effective-text-decoration-inheritance.html	                        (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/effective-text-decoration-inheritance.html	2021-06-08 12:11:32 UTC (rev 278602)
@@ -0,0 +1,21 @@
+<script>
+class CustomElement extends HTMLElement {
+  constructor() {
+    super();
+
+    const shadow = this.attachShadow({ mode: 'open' });
+    const slot = document.createElement('slot');
+    const style = document.createElement('style');
+    style.textContent = `
+      :host {
+        text-decoration: underline;
+      }
+    `;
+    shadow.append(style, slot);
+  }
+}
+
+customElements.define('custom-element', CustomElement);
+</script>
+
+<custom-element>This should be underlined</custom-element>

Modified: trunk/Source/WebCore/ChangeLog (278601 => 278602)


--- trunk/Source/WebCore/ChangeLog	2021-06-08 12:02:43 UTC (rev 278601)
+++ trunk/Source/WebCore/ChangeLog	2021-06-08 12:11:32 UTC (rev 278602)
@@ -1,3 +1,28 @@
+2021-06-08  Antti Koivisto  <[email protected]>
+
+        `text-decoration: underline` is not applied to web component
+        https://bugs.webkit.org/show_bug.cgi?id=226724
+        <rdar://problem/78987286>
+
+        Reviewed by Ryosuke Niwa.
+
+        'text-decoration' is not an inherited property in itself but its effective value
+        behaves as it was. We fail to inherit this effective value into author shadow trees.
+
+        Test case by Jeroen Zwartepoorte.
+
+        Test: fast/shadow-dom/effective-text-decoration-inheritance.html
+
+        * style/StyleAdjuster.cpp:
+        (WebCore::Style::shouldInheritEffectiveTextDecorations):
+
+        Test for user agent shadow tree, not a shadow tree in general.
+        Also inverse the logic and refactor a bit.
+
+        (WebCore::Style::Adjuster::adjust const):
+        (WebCore::Style::isAtShadowBoundary): Deleted.
+        (WebCore::Style::doesNotInheritTextDecoration): Deleted.
+
 2021-06-08  Frédéric Wang  <[email protected]>
 
         Crash in InsertParagraphSeparatorCommand::doApply

Modified: trunk/Source/WebCore/style/StyleAdjuster.cpp (278601 => 278602)


--- trunk/Source/WebCore/style/StyleAdjuster.cpp	2021-06-08 12:02:43 UTC (rev 278601)
+++ trunk/Source/WebCore/style/StyleAdjuster.cpp	2021-06-08 12:11:32 UTC (rev 278602)
@@ -141,20 +141,33 @@
     return DisplayType::Block;
 }
 
-static inline bool isAtShadowBoundary(const Element& element)
+static bool shouldInheritTextDecorationsInEffect(const RenderStyle& style, const Element* element)
 {
-    auto* parentNode = element.parentNode();
-    return parentNode && parentNode->isShadowRoot();
-}
+    if (style.isFloating() || style.hasOutOfFlowPosition())
+        return false;
 
-// CSS requires text-decoration to be reset at each DOM element for tables,
-// inline blocks, inline tables, shadow DOM crossings, floating elements,
-// and absolute or relatively positioned elements.
-static bool doesNotInheritTextDecoration(const RenderStyle& style, const Element* element)
-{
-    return style.display() == DisplayType::Table || style.display() == DisplayType::InlineTable
-        || style.display() == DisplayType::InlineBlock || style.display() == DisplayType::InlineBox || (element && isAtShadowBoundary(*element))
-        || style.isFloating() || style.hasOutOfFlowPosition();
+    auto isAtUserAgentShadowBoundary = [&] {
+        if (!element)
+            return false;
+        auto* parentNode = element->parentNode();
+        return parentNode && parentNode->isUserAgentShadowRoot();
+    }();
+
+    // There is no other good way to prevent decorations from affecting user agent shadow trees.
+    if (isAtUserAgentShadowBoundary)
+        return false;
+
+    switch (style.display()) {
+    case DisplayType::Table:
+    case DisplayType::InlineTable:
+    case DisplayType::InlineBlock:
+    case DisplayType::InlineBox:
+        return false;
+    default:
+        break;
+    };
+
+    return true;
 }
 
 static bool isScrollableOverflow(Overflow overflow)
@@ -393,10 +406,10 @@
         }
     }
 
-    if (doesNotInheritTextDecoration(style, m_element))
+    if (shouldInheritTextDecorationsInEffect(style, m_element))
+        style.addToTextDecorationsInEffect(style.textDecoration());
+    else
         style.setTextDecorationsInEffect(style.textDecoration());
-    else
-        style.addToTextDecorationsInEffect(style.textDecoration());
 
     // If either overflow value is not visible, change to auto.
     if (style.overflowX() == Overflow::Visible && style.overflowY() != Overflow::Visible) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to