OLD | NEW |
---|---|
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 Loading... | |
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 | 51 |
46 DECLARE_TRACE(); | 52 DECLARE_TRACE(); |
47 | 53 |
48 private: | 54 private: |
49 explicit IntersectionObserver(IntersectionObserverCallback&, Element&, const Vector<float>& thresholds); | 55 explicit IntersectionObserver(IntersectionObserverCallback&, Element&, const Vector<Length>& rootMargin, const Vector<float>& thresholds); |
50 | 56 |
51 void checkRootAndDetachIfNeeded(); | 57 void checkRootAndDetachIfNeeded(); |
52 | 58 |
53 Member<IntersectionObserverCallback> m_callback; | 59 Member<IntersectionObserverCallback> m_callback; |
54 WeakPtrWillBeWeakMember<Element> m_root; | 60 WeakPtrWillBeWeakMember<Element> m_root; |
55 HeapHashSet<WeakMember<IntersectionObservation>> m_observations; | 61 HeapHashSet<WeakMember<IntersectionObservation>> m_observations; |
56 HeapVector<Member<IntersectionObserverEntry>> m_entries; | 62 HeapVector<Member<IntersectionObserverEntry>> m_entries; |
57 Vector<float> m_thresholds; | 63 Vector<float> m_thresholds; |
64 Length m_topMargin; | |
65 Length m_rightMargin; | |
66 Length m_bottomMargin; | |
67 Length m_leftMargin; | |
ojan
2016/01/12 01:08:49
This object is getting quite large. I don't think
szager1
2016/01/12 19:24:43
Acknowledged. I would expect that the number of o
| |
58 }; | 68 }; |
59 | 69 |
60 } // namespace blink | 70 } // namespace blink |
61 | 71 |
62 #endif // IntersectionObserver_h | 72 #endif // IntersectionObserver_h |
OLD | NEW |