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

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

Issue 2272773002: Use intersection observer to control frame throttling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 years, 3 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/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"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const Length& leftMargin() const { return m_leftMargin; } 52 const Length& leftMargin() const { return m_leftMargin; }
53 void computeIntersectionObservations(); 53 void computeIntersectionObservations();
54 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&); 54 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&);
55 void applyRootMargin(LayoutRect&) const; 55 void applyRootMargin(LayoutRect&) const;
56 unsigned firstThresholdGreaterThan(float ratio) const; 56 unsigned firstThresholdGreaterThan(float ratio) const;
57 void deliver(); 57 void deliver();
58 void removeObservation(IntersectionObservation&); 58 void removeObservation(IntersectionObservation&);
59 bool hasEntries() const { return m_entries.size(); } 59 bool hasEntries() const { return m_entries.size(); }
60 const HeapLinkedHashSet<WeakMember<IntersectionObservation>>& observations() const { return m_observations; } 60 const HeapLinkedHashSet<WeakMember<IntersectionObservation>>& observations() const { return m_observations; }
61 61
62 // A low latency intersection observer delivers events with an immediately
63 // posted task instead of waiting for an idle period (or up to 100ms).
64 // TODO(skyostil): Figure out how we want to expose low latency mode for web
65 // authors and adjust/remove this API accordingly.
ojan 2016/09/06 21:16:35 FWIW, it looks like we're just going to change it
66 void setLowLatency(bool lowLatency) { m_lowLatency = lowLatency; }
67 bool lowLatency() const { return m_lowLatency; }
68
62 DECLARE_TRACE(); 69 DECLARE_TRACE();
63 70
64 private: 71 private:
65 explicit IntersectionObserver(IntersectionObserverCallback&, Node&, const Ve ctor<Length>& rootMargin, const Vector<float>& thresholds); 72 explicit IntersectionObserver(IntersectionObserverCallback&, Node&, const Ve ctor<Length>& rootMargin, const Vector<float>& thresholds);
66 void clearWeakMembers(Visitor*); 73 void clearWeakMembers(Visitor*);
67 74
68 Member<IntersectionObserverCallback> m_callback; 75 Member<IntersectionObserverCallback> m_callback;
69 WeakMember<Node> m_root; 76 WeakMember<Node> m_root;
70 HeapLinkedHashSet<WeakMember<IntersectionObservation>> m_observations; 77 HeapLinkedHashSet<WeakMember<IntersectionObservation>> m_observations;
71 HeapVector<Member<IntersectionObserverEntry>> m_entries; 78 HeapVector<Member<IntersectionObserverEntry>> m_entries;
72 Vector<float> m_thresholds; 79 Vector<float> m_thresholds;
73 Length m_topMargin; 80 Length m_topMargin;
74 Length m_rightMargin; 81 Length m_rightMargin;
75 Length m_bottomMargin; 82 Length m_bottomMargin;
76 Length m_leftMargin; 83 Length m_leftMargin;
84 bool m_lowLatency;
77 }; 85 };
78 86
79 } // namespace blink 87 } // namespace blink
80 88
81 #endif // IntersectionObserver_h 89 #endif // IntersectionObserver_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/dom/IntersectionObserver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698