Title: [228339] trunk/Source/WebCore
Revision
228339
Author
za...@apple.com
Date
2018-02-09 15:23:02 -0800 (Fri, 09 Feb 2018)

Log Message

[RenderTreeBuilder] Move RenderRubyAsInline/AsBlock::takeChild mutation to a RenderTreeBuilder
https://bugs.webkit.org/show_bug.cgi?id=182651
<rdar://problem/37405042>

Reviewed by Antti Koivisto.

No change in functionality.

* rendering/RenderRuby.cpp:
(WebCore::RenderRubyAsInline::takeChild):
(WebCore::RenderRubyAsBlock::takeChild):
(WebCore::isAnonymousRubyInlineBlock): Deleted.
(WebCore::isRubyChildForNormalRemoval): Deleted.
(WebCore::findRubyRunParent): Deleted.
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::takeChildFromRenderRubyAsInline):
(WebCore::RenderTreeBuilder::takeChildFromRenderRubyAsBlock):
* rendering/updating/RenderTreeBuilder.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::findRubyRunParent):
(WebCore::RenderTreeBuilder::Ruby::takeChild):
* rendering/updating/RenderTreeBuilderRuby.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228338 => 228339)


--- trunk/Source/WebCore/ChangeLog	2018-02-09 22:13:00 UTC (rev 228338)
+++ trunk/Source/WebCore/ChangeLog	2018-02-09 23:23:02 UTC (rev 228339)
@@ -1,3 +1,28 @@
+2018-02-09  Zalan Bujtas  <za...@apple.com>
+
+        [RenderTreeBuilder] Move RenderRubyAsInline/AsBlock::takeChild mutation to a RenderTreeBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=182651
+        <rdar://problem/37405042>
+
+        Reviewed by Antti Koivisto.
+
+        No change in functionality.
+
+        * rendering/RenderRuby.cpp:
+        (WebCore::RenderRubyAsInline::takeChild):
+        (WebCore::RenderRubyAsBlock::takeChild):
+        (WebCore::isAnonymousRubyInlineBlock): Deleted.
+        (WebCore::isRubyChildForNormalRemoval): Deleted.
+        (WebCore::findRubyRunParent): Deleted.
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::RenderTreeBuilder::takeChildFromRenderRubyAsInline):
+        (WebCore::RenderTreeBuilder::takeChildFromRenderRubyAsBlock):
+        * rendering/updating/RenderTreeBuilder.h:
+        * rendering/updating/RenderTreeBuilderRuby.cpp:
+        (WebCore::findRubyRunParent):
+        (WebCore::RenderTreeBuilder::Ruby::takeChild):
+        * rendering/updating/RenderTreeBuilderRuby.h:
+
 2018-02-09  Per Arne Vollan  <pvol...@apple.com>
 
         Assert that NSApp is not running in the WebProcess.

Modified: trunk/Source/WebCore/rendering/RenderRuby.cpp (228338 => 228339)


--- trunk/Source/WebCore/rendering/RenderRuby.cpp	2018-02-09 22:13:00 UTC (rev 228338)
+++ trunk/Source/WebCore/rendering/RenderRuby.cpp	2018-02-09 23:23:02 UTC (rev 228339)
@@ -45,39 +45,6 @@
 WTF_MAKE_ISO_ALLOCATED_IMPL(RenderRubyAsInline);
 WTF_MAKE_ISO_ALLOCATED_IMPL(RenderRubyAsBlock);
 
-//=== generic helper functions to avoid excessive code duplication ===
-
-static inline bool isAnonymousRubyInlineBlock(const RenderObject* object)
-{
-    ASSERT(!object
-        || !isRuby(object->parent())
-        || is<RenderRubyRun>(*object)
-        || (object->isInline() && (object->isBeforeContent() || object->isAfterContent()))
-        || (object->isAnonymous() && is<RenderBlock>(*object) && object->style().display() == INLINE_BLOCK));
-
-    return object
-        && isRuby(object->parent())
-        && is<RenderBlock>(*object)
-        && !is<RenderRubyRun>(*object);
-}
-
-#ifndef ASSERT_DISABLED
-static inline bool isRubyChildForNormalRemoval(const RenderObject& object)
-{
-    return object.isRubyRun()
-    || object.isBeforeContent()
-    || object.isAfterContent()
-    || object.isRenderMultiColumnFlow()
-    || object.isRenderMultiColumnSet()
-    || isAnonymousRubyInlineBlock(&object);
-}
-#endif
-
-static inline RenderRubyRun& findRubyRunParent(RenderObject& child)
-{
-    return *lineageOfType<RenderRubyRun>(child).first();
-}
-
 //=== ruby as inline object ===
 
 RenderRubyAsInline::RenderRubyAsInline(Element& element, RenderStyle&& style)
@@ -95,26 +62,7 @@
 
 RenderPtr<RenderObject> RenderRubyAsInline::takeChild(RenderTreeBuilder& builder, RenderObject& child)
 {
-    // If the child's parent is *this (must be a ruby run or generated content or anonymous block),
-    // just use the normal remove method.
-    if (child.parent() == this) {
-#ifndef ASSERT_DISABLED
-        ASSERT(isRubyChildForNormalRemoval(child));
-#endif
-        return RenderInline::takeChild(builder, child);
-    }
-    // If the child's parent is an anoymous block (must be generated :before/:after content)
-    // just use the block's remove method.
-    if (isAnonymousRubyInlineBlock(child.parent())) {
-        ASSERT(child.isBeforeContent() || child.isAfterContent());
-        auto& parent = *child.parent();
-        auto takenChild = parent.takeChild(builder, child);
-        parent.removeFromParentAndDestroy(builder);
-        return takenChild;
-    }
-
-    // Otherwise find the containing run and remove it from there.
-    return findRubyRunParent(child).takeChild(builder, child);
+    return builder.takeChildFromRenderRubyAsInline(*this, child);
 }
 
 //=== ruby as block object ===
@@ -134,26 +82,7 @@
 
 RenderPtr<RenderObject> RenderRubyAsBlock::takeChild(RenderTreeBuilder& builder, RenderObject& child)
 {
-    // If the child's parent is *this (must be a ruby run or generated content or anonymous block),
-    // just use the normal remove method.
-    if (child.parent() == this) {
-#ifndef ASSERT_DISABLED
-        ASSERT(isRubyChildForNormalRemoval(child));
-#endif
-        return RenderBlockFlow::takeChild(builder, child);
-    }
-    // If the child's parent is an anoymous block (must be generated :before/:after content)
-    // just use the block's remove method.
-    if (isAnonymousRubyInlineBlock(child.parent())) {
-        ASSERT(child.isBeforeContent() || child.isAfterContent());
-        auto& parent = *child.parent();
-        auto takenChild = parent.takeChild(builder, child);
-        parent.removeFromParentAndDestroy(builder);
-        return takenChild;
-    }
-
-    // Otherwise find the containing run and remove it from there.
-    return findRubyRunParent(child).takeChild(builder, child);
+    return builder.takeChildFromRenderRubyAsBlock(*this, child);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (228338 => 228339)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2018-02-09 22:13:00 UTC (rev 228338)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2018-02-09 23:23:02 UTC (rev 228339)
@@ -470,6 +470,16 @@
     mathMLBuilder().insertChild(parent, WTFMove(child), beforeChild);
 }
 
+RenderPtr<RenderObject> RenderTreeBuilder::takeChildFromRenderRubyAsInline(RenderRubyAsInline& parent, RenderObject& child)
+{
+    return rubyBuilder().takeChild(parent, child);
+}
+
+RenderPtr<RenderObject> RenderTreeBuilder::takeChildFromRenderRubyAsBlock(RenderRubyAsBlock& 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 (228338 => 228339)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h	2018-02-09 22:13:00 UTC (rev 228338)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h	2018-02-09 23:23:02 UTC (rev 228339)
@@ -30,6 +30,8 @@
 namespace WebCore {
 
 class RenderMathMLFenced;
+class RenderRubyAsBlock;
+class RenderRubyAsInline;
 class RenderRubyBase;
 class RenderRubyRun;
 class RenderSVGContainer;
@@ -71,6 +73,9 @@
     void insertChildToRenderTableRow(RenderTableRow& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr);
     void insertChildToRenderMathMLFenced(RenderMathMLFenced& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr);
 
+    RenderPtr<RenderObject> takeChildFromRenderRubyAsInline(RenderRubyAsInline& parent, RenderObject& child);
+    RenderPtr<RenderObject> takeChildFromRenderRubyAsBlock(RenderRubyAsBlock& parent, RenderObject& child);
+
     bool childRequiresTable(const RenderElement& parent, const RenderObject& child);
     void makeChildrenNonInline(RenderBlock& parent, RenderObject* insertionPoint = nullptr);
     RenderObject* splitAnonymousBoxesAroundChild(RenderBox& parent, RenderObject* beforeChild);

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp (228338 => 228339)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp	2018-02-09 22:13:00 UTC (rev 228338)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp	2018-02-09 23:23:02 UTC (rev 228339)
@@ -33,6 +33,11 @@
 
 namespace WebCore {
 
+static inline RenderRubyRun& findRubyRunParent(RenderObject& child)
+{
+    return *lineageOfType<RenderRubyRun>(child).first();
+}
+
 static inline bool isAnonymousRubyInlineBlock(const RenderObject* object)
 {
     ASSERT(!object
@@ -367,4 +372,52 @@
     return *base;
 }
 
+RenderPtr<RenderObject> RenderTreeBuilder::Ruby::takeChild(RenderRubyAsInline& parent, RenderObject& child)
+{
+    // If the child's parent is *this (must be a ruby run or generated content or anonymous block),
+    // just use the normal remove method.
+    if (child.parent() == &parent) {
+#ifndef ASSERT_DISABLED
+        ASSERT(isRubyChildForNormalRemoval(child));
+#endif
+        return parent.RenderInline::takeChild(m_builder, child);
+    }
+    // If the child's parent is an anoymous block (must be generated :before/:after content)
+    // just use the block's remove method.
+    if (isAnonymousRubyInlineBlock(child.parent())) {
+        ASSERT(child.isBeforeContent() || child.isAfterContent());
+        auto& parent = *child.parent();
+        auto takenChild = parent.takeChild(m_builder, child);
+        parent.removeFromParentAndDestroy(m_builder);
+        return takenChild;
+    }
+
+    // Otherwise find the containing run and remove it from there.
+    return findRubyRunParent(child).takeChild(m_builder, child);
 }
+
+RenderPtr<RenderObject> RenderTreeBuilder::Ruby::takeChild(RenderRubyAsBlock& parent, RenderObject& child)
+{
+    // If the child's parent is *this (must be a ruby run or generated content or anonymous block),
+    // just use the normal remove method.
+    if (child.parent() == &parent) {
+#ifndef ASSERT_DISABLED
+        ASSERT(isRubyChildForNormalRemoval(child));
+#endif
+        return parent.RenderBlockFlow::takeChild(m_builder, child);
+    }
+    // If the child's parent is an anoymous block (must be generated :before/:after content)
+    // just use the block's remove method.
+    if (isAnonymousRubyInlineBlock(child.parent())) {
+        ASSERT(child.isBeforeContent() || child.isAfterContent());
+        auto& parent = *child.parent();
+        auto takenChild = parent.takeChild(m_builder, child);
+        parent.removeFromParentAndDestroy(m_builder);
+        return takenChild;
+    }
+
+    // Otherwise find the containing run and remove it from there.
+    return findRubyRunParent(child).takeChild(m_builder, child);
+}
+
+}

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h (228338 => 228339)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h	2018-02-09 22:13:00 UTC (rev 228338)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h	2018-02-09 23:23:02 UTC (rev 228339)
@@ -42,6 +42,9 @@
     Ruby(RenderTreeBuilder&);
 
     void insertChild(RenderRubyRun& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
+    RenderPtr<RenderObject> takeChild(RenderRubyAsInline& parent, RenderObject& child);
+    RenderPtr<RenderObject> takeChild(RenderRubyAsBlock& parent, RenderObject& child);
+
     RenderElement& findOrCreateParentForChild(RenderRubyAsBlock& parent, const RenderObject& child, RenderObject*& beforeChild);
     RenderElement& findOrCreateParentForChild(RenderRubyAsInline& parent, const RenderObject& child, RenderObject*& beforeChild);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to