| 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 #ifndef IntersectionObserverController_h | 5 #ifndef IntersectionObserverController_h |
| 6 #define IntersectionObserverController_h | 6 #define IntersectionObserverController_h |
| 7 | 7 |
| 8 #include "core/dom/ActiveDOMObject.h" | 8 #include "core/dom/ActiveDOMObject.h" |
| 9 #include "core/dom/IdleRequestCallback.h" | 9 #include "core/dom/IdleRequestCallback.h" |
| 10 #include "core/dom/IntersectionObserver.h" | 10 #include "core/dom/IntersectionObserver.h" |
| 11 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
| 12 #include "wtf/HashSet.h" | 12 #include "wtf/HashSet.h" |
| 13 | 13 |
| 14 // Design doc for IntersectionObserver implementation: | 14 // Design doc for IntersectionObserver implementation: |
| 15 // https://docs.google.com/a/google.com/document/d/1hLK0eyT5_BzyNS4OkjsnoqqFQD
YCbKfyBinj94OnLiQ | 15 // https://docs.google.com/a/google.com/document/d/1hLK0eyT5_BzyNS4OkjsnoqqFQD
YCbKfyBinj94OnLiQ |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class CancellableTaskFactory; |
| 19 class Document; | 20 class Document; |
| 20 | 21 |
| 21 class IntersectionObserverController : public IdleRequestCallback, public Active
DOMObject { | 22 class IntersectionObserverController : public IdleRequestCallback, public Active
DOMObject { |
| 22 USING_GARBAGE_COLLECTED_MIXIN(IntersectionObserverController); | 23 USING_GARBAGE_COLLECTED_MIXIN(IntersectionObserverController); |
| 23 public: | 24 public: |
| 24 static IntersectionObserverController* create(Document*); | 25 static IntersectionObserverController* create(Document*); |
| 25 ~IntersectionObserverController(); | 26 ~IntersectionObserverController(); |
| 26 | 27 |
| 27 void resume() override; | 28 void resume() override; |
| 28 void handleEvent(IdleDeadline*) override; | 29 void handleEvent(IdleDeadline*) override; |
| 29 | 30 |
| 30 void scheduleIntersectionObserverForDelivery(IntersectionObserver&); | 31 void scheduleIntersectionObserverForDelivery(IntersectionObserver&); |
| 31 void deliverIntersectionObservations(); | 32 void deliverIntersectionObservations(); |
| 32 void computeTrackedIntersectionObservations(); | 33 void computeTrackedIntersectionObservations(); |
| 33 void addTrackedObserver(IntersectionObserver&); | 34 void addTrackedObserver(IntersectionObserver&); |
| 34 void removeTrackedObserversForRoot(const Node&); | 35 void removeTrackedObserversForRoot(const Node&); |
| 35 | 36 |
| 36 DECLARE_TRACE(); | 37 DECLARE_TRACE(); |
| 37 | 38 |
| 38 private: | 39 private: |
| 39 explicit IntersectionObserverController(Document*); | 40 explicit IntersectionObserverController(Document*); |
| 40 | 41 |
| 41 private: | 42 private: |
| 43 void deliverLowLatencyNotifications(); |
| 44 |
| 42 // IntersectionObservers for which this is the tracking document. | 45 // IntersectionObservers for which this is the tracking document. |
| 43 HeapHashSet<WeakMember<IntersectionObserver>> m_trackedIntersectionObservers
; | 46 HeapHashSet<WeakMember<IntersectionObserver>> m_trackedIntersectionObservers
; |
| 44 // IntersectionObservers for which this is the execution context of the call
back. | 47 // IntersectionObservers for which this is the execution context of the call
back. |
| 45 HeapHashSet<Member<IntersectionObserver>> m_pendingIntersectionObservers; | 48 HeapHashSet<Member<IntersectionObserver>> m_pendingIntersectionObservers; |
| 49 HeapHashSet<Member<IntersectionObserver>> m_pendingLowLatencyIntersectionObs
ervers; |
| 50 |
| 51 std::unique_ptr<CancellableTaskFactory> m_lowLatencyNotificationTask; |
| 46 | 52 |
| 47 int m_callbackID; | 53 int m_callbackID; |
| 48 bool m_callbackFiredWhileSuspended; | 54 bool m_callbackFiredWhileSuspended; |
| 55 bool m_lowLatencyCallbackFiredWhileSuspended; |
| 49 }; | 56 }; |
| 50 | 57 |
| 51 } // namespace blink | 58 } // namespace blink |
| 52 | 59 |
| 53 #endif // IntersectionObserverController_h | 60 #endif // IntersectionObserverController_h |
| OLD | NEW |