Changeset 288054 in webkit


Ignore:
Timestamp:
Jan 15, 2022 5:32:05 AM (6 months ago)
Author:
graouts@webkit.org
Message:

Setting content: normal on a ::marker should make computed style return resolved values
https://bugs.webkit.org/show_bug.cgi?id=235222

Reviewed by Aditya Keerthi.

LayoutTests/imported/w3c:

Mark WPT progressions.

  • web-platform-tests/css/css-pseudo/marker-computed-size-expected.txt:

Source/WebCore:

Until now, StyleBuilder would treat "none" and "normal" values the same way for the "content"
CSS property. However, "normal", the initial value, is not the same as "none" which explicitly
states that we do not have any content. The WPT test css/css-pseudo/marker-computed-size.html
checks on this by setting content: normal on a ::marker and expecting the computed style
for "width" and "height" to be pixel values and not "auto".

We already have a bit in RenderStyle that would be turned on when we would parse either "none"
or "normal". We're now only setting that bit, with a better name when the value is explicitly "none".

So we now remove hasExplicitlyClearedContent() and instead expose hasEffectiveContentNone()
on RenderStyle.

We also remove a stale comment in applyInheritContent() since the spec has not changed to make
"content" inherited.

Finally, Styleable::renderer() now returns the markerRenderer() unless
RenderStyle::hasEffectiveContentNone() is true.

For reference, the relevant spec is https://drafts.csswg.org/css-content-3/#content-property.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::contentToCSSValue):

  • rendering/RenderThemeIOS.mm:

(WebCore::RenderThemeIOS::isControlStyled const):

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::RenderStyle):

  • rendering/style/RenderStyle.h:

(WebCore::RenderStyle::hasEffectiveContentNone const):
(WebCore::RenderStyle::setHasContentNone):
(WebCore::RenderStyle::NonInheritedFlags::operator== const):
(WebCore::RenderStyle::setHasExplicitlyClearedContent): Deleted.
(WebCore::RenderStyle::hasExplicitlyClearedContent const): Deleted.

  • style/StyleBuilderCustom.h:

(WebCore::Style::BuilderCustom::applyInitialContent):
(WebCore::Style::BuilderCustom::applyInheritContent):
(WebCore::Style::BuilderCustom::applyValueContent):

  • style/Styleable.cpp:

(WebCore::Styleable::renderer const):

LayoutTests:

  • platform/gtk/imported/w3c/web-platform-tests/css/css-pseudo/marker-computed-size-expected.txt:
Location:
trunk
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r288052 r288054  
     12022-01-14  Antoine Quint  <graouts@webkit.org>
     2
     3        Setting `content: normal` on a ::marker should make computed style return resolved values
     4        https://bugs.webkit.org/show_bug.cgi?id=235222
     5
     6        Reviewed by Aditya Keerthi.
     7
     8        * platform/gtk/imported/w3c/web-platform-tests/css/css-pseudo/marker-computed-size-expected.txt:
     9
    1102022-01-14  Frederic Wang  <fwang@igalia.com>
    211
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r288049 r288054  
     12022-01-14  Antoine Quint  <graouts@webkit.org>
     2
     3        Setting `content: normal` on a ::marker should make computed style return resolved values
     4        https://bugs.webkit.org/show_bug.cgi?id=235222
     5
     6        Reviewed by Aditya Keerthi.
     7
     8        Mark WPT progressions.
     9
     10        * web-platform-tests/css/css-pseudo/marker-computed-size-expected.txt:
     11
    1122022-01-14  Yusuke Suzuki  <ysuzuki@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/marker-computed-size-expected.txt

    r267650 r288054  
    11
    2 FAIL Decimal ::marker assert_equals: width expected "30px" but got "auto"
    3 FAIL Decimal ::marker with custom value assert_equals: width expected "40px" but got "auto"
    4 FAIL String ::marker assert_equals: width expected "20px" but got "auto"
     2PASS Decimal ::marker
     3PASS Decimal ::marker with custom value
     4PASS String ::marker
    55PASS ::marker with no box due to 'list-style'
    66FAIL ::marker with custom string contents assert_equals: width expected "60px" but got "auto"
  • trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/css/css-pseudo/marker-computed-size-expected.txt

    r288053 r288054  
    11
    2 FAIL Decimal ::marker assert_equals: width expected "30px" but got "auto"
    3 FAIL Decimal ::marker with custom value assert_equals: width expected "40px" but got "auto"
    4 FAIL String ::marker assert_equals: width expected "20px" but got "auto"
     2FAIL Decimal ::marker assert_equals: width expected "30px" but got "11px"
     3FAIL Decimal ::marker with custom value assert_equals: width expected "40px" but got "16px"
     4FAIL String ::marker assert_equals: width expected "20px" but got "7px"
    55PASS ::marker with no box due to 'list-style'
    66FAIL ::marker with custom string contents assert_equals: width expected "60px" but got "auto"
  • trunk/Source/WebCore/ChangeLog

    r288053 r288054  
     12022-01-14  Antoine Quint  <graouts@webkit.org>
     2
     3        Setting `content: normal` on a ::marker should make computed style return resolved values
     4        https://bugs.webkit.org/show_bug.cgi?id=235222
     5
     6        Reviewed by Aditya Keerthi.
     7
     8        Until now, StyleBuilder would treat "none" and "normal" values the same way for the "content"
     9        CSS property. However, "normal", the initial value, is not the same as "none" which explicitly
     10        states that we do not have any content. The WPT test css/css-pseudo/marker-computed-size.html
     11        checks on this by setting `content: normal` on a ::marker and expecting the computed style
     12        for "width" and "height" to be pixel values and not "auto".
     13
     14        We already have a bit in RenderStyle that would be turned on when we would parse either "none"
     15        or "normal". We're now only setting that bit, with a better name  when the value is explicitly "none".
     16
     17        So we now remove hasExplicitlyClearedContent() and instead expose hasEffectiveContentNone()
     18        on RenderStyle.
     19
     20        We also remove a stale comment in applyInheritContent() since the spec has not changed to make
     21        "content" inherited.
     22
     23        Finally, Styleable::renderer() now returns the markerRenderer() unless
     24        RenderStyle::hasEffectiveContentNone() is true.
     25
     26        For reference, the relevant spec is https://drafts.csswg.org/css-content-3/#content-property.
     27
     28        * css/CSSComputedStyleDeclaration.cpp:
     29        (WebCore::contentToCSSValue):
     30        * rendering/RenderThemeIOS.mm:
     31        (WebCore::RenderThemeIOS::isControlStyled const):
     32        * rendering/style/RenderStyle.cpp:
     33        (WebCore::RenderStyle::RenderStyle):
     34        * rendering/style/RenderStyle.h:
     35        (WebCore::RenderStyle::hasEffectiveContentNone const):
     36        (WebCore::RenderStyle::setHasContentNone):
     37        (WebCore::RenderStyle::NonInheritedFlags::operator== const):
     38        (WebCore::RenderStyle::setHasExplicitlyClearedContent): Deleted.
     39        (WebCore::RenderStyle::hasExplicitlyClearedContent const): Deleted.
     40        * style/StyleBuilderCustom.h:
     41        (WebCore::Style::BuilderCustom::applyInitialContent):
     42        (WebCore::Style::BuilderCustom::applyInheritContent):
     43        (WebCore::Style::BuilderCustom::applyValueContent):
     44        * style/Styleable.cpp:
     45        (WebCore::Styleable::renderer const):
     46
    1472022-01-14  Peng Liu  <peng.liu6@apple.com>
    248
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r287987 r288054  
    19251925            list->append(cssValuePool.createValue(downcast<TextContentData>(*contentData).text(), CSSUnitType::CSS_STRING));
    19261926    }
    1927     if (!list->length()) {
    1928         auto isBeforeOrAfter = style.styleType() == PseudoId::Before || style.styleType() == PseudoId::After;
    1929         list->append(cssValuePool.createIdentifierValue(isBeforeOrAfter ? CSSValueNone : CSSValueNormal));
    1930     }
     1927    if (!list->length())
     1928        list->append(cssValuePool.createIdentifierValue(style.hasEffectiveContentNone() ? CSSValueNone : CSSValueNormal));
    19311929    return list;
    19321930}
  • trunk/Source/WebCore/rendering/RenderThemeIOS.mm

    r287552 r288054  
    497497#if ENABLE(DATALIST_ELEMENT)
    498498    if (style.effectiveAppearance() == ListButtonPart)
    499         return style.hasContent() || style.hasExplicitlyClearedContent();
     499        return style.hasContent() || style.hasEffectiveContentNone();
    500500#endif
    501501
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r287757 r288054  
    195195    m_nonInheritedFlags.lastChildState = false;
    196196    m_nonInheritedFlags.isLink = false;
    197     m_nonInheritedFlags.hasExplicitlyClearedContent = false;
     197    m_nonInheritedFlags.hasContentNone = false;
    198198    m_nonInheritedFlags.styleType = static_cast<unsigned>(PseudoId::None);
    199199    m_nonInheritedFlags.pseudoBits = static_cast<unsigned>(PseudoId::None);
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r288035 r288054  
    14721472    static PathOperation* initialClipPath() { return nullptr; }
    14731473
     1474    bool hasEffectiveContentNone() const { return !contentData() && (m_nonInheritedFlags.hasContentNone || styleType() == PseudoId::Before || styleType() == PseudoId::After); }
    14741475    bool hasContent() const { return contentData(); }
    14751476    const ContentData* contentData() const { return m_rareNonInheritedData->content.get(); }
     
    14771478    bool contentDataEquivalent(const RenderStyle* otherStyle) const { return const_cast<RenderStyle*>(this)->m_rareNonInheritedData->contentDataEquivalent(*const_cast<RenderStyle*>(otherStyle)->m_rareNonInheritedData); }
    14781479    void clearContent();
    1479     void setHasExplicitlyClearedContent(bool v) { m_nonInheritedFlags.hasExplicitlyClearedContent = v; }
    1480     bool hasExplicitlyClearedContent() const { return m_nonInheritedFlags.hasExplicitlyClearedContent; };
     1480    void setHasContentNone(bool v) { m_nonInheritedFlags.hasContentNone = v; }
    14811481    void setContent(const String&, bool add = false);
    14821482    void setContent(RefPtr<StyleImage>&&, bool add = false);
     
    19421942        unsigned lastChildState : 1;
    19431943        unsigned isLink : 1;
    1944         unsigned hasExplicitlyClearedContent : 1;
     1944        unsigned hasContentNone : 1;
    19451945
    19461946        unsigned styleType : 4; // PseudoId
     
    20792079        && lastChildState == other.lastChildState
    20802080        && isLink == other.isLink
    2081         && hasExplicitlyClearedContent == other.hasExplicitlyClearedContent
     2081        && hasContentNone == other.hasContentNone
    20822082        && styleType == other.styleType
    20832083        && pseudoBits == other.pseudoBits;
  • trunk/Source/WebCore/style/StyleBuilderCustom.h

    r287430 r288054  
    15211521{
    15221522    builderState.style().clearContent();
    1523     builderState.style().setHasExplicitlyClearedContent(true);
     1523    builderState.style().setHasContentNone(false);
    15241524}
    15251525
    15261526inline void BuilderCustom::applyInheritContent(BuilderState&)
    15271527{
    1528     // FIXME: In CSS3, it will be possible to inherit content. In CSS2 it is not. This
    1529     // note is a reminder that eventually "inherit" needs to be supported.
    15301528}
    15311529
     
    15361534        ASSERT_UNUSED(primitiveValue, primitiveValue.valueID() == CSSValueNormal || primitiveValue.valueID() == CSSValueNone);
    15371535        builderState.style().clearContent();
    1538         builderState.style().setHasExplicitlyClearedContent(true);
     1536        builderState.style().setHasContentNone(primitiveValue.valueID() == CSSValueNone);
    15391537        return;
    15401538    }
  • trunk/Source/WebCore/style/Styleable.cpp

    r287987 r288054  
    101101        if (is<RenderListItem>(element.renderer())) {
    102102            auto* markerRenderer = downcast<RenderListItem>(*element.renderer()).markerRenderer();
    103             if (markerRenderer && markerRenderer->style().hasContent())
     103            if (markerRenderer && !markerRenderer->style().hasEffectiveContentNone())
    104104                return markerRenderer;
    105105        }
Note: See TracChangeset for help on using the changeset viewer.