Diff
Modified: trunk/Source/WebCore/ChangeLog (226713 => 226714)
--- trunk/Source/WebCore/ChangeLog 2018-01-10 15:29:00 UTC (rev 226713)
+++ trunk/Source/WebCore/ChangeLog 2018-01-10 15:54:31 UTC (rev 226714)
@@ -1,3 +1,36 @@
+2018-01-10 Zalan Bujtas <[email protected]>
+
+ [RenderTreeBuilder] Move RenderRuby's moveChildren logic to RenderTreeBuilder
+ https://bugs.webkit.org/show_bug.cgi?id=181470
+ <rdar://problem/36397683>
+
+ Reviewed by Antti Koivisto.
+
+ This is about moving code, no cleanup and/or normalization (unfortunately it also means
+ some temporary changes).
+
+ No change in functionality.
+
+ * rendering/RenderBlockFlow.h:
+ * rendering/RenderRubyBase.cpp:
+ (WebCore::RenderRubyBase::moveChildren): Deleted.
+ (WebCore::RenderRubyBase::mergeChildrenWithBase): Deleted.
+ (WebCore::RenderRubyBase::moveInlineChildren): Deleted.
+ (WebCore::RenderRubyBase::moveBlockChildren): Deleted.
+ * rendering/RenderRubyBase.h:
+ * rendering/RenderRubyRun.cpp:
+ (WebCore::RenderRubyRun::takeChild):
+ * rendering/updating/RenderTreeBuilder.cpp:
+ (WebCore::RenderTreeBuilder::moveRubyChildren):
+ * rendering/updating/RenderTreeBuilder.h:
+ * rendering/updating/RenderTreeBuilderRuby.cpp:
+ (WebCore::RenderTreeBuilder::Ruby::moveInlineChildren):
+ (WebCore::RenderTreeBuilder::Ruby::moveBlockChildren):
+ (WebCore::RenderTreeBuilder::Ruby::moveChildren):
+ (WebCore::RenderTreeBuilder::Ruby::moveChildrenInternal):
+ (WebCore::RenderTreeBuilder::Ruby::insertChild):
+ * rendering/updating/RenderTreeBuilderRuby.h:
+
2018-01-10 Philippe Normand <[email protected]>
[GStreamer] fix critical GObject warning
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (226713 => 226714)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.h 2018-01-10 15:29:00 UTC (rev 226713)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h 2018-01-10 15:54:31 UTC (rev 226714)
@@ -394,6 +394,8 @@
// column balancer to help set a good minimum column height.
void updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeight);
+ void addFloatsToNewParent(RenderBlockFlow& toBlockFlow) const;
+
protected:
void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const override;
@@ -453,8 +455,6 @@
bool isTopLayoutOverflowAllowed() const override;
bool isLeftLayoutOverflowAllowed() const override;
- void addFloatsToNewParent(RenderBlockFlow& toBlockFlow) const;
-
virtual void computeColumnCountAndWidth();
virtual void cachePriorCharactersIfNeeded(const LazyLineBreakIterator&) {};
Modified: trunk/Source/WebCore/rendering/RenderRubyBase.cpp (226713 => 226714)
--- trunk/Source/WebCore/rendering/RenderRubyBase.cpp 2018-01-10 15:29:00 UTC (rev 226713)
+++ trunk/Source/WebCore/rendering/RenderRubyBase.cpp 2018-01-10 15:54:31 UTC (rev 226714)
@@ -54,84 +54,6 @@
return child.isInline();
}
-void RenderRubyBase::moveChildren(RenderRubyBase* toBase, RenderObject* beforeChild)
-{
- // This function removes all children that are before (!) beforeChild
- // and appends them to toBase.
- ASSERT_ARG(toBase, toBase);
-
- if (beforeChild && beforeChild->parent() != this)
- beforeChild = RenderTreeBuilder::current()->splitAnonymousBoxesAroundChild(*this, beforeChild);
-
- if (childrenInline())
- moveInlineChildren(toBase, beforeChild);
- else
- moveBlockChildren(toBase, beforeChild);
-
- setNeedsLayoutAndPrefWidthsRecalc();
- toBase->setNeedsLayoutAndPrefWidthsRecalc();
-}
-
-void RenderRubyBase::mergeChildrenWithBase(RenderRubyBase& toBlock)
-{
- moveChildren(&toBlock);
- addFloatsToNewParent(toBlock);
-}
-
-void RenderRubyBase::moveInlineChildren(RenderRubyBase* toBase, RenderObject* beforeChild)
-{
- ASSERT(childrenInline());
- ASSERT_ARG(toBase, toBase);
-
- if (!firstChild())
- return;
-
- RenderBlock* toBlock;
- if (toBase->childrenInline()) {
- // The standard and easy case: move the children into the target base
- toBlock = toBase;
- } else {
- // We need to wrap the inline objects into an anonymous block.
- // If toBase has a suitable block, we re-use it, otherwise create a new one.
- RenderObject* lastChild = toBase->lastChild();
- if (lastChild && lastChild->isAnonymousBlock() && lastChild->childrenInline())
- toBlock = downcast<RenderBlock>(lastChild);
- else {
- auto newToBlock = toBase->createAnonymousBlock();
- toBlock = newToBlock.get();
- toBase->insertChildInternal(WTFMove(newToBlock), nullptr);
- }
- }
- // Move our inline children into the target block we determined above.
- moveChildrenTo(toBlock, firstChild(), beforeChild, RenderBoxModelObject::NormalizeAfterInsertion::No);
-}
-
-void RenderRubyBase::moveBlockChildren(RenderRubyBase* toBase, RenderObject* beforeChild)
-{
- ASSERT(!childrenInline());
- ASSERT_ARG(toBase, toBase);
-
- if (!firstChild())
- return;
-
- if (toBase->childrenInline())
- RenderTreeBuilder::current()->makeChildrenNonInline(*toBase);
-
- // If an anonymous block would be put next to another such block, then merge those.
- RenderObject* firstChildHere = firstChild();
- RenderObject* lastChildThere = toBase->lastChild();
- if (firstChildHere->isAnonymousBlock() && firstChildHere->childrenInline()
- && lastChildThere && lastChildThere->isAnonymousBlock() && lastChildThere->childrenInline()) {
- RenderBlock* anonBlockHere = downcast<RenderBlock>(firstChildHere);
- RenderBlock* anonBlockThere = downcast<RenderBlock>(lastChildThere);
- anonBlockHere->moveAllChildrenTo(anonBlockThere, RenderBoxModelObject::NormalizeAfterInsertion::Yes);
- anonBlockHere->deleteLines();
- anonBlockHere->removeFromParentAndDestroy();
- }
- // Move all remaining children normally.
- moveChildrenTo(toBase, firstChild(), beforeChild, RenderBoxModelObject::NormalizeAfterInsertion::No);
-}
-
RenderRubyRun* RenderRubyBase::rubyRun() const
{
ASSERT(parent());
Modified: trunk/Source/WebCore/rendering/RenderRubyBase.h (226713 => 226714)
--- trunk/Source/WebCore/rendering/RenderRubyBase.h 2018-01-10 15:29:00 UTC (rev 226713)
+++ trunk/Source/WebCore/rendering/RenderRubyBase.h 2018-01-10 15:54:31 UTC (rev 226714)
@@ -59,21 +59,12 @@
void cachePriorCharactersIfNeeded(const LazyLineBreakIterator&) override;
- void moveChildren(RenderRubyBase* toBase, RenderObject* beforeChild = 0);
-
private:
bool isRubyBase() const override { return true; }
bool isChildAllowed(const RenderObject&, const RenderStyle&) const override;
ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const override;
void adjustInlineDirectionLineBounds(int expansionOpportunityCount, float& logicalLeft, float& logicalWidth) const override;
- void mergeChildrenWithBase(RenderRubyBase& toBlock);
- void moveInlineChildren(RenderRubyBase* toBase, RenderObject* beforeChild = 0);
- void moveBlockChildren(RenderRubyBase* toBase, RenderObject* beforeChild = 0);
-
- // Allow RenderRubyRun to manipulate the children within ruby bases.
- friend class RenderRubyRun;
-
float m_initialOffset;
unsigned m_isAfterExpansion : 1;
};
Modified: trunk/Source/WebCore/rendering/RenderRubyRun.cpp (226713 => 226714)
--- trunk/Source/WebCore/rendering/RenderRubyRun.cpp 2018-01-10 15:29:00 UTC (rev 226713)
+++ trunk/Source/WebCore/rendering/RenderRubyRun.cpp 2018-01-10 15:54:31 UTC (rev 226714)
@@ -121,7 +121,7 @@
if (rightRun.hasRubyBase()) {
RenderRubyBase* rightBase = rightRun.rubyBaseSafe();
// Collect all children in a single base, then swap the bases.
- rightBase->mergeChildrenWithBase(*base);
+ RenderTreeBuilder::current()->moveRubyChildren(*rightBase, *base);
moveChildTo(&rightRun, base, RenderBoxModelObject::NormalizeAfterInsertion::No);
rightRun.moveChildTo(this, rightBase, RenderBoxModelObject::NormalizeAfterInsertion::No);
// The now empty ruby base will be removed below.
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (226713 => 226714)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2018-01-10 15:29:00 UTC (rev 226713)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2018-01-10 15:54:31 UTC (rev 226714)
@@ -350,6 +350,11 @@
inlineBuilder().splitFlow(parent, beforeChild, WTFMove(newBlockBox), WTFMove(child), oldCont);
}
+void RenderTreeBuilder::moveRubyChildren(RenderRubyBase& from, RenderRubyBase& to)
+{
+ rubyBuilder().moveChildren(from, to);
+}
+
void RenderTreeBuilder::insertChildToRenderBlockFlow(RenderBlockFlow& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
{
blockFlowBuilder().insertChild(parent, WTFMove(child), beforeChild);
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h (226713 => 226714)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h 2018-01-10 15:29:00 UTC (rev 226713)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h 2018-01-10 15:54:31 UTC (rev 226714)
@@ -30,6 +30,7 @@
namespace WebCore {
class RenderMathMLFenced;
+class RenderRubyBase;
class RenderRubyRun;
class RenderSVGContainer;
class RenderSVGInline;
@@ -74,6 +75,7 @@
void makeChildrenNonInline(RenderBlock& parent, RenderObject* insertionPoint = nullptr);
RenderObject* splitAnonymousBoxesAroundChild(RenderBox& parent, RenderObject* beforeChild);
void splitFlow(RenderInline& parent, RenderObject* beforeChild, RenderPtr<RenderBlock> newBlockBox, RenderPtr<RenderObject> child, RenderBoxModelObject* oldCont);
+ void moveRubyChildren(RenderRubyBase& from, RenderRubyBase& to);
private:
class FirstLetter;
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp (226713 => 226714)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp 2018-01-10 15:29:00 UTC (rev 226713)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp 2018-01-10 15:54:31 UTC (rev 226714)
@@ -111,6 +111,80 @@
{
}
+void RenderTreeBuilder::Ruby::moveInlineChildren(RenderRubyBase& from, RenderRubyBase& to, RenderObject* beforeChild)
+{
+ ASSERT(from.childrenInline());
+
+ if (!from.firstChild())
+ return;
+
+ RenderBlock* toBlock = nullptr;
+ if (to.childrenInline()) {
+ // The standard and easy case: move the children into the target base
+ toBlock = &to;
+ } else {
+ // We need to wrap the inline objects into an anonymous block.
+ // If toBase has a suitable block, we re-use it, otherwise create a new one.
+ auto* lastChild = to.lastChild();
+ if (lastChild && lastChild->isAnonymousBlock() && lastChild->childrenInline())
+ toBlock = downcast<RenderBlock>(lastChild);
+ else {
+ auto newToBlock = to.createAnonymousBlock();
+ toBlock = newToBlock.get();
+ to.insertChildInternal(WTFMove(newToBlock), nullptr);
+ }
+ }
+ // Move our inline children into the target block we determined above.
+ from.moveChildrenTo(toBlock, from.firstChild(), beforeChild, RenderBoxModelObject::NormalizeAfterInsertion::No);
+}
+
+void RenderTreeBuilder::Ruby::moveBlockChildren(RenderRubyBase& from, RenderRubyBase& to, RenderObject* beforeChild)
+{
+ ASSERT(!from.childrenInline());
+
+ if (!from.firstChild())
+ return;
+
+ if (to.childrenInline())
+ m_builder.makeChildrenNonInline(to);
+
+ // If an anonymous block would be put next to another such block, then merge those.
+ auto* firstChildHere = from.firstChild();
+ auto* lastChildThere = to.lastChild();
+ if (firstChildHere->isAnonymousBlock() && firstChildHere->childrenInline()
+ && lastChildThere && lastChildThere->isAnonymousBlock() && lastChildThere->childrenInline()) {
+ auto* anonBlockHere = downcast<RenderBlock>(firstChildHere);
+ auto* anonBlockThere = downcast<RenderBlock>(lastChildThere);
+ anonBlockHere->moveAllChildrenTo(anonBlockThere, RenderBoxModelObject::NormalizeAfterInsertion::Yes);
+ anonBlockHere->deleteLines();
+ anonBlockHere->removeFromParentAndDestroy();
+ }
+ // Move all remaining children normally.
+ from.moveChildrenTo(&to, from.firstChild(), beforeChild, RenderBoxModelObject::NormalizeAfterInsertion::No);
+}
+
+void RenderTreeBuilder::Ruby::moveChildren(RenderRubyBase& from, RenderRubyBase& to)
+{
+ moveChildrenInternal(from, to);
+ from.addFloatsToNewParent(to);
+}
+
+void RenderTreeBuilder::Ruby::moveChildrenInternal(RenderRubyBase& from, RenderRubyBase& to, RenderObject* beforeChild)
+{
+ // This function removes all children that are before (!) beforeChild
+ // and appends them to toBase.
+ if (beforeChild && beforeChild->parent() != &from)
+ beforeChild = m_builder.splitAnonymousBoxesAroundChild(from, beforeChild);
+
+ if (from.childrenInline())
+ moveInlineChildren(from, to, beforeChild);
+ else
+ moveBlockChildren(from, to, beforeChild);
+
+ from.setNeedsLayoutAndPrefWidthsRecalc();
+ to.setNeedsLayoutAndPrefWidthsRecalc();
+}
+
void RenderTreeBuilder::Ruby::insertChild(RenderRubyRun& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
{
if (child->isRubyText()) {
@@ -147,7 +221,7 @@
auto& run = *newRun;
m_builder.insertChild(*ruby, WTFMove(newRun), &parent);
m_builder.insertChild(run, WTFMove(child));
- parent.rubyBaseSafe()->moveChildren(run.rubyBaseSafe(), beforeChild);
+ moveChildrenInternal(*parent.rubyBaseSafe(), *run.rubyBaseSafe(), beforeChild);
}
return;
}
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h (226713 => 226714)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h 2018-01-10 15:29:00 UTC (rev 226713)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h 2018-01-10 15:54:31 UTC (rev 226714)
@@ -44,7 +44,13 @@
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);
+ void moveChildrenInternal(RenderRubyBase& from, RenderRubyBase& to, RenderObject* beforeChild = nullptr);
+
RenderTreeBuilder& m_builder;
};