Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: third_party/WebKit/Source/core/dom/IntersectionObserver.h

Issue 1600243002: Revert of Use registerWeakMembers to clean up IntersectionObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/IntersectionObserver.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "core/dom/IntersectionObserverEntry.h" 11 #include "core/dom/IntersectionObserverEntry.h"
12 #include "platform/heap/Handle.h" 12 #include "platform/heap/Handle.h"
13 #include "wtf/HashSet.h" 13 #include "wtf/HashSet.h"
14 #include "wtf/RefCounted.h" 14 #include "wtf/RefCounted.h"
15 #include "wtf/Vector.h" 15 #include "wtf/Vector.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 class ExceptionState; 19 class ExceptionState;
20 class IntersectionObserverCallback; 20 class IntersectionObserverCallback;
21 class IntersectionObserverInit; 21 class IntersectionObserverInit;
22 22
23 // TODO(oilpan): Switch to GarbageCollected<> after oilpan ships 23 // TODO(oilpan): Switch to GarbageCollected<> after oilpan ships
24 class IntersectionObserver final : public GarbageCollectedFinalized<Intersection Observer>, public ScriptWrappable { 24 class IntersectionObserver final : public GarbageCollectedFinalized<Intersection Observer>, public ScriptWrappable {
25 DEFINE_WRAPPERTYPEINFO(); 25 DEFINE_WRAPPERTYPEINFO();
26 26
27 public: 27 public:
28 static IntersectionObserver* create(const IntersectionObserverInit&, Interse ctionObserverCallback&, ExceptionState&); 28 static IntersectionObserver* create(const IntersectionObserverInit&, Interse ctionObserverCallback&, ExceptionState&);
29 static void resumeSuspendedObservers(); 29 static void resumeSuspendedObservers();
30 static void rootDisappearedCallback(Visitor*, void*);
31 30
32 // API methods 31 // API methods
33 void observe(Element*, ExceptionState&); 32 void observe(Element*, ExceptionState&);
34 void unobserve(Element*, ExceptionState&); 33 void unobserve(Element*, ExceptionState&);
35 HeapVector<Member<IntersectionObserverEntry>> takeRecords(); 34 HeapVector<Member<IntersectionObserverEntry>> takeRecords();
36 35
37 Node* root() const { return m_root.get(); } 36 Node* root() const { return m_root.get(); }
38 LayoutObject* rootLayoutObject() const; 37 LayoutObject* rootLayoutObject() const;
39 bool hasPercentMargin() const; 38 bool hasPercentMargin() const;
40 const Length& topMargin() const { return m_topMargin; } 39 const Length& topMargin() const { return m_topMargin; }
41 const Length& rightMargin() const { return m_rightMargin; } 40 const Length& rightMargin() const { return m_rightMargin; }
42 const Length& bottomMargin() const { return m_bottomMargin; } 41 const Length& bottomMargin() const { return m_bottomMargin; }
43 const Length& leftMargin() const { return m_leftMargin; } 42 const Length& leftMargin() const { return m_leftMargin; }
44 bool isDescendantOfRoot(const Element*) const; 43 bool isDescendantOfRoot(const Element*) const;
45 void computeIntersectionObservations(double timestamp); 44 void computeIntersectionObservations(double timestamp);
46 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&); 45 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&);
47 void applyRootMargin(LayoutRect&) const; 46 void applyRootMargin(LayoutRect&) const;
48 unsigned firstThresholdGreaterThan(float ratio) const; 47 unsigned firstThresholdGreaterThan(float ratio) const;
49 void deliver(); 48 void deliver();
50 void setActive(bool); 49 void setActive(bool);
51 void disconnect(); 50 void disconnect();
52 void removeObservation(IntersectionObservation&); 51 void removeObservation(IntersectionObservation&);
53 bool hasEntries() const { return m_entries.size(); } 52 bool hasEntries() const { return m_entries.size(); }
54 53
55 DECLARE_TRACE(); 54 DECLARE_TRACE();
56 55
57 private: 56 private:
58 explicit IntersectionObserver(IntersectionObserverCallback&, Node&, const Ve ctor<Length>& rootMargin, const Vector<float>& thresholds); 57 explicit IntersectionObserver(IntersectionObserverCallback&, Node&, const Ve ctor<Length>& rootMargin, const Vector<float>& thresholds);
59 58
59 void checkRootAndDetachIfNeeded();
60
60 Member<IntersectionObserverCallback> m_callback; 61 Member<IntersectionObserverCallback> m_callback;
61 WeakPtrWillBeWeakMember<Node> m_root; 62 WeakPtrWillBeWeakMember<Node> m_root;
62 HeapHashSet<WeakMember<IntersectionObservation>> m_observations; 63 HeapHashSet<WeakMember<IntersectionObservation>> m_observations;
63 HeapVector<Member<IntersectionObserverEntry>> m_entries; 64 HeapVector<Member<IntersectionObserverEntry>> m_entries;
64 Vector<float> m_thresholds; 65 Vector<float> m_thresholds;
65 Length m_topMargin; 66 Length m_topMargin;
66 Length m_rightMargin; 67 Length m_rightMargin;
67 Length m_bottomMargin; 68 Length m_bottomMargin;
68 Length m_leftMargin; 69 Length m_leftMargin;
69 }; 70 };
70 71
71 } // namespace blink 72 } // namespace blink
72 73
73 #endif // IntersectionObserver_h 74 #endif // IntersectionObserver_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/IntersectionObserver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698