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/ExceptionStatePlaceholder.h" | 8 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
9 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
10 #include "core/dom/IntersectionObservation.h" | 10 #include "core/dom/IntersectionObservation.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 const Length& leftMargin() const { return m_leftMargin; } | 52 const Length& leftMargin() const { return m_leftMargin; } |
53 void computeIntersectionObservations(); | 53 void computeIntersectionObservations(); |
54 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&); | 54 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&); |
55 void applyRootMargin(LayoutRect&) const; | 55 void applyRootMargin(LayoutRect&) const; |
56 unsigned firstThresholdGreaterThan(float ratio) const; | 56 unsigned firstThresholdGreaterThan(float ratio) const; |
57 void deliver(); | 57 void deliver(); |
58 void removeObservation(IntersectionObservation&); | 58 void removeObservation(IntersectionObservation&); |
59 bool hasEntries() const { return m_entries.size(); } | 59 bool hasEntries() const { return m_entries.size(); } |
60 const HeapLinkedHashSet<WeakMember<IntersectionObservation>>& observations() const { return m_observations; } | 60 const HeapLinkedHashSet<WeakMember<IntersectionObservation>>& observations() const { return m_observations; } |
61 | 61 |
62 // A low latency intersection observer delivers events with an immediately | |
63 // posted task instead of waiting for an idle period (or up to 100ms). | |
64 // TODO(skyostil): Figure out how we want to expose low latency mode for web | |
65 // authors and adjust/remove this API accordingly. | |
ojan
2016/09/06 21:16:35
FWIW, it looks like we're just going to change it
| |
66 void setLowLatency(bool lowLatency) { m_lowLatency = lowLatency; } | |
67 bool lowLatency() const { return m_lowLatency; } | |
68 | |
62 DECLARE_TRACE(); | 69 DECLARE_TRACE(); |
63 | 70 |
64 private: | 71 private: |
65 explicit IntersectionObserver(IntersectionObserverCallback&, Node&, const Ve ctor<Length>& rootMargin, const Vector<float>& thresholds); | 72 explicit IntersectionObserver(IntersectionObserverCallback&, Node&, const Ve ctor<Length>& rootMargin, const Vector<float>& thresholds); |
66 void clearWeakMembers(Visitor*); | 73 void clearWeakMembers(Visitor*); |
67 | 74 |
68 Member<IntersectionObserverCallback> m_callback; | 75 Member<IntersectionObserverCallback> m_callback; |
69 WeakMember<Node> m_root; | 76 WeakMember<Node> m_root; |
70 HeapLinkedHashSet<WeakMember<IntersectionObservation>> m_observations; | 77 HeapLinkedHashSet<WeakMember<IntersectionObservation>> m_observations; |
71 HeapVector<Member<IntersectionObserverEntry>> m_entries; | 78 HeapVector<Member<IntersectionObserverEntry>> m_entries; |
72 Vector<float> m_thresholds; | 79 Vector<float> m_thresholds; |
73 Length m_topMargin; | 80 Length m_topMargin; |
74 Length m_rightMargin; | 81 Length m_rightMargin; |
75 Length m_bottomMargin; | 82 Length m_bottomMargin; |
76 Length m_leftMargin; | 83 Length m_leftMargin; |
84 bool m_lowLatency; | |
77 }; | 85 }; |
78 | 86 |
79 } // namespace blink | 87 } // namespace blink |
80 | 88 |
81 #endif // IntersectionObserver_h | 89 #endif // IntersectionObserver_h |
OLD | NEW |