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

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

Issue 1611413007: Remove unnecessary anonymous blocks when splitting anonymous boxes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@568387-RemovePercentHeight
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) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 4652 matching lines...) Expand 10 before | Expand all | Expand 10 after
4663 // Because we may have added some sections with already computed column structures, we need to 4663 // Because we may have added some sections with already computed column structures, we need to
4664 // sync the table structure with them now. This avoids crashes when addi ng new cells to the table. 4664 // sync the table structure with them now. This avoids crashes when addi ng new cells to the table.
4665 toLayoutTable(box)->forceSectionsRecalc(); 4665 toLayoutTable(box)->forceSectionsRecalc();
4666 } else if (box->isTableSection()) { 4666 } else if (box->isTableSection()) {
4667 toLayoutTableSection(box)->setNeedsCellRecalc(); 4667 toLayoutTableSection(box)->setNeedsCellRecalc();
4668 } 4668 }
4669 4669
4670 box->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalid ationReason::AnonymousBlockChange); 4670 box->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalid ationReason::AnonymousBlockChange);
4671 } 4671 }
4672 4672
4673 static bool collapseIfWillBecomeLoneAnonymousBlock(LayoutBox* child)
mstensho (USE GERRIT) 2016/01/28 20:45:14 I think this would fit better in LayoutBlock. Doin
rhogan 2016/01/30 12:38:58 Waaaah! I moved it here because you thought it sho
4674 {
4675 if (!child->isAnonymousBlock())
4676 return false;
4677 LayoutBlock* childBlock = toLayoutBlock(child);
4678 if (childBlock->beingDestroyed())
4679 return false;
4680 // We're splitting from our previousSibling().
mstensho (USE GERRIT) 2016/01/28 20:45:14 I'm still uneasy about this. I think we should ra
rhogan 2016/01/30 12:38:57 We're not guessing though - if we create postBox h
4681 if (child->nextSibling() || childBlock->continuation())
4682 return false;
4683 LayoutBlock* parent = child->containingBlock();
mstensho (USE GERRIT) 2016/01/28 20:45:14 This should always be the same as child->parent(),
rhogan 2016/01/30 12:38:57 Done.
4684 if (parent->isRubyBase() || parent->isRubyRun())
4685 return false;
4686 LayoutBlock::collapseAnonymousBlockChild(parent, childBlock);
4687 return true;
4688 }
4689
4673 LayoutObject* LayoutBox::splitAnonymousBoxesAroundChild(LayoutObject* beforeChil d) 4690 LayoutObject* LayoutBox::splitAnonymousBoxesAroundChild(LayoutObject* beforeChil d)
4674 { 4691 {
4675 bool didSplitParentAnonymousBoxes = false; 4692 bool didSplitParentAnonymousBoxes = false;
4676 4693
4677 while (beforeChild->parent() != this) { 4694 while (beforeChild->parent() != this) {
4678 LayoutBox* boxToSplit = toLayoutBox(beforeChild->parent()); 4695 LayoutBox* boxToSplit = toLayoutBox(beforeChild->parent());
4679 if (boxToSplit->slowFirstChild() != beforeChild && boxToSplit->isAnonymo us()) { 4696 if (boxToSplit->slowFirstChild() != beforeChild && boxToSplit->isAnonymo us()) {
4680 didSplitParentAnonymousBoxes = true; 4697 didSplitParentAnonymousBoxes = true;
4681 4698
4682 // We have to split the parent box into two boxes and move children 4699 // We have to split the parent box into two boxes and move children
4683 // from |beforeChild| to end into the new post box. 4700 // from |beforeChild| to end into the new post box.
4684 LayoutBox* postBox = boxToSplit->createAnonymousBoxWithSameTypeAs(th is); 4701 LayoutBox* postBox = boxToSplit->createAnonymousBoxWithSameTypeAs(th is);
4685 postBox->setChildrenInline(boxToSplit->childrenInline()); 4702 postBox->setChildrenInline(boxToSplit->childrenInline());
4686 LayoutBox* parentBox = toLayoutBox(boxToSplit->parent()); 4703 LayoutBox* parentBox = toLayoutBox(boxToSplit->parent());
4687 // We need to invalidate the |parentBox| before inserting the new no de 4704 // We need to invalidate the |parentBox| before inserting the new no de
4688 // so that the table paint invalidation logic knows the structure is dirty. 4705 // so that the table paint invalidation logic knows the structure is dirty.
4689 // See for example LayoutTableCell:clippedOverflowRectForPaintInvali dation. 4706 // See for example LayoutTableCell:clippedOverflowRectForPaintInvali dation.
4690 markBoxForRelayoutAfterSplit(parentBox); 4707 markBoxForRelayoutAfterSplit(parentBox);
4691 parentBox->virtualChildren()->insertChildNode(parentBox, postBox, bo xToSplit->nextSibling()); 4708 parentBox->virtualChildren()->insertChildNode(parentBox, postBox, bo xToSplit->nextSibling());
4692 boxToSplit->moveChildrenTo(postBox, beforeChild, 0, true); 4709 boxToSplit->moveChildrenTo(postBox, beforeChild, 0, true);
4693 4710
4694 markBoxForRelayoutAfterSplit(boxToSplit); 4711 markBoxForRelayoutAfterSplit(boxToSplit);
4695 markBoxForRelayoutAfterSplit(postBox); 4712 markBoxForRelayoutAfterSplit(postBox);
4696 4713
4697 beforeChild = postBox; 4714 beforeChild = postBox;
4698 } else { 4715 } else {
4699 beforeChild = boxToSplit; 4716 // If a lone anonymous block is now unnecessary collapse it away - t his will make beforeChild's current
4717 // grandparent its parent so no need to set it before looping.
4718 if (!collapseIfWillBecomeLoneAnonymousBlock(boxToSplit))
4719 beforeChild = boxToSplit;
4700 } 4720 }
4701 } 4721 }
4702 4722
4703 if (didSplitParentAnonymousBoxes) 4723 if (didSplitParentAnonymousBoxes)
4704 markBoxForRelayoutAfterSplit(this); 4724 markBoxForRelayoutAfterSplit(this);
4705 4725
4706 ASSERT(beforeChild->parent() == this); 4726 ASSERT(beforeChild->parent() == this);
4707 return beforeChild; 4727 return beforeChild;
4708 } 4728 }
4709 4729
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
4904 } 4924 }
4905 4925
4906 void LayoutBox::clearPreviousPaintInvalidationRects() 4926 void LayoutBox::clearPreviousPaintInvalidationRects()
4907 { 4927 {
4908 LayoutBoxModelObject::clearPreviousPaintInvalidationRects(); 4928 LayoutBoxModelObject::clearPreviousPaintInvalidationRects();
4909 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) 4929 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea())
4910 scrollableArea->clearPreviousPaintInvalidationRects(); 4930 scrollableArea->clearPreviousPaintInvalidationRects();
4911 } 4931 }
4912 4932
4913 } // namespace blink 4933 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698