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

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

Issue 1411543009: Manually revert "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 5 years, 1 month 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 LayoutObject* child = block->nextSibling();
381 while (child && child->isFloatingOrOutOfFlowPositioned()) {
382 LayoutObject* sibling = child->nextSibling();
383 container->moveChildTo(block, child, nullptr, false);
384 child = sibling;
385 }
386 }
387
388 static void addPreviousFloatingOrOutOfFlowSiblingsToBlock(LayoutBlock* block, La youtBlock* container)
389 {
390 LayoutObject* child = block->previousSibling();
391 while (child && child->isFloatingOrOutOfFlowPositioned()) {
392 LayoutObject* sibling = child->previousSibling();
393 container->moveChildTo(block, child, block->firstChild(), false);
394 child = sibling;
395 }
396 }
397
398 void LayoutBlock::addChildIgnoringContinuation(LayoutObject* newChild, LayoutObj ect* beforeChild) 378 void LayoutBlock::addChildIgnoringContinuation(LayoutObject* newChild, LayoutObj ect* beforeChild)
399 { 379 {
400 if (beforeChild && beforeChild->parent() != this) { 380 if (beforeChild && beforeChild->parent() != this) {
401 LayoutObject* beforeChildContainer = beforeChild->parent(); 381 LayoutObject* beforeChildContainer = beforeChild->parent();
402 while (beforeChildContainer->parent() != this) 382 while (beforeChildContainer->parent() != this)
403 beforeChildContainer = beforeChildContainer->parent(); 383 beforeChildContainer = beforeChildContainer->parent();
404 ASSERT(beforeChildContainer); 384 ASSERT(beforeChildContainer);
405 385
406 if (beforeChildContainer->isAnonymous()) { 386 if (beforeChildContainer->isAnonymous()) {
407 // 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
462 if (afterChild && afterChild->isAnonymousBlock()) { 442 if (afterChild && afterChild->isAnonymousBlock()) {
463 afterChild->addChild(newChild); 443 afterChild->addChild(newChild);
464 return; 444 return;
465 } 445 }
466 446
467 if (newChild->isInline()) { 447 if (newChild->isInline()) {
468 // No suitable existing anonymous box - create a new one. 448 // No suitable existing anonymous box - create a new one.
469 LayoutBlock* newBox = createAnonymousBlock(); 449 LayoutBlock* newBox = createAnonymousBlock();
470 LayoutBox::addChild(newBox, beforeChild); 450 LayoutBox::addChild(newBox, beforeChild);
471 // 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 .
472 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 }
473 newBox->addChild(newChild); 458 newBox->addChild(newChild);
474 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 }
475 return; 465 return;
476 } 466 }
477 } 467 }
478 468
479 LayoutBox::addChild(newChild, beforeChild); 469 LayoutBox::addChild(newChild, beforeChild);
480 470
481 if (madeBoxesNonInline && parent() && isAnonymousBlock() && parent()->isLayo utBlock()) 471 if (madeBoxesNonInline && parent() && isAnonymousBlock() && parent()->isLayo utBlock())
482 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this); 472 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this);
483 // this object may be dead here 473 // this object may be dead here
484 } 474 }
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 collapseAnonymousBlockChild(this, toLayoutBlock(child)); 725 collapseAnonymousBlockChild(this, toLayoutBlock(child));
736 } else if (((prev && prev->isAnonymousBlock()) || (next && next->isAnonymous Block())) && canCollapseAnonymousBlockChild()) { 726 } else if (((prev && prev->isAnonymousBlock()) || (next && next->isAnonymous Block())) && canCollapseAnonymousBlockChild()) {
737 // It's possible that the removal has knocked us down to a single anonym ous 727 // It's possible that the removal has knocked us down to a single anonym ous
738 // block with pseudo-style element siblings (e.g. first-letter). If thes e 728 // block with pseudo-style element siblings (e.g. first-letter). If thes e
739 // are floating, then we need to pull the content up also. 729 // are floating, then we need to pull the content up also.
740 LayoutBlock* anonymousBlock = toLayoutBlock((prev && prev->isAnonymousBl ock()) ? prev : next); 730 LayoutBlock* anonymousBlock = toLayoutBlock((prev && prev->isAnonymousBl ock()) ? prev : next);
741 if ((anonymousBlock->previousSibling() || anonymousBlock->nextSibling()) 731 if ((anonymousBlock->previousSibling() || anonymousBlock->nextSibling())
742 && (!anonymousBlock->previousSibling() || (anonymousBlock->previousS ibling()->style()->styleType() != NOPSEUDO && anonymousBlock->previousSibling()- >isFloating() && !anonymousBlock->previousSibling()->previousSibling())) 732 && (!anonymousBlock->previousSibling() || (anonymousBlock->previousS ibling()->style()->styleType() != NOPSEUDO && anonymousBlock->previousSibling()- >isFloating() && !anonymousBlock->previousSibling()->previousSibling()))
743 && (!anonymousBlock->nextSibling() || (anonymousBlock->nextSibling() ->style()->styleType() != NOPSEUDO && anonymousBlock->nextSibling()->isFloating( ) && !anonymousBlock->nextSibling()->nextSibling()))) { 733 && (!anonymousBlock->nextSibling() || (anonymousBlock->nextSibling() ->style()->styleType() != NOPSEUDO && anonymousBlock->nextSibling()->isFloating( ) && !anonymousBlock->nextSibling()->nextSibling()))) {
744 collapseAnonymousBlockChild(this, anonymousBlock); 734 collapseAnonymousBlockChild(this, anonymousBlock);
745 } else {
746 // If we have floating or out-of-flow siblings now adjacent to an an onymous block, fold them
747 // into it.
748 if (prev && prev->isAnonymousBlock())
749 addNextFloatingOrOutOfFlowSiblingsToBlock(toLayoutBlock(prev), t his);
750 else if (next && next->isAnonymousBlock())
751 addPreviousFloatingOrOutOfFlowSiblingsToBlock(toLayoutBlock(next ), this);
752 } 735 }
753 } 736 }
754 737
755 if (!firstChild()) { 738 if (!firstChild()) {
756 // If this was our last child be sure to clear out our line boxes. 739 // If this was our last child be sure to clear out our line boxes.
757 if (childrenInline()) 740 if (childrenInline())
758 deleteLineBoxTree(); 741 deleteLineBoxTree();
759 742
760 // If we are an empty anonymous block in the continuation chain, 743 // If we are an empty anonymous block in the continuation chain,
761 // we need to remove ourself and fix the continuation chain. 744 // we need to remove ourself and fix the continuation chain.
(...skipping 2141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2903 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 2886 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
2904 { 2887 {
2905 showLayoutObject(); 2888 showLayoutObject();
2906 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2889 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2907 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2890 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2908 } 2891 }
2909 2892
2910 #endif 2893 #endif
2911 2894
2912 } // namespace blink 2895 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/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