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

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: virtual destructor Created 4 years, 12 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 e7dde710055129368066dc36d0f2f12cd54851cf..41f6f14d1b808b5e9edb750a2622daff0b99831e 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -119,7 +119,8 @@ void LayoutBox::willBeDestroyed()
clearContainingBlockOverrideSize();
clearExtraInlineAndBlockOffests();
- LayoutBlock::removePercentHeightDescendantIfNeeded(this);
+ removeFromPositionedContainer();
+ removeFromPercentHeightContainer();
ShapeOutsideInfo::removeInfo(*this);
@@ -150,7 +151,7 @@ void LayoutBox::removeFloatingOrPositionedChildFromBlockLists()
}
if (isOutOfFlowPositioned())
- LayoutBlock::removePositionedObject(this);
+ removeFromPositionedContainer();
}
void LayoutBox::styleWillChange(StyleDifference diff, const ComputedStyle& newStyle)
@@ -208,11 +209,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.
@@ -4895,4 +4895,50 @@ void LayoutBox::clearPreviousPaintInvalidationRects()
scrollableArea->clearPreviousPaintInvalidationRects();
}
+void LayoutBox::setPositionedContainer(LayoutBlock* container)
+{
+ ASSERT(!container || !positionedContainer());
+ if (!container && !m_rareData)
+ return;
+ ensureRareData().m_positionedContainer = container;
+}
+
+void LayoutBox::removeFromPositionedContainer()
+{
+ if (!positionedContainer())
+ return;
+
+ ASSERT(positionedContainer()->positionedObjects()->contains(this));
+ positionedContainer()->removePositionedObject(this);
+ // The above call should call this object's setPositionedContainer(nullptr).
+ ASSERT(!positionedContainer());
+}
+
+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

Powered by Google App Engine
This is Rietveld 408576698