Diff
Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog (228688 => 228689)
--- releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog 2018-02-19 16:16:00 UTC (rev 228688)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog 2018-02-19 16:16:07 UTC (rev 228689)
@@ -1,3 +1,29 @@
+2018-02-10 Zalan Bujtas <[email protected]>
+
+ [RenderTreeBuilder] Move RenderBlock::takeChild mutation to a RenderTreeBuilder
+ https://bugs.webkit.org/show_bug.cgi?id=182662
+ <rdar://problem/37408571>
+
+ Reviewed by Simon Fraser.
+
+ No change in functionality.
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::takeChild):
+ (WebCore::canDropAnonymousBlock): Deleted.
+ (WebCore::canMergeContiguousAnonymousBlocks): Deleted.
+ * rendering/RenderBlock.h:
+ (WebCore::RenderBlock::moveAllChildrenIncludingFloatsTo):
+ * rendering/RenderBlockFlow.h:
+ * rendering/updating/RenderTreeBuilder.cpp:
+ (WebCore::RenderTreeBuilder::takenChildFromRenderBlock):
+ * rendering/updating/RenderTreeBuilder.h:
+ * rendering/updating/RenderTreeBuilderBlock.cpp:
+ (WebCore::canDropAnonymousBlock):
+ (WebCore::canMergeContiguousAnonymousBlocks):
+ (WebCore::RenderTreeBuilder::Block::takeChild):
+ * rendering/updating/RenderTreeBuilderBlock.h:
+
2018-02-09 Zalan Bujtas <[email protected]>
[RenderTreeBuilder] Move RenderRubyRun::takeChild mutation to a RenderTreeBuilder
Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/RenderBlock.cpp (228688 => 228689)
--- releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/RenderBlock.cpp 2018-02-19 16:16:00 UTC (rev 228688)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/RenderBlock.cpp 2018-02-19 16:16:07 UTC (rev 228689)
@@ -482,42 +482,6 @@
cache->deferRecomputeIsIgnored(element());
}
-static bool canDropAnonymousBlock(const RenderBlock& anonymousBlock)
-{
- if (anonymousBlock.beingDestroyed() || anonymousBlock.continuation())
- return false;
- if (anonymousBlock.isRubyRun() || anonymousBlock.isRubyBase())
- return false;
- return true;
-}
-
-static bool canMergeContiguousAnonymousBlocks(RenderObject& oldChild, RenderObject* previous, RenderObject* next)
-{
- ASSERT(!oldChild.renderTreeBeingDestroyed());
-
- if (oldChild.isInline())
- return false;
-
- if (is<RenderBoxModelObject>(oldChild) && downcast<RenderBoxModelObject>(oldChild).continuation())
- return false;
-
- if (previous) {
- if (!previous->isAnonymousBlock())
- return false;
- RenderBlock& previousAnonymousBlock = downcast<RenderBlock>(*previous);
- if (!canDropAnonymousBlock(previousAnonymousBlock))
- return false;
- }
- if (next) {
- if (!next->isAnonymousBlock())
- return false;
- RenderBlock& nextAnonymousBlock = downcast<RenderBlock>(*next);
- if (!canDropAnonymousBlock(nextAnonymousBlock))
- return false;
- }
- return true;
-}
-
void RenderBlock::dropAnonymousBoxChild(RenderTreeBuilder& builder, RenderBlock& child)
{
setNeedsLayoutAndPrefWidthsRecalc();
@@ -532,91 +496,7 @@
RenderPtr<RenderObject> RenderBlock::takeChild(RenderTreeBuilder& builder, RenderObject& oldChild)
{
- // No need to waste time in merging or removing empty anonymous blocks.
- // We can just bail out if our document is getting destroyed.
- if (renderTreeBeingDestroyed())
- return RenderBox::takeChild(builder, oldChild);
-
- // If this child is a block, and if our previous and next siblings are both anonymous blocks
- // with inline content, then we can fold the inline content back together.
- RenderObject* prev = oldChild.previousSibling();
- RenderObject* next = oldChild.nextSibling();
- bool canMergeAnonymousBlocks = canMergeContiguousAnonymousBlocks(oldChild, prev, next);
- if (canMergeAnonymousBlocks && prev && next) {
- prev->setNeedsLayoutAndPrefWidthsRecalc();
- RenderBlock& nextBlock = downcast<RenderBlock>(*next);
- RenderBlock& prevBlock = downcast<RenderBlock>(*prev);
-
- if (prev->childrenInline() != next->childrenInline()) {
- RenderBlock& inlineChildrenBlock = prev->childrenInline() ? prevBlock : nextBlock;
- RenderBlock& blockChildrenBlock = prev->childrenInline() ? nextBlock : prevBlock;
-
- // Place the inline children block inside of the block children block instead of deleting it.
- // In order to reuse it, we have to reset it to just be a generic anonymous block. Make sure
- // to clear out inherited column properties by just making a new style, and to also clear the
- // column span flag if it is set.
- ASSERT(!inlineChildrenBlock.continuation());
- // Cache this value as it might get changed in setStyle() call.
- inlineChildrenBlock.setStyle(RenderStyle::createAnonymousStyleWithDisplay(style(), BLOCK));
- auto blockToMove = takeChildInternal(inlineChildrenBlock);
-
- // Now just put the inlineChildrenBlock inside the blockChildrenBlock.
- RenderObject* beforeChild = prev == &inlineChildrenBlock ? blockChildrenBlock.firstChild() : nullptr;
- blockChildrenBlock.insertChildInternal(WTFMove(blockToMove), beforeChild);
- next->setNeedsLayoutAndPrefWidthsRecalc();
-
- // inlineChildrenBlock got reparented to blockChildrenBlock, so it is no longer a child
- // of "this". we null out prev or next so that is not used later in the function.
- if (&inlineChildrenBlock == &prevBlock)
- prev = nullptr;
- else
- next = nullptr;
- } else {
- // Take all the children out of the |next| block and put them in
- // the |prev| block.
- nextBlock.moveAllChildrenIncludingFloatsTo(builder, prevBlock, RenderBoxModelObject::NormalizeAfterInsertion::No);
-
- // Delete the now-empty block's lines and nuke it.
- nextBlock.deleteLines();
- nextBlock.removeFromParentAndDestroy(builder);
- next = nullptr;
- }
- }
-
- invalidateLineLayoutPath();
-
- auto takenChild = RenderBox::takeChild(builder, oldChild);
-
- RenderObject* child = prev ? prev : next;
- if (canMergeAnonymousBlocks && child && !child->previousSibling() && !child->nextSibling() && canDropAnonymousBlockChild()) {
- // The removal has knocked us down to containing only a single anonymous
- // box. We can pull the content right back up into our box.
- dropAnonymousBoxChild(builder, downcast<RenderBlock>(*child));
- } else if (((prev && prev->isAnonymousBlock()) || (next && next->isAnonymousBlock())) && canDropAnonymousBlockChild()) {
- // It's possible that the removal has knocked us down to a single anonymous
- // block with floating siblings.
- RenderBlock& anonBlock = downcast<RenderBlock>((prev && prev->isAnonymousBlock()) ? *prev : *next);
- if (canDropAnonymousBlock(anonBlock)) {
- bool dropAnonymousBlock = true;
- for (auto& sibling : childrenOfType<RenderObject>(*this)) {
- if (&sibling == &anonBlock)
- continue;
- if (!sibling.isFloating()) {
- dropAnonymousBlock = false;
- break;
- }
- }
- if (dropAnonymousBlock)
- dropAnonymousBoxChild(builder, anonBlock);
- }
- }
-
- if (!firstChild()) {
- // If this was our last child be sure to clear out our line boxes.
- if (childrenInline())
- deleteLines();
- }
- return takenChild;
+ return builder.takeChildFromRenderBlock(*this, oldChild);
}
bool RenderBlock::childrenPreventSelfCollapsing() const
Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/RenderBlock.h (228688 => 228689)
--- releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/RenderBlock.h 2018-02-19 16:16:00 UTC (rev 228688)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/RenderBlock.h 2018-02-19 16:16:07 UTC (rev 228689)
@@ -397,6 +397,8 @@
LayoutRect paintRectToClipOutFromBorder(const LayoutRect&) override;
void addChildIgnoringContinuation(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild) override;
bool isInlineBlockOrInlineTable() const final { return isInline() && isReplaced(); }
+ // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
+ virtual void moveAllChildrenIncludingFloatsTo(RenderTreeBuilder& builder, RenderBlock& toBlock, RenderBoxModelObject::NormalizeAfterInsertion normalizeAfterInsertion) { moveAllChildrenTo(builder, &toBlock, normalizeAfterInsertion); }
protected:
virtual void addOverflowFromChildren();
@@ -434,9 +436,6 @@
const char* renderName() const override;
- // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
- virtual void moveAllChildrenIncludingFloatsTo(RenderTreeBuilder& builder, RenderBlock& toBlock, RenderBoxModelObject::NormalizeAfterInsertion normalizeAfterInsertion) { moveAllChildrenTo(builder, &toBlock, normalizeAfterInsertion); }
-
bool isSelfCollapsingBlock() const override;
virtual bool childrenPreventSelfCollapsing() const;
Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/RenderBlockFlow.h (228688 => 228689)
--- releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/RenderBlockFlow.h 2018-02-19 16:16:00 UTC (rev 228688)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/RenderBlockFlow.h 2018-02-19 16:16:07 UTC (rev 228689)
@@ -464,7 +464,8 @@
// Called to lay out the legend for a fieldset or the ruby text of a ruby run. Also used by multi-column layout to handle
// the flow thread child.
void layoutExcludedChildren(bool relayoutChildren) override;
-
+ void moveAllChildrenIncludingFloatsTo(RenderTreeBuilder&, RenderBlock& toBlock, RenderBoxModelObject::NormalizeAfterInsertion) override;
+
private:
bool recomputeLogicalWidthAndColumnWidth();
LayoutUnit columnGap() const;
@@ -476,7 +477,6 @@
void paintInlineChildren(PaintInfo&, const LayoutPoint&) override;
void paintFloats(PaintInfo&, const LayoutPoint&, bool preservePhase = false) override;
- void moveAllChildrenIncludingFloatsTo(RenderTreeBuilder&, RenderBlock& toBlock, RenderBoxModelObject::NormalizeAfterInsertion) override;
void repaintOverhangingFloats(bool paintAllDescendants) final;
void clipOutFloatingObjects(RenderBlock&, const PaintInfo*, const LayoutPoint&, const LayoutSize&) override;
Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (228688 => 228689)
--- releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2018-02-19 16:16:00 UTC (rev 228688)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2018-02-19 16:16:07 UTC (rev 228689)
@@ -485,6 +485,11 @@
return rubyBuilder().takeChild(parent, child);
}
+RenderPtr<RenderObject> RenderTreeBuilder::takeChildFromRenderBlock(RenderBlock& parent, RenderObject& oldChild)
+{
+ return blockBuilder().takeChild(parent, oldChild);
+}
+
void RenderTreeBuilder::updateAfterDescendants(RenderElement& renderer)
{
if (is<RenderBlock>(renderer))
Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilder.h (228688 => 228689)
--- releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilder.h 2018-02-19 16:16:00 UTC (rev 228688)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilder.h 2018-02-19 16:16:07 UTC (rev 228689)
@@ -76,6 +76,7 @@
RenderPtr<RenderObject> takeChildFromRenderRubyAsInline(RenderRubyAsInline& parent, RenderObject& child);
RenderPtr<RenderObject> takeChildFromRenderRubyAsBlock(RenderRubyAsBlock& parent, RenderObject& child);
RenderPtr<RenderObject> takeChildFromRenderRubyRun(RenderRubyRun& parent, RenderObject& child);
+ RenderPtr<RenderObject> takeChildFromRenderBlock(RenderBlock& parent, RenderObject& oldChild);
bool childRequiresTable(const RenderElement& parent, const RenderObject& child);
void makeChildrenNonInline(RenderBlock& parent, RenderObject* insertionPoint = nullptr);
Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilderBlock.cpp (228688 => 228689)
--- releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilderBlock.cpp 2018-02-19 16:16:00 UTC (rev 228688)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilderBlock.cpp 2018-02-19 16:16:07 UTC (rev 228689)
@@ -35,6 +35,42 @@
namespace WebCore {
+static bool canDropAnonymousBlock(const RenderBlock& anonymousBlock)
+{
+ if (anonymousBlock.beingDestroyed() || anonymousBlock.continuation())
+ return false;
+ if (anonymousBlock.isRubyRun() || anonymousBlock.isRubyBase())
+ return false;
+ return true;
+}
+
+static bool canMergeContiguousAnonymousBlocks(RenderObject& oldChild, RenderObject* previous, RenderObject* next)
+{
+ ASSERT(!oldChild.renderTreeBeingDestroyed());
+
+ if (oldChild.isInline())
+ return false;
+
+ if (is<RenderBoxModelObject>(oldChild) && downcast<RenderBoxModelObject>(oldChild).continuation())
+ return false;
+
+ if (previous) {
+ if (!previous->isAnonymousBlock())
+ return false;
+ RenderBlock& previousAnonymousBlock = downcast<RenderBlock>(*previous);
+ if (!canDropAnonymousBlock(previousAnonymousBlock))
+ return false;
+ }
+ if (next) {
+ if (!next->isAnonymousBlock())
+ return false;
+ RenderBlock& nextAnonymousBlock = downcast<RenderBlock>(*next);
+ if (!canDropAnonymousBlock(nextAnonymousBlock))
+ return false;
+ }
+ return true;
+}
+
static RenderBlock* continuationBefore(RenderBlock& parent, RenderObject* beforeChild)
{
if (beforeChild && beforeChild->parent() == &parent)
@@ -228,4 +264,93 @@
// anonymousBlock is dead here.
}
+RenderPtr<RenderObject> RenderTreeBuilder::Block::takeChild(RenderBlock& parent, RenderObject& oldChild)
+{
+ // No need to waste time in merging or removing empty anonymous blocks.
+ // We can just bail out if our document is getting destroyed.
+ if (parent.renderTreeBeingDestroyed())
+ return parent.RenderBox::takeChild(m_builder, oldChild);
+
+ // If this child is a block, and if our previous and next siblings are both anonymous blocks
+ // with inline content, then we can fold the inline content back together.
+ RenderObject* prev = oldChild.previousSibling();
+ RenderObject* next = oldChild.nextSibling();
+ bool canMergeAnonymousBlocks = canMergeContiguousAnonymousBlocks(oldChild, prev, next);
+ if (canMergeAnonymousBlocks && prev && next) {
+ prev->setNeedsLayoutAndPrefWidthsRecalc();
+ RenderBlock& nextBlock = downcast<RenderBlock>(*next);
+ RenderBlock& prevBlock = downcast<RenderBlock>(*prev);
+
+ if (prev->childrenInline() != next->childrenInline()) {
+ RenderBlock& inlineChildrenBlock = prev->childrenInline() ? prevBlock : nextBlock;
+ RenderBlock& blockChildrenBlock = prev->childrenInline() ? nextBlock : prevBlock;
+
+ // Place the inline children block inside of the block children block instead of deleting it.
+ // In order to reuse it, we have to reset it to just be a generic anonymous block. Make sure
+ // to clear out inherited column properties by just making a new style, and to also clear the
+ // column span flag if it is set.
+ ASSERT(!inlineChildrenBlock.continuation());
+ // Cache this value as it might get changed in setStyle() call.
+ inlineChildrenBlock.setStyle(RenderStyle::createAnonymousStyleWithDisplay(parent.style(), BLOCK));
+ auto blockToMove = parent.takeChildInternal(inlineChildrenBlock);
+
+ // Now just put the inlineChildrenBlock inside the blockChildrenBlock.
+ RenderObject* beforeChild = prev == &inlineChildrenBlock ? blockChildrenBlock.firstChild() : nullptr;
+ blockChildrenBlock.insertChildInternal(WTFMove(blockToMove), beforeChild);
+ next->setNeedsLayoutAndPrefWidthsRecalc();
+
+ // inlineChildrenBlock got reparented to blockChildrenBlock, so it is no longer a child
+ // of "this". we null out prev or next so that is not used later in the function.
+ if (&inlineChildrenBlock == &prevBlock)
+ prev = nullptr;
+ else
+ next = nullptr;
+ } else {
+ // Take all the children out of the |next| block and put them in
+ // the |prev| block.
+ nextBlock.moveAllChildrenIncludingFloatsTo(m_builder, prevBlock, RenderBoxModelObject::NormalizeAfterInsertion::No);
+
+ // Delete the now-empty block's lines and nuke it.
+ nextBlock.deleteLines();
+ nextBlock.removeFromParentAndDestroy(m_builder);
+ next = nullptr;
+ }
+ }
+
+ parent.invalidateLineLayoutPath();
+
+ auto takenChild = parent.RenderBox::takeChild(m_builder, oldChild);
+
+ RenderObject* child = prev ? prev : next;
+ if (canMergeAnonymousBlocks && child && !child->previousSibling() && !child->nextSibling() && parent.canDropAnonymousBlockChild()) {
+ // The removal has knocked us down to containing only a single anonymous
+ // box. We can pull the content right back up into our box.
+ parent.dropAnonymousBoxChild(m_builder, downcast<RenderBlock>(*child));
+ } else if (((prev && prev->isAnonymousBlock()) || (next && next->isAnonymousBlock())) && parent.canDropAnonymousBlockChild()) {
+ // It's possible that the removal has knocked us down to a single anonymous
+ // block with floating siblings.
+ RenderBlock& anonBlock = downcast<RenderBlock>((prev && prev->isAnonymousBlock()) ? *prev : *next);
+ if (canDropAnonymousBlock(anonBlock)) {
+ bool dropAnonymousBlock = true;
+ for (auto& sibling : childrenOfType<RenderObject>(parent)) {
+ if (&sibling == &anonBlock)
+ continue;
+ if (!sibling.isFloating()) {
+ dropAnonymousBlock = false;
+ break;
+ }
+ }
+ if (dropAnonymousBlock)
+ parent.dropAnonymousBoxChild(m_builder, anonBlock);
+ }
+ }
+
+ if (!parent.firstChild()) {
+ // If this was our last child be sure to clear out our line boxes.
+ if (parent.childrenInline())
+ parent.deleteLines();
+ }
+ return takenChild;
}
+
+}
Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilderBlock.h (228688 => 228689)
--- releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilderBlock.h 2018-02-19 16:16:00 UTC (rev 228688)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/rendering/updating/RenderTreeBuilderBlock.h 2018-02-19 16:16:07 UTC (rev 228689)
@@ -36,6 +36,8 @@
void insertChild(RenderBlock& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
void insertChildIgnoringContinuation(RenderBlock& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
+ RenderPtr<RenderObject> takeChild(RenderBlock& parent, RenderObject& oldChild);
+
void childBecameNonInline(RenderBlock& parent, RenderElement& child);
private: