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" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 if (target->document() == rootNode()->document()) { | 263 if (target->document() == rootNode()->document()) { |
264 shouldReportRootBounds = true; | 264 shouldReportRootBounds = true; |
265 isDOMDescendant = rootNode()->isShadowIncludingInclusiveAncestorOf(target); | 265 isDOMDescendant = rootNode()->isShadowIncludingInclusiveAncestorOf(target); |
266 } else if (targetFrame && rootFrame) { | 266 } else if (targetFrame && rootFrame) { |
267 shouldReportRootBounds = | 267 shouldReportRootBounds = |
268 targetFrame->securityContext()->getSecurityOrigin()->canAccess( | 268 targetFrame->securityContext()->getSecurityOrigin()->canAccess( |
269 rootFrame->securityContext()->getSecurityOrigin()); | 269 rootFrame->securityContext()->getSecurityOrigin()); |
270 isDOMDescendant = (targetFrame->tree().top() == rootFrame); | 270 isDOMDescendant = (targetFrame->tree().top() == rootFrame); |
271 } | 271 } |
272 | 272 |
273 IntersectionObservation* observation = new IntersectionObservation( | 273 IntersectionObservation* observation = |
274 *this, *target, | 274 new IntersectionObservation(*this, *target, shouldReportRootBounds); |
275 shouldReportRootBounds | |
276 ? IntersectionGeometry::ReportRootBounds::kShouldReportRootBounds | |
277 : IntersectionGeometry::ReportRootBounds::kShouldNotReportRootBounds); | |
278 target->ensureIntersectionObserverData().addObservation(*observation); | 275 target->ensureIntersectionObserverData().addObservation(*observation); |
279 m_observations.add(observation); | 276 m_observations.add(observation); |
280 | 277 |
281 if (!isDOMDescendant) { | 278 if (!isDOMDescendant) { |
282 m_root->document().addConsoleMessage( | 279 m_root->document().addConsoleMessage( |
283 ConsoleMessage::create(JSMessageSource, WarningMessageLevel, | 280 ConsoleMessage::create(JSMessageSource, WarningMessageLevel, |
284 "IntersectionObserver.observe(target): target " | 281 "IntersectionObserver.observe(target): target " |
285 "element is not a descendant of root.")); | 282 "element is not a descendant of root.")); |
286 return; | 283 return; |
287 } | 284 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 | 415 |
419 DEFINE_TRACE(IntersectionObserver) { | 416 DEFINE_TRACE(IntersectionObserver) { |
420 visitor->template registerWeakMembers< | 417 visitor->template registerWeakMembers< |
421 IntersectionObserver, &IntersectionObserver::clearWeakMembers>(this); | 418 IntersectionObserver, &IntersectionObserver::clearWeakMembers>(this); |
422 visitor->trace(m_callback); | 419 visitor->trace(m_callback); |
423 visitor->trace(m_observations); | 420 visitor->trace(m_observations); |
424 visitor->trace(m_entries); | 421 visitor->trace(m_entries); |
425 } | 422 } |
426 | 423 |
427 } // namespace blink | 424 } // namespace blink |
OLD | NEW |