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

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

Issue 1551573002: Clear box from percentage descendants when it is split off from the ancestor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 86
87 // Size of border belt for autoscroll. When mouse pointer in border belt, 87 // Size of border belt for autoscroll. When mouse pointer in border belt,
88 // autoscroll is started. 88 // autoscroll is started.
89 static const int autoscrollBeltSize = 20; 89 static const int autoscrollBeltSize = 20;
90 static const unsigned backgroundObscurationTestMaxDepth = 4; 90 static const unsigned backgroundObscurationTestMaxDepth = 4;
91 91
92 struct SameSizeAsLayoutBox : public LayoutBoxModelObject { 92 struct SameSizeAsLayoutBox : public LayoutBoxModelObject {
93 LayoutRect frameRect; 93 LayoutRect frameRect;
94 LayoutUnit intrinsicContentLogicalHeight; 94 LayoutUnit intrinsicContentLogicalHeight;
95 LayoutRectOutsets marginBoxOutsets; 95 LayoutRectOutsets marginBoxOutsets;
mstensho (USE GERRIT) 2016/01/21 19:12:33 What's this? Please submit master rebases and your
96 LayoutUnit preferredLogicalWidth[2]; 96 LayoutUnit preferredLogicalWidth[2];
97 void* pointers[3]; 97 void* pointers[3];
98 }; 98 };
99 99
100 static_assert(sizeof(LayoutBox) == sizeof(SameSizeAsLayoutBox), "LayoutBox shoul d stay small"); 100 static_assert(sizeof(LayoutBox) == sizeof(SameSizeAsLayoutBox), "LayoutBox shoul d stay small");
101 101
102 LayoutBox::LayoutBox(ContainerNode* node) 102 LayoutBox::LayoutBox(ContainerNode* node)
103 : LayoutBoxModelObject(node) 103 : LayoutBoxModelObject(node)
104 , m_intrinsicContentLogicalHeight(-1) 104 , m_intrinsicContentLogicalHeight(-1)
105 , m_minPreferredLogicalWidth(-1) 105 , m_minPreferredLogicalWidth(-1)
(...skipping 4557 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)
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/21 19:12:33 It's not lone if it has a previousSibling(). Pleas
rhogan 2016/01/24 12:31:37 No, but it's about to split from the previousSibli
mstensho (USE GERRIT) 2016/01/25 09:17:07 That's making an assumption about what the caller
4681 if (child->nextSibling() || childBlock->continuation())
4682 return false;
4683 LayoutBlock* parent = child->containingBlock();
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
4714 // Splitting the box means the left side of the container chain will lose any percent height descendants
4715 // below |postBox| in the right hand side.
4716 if (LayoutBlock::hasPercentHeightContainerMap())
4717 LayoutBlock::clearPercentHeightDescendantsFrom(postBox);
4718
4697 beforeChild = postBox; 4719 beforeChild = postBox;
4698 } else { 4720 } else {
4699 beforeChild = boxToSplit; 4721 // If a lone anonymous block is now unnecessary collapse it away - t his will make beforeChild's current
4722 // grandparent its parent so no need to set it before looping.
mstensho (USE GERRIT) 2016/01/21 19:12:33 Thanks for explaining!
4723 if (!collapseIfWillBecomeLoneAnonymousBlock(boxToSplit))
4724 beforeChild = boxToSplit;
4700 } 4725 }
4701 } 4726 }
4702 4727
4703 if (didSplitParentAnonymousBoxes) 4728 if (didSplitParentAnonymousBoxes)
4704 markBoxForRelayoutAfterSplit(this); 4729 markBoxForRelayoutAfterSplit(this);
4705 4730
4706 ASSERT(beforeChild->parent() == this); 4731 ASSERT(beforeChild->parent() == this);
4707 return beforeChild; 4732 return beforeChild;
4708 } 4733 }
4709 4734
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
4904 } 4929 }
4905 4930
4906 void LayoutBox::clearPreviousPaintInvalidationRects() 4931 void LayoutBox::clearPreviousPaintInvalidationRects()
4907 { 4932 {
4908 LayoutBoxModelObject::clearPreviousPaintInvalidationRects(); 4933 LayoutBoxModelObject::clearPreviousPaintInvalidationRects();
4909 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) 4934 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea())
4910 scrollableArea->clearPreviousPaintInvalidationRects(); 4935 scrollableArea->clearPreviousPaintInvalidationRects();
4911 } 4936 }
4912 4937
4913 } // namespace blink 4938 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698