Index: Source/core/layout/LayoutObject.cpp |
diff --git a/Source/core/layout/LayoutObject.cpp b/Source/core/layout/LayoutObject.cpp |
index dd8196f6431d8f97f0899ba661e2d853398328ff..e9233a26643ed019ecf989024300c1fc769c5df2 100644 |
--- a/Source/core/layout/LayoutObject.cpp |
+++ b/Source/core/layout/LayoutObject.cpp |
@@ -865,6 +865,31 @@ LayoutBlock* LayoutObject::containerForFixedPosition(const LayoutBoxModelObject* |
return toLayoutBlock(ancestor); |
} |
+LayoutBlock* LayoutObject::containerForAbsolutePosition() const |
+{ |
+ LayoutObject* o = parent(); |
+ while (o) { |
+ if (o->style()->position() != StaticPosition && (!o->isInline() || o->isReplaced())) |
+ break; |
+ |
+ if (o->canContainFixedPositionObjects()) |
+ break; |
+ |
+ o = o->parent(); |
+ } |
+ |
+ if (o && !o->isLayoutBlock()) |
+ o = o->containingBlock(); |
+ |
+ while (o && o->isAnonymousBlock()) |
+ o = o->containingBlock(); |
+ |
+ if (!o || !o->isLayoutBlock()) |
+ return nullptr; // This can still happen in case of an orphaned tree |
+ |
+ return toLayoutBlock(o); |
+} |
+ |
LayoutBlock* LayoutObject::containingBlock() const |
{ |
LayoutObject* o = parent(); |
@@ -872,23 +897,9 @@ LayoutBlock* LayoutObject::containingBlock() const |
o = toLayoutScrollbarPart(this)->layoutObjectOwningScrollbar(); |
if (!isTextOrSVGChild() && m_style->position() == FixedPosition) |
return containerForFixedPosition(); |
- if (!isTextOrSVGChild() && m_style->position() == AbsolutePosition) { |
- while (o) { |
- if (o->style()->position() != StaticPosition && (!o->isInline() || o->isReplaced())) |
- break; |
- |
- if (o->canContainFixedPositionObjects()) |
- break; |
- |
- o = o->parent(); |
- } |
- |
- if (o && !o->isLayoutBlock()) |
- o = o->containingBlock(); |
- |
- while (o && o->isAnonymousBlock()) |
- o = o->containingBlock(); |
- } else if (isColumnSpanAll()) { |
+ if (!isTextOrSVGChild() && m_style->position() == AbsolutePosition) |
+ return containerForAbsolutePosition(); |
+ if (isColumnSpanAll()) { |
o = spannerPlaceholder()->containingBlock(); |
} else { |
while (o && ((o->isInline() && !o->isReplaced()) || !o->isLayoutBlock())) |