Changeset 228464 in webkit
- Timestamp:
- Feb 14, 2018 9:11:11 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r228453 r228464 1 2018-02-14 Zalan Bujtas <zalan@apple.com> 2 3 [RenderTreeBuilder] Move RenderElement::takeChild() to RenderTreeBuilder 4 https://bugs.webkit.org/show_bug.cgi?id=182762 5 <rdar://problem/37523756> 6 7 Reviewed by Daniel Bates. 8 9 This patch removes the remaining takeChild() related mutation logic from the renderers. 10 11 No change in functionality. 12 13 * rendering/RenderBoxModelObject.cpp: 14 (WebCore::RenderBoxModelObject::moveChildTo): 15 * rendering/RenderElement.cpp: 16 (WebCore::RenderElement::takeChild): Deleted. 17 (WebCore::RenderElement::takeChildInternal): Deleted. 18 * rendering/RenderElement.h: 19 * rendering/RenderObject.h: 20 * rendering/updating/RenderTreeBuilder.cpp: 21 (WebCore::RenderTreeBuilder::takeChild): 22 (WebCore::RenderTreeBuilder::childFlowStateChangesAndAffectsParentBlock): 23 (WebCore::RenderTreeBuilder::takeChildFromRenderElement): 24 * rendering/updating/RenderTreeBuilder.h: 25 * rendering/updating/RenderTreeBuilderBlock.cpp: 26 (WebCore::RenderTreeBuilder::Block::removeLeftoverAnonymousBlock): 27 (WebCore::RenderTreeBuilder::Block::takeChild): 28 (WebCore::RenderTreeBuilder::Block::dropAnonymousBoxChild): 29 * rendering/updating/RenderTreeBuilderInline.cpp: 30 (WebCore::RenderTreeBuilder::Inline::splitFlow): 31 (WebCore::RenderTreeBuilder::Inline::splitInlines): 32 (WebCore::RenderTreeBuilder::Inline::childBecameNonInline): 33 * rendering/updating/RenderTreeBuilderRuby.cpp: 34 (WebCore::RenderTreeBuilder::Ruby::takeChild): 35 * rendering/updating/RenderTreeBuilderSVG.cpp: 36 (WebCore::RenderTreeBuilder::SVG::takeChild): Leftover from the previous patch. 37 1 38 2018-02-13 Antti Koivisto <antti@apple.com> 2 39 -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r228337 r228464 2697 2697 // Takes care of adding the new child correctly if toBlock and fromBlock 2698 2698 // have different kind of children (block vs inline). 2699 auto childToMove = takeChildInternal(*child);2699 auto childToMove = builder.takeChildFromRenderElement(*this, *child); 2700 2700 builder.insertChild(*toBoxModelObject, WTFMove(childToMove), beforeChild); 2701 2701 } else { 2702 auto childToMove = takeChildInternal(*child);2702 auto childToMove = builder.takeChildFromRenderElement(*this, *child); 2703 2703 toBoxModelObject->insertChildInternal(WTFMove(childToMove), beforeChild); 2704 2704 } -
trunk/Source/WebCore/rendering/RenderElement.cpp
r228400 r228464 482 482 } 483 483 484 RenderPtr<RenderObject> RenderElement::takeChild(RenderTreeBuilder&, RenderObject& oldChild)485 {486 return takeChildInternal(oldChild);487 }488 489 484 void RenderElement::removeAndDestroyChild(RenderTreeBuilder& builder, RenderObject& oldChild) 490 485 { … … 581 576 if (hasOutlineAutoAncestor() || outlineStyleForRepaint().outlineStyleIsAuto()) 582 577 newChild->setHasOutlineAutoAncestor(); 583 }584 585 RenderPtr<RenderObject> RenderElement::takeChildInternal(RenderObject& oldChild)586 {587 RELEASE_ASSERT_WITH_MESSAGE(!view().frameView().layoutContext().layoutState(), "Layout must not mutate render tree");588 589 ASSERT(canHaveChildren() || canHaveGeneratedChildren());590 ASSERT(oldChild.parent() == this);591 592 if (oldChild.isFloatingOrOutOfFlowPositioned())593 downcast<RenderBox>(oldChild).removeFloatingOrPositionedChildFromBlockLists();594 595 // So that we'll get the appropriate dirty bit set (either that a normal flow child got yanked or596 // that a positioned child got yanked). We also repaint, so that the area exposed when the child597 // disappears gets repainted properly.598 if (!renderTreeBeingDestroyed() && oldChild.everHadLayout()) {599 oldChild.setNeedsLayoutAndPrefWidthsRecalc();600 // We only repaint |oldChild| if we have a RenderLayer as its visual overflow may not be tracked by its parent.601 if (oldChild.isBody())602 view().repaintRootContents();603 else604 oldChild.repaint();605 }606 607 // If we have a line box wrapper, delete it.608 if (is<RenderBox>(oldChild))609 downcast<RenderBox>(oldChild).deleteLineBoxWrapper();610 else if (is<RenderLineBreak>(oldChild))611 downcast<RenderLineBreak>(oldChild).deleteInlineBoxWrapper();612 613 if (!renderTreeBeingDestroyed() && is<RenderFlexibleBox>(this) && !oldChild.isFloatingOrOutOfFlowPositioned() && oldChild.isBox())614 downcast<RenderFlexibleBox>(this)->clearCachedChildIntrinsicContentLogicalHeight(downcast<RenderBox>(oldChild));615 616 // If oldChild is the start or end of the selection, then clear the selection to617 // avoid problems of invalid pointers.618 if (!renderTreeBeingDestroyed() && oldChild.isSelectionBorder())619 frame().selection().setNeedsSelectionUpdate();620 621 if (!renderTreeBeingDestroyed())622 oldChild.willBeRemovedFromTree();623 624 oldChild.resetFragmentedFlowStateOnRemoval();625 626 // WARNING: There should be no code running between willBeRemovedFromTree and the actual removal below.627 // This is needed to avoid race conditions where willBeRemovedFromTree would dirty the tree's structure628 // and the code running here would force an untimely rebuilding, leaving |oldChild| dangling.629 auto childToTake = detachRendererInternal(oldChild);630 631 // rendererRemovedFromTree walks the whole subtree. We can improve performance632 // by skipping this step when destroying the entire tree.633 if (!renderTreeBeingDestroyed() && is<RenderElement>(*childToTake))634 RenderCounter::rendererRemovedFromTree(downcast<RenderElement>(*childToTake));635 636 if (!renderTreeBeingDestroyed()) {637 if (AXObjectCache* cache = document().existingAXObjectCache())638 cache->childrenChanged(this);639 }640 641 return childToTake;642 578 } 643 579 -
trunk/Source/WebCore/rendering/RenderElement.h
r228337 r228464 90 90 virtual void addChild(RenderTreeBuilder&, RenderPtr<RenderObject>, RenderObject* beforeChild); 91 91 virtual void addChildIgnoringContinuation(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild = nullptr); 92 virtual RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) WARN_UNUSED_RETURN;93 92 void removeAndDestroyChild(RenderTreeBuilder&, RenderObject&); 94 93 … … 102 101 103 102 void insertChildInternal(RenderPtr<RenderObject>, RenderObject* beforeChild); 104 RenderPtr<RenderObject> takeChildInternal(RenderObject&) WARN_UNUSED_RETURN;105 103 106 104 virtual RenderElement* hoverAncestor() const; -
trunk/Source/WebCore/rendering/RenderObject.h
r228337 r228464 777 777 } 778 778 779 virtual void willBeRemovedFromTree(); 780 void resetFragmentedFlowStateOnRemoval(); 781 779 782 protected: 780 783 ////////////////////////////////////////// … … 792 795 793 796 virtual void insertedIntoTree(); 794 virtual void willBeRemovedFromTree();795 797 796 798 void setNeedsPositionedMovementLayoutBit(bool b) { m_bitfields.setNeedsPositionedMovementLayout(b); } … … 803 805 804 806 void initializeFragmentedFlowStateOnInsertion(); 805 void resetFragmentedFlowStateOnRemoval();806 807 static FragmentedFlowState computedFragmentedFlowState(const RenderObject&); 807 808 -
trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp
r228441 r228464 27 27 #include "RenderTreeBuilder.h" 28 28 29 #include "AXObjectCache.h" 30 #include "Frame.h" 31 #include "FrameSelection.h" 29 32 #include "RenderButton.h" 33 #include "RenderCounter.h" 30 34 #include "RenderElement.h" 31 35 #include "RenderGrid.h" 36 #include "RenderLineBreak.h" 32 37 #include "RenderMenuList.h" 33 38 #include "RenderRuby.h" … … 231 236 return blockBuilder().takeChild(downcast<RenderBlock>(parent), child); 232 237 233 return parent.takeChild(*this, child);238 return takeChildFromRenderElement(parent, child); 234 239 } 235 240 … … 360 365 auto& block = *newBlock; 361 366 parent->insertChildInternal(WTFMove(newBlock), &child); 362 auto thisToMove = parent->takeChildInternal(child);367 auto thisToMove = takeChildFromRenderElement(*parent, child); 363 368 block.insertChildInternal(WTFMove(thisToMove), nullptr); 364 369 } … … 564 569 } 565 570 566 } 571 RenderPtr<RenderObject> RenderTreeBuilder::takeChildFromRenderElement(RenderElement& parent, RenderObject& child) 572 { 573 RELEASE_ASSERT_WITH_MESSAGE(!parent.view().frameView().layoutContext().layoutState(), "Layout must not mutate render tree"); 574 575 ASSERT(parent.canHaveChildren() || parent.canHaveGeneratedChildren()); 576 ASSERT(child.parent() == &parent); 577 578 if (child.isFloatingOrOutOfFlowPositioned()) 579 downcast<RenderBox>(child).removeFloatingOrPositionedChildFromBlockLists(); 580 581 // So that we'll get the appropriate dirty bit set (either that a normal flow child got yanked or 582 // that a positioned child got yanked). We also repaint, so that the area exposed when the child 583 // disappears gets repainted properly. 584 if (!parent.renderTreeBeingDestroyed() && child.everHadLayout()) { 585 child.setNeedsLayoutAndPrefWidthsRecalc(); 586 // We only repaint |child| if we have a RenderLayer as its visual overflow may not be tracked by its parent. 587 if (child.isBody()) 588 parent.view().repaintRootContents(); 589 else 590 child.repaint(); 591 } 592 593 // If we have a line box wrapper, delete it. 594 if (is<RenderBox>(child)) 595 downcast<RenderBox>(child).deleteLineBoxWrapper(); 596 else if (is<RenderLineBreak>(child)) 597 downcast<RenderLineBreak>(child).deleteInlineBoxWrapper(); 598 599 if (!parent.renderTreeBeingDestroyed() && is<RenderFlexibleBox>(parent) && !child.isFloatingOrOutOfFlowPositioned() && child.isBox()) 600 downcast<RenderFlexibleBox>(parent).clearCachedChildIntrinsicContentLogicalHeight(downcast<RenderBox>(child)); 601 602 // If child is the start or end of the selection, then clear the selection to 603 // avoid problems of invalid pointers. 604 if (!parent.renderTreeBeingDestroyed() && child.isSelectionBorder()) 605 parent.frame().selection().setNeedsSelectionUpdate(); 606 607 if (!parent.renderTreeBeingDestroyed()) 608 child.willBeRemovedFromTree(); 609 610 child.resetFragmentedFlowStateOnRemoval(); 611 612 // WARNING: There should be no code running between willBeRemovedFromTree() and the actual removal below. 613 // This is needed to avoid race conditions where willBeRemovedFromTree() would dirty the tree's structure 614 // and the code running here would force an untimely rebuilding, leaving |child| dangling. 615 auto childToTake = parent.detachRendererInternal(child); 616 617 // rendererRemovedFromTree() walks the whole subtree. We can improve performance 618 // by skipping this step when destroying the entire tree. 619 if (!parent.renderTreeBeingDestroyed() && is<RenderElement>(*childToTake)) 620 RenderCounter::rendererRemovedFromTree(downcast<RenderElement>(*childToTake)); 621 622 if (!parent.renderTreeBeingDestroyed()) { 623 if (AXObjectCache* cache = parent.document().existingAXObjectCache()) 624 cache->childrenChanged(&parent); 625 } 626 627 return childToTake; 628 } 629 630 631 } -
trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h
r228441 r228464 79 79 void insertChildToRenderMathMLFenced(RenderMathMLFenced& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr); 80 80 81 RenderPtr<RenderObject> takeChildFromRenderElement(RenderElement& parent, RenderObject& child) WARN_UNUSED_RETURN; 82 81 83 bool childRequiresTable(const RenderElement& parent, const RenderObject& child); 82 84 void makeChildrenNonInline(RenderBlock& parent, RenderObject* insertionPoint = nullptr); -
trunk/Source/WebCore/rendering/updating/RenderTreeBuilderBlock.cpp
r228441 r228464 262 262 // FIXME: This should really just be a moveAllChilrenTo (see webkit.org/b/182495) 263 263 anonymousBlock.moveAllChildrenToInternal(*parent); 264 auto toBeDestroyed = parent->takeChildInternal(anonymousBlock);264 auto toBeDestroyed = m_builder.takeChildFromRenderElement(*parent, anonymousBlock); 265 265 // anonymousBlock is dead here. 266 266 } … … 271 271 // We can just bail out if our document is getting destroyed. 272 272 if (parent.renderTreeBeingDestroyed()) 273 return parent.RenderBox::takeChild(m_builder, oldChild);273 return m_builder.takeChildFromRenderElement(parent, oldChild); 274 274 275 275 // If this child is a block, and if our previous and next siblings are both anonymous blocks … … 294 294 // Cache this value as it might get changed in setStyle() call. 295 295 inlineChildrenBlock.setStyle(RenderStyle::createAnonymousStyleWithDisplay(parent.style(), BLOCK)); 296 auto blockToMove = parent.takeChildInternal(inlineChildrenBlock);296 auto blockToMove = m_builder.takeChildFromRenderElement(parent, inlineChildrenBlock); 297 297 298 298 // Now just put the inlineChildrenBlock inside the blockChildrenBlock. … … 321 321 parent.invalidateLineLayoutPath(); 322 322 323 auto takenChild = parent.RenderBox::takeChild(m_builder, oldChild);323 auto takenChild = m_builder.takeChildFromRenderElement(parent, oldChild); 324 324 325 325 RenderObject* child = prev ? prev : next; … … 361 361 auto* nextSibling = child.nextSibling(); 362 362 363 auto toBeDeleted = parent.takeChildInternal(child);363 auto toBeDeleted = m_builder.takeChildFromRenderElement(parent, child); 364 364 child.moveAllChildrenTo(m_builder, &parent, nextSibling, RenderBoxModelObject::NormalizeAfterInsertion::No); 365 365 // Delete the now-empty block's lines and nuke it. -
trunk/Source/WebCore/rendering/updating/RenderTreeBuilderInline.cpp
r227903 r228464 236 236 RenderObject* no = o; 237 237 o = no->nextSibling(); 238 auto childToMove = block->takeChildInternal(*no);238 auto childToMove = m_builder.takeChildFromRenderElement(*block, *no); 239 239 pre->insertChildInternal(WTFMove(childToMove), nullptr); 240 240 no->setNeedsLayoutAndPrefWidthsRecalc(); … … 306 306 // every time, which is a bit wasteful. 307 307 } 308 auto childToMove = rendererToMove->parent()->takeChildInternal(*rendererToMove);308 auto childToMove = m_builder.takeChildFromRenderElement(*rendererToMove->parent(), *rendererToMove); 309 309 cloneInline->addChildIgnoringContinuation(m_builder, WTFMove(childToMove)); 310 310 rendererToMove->setNeedsLayoutAndPrefWidthsRecalc(); … … 344 344 for (auto* sibling = currentChild->nextSibling(); sibling;) { 345 345 auto* next = sibling->nextSibling(); 346 auto childToMove = current->takeChildInternal(*sibling);346 auto childToMove = m_builder.takeChildFromRenderElement(*current, *sibling); 347 347 cloneInline->addChildIgnoringContinuation(m_builder, WTFMove(childToMove)); 348 348 sibling->setNeedsLayoutAndPrefWidthsRecalc(); … … 368 368 for (auto* current = currentChild->nextSibling(); current;) { 369 369 auto* next = current->nextSibling(); 370 auto childToMove = fromBlock->takeChildInternal(*current);370 auto childToMove = m_builder.takeChildFromRenderElement(*fromBlock, *current); 371 371 toBlock->insertChildInternal(WTFMove(childToMove), nullptr); 372 372 current = next; … … 390 390 newBox->insertIntoContinuationChainAfter(parent); 391 391 auto* beforeChild = child.nextSibling(); 392 auto removedChild = parent.takeChildInternal(child);392 auto removedChild = m_builder.takeChildFromRenderElement(parent, child); 393 393 splitFlow(parent, beforeChild, WTFMove(newBox), WTFMove(removedChild), oldContinuation); 394 394 } -
trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp
r228432 r228464 383 383 ASSERT(isRubyChildForNormalRemoval(child)); 384 384 #endif 385 return parent.RenderInline::takeChild(m_builder, child);385 return m_builder.takeChildFromRenderElement(parent, child); 386 386 } 387 387 // If the child's parent is an anoymous block (must be generated :before/:after content) -
trunk/Source/WebCore/rendering/updating/RenderTreeBuilderSVG.cpp
r228429 r228464 79 79 Vector<SVGTextLayoutAttributes*, 2> affectedAttributes; 80 80 parent.subtreeChildWillBeRemoved(&child, affectedAttributes); 81 auto takenChild = parent.RenderBlockFlow::takeChild(m_builder, child);81 auto takenChild = m_builder.blockBuilder().takeChild(parent, child); 82 82 parent.subtreeChildWasRemoved(affectedAttributes); 83 83 return takenChild; … … 90 90 auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(parent); 91 91 if (!textAncestor) 92 return parent.RenderElement::takeChild(m_builder, child);92 return m_builder.takeChildFromRenderElement(parent, child); 93 93 94 94 Vector<SVGTextLayoutAttributes*, 2> affectedAttributes; 95 95 textAncestor->subtreeChildWillBeRemoved(&child, affectedAttributes); 96 auto takenChild = parent.RenderElement::takeChild(m_builder, child);96 auto takenChild = m_builder.takeChildFromRenderElement(parent, child); 97 97 textAncestor->subtreeChildWasRemoved(affectedAttributes); 98 98 return takenChild; … … 102 102 { 103 103 SVGResourcesCache::clientWillBeRemovedFromTree(child); 104 return parent.RenderElement::takeChild(m_builder, child);104 return m_builder.takeChildFromRenderElement(parent, child); 105 105 } 106 106 … … 108 108 { 109 109 SVGResourcesCache::clientWillBeRemovedFromTree(child); 110 return parent.RenderElement::takeChild(m_builder, child);110 return m_builder.takeChildFromRenderElement(parent, child); 111 111 } 112 112
Note: See TracChangeset
for help on using the changeset viewer.