Share some code to dirty z-order and normal flow lists when child layers are added...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2018 17:25:47 +0000 (17:25 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2018 17:25:47 +0000 (17:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190585

Reviewed by Zalan Bujtas.

Factor code which dirties the normal flow list and child stacking context z-order lists
when a layer is added or removed.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::addChild):
(WebCore::RenderLayer::removeChild):
(WebCore::RenderLayer::dirtyPaintOrderListsOnChildChange):
* rendering/RenderLayer.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237123 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h

index eb60604..08835b1 100644 (file)
@@ -1,5 +1,21 @@
 2018-10-15  Simon Fraser  <simon.fraser@apple.com>
 
+        Share some code to dirty z-order and normal flow lists when child layers are added or removed
+        https://bugs.webkit.org/show_bug.cgi?id=190585
+
+        Reviewed by Zalan Bujtas.
+
+        Factor code which dirties the normal flow list and child stacking context z-order lists
+        when a layer is added or removed.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::addChild):
+        (WebCore::RenderLayer::removeChild):
+        (WebCore::RenderLayer::dirtyPaintOrderListsOnChildChange):
+        * rendering/RenderLayer.h:
+
+2018-10-15  Simon Fraser  <simon.fraser@apple.com>
+
         Make a helper function to check for reflection layers
         https://bugs.webkit.org/show_bug.cgi?id=190584
 
index 6030981..7053498 100644 (file)
@@ -394,15 +394,7 @@ void RenderLayer::addChild(RenderLayer& child, RenderLayer* beforeChild)
 
     child.setParent(this);
 
-    if (child.isNormalFlowOnly())
-        dirtyNormalFlowList();
-
-    if (!child.isNormalFlowOnly() || child.firstChild()) {
-        // Dirty the z-order list in which we are contained. The stackingContext() can be null in the
-        // case where we're building up generated content layers. This is ok, since the lists will start
-        // off dirty in that case anyway.
-        child.dirtyStackingContextZOrderLists();
-    }
+    dirtyPaintOrderListsOnChildChange(child);
 
     child.updateDescendantDependentFlags();
     if (child.m_hasVisibleContent || child.m_hasVisibleDescendant)
@@ -413,7 +405,7 @@ void RenderLayer::addChild(RenderLayer& child, RenderLayer* beforeChild)
 
 #if ENABLE(CSS_COMPOSITING)
     if (child.hasBlendMode() || (child.hasNotIsolatedBlendingDescendants() && !child.isolatesBlending()))
-        updateAncestorChainHasBlendingDescendants();
+        updateAncestorChainHasBlendingDescendants(); // Why not just dirty?
 #endif
 
     compositor().layerWasAdded(*this, child);
@@ -435,14 +427,7 @@ void RenderLayer::removeChild(RenderLayer& oldChild)
     if (m_last == &oldChild)
         m_last = oldChild.previousSibling();
 
-    if (oldChild.isNormalFlowOnly())
-        dirtyNormalFlowList();
-    if (!oldChild.isNormalFlowOnly() || oldChild.firstChild()) {
-        // Dirty the z-order list in which we are contained. When called via the
-        // reattachment process in removeOnlyThisLayer, the layer may already be disconnected
-        // from the main layer tree, so we need to null-check the |stackingContext| value.
-        oldChild.dirtyStackingContextZOrderLists();
-    }
+    dirtyPaintOrderListsOnChildChange(oldChild);
 
     oldChild.setPreviousSibling(nullptr);
     oldChild.setNextSibling(nullptr);
@@ -461,6 +446,19 @@ void RenderLayer::removeChild(RenderLayer& oldChild)
 #endif
 }
 
+void RenderLayer::dirtyPaintOrderListsOnChildChange(RenderLayer& child)
+{
+    if (child.isNormalFlowOnly())
+        dirtyNormalFlowList();
+
+    if (!child.isNormalFlowOnly() || child.firstChild()) {
+        // Dirty the z-order list in which we are contained. The stackingContext() can be null in the
+        // case where we're building up generated content layers. This is ok, since the lists will start
+        // off dirty in that case anyway.
+        child.dirtyStackingContextZOrderLists();
+    }
+}
+
 void RenderLayer::insertOnlyThisLayer()
 {
     if (!m_parent && renderer().parent()) {
index 80f2e8b..3b437ad 100644 (file)
@@ -745,6 +745,8 @@ private:
     void setParent(RenderLayer*);
     void setFirstChild(RenderLayer* first) { m_first = first; }
     void setLastChild(RenderLayer* last) { m_last = last; }
+    
+    void dirtyPaintOrderListsOnChildChange(RenderLayer&);
 
     bool shouldBeNormalFlowOnly() const;
     bool shouldBeStackingContext() const;