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

Unified Diff: Source/core/layout/LayoutObject.cpp

Issue 1218023004: Fix a regression when position:static with absolute child changed to relative (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: mstensho@ review in #10, and test from #11 Created 5 years, 5 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
« no previous file with comments | « Source/core/layout/LayoutObject.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutObject.cpp
diff --git a/Source/core/layout/LayoutObject.cpp b/Source/core/layout/LayoutObject.cpp
index 39912284a41dacf2f68f32faac07fca4172e674a..93e6bc74adc349f12dc6d743d3b618a84ace6059 100644
--- a/Source/core/layout/LayoutObject.cpp
+++ b/Source/core/layout/LayoutObject.cpp
@@ -865,30 +865,43 @@ LayoutBlock* LayoutObject::containerForFixedPosition(const LayoutBoxModelObject*
return toLayoutBlock(ancestor);
}
-LayoutBlock* LayoutObject::containingBlock() const
+LayoutBlock* LayoutObject::containingBlockForAbsolutePosition() const
{
LayoutObject* o = parent();
- if (!o && isLayoutScrollbarPart())
- 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;
+ while (o) {
+ if (o->style()->position() != StaticPosition && (!o->isInline() || o->isReplaced()))
+ break;
- if (o->canContainFixedPositionObjects())
- break;
+ if (o->canContainFixedPositionObjects())
+ break;
- o = o->parent();
- }
+ o = o->parent();
+ }
- if (o && !o->isLayoutBlock())
- o = o->containingBlock();
+ if (o && !o->isLayoutBlock())
+ o = o->containingBlock();
- while (o && o->isAnonymousBlock())
- o = o->containingBlock();
- } else if (isColumnSpanAll()) {
+ 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();
+ if (!o && isLayoutScrollbarPart())
+ o = toLayoutScrollbarPart(this)->layoutObjectOwningScrollbar();
+ if (!isTextOrSVGChild()) {
+ if (m_style->position() == FixedPosition)
+ return containerForFixedPosition();
+ if (m_style->position() == AbsolutePosition)
+ return containingBlockForAbsolutePosition();
+ }
+ if (isColumnSpanAll()) {
o = spannerPlaceholder()->containingBlock();
} else {
while (o && ((o->isInline() && !o->isReplaced()) || !o->isLayoutBlock()))
« no previous file with comments | « Source/core/layout/LayoutObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698