| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/dom/IntersectionObserver.h" | 5 #include "core/dom/IntersectionObserver.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "core/css/parser/CSSParserTokenRange.h" | 8 #include "core/css/parser/CSSParserTokenRange.h" |
| 9 #include "core/css/parser/CSSTokenizer.h" | 9 #include "core/css/parser/CSSTokenizer.h" |
| 10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
| 11 #include "core/dom/ExceptionCode.h" | 11 #include "core/dom/ExceptionCode.h" |
| 12 #include "core/dom/ExecutionContext.h" | 12 #include "core/dom/ExecutionContext.h" |
| 13 #include "core/dom/IntersectionObserverCallback.h" | 13 #include "core/dom/IntersectionObserverCallback.h" |
| 14 #include "core/dom/IntersectionObserverController.h" | 14 #include "core/dom/IntersectionObserverController.h" |
| 15 #include "core/dom/IntersectionObserverEntry.h" | 15 #include "core/dom/IntersectionObserverEntry.h" |
| 16 #include "core/dom/IntersectionObserverInit.h" | 16 #include "core/dom/IntersectionObserverInit.h" |
| 17 #include "core/dom/NodeIntersectionObserverData.h" | 17 #include "core/dom/NodeIntersectionObserverData.h" |
| 18 #include "core/frame/FrameView.h" |
| 18 #include "core/html/HTMLFrameOwnerElement.h" | 19 #include "core/html/HTMLFrameOwnerElement.h" |
| 19 #include "core/layout/LayoutView.h" | 20 #include "core/layout/LayoutView.h" |
| 20 #include "core/timing/DOMWindowPerformance.h" | 21 #include "core/timing/DOMWindowPerformance.h" |
| 21 #include "core/timing/Performance.h" | 22 #include "core/timing/Performance.h" |
| 22 #include "platform/Timer.h" | 23 #include "platform/Timer.h" |
| 23 #include <algorithm> | 24 #include <algorithm> |
| 24 | 25 |
| 25 namespace blink { | 26 namespace blink { |
| 26 | 27 |
| 27 static void parseRootMargin(String rootMarginParameter, Vector<Length>& rootMarg
in, ExceptionState& exceptionState) | 28 static void parseRootMargin(String rootMarginParameter, Vector<Length>& rootMarg
in, ExceptionState& exceptionState) |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 return; | 177 return; |
| 177 | 178 |
| 178 bool shouldReportRootBounds = false; | 179 bool shouldReportRootBounds = false; |
| 179 LocalFrame* targetFrame = target->document().frame(); | 180 LocalFrame* targetFrame = target->document().frame(); |
| 180 LocalFrame* rootFrame = rootNode()->document().frame(); | 181 LocalFrame* rootFrame = rootNode()->document().frame(); |
| 181 if (targetFrame && rootFrame) | 182 if (targetFrame && rootFrame) |
| 182 shouldReportRootBounds = targetFrame->securityContext()->getSecurityOrig
in()->canAccess(rootFrame->securityContext()->getSecurityOrigin()); | 183 shouldReportRootBounds = targetFrame->securityContext()->getSecurityOrig
in()->canAccess(rootFrame->securityContext()->getSecurityOrigin()); |
| 183 IntersectionObservation* observation = new IntersectionObservation(*this, *t
arget, shouldReportRootBounds); | 184 IntersectionObservation* observation = new IntersectionObservation(*this, *t
arget, shouldReportRootBounds); |
| 184 target->ensureIntersectionObserverData().addObservation(*observation); | 185 target->ensureIntersectionObserverData().addObservation(*observation); |
| 185 m_observations.add(observation); | 186 m_observations.add(observation); |
| 187 if (!rootFrame) |
| 188 return; |
| 189 if (FrameView* rootFrameView = rootFrame->view()) |
| 190 rootFrameView->scheduleAnimation(); |
| 186 } | 191 } |
| 187 | 192 |
| 188 void IntersectionObserver::unobserve(Element* target) | 193 void IntersectionObserver::unobserve(Element* target) |
| 189 { | 194 { |
| 190 if (!target || !target->intersectionObserverData()) | 195 if (!target || !target->intersectionObserverData()) |
| 191 return; | 196 return; |
| 192 // TODO(szager): unobserve callback | 197 // TODO(szager): unobserve callback |
| 193 if (IntersectionObservation* observation = target->intersectionObserverData(
)->getObservationFor(*this)) | 198 if (IntersectionObservation* observation = target->intersectionObserverData(
)->getObservationFor(*this)) |
| 194 observation->disconnect(); | 199 observation->disconnect(); |
| 195 } | 200 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 311 |
| 307 DEFINE_TRACE(IntersectionObserver) | 312 DEFINE_TRACE(IntersectionObserver) |
| 308 { | 313 { |
| 309 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs
erver::clearWeakMembers>(this); | 314 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs
erver::clearWeakMembers>(this); |
| 310 visitor->trace(m_callback); | 315 visitor->trace(m_callback); |
| 311 visitor->trace(m_observations); | 316 visitor->trace(m_observations); |
| 312 visitor->trace(m_entries); | 317 visitor->trace(m_entries); |
| 313 } | 318 } |
| 314 | 319 |
| 315 } // namespace blink | 320 } // namespace blink |
| OLD | NEW |