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

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: Added dispose() methods for expicit cleanup 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;
esprehn 2015/12/17 01:40:29 not used
szager1 2015/12/17 20:27:26 Removed.
24
25 class IntersectionObserver final : public GarbageCollectedFinalized<Intersection Observer>, public ScriptWrappable {
26 DEFINE_WRAPPERTYPEINFO();
27
28 public:
29 static IntersectionObserver* create(const IntersectionObserverInit&, Interse ctionObserverCallback&, ExceptionState&);
30 static void resumeSuspendedObservers();
31
32 // API methods
33 void observe(Element*, ExceptionState&);
34 void unobserve(Element*, ExceptionState&);
35 void disconnect();
36 HeapVector<Member<IntersectionObserverEntry>> takeRecords();
37
38 Element* root() { return m_root.get(); }
39 LayoutObject* rootLayoutObject();
40 bool isDescendantOfRoot(const Element*) const;
41 void computeIntersectionObservations(double timestamp);
42 void disconnect(IntersectionObservation&);
43 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&);
44 void applyRootMargin(LayoutRect&) const;
45 unsigned firstThresholdGreaterThan(float ratio) const;
46 bool shouldBeSuspended() const;
47 void deliver();
48 void setActive(bool);
49 bool hasPercentMargin() const;
50 const Length& topMargin() const { return m_topMargin; }
51 const Length& rightMargin() const { return m_rightMargin; }
52 const Length& bottomMargin() const { return m_bottomMargin; }
53 const Length& leftMargin() const { return m_leftMargin; }
54
55 #if !ENABLE(OILPAN)
56 void dispose();
57 #endif
58
59 DECLARE_TRACE();
60
61 private:
62 explicit IntersectionObserver(IntersectionObserverCallback&, Element&, const Vector<Length>& rootMargin, const Vector<float>& thresholds);
63
64 void checkRootAndDetachIfNeeded();
65
66 Member<IntersectionObserverCallback> m_callback;
67 WeakPtrWillBeWeakMember<Element> m_root;
68 HeapHashSet<WeakMember<IntersectionObservation>> m_observations;
69 HeapVector<Member<IntersectionObserverEntry>> m_entries;
70 Vector<float> m_thresholds;
71 Length m_topMargin;
72 Length m_rightMargin;
73 Length m_bottomMargin;
74 Length m_leftMargin;
75 };
76
77 } // namespace blink
78
79 #endif // IntersectionObserver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698