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

Side by Side Diff: third_party/WebKit/Source/core/layout/IntersectionGeometry.h

Issue 2553103004: Refactor IntersectionGeometry class and move it to core/layout. (Closed)
Patch Set: nits 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 IntersectionGeometry_h 5 #ifndef IntersectionGeometry_h
6 #define IntersectionGeometry_h 6 #define IntersectionGeometry_h
7 7
8 #include "platform/Length.h" 8 #include "platform/Length.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 #include "wtf/Vector.h" 11 #include "wtf/Vector.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class Node;
16 class Element; 15 class Element;
17 class LayoutObject; 16 class LayoutObject;
18 17
19 class IntersectionGeometry final 18 // Computes the intersection between an ancestor (root) element and a
20 : public GarbageCollectedFinalized<IntersectionGeometry> { 19 // descendant (target) element, with overflow and CSS clipping applied, but not
20 // paint occlusion.
21 //
22 // If the root argument to the constructor is null, computes the intersection
23 // of the target with the top-level frame viewport (AKA the "implicit root").
24 class IntersectionGeometry {
25 STACK_ALLOCATED()
21 public: 26 public:
22 enum ReportRootBounds { 27 IntersectionGeometry(Element* root,
23 kShouldReportRootBounds, 28 Element& target,
24 kShouldNotReportRootBounds,
25 };
26
27 IntersectionGeometry(Node* root,
28 Element* target,
29 const Vector<Length>& rootMargin, 29 const Vector<Length>& rootMargin,
30 ReportRootBounds shouldReportRootBounds); 30 bool shouldReportRootBounds);
31 ~IntersectionGeometry(); 31 ~IntersectionGeometry();
32 32
33 void computeGeometry(); 33 void computeGeometry();
34
35 LayoutObject* root() const { return m_root; }
36 LayoutObject* target() const { return m_target; }
37
38 // Client rect in the coordinate system of the frame containing target.
34 LayoutRect targetRect() const { return m_targetRect; } 39 LayoutRect targetRect() const { return m_targetRect; }
40
41 // Client rect in the coordinate system of the frame containing target.
35 LayoutRect intersectionRect() const { return m_intersectionRect; } 42 LayoutRect intersectionRect() const { return m_intersectionRect; }
43
44 // Client rect in the coordinate system of the frame containing root.
36 LayoutRect rootRect() const { return m_rootRect; } 45 LayoutRect rootRect() const { return m_rootRect; }
46
37 bool doesIntersect() const { return m_doesIntersect; } 47 bool doesIntersect() const { return m_doesIntersect; }
38 48
39 IntRect intersectionIntRect() const { 49 IntRect intersectionIntRect() const {
40 return pixelSnappedIntRect(m_intersectionRect); 50 return pixelSnappedIntRect(m_intersectionRect);
41 } 51 }
42 52
43 IntRect targetIntRect() const { return pixelSnappedIntRect(m_targetRect); } 53 IntRect targetIntRect() const { return pixelSnappedIntRect(m_targetRect); }
44 54
45 IntRect rootIntRect() const { return pixelSnappedIntRect(m_rootRect); } 55 IntRect rootIntRect() const { return pixelSnappedIntRect(m_rootRect); }
46 56
47 DECLARE_TRACE();
48
49 private: 57 private:
58 bool canComputeGeometry(Element* root, Element& target) const;
50 void initializeGeometry(); 59 void initializeGeometry();
51 void initializeTargetRect(); 60 void initializeTargetRect();
52 void initializeRootRect(); 61 void initializeRootRect();
53 void clipToRoot(); 62 void clipToRoot();
54 void mapTargetRectToTargetFrameCoordinates(); 63 void mapTargetRectToTargetFrameCoordinates();
55 void mapRootRectToRootFrameCoordinates(); 64 void mapRootRectToRootFrameCoordinates();
56 void mapRootRectToTargetFrameCoordinates(); 65 void mapIntersectionRectToTargetFrameCoordinates();
57 Element* root() const;
58 LayoutObject* getRootLayoutObject() const;
59 void applyRootMargin(); 66 void applyRootMargin();
60 67
61 Member<Node> m_root; 68 // Returns true iff it's possible to compute an intersection between root
62 Member<Element> m_target; 69 // and target.
70 bool isValid() const { return m_isValid; }
ojan 2016/12/12 19:53:31 Nit: How about a more descriptive name? I wouldn't
szager1 2016/12/12 20:16:11 Done.
71 bool rootIsImplicit() const { return m_rootIsImplicit; }
72 bool shouldReportRootBounds() const { return m_shouldReportRootBounds; }
73
74 LayoutObject* m_root;
75 LayoutObject* m_target;
63 const Vector<Length> m_rootMargin; 76 const Vector<Length> m_rootMargin;
64 const ReportRootBounds m_shouldReportRootBounds;
65 LayoutRect m_targetRect; 77 LayoutRect m_targetRect;
66 LayoutRect m_intersectionRect; 78 LayoutRect m_intersectionRect;
67 LayoutRect m_rootRect; 79 LayoutRect m_rootRect;
68 bool m_doesIntersect = false; 80 unsigned m_doesIntersect : 1;
81 const unsigned m_shouldReportRootBounds : 1;
82 const unsigned m_rootIsImplicit : 1;
83 const unsigned m_isValid : 1;
69 }; 84 };
70 85
71 } // namespace blink 86 } // namespace blink
72 87
73 #endif // IntersectionGeometry_h 88 #endif // IntersectionGeometry_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/BUILD.gn ('k') | third_party/WebKit/Source/core/layout/IntersectionGeometry.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698