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

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

Issue 1449623002: IntersectionObserver: second cut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Add missing break, rebaseline, no config.h Created 4 years, 12 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef IntersectionObserver_h
6 #define IntersectionObserver_h
7
8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "core/dom/Element.h"
10 #include "core/dom/IntersectionObservation.h"
11 #include "core/dom/IntersectionObserverEntry.h"
12 #include "platform/heap/Handle.h"
13 #include "wtf/HashSet.h"
14 #include "wtf/RefCounted.h"
15 #include "wtf/Vector.h"
16
17 namespace blink {
18
19 class ExceptionState;
20 class IntersectionObserverCallback;
21 class IntersectionObserverInit;
22
23 class IntersectionObserver final : public GarbageCollectedFinalized<Intersection Observer>, public ScriptWrappable {
24 DEFINE_WRAPPERTYPEINFO();
25
26 public:
27 static IntersectionObserver* create(const IntersectionObserverInit&, Interse ctionObserverCallback&, ExceptionState&);
28 static void resumeSuspendedObservers();
29
30 // API methods
31 void observe(Element*, ExceptionState&);
32 void unobserve(Element*, ExceptionState&);
33 void disconnect();
34 HeapVector<Member<IntersectionObserverEntry>> takeRecords();
35
36 Element* root() { return m_root.get(); }
37 LayoutObject* rootLayoutObject();
38 bool isDescendantOfRoot(const Element*) const;
39 void computeIntersectionObservations(double timestamp);
40 void disconnect(IntersectionObservation&);
41 void enqueueIntersectionObserverEntry(IntersectionObserverEntry&);
42 void applyRootMargin(LayoutRect&) const;
43 unsigned firstThresholdGreaterThan(float ratio) const;
44 bool shouldBeSuspended() const;
45 void deliver();
46 void setActive(bool);
47 bool hasPercentMargin() const;
48 const Length& topMargin() const { return m_topMargin; }
49 const Length& rightMargin() const { return m_rightMargin; }
50 const Length& bottomMargin() const { return m_bottomMargin; }
51 const Length& leftMargin() const { return m_leftMargin; }
52
53 #if !ENABLE(OILPAN)
54 void dispose();
55 #endif
56
57 DECLARE_TRACE();
58
59 private:
60 explicit IntersectionObserver(IntersectionObserverCallback&, Element&, const Vector<Length>& rootMargin, const Vector<float>& thresholds);
61
62 void checkRootAndDetachIfNeeded();
63
64 Member<IntersectionObserverCallback> m_callback;
65 WeakPtrWillBeWeakMember<Element> m_root;
haraken 2015/12/22 01:13:30 If you use a WeakMember, isn't there any risk that
esprehn 2015/12/22 07:50:33 JS can't get the root from the observer, that's no
szager1 2015/12/22 07:53:41 m_root should become nullptr when the Element it p
66 HeapHashSet<WeakMember<IntersectionObservation>> m_observations;
haraken 2015/12/22 01:13:30 I'm wondering why this needs to be weak. You're a
esprehn 2015/12/22 07:50:33 Hmm yeah, shouldn't the observer keep the observat
szager1 2015/12/22 07:53:41 No, I think you are confused about the members of
67 HeapVector<Member<IntersectionObserverEntry>> m_entries;
68 Vector<float> m_thresholds;
69 Length m_topMargin;
70 Length m_rightMargin;
71 Length m_bottomMargin;
72 Length m_leftMargin;
73 };
74
75 } // namespace blink
76
77 #endif // IntersectionObserver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698