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

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

Issue 1449623002: IntersectionObserver: second cut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Clarify the tear-down path for observers and observations. Created 5 years, 1 month 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef IntersectionObserver_h
6 #define IntersectionObserver_h
7
8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "core/dom/Element.h"
10 #include "core/dom/IntersectionObservation.h"
11 #include "core/dom/IntersectionObservationRegistry.h"
12 #include "core/dom/IntersectionObserverEntry.h"
13 #include "platform/heap/Handle.h"
14 #include "wtf/HashSet.h"
15 #include "wtf/RefCounted.h"
16 #include "wtf/Vector.h"
17
18 namespace blink {
19
20 class ExceptionState;
21 class IntersectionObserverCallback;
22 class IntersectionObserverInit;
23
24 typedef WillBeHeapVector<RefPtrWillBeRawPtr<IntersectionObserverEntry>> Intersec tionObserverEntryVector;
25
26 class IntersectionObserver final : public RefCountedWillBeGarbageCollectedFinali zed<IntersectionObserver>, public ScriptWrappable {
haraken 2015/11/16 00:41:35 You don't need to use WillBe types.
szager1 2015/11/19 19:15:38 Working on this...
27 DEFINE_WRAPPERTYPEINFO();
28 friend class IntersectionObserverRegistry;
29 public:
30 static PassRefPtrWillBeRawPtr<IntersectionObserver> create(const Intersectio nObserverInit&, PassOwnPtrWillBeRawPtr<IntersectionObserverCallback>, ExceptionS tate&);
31 static void resumeSuspendedObservers();
32
33 ~IntersectionObserver();
34
35 bool checkTargetHierarchy(Element*);
36 Document& getTrackingDocumentForTarget(Element*);
37 void observe(Element*, ExceptionState&);
38 void unobserve(Element*, ExceptionState&);
39 void disconnect(IntersectionObservation&);
40 void disconnect();
41 IntersectionObserverEntryVector takeRecords();
42
43 void enqueueIntersectionObserverEntry(PassRefPtrWillBeRawPtr<IntersectionObs erverEntry>);
44
45 bool hasRoot() const { return m_hasRoot; }
46 Element* root() { return m_root.get(); }
47 Document* trackingDocument() { return m_trackingDocument.get(); }
48 const Vector<float>& thresholds() const { return m_thresholds; }
49 size_t firstThresholdGreaterThan(float ratio) const;
50 bool shouldBeSuspended() const;
51 void deliver();
52
53 // Eagerly finalized as destructor accesses heap object members.
54 EAGERLY_FINALIZE();
haraken 2015/11/16 00:41:35 I guess you don't need this. The destructor is not
szager1 2015/11/19 19:15:38 Done.
55 DECLARE_TRACE();
56
57 private:
58 explicit IntersectionObserver(PassOwnPtrWillBeRawPtr<IntersectionObserverCal lback>, RefPtrWillBeRawPtr<Element>, int, const Vector<float>&);
59
60 PassRefPtr<IntersectionObservation> createObservation(Element*);
61
62 OwnPtrWillBeMember<IntersectionObserverCallback> m_callback;
63 WeakPtrWillBeWeakMember<Element> m_root;
64 WeakPtrWillBeWeakMember<Document> m_trackingDocument;
65 IntersectionObservation::HashSet m_observations;
66 IntersectionObserverEntryVector m_entries;
67 Vector<float> m_thresholds;
68 int m_rootMargin;
69 // m_root is a weak pointer, so may become null if the root Element is deall ocated.
70 // Only m_hasRoot indicates for certain that there *should* be a root.
71 bool m_hasRoot;
72 };
73
74 } // namespace blink
75
76 #endif // IntersectionObserver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698