Chromium Code Reviews| 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 3bb9aed1aa1db7e89140063a78126833707fe813..59b94832fb44446e1f10852c86db1a52632b7917 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()); |
|
ojan
2016/01/12 01:28:18
How do you know this is an Element and not the Doc
szager1
2016/01/12 21:19:51
The target can only ever be an Element; only the r
|
| +} |
| + |
| 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()) |
| @@ -152,7 +157,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(); |
| } |