Title: [288000] trunk/Source/WebCore
Revision
288000
Author
simon.fra...@apple.com
Date
2022-01-13 17:15:23 -0800 (Thu, 13 Jan 2022)

Log Message

Move the code that computes layer content visibility into its own function
https://bugs.webkit.org/show_bug.cgi?id=235195

Reviewed by Alan Bujtas.

Just move into its own function the code with the odd-looking RenderObject walk that looks
for visibility:visible non-layer children in a visibility:hidden ancestor.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateDescendantDependentFlags):
(WebCore::RenderLayer::computeHasVisibleContent const):
* rendering/RenderLayer.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287999 => 288000)


--- trunk/Source/WebCore/ChangeLog	2022-01-14 01:01:40 UTC (rev 287999)
+++ trunk/Source/WebCore/ChangeLog	2022-01-14 01:15:23 UTC (rev 288000)
@@ -1,3 +1,18 @@
+2022-01-13  Simon Fraser  <simon.fra...@apple.com>
+
+        Move the code that computes layer content visibility into its own function
+        https://bugs.webkit.org/show_bug.cgi?id=235195
+
+        Reviewed by Alan Bujtas.
+
+        Just move into its own function the code with the odd-looking RenderObject walk that looks
+        for visibility:visible non-layer children in a visibility:hidden ancestor.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateDescendantDependentFlags):
+        (WebCore::RenderLayer::computeHasVisibleContent const):
+        * rendering/RenderLayer.h:
+
 2022-01-13  Elliott Williams  <e...@apple.com>
 
         [XCBuild] Add "product dependencies" which influence workspace build order

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (287999 => 288000)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2022-01-14 01:01:40 UTC (rev 287999)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2022-01-14 01:15:23 UTC (rev 288000)
@@ -1559,35 +1559,39 @@
     }
 
     if (m_visibleContentStatusDirty) {
-        if (renderer().style().visibility() == Visibility::Visible)
-            m_hasVisibleContent = true;
+        m_hasVisibleContent = computeHasVisibleContent();
+        m_visibleContentStatusDirty = false;
+    }
+}
+
+bool RenderLayer::computeHasVisibleContent() const
+{
+    if (renderer().style().visibility() == Visibility::Visible)
+        return true;
+
+    // Layer's renderer has visibility:hidden, but some non-layer child may have visibility:visible.
+    RenderObject* r = renderer().firstChild();
+    while (r) {
+        if (r->style().visibility() == Visibility::Visible && !r->hasLayer())
+            return true;
+
+        RenderObject* child = nullptr;
+        if (!r->hasLayer() && (child = r->firstChildSlow()))
+            r = child;
+        else if (r->nextSibling())
+            r = r->nextSibling();
         else {
-            // layer may be hidden but still have some visible content, check for this
-            m_hasVisibleContent = false;
-            RenderObject* r = renderer().firstChild();
-            while (r) {
-                if (r->style().visibility() == Visibility::Visible && !r->hasLayer()) {
-                    m_hasVisibleContent = true;
-                    break;
-                }
-                RenderObject* child = nullptr;
-                if (!r->hasLayer() && (child = r->firstChildSlow()))
-                    r = child;
-                else if (r->nextSibling())
-                    r = r->nextSibling();
-                else {
-                    do {
-                        r = r->parent();
-                        if (r == &renderer())
-                            r = nullptr;
-                    } while (r && !r->nextSibling());
-                    if (r)
-                        r = r->nextSibling();
-                }
-            }
-        }    
-        m_visibleContentStatusDirty = false; 
+            do {
+                r = r->parent();
+                if (r == &renderer())
+                    r = nullptr;
+            } while (r && !r->nextSibling());
+            if (r)
+                r = r->nextSibling();
+        }
     }
+
+    return false;
 }
 
 void RenderLayer::dirty3DTransformedDescendantStatus()

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (287999 => 288000)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2022-01-14 01:01:40 UTC (rev 287999)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2022-01-14 01:15:23 UTC (rev 288000)
@@ -1033,6 +1033,8 @@
 
     void dirtyAncestorChainVisibleDescendantStatus();
     void setAncestorChainHasVisibleDescendant();
+    
+    bool computeHasVisibleContent() const;
 
     bool has3DTransformedDescendant() const { return m_has3DTransformedDescendant; }
     bool has3DTransformedAncestor() const { return m_has3DTransformedAncestor; }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to