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

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: Rebase again. Created 4 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
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" 9 #include "core/dom/IntersectionGeometry.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class Element; 14 class Element;
15 class IntersectionObserver; 15 class IntersectionObserver;
16 16
17 class IntersectionObservation final 17 class IntersectionObservation final
18 : public GarbageCollected<IntersectionObservation> { 18 : public GarbageCollected<IntersectionObservation> {
19 public: 19 public:
20 IntersectionObservation(IntersectionObserver&, 20 IntersectionObservation(
21 Element&, 21 IntersectionObserver&,
22 bool shouldReportRootBounds); 22 Element&,
23 23 IntersectionGeometry::ReportRootBounds shouldReportRootBounds);
24 struct IntersectionGeometry {
25 LayoutRect targetRect;
26 LayoutRect intersectionRect;
27 LayoutRect rootRect;
28 bool doesIntersect;
29
30 IntersectionGeometry() : doesIntersect(false) {}
31 };
32 24
33 IntersectionObserver& observer() const { return *m_observer; } 25 IntersectionObserver& observer() const { return *m_observer; }
34 Element* target() const { return m_target; } 26 Element* target() const { return m_target; }
35 unsigned lastThresholdIndex() const { return m_lastThresholdIndex; } 27 unsigned lastThresholdIndex() const { return m_lastThresholdIndex; }
36 void setLastThresholdIndex(unsigned index) { m_lastThresholdIndex = index; } 28 void setLastThresholdIndex(unsigned index) { m_lastThresholdIndex = index; }
37 bool shouldReportRootBounds() const { return m_shouldReportRootBounds; }
38 void computeIntersectionObservations(DOMHighResTimeStamp); 29 void computeIntersectionObservations(DOMHighResTimeStamp);
39 void disconnect(); 30 void disconnect();
40 void clearRootAndRemoveFromTarget(); 31 void clearRootAndRemoveFromTarget();
41 32
42 DECLARE_TRACE(); 33 DECLARE_TRACE();
43 34
44 private: 35 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; 36 Member<IntersectionObserver> m_observer;
56
57 WeakMember<Element> m_target; 37 WeakMember<Element> m_target;
58 38
59 unsigned m_shouldReportRootBounds : 1; 39 const unsigned m_shouldReportRootBounds : 1;
60 unsigned m_lastThresholdIndex : 30; 40 unsigned m_lastThresholdIndex : 30;
61 }; 41 };
62 42
63 } // namespace blink 43 } // namespace blink
64 44
65 #endif // IntersectionObservation_h 45 #endif // IntersectionObservation_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698