| 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 bool hasEntries() const { return m_entries.size(); } | 51 bool hasEntries() const { return m_entries.size(); } |
| 52 | 52 |
| 53 DECLARE_TRACE(); | 53 DECLARE_TRACE(); |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 explicit IntersectionObserver(IntersectionObserverCallback&, Element&, const
Vector<Length>& rootMargin, const Vector<float>& thresholds); | 56 explicit IntersectionObserver(IntersectionObserverCallback&, Node&, const Ve
ctor<Length>& rootMargin, const Vector<float>& thresholds); |
| 57 | 57 |
| 58 void checkRootAndDetachIfNeeded(); | 58 void checkRootAndDetachIfNeeded(); |
| 59 | 59 |
| 60 Member<IntersectionObserverCallback> m_callback; | 60 Member<IntersectionObserverCallback> m_callback; |
| 61 WeakPtrWillBeWeakMember<Element> m_root; | 61 WeakPtrWillBeWeakMember<Node> m_root; |
| 62 HeapHashSet<WeakMember<IntersectionObservation>> m_observations; | 62 HeapHashSet<WeakMember<IntersectionObservation>> m_observations; |
| 63 HeapVector<Member<IntersectionObserverEntry>> m_entries; | 63 HeapVector<Member<IntersectionObserverEntry>> m_entries; |
| 64 Vector<float> m_thresholds; | 64 Vector<float> m_thresholds; |
| 65 Length m_topMargin; | 65 Length m_topMargin; |
| 66 Length m_rightMargin; | 66 Length m_rightMargin; |
| 67 Length m_bottomMargin; | 67 Length m_bottomMargin; |
| 68 Length m_leftMargin; | 68 Length m_leftMargin; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 } // namespace blink | 71 } // namespace blink |
| 72 | 72 |
| 73 #endif // IntersectionObserver_h | 73 #endif // IntersectionObserver_h |
| OLD | NEW |