| 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/IntersectionObserverController.h" | 5 #include "core/dom/IntersectionObserverController.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 IntersectionObserverVector observers; | 55 IntersectionObserverVector observers; |
| 56 copyToVector(m_pendingIntersectionObservers, observers); | 56 copyToVector(m_pendingIntersectionObservers, observers); |
| 57 m_pendingIntersectionObservers.clear(); | 57 m_pendingIntersectionObservers.clear(); |
| 58 for (auto& observer : observers) | 58 for (auto& observer : observers) |
| 59 observer->deliver(); | 59 observer->deliver(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void IntersectionObserverController::computeTrackedIntersectionObservations() | 62 void IntersectionObserverController::computeTrackedIntersectionObservations() |
| 63 { | 63 { |
| 64 // TODO(szager): Need to define timestamp. | |
| 65 double timestamp = currentTime(); | |
| 66 for (auto& observer : m_trackedIntersectionObservers) { | 64 for (auto& observer : m_trackedIntersectionObservers) { |
| 67 observer->computeIntersectionObservations(timestamp); | 65 observer->computeIntersectionObservations(); |
| 68 if (observer->hasEntries()) | 66 if (observer->hasEntries()) |
| 69 scheduleIntersectionObserverForDelivery(*observer); | 67 scheduleIntersectionObserverForDelivery(*observer); |
| 70 } | 68 } |
| 71 } | 69 } |
| 72 | 70 |
| 73 void IntersectionObserverController::addTrackedObserver(IntersectionObserver& ob
server) | 71 void IntersectionObserverController::addTrackedObserver(IntersectionObserver& ob
server) |
| 74 { | 72 { |
| 75 m_trackedIntersectionObservers.add(&observer); | 73 m_trackedIntersectionObservers.add(&observer); |
| 76 } | 74 } |
| 77 | 75 |
| 78 void IntersectionObserverController::removeTrackedObserversForRoot(const Node& r
oot) | 76 void IntersectionObserverController::removeTrackedObserversForRoot(const Node& r
oot) |
| 79 { | 77 { |
| 80 HeapVector<Member<IntersectionObserver>> toRemove; | 78 HeapVector<Member<IntersectionObserver>> toRemove; |
| 81 for (auto& observer : m_trackedIntersectionObservers) { | 79 for (auto& observer : m_trackedIntersectionObservers) { |
| 82 if (observer->root() == &root) | 80 if (observer->root() == &root) |
| 83 toRemove.append(observer); | 81 toRemove.append(observer); |
| 84 } | 82 } |
| 85 m_trackedIntersectionObservers.removeAll(toRemove); | 83 m_trackedIntersectionObservers.removeAll(toRemove); |
| 86 } | 84 } |
| 87 | 85 |
| 88 DEFINE_TRACE(IntersectionObserverController) | 86 DEFINE_TRACE(IntersectionObserverController) |
| 89 { | 87 { |
| 90 visitor->trace(m_trackedIntersectionObservers); | 88 visitor->trace(m_trackedIntersectionObservers); |
| 91 visitor->trace(m_pendingIntersectionObservers); | 89 visitor->trace(m_pendingIntersectionObservers); |
| 92 ActiveDOMObject::trace(visitor); | 90 ActiveDOMObject::trace(visitor); |
| 93 } | 91 } |
| 94 | 92 |
| 95 } // namespace blink | 93 } // namespace blink |
| OLD | NEW |