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