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

Unified Diff: third_party/WebKit/Source/core/dom/IntersectionObservation.cpp

Issue 1559593002: Add root margin support for IntersectionObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@intersection-observer-no-root-margin
Patch Set: Initialize margin members to Fixed Created 4 years, 11 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/dom/IntersectionObservation.cpp
diff --git a/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp b/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
index 1a7b4c6f6f23b94ed91a2b847032eb19f0501304..3fcc21ce81f7d60f55f49a00569affaa938a1e9a 100644
--- a/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
+++ b/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
@@ -45,6 +45,7 @@ void IntersectionObservation::clipToRoot(LayoutRect& rect)
if (rootLayoutObject->hasOverflowClip()) {
LayoutBox* rootLayoutBox = toLayoutBox(rootLayoutObject);
LayoutRect clipRect(LayoutPoint(), LayoutSize(rootLayoutBox->layer()->size()));
+ m_observer->applyRootMargin(clipRect);
rootLayoutBox->flipForWritingMode(rect);
rect.intersect(clipRect);
rootLayoutBox->flipForWritingMode(rect);
@@ -57,12 +58,14 @@ void IntersectionObservation::clipToFrameView(IntersectionGeometry& geometry)
LayoutObject* rootLayoutObject = m_observer->rootLayoutObject();
if (rootElement == rootElement->document().documentElement()) {
geometry.rootRect = LayoutRect(rootElement->document().view()->visibleContentRect());
+ m_observer->applyRootMargin(geometry.rootRect);
geometry.intersectionRect.intersect(geometry.rootRect);
} else {
if (rootLayoutObject->isBox())
geometry.rootRect = LayoutRect(toLayoutBox(rootLayoutObject)->absoluteContentBox());
else
geometry.rootRect = LayoutRect(rootLayoutObject->absoluteBoundingBoxRect());
+ m_observer->applyRootMargin(geometry.rootRect);
}
LayoutPoint scrollPosition(rootElement->document().view()->scrollPosition());

Powered by Google App Engine
This is Rietveld 408576698