Changeset 221542 in webkit


Ignore:
Timestamp:
Sep 2, 2017 7:31:13 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Wrong getComputedStyle result for pseudo-elements in display: none subtrees.
https://bugs.webkit.org/show_bug.cgi?id=176259

Patch by Emilio Cobos Álvarez <emilio> on 2017-09-02
Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

  • web-platform-tests/cssom/getComputedStyle-pseudo-expected.txt:

Source/WebCore:

Before this patch, we were wrongly returning the parent style when there wasn't
a cached pseudo style.

With this, the only remaining failures in getComputedStyle-pseudo is a
serialisation bug for the "content" property, and the display: contents test,
which is because we don't support pseudo-elements of display: contents elements
yet.

Tests: imported/w3c/web-platform-tests/cssom/getComputedStyle-pseudo.html

  • dom/Document.cpp:

(WebCore::Document::styleForElementIgnoringPendingStylesheets):

  • dom/Document.h:
  • dom/Element.cpp:

(WebCore::Element::resolvePseudoElementStyle):
(WebCore::Element::computedStyle):

  • dom/Element.h:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element-expected.txt

    r191262 r221542  
    6464PASS Expected '100px' for height in the computed style for element with id testNoPseudoElement and pseudo-element null and got '100px'
    6565PASS Expected '100px' for width in the computed style for element with id testNoPseudoElement and pseudo-element null and got '100px'
    66 PASS Expected '100px' for height in the computed style for element with id testNoPseudoElement and pseudo-element :after and got '100px'
    67 PASS Expected '100px' for width in the computed style for element with id testNoPseudoElement and pseudo-element :after and got '100px'
     66PASS Expected 'auto' for height in the computed style for element with id testNoPseudoElement and pseudo-element :after and got 'auto'
     67PASS Expected 'auto' for width in the computed style for element with id testNoPseudoElement and pseudo-element :after and got 'auto'
    6868PASS Expected '0.5' for opacity in the computed style for element with id testHardwareAcceleratedCompositing and pseudo-element :before and got '0.5'
  • trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element.html

    r191262 r221542  
    181181        { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : null, 'property' : 'height', 'expectedValue' : '100px' },
    182182        { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : null, 'property' : 'width', 'expectedValue' : '100px' },
    183         { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : ':after', 'property' : 'height', 'expectedValue' : '100px' },
    184         { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : ':after', 'property' : 'width', 'expectedValue' : '100px' },
     183        { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : ':after', 'property' : 'height', 'expectedValue' : 'auto' },
     184        { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : ':after', 'property' : 'width', 'expectedValue' : 'auto' },
    185185        { 'elementId' : 'testHardwareAcceleratedCompositing', 'pseudoElement' : ':before', 'property' : 'opacity', 'expectedValue' : '0.5' }
    186186      ];
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r221512 r221542  
     12017-09-02  Emilio Cobos Álvarez  <emilio@crisal.io>
     2
     3        Wrong getComputedStyle result for pseudo-elements in display: none subtrees.
     4        https://bugs.webkit.org/show_bug.cgi?id=176259
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * web-platform-tests/cssom/getComputedStyle-pseudo-expected.txt:
     9
    1102017-09-01  Sam Weinig  <sam@webkit.org>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/cssom/getComputedStyle-pseudo-expected.txt

    r221501 r221542  
    11
    22PASS Resolution of width is correct for ::before and ::after pseudo-elements
    3 FAIL Resolution of width is correct for ::before and ::after pseudo-elements of display: contents elements assert_equals: expected "50px" but got "auto"
    4 FAIL Resolution of nonexistent pseudo-element styles assert_equals: Nonexistent :before pseudo-element shouldn't claim to have the same style as the originating element expected "static" but got "relative"
    5 FAIL Resolution of pseudo-element styles in display: none elements assert_equals: Pseudo-styles of display: none elements should be correct expected "\"Foo\"" but got ""
     3FAIL Resolution of width is correct for ::before and ::after pseudo-elements of display: contents elements assert_equals: expected "50px" but got "50%"
     4PASS Resolution of nonexistent pseudo-element styles
     5FAIL Resolution of pseudo-element styles in display: none elements assert_equals: Pseudo-styles of display: none elements should be correct expected "\"Foo\"" but got "Foo"
    66
  • trunk/Source/WebCore/ChangeLog

    r221540 r221542  
     12017-09-02  Emilio Cobos Álvarez  <emilio@crisal.io>
     2
     3        Wrong getComputedStyle result for pseudo-elements in display: none subtrees.
     4        https://bugs.webkit.org/show_bug.cgi?id=176259
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Before this patch, we were wrongly returning the parent style when there wasn't
     9        a cached pseudo style.
     10
     11        With this, the only remaining failures in getComputedStyle-pseudo is a
     12        serialisation bug for the "content" property, and the display: contents test,
     13        which is because we don't support pseudo-elements of display: contents elements
     14        yet.
     15
     16        Tests: imported/w3c/web-platform-tests/cssom/getComputedStyle-pseudo.html
     17
     18        * dom/Document.cpp:
     19        (WebCore::Document::styleForElementIgnoringPendingStylesheets):
     20        * dom/Document.h:
     21        * dom/Element.cpp:
     22        (WebCore::Element::resolvePseudoElementStyle):
     23        (WebCore::Element::computedStyle):
     24        * dom/Element.h:
     25
    1262017-09-02  Chris Dumez  <cdumez@apple.com>
    227
  • trunk/Source/WebCore/dom/Document.cpp

    r221494 r221542  
    19501950}
    19511951
    1952 std::unique_ptr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Element& element, const RenderStyle* parentStyle)
     1952std::unique_ptr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Element& element, const RenderStyle* parentStyle, PseudoId pseudoElementSpecifier)
    19531953{
    19541954    ASSERT(&element.document() == this);
     1955    ASSERT(!element.isPseudoElement() || !pseudoElementSpecifier);
     1956    ASSERT(!pseudoElementSpecifier || parentStyle);
    19551957
    19561958    // On iOS request delegates called during styleForElement may result in re-entering WebKit and killing the style resolver.
     
    19581960
    19591961    SetForScope<bool> change(m_ignorePendingStylesheets, true);
    1960     auto elementStyle = element.resolveStyle(parentStyle);
    1961 
     1962    auto& resolver = element.styleResolver();
     1963
     1964    if (pseudoElementSpecifier)
     1965        return resolver.pseudoStyleForElement(element, PseudoStyleRequest(pseudoElementSpecifier), *parentStyle);
     1966
     1967    auto elementStyle = resolver.styleForElement(element, parentStyle);
    19621968    if (elementStyle.relations) {
    19631969        Style::Update emptyUpdate(*this);
  • trunk/Source/WebCore/dom/Document.h

    r221494 r221542  
    563563    WEBCORE_EXPORT void updateLayoutIgnorePendingStylesheets(RunPostLayoutTasks = RunPostLayoutTasks::Asynchronously);
    564564
    565     std::unique_ptr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element&, const RenderStyle* parentStyle);
     565    std::unique_ptr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element&, const RenderStyle* parentStyle, PseudoId = NOPSEUDO);
    566566
    567567    // Returns true if page box (margin boxes and page borders) is visible.
  • trunk/Source/WebCore/dom/Element.cpp

    r221464 r221542  
    27402740}
    27412741
     2742const RenderStyle& Element::resolvePseudoElementStyle(PseudoId pseudoElementSpecifier)
     2743{
     2744    ASSERT(!isPseudoElement());
     2745
     2746    auto* parentStyle = existingComputedStyle();
     2747    ASSERT(parentStyle);
     2748    ASSERT(!parentStyle->getCachedPseudoStyle(pseudoElementSpecifier));
     2749
     2750    auto style = document().styleForElementIgnoringPendingStylesheets(*this, parentStyle, pseudoElementSpecifier);
     2751    if (!style) {
     2752        style = RenderStyle::createPtr();
     2753        style->inheritFrom(*parentStyle);
     2754        style->setStyleType(pseudoElementSpecifier);
     2755    }
     2756
     2757    auto* computedStyle = style.get();
     2758    const_cast<RenderStyle*>(parentStyle)->addCachedPseudoStyle(WTFMove(style));
     2759    return *computedStyle;
     2760}
     2761
    27422762const RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier)
    27432763{
     
    27552775        if (auto* cachedPseudoStyle = style->getCachedPseudoStyle(pseudoElementSpecifier))
    27562776            return cachedPseudoStyle;
     2777        return &resolvePseudoElementStyle(pseudoElementSpecifier);
    27572778    }
    27582779
  • trunk/Source/WebCore/dom/Element.h

    r221464 r221542  
    647647
    648648    const RenderStyle& resolveComputedStyle();
     649    const RenderStyle& resolvePseudoElementStyle(PseudoId);
    649650
    650651    bool rareDataStyleAffectedByEmpty() const;
Note: See TracChangeset for help on using the changeset viewer.