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

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

Issue 2511143006: Detect change on the intersection of video and viewport. (Closed)
Patch Set: Created 4 years, 1 month 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 IntersectionObservation_h 5 #ifndef IntersectionObservation_h
6 #define IntersectionObservation_h 6 #define IntersectionObservation_h
7 7
8 #include "core/dom/DOMHighResTimeStamp.h" 8 #include "core/dom/DOMHighResTimeStamp.h"
9 #include "platform/geometry/LayoutRect.h"
10 #include "platform/heap/Handle.h" 9 #include "platform/heap/Handle.h"
11 10
12 namespace blink { 11 namespace blink {
13 12
14 class Element; 13 class Element;
15 class IntersectionObserver; 14 class IntersectionObserver;
16 15
17 class IntersectionObservation final 16 class IntersectionObservation final
18 : public GarbageCollected<IntersectionObservation> { 17 : public GarbageCollected<IntersectionObservation> {
19 public: 18 public:
20 IntersectionObservation(IntersectionObserver&, 19 IntersectionObservation(IntersectionObserver&,
21 Element&, 20 Element&,
22 bool shouldReportRootBounds); 21 bool shouldReportRootBounds);
23 22
24 struct IntersectionGeometry {
25 LayoutRect targetRect;
26 LayoutRect intersectionRect;
27 LayoutRect rootRect;
28 bool doesIntersect;
29
30 IntersectionGeometry() : doesIntersect(false) {}
31 };
32
33 IntersectionObserver& observer() const { return *m_observer; } 23 IntersectionObserver& observer() const { return *m_observer; }
34 Element* target() const { return m_target; } 24 Element* target() const { return m_target; }
35 unsigned lastThresholdIndex() const { return m_lastThresholdIndex; } 25 unsigned lastThresholdIndex() const { return m_lastThresholdIndex; }
36 void setLastThresholdIndex(unsigned index) { m_lastThresholdIndex = index; } 26 void setLastThresholdIndex(unsigned index) { m_lastThresholdIndex = index; }
37 bool shouldReportRootBounds() const { return m_shouldReportRootBounds; } 27 bool shouldReportRootBounds() const { return m_shouldReportRootBounds; }
38 void computeIntersectionObservations(DOMHighResTimeStamp); 28 void computeIntersectionObservations(DOMHighResTimeStamp);
39 void disconnect(); 29 void disconnect();
40 void clearRootAndRemoveFromTarget(); 30 void clearRootAndRemoveFromTarget();
41 31
42 DECLARE_TRACE(); 32 DECLARE_TRACE();
43 33
44 private: 34 private:
45 void applyRootMargin(LayoutRect&) const;
46 void initializeGeometry(IntersectionGeometry&) const;
47 void initializeTargetRect(LayoutRect&) const;
48 void initializeRootRect(LayoutRect&) const;
49 void clipToRoot(IntersectionGeometry&) const;
50 void mapTargetRectToTargetFrameCoordinates(LayoutRect&) const;
51 void mapRootRectToRootFrameCoordinates(LayoutRect&) const;
52 void mapRootRectToTargetFrameCoordinates(LayoutRect&) const;
53 bool computeGeometry(IntersectionGeometry&) const;
54
55 Member<IntersectionObserver> m_observer; 35 Member<IntersectionObserver> m_observer;
56
57 WeakMember<Element> m_target; 36 WeakMember<Element> m_target;
58 37
59 unsigned m_shouldReportRootBounds : 1; 38 unsigned m_shouldReportRootBounds : 1;
60 unsigned m_lastThresholdIndex : 30; 39 unsigned m_lastThresholdIndex : 30;
61 }; 40 };
62 41
63 } // namespace blink 42 } // namespace blink
64 43
65 #endif // IntersectionObservation_h 44 #endif // IntersectionObservation_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698