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" | 9 #include "core/dom/Element.h" |
10 #include "core/dom/IntersectionObservation.h" | 10 #include "core/dom/IntersectionObservation.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 public: | 26 public: |
27 static IntersectionObserver* create(const IntersectionObserverInit&, Interse
ctionObserverCallback&, ExceptionState&); | 27 static IntersectionObserver* create(const IntersectionObserverInit&, Interse
ctionObserverCallback&, ExceptionState&); |
28 static void resumeSuspendedObservers(); | 28 static void resumeSuspendedObservers(); |
29 | 29 |
30 // API methods | 30 // API methods |
31 void observe(Element*, ExceptionState&); | 31 void observe(Element*, ExceptionState&); |
32 void unobserve(Element*, ExceptionState&); | 32 void unobserve(Element*, ExceptionState&); |
33 HeapVector<Member<IntersectionObserverEntry>> takeRecords(); | 33 HeapVector<Member<IntersectionObserverEntry>> takeRecords(); |
34 | 34 |
35 Element* root() { return m_root.get(); } | 35 Node* root() const { return m_root.get(); } |
36 LayoutObject* rootLayoutObject(); | 36 LayoutObject* rootLayoutObject() const; |
37 bool hasPercentMargin() const; | 37 bool hasPercentMargin() const; |
38 const Length& topMargin() const { return m_topMargin; } | 38 const Length& topMargin() const { return m_topMargin; } |
39 const Length& rightMargin() const { return m_rightMargin; } | 39 const Length& rightMargin() const { return m_rightMargin; } |
40 const Length& bottomMargin() const { return m_bottomMargin; } | 40 const Length& bottomMargin() const { return m_bottomMargin; } |
41 const Length& leftMargin() const { return m_leftMargin; } | 41 const Length& leftMargin() const { return m_leftMargin; } |
42 bool isDescendantOfRoot(const Element*) const; | 42 bool isDescendantOfRoot(const Element*) const; |
43 void computeIntersectionObservations(double timestamp); | 43 void computeIntersectionObservations(double timestamp); |
44 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&); | 44 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&); |
45 void applyRootMargin(LayoutRect&) const; | 45 void applyRootMargin(LayoutRect&) const; |
46 unsigned firstThresholdGreaterThan(float ratio) const; | 46 unsigned firstThresholdGreaterThan(float ratio) const; |
47 void deliver(); | 47 void deliver(); |
48 void setActive(bool); | 48 void setActive(bool); |
49 void disconnect(); | 49 void disconnect(); |
50 void removeObservation(IntersectionObservation&); | 50 void removeObservation(IntersectionObservation&); |
51 | 51 |
52 DECLARE_TRACE(); | 52 DECLARE_TRACE(); |
53 | 53 |
54 private: | 54 private: |
55 explicit IntersectionObserver(IntersectionObserverCallback&, Element&, const
Vector<Length>& rootMargin, const Vector<float>& thresholds); | 55 explicit IntersectionObserver(IntersectionObserverCallback&, Node&, const Ve
ctor<Length>& rootMargin, const Vector<float>& thresholds); |
56 | 56 |
57 void checkRootAndDetachIfNeeded(); | 57 void checkRootAndDetachIfNeeded(); |
58 | 58 |
59 Member<IntersectionObserverCallback> m_callback; | 59 Member<IntersectionObserverCallback> m_callback; |
60 WeakPtrWillBeWeakMember<Element> m_root; | 60 WeakPtrWillBeWeakMember<Node> m_root; |
61 HeapHashSet<WeakMember<IntersectionObservation>> m_observations; | 61 HeapHashSet<WeakMember<IntersectionObservation>> m_observations; |
62 HeapVector<Member<IntersectionObserverEntry>> m_entries; | 62 HeapVector<Member<IntersectionObserverEntry>> m_entries; |
63 Vector<float> m_thresholds; | 63 Vector<float> m_thresholds; |
64 Length m_topMargin; | 64 Length m_topMargin; |
65 Length m_rightMargin; | 65 Length m_rightMargin; |
66 Length m_bottomMargin; | 66 Length m_bottomMargin; |
67 Length m_leftMargin; | 67 Length m_leftMargin; |
68 }; | 68 }; |
69 | 69 |
70 } // namespace blink | 70 } // namespace blink |
71 | 71 |
72 #endif // IntersectionObserver_h | 72 #endif // IntersectionObserver_h |
OLD | NEW |