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

Unified Diff: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 2761413002: Fix position of floating layer whose containing block is also floating (Closed)
Patch Set: TODO in GraphicsLayerUpdater Created 3 years, 9 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/paint/PaintLayer.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.cpp b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
index abd609c8f6e5c374e79065e6f3e944837b4054fa..4bf93cac73f42532baa478d26565475ecdfe23cc 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayer.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
@@ -870,8 +870,10 @@ PaintLayer* PaintLayer::containingLayer(const PaintLayer* ancestor,
*skippedAncestor = false;
LayoutObject& layoutObject = this->layoutObject();
- if (layoutObject.isColumnSpanAll() ||
- layoutObject.isFloatingWithNonContainingBlockParent()) {
+ // Column span need to find the containing layer through its containing block.
+ // TODO(wangxianzhu): This can be combined with the loop handing possible
+ // floating objects.
+ if (layoutObject.isColumnSpanAll()) {
Optional<LayoutObject::AncestorSkipInfo> skipInfo;
if (skippedAncestor)
skipInfo.emplace(&ancestor->layoutObject());
@@ -899,7 +901,28 @@ PaintLayer* PaintLayer::containingLayer(const PaintLayer* ancestor,
return curr;
}
- return parent();
+ // If the parent layer is not a block, there might be floating objects
+ // between this layer (included) and parent layer which need to escape the
+ // inline parent to find the actual containing layer through the containing
+ // block chain.
+ if (!parent() || parent()->layoutObject().isLayoutBlock())
+ return parent();
+
+ // This is a universal approach to find containing layer, but is slower than
+ // the earlier code.
+ Optional<LayoutObject::AncestorSkipInfo> skipInfo;
+ if (skippedAncestor)
+ skipInfo.emplace(&ancestor->layoutObject());
+ auto* object = &layoutObject;
+ while (auto* container =
+ object->container(skippedAncestor ? &*skipInfo : nullptr)) {
+ if (skippedAncestor && skipInfo->ancestorSkipped())
+ *skippedAncestor = true;
+ if (container->hasLayer())
+ return toLayoutBoxModelObject(container)->layer();
+ object = container;
+ }
+ return nullptr;
}
PaintLayer* PaintLayer::enclosingTransformedAncestor() const {

Powered by Google App Engine
This is Rietveld 408576698