OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IntersectionObserver_h |
| 6 #define IntersectionObserver_h |
| 7 |
| 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "core/dom/Element.h" |
| 10 #include "core/dom/IntersectionObserverEntry.h" |
| 11 #include "platform/heap/Handle.h" |
| 12 #include "wtf/HashSet.h" |
| 13 #include "wtf/RefCounted.h" |
| 14 #include "wtf/Vector.h" |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 class ExceptionState; |
| 19 class IntersectionObserverCallback; |
| 20 class IntersectionObserver; |
| 21 class IntersectionObserverInit; |
| 22 |
| 23 using IntersectionObserverEntryVector = WillBeHeapVector<RefPtrWillBeMember<Inte
rsectionObserverEntry>>; |
| 24 using IntersectionObserverTargetVector = WillBeHeapVector<RefPtrWillBeWeakMember
<Element>>; |
| 25 |
| 26 class IntersectionObserver final : public RefCountedWillBeGarbageCollectedFinali
zed<IntersectionObserver>, public ScriptWrappable { |
| 27 DEFINE_WRAPPERTYPEINFO(); |
| 28 friend class Document; |
| 29 public: |
| 30 static PassRefPtrWillBeRawPtr<IntersectionObserver> create(Document*, const
IntersectionObserverInit&, PassOwnPtrWillBeRawPtr<IntersectionObserverCallback>
); |
| 31 static void resumeSuspendedObservers(); |
| 32 |
| 33 ~IntersectionObserver(); |
| 34 |
| 35 void observe(Element*, ExceptionState&); |
| 36 void unobserve(Element*, ExceptionState&); |
| 37 void disconnect(); |
| 38 IntersectionObserverEntryVector takeRecords(); |
| 39 |
| 40 void enqueueIntersectionObserverEntry(PassRefPtrWillBeRawPtr<IntersectionObs
erverEntry>); |
| 41 |
| 42 // Eagerly finalized as destructor accesses heap object members. |
| 43 EAGERLY_FINALIZE(); |
| 44 DECLARE_TRACE(); |
| 45 |
| 46 private: |
| 47 explicit IntersectionObserver(Document*, const IntersectionObserverInit&, P
assOwnPtrWillBeRawPtr<IntersectionObserverCallback>); |
| 48 void deliver(); |
| 49 bool shouldBeSuspended() const; |
| 50 |
| 51 OwnPtrWillBeMember<IntersectionObserverCallback> m_callback; |
| 52 RawPtrWillBeWeakMember<Document> m_document; |
| 53 IntersectionObserverEntryVector m_entries; |
| 54 IntersectionObserverTargetVector m_targets; |
| 55 }; |
| 56 |
| 57 } // namespace blink |
| 58 |
| 59 #endif // IntersectionObserver_h |
OLD | NEW |