Title: [218318] trunk/Source/WebCore
Revision
218318
Author
commit-qu...@webkit.org
Date
2017-06-14 23:58:02 -0700 (Wed, 14 Jun 2017)

Log Message

Don't always recalc the style of display: contents elements.
https://bugs.webkit.org/show_bug.cgi?id=172753

Patch by Emilio Cobos Álvarez <eco...@igalia.com> on 2017-06-15
Reviewed by Antti Koivisto.

No new tests (no functionality change). This only removes an
inefficiency.

* dom/Element.cpp:
(WebCore::Element::existingComputedStyle):
* dom/Element.h:
* style/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::updateRenderTree):
(WebCore::RenderTreeUpdater::updateElementRenderer):
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::resolveElement):
(WebCore::Style::TreeResolver::createAnimatedElementUpdate):
(WebCore::Style::shouldResolveElement):
(WebCore::Style::TreeResolver::resolveComposedTree):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (218317 => 218318)


--- trunk/Source/WebCore/ChangeLog	2017-06-15 06:23:19 UTC (rev 218317)
+++ trunk/Source/WebCore/ChangeLog	2017-06-15 06:58:02 UTC (rev 218318)
@@ -1,3 +1,25 @@
+2017-06-15 Emilio Cobos Álvarez  <eco...@igalia.com>
+
+        Don't always recalc the style of display: contents elements.
+        https://bugs.webkit.org/show_bug.cgi?id=172753
+
+        Reviewed by Antti Koivisto.
+
+        No new tests (no functionality change). This only removes an
+        inefficiency.
+
+        * dom/Element.cpp:
+        (WebCore::Element::existingComputedStyle):
+        * dom/Element.h:
+        * style/RenderTreeUpdater.cpp:
+        (WebCore::RenderTreeUpdater::updateRenderTree):
+        (WebCore::RenderTreeUpdater::updateElementRenderer):
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::resolveElement):
+        (WebCore::Style::TreeResolver::createAnimatedElementUpdate):
+        (WebCore::Style::shouldResolveElement):
+        (WebCore::Style::TreeResolver::resolveComposedTree):
+
 2017-06-14  Antoine Quint  <grao...@apple.com>
 
         Rebaseline media/modern-media-controls/media-documents

Modified: trunk/Source/WebCore/dom/Element.cpp (218317 => 218318)


--- trunk/Source/WebCore/dom/Element.cpp	2017-06-15 06:23:19 UTC (rev 218317)
+++ trunk/Source/WebCore/dom/Element.cpp	2017-06-15 06:58:02 UTC (rev 218318)
@@ -2663,7 +2663,7 @@
     }
 }
 
-const RenderStyle* Element::existingComputedStyle()
+const RenderStyle* Element::existingComputedStyle() const
 {
     if (auto* renderTreeStyle = renderStyle())
         return renderTreeStyle;

Modified: trunk/Source/WebCore/dom/Element.h (218317 => 218318)


--- trunk/Source/WebCore/dom/Element.h	2017-06-15 06:23:19 UTC (rev 218317)
+++ trunk/Source/WebCore/dom/Element.h	2017-06-15 06:58:02 UTC (rev 218318)
@@ -505,6 +505,8 @@
 
     LayoutRect absoluteEventHandlerBounds(bool& includesFixedPositionElements) override;
 
+    const RenderStyle* existingComputedStyle() const;
+
     void setBeforePseudoElement(Ref<PseudoElement>&&);
     void setAfterPseudoElement(Ref<PseudoElement>&&);
     void clearBeforePseudoElement();
@@ -643,7 +645,6 @@
 
     void removeShadowRoot();
 
-    const RenderStyle* existingComputedStyle();
     const RenderStyle& resolveComputedStyle();
 
     bool rareDataStyleAffectedByEmpty() const;

Modified: trunk/Source/WebCore/style/RenderTreeUpdater.cpp (218317 => 218318)


--- trunk/Source/WebCore/style/RenderTreeUpdater.cpp	2017-06-15 06:23:19 UTC (rev 218317)
+++ trunk/Source/WebCore/style/RenderTreeUpdater.cpp	2017-06-15 06:58:02 UTC (rev 218318)
@@ -157,6 +157,8 @@
 
         if (auto* renderer = node.renderer())
             renderTreePosition().invalidateNextSibling(*renderer);
+        else if (is<Element>(node) && downcast<Element>(node).hasDisplayContents())
+            renderTreePosition().invalidateNextSibling();
 
         if (is<Text>(node)) {
             auto& text = downcast<Text>(node);
@@ -170,12 +172,16 @@
         auto& element = downcast<Element>(node);
 
         auto* elementUpdate = m_styleUpdate->elementUpdate(element);
-        if (!elementUpdate) {
+
+        // We hop through display: contents elements in findRenderingRoot, so
+        // there may be other updates down the tree.
+        if (!elementUpdate && !element.hasDisplayContents()) {
             it.traverseNextSkippingChildren();
             continue;
         }
 
-        updateElementRenderer(element, *elementUpdate);
+        if (elementUpdate)
+            updateElementRenderer(element, *elementUpdate);
 
         bool mayHaveRenderedDescendants = element.renderer() || (element.hasDisplayContents() && shouldCreateRenderer(element, renderTreePosition().parent()));
         if (!mayHaveRenderedDescendants) {
@@ -274,8 +280,6 @@
             element.resetComputedStyle();
         else
             element.storeDisplayContentsStyle(RenderStyle::clonePtr(*update.style));
-        // Render tree position needs to be recomputed as rendering siblings may be found from the display:contents subtree.
-        renderTreePosition().invalidateNextSibling();
     }
 
     bool shouldCreateNewRenderer = !element.renderer() && !hasDisplayContents;

Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (218317 => 218318)


--- trunk/Source/WebCore/style/StyleTreeResolver.cpp	2017-06-15 06:23:19 UTC (rev 218317)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp	2017-06-15 06:58:02 UTC (rev 218318)
@@ -179,7 +179,7 @@
     if (!affectsRenderedSubtree(element, *newStyle))
         return { };
 
-    auto* existingStyle = element.renderStyle();
+    auto* existingStyle = element.existingComputedStyle();
 
     if (m_didSeePendingStylesheet && (!existingStyle || existingStyle->isNotFinal())) {
         newStyle->setIsNotFinal();
@@ -248,9 +248,10 @@
         return makeUpdate(WTFMove(newStyle), Detach);
 
     if (!renderer) {
-        auto keepsDisplayContents = newStyle->display() == CONTENTS && element.hasDisplayContents();
-        // Some inherited property might have changed.
-        return makeUpdate(WTFMove(newStyle), keepsDisplayContents ? Inherit : Detach);
+        auto change = Detach;
+        if (auto* oldStyle = element.existingComputedStyle())
+            change = determineChange(*oldStyle, *newStyle);
+        return makeUpdate(WTFMove(newStyle), change);
     }
 
     std::unique_ptr<RenderStyle> animatedStyle;
@@ -331,14 +332,12 @@
     if (parentChange >= Inherit)
         return true;
     if (parentChange == NoInherit) {
-        auto* existingStyle = element.renderStyle();
+        auto* existingStyle = element.existingComputedStyle();
         if (existingStyle && existingStyle->hasExplicitlyInheritedProperties())
             return true;
     }
     if (element.needsStyleRecalc())
         return true;
-    if (element.hasDisplayContents())
-        return true;
     if (shouldResolvePseudoElement(element.beforePseudoElement()))
         return true;
     if (shouldResolvePseudoElement(element.afterPseudoElement()))
@@ -417,7 +416,7 @@
         if (element.needsStyleRecalc() || parent.elementNeedingStyleRecalcAffectsNextSiblingElementStyle)
             parent.elementNeedingStyleRecalcAffectsNextSiblingElementStyle = element.affectsNextSiblingElementStyle();
 
-        auto* style = element.renderStyle();
+        auto* style = element.existingComputedStyle();
         auto change = NoChange;
 
         bool shouldResolve = shouldResolveElement(element, parent.change) || affectedByPreviousSibling;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to