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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 1544423002: Improve positioned/percentHeight descendant/container tracking (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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 92342e025981d09bbb700ce959d588a3b27c7fc8..376c27eb5e325ce4876c3d8d367e02358f6d11a5 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -130,7 +130,9 @@ void LayoutBox::willBeDestroyed()
clearContainingBlockOverrideSize();
clearExtraInlineAndBlockOffests();
- LayoutBlock::removePercentHeightDescendantIfNeeded(this);
+ if (isOutOfFlowPositioned())
+ LayoutBlock::removePositionedObject(this);
+ removeFromPercentHeightContainer();
ShapeOutsideInfo::removeInfo(*this);
@@ -219,11 +221,10 @@ void LayoutBox::styleDidChange(StyleDifference diff, const ComputedStyle* oldSty
const ComputedStyle& newStyle = styleRef();
if (needsLayout() && oldStyle)
- LayoutBlock::removePercentHeightDescendantIfNeeded(this);
+ removeFromPercentHeightContainer();
- if (LayoutBlock::hasPercentHeightContainerMap() && slowFirstChild()
- && oldHorizontalWritingMode != isHorizontalWritingMode())
- LayoutBlock::clearPercentHeightDescendantsFrom(this);
+ if (oldHorizontalWritingMode != isHorizontalWritingMode())
+ clearPercentHeightDescendants();
// If our zoom factor changes and we have a defined scrollLeft/Top, we need to adjust that value into the
// new zoomed coordinate space.
@@ -4611,4 +4612,31 @@ void LayoutBox::clearPreviousPaintInvalidationRects()
scrollableArea->clearPreviousPaintInvalidationRects();
}
+void LayoutBox::setPercentHeightContainer(LayoutBlock* container)
+{
+ ASSERT(!container || !percentHeightContainer());
+ if (!container && !m_rareData)
+ return;
+ ensureRareData().m_percentHeightContainer = container;
+}
+
+void LayoutBox::removeFromPercentHeightContainer()
+{
+ if (!percentHeightContainer())
+ return;
+
+ ASSERT(percentHeightContainer()->hasPercentHeightDescendant(this));
+ percentHeightContainer()->removePercentHeightDescendant(this);
+ // The above call should call this object's setPercentHeightContainer(nullptr).
+ ASSERT(!percentHeightContainer());
+}
+
+void LayoutBox::clearPercentHeightDescendants()
+{
+ for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrder(this)) {
+ if (curr->isBox())
+ toLayoutBox(curr)->removeFromPercentHeightContainer();
+ }
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698