Changeset 208005 in webkit
- Timestamp:
- Oct 27, 2016 2:19:34 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r208003 r208005 1 2016-10-27 Zalan Bujtas <zalan@apple.com> 2 3 RenderMultiColumnFlowThread::processPossibleSpannerDescendant should take RenderObject& instead of RenderObject* 4 https://bugs.webkit.org/show_bug.cgi?id=164072 5 6 Reviewed by Simon Fraser. 7 8 No change in functionality. 9 10 * rendering/RenderFlowThread.h: 11 * rendering/RenderMultiColumnFlowThread.cpp: 12 (WebCore::findSetRendering): 13 (WebCore::isValidColumnSpanner): 14 (WebCore::RenderMultiColumnFlowThread::processPossibleSpannerDescendant): 15 (WebCore::RenderMultiColumnFlowThread::flowThreadDescendantInserted): 16 (WebCore::RenderMultiColumnFlowThread::findSetRendering): Deleted. 17 * rendering/RenderMultiColumnFlowThread.h: 18 * rendering/RenderMultiColumnSet.cpp: 19 (WebCore::precedesRenderer): 20 (WebCore::RenderMultiColumnSet::containsRendererInFlowThread): 21 * rendering/RenderMultiColumnSet.h: 22 * rendering/RenderMultiColumnSpannerPlaceholder.cpp: 23 (WebCore::RenderMultiColumnSpannerPlaceholder::createAnonymous): 24 (WebCore::RenderMultiColumnSpannerPlaceholder::RenderMultiColumnSpannerPlaceholder): 25 * rendering/RenderMultiColumnSpannerPlaceholder.h: 26 * rendering/RenderObject.cpp: 27 (WebCore::RenderObject::insertedIntoTree): 28 1 29 2016-10-27 Brent Fulgham <bfulgham@apple.com> 2 30 -
trunk/Source/WebCore/rendering/RenderFlowThread.h
r206049 r208005 93 93 virtual RenderObject* resolveMovedChild(RenderObject* child) const { return child; } 94 94 // Called when a descendant of the flow thread has been inserted. 95 virtual void flowThreadDescendantInserted(RenderObject *) { }95 virtual void flowThreadDescendantInserted(RenderObject&) { } 96 96 // Called when a sibling or descendant of the flow thread is about to be removed. 97 97 virtual void flowThreadRelativeWillBeRemoved(RenderObject*) { } -
trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp
r207930 r208005 134 134 } 135 135 136 RenderMultiColumnSet* RenderMultiColumnFlowThread::findSetRendering(RenderObject* renderer) const 137 { 138 for (RenderMultiColumnSet* multicolSet = firstMultiColumnSet(); multicolSet; multicolSet = multicolSet->nextSiblingMultiColumnSet()) { 136 static RenderMultiColumnSet* findSetRendering(const RenderMultiColumnFlowThread& flowThread, const RenderObject& renderer) 137 { 138 // Find the set inside which the specified renderer would be rendered. 139 for (auto* multicolSet = flowThread.firstMultiColumnSet(); multicolSet; multicolSet = multicolSet->nextSiblingMultiColumnSet()) { 139 140 if (multicolSet->containsRendererInFlowThread(renderer)) 140 141 return multicolSet; … … 234 235 } 235 236 236 static bool isValidColumnSpanner( RenderMultiColumnFlowThread* flowThread, RenderObject*descendant)237 static bool isValidColumnSpanner(const RenderMultiColumnFlowThread& flowThread, const RenderObject& descendant) 237 238 { 238 239 // We assume that we're inside the flow thread. This function is not to be called otherwise. 239 ASSERT(descendant ->isDescendantOf(flowThread));240 ASSERT(descendant.isDescendantOf(&flowThread)); 240 241 241 242 // First make sure that the renderer itself has the right properties for becoming a spanner. 242 auto& style = descendant ->style();243 if (style.columnSpan() != ColumnSpanAll || !is<RenderBox>( *descendant) || descendant->isFloatingOrOutOfFlowPositioned())243 auto& style = descendant.style(); 244 if (style.columnSpan() != ColumnSpanAll || !is<RenderBox>(descendant) || descendant.isFloatingOrOutOfFlowPositioned()) 244 245 return false; 245 246 246 RenderElement* container = descendant ->parent();247 RenderElement* container = descendant.parent(); 247 248 if (!is<RenderBlockFlow>(*container) || container->childrenInline()) { 248 249 // Needs to be block-level. … … 251 252 252 253 // We need to have the flow thread as the containing block. A spanner cannot break out of the flow thread. 253 RenderFlowThread* enclosingFlowThread = descendant ->flowThreadContainingBlock();254 if (enclosingFlowThread != flowThread)254 RenderFlowThread* enclosingFlowThread = descendant.flowThreadContainingBlock(); 255 if (enclosingFlowThread != &flowThread) 255 256 return false; 256 257 257 258 // This looks like a spanner, but if we're inside something unbreakable, it's not to be treated as one. 258 for ( RenderBox* ancestor = downcast<RenderBox>(*descendant).containingBlock(); ancestor && !is<RenderView>(*ancestor); ancestor = ancestor->containingBlock()) {259 for (auto* ancestor = downcast<RenderBox>(descendant).containingBlock(); ancestor && !is<RenderView>(*ancestor); ancestor = ancestor->containingBlock()) { 259 260 if (ancestor->isRenderFlowThread()) { 260 261 // Don't allow any intervening non-multicol fragmentation contexts. The spec doesn't say 261 262 // anything about disallowing this, but it's just going to be too complicated to 262 263 // implement (not to mention specify behavior). 263 return ancestor == flowThread;264 } 265 ASSERT(ancestor->style().columnSpan() != ColumnSpanAll || !isValidColumnSpanner(flowThread, ancestor));264 return ancestor == &flowThread; 265 } 266 ASSERT(ancestor->style().columnSpan() != ColumnSpanAll || !isValidColumnSpanner(flowThread, *ancestor)); 266 267 if (ancestor->isUnsplittableForPagination()) 267 268 return false; … … 295 296 } 296 297 297 RenderObject* RenderMultiColumnFlowThread::processPossibleSpannerDescendant(RenderObject*& subtreeRoot, RenderObject *descendant)298 RenderObject* RenderMultiColumnFlowThread::processPossibleSpannerDescendant(RenderObject*& subtreeRoot, RenderObject& descendant) 298 299 { 299 300 RenderBlockFlow* multicolContainer = multiColumnBlockFlow(); 300 RenderObject* nextRendererInFlowThread = spannerPlacehoderCandidate( *descendant, *this);301 RenderObject* nextRendererInFlowThread = spannerPlacehoderCandidate(descendant, *this); 301 302 RenderObject* insertBeforeMulticolChild = nullptr; 302 RenderObject* nextDescendant = descendant;303 304 if (isValidColumnSpanner( this, descendant)) {303 RenderObject* nextDescendant = &descendant; 304 305 if (isValidColumnSpanner(*this, descendant)) { 305 306 // This is a spanner (column-span:all). Such renderers are moved from where they would 306 307 // otherwise occur in the render tree to becoming a direct child of the multicol container, … … 308 309 // basically just relies on regular block layout done by the RenderBlockFlow that 309 310 // establishes the multicol container. 310 RenderBlockFlow* container = downcast<RenderBlockFlow>(descendant ->parent());311 RenderBlockFlow* container = downcast<RenderBlockFlow>(descendant.parent()); 311 312 RenderMultiColumnSet* setToSplit = nullptr; 312 313 if (nextRendererInFlowThread) { 313 setToSplit = findSetRendering( descendant);314 setToSplit = findSetRendering(*this, descendant); 314 315 if (setToSplit) { 315 316 setToSplit->setNeedsLayout(); … … 323 324 // this placeholder serves as a break point for column sets, so that, when encountered, we 324 325 // end flowing one column set and move to the next one. 325 RenderMultiColumnSpannerPlaceholder* placeholder = RenderMultiColumnSpannerPlaceholder::createAnonymous(this, downcast<RenderBox>(descendant), &container->style()); 326 container->addChild(placeholder, descendant->nextSibling()); 327 container->removeChild(*descendant); 326 RenderMultiColumnSpannerPlaceholder* placeholder = RenderMultiColumnSpannerPlaceholder::createAnonymous(this, 327 downcast<RenderBox>(descendant), &container->style()); 328 container->addChild(placeholder, descendant.nextSibling()); 329 container->removeChild(descendant); 328 330 329 331 // This is a guard to stop an ancestor flow thread from processing the spanner. 330 332 gShiftingSpanner = true; 331 multicolContainer->RenderBlock::addChild( descendant, insertBeforeMulticolChild);333 multicolContainer->RenderBlock::addChild(&descendant, insertBeforeMulticolChild); 332 334 gShiftingSpanner = false; 333 335 … … 336 338 // creation of column sets or anything like that. Continue at its original position in 337 339 // the tree, i.e. where the placeholder was just put. 338 if (subtreeRoot == descendant)340 if (subtreeRoot == &descendant) 339 341 subtreeRoot = placeholder; 340 342 nextDescendant = placeholder; … … 376 378 } 377 379 378 void RenderMultiColumnFlowThread::flowThreadDescendantInserted(RenderObject * descendant)379 { 380 if (gShiftingSpanner || m_beingEvacuated || descendant->isInFlowRenderFlowThread())380 void RenderMultiColumnFlowThread::flowThreadDescendantInserted(RenderObject& newDescendant) 381 { 382 if (gShiftingSpanner || m_beingEvacuated || newDescendant.isInFlowRenderFlowThread()) 381 383 return; 382 RenderObject* subtreeRoot = descendant;383 for ( ; descendant; descendant = (descendant ? descendant->nextInPreOrder(subtreeRoot) : nullptr)) {384 RenderObject* subtreeRoot = &newDescendant; 385 for (auto* descendant = &newDescendant; descendant; descendant = (descendant ? descendant->nextInPreOrder(subtreeRoot) : nullptr)) { 384 386 if (is<RenderMultiColumnSpannerPlaceholder>(*descendant)) { 385 387 // A spanner's placeholder has been inserted. The actual spanner renderer is moved from … … 407 409 subtreeRoot = spanner; 408 410 // Now we process the spanner. 409 descendant = processPossibleSpannerDescendant(subtreeRoot, spanner);411 descendant = processPossibleSpannerDescendant(subtreeRoot, *spanner); 410 412 continue; 411 413 } … … 416 418 continue; 417 419 } 418 419 descendant = processPossibleSpannerDescendant(subtreeRoot, descendant); 420 descendant = processPossibleSpannerDescendant(subtreeRoot, *descendant); 420 421 } 421 422 } -
trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h
r200041 r208005 53 53 54 54 void layout() override; 55 56 // Find the set inside which the specified renderer would be rendered.57 RenderMultiColumnSet* findSetRendering(RenderObject*) const;58 55 59 56 // Populate the flow thread with what's currently its siblings. Called when a regular block … … 117 114 void willBeRemovedFromTree() override; 118 115 RenderObject* resolveMovedChild(RenderObject* child) const override; 119 void flowThreadDescendantInserted(RenderObject *) override;116 void flowThreadDescendantInserted(RenderObject&) override; 120 117 void flowThreadRelativeWillBeRemoved(RenderObject*) override; 121 118 void flowThreadDescendantBoxLaidOut(RenderBox*) override; … … 130 127 131 128 void handleSpannerRemoval(RenderObject* spanner); 132 RenderObject* processPossibleSpannerDescendant(RenderObject*& subtreeRoot, RenderObject *descendant);129 RenderObject* processPossibleSpannerDescendant(RenderObject*& subtreeRoot, RenderObject& descendant); 133 130 134 131 private: -
trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp
r200041 r208005 92 92 } 93 93 94 static bool precedesRenderer( RenderObject* renderer,RenderObject* boundary)94 static bool precedesRenderer(const RenderObject* renderer, const RenderObject* boundary) 95 95 { 96 96 for (; renderer; renderer = renderer->nextInPreOrder()) { … … 101 101 } 102 102 103 bool RenderMultiColumnSet::containsRendererInFlowThread( RenderObject*renderer) const103 bool RenderMultiColumnSet::containsRendererInFlowThread(const RenderObject& renderer) const 104 104 { 105 105 if (!previousSiblingMultiColumnSet() && !nextSiblingMultiColumnSet()) { 106 106 // There is only one set. This is easy, then. 107 return renderer ->isDescendantOf(m_flowThread);107 return renderer.isDescendantOf(m_flowThread); 108 108 } 109 109 … … 114 114 115 115 // This is SLOW! But luckily very uncommon. 116 return precedesRenderer(firstRenderer, renderer) && precedesRenderer(renderer, lastRenderer);116 return precedesRenderer(firstRenderer, &renderer) && precedesRenderer(&renderer, lastRenderer); 117 117 } 118 118 -
trunk/Source/WebCore/rendering/RenderMultiColumnSet.h
r200041 r208005 61 61 62 62 // Return true if the specified renderer (descendant of the flow thread) is inside this column set. 63 bool containsRendererInFlowThread( RenderObject*) const;63 bool containsRendererInFlowThread(const RenderObject&) const; 64 64 65 65 void setLogicalTopInFlowThread(LayoutUnit); -
trunk/Source/WebCore/rendering/RenderMultiColumnSpannerPlaceholder.cpp
r200098 r208005 35 35 namespace WebCore { 36 36 37 RenderMultiColumnSpannerPlaceholder* RenderMultiColumnSpannerPlaceholder::createAnonymous(RenderMultiColumnFlowThread* flowThread, RenderBox *spanner, const RenderStyle* parentStyle)37 RenderMultiColumnSpannerPlaceholder* RenderMultiColumnSpannerPlaceholder::createAnonymous(RenderMultiColumnFlowThread* flowThread, RenderBox& spanner, const RenderStyle* parentStyle) 38 38 { 39 39 auto newStyle = RenderStyle::createAnonymousStyleWithDisplay(*parentStyle, BLOCK); … … 44 44 } 45 45 46 RenderMultiColumnSpannerPlaceholder::RenderMultiColumnSpannerPlaceholder(RenderMultiColumnFlowThread* flowThread, RenderBox *spanner, RenderStyle&& style)46 RenderMultiColumnSpannerPlaceholder::RenderMultiColumnSpannerPlaceholder(RenderMultiColumnFlowThread* flowThread, RenderBox& spanner, RenderStyle&& style) 47 47 : RenderBox(flowThread->document(), WTFMove(style), RenderBoxModelObjectFlag) 48 , m_spanner( spanner)48 , m_spanner(&spanner) 49 49 , m_flowThread(flowThread) 50 50 { -
trunk/Source/WebCore/rendering/RenderMultiColumnSpannerPlaceholder.h
r200098 r208005 39 39 class RenderMultiColumnSpannerPlaceholder final : public RenderBox { 40 40 public: 41 static RenderMultiColumnSpannerPlaceholder* createAnonymous(RenderMultiColumnFlowThread*, RenderBox *spanner, const RenderStyle* parentStyle);41 static RenderMultiColumnSpannerPlaceholder* createAnonymous(RenderMultiColumnFlowThread*, RenderBox& spanner, const RenderStyle* parentStyle); 42 42 43 43 RenderBox* spanner() const { return m_spanner; } … … 45 45 46 46 private: 47 RenderMultiColumnSpannerPlaceholder(RenderMultiColumnFlowThread*, RenderBox *spanner, RenderStyle&&);47 RenderMultiColumnSpannerPlaceholder(RenderMultiColumnFlowThread*, RenderBox& spanner, RenderStyle&&); 48 48 bool isRenderMultiColumnSpannerPlaceholder() const override { return true; } 49 49 -
trunk/Source/WebCore/rendering/RenderObject.cpp
r207736 r208005 1422 1422 1423 1423 if (RenderFlowThread* flowThread = flowThreadContainingBlock()) 1424 flowThread->flowThreadDescendantInserted( this);1424 flowThread->flowThreadDescendantInserted(*this); 1425 1425 } 1426 1426
Note: See TracChangeset
for help on using the changeset viewer.