Title: [228687] releases/WebKitGTK/webkit-2.20/Source/WebCore
Revision
228687
Author
carlo...@webkit.org
Date
2018-02-19 08:15:55 -0800 (Mon, 19 Feb 2018)

Log Message

Merge r228339 - [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: releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog (228686 => 228687)


--- releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog	2018-02-19 16:06:10 UTC (rev 228686)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog	2018-02-19 16:15:55 UTC (rev 228687)
@@ -1,5 +1,30 @@
 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  Zalan Bujtas  <za...@apple.com>
+
         [RenderTreeBuilder] Introduce RenderTreeBuilder to willBeDestoryed/removeFromParentAndDestroy
         https://bugs.webkit.org/show_bug.cgi?id=182635
         <rdar://problem/37377489>

Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/RenderRuby.cpp (228686 => 228687)


--- releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/RenderRuby.cpp	2018-02-19 16:06:10 UTC (rev 228686)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/RenderRuby.cpp	2018-02-19 16:15:55 UTC (rev 228687)
@@ -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: releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (228686 => 228687)


--- releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2018-02-19 16:06:10 UTC (rev 228686)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2018-02-19 16:15:55 UTC (rev 228687)
@@ -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: releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilder.h (228686 => 228687)


--- releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilder.h	2018-02-19 16:06:10 UTC (rev 228686)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilder.h	2018-02-19 16:15:55 UTC (rev 228687)
@@ -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: releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp (228686 => 228687)


--- releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp	2018-02-19 16:06:10 UTC (rev 228686)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp	2018-02-19 16:15:55 UTC (rev 228687)
@@ -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: releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h (228686 => 228687)


--- releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h	2018-02-19 16:06:10 UTC (rev 228686)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h	2018-02-19 16:15:55 UTC (rev 228687)
@@ -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