Title: [199004] trunk/Source/WebCore
Revision
199004
Author
[email protected]
Date
2016-04-04 06:40:10 -0700 (Mon, 04 Apr 2016)

Log Message

Avoid double traversal in RenderTreeUpdater for slot roots
https://bugs.webkit.org/show_bug.cgi?id=156110

Reviewed by Andreas Kling.

* style/RenderTreeUpdater.cpp:
(WebCore::hasDisplayContents):
(WebCore::findRenderingRoot):
(WebCore::findRenderingRoots):
(WebCore::RenderTreeUpdater::commit):

    If there are multiple roots that are slots we may end up updating the same rendering root multiple times.
    Fix by deduplicating the roots.

(WebCore::RenderTreeUpdater::updateRenderTree):

    Some cleanups.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (199003 => 199004)


--- trunk/Source/WebCore/ChangeLog	2016-04-04 12:56:33 UTC (rev 199003)
+++ trunk/Source/WebCore/ChangeLog	2016-04-04 13:40:10 UTC (rev 199004)
@@ -1,5 +1,25 @@
 2016-04-04  Antti Koivisto  <[email protected]>
 
+        Avoid double traversal in RenderTreeUpdater for slot roots
+        https://bugs.webkit.org/show_bug.cgi?id=156110
+
+        Reviewed by Andreas Kling.
+
+        * style/RenderTreeUpdater.cpp:
+        (WebCore::hasDisplayContents):
+        (WebCore::findRenderingRoot):
+        (WebCore::findRenderingRoots):
+        (WebCore::RenderTreeUpdater::commit):
+
+            If there are multiple roots that are slots we may end up updating the same rendering root multiple times.
+            Fix by deduplicating the roots.
+
+        (WebCore::RenderTreeUpdater::updateRenderTree):
+
+            Some cleanups.
+
+2016-04-04  Antti Koivisto  <[email protected]>
+
         Enable assertions against DOM mutations in RenderTreeUpdater
         https://bugs.webkit.org/show_bug.cgi?id=156156
 

Modified: trunk/Source/WebCore/style/RenderTreeUpdater.cpp (199003 => 199004)


--- trunk/Source/WebCore/style/RenderTreeUpdater.cpp	2016-04-04 12:56:33 UTC (rev 199003)
+++ trunk/Source/WebCore/style/RenderTreeUpdater.cpp	2016-04-04 13:40:10 UTC (rev 199004)
@@ -61,19 +61,31 @@
 {
 }
 
-static ContainerNode& findRenderingRoot(ContainerNode& node)
+static ContainerNode* findRenderingRoot(ContainerNode& node)
 {
     if (node.renderer())
-        return node;
+        return &node;
     for (auto& ancestor : composedTreeAncestors(node)) {
         if (ancestor.renderer())
-            return ancestor;
-        ASSERT(hasImplicitDisplayContents(ancestor));
+            return &ancestor;
+        if (!hasImplicitDisplayContents(ancestor))
+            return nullptr;
     }
-    ASSERT_NOT_REACHED();
-    return node.document();
+    return &node.document();
 }
 
+static ListHashSet<ContainerNode*> findRenderingRoots(const Style::Update& update)
+{
+    ListHashSet<ContainerNode*> renderingRoots;
+    for (auto* root : update.roots()) {
+        auto* renderingRoot = findRenderingRoot(*root);
+        if (!renderingRoot)
+            continue;
+        renderingRoots.add(renderingRoot);
+    }
+    return renderingRoots;
+}
+
 void RenderTreeUpdater::commit(std::unique_ptr<const Style::Update> styleUpdate)
 {
     ASSERT(&m_document == &styleUpdate->document());
@@ -83,8 +95,8 @@
 
     m_styleUpdate = WTFMove(styleUpdate);
 
-    for (auto* root : m_styleUpdate->roots())
-        updateRenderTree(findRenderingRoot(*root));
+    for (auto* root : findRenderingRoots(*m_styleUpdate))
+        updateRenderTree(*root);
 
     m_styleUpdate = nullptr;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to