Title: [221579] releases/WebKitGTK/webkit-2.18
Revision
221579
Author
[email protected]
Date
2017-09-04 02:14:14 -0700 (Mon, 04 Sep 2017)

Log Message

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

Patch by Emilio Cobos Álvarez <[email protected]> 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:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.18/LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element-expected.txt (221578 => 221579)


--- releases/WebKitGTK/webkit-2.18/LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element-expected.txt	2017-09-04 08:50:04 UTC (rev 221578)
+++ releases/WebKitGTK/webkit-2.18/LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element-expected.txt	2017-09-04 09:14:14 UTC (rev 221579)
@@ -63,6 +63,6 @@
 PASS Expected 'rgb(165, 42, 42)' for color in the computed style for element with id testNoPseudoElement and pseudo-element :garbage and got 'rgb(165, 42, 42)'
 PASS Expected '100px' for height in the computed style for element with id testNoPseudoElement and pseudo-element null and got '100px'
 PASS Expected '100px' for width in the computed style for element with id testNoPseudoElement and pseudo-element null and got '100px'
-PASS Expected '100px' for height in the computed style for element with id testNoPseudoElement and pseudo-element :after and got '100px'
-PASS Expected '100px' for width in the computed style for element with id testNoPseudoElement and pseudo-element :after and got '100px'
+PASS Expected 'auto' for height in the computed style for element with id testNoPseudoElement and pseudo-element :after and got 'auto'
+PASS Expected 'auto' for width in the computed style for element with id testNoPseudoElement and pseudo-element :after and got 'auto'
 PASS Expected '0.5' for opacity in the computed style for element with id testHardwareAcceleratedCompositing and pseudo-element :before and got '0.5'

Modified: releases/WebKitGTK/webkit-2.18/LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element.html (221578 => 221579)


--- releases/WebKitGTK/webkit-2.18/LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element.html	2017-09-04 08:50:04 UTC (rev 221578)
+++ releases/WebKitGTK/webkit-2.18/LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element.html	2017-09-04 09:14:14 UTC (rev 221579)
@@ -180,8 +180,8 @@
         { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : ':garbage', 'property' : 'color', 'expectedValue' : 'rgb(165, 42, 42)' },
         { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : null, 'property' : 'height', 'expectedValue' : '100px' },
         { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : null, 'property' : 'width', 'expectedValue' : '100px' },
-        { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : ':after', 'property' : 'height', 'expectedValue' : '100px' },
-        { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : ':after', 'property' : 'width', 'expectedValue' : '100px' },
+        { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : ':after', 'property' : 'height', 'expectedValue' : 'auto' },
+        { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : ':after', 'property' : 'width', 'expectedValue' : 'auto' },
         { 'elementId' : 'testHardwareAcceleratedCompositing', 'pseudoElement' : ':before', 'property' : 'opacity', 'expectedValue' : '0.5' }
       ];
 

Modified: releases/WebKitGTK/webkit-2.18/LayoutTests/imported/w3c/ChangeLog (221578 => 221579)


--- releases/WebKitGTK/webkit-2.18/LayoutTests/imported/w3c/ChangeLog	2017-09-04 08:50:04 UTC (rev 221578)
+++ releases/WebKitGTK/webkit-2.18/LayoutTests/imported/w3c/ChangeLog	2017-09-04 09:14:14 UTC (rev 221579)
@@ -1,3 +1,12 @@
+2017-09-02  Emilio Cobos Álvarez  <[email protected]>
+
+        Wrong getComputedStyle result for pseudo-elements in display: none subtrees.
+        https://bugs.webkit.org/show_bug.cgi?id=176259
+
+        Reviewed by Antti Koivisto.
+
+        * web-platform-tests/cssom/getComputedStyle-pseudo-expected.txt:
+
 2017-09-01  Emilio Cobos Álvarez  <[email protected]>
 
         Wrong getComputedStyle behavior for pseudo-elements for layout-dependent properties.

Modified: releases/WebKitGTK/webkit-2.18/LayoutTests/imported/w3c/web-platform-tests/cssom/getComputedStyle-pseudo-expected.txt (221578 => 221579)


--- releases/WebKitGTK/webkit-2.18/LayoutTests/imported/w3c/web-platform-tests/cssom/getComputedStyle-pseudo-expected.txt	2017-09-04 08:50:04 UTC (rev 221578)
+++ releases/WebKitGTK/webkit-2.18/LayoutTests/imported/w3c/web-platform-tests/cssom/getComputedStyle-pseudo-expected.txt	2017-09-04 09:14:14 UTC (rev 221579)
@@ -1,6 +1,6 @@
 
 PASS Resolution of width is correct for ::before and ::after pseudo-elements 
-FAIL Resolution of width is correct for ::before and ::after pseudo-elements of display: contents elements assert_equals: expected "50px" but got "auto"
-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"
-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 ""
+FAIL Resolution of width is correct for ::before and ::after pseudo-elements of display: contents elements assert_equals: expected "50px" but got "50%"
+PASS Resolution of nonexistent pseudo-element styles 
+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 "Foo"
 

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog (221578 => 221579)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog	2017-09-04 08:50:04 UTC (rev 221578)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog	2017-09-04 09:14:14 UTC (rev 221579)
@@ -1,3 +1,28 @@
+2017-09-02  Emilio Cobos Álvarez  <[email protected]>
+
+        Wrong getComputedStyle result for pseudo-elements in display: none subtrees.
+        https://bugs.webkit.org/show_bug.cgi?id=176259
+
+        Reviewed by Antti Koivisto.
+
+        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:
+
 2017-09-02  Joseph Pecoraro  <[email protected]>
 
         Performance / PerformanceObserver leaks seen on bots

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Document.cpp (221578 => 221579)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Document.cpp	2017-09-04 08:50:04 UTC (rev 221578)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Document.cpp	2017-09-04 09:14:14 UTC (rev 221579)
@@ -1949,16 +1949,22 @@
     m_ignorePendingStylesheets = oldIgnore;
 }
 
-std::unique_ptr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Element& element, const RenderStyle* parentStyle)
+std::unique_ptr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Element& element, const RenderStyle* parentStyle, PseudoId pseudoElementSpecifier)
 {
     ASSERT(&element.document() == this);
+    ASSERT(!element.isPseudoElement() || !pseudoElementSpecifier);
+    ASSERT(!pseudoElementSpecifier || parentStyle);
 
     // On iOS request delegates called during styleForElement may result in re-entering WebKit and killing the style resolver.
     Style::PostResolutionCallbackDisabler disabler(*this);
 
     SetForScope<bool> change(m_ignorePendingStylesheets, true);
-    auto elementStyle = element.resolveStyle(parentStyle);
+    auto& resolver = element.styleResolver();
 
+    if (pseudoElementSpecifier)
+        return resolver.pseudoStyleForElement(element, PseudoStyleRequest(pseudoElementSpecifier), *parentStyle);
+
+    auto elementStyle = resolver.styleForElement(element, parentStyle);
     if (elementStyle.relations) {
         Style::Update emptyUpdate(*this);
         Style::commitRelations(WTFMove(elementStyle.relations), emptyUpdate);

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Document.h (221578 => 221579)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Document.h	2017-09-04 08:50:04 UTC (rev 221578)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Document.h	2017-09-04 09:14:14 UTC (rev 221579)
@@ -557,7 +557,7 @@
     };
     WEBCORE_EXPORT void updateLayoutIgnorePendingStylesheets(RunPostLayoutTasks = RunPostLayoutTasks::Asynchronously);
 
-    std::unique_ptr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element&, const RenderStyle* parentStyle);
+    std::unique_ptr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element&, const RenderStyle* parentStyle, PseudoId = NOPSEUDO);
 
     // Returns true if page box (margin boxes and page borders) is visible.
     WEBCORE_EXPORT bool isPageBoxVisible(int pageIndex);

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Element.cpp (221578 => 221579)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Element.cpp	2017-09-04 08:50:04 UTC (rev 221578)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Element.cpp	2017-09-04 09:14:14 UTC (rev 221579)
@@ -2759,6 +2759,26 @@
     return *computedStyle;
 }
 
+const RenderStyle& Element::resolvePseudoElementStyle(PseudoId pseudoElementSpecifier)
+{
+    ASSERT(!isPseudoElement());
+
+    auto* parentStyle = existingComputedStyle();
+    ASSERT(parentStyle);
+    ASSERT(!parentStyle->getCachedPseudoStyle(pseudoElementSpecifier));
+
+    auto style = document().styleForElementIgnoringPendingStylesheets(*this, parentStyle, pseudoElementSpecifier);
+    if (!style) {
+        style = RenderStyle::createPtr();
+        style->inheritFrom(*parentStyle);
+        style->setStyleType(pseudoElementSpecifier);
+    }
+
+    auto* computedStyle = style.get();
+    const_cast<RenderStyle*>(parentStyle)->addCachedPseudoStyle(WTFMove(style));
+    return *computedStyle;
+}
+
 const RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier)
 {
     if (!isConnected())
@@ -2774,6 +2794,7 @@
     if (pseudoElementSpecifier) {
         if (auto* cachedPseudoStyle = style->getCachedPseudoStyle(pseudoElementSpecifier))
             return cachedPseudoStyle;
+        return &resolvePseudoElementStyle(pseudoElementSpecifier);
     }
 
     return style;

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Element.h (221578 => 221579)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Element.h	2017-09-04 08:50:04 UTC (rev 221578)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Element.h	2017-09-04 09:14:14 UTC (rev 221579)
@@ -648,6 +648,7 @@
     void removeShadowRoot();
 
     const RenderStyle& resolveComputedStyle();
+    const RenderStyle& resolvePseudoElementStyle(PseudoId);
 
     bool rareDataStyleAffectedByEmpty() const;
     bool rareDataStyleAffectedByFocusWithin() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to