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 #include "core/dom/IdleRequestOptions.h" | 8 #include "core/dom/IdleRequestOptions.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 typedef HeapVector<Member<IntersectionObserver>> IntersectionObserverVector; | |
sof
2016/05/24 07:16:32
now unused, forgot to remove this in ps#1.
| |
13 | |
14 IntersectionObserverController* IntersectionObserverController::create(Document* document) | 12 IntersectionObserverController* IntersectionObserverController::create(Document* document) |
15 { | 13 { |
16 IntersectionObserverController* result = new IntersectionObserverController( document); | 14 IntersectionObserverController* result = new IntersectionObserverController( document); |
17 result->suspendIfNeeded(); | 15 result->suspendIfNeeded(); |
18 return result; | 16 return result; |
19 } | 17 } |
20 | 18 |
21 IntersectionObserverController::IntersectionObserverController(Document* documen t) | 19 IntersectionObserverController::IntersectionObserverController(Document* documen t) |
22 : ActiveDOMObject(document) | 20 : ActiveDOMObject(document) |
23 , m_callbackID(0) | 21 , m_callbackID(0) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 m_callbackID = 0; | 55 m_callbackID = 0; |
58 deliverIntersectionObservations(); | 56 deliverIntersectionObservations(); |
59 } | 57 } |
60 | 58 |
61 void IntersectionObserverController::deliverIntersectionObservations() | 59 void IntersectionObserverController::deliverIntersectionObservations() |
62 { | 60 { |
63 if (getExecutionContext()->activeDOMObjectsAreSuspended()) { | 61 if (getExecutionContext()->activeDOMObjectsAreSuspended()) { |
64 m_callbackFiredWhileSuspended = true; | 62 m_callbackFiredWhileSuspended = true; |
65 return; | 63 return; |
66 } | 64 } |
67 IntersectionObserverVector observers; | 65 HeapHashSet<Member<IntersectionObserver>> observers; |
68 copyToVector(m_pendingIntersectionObservers, observers); | 66 m_pendingIntersectionObservers.swap(observers); |
69 m_pendingIntersectionObservers.clear(); | |
70 for (auto& observer : observers) | 67 for (auto& observer : observers) |
71 observer->deliver(); | 68 observer->deliver(); |
72 } | 69 } |
73 | 70 |
74 void IntersectionObserverController::computeTrackedIntersectionObservations() | 71 void IntersectionObserverController::computeTrackedIntersectionObservations() |
75 { | 72 { |
76 for (auto& observer : m_trackedIntersectionObservers) { | 73 for (auto& observer : m_trackedIntersectionObservers) { |
77 observer->computeIntersectionObservations(); | 74 observer->computeIntersectionObservations(); |
78 if (observer->hasEntries()) | 75 if (observer->hasEntries()) |
79 scheduleIntersectionObserverForDelivery(*observer); | 76 scheduleIntersectionObserverForDelivery(*observer); |
(...skipping 17 matching lines...) Expand all Loading... | |
97 | 94 |
98 DEFINE_TRACE(IntersectionObserverController) | 95 DEFINE_TRACE(IntersectionObserverController) |
99 { | 96 { |
100 visitor->trace(m_trackedIntersectionObservers); | 97 visitor->trace(m_trackedIntersectionObservers); |
101 visitor->trace(m_pendingIntersectionObservers); | 98 visitor->trace(m_pendingIntersectionObservers); |
102 ActiveDOMObject::trace(visitor); | 99 ActiveDOMObject::trace(visitor); |
103 IdleRequestCallback::trace(visitor); | 100 IdleRequestCallback::trace(visitor); |
104 } | 101 } |
105 | 102 |
106 } // namespace blink | 103 } // namespace blink |
OLD | NEW |