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

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

Issue 1559593002: Add root margin support for IntersectionObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@intersection-observer-no-root-margin
Patch Set: Initialize margin members to Fixed 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
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"
(...skipping 16 matching lines...) Expand all
27 static IntersectionObserver* create(const IntersectionObserverInit&, Interse ctionObserverCallback&, ExceptionState&); 27 static IntersectionObserver* create(const IntersectionObserverInit&, Interse ctionObserverCallback&, ExceptionState&);
28 static void resumeSuspendedObservers(); 28 static void resumeSuspendedObservers();
29 29
30 // API methods 30 // API methods
31 void observe(Element*, ExceptionState&); 31 void observe(Element*, ExceptionState&);
32 void unobserve(Element*, ExceptionState&); 32 void unobserve(Element*, ExceptionState&);
33 HeapVector<Member<IntersectionObserverEntry>> takeRecords(); 33 HeapVector<Member<IntersectionObserverEntry>> takeRecords();
34 34
35 Element* root() { return m_root.get(); } 35 Element* root() { return m_root.get(); }
36 LayoutObject* rootLayoutObject(); 36 LayoutObject* rootLayoutObject();
37 bool hasPercentMargin() const;
38 const Length& topMargin() const { return m_topMargin; }
39 const Length& rightMargin() const { return m_rightMargin; }
40 const Length& bottomMargin() const { return m_bottomMargin; }
41 const Length& leftMargin() const { return m_leftMargin; }
37 bool isDescendantOfRoot(const Element*) const; 42 bool isDescendantOfRoot(const Element*) const;
38 void computeIntersectionObservations(double timestamp); 43 void computeIntersectionObservations(double timestamp);
39 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&); 44 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&);
45 void applyRootMargin(LayoutRect&) const;
40 unsigned firstThresholdGreaterThan(float ratio) const; 46 unsigned firstThresholdGreaterThan(float ratio) const;
41 void deliver(); 47 void deliver();
42 void setActive(bool); 48 void setActive(bool);
43 void disconnect(); 49 void disconnect();
44 void removeObservation(IntersectionObservation&); 50 void removeObservation(IntersectionObservation&);
45 bool hasEntries() const { return m_entries.size(); } 51 bool hasEntries() const { return m_entries.size(); }
46 52
47 DECLARE_TRACE(); 53 DECLARE_TRACE();
48 54
49 private: 55 private:
50 explicit IntersectionObserver(IntersectionObserverCallback&, Element&, const Vector<float>& thresholds); 56 explicit IntersectionObserver(IntersectionObserverCallback&, Element&, const Vector<Length>& rootMargin, const Vector<float>& thresholds);
51 57
52 void checkRootAndDetachIfNeeded(); 58 void checkRootAndDetachIfNeeded();
53 59
54 Member<IntersectionObserverCallback> m_callback; 60 Member<IntersectionObserverCallback> m_callback;
55 WeakPtrWillBeWeakMember<Element> m_root; 61 WeakPtrWillBeWeakMember<Element> m_root;
56 HeapHashSet<WeakMember<IntersectionObservation>> m_observations; 62 HeapHashSet<WeakMember<IntersectionObservation>> m_observations;
57 HeapVector<Member<IntersectionObserverEntry>> m_entries; 63 HeapVector<Member<IntersectionObserverEntry>> m_entries;
58 Vector<float> m_thresholds; 64 Vector<float> m_thresholds;
65 Length m_topMargin;
66 Length m_rightMargin;
67 Length m_bottomMargin;
68 Length m_leftMargin;
59 }; 69 };
60 70
61 } // namespace blink 71 } // namespace blink
62 72
63 #endif // IntersectionObserver_h 73 #endif // IntersectionObserver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698