| 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/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "core/dom/IntersectionObservation.h" | 10 #include "core/dom/IntersectionObservation.h" |
| 10 #include "core/dom/IntersectionObserverEntry.h" | 11 #include "core/dom/IntersectionObserverEntry.h" |
| 11 #include "platform/Length.h" | 12 #include "platform/Length.h" |
| 12 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
| 13 #include "wtf/HashSet.h" | 14 #include "wtf/HashSet.h" |
| 14 #include "wtf/Vector.h" | 15 #include "wtf/Vector.h" |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 | 18 |
| 19 class Document; |
| 18 class Element; | 20 class Element; |
| 19 class ExceptionState; | 21 class ExceptionState; |
| 20 class LayoutObject; | 22 class LayoutObject; |
| 21 class IntersectionObserverCallback; | 23 class IntersectionObserverCallback; |
| 22 class IntersectionObserverInit; | 24 class IntersectionObserverInit; |
| 23 | 25 |
| 24 class CORE_EXPORT IntersectionObserver final : public GarbageCollectedFinalized<
IntersectionObserver>, public ScriptWrappable { | 26 class CORE_EXPORT IntersectionObserver final : public GarbageCollectedFinalized<
IntersectionObserver>, public ScriptWrappable { |
| 25 DEFINE_WRAPPERTYPEINFO(); | 27 DEFINE_WRAPPERTYPEINFO(); |
| 26 | 28 |
| 27 public: | 29 public: |
| 30 using EventCallback = Function<void(const HeapVector<Member<IntersectionObse
rverEntry>>&), WTF::SameThreadAffinity>; |
| 31 |
| 28 static IntersectionObserver* create(const IntersectionObserverInit&, Interse
ctionObserverCallback&, ExceptionState&); | 32 static IntersectionObserver* create(const IntersectionObserverInit&, Interse
ctionObserverCallback&, ExceptionState&); |
| 33 static IntersectionObserver* create(const Vector<Length>& rootMargin, const
Vector<float>& thresholds, Document*, std::unique_ptr<EventCallback>); |
| 29 static void resumeSuspendedObservers(); | 34 static void resumeSuspendedObservers(); |
| 30 | 35 |
| 31 // API methods | 36 // API methods. |
| 32 void observe(Element*, ExceptionState&); | 37 void observe(Element*, ExceptionState& = ASSERT_NO_EXCEPTION); |
| 33 void unobserve(Element*, ExceptionState&); | 38 void unobserve(Element*, ExceptionState& = ASSERT_NO_EXCEPTION); |
| 34 void disconnect(ExceptionState&); | 39 void disconnect(ExceptionState&); |
| 35 HeapVector<Member<IntersectionObserverEntry>> takeRecords(ExceptionState&); | 40 HeapVector<Member<IntersectionObserverEntry>> takeRecords(ExceptionState&); |
| 36 | 41 |
| 37 // API attributes | 42 // API attributes. |
| 38 Element* root() const; | 43 Element* root() const; |
| 39 String rootMargin() const; | 44 String rootMargin() const; |
| 40 const Vector<float>& thresholds() const { return m_thresholds; } | 45 const Vector<float>& thresholds() const { return m_thresholds; } |
| 41 | 46 |
| 42 Node* rootNode() const { return m_root.get(); } | 47 Node* rootNode() const { return m_root.get(); } |
| 43 LayoutObject* rootLayoutObject() const; | 48 LayoutObject* rootLayoutObject() const; |
| 44 const Length& topMargin() const { return m_topMargin; } | 49 const Length& topMargin() const { return m_topMargin; } |
| 45 const Length& rightMargin() const { return m_rightMargin; } | 50 const Length& rightMargin() const { return m_rightMargin; } |
| 46 const Length& bottomMargin() const { return m_bottomMargin; } | 51 const Length& bottomMargin() const { return m_bottomMargin; } |
| 47 const Length& leftMargin() const { return m_leftMargin; } | 52 const Length& leftMargin() const { return m_leftMargin; } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 67 Vector<float> m_thresholds; | 72 Vector<float> m_thresholds; |
| 68 Length m_topMargin; | 73 Length m_topMargin; |
| 69 Length m_rightMargin; | 74 Length m_rightMargin; |
| 70 Length m_bottomMargin; | 75 Length m_bottomMargin; |
| 71 Length m_leftMargin; | 76 Length m_leftMargin; |
| 72 }; | 77 }; |
| 73 | 78 |
| 74 } // namespace blink | 79 } // namespace blink |
| 75 | 80 |
| 76 #endif // IntersectionObserver_h | 81 #endif // IntersectionObserver_h |
| OLD | NEW |