Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlock.cpp

Issue 1558433003: Revert of Re-land 'Fold out-of-flow objects into anonymous blocks when removing children' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 if (startOfContinuations && startOfContinuations->styleRef().outlineStyleIsA uto()) 368 if (startOfContinuations && startOfContinuations->styleRef().outlineStyleIsA uto())
369 startOfContinuations->invalidateDisplayItemClient(*startOfContinuations) ; 369 startOfContinuations->invalidateDisplayItemClient(*startOfContinuations) ;
370 } 370 }
371 371
372 void LayoutBlock::invalidateDisplayItemClients(const LayoutBoxModelObject& paint InvalidationContainer, PaintInvalidationReason invalidationReason, const LayoutR ect* paintInvalidationRect) const 372 void LayoutBlock::invalidateDisplayItemClients(const LayoutBoxModelObject& paint InvalidationContainer, PaintInvalidationReason invalidationReason, const LayoutR ect* paintInvalidationRect) const
373 { 373 {
374 LayoutBox::invalidateDisplayItemClients(paintInvalidationContainer, invalida tionReason, paintInvalidationRect); 374 LayoutBox::invalidateDisplayItemClients(paintInvalidationContainer, invalida tionReason, paintInvalidationRect);
375 invalidateDisplayItemClientForStartOfContinuationsIfNeeded(*this); 375 invalidateDisplayItemClientForStartOfContinuationsIfNeeded(*this);
376 } 376 }
377 377
378 static void addNextFloatingOrOutOfFlowSiblingsToBlock(LayoutBlock* block, Layout Block* container)
379 {
380 if (block->beingDestroyed())
381 return;
382
383 LayoutObject* child = block->nextSibling();
384 while (child && child->isFloatingOrOutOfFlowPositioned()) {
385 LayoutObject* sibling = child->nextSibling();
386 container->moveChildTo(block, child, nullptr, false);
387 child = sibling;
388 }
389 }
390
391 static void addPreviousFloatingOrOutOfFlowSiblingsToBlock(LayoutBlock* block, La youtBlock* container)
392 {
393 if (block->beingDestroyed())
394 return;
395
396 LayoutObject* child = block->previousSibling();
397 while (child && child->isFloatingOrOutOfFlowPositioned()) {
398 LayoutObject* sibling = child->previousSibling();
399 container->moveChildTo(block, child, block->firstChild(), false);
400 child = sibling;
401 }
402 }
403
404 void LayoutBlock::addChildIgnoringContinuation(LayoutObject* newChild, LayoutObj ect* beforeChild) 378 void LayoutBlock::addChildIgnoringContinuation(LayoutObject* newChild, LayoutObj ect* beforeChild)
405 { 379 {
406 if (beforeChild && beforeChild->parent() != this) { 380 if (beforeChild && beforeChild->parent() != this) {
407 LayoutObject* beforeChildContainer = beforeChild->parent(); 381 LayoutObject* beforeChildContainer = beforeChild->parent();
408 while (beforeChildContainer->parent() != this) 382 while (beforeChildContainer->parent() != this)
409 beforeChildContainer = beforeChildContainer->parent(); 383 beforeChildContainer = beforeChildContainer->parent();
410 ASSERT(beforeChildContainer); 384 ASSERT(beforeChildContainer);
411 385
412 if (beforeChildContainer->isAnonymous()) { 386 if (beforeChildContainer->isAnonymous()) {
413 // If the requested beforeChild is not one of our children, then thi s is because 387 // If the requested beforeChild is not one of our children, then thi s is because
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 if (afterChild && afterChild->isAnonymousBlock()) { 442 if (afterChild && afterChild->isAnonymousBlock()) {
469 afterChild->addChild(newChild); 443 afterChild->addChild(newChild);
470 return; 444 return;
471 } 445 }
472 446
473 if (newChild->isInline()) { 447 if (newChild->isInline()) {
474 // No suitable existing anonymous box - create a new one. 448 // No suitable existing anonymous box - create a new one.
475 LayoutBlock* newBox = createAnonymousBlock(); 449 LayoutBlock* newBox = createAnonymousBlock();
476 LayoutBox::addChild(newBox, beforeChild); 450 LayoutBox::addChild(newBox, beforeChild);
477 // Reparent adjacent floating or out-of-flow siblings to the new box . 451 // Reparent adjacent floating or out-of-flow siblings to the new box .
478 addPreviousFloatingOrOutOfFlowSiblingsToBlock(newBox, this); 452 LayoutObject* child = newBox->previousSibling();
453 while (child && child->isFloatingOrOutOfFlowPositioned()) {
454 LayoutObject* sibling = child->previousSibling();
455 moveChildTo(newBox, child, newBox->firstChild(), false);
456 child = sibling;
457 }
479 newBox->addChild(newChild); 458 newBox->addChild(newChild);
480 addNextFloatingOrOutOfFlowSiblingsToBlock(newBox, this); 459 child = newBox->nextSibling();
460 while (child && child->isFloatingOrOutOfFlowPositioned()) {
461 LayoutObject* sibling = child->nextSibling();
462 moveChildTo(newBox, child, nullptr, false);
463 child = sibling;
464 }
481 return; 465 return;
482 } 466 }
483 } 467 }
484 468
485 LayoutBox::addChild(newChild, beforeChild); 469 LayoutBox::addChild(newChild, beforeChild);
486 470
487 if (madeBoxesNonInline && parent() && isAnonymousBlock() && parent()->isLayo utBlock()) 471 if (madeBoxesNonInline && parent() && isAnonymousBlock() && parent()->isLayo utBlock())
488 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this); 472 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this);
489 // this object may be dead here 473 // this object may be dead here
490 } 474 }
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 collapseAnonymousBlockChild(this, toLayoutBlock(child)); 732 collapseAnonymousBlockChild(this, toLayoutBlock(child));
749 } else if (((prev && prev->isAnonymousBlock()) || (next && next->isAnonymous Block())) && canCollapseAnonymousBlockChild()) { 733 } else if (((prev && prev->isAnonymousBlock()) || (next && next->isAnonymous Block())) && canCollapseAnonymousBlockChild()) {
750 // It's possible that the removal has knocked us down to a single anonym ous 734 // It's possible that the removal has knocked us down to a single anonym ous
751 // block with pseudo-style element siblings (e.g. first-letter). If thes e 735 // block with pseudo-style element siblings (e.g. first-letter). If thes e
752 // are floating, then we need to pull the content up also. 736 // are floating, then we need to pull the content up also.
753 LayoutBlock* anonymousBlock = toLayoutBlock((prev && prev->isAnonymousBl ock()) ? prev : next); 737 LayoutBlock* anonymousBlock = toLayoutBlock((prev && prev->isAnonymousBl ock()) ? prev : next);
754 if ((anonymousBlock->previousSibling() || anonymousBlock->nextSibling()) 738 if ((anonymousBlock->previousSibling() || anonymousBlock->nextSibling())
755 && (!anonymousBlock->previousSibling() || (anonymousBlock->previousS ibling()->style()->styleType() != NOPSEUDO && anonymousBlock->previousSibling()- >isFloating() && !anonymousBlock->previousSibling()->previousSibling())) 739 && (!anonymousBlock->previousSibling() || (anonymousBlock->previousS ibling()->style()->styleType() != NOPSEUDO && anonymousBlock->previousSibling()- >isFloating() && !anonymousBlock->previousSibling()->previousSibling()))
756 && (!anonymousBlock->nextSibling() || (anonymousBlock->nextSibling() ->style()->styleType() != NOPSEUDO && anonymousBlock->nextSibling()->isFloating( ) && !anonymousBlock->nextSibling()->nextSibling()))) { 740 && (!anonymousBlock->nextSibling() || (anonymousBlock->nextSibling() ->style()->styleType() != NOPSEUDO && anonymousBlock->nextSibling()->isFloating( ) && !anonymousBlock->nextSibling()->nextSibling()))) {
757 collapseAnonymousBlockChild(this, anonymousBlock); 741 collapseAnonymousBlockChild(this, anonymousBlock);
758 } else {
759 // If we have floating or out-of-flow siblings now adjacent to an an onymous block, fold them
760 // into it.
761 if (prev && prev->isAnonymousBlock())
762 addNextFloatingOrOutOfFlowSiblingsToBlock(toLayoutBlock(prev), t his);
763 else if (next && next->isAnonymousBlock())
764 addPreviousFloatingOrOutOfFlowSiblingsToBlock(toLayoutBlock(next ), this);
765 } 742 }
766 } 743 }
767 744
768 if (!firstChild()) { 745 if (!firstChild()) {
769 // If this was our last child be sure to clear out our line boxes. 746 // If this was our last child be sure to clear out our line boxes.
770 if (childrenInline()) 747 if (childrenInline())
771 deleteLineBoxTree(); 748 deleteLineBoxTree();
772 749
773 // If we are an empty anonymous block in the continuation chain, 750 // If we are an empty anonymous block in the continuation chain,
774 // we need to remove ourself and fix the continuation chain. 751 // we need to remove ourself and fix the continuation chain.
(...skipping 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2934 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 2911 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
2935 { 2912 {
2936 showLayoutObject(); 2913 showLayoutObject();
2937 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2914 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2938 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2915 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2939 } 2916 }
2940 2917
2941 #endif 2918 #endif
2942 2919
2943 } // namespace blink 2920 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/block/float/remove-div-after-float-and-before-anonymous-block-container-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698