Changeset 278602 in webkit


Ignore:
Timestamp:
Jun 8, 2021 5:11:32 AM (14 months ago)
Author:
Antti Koivisto
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.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r278594 r278602  
     12021-06-08  Antti Koivisto  <antti@apple.com>
     2
     3        `text-decoration: underline` is not applied to web component
     4        https://bugs.webkit.org/show_bug.cgi?id=226724
     5        <rdar://problem/78987286>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        * fast/shadow-dom/effective-text-decoration-inheritance-expected.html: Added.
     10        * fast/shadow-dom/effective-text-decoration-inheritance.html: Added.
     11
    1122021-06-08  Fujii Hironori  <Hironori.Fujii@sony.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r278593 r278602  
     12021-06-08  Antti Koivisto  <antti@apple.com>
     2
     3        `text-decoration: underline` is not applied to web component
     4        https://bugs.webkit.org/show_bug.cgi?id=226724
     5        <rdar://problem/78987286>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        'text-decoration' is not an inherited property in itself but its effective value
     10        behaves as it was. We fail to inherit this effective value into author shadow trees.
     11
     12        Test case by Jeroen Zwartepoorte.
     13
     14        Test: fast/shadow-dom/effective-text-decoration-inheritance.html
     15
     16        * style/StyleAdjuster.cpp:
     17        (WebCore::Style::shouldInheritEffectiveTextDecorations):
     18
     19        Test for user agent shadow tree, not a shadow tree in general.
     20        Also inverse the logic and refactor a bit.
     21
     22        (WebCore::Style::Adjuster::adjust const):
     23        (WebCore::Style::isAtShadowBoundary): Deleted.
     24        (WebCore::Style::doesNotInheritTextDecoration): Deleted.
     25
    1262021-06-08  Frédéric Wang  <fwang@igalia.com>
    227
  • trunk/Source/WebCore/style/StyleAdjuster.cpp

    r277949 r278602  
    142142}
    143143
    144 static inline bool isAtShadowBoundary(const Element& element)
    145 {
    146     auto* parentNode = element.parentNode();
    147     return parentNode && parentNode->isShadowRoot();
    148 }
    149 
    150 // CSS requires text-decoration to be reset at each DOM element for tables,
    151 // inline blocks, inline tables, shadow DOM crossings, floating elements,
    152 // and absolute or relatively positioned elements.
    153 static bool doesNotInheritTextDecoration(const RenderStyle& style, const Element* element)
    154 {
    155     return style.display() == DisplayType::Table || style.display() == DisplayType::InlineTable
    156         || style.display() == DisplayType::InlineBlock || style.display() == DisplayType::InlineBox || (element && isAtShadowBoundary(*element))
    157         || style.isFloating() || style.hasOutOfFlowPosition();
     144static bool shouldInheritTextDecorationsInEffect(const RenderStyle& style, const Element* element)
     145{
     146    if (style.isFloating() || style.hasOutOfFlowPosition())
     147        return false;
     148
     149    auto isAtUserAgentShadowBoundary = [&] {
     150        if (!element)
     151            return false;
     152        auto* parentNode = element->parentNode();
     153        return parentNode && parentNode->isUserAgentShadowRoot();
     154    }();
     155
     156    // There is no other good way to prevent decorations from affecting user agent shadow trees.
     157    if (isAtUserAgentShadowBoundary)
     158        return false;
     159
     160    switch (style.display()) {
     161    case DisplayType::Table:
     162    case DisplayType::InlineTable:
     163    case DisplayType::InlineBlock:
     164    case DisplayType::InlineBox:
     165        return false;
     166    default:
     167        break;
     168    };
     169
     170    return true;
    158171}
    159172
     
    394407    }
    395408
    396     if (doesNotInheritTextDecoration(style, m_element))
     409    if (shouldInheritTextDecorationsInEffect(style, m_element))
     410        style.addToTextDecorationsInEffect(style.textDecoration());
     411    else
    397412        style.setTextDecorationsInEffect(style.textDecoration());
    398     else
    399         style.addToTextDecorationsInEffect(style.textDecoration());
    400413
    401414    // If either overflow value is not visible, change to auto.
Note: See TracChangeset for help on using the changeset viewer.