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 |
11 typedef HeapVector<Member<IntersectionObserver>> IntersectionObserverVector; | 11 typedef HeapVector<Member<IntersectionObserver>> IntersectionObserverVector; |
12 | 12 |
13 IntersectionObserverController::IntersectionObserverController() | 13 IntersectionObserverController::IntersectionObserverController() |
14 : m_timer(this, &IntersectionObserverController::deliverIntersectionObservat ions) | 14 : m_timer(this, &IntersectionObserverController::deliverIntersectionObservat ions) |
15 { | 15 { |
16 } | 16 } |
17 | 17 |
18 IntersectionObserverController::~IntersectionObserverController() { } | 18 IntersectionObserverController::~IntersectionObserverController() { } |
19 | 19 |
20 void IntersectionObserverController::scheduleIntersectionObserverForDelivery(Int ersectionObserver& observer) | 20 void IntersectionObserverController::scheduleIntersectionObserverForDelivery(Int ersectionObserver& observer) |
21 { | 21 { |
22 // TODO(szager): use idle callback with a timeout | 22 // TODO(szager): use idle callback with a timeout. Until we do that, there is no |
23 // reliable way to write a test for takeRecords, because it's impossible to guarantee | |
24 // that javascript will get a chance to run before the timer fires. | |
ojan
2016/01/12 00:43:05
As per in person discussion, not quite clear if th
| |
23 if (!m_timer.isActive()) | 25 if (!m_timer.isActive()) |
24 m_timer.startOneShot(0, BLINK_FROM_HERE); | 26 m_timer.startOneShot(0, BLINK_FROM_HERE); |
25 m_pendingIntersectionObservers.add(&observer); | 27 m_pendingIntersectionObservers.add(&observer); |
26 } | 28 } |
27 | 29 |
28 void IntersectionObserverController::deliverIntersectionObservations(Timer<Inter sectionObserverController>*) | 30 void IntersectionObserverController::deliverIntersectionObservations(Timer<Inter sectionObserverController>*) |
29 { | 31 { |
30 IntersectionObserverVector observers; | 32 IntersectionObserverVector observers; |
31 copyToVector(m_pendingIntersectionObservers, observers); | 33 copyToVector(m_pendingIntersectionObservers, observers); |
32 m_pendingIntersectionObservers.clear(); | 34 m_pendingIntersectionObservers.clear(); |
(...skipping 25 matching lines...) Expand all Loading... | |
58 m_trackedIntersectionObservers.removeAll(toRemove); | 60 m_trackedIntersectionObservers.removeAll(toRemove); |
59 } | 61 } |
60 | 62 |
61 DEFINE_TRACE(IntersectionObserverController) | 63 DEFINE_TRACE(IntersectionObserverController) |
62 { | 64 { |
63 visitor->trace(m_trackedIntersectionObservers); | 65 visitor->trace(m_trackedIntersectionObservers); |
64 visitor->trace(m_pendingIntersectionObservers); | 66 visitor->trace(m_pendingIntersectionObservers); |
65 } | 67 } |
66 | 68 |
67 } // namespace blink | 69 } // namespace blink |
OLD | NEW |