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..dc37faf048f8c5b9da01d1fae9b8d8715cd9a49d 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
@@ -3179,7 +3179,7 @@ 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; |
@@ -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->isOutOfFlowPositioned() && ancestor->style()->position() == FixedPosition) |
hayato
2016/06/29 05:42:46
Could you clean up this function?
e.g. Remove L31
kochi
2016/06/29 06:24:37
Done.
|
+ return nullptr; |
+ continue; |
+ } |
+ |
if (ancestor->isPositioned()) |
break; |