| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 170 } |
| 171 | 171 |
| 172 void IntersectionObserver::observe(Element* target) | 172 void IntersectionObserver::observe(Element* target) |
| 173 { | 173 { |
| 174 if (!m_root || !target || m_root.get() == target) | 174 if (!m_root || !target || m_root.get() == target) |
| 175 return; | 175 return; |
| 176 | 176 |
| 177 if (target->ensureIntersectionObserverData().getObservationFor(*this)) | 177 if (target->ensureIntersectionObserverData().getObservationFor(*this)) |
| 178 return; | 178 return; |
| 179 | 179 |
| 180 bool shouldReportRootBounds = target->document().frame()->securityContext()-
>getSecurityOrigin()->canAccess(rootNode()->document().frame()->securityContext(
)->getSecurityOrigin()); | 180 bool shouldReportRootBounds = false; |
| 181 LocalFrame* targetFrame = target->document().frame(); |
| 182 LocalFrame* rootFrame = rootNode()->document().frame(); |
| 183 if (targetFrame && rootFrame) |
| 184 shouldReportRootBounds = targetFrame->securityContext()->getSecurityOrig
in()->canAccess(rootFrame->securityContext()->getSecurityOrigin()); |
| 181 IntersectionObservation* observation = new IntersectionObservation(*this, *t
arget, shouldReportRootBounds); | 185 IntersectionObservation* observation = new IntersectionObservation(*this, *t
arget, shouldReportRootBounds); |
| 182 target->ensureIntersectionObserverData().addObservation(*observation); | 186 target->ensureIntersectionObserverData().addObservation(*observation); |
| 183 m_observations.add(observation); | 187 m_observations.add(observation); |
| 184 } | 188 } |
| 185 | 189 |
| 186 void IntersectionObserver::unobserve(Element* target) | 190 void IntersectionObserver::unobserve(Element* target) |
| 187 { | 191 { |
| 188 if (!target || !target->intersectionObserverData()) | 192 if (!target || !target->intersectionObserverData()) |
| 189 return; | 193 return; |
| 190 // TODO(szager): unobserve callback | 194 // TODO(szager): unobserve callback |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 308 |
| 305 DEFINE_TRACE(IntersectionObserver) | 309 DEFINE_TRACE(IntersectionObserver) |
| 306 { | 310 { |
| 307 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs
erver::clearWeakMembers>(this); | 311 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs
erver::clearWeakMembers>(this); |
| 308 visitor->trace(m_callback); | 312 visitor->trace(m_callback); |
| 309 visitor->trace(m_observations); | 313 visitor->trace(m_observations); |
| 310 visitor->trace(m_entries); | 314 visitor->trace(m_entries); |
| 311 } | 315 } |
| 312 | 316 |
| 313 } // namespace blink | 317 } // namespace blink |
| OLD | NEW |