Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/IntersectionObserver.h |
| diff --git a/third_party/WebKit/Source/core/dom/IntersectionObserver.h b/third_party/WebKit/Source/core/dom/IntersectionObserver.h |
| index cb3913595144df13c8ef9e14cccd5fa577744997..2eecf1aca6c4306477bd113c840f19c7973b00d4 100644 |
| --- a/third_party/WebKit/Source/core/dom/IntersectionObserver.h |
| +++ b/third_party/WebKit/Source/core/dom/IntersectionObserver.h |
| @@ -21,6 +21,7 @@ class Element; |
| class ExceptionState; |
| class IntersectionObserverCallback; |
| class IntersectionObserverInit; |
| +class LayoutObject; |
| class CORE_EXPORT IntersectionObserver final |
| : public GarbageCollectedFinalized<IntersectionObserver>, |
| @@ -35,10 +36,10 @@ class CORE_EXPORT IntersectionObserver final |
| // Defines the assumed initial state of the observed element. If the actual |
| // state is the same as the initial state, then no observation will be |
| // delivered. kAuto means the initial observation will always get sent. |
| - enum class InitialState { |
| + enum InitialState { |
| // TODO(skyostil): Add support for kVisible. |
| - kAuto, |
| - kHidden, |
| + kAuto = 0, |
| + kHidden = 1, |
| }; |
| static IntersectionObserver* create(const IntersectionObserverInit&, |
| @@ -58,11 +59,22 @@ class CORE_EXPORT IntersectionObserver final |
| HeapVector<Member<IntersectionObserverEntry>> takeRecords(ExceptionState&); |
| // API attributes. |
| - Element* root() const; |
| + Element* root() const { return m_root.get(); } |
| String rootMargin() const; |
| const Vector<float>& thresholds() const { return m_thresholds; } |
| - Node* rootNode() const { return m_root.get(); } |
| + // An observer can either track intersections with an explicit root Element, |
| + // or with the the top-level frame's viewport (the "implicit root"). When |
| + // tracking the implicit root, m_root will be null, but because m_root is a |
| + // weak pointer, we cannot surmise that this observer tracks the implicit |
| + // root just because m_root is null. Hence m_rootIsImplicit. |
| + bool rootIsImplicit() const { return m_rootIsImplicit; } |
| + |
| + // This is the document which is responsible for running |
| + // computeIntersectionObservations at frame generation time. |
| + Document& trackingDocument() const; |
| + |
| + LayoutObject* rootLayoutObject() const; |
|
kenrb
2016/12/09 21:01:43
This does not appear to have any callers.
szager1
2016/12/10 20:51:18
Removed.
|
| const Length& topMargin() const { return m_topMargin; } |
| const Length& rightMargin() const { return m_rightMargin; } |
| const Length& bottomMargin() const { return m_bottomMargin; } |
| @@ -88,13 +100,17 @@ class CORE_EXPORT IntersectionObserver final |
| private: |
| explicit IntersectionObserver(IntersectionObserverCallback&, |
| - Node&, |
| + Element*, |
| const Vector<Length>& rootMargin, |
| const Vector<float>& thresholds); |
| void clearWeakMembers(Visitor*); |
| + // Returns false if this observer has an explicit root element which has been |
| + // deleted; true otherwise. |
| + bool rootIsValid() const; |
| + |
| Member<IntersectionObserverCallback> m_callback; |
| - WeakMember<Node> m_root; |
| + WeakMember<Element> m_root; |
| HeapLinkedHashSet<WeakMember<IntersectionObservation>> m_observations; |
| HeapVector<Member<IntersectionObserverEntry>> m_entries; |
| Vector<float> m_thresholds; |
| @@ -102,7 +118,8 @@ class CORE_EXPORT IntersectionObserver final |
| Length m_rightMargin; |
| Length m_bottomMargin; |
| Length m_leftMargin; |
| - InitialState m_initialState; |
| + unsigned m_rootIsImplicit : 1; |
| + unsigned m_initialState : 1; |
| }; |
| } // namespace blink |