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 IntersectionObserver_h | 5 #ifndef IntersectionObserver_h |
6 #define IntersectionObserver_h | 6 #define IntersectionObserver_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
9 #include "core/dom/Element.h" | |
10 #include "core/dom/IntersectionObservation.h" | 9 #include "core/dom/IntersectionObservation.h" |
11 #include "core/dom/IntersectionObserverEntry.h" | 10 #include "core/dom/IntersectionObserverEntry.h" |
| 11 #include "platform/Length.h" |
12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
13 #include "wtf/HashSet.h" | 13 #include "wtf/HashSet.h" |
14 #include "wtf/RefCounted.h" | |
15 #include "wtf/Vector.h" | 14 #include "wtf/Vector.h" |
16 | 15 |
17 namespace blink { | 16 namespace blink { |
18 | 17 |
| 18 class Element; |
19 class ExceptionState; | 19 class ExceptionState; |
| 20 class LayoutObject; |
20 class IntersectionObserverCallback; | 21 class IntersectionObserverCallback; |
21 class IntersectionObserverInit; | 22 class IntersectionObserverInit; |
22 | 23 |
23 // TODO(oilpan): Switch to GarbageCollected<> after oilpan ships | |
24 class IntersectionObserver final : public GarbageCollectedFinalized<Intersection
Observer>, public ScriptWrappable { | 24 class IntersectionObserver final : public GarbageCollectedFinalized<Intersection
Observer>, public ScriptWrappable { |
25 DEFINE_WRAPPERTYPEINFO(); | 25 DEFINE_WRAPPERTYPEINFO(); |
26 | 26 |
27 public: | 27 public: |
28 static IntersectionObserver* create(const IntersectionObserverInit&, Interse
ctionObserverCallback&, ExceptionState&); | 28 static IntersectionObserver* create(const IntersectionObserverInit&, Interse
ctionObserverCallback&, ExceptionState&); |
29 static void resumeSuspendedObservers(); | 29 static void resumeSuspendedObservers(); |
30 | 30 |
31 // API methods | 31 // API methods |
32 void observe(Element*); | 32 void observe(Element*); |
33 void unobserve(Element*); | 33 void unobserve(Element*); |
(...skipping 14 matching lines...) Expand all Loading... |
48 unsigned firstThresholdGreaterThan(float ratio) const; | 48 unsigned firstThresholdGreaterThan(float ratio) const; |
49 void deliver(); | 49 void deliver(); |
50 void removeObservation(IntersectionObservation&); | 50 void removeObservation(IntersectionObservation&); |
51 bool hasEntries() const { return m_entries.size(); } | 51 bool hasEntries() const { return m_entries.size(); } |
52 const HeapHashSet<WeakMember<IntersectionObservation>>& observations() const
{ return m_observations; } | 52 const HeapHashSet<WeakMember<IntersectionObservation>>& observations() const
{ return m_observations; } |
53 | 53 |
54 DECLARE_TRACE(); | 54 DECLARE_TRACE(); |
55 | 55 |
56 private: | 56 private: |
57 explicit IntersectionObserver(IntersectionObserverCallback&, Node&, const Ve
ctor<Length>& rootMargin, const Vector<float>& thresholds); | 57 explicit IntersectionObserver(IntersectionObserverCallback&, Node&, const Ve
ctor<Length>& rootMargin, const Vector<float>& thresholds); |
58 #if ENABLE(OILPAN) | |
59 void clearWeakMembers(Visitor*); | 58 void clearWeakMembers(Visitor*); |
60 #endif | |
61 | 59 |
62 Member<IntersectionObserverCallback> m_callback; | 60 Member<IntersectionObserverCallback> m_callback; |
63 WeakMember<Node> m_root; | 61 WeakMember<Node> m_root; |
64 HeapHashSet<WeakMember<IntersectionObservation>> m_observations; | 62 HeapHashSet<WeakMember<IntersectionObservation>> m_observations; |
65 HeapVector<Member<IntersectionObserverEntry>> m_entries; | 63 HeapVector<Member<IntersectionObserverEntry>> m_entries; |
66 Vector<float> m_thresholds; | 64 Vector<float> m_thresholds; |
67 Length m_topMargin; | 65 Length m_topMargin; |
68 Length m_rightMargin; | 66 Length m_rightMargin; |
69 Length m_bottomMargin; | 67 Length m_bottomMargin; |
70 Length m_leftMargin; | 68 Length m_leftMargin; |
71 }; | 69 }; |
72 | 70 |
73 } // namespace blink | 71 } // namespace blink |
74 | 72 |
75 #endif // IntersectionObserver_h | 73 #endif // IntersectionObserver_h |
OLD | NEW |