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

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

Issue 1817693002: Support edge-inclusive intersections in mapToVisibleRectInAncestorSpace (Closed) Base URL: https://chromium.googlesource.com/chromium/src@intersection-observer-idle-callback
Patch Set: Address comments, add mapToVisibleRectInContainerSpace test Created 4 years, 9 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
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 "platform/geometry/LayoutRect.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 class Node; 16 class Node;
17 17
18 // TODO(oilpan): Switch to GarbageCollected<> after oilpan ships. 18 // TODO(oilpan): Switch to GarbageCollected<> after oilpan ships.
19 class IntersectionObservation : public GarbageCollectedFinalized<IntersectionObs ervation> { 19 class IntersectionObservation : public GarbageCollectedFinalized<IntersectionObs ervation> {
20 public: 20 public:
21 IntersectionObservation(IntersectionObserver&, Element&, bool shouldReportRo otBounds); 21 IntersectionObservation(IntersectionObserver&, Element&, bool shouldReportRo otBounds);
22 22
23 struct IntersectionGeometry { 23 struct IntersectionGeometry {
24 LayoutRect targetRect; 24 LayoutRect targetRect;
25 LayoutRect intersectionRect; 25 LayoutRect intersectionRect;
26 LayoutRect rootRect; 26 LayoutRect rootRect;
27 bool doesIntersect;
27 }; 28 };
28 29
29 IntersectionObserver& observer() const { return *m_observer; } 30 IntersectionObserver& observer() const { return *m_observer; }
30 Element* target() const; 31 Element* target() const;
31 unsigned lastThresholdIndex() const { return m_lastThresholdIndex; } 32 unsigned lastThresholdIndex() const { return m_lastThresholdIndex; }
32 void setLastThresholdIndex(unsigned index) { m_lastThresholdIndex = index; } 33 void setLastThresholdIndex(unsigned index) { m_lastThresholdIndex = index; }
33 bool shouldReportRootBounds() const { return m_shouldReportRootBounds; } 34 bool shouldReportRootBounds() const { return m_shouldReportRootBounds; }
34 void computeIntersectionObservations(DOMHighResTimeStamp); 35 void computeIntersectionObservations(DOMHighResTimeStamp);
35 void disconnect(); 36 void disconnect();
36 void clearRootAndRemoveFromTarget(); 37 void clearRootAndRemoveFromTarget();
37 38
38 DECLARE_TRACE(); 39 DECLARE_TRACE();
39 40
40 private: 41 private:
41 void applyRootMargin(LayoutRect&) const; 42 void applyRootMargin(LayoutRect&) const;
43 void initializeGeometry(IntersectionGeometry&) const;
42 void initializeTargetRect(LayoutRect&) const; 44 void initializeTargetRect(LayoutRect&) const;
43 void initializeRootRect(LayoutRect&) const; 45 void initializeRootRect(LayoutRect&) const;
44 void clipToRoot(LayoutRect&, const LayoutRect&) const; 46 void clipToRoot(IntersectionGeometry&) const;
45 void mapTargetRectToTargetFrameCoordinates(LayoutRect&) const; 47 void mapTargetRectToTargetFrameCoordinates(LayoutRect&) const;
46 void mapRootRectToRootFrameCoordinates(LayoutRect&) const; 48 void mapRootRectToRootFrameCoordinates(LayoutRect&) const;
47 void mapRootRectToTargetFrameCoordinates(LayoutRect&) const; 49 void mapRootRectToTargetFrameCoordinates(LayoutRect&) const;
48 bool computeGeometry(IntersectionGeometry&) const; 50 bool computeGeometry(IntersectionGeometry&) const;
49 51
50 Member<IntersectionObserver> m_observer; 52 Member<IntersectionObserver> m_observer;
51 53
52 // TODO(szager): Why Node instead of Element? Because NodeIntersectionObser verData::createWeakPtr() 54 // TODO(szager): Why Node instead of Element? Because NodeIntersectionObser verData::createWeakPtr()
53 // returns a WeakPtr<Node>, which cannot be coerced into a WeakPtr<Element>. When oilpan rolls out, 55 // returns a WeakPtr<Node>, which cannot be coerced into a WeakPtr<Element>. When oilpan rolls out,
54 // this can be changed to WeakMember<Element>. 56 // this can be changed to WeakMember<Element>.
55 WeakPtrWillBeWeakMember<Node> m_target; 57 WeakPtrWillBeWeakMember<Node> m_target;
56 58
57 unsigned m_shouldReportRootBounds : 1; 59 unsigned m_shouldReportRootBounds : 1;
58 unsigned m_lastThresholdIndex : 30; 60 unsigned m_lastThresholdIndex : 30;
59 }; 61 };
60 62
61 } // namespace blink 63 } // namespace blink
62 64
63 #endif // IntersectionObservation_h 65 #endif // IntersectionObservation_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698