Title: [228345] trunk/Source/WebCore
Revision
228345
Author
za...@apple.com
Date
2018-02-09 16:45:25 -0800 (Fri, 09 Feb 2018)

Log Message

[RenderTreeBuilder] Move RenderRubyRun::takeChild mutation to a RenderTreeBuilder
https://bugs.webkit.org/show_bug.cgi?id=182655
<rdar://problem/37406801>

Reviewed by Simon Fraser.

No change in functionality.

* rendering/RenderRubyRun.cpp:
(WebCore::RenderRubyRun::takeChild):
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::takeChildFromRenderRubyRun):
* rendering/updating/RenderTreeBuilder.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::takeChild):
* rendering/updating/RenderTreeBuilderRuby.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228344 => 228345)


--- trunk/Source/WebCore/ChangeLog	2018-02-10 00:26:50 UTC (rev 228344)
+++ trunk/Source/WebCore/ChangeLog	2018-02-10 00:45:25 UTC (rev 228345)
@@ -1,3 +1,22 @@
+2018-02-09  Zalan Bujtas  <za...@apple.com>
+
+        [RenderTreeBuilder] Move RenderRubyRun::takeChild mutation to a RenderTreeBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=182655
+        <rdar://problem/37406801>
+
+        Reviewed by Simon Fraser.
+
+        No change in functionality.
+
+        * rendering/RenderRubyRun.cpp:
+        (WebCore::RenderRubyRun::takeChild):
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::RenderTreeBuilder::takeChildFromRenderRubyRun):
+        * rendering/updating/RenderTreeBuilder.h:
+        * rendering/updating/RenderTreeBuilderRuby.cpp:
+        (WebCore::RenderTreeBuilder::Ruby::takeChild):
+        * rendering/updating/RenderTreeBuilderRuby.h:
+
 2018-02-09  Andy Estes  <aes...@apple.com>
 
         [Payment Request] Apple Pay sheet does not dismiss when calling complete() with result "unknown" or "fail"

Modified: trunk/Source/WebCore/rendering/RenderRubyRun.cpp (228344 => 228345)


--- trunk/Source/WebCore/rendering/RenderRubyRun.cpp	2018-02-10 00:26:50 UTC (rev 228344)
+++ trunk/Source/WebCore/rendering/RenderRubyRun.cpp	2018-02-10 00:45:25 UTC (rev 228345)
@@ -99,38 +99,7 @@
 
 RenderPtr<RenderObject> RenderRubyRun::takeChild(RenderTreeBuilder& builder, RenderObject& child)
 {
-    // If the child is a ruby text, then merge the ruby base with the base of
-    // the right sibling run, if possible.
-    if (!beingDestroyed() && !renderTreeBeingDestroyed() && child.isRubyText()) {
-        RenderRubyBase* base = rubyBase();
-        RenderObject* rightNeighbour = nextSibling();
-        if (base && is<RenderRubyRun>(rightNeighbour)) {
-            // Ruby run without a base can happen only at the first run.
-            RenderRubyRun& rightRun = downcast<RenderRubyRun>(*rightNeighbour);
-            if (rightRun.hasRubyBase()) {
-                RenderRubyBase* rightBase = rightRun.rubyBase();
-                // Collect all children in a single base, then swap the bases.
-                builder.moveRubyChildren(*rightBase, *base);
-                moveChildTo(builder, &rightRun, base, RenderBoxModelObject::NormalizeAfterInsertion::No);
-                rightRun.moveChildTo(builder, this, rightBase, RenderBoxModelObject::NormalizeAfterInsertion::No);
-                // The now empty ruby base will be removed below.
-                ASSERT(!rubyBase()->firstChild());
-            }
-        }
-    }
-
-    auto takenChild = RenderBlockFlow::takeChild(builder, child);
-
-    if (!beingDestroyed() && !renderTreeBeingDestroyed()) {
-        // Check if our base (if any) is now empty. If so, destroy it.
-        RenderBlock* base = rubyBase();
-        if (base && !base->firstChild()) {
-            auto takenBase = RenderBlockFlow::takeChild(builder, *base);
-            base->deleteLines();
-        }
-    }
-
-    return takenChild;
+    return builder.takeChildFromRenderRubyRun(*this, child);
 }
 
 RenderPtr<RenderRubyBase> RenderRubyRun::createRubyBase() const

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (228344 => 228345)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2018-02-10 00:26:50 UTC (rev 228344)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2018-02-10 00:45:25 UTC (rev 228345)
@@ -480,6 +480,11 @@
     return rubyBuilder().takeChild(parent, child);
 }
 
+RenderPtr<RenderObject> RenderTreeBuilder::takeChildFromRenderRubyRun(RenderRubyRun& parent, RenderObject& child)
+{
+    return rubyBuilder().takeChild(parent, child);
+}
+
 void RenderTreeBuilder::updateAfterDescendants(RenderElement& renderer)
 {
     if (is<RenderBlock>(renderer))

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h (228344 => 228345)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h	2018-02-10 00:26:50 UTC (rev 228344)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h	2018-02-10 00:45:25 UTC (rev 228345)
@@ -75,6 +75,7 @@
 
     RenderPtr<RenderObject> takeChildFromRenderRubyAsInline(RenderRubyAsInline& parent, RenderObject& child);
     RenderPtr<RenderObject> takeChildFromRenderRubyAsBlock(RenderRubyAsBlock& parent, RenderObject& child);
+    RenderPtr<RenderObject> takeChildFromRenderRubyRun(RenderRubyRun& parent, RenderObject& child);
 
     bool childRequiresTable(const RenderElement& parent, const RenderObject& child);
     void makeChildrenNonInline(RenderBlock& parent, RenderObject* insertionPoint = nullptr);

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp (228344 => 228345)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp	2018-02-10 00:26:50 UTC (rev 228344)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp	2018-02-10 00:45:25 UTC (rev 228345)
@@ -420,4 +420,39 @@
     return findRubyRunParent(child).takeChild(m_builder, child);
 }
 
+RenderPtr<RenderObject> RenderTreeBuilder::Ruby::takeChild(RenderRubyRun& parent, RenderObject& child)
+{
+    // If the child is a ruby text, then merge the ruby base with the base of
+    // the right sibling run, if possible.
+    if (!parent.beingDestroyed() && !parent.renderTreeBeingDestroyed() && child.isRubyText()) {
+        RenderRubyBase* base = parent.rubyBase();
+        RenderObject* rightNeighbour = parent.nextSibling();
+        if (base && is<RenderRubyRun>(rightNeighbour)) {
+            // Ruby run without a base can happen only at the first run.
+            RenderRubyRun& rightRun = downcast<RenderRubyRun>(*rightNeighbour);
+            if (rightRun.hasRubyBase()) {
+                RenderRubyBase* rightBase = rightRun.rubyBase();
+                // Collect all children in a single base, then swap the bases.
+                m_builder.moveRubyChildren(*rightBase, *base);
+                parent.moveChildTo(m_builder, &rightRun, base, RenderBoxModelObject::NormalizeAfterInsertion::No);
+                rightRun.moveChildTo(m_builder, &parent, rightBase, RenderBoxModelObject::NormalizeAfterInsertion::No);
+                // The now empty ruby base will be removed below.
+                ASSERT(!parent.rubyBase()->firstChild());
+            }
+        }
+    }
+
+    auto takenChild = parent.RenderBlockFlow::takeChild(m_builder, child);
+
+    if (!parent.beingDestroyed() && !parent.renderTreeBeingDestroyed()) {
+        // Check if our base (if any) is now empty. If so, destroy it.
+        RenderBlock* base = parent.rubyBase();
+        if (base && !base->firstChild()) {
+            auto takenBase = parent.RenderBlockFlow::takeChild(m_builder, *base);
+            base->deleteLines();
+        }
+    }
+    return takenChild;
 }
+
+}

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h (228344 => 228345)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h	2018-02-10 00:26:50 UTC (rev 228344)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h	2018-02-10 00:45:25 UTC (rev 228345)
@@ -44,12 +44,13 @@
     void insertChild(RenderRubyRun& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
     RenderPtr<RenderObject> takeChild(RenderRubyAsInline& parent, RenderObject& child);
     RenderPtr<RenderObject> takeChild(RenderRubyAsBlock& parent, RenderObject& child);
+    RenderPtr<RenderObject> takeChild(RenderRubyRun& parent, RenderObject& child);
 
+    void moveChildren(RenderRubyBase& from, RenderRubyBase& to);
+
     RenderElement& findOrCreateParentForChild(RenderRubyAsBlock& parent, const RenderObject& child, RenderObject*& beforeChild);
     RenderElement& findOrCreateParentForChild(RenderRubyAsInline& parent, const RenderObject& child, RenderObject*& beforeChild);
 
-    void moveChildren(RenderRubyBase& from, RenderRubyBase& to);
-
 private:
     void moveInlineChildren(RenderRubyBase& from, RenderRubyBase& to, RenderObject* beforeChild);
     void moveBlockChildren(RenderRubyBase& from, RenderRubyBase& to, RenderObject* beforeChild);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to