Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: third_party/WebKit/Source/core/dom/IntersectionObserverController.h

Issue 1552213002: Implement suspend/resume for IntersectionObserver notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@intersection-observer
Patch Set: Create IntersectionObserverController on demand Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/dom/IntersectionObserver.h" 9 #include "core/dom/IntersectionObserver.h"
10 #include "platform/Timer.h" 10 #include "platform/Timer.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:
15 // https://docs.google.com/a/google.com/document/d/1hLK0eyT5_BzyNS4OkjsnoqqFQD YCbKfyBinj94OnLiQ
16
14 namespace blink { 17 namespace blink {
15 18
16 class IntersectionObserverController : public GarbageCollectedFinalized<Intersec tionObserverController> { 19 class IntersectionObserverController : public GarbageCollectedFinalized<Intersec tionObserverController>, public ActiveDOMObject {
17 public: 20 public:
18 IntersectionObserverController(); 21 static IntersectionObserverController* create(Document*);
19 ~IntersectionObserverController(); 22 ~IntersectionObserverController();
20 23
24 void resume() override;
25
21 void scheduleIntersectionObserverForDelivery(IntersectionObserver&); 26 void scheduleIntersectionObserverForDelivery(IntersectionObserver&);
22 void deliverIntersectionObservations(Timer<IntersectionObserverController>*) ; 27 void deliverIntersectionObservations(Timer<IntersectionObserverController>*) ;
23 void computeTrackedIntersectionObservations(); 28 void computeTrackedIntersectionObservations();
24 void addTrackedObserver(IntersectionObserver&); 29 void addTrackedObserver(IntersectionObserver&);
25 void removeTrackedObserversForRoot(const Element&); 30 void removeTrackedObserversForRoot(const Element&);
26 31
27 DECLARE_TRACE(); 32 DECLARE_TRACE();
28 33
29 private: 34 private:
30 // Design doc for IntersectionObserver implementation: 35 explicit IntersectionObserverController(Document*);
31 // https://docs.google.com/a/google.com/document/d/1hLK0eyT5_BzyNS4Okjsnoq qFQDYCbKfyBinj94OnLiQ
32 36
37 private:
33 Timer<IntersectionObserverController> m_timer; 38 Timer<IntersectionObserverController> m_timer;
34 // IntersectionObservers for which this is the tracking document. 39 // IntersectionObservers for which this is the tracking document.
35 HeapHashSet<WeakMember<IntersectionObserver>> m_trackedIntersectionObservers ; 40 HeapHashSet<WeakMember<IntersectionObserver>> m_trackedIntersectionObservers ;
36 // IntersectionObservers for which this is the execution context of the call back. 41 // IntersectionObservers for which this is the execution context of the call back.
37 HeapHashSet<Member<IntersectionObserver>> m_pendingIntersectionObservers; 42 HeapHashSet<Member<IntersectionObserver>> m_pendingIntersectionObservers;
43
44 bool m_timerFiredWhileSuspended;
38 }; 45 };
39 46
40 } // namespace blink 47 } // namespace blink
41 48
42 #endif // IntersectionObserverController_h 49 #endif // IntersectionObserverController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698