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

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

Issue 2051253002: Start autoplay muted videos with autoplay attribute when they are visible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup and tests Created 4 years, 6 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
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/IntersectionObservation.h" 9 #include "core/dom/IntersectionObservation.h"
10 #include "core/dom/IntersectionObserverEntry.h" 10 #include "core/dom/IntersectionObserverEntry.h"
(...skipping 10 matching lines...) Expand all
21 class IntersectionObserverCallback; 21 class IntersectionObserverCallback;
22 class IntersectionObserverInit; 22 class IntersectionObserverInit;
23 23
24 class CORE_EXPORT IntersectionObserver final : public GarbageCollectedFinalized< IntersectionObserver>, public ScriptWrappable { 24 class CORE_EXPORT IntersectionObserver final : public GarbageCollectedFinalized< IntersectionObserver>, 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 30
31 // API methods 31 IntersectionObserver(IntersectionObserverCallback&, Node&, const Vector<Leng th>& rootMargin, const Vector<float>& thresholds);
32
33 // JS API methods.
32 void observe(Element*, ExceptionState&); 34 void observe(Element*, ExceptionState&);
esprehn 2016/06/14 16:01:18 void observe(Element*, ExceptionState& = ASSERT_NO
33 void unobserve(Element*, ExceptionState&); 35 void unobserve(Element*, ExceptionState&);
34 void disconnect(ExceptionState&); 36 void disconnect(ExceptionState&);
35 HeapVector<Member<IntersectionObserverEntry>> takeRecords(ExceptionState&); 37 HeapVector<Member<IntersectionObserverEntry>> takeRecords(ExceptionState&);
36 38
37 // API attributes 39 // JS API attributes.
38 Element* root() const; 40 Element* root() const;
39 String rootMargin() const; 41 String rootMargin() const;
40 const Vector<float>& thresholds() const { return m_thresholds; } 42 const Vector<float>& thresholds() const { return m_thresholds; }
41 43
44 // C++ API methods.
45 void observe(Element*);
46 void unobserve(Element*);
esprehn 2016/06/14 16:01:18 remove
47
42 Node* rootNode() const { return m_root.get(); } 48 Node* rootNode() const { return m_root.get(); }
43 LayoutObject* rootLayoutObject() const; 49 LayoutObject* rootLayoutObject() const;
44 const Length& topMargin() const { return m_topMargin; } 50 const Length& topMargin() const { return m_topMargin; }
45 const Length& rightMargin() const { return m_rightMargin; } 51 const Length& rightMargin() const { return m_rightMargin; }
46 const Length& bottomMargin() const { return m_bottomMargin; } 52 const Length& bottomMargin() const { return m_bottomMargin; }
47 const Length& leftMargin() const { return m_leftMargin; } 53 const Length& leftMargin() const { return m_leftMargin; }
48 void computeIntersectionObservations(); 54 void computeIntersectionObservations();
49 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&); 55 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&);
50 void applyRootMargin(LayoutRect&) const; 56 void applyRootMargin(LayoutRect&) const;
51 unsigned firstThresholdGreaterThan(float ratio) const; 57 unsigned firstThresholdGreaterThan(float ratio) const;
52 void deliver(); 58 void deliver();
53 void removeObservation(IntersectionObservation&); 59 void removeObservation(IntersectionObservation&);
54 bool hasEntries() const { return m_entries.size(); } 60 bool hasEntries() const { return m_entries.size(); }
55 const HeapLinkedHashSet<WeakMember<IntersectionObservation>>& observations() const { return m_observations; } 61 const HeapLinkedHashSet<WeakMember<IntersectionObservation>>& observations() const { return m_observations; }
56 62
57 DECLARE_TRACE(); 63 DECLARE_TRACE();
58 64
59 private: 65 private:
60 explicit IntersectionObserver(IntersectionObserverCallback&, Node&, const Ve ctor<Length>& rootMargin, const Vector<float>& thresholds);
61 void clearWeakMembers(Visitor*); 66 void clearWeakMembers(Visitor*);
62 67
63 Member<IntersectionObserverCallback> m_callback; 68 Member<IntersectionObserverCallback> m_callback;
64 WeakMember<Node> m_root; 69 WeakMember<Node> m_root;
65 HeapLinkedHashSet<WeakMember<IntersectionObservation>> m_observations; 70 HeapLinkedHashSet<WeakMember<IntersectionObservation>> m_observations;
66 HeapVector<Member<IntersectionObserverEntry>> m_entries; 71 HeapVector<Member<IntersectionObserverEntry>> m_entries;
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698