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

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: Implemented root margin Created 5 years 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 typedef HeapVector<Member<IntersectionObserverEntry>> IntersectionObserverEntryV ector;
esprehn 2015/12/12 00:14:16 remove the typedefs, the name is nearly as long as
szager1 2015/12/16 19:15:36 Done.
24
25 class IntersectionObserver final : public GarbageCollectedFinalized<Intersection Observer>, public ScriptWrappable {
26 DEFINE_WRAPPERTYPEINFO();
27 public:
28 typedef HeapHashSet<Member<IntersectionObserver>> HashSet;
29 typedef HeapHashSet<WeakMember<IntersectionObserver>> WeakHashSet;
esprehn 2015/12/12 00:14:16 I'd remove these and just type out the types in th
szager1 2015/12/16 19:15:37 Done.
30
31 static IntersectionObserver* create(const IntersectionObserverInit&, Interse ctionObserverCallback*, ExceptionState&);
32 static void resumeSuspendedObservers();
33
34 // API methods
35 void observe(Element*, ExceptionState&);
36 void unobserve(Element*, ExceptionState&);
37 void disconnect();
38 IntersectionObserverEntryVector takeRecords();
39
40 Element* root() { return m_root.get(); }
41 void computeIntersectionObservations(int);
42 void disconnect(IntersectionObservation&);
43 bool isDescendantOfRoot(Element*) const;
esprehn 2015/12/12 00:14:16 reference
szager1 2015/12/16 19:15:36 I'd argue that in this particular case, using a re
44 void enqueueIntersectionObserverEntry(IntersectionObserverEntry*);
esprehn 2015/12/12 00:14:16 reference
szager1 2015/12/16 19:15:36 Done.
45 void applyRootMargin(LayoutRect&) const;
46 size_t firstThresholdGreaterThan(float ratio) const;
47 bool shouldBeSuspended() const;
48 void deliver();
49 void setActive(bool);
50 bool hasPercentMargin() const;
51 const Length& topMargin() const { return m_topMargin; }
52 const Length& rightMargin() const { return m_rightMargin; }
53 const Length& bottomMargin() const { return m_bottomMargin; }
54 const Length& leftMargin() const { return m_leftMargin; }
55
56 DECLARE_TRACE();
57
58 private:
59 explicit IntersectionObserver(IntersectionObserverCallback*, Element*, const Vector<Length>&, const Vector<float>&);
esprehn 2015/12/12 00:14:16 reference for most of these I think? Also the two
szager1 2015/12/16 19:15:36 Done.
60
61 void checkRootAndDetachIfNecessary();
62
esprehn 2015/12/12 00:14:16 Needed() not Necessary.
ojan 2015/12/12 01:06:29 Lets just call this checkRootAndDetach. We have to
esprehn 2015/12/12 01:49:52 Actually looking at this function just call it det
szager1 2015/12/16 19:15:36 That's not actually what it does. Rather, it chec
63 Member<IntersectionObserverCallback> m_callback;
64 WeakPtrWillBeWeakMember<Element> m_root;
65 Member<IntersectionObservation::WeakHashSet> m_observations;
esprehn 2015/12/12 00:14:16 just write the types
szager1 2015/12/16 19:15:37 Done.
66 Member<IntersectionObserverEntryVector> m_entries;
67 Vector<float> m_thresholds;
68 Length m_topMargin;
69 Length m_rightMargin;
70 Length m_bottomMargin;
71 Length m_leftMargin;
esprehn 2015/12/12 00:14:16 wow these things are big... you definitely won't w
szager1 2015/12/16 19:15:36 That would be a very strange use case. I agree th
72 };
73
74 } // namespace blink
75
76 #endif // IntersectionObserver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698