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

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

Issue 1548523002: Use Document, rather than document element, for implicit root. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@intersection-observer
Patch Set: Nits, comments, rebaseline 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 3fcc21ce81f7d60f55f49a00569affaa938a1e9a..1f06da2f7f20b48a858b902738a2a7bf00991ed3 100644
--- a/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
+++ b/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
@@ -23,10 +23,15 @@ IntersectionObservation::IntersectionObservation(IntersectionObserver& observer,
{
}
+Element* IntersectionObservation::target() const
+{
+ return toElement(m_target.get());
+}
+
void IntersectionObservation::initializeGeometry(IntersectionGeometry& geometry)
{
ASSERT(m_target);
- LayoutObject* targetLayoutObject = m_target->layoutObject();
+ LayoutObject* targetLayoutObject = target()->layoutObject();
if (targetLayoutObject->isBoxModelObject())
geometry.targetRect = toLayoutBoxModelObject(targetLayoutObject)->visualOverflowRect();
else
@@ -40,7 +45,7 @@ void IntersectionObservation::clipToRoot(LayoutRect& rect)
// TODO(szager): the writing mode flipping needs a test.
ASSERT(m_target);
LayoutObject* rootLayoutObject = m_observer->rootLayoutObject();
- LayoutObject* targetLayoutObject = m_target->layoutObject();
+ LayoutObject* targetLayoutObject = target()->layoutObject();
targetLayoutObject->mapToVisibleRectInAncestorSpace(toLayoutBoxModelObject(rootLayoutObject), rect, nullptr);
if (rootLayoutObject->hasOverflowClip()) {
LayoutBox* rootLayoutBox = toLayoutBox(rootLayoutObject);
@@ -54,10 +59,10 @@ void IntersectionObservation::clipToRoot(LayoutRect& rect)
void IntersectionObservation::clipToFrameView(IntersectionGeometry& geometry)
{
- Element* rootElement = m_observer->root();
+ Node* rootNode = m_observer->root();
LayoutObject* rootLayoutObject = m_observer->rootLayoutObject();
- if (rootElement == rootElement->document().documentElement()) {
- geometry.rootRect = LayoutRect(rootElement->document().view()->visibleContentRect());
+ if (rootLayoutObject->isLayoutView()) {
+ geometry.rootRect = LayoutRect(toLayoutView(rootLayoutObject)->frameView()->visibleContentRect());
m_observer->applyRootMargin(geometry.rootRect);
geometry.intersectionRect.intersect(geometry.rootRect);
} else {
@@ -68,7 +73,7 @@ void IntersectionObservation::clipToFrameView(IntersectionGeometry& geometry)
m_observer->applyRootMargin(geometry.rootRect);
}
- LayoutPoint scrollPosition(rootElement->document().view()->scrollPosition());
+ LayoutPoint scrollPosition(rootNode->document().view()->scrollPosition());
geometry.targetRect.moveBy(-scrollPosition);
geometry.intersectionRect.moveBy(-scrollPosition);
geometry.rootRect.moveBy(-scrollPosition);
@@ -83,7 +88,7 @@ bool IntersectionObservation::computeGeometry(IntersectionGeometry& geometry)
{
ASSERT(m_target);
LayoutObject* rootLayoutObject = m_observer->rootLayoutObject();
- LayoutObject* targetLayoutObject = m_target->layoutObject();
+ LayoutObject* targetLayoutObject = target()->layoutObject();
if (!rootLayoutObject->isBoxModelObject())
return false;
if (!targetLayoutObject->isBoxModelObject() && !targetLayoutObject->isText())
@@ -157,7 +162,7 @@ void IntersectionObservation::computeIntersectionObservations(double timestamp)
void IntersectionObservation::disconnect()
{
if (m_target)
- m_target->ensureIntersectionObserverData().removeObservation(this->observer());
+ target()->ensureIntersectionObserverData().removeObservation(this->observer());
m_observer->removeObservation(*this);
m_observer.clear();
}

Powered by Google App Engine
This is Rietveld 408576698