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

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

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

Powered by Google App Engine
This is Rietveld 408576698