Title: [228683] trunk/Source/WebCore
Revision
228683
Author
za...@apple.com
Date
2018-02-19 07:16:59 -0800 (Mon, 19 Feb 2018)

Log Message

[RenderTreeBuilder] Move RenderElement::removeAndDestroyChild() to RenderTreeBuilder
https://bugs.webkit.org/show_bug.cgi?id=182915
<rdar://problem/37658123>

Reviewed by Antti Koivisto.

No change in functionality.

* rendering/RenderElement.cpp:
(WebCore::RenderElement::removeAndDestroyChild): Deleted.
* rendering/RenderElement.h:
(WebCore::RenderElement::isChildAllowed const):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::removeFromParentAndDestroy):
* rendering/RenderView.cpp:
(WebCore::RenderView::willBeDestroyed):
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::removeAndDestroyChild):
(WebCore::RenderTreeBuilder::removeFromParentAndDestroyCleaningUpAnonymousWrappers):
* rendering/updating/RenderTreeBuilder.h:
* rendering/updating/RenderTreeBuilderFirstLetter.cpp:
(WebCore::RenderTreeBuilder::FirstLetter::updateStyle):
(WebCore::RenderTreeBuilder::FirstLetter::createRenderers):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228682 => 228683)


--- trunk/Source/WebCore/ChangeLog	2018-02-19 15:16:45 UTC (rev 228682)
+++ trunk/Source/WebCore/ChangeLog	2018-02-19 15:16:59 UTC (rev 228683)
@@ -1,3 +1,29 @@
+2018-02-19  Zalan Bujtas  <za...@apple.com>
+
+        [RenderTreeBuilder] Move RenderElement::removeAndDestroyChild() to RenderTreeBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=182915
+        <rdar://problem/37658123>
+
+        Reviewed by Antti Koivisto.
+
+        No change in functionality.
+
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::removeAndDestroyChild): Deleted.
+        * rendering/RenderElement.h:
+        (WebCore::RenderElement::isChildAllowed const):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::removeFromParentAndDestroy):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::willBeDestroyed):
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::RenderTreeBuilder::removeAndDestroyChild):
+        (WebCore::RenderTreeBuilder::removeFromParentAndDestroyCleaningUpAnonymousWrappers):
+        * rendering/updating/RenderTreeBuilder.h:
+        * rendering/updating/RenderTreeBuilderFirstLetter.cpp:
+        (WebCore::RenderTreeBuilder::FirstLetter::updateStyle):
+        (WebCore::RenderTreeBuilder::FirstLetter::createRenderers):
+
 2018-02-12  Sergio Villar Senin  <svil...@igalia.com>
 
         [WebVR][OpenVR] Implement getVRDisplays()

Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (228682 => 228683)


--- trunk/Source/WebCore/rendering/RenderElement.cpp	2018-02-19 15:16:45 UTC (rev 228682)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp	2018-02-19 15:16:59 UTC (rev 228683)
@@ -473,24 +473,6 @@
     SVGRenderSupport::childAdded(*this, child);
 }
 
-void RenderElement::removeAndDestroyChild(RenderTreeBuilder& builder, RenderObject& oldChild)
-{
-    auto toDestroy = builder.takeChild(*this, oldChild);
-    // We need to detach the subtree first so that the descendants don't have
-    // access to previous/next sublings at takeChild().
-    // FIXME: webkit.org/b/182909.
-    if (!is<RenderElement>(toDestroy.get()))
-        return;
-
-    auto& child = downcast<RenderElement>(*toDestroy.get());
-    while (child.firstChild()) {
-        auto& firstChild = *child.firstChild();
-        if (auto* node = firstChild.node())
-            node->setRenderer(nullptr);
-        child.removeAndDestroyChild(builder, firstChild);
-    }
-}
-
 RenderObject* RenderElement::attachRendererInternal(RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     child->setParent(this);

Modified: trunk/Source/WebCore/rendering/RenderElement.h (228682 => 228683)


--- trunk/Source/WebCore/rendering/RenderElement.h	2018-02-19 15:16:45 UTC (rev 228682)
+++ trunk/Source/WebCore/rendering/RenderElement.h	2018-02-19 15:16:59 UTC (rev 228683)
@@ -87,7 +87,6 @@
     bool isRenderInline() const;
 
     virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const { return true; }
-    void removeAndDestroyChild(RenderTreeBuilder&, RenderObject&);
     void didInsertChild(RenderObject& child, RenderObject* beforeChild);
 
     // The following functions are used when the render tree hierarchy changes to make sure layers get

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (228682 => 228683)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2018-02-19 15:16:45 UTC (rev 228682)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2018-02-19 15:16:59 UTC (rev 228683)
@@ -258,7 +258,7 @@
 void RenderObject::removeFromParentAndDestroy(RenderTreeBuilder& builder)
 {
     ASSERT(m_parent);
-    m_parent->removeAndDestroyChild(builder, *this);
+    builder.removeAndDestroyChild(*this);
 }
 
 RenderObject* RenderObject::nextInPreOrder() const

Modified: trunk/Source/WebCore/rendering/RenderView.cpp (228682 => 228683)


--- trunk/Source/WebCore/rendering/RenderView.cpp	2018-02-19 15:16:45 UTC (rev 228682)
+++ trunk/Source/WebCore/rendering/RenderView.cpp	2018-02-19 15:16:59 UTC (rev 228683)
@@ -616,7 +616,7 @@
     RenderBlockFlow::willBeDestroyed(builder);
     // FIXME: This is a workaround for leftover content (see webkit.org/b/182547).
     while (firstChild())
-        removeAndDestroyChild(builder, *firstChild());
+        builder.removeAndDestroyChild(*firstChild());
 
     ASSERT_WITH_MESSAGE(m_rendererCount == 1, "All other renderers in this render tree should have been destroyed");
 }

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (228682 => 228683)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2018-02-19 15:16:45 UTC (rev 228682)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2018-02-19 15:16:59 UTC (rev 228683)
@@ -139,6 +139,25 @@
     s_current = m_previous;
 }
 
+void RenderTreeBuilder::removeAndDestroyChild(RenderObject& child)
+{
+    ASSERT(child.parent());
+    auto toDestroy = takeChild(*child.parent(), child);
+    // We need to detach the subtree first so that the descendants don't have
+    // access to previous/next sublings at takeChild().
+    // FIXME: webkit.org/b/182909.
+    if (!is<RenderElement>(toDestroy.get()))
+        return;
+
+    auto& childToDestroy = downcast<RenderElement>(*toDestroy.get());
+    while (childToDestroy.firstChild()) {
+        auto& firstChild = *childToDestroy.firstChild();
+        if (auto* node = firstChild.node())
+            node->setRenderer(nullptr);
+        removeAndDestroyChild(firstChild);
+    }
+}
+
 void RenderTreeBuilder::insertChild(RenderElement& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     auto insertRecursiveIfNeeded = [&](RenderElement& parentCandidate) {
@@ -639,7 +658,7 @@
         tableBuilder().collapseAndDestroyAnonymousSiblingRows(downcast<RenderTableRow>(destroyRoot));
 
     auto& destroyRootParent = *destroyRoot.parent();
-    destroyRootParent.removeAndDestroyChild(*this, destroyRoot);
+    removeAndDestroyChild(destroyRoot);
     removeAnonymousWrappersForInlineChildrenIfNeeded(destroyRootParent);
 
     // Anonymous parent might have become empty, try to delete it too.

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h (228682 => 228683)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h	2018-02-19 15:16:45 UTC (rev 228682)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h	2018-02-19 15:16:59 UTC (rev 228683)
@@ -44,6 +44,7 @@
     void insertChild(RenderTreePosition&, RenderPtr<RenderObject>);
     void insertChild(RenderElement& parent, RenderPtr<RenderObject>, RenderObject* beforeChild = nullptr);
 
+    void removeAndDestroyChild(RenderObject& child);
     RenderPtr<RenderObject> takeChild(RenderElement&, RenderObject&) WARN_UNUSED_RETURN;
 
     // NormalizeAfterInsertion::Yes ensures that the destination subtree is consistent after the insertion (anonymous wrappers etc).

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp (228682 => 228683)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp	2018-02-19 15:16:45 UTC (rev 228682)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp	2018-02-19 15:16:59 UTC (rev 228683)
@@ -185,7 +185,7 @@
             remainingText->setFirstLetter(*newFirstLetter);
             newFirstLetter->setFirstLetterRemainingText(*remainingText);
         }
-        firstLetterContainer->removeAndDestroyChild(m_builder, *firstLetter);
+        m_builder.removeAndDestroyChild(*firstLetter);
         m_builder.insertChild(*firstLetterContainer, WTFMove(newFirstLetter), nextSibling);
         return;
     }
@@ -241,7 +241,7 @@
 
         auto* textNode = currentTextChild.textNode();
         auto* beforeChild = currentTextChild.nextSibling();
-        firstLetterContainer->removeAndDestroyChild(m_builder, currentTextChild);
+        m_builder.removeAndDestroyChild(currentTextChild);
 
         // Construct a text fragment for the text after the first letter.
         // This text fragment might be empty.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to