Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/IntersectionObserver.cpp |
| diff --git a/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp b/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp |
| index 32ef04c78978b5f0856a4812c1ff8499585d1e5d..16dabe16eb5fd8deadc5bec097a0959bdea30ee4 100644 |
| --- a/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp |
| +++ b/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp |
| @@ -204,7 +204,8 @@ IntersectionObserver::IntersectionObserver( |
| m_rightMargin(Fixed), |
| m_bottomMargin(Fixed), |
| m_leftMargin(Fixed), |
| - m_initialState(InitialState::kHidden) { |
| + m_initialState(InitialState::kHidden), |
| + m_observeViewportIntersection(thresholds.isEmpty()) { |
| switch (rootMargin.size()) { |
| case 0: |
| break; |
| @@ -269,7 +270,9 @@ void IntersectionObserver::observe(Element* target, |
| LocalFrame* targetFrame = target->document().frame(); |
| LocalFrame* rootFrame = m_root->document().frame(); |
| - if (target->document() == rootNode()->document()) { |
| + if (m_observeViewportIntersection) { |
|
szager1
2016/11/16 21:37:55
Hmm... you're using m_observerViewportIntersection
xjz
2016/11/16 22:57:15
Done.
|
| + shouldReportRootBounds = true; |
| + } else if (target->document() == rootNode()->document()) { |
| shouldReportRootBounds = true; |
| isDOMDescendant = rootNode()->isShadowIncludingInclusiveAncestorOf(target); |
| } else if (targetFrame && rootFrame) { |
| @@ -279,8 +282,13 @@ void IntersectionObserver::observe(Element* target, |
| isDOMDescendant = (targetFrame->tree().top() == rootFrame); |
| } |
| - IntersectionObservation* observation = |
| - new IntersectionObservation(*this, *target, shouldReportRootBounds); |
| + IntersectionObservation* observation; |
| + if (m_observeViewportIntersection) { |
| + observation = new ViewportIntersectionObservation(*this, *target); |
| + } else { |
| + observation = |
| + new IntersectionObservation(*this, *target, shouldReportRootBounds); |
| + } |
| target->ensureIntersectionObserverData().addObservation(*observation); |
| m_observations.add(observation); |