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

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: Fix rootMargin parsing Created 5 years 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/IntersectionObserverEntry.h"
12 #include "platform/heap/Handle.h"
13 #include "wtf/HashSet.h"
14 #include "wtf/RefCounted.h"
15 #include "wtf/Vector.h"
16
17 namespace blink {
18
19 class ExceptionState;
20 class IntersectionObserverCallback;
21 class IntersectionObserverInit;
22
23 typedef HeapVector<Member<IntersectionObserverEntry>> IntersectionObserverEntryV ector;
24
25 class IntersectionObserver final : public GarbageCollectedFinalized<Intersection Observer>, public ScriptWrappable {
26 DEFINE_WRAPPERTYPEINFO();
27 public:
28 typedef HeapHashSet<Member<IntersectionObserver>> HashSet;
29 typedef HeapHashSet<WeakMember<IntersectionObserver>> WeakHashSet;
30
31 static IntersectionObserver* create(const IntersectionObserverInit&, Interse ctionObserverCallback*, ExceptionState&);
32 static void resumeSuspendedObservers();
33
34 // API methods
35 void observe(Element*, ExceptionState&);
36 void unobserve(Element*, ExceptionState&);
37 void disconnect();
38 IntersectionObserverEntryVector takeRecords();
39
40 Element* root() { return m_root.get(); }
41 void computeIntersectionObservations(int);
42 void disconnect(IntersectionObservation&);
43 bool isDescendantOfRoot(Element*);
44 void enqueueIntersectionObserverEntry(IntersectionObserverEntry*);
45 size_t firstThresholdGreaterThan(float ratio) const;
46 bool shouldBeSuspended() const;
47 void deliver();
48 void setActive(bool);
49
50 DECLARE_TRACE();
51
52 private:
53 explicit IntersectionObserver(IntersectionObserverCallback*, Element*, int, const Vector<float>&);
54
55 void checkRootAndDetachIfNecessary();
56 IntersectionObservation* createObservation(Element*);
57
58 Member<IntersectionObserverCallback> m_callback;
59 WeakPtrWillBeWeakMember<Element> m_root;
60 Member<IntersectionObservation::WeakHashSet> m_observations;
61 Member<IntersectionObserverEntryVector> m_entries;
62 Vector<float> m_thresholds;
63 int m_rootMargin;
64 };
65
66 } // namespace blink
67
68 #endif // IntersectionObserver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698