| 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" |
| 11 #include "core/dom/IntersectionObserverEntry.h" | 11 #include "core/dom/IntersectionObserverEntry.h" |
| 12 #include "platform/Length.h" | 12 #include "platform/Length.h" |
| 13 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
| 14 #include "wtf/HashSet.h" | 14 #include "wtf/HashSet.h" |
| 15 #include "wtf/Vector.h" | 15 #include "wtf/Vector.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class Document; | 19 class Document; |
| 20 class Element; | 20 class Element; |
| 21 class ExceptionState; | 21 class ExceptionState; |
| 22 class LayoutObject; | |
| 23 class IntersectionObserverCallback; | 22 class IntersectionObserverCallback; |
| 24 class IntersectionObserverInit; | 23 class IntersectionObserverInit; |
| 25 | 24 |
| 26 class CORE_EXPORT IntersectionObserver final | 25 class CORE_EXPORT IntersectionObserver final |
| 27 : public GarbageCollectedFinalized<IntersectionObserver>, | 26 : public GarbageCollectedFinalized<IntersectionObserver>, |
| 28 public ScriptWrappable { | 27 public ScriptWrappable { |
| 29 DEFINE_WRAPPERTYPEINFO(); | 28 DEFINE_WRAPPERTYPEINFO(); |
| 30 | 29 |
| 31 public: | 30 public: |
| 32 using EventCallback = | 31 using EventCallback = |
| (...skipping 24 matching lines...) Expand all Loading... |
| 57 void unobserve(Element*, ExceptionState& = ASSERT_NO_EXCEPTION); | 56 void unobserve(Element*, ExceptionState& = ASSERT_NO_EXCEPTION); |
| 58 void disconnect(ExceptionState& = ASSERT_NO_EXCEPTION); | 57 void disconnect(ExceptionState& = ASSERT_NO_EXCEPTION); |
| 59 HeapVector<Member<IntersectionObserverEntry>> takeRecords(ExceptionState&); | 58 HeapVector<Member<IntersectionObserverEntry>> takeRecords(ExceptionState&); |
| 60 | 59 |
| 61 // API attributes. | 60 // API attributes. |
| 62 Element* root() const; | 61 Element* root() const; |
| 63 String rootMargin() const; | 62 String rootMargin() const; |
| 64 const Vector<float>& thresholds() const { return m_thresholds; } | 63 const Vector<float>& thresholds() const { return m_thresholds; } |
| 65 | 64 |
| 66 Node* rootNode() const { return m_root.get(); } | 65 Node* rootNode() const { return m_root.get(); } |
| 67 LayoutObject* rootLayoutObject() const; | |
| 68 const Length& topMargin() const { return m_topMargin; } | 66 const Length& topMargin() const { return m_topMargin; } |
| 69 const Length& rightMargin() const { return m_rightMargin; } | 67 const Length& rightMargin() const { return m_rightMargin; } |
| 70 const Length& bottomMargin() const { return m_bottomMargin; } | 68 const Length& bottomMargin() const { return m_bottomMargin; } |
| 71 const Length& leftMargin() const { return m_leftMargin; } | 69 const Length& leftMargin() const { return m_leftMargin; } |
| 72 void computeIntersectionObservations(); | 70 void computeIntersectionObservations(); |
| 73 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&); | 71 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&); |
| 74 void applyRootMargin(LayoutRect&) const; | |
| 75 unsigned firstThresholdGreaterThan(float ratio) const; | 72 unsigned firstThresholdGreaterThan(float ratio) const; |
| 76 void deliver(); | 73 void deliver(); |
| 77 void removeObservation(IntersectionObservation&); | 74 void removeObservation(IntersectionObservation&); |
| 78 bool hasEntries() const { return m_entries.size(); } | 75 bool hasEntries() const { return m_entries.size(); } |
| 79 const HeapLinkedHashSet<WeakMember<IntersectionObservation>>& observations() | 76 const HeapLinkedHashSet<WeakMember<IntersectionObservation>>& observations() |
| 80 const { | 77 const { |
| 81 return m_observations; | 78 return m_observations; |
| 82 } | 79 } |
| 83 | 80 |
| 84 // Set the assumed initial state of the observed element. Note that this can | 81 // Set the assumed initial state of the observed element. Note that this can |
| (...skipping 19 matching lines...) Expand all Loading... |
| 104 Length m_topMargin; | 101 Length m_topMargin; |
| 105 Length m_rightMargin; | 102 Length m_rightMargin; |
| 106 Length m_bottomMargin; | 103 Length m_bottomMargin; |
| 107 Length m_leftMargin; | 104 Length m_leftMargin; |
| 108 InitialState m_initialState; | 105 InitialState m_initialState; |
| 109 }; | 106 }; |
| 110 | 107 |
| 111 } // namespace blink | 108 } // namespace blink |
| 112 | 109 |
| 113 #endif // IntersectionObserver_h | 110 #endif // IntersectionObserver_h |
| OLD | NEW |