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

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

Issue 2051703002: Implement closed shadow adjustment for Element.offsetParent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add one more test case. Created 4 years, 6 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/LayoutObject.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
index 24b588d3a47c96c288e5b9f7a8f81d02cc95732f..c4d016e971f6d03fcc8891218ff39fa1b12e6d2a 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -3179,12 +3179,12 @@ void LayoutObject::imageChanged(ImageResource* image, const IntRect* rect)
imageChanged(static_cast<WrappedImagePtr>(image), rect);
}
-Element* LayoutObject::offsetParent() const
+Element* LayoutObject::offsetParent(const Element* unclosedBase) const
{
if (isDocumentElement() || isBody())
return nullptr;
- if (isOutOfFlowPositioned() && style()->position() == FixedPosition)
+ if (isFixedPositioned())
return nullptr;
float effectiveZoom = style()->effectiveZoom();
@@ -3197,6 +3197,16 @@ Element* LayoutObject::offsetParent() const
if (!node)
continue;
+ // TODO(kochi): If |unclosedBase| or |node| is nested deep in shadow roots, this loop may
+ // get expensive, as isUnclosedNodeOf() can take up to O(N+M) time (N and M are depths).
+ if (unclosedBase && (!node->isUnclosedNodeOf(*unclosedBase) || (node->isInShadowTree() && node->containingShadowRoot()->type() == ShadowRootType::UserAgent))) {
+ // If 'position: fixed' node is found while traversing up, terminate the loop and
+ // return null.
+ if (ancestor->isFixedPositioned())
+ return nullptr;
+ continue;
+ }
+
if (ancestor->isPositioned())
break;
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | third_party/WebKit/Source/core/layout/LayoutVideo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698