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 |