Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | |
| 47 bool rootIsImplicit() const { return m_rootIsImplicit; } | |
| 37 bool doesIntersect() const { return m_doesIntersect; } | 48 bool doesIntersect() const { return m_doesIntersect; } |
| 49 bool shouldReportRootBounds() const { return m_shouldReportRootBounds; } | |
|
xjz
2016/12/07 01:01:14
This seems is not used anywhere in this CL. Maybe
szager1
2016/12/07 01:30:49
There is one direct usage of the member variable;
| |
| 50 | |
| 51 // Returns true iff it's possible to compute an intersection between root | |
| 52 // and target. | |
| 53 bool isValid() const { return m_isValid; } | |
|
xjz
2016/12/07 01:01:14
All these added APIs seems are only used by Inters
szager1
2016/12/07 01:30:49
Done.
| |
| 38 | 54 |
| 39 IntRect intersectionIntRect() const { | 55 IntRect intersectionIntRect() const { |
| 40 return pixelSnappedIntRect(m_intersectionRect); | 56 return pixelSnappedIntRect(m_intersectionRect); |
| 41 } | 57 } |
| 42 | 58 |
| 43 IntRect targetIntRect() const { return pixelSnappedIntRect(m_targetRect); } | 59 IntRect targetIntRect() const { return pixelSnappedIntRect(m_targetRect); } |
| 44 | 60 |
| 45 IntRect rootIntRect() const { return pixelSnappedIntRect(m_rootRect); } | 61 IntRect rootIntRect() const { return pixelSnappedIntRect(m_rootRect); } |
| 46 | 62 |
| 47 DECLARE_TRACE(); | |
| 48 | |
| 49 private: | 63 private: |
| 50 void initializeGeometry(); | 64 bool initializeGeometry(Element* root, Element& target); |
| 51 void initializeTargetRect(); | 65 void initializeTargetRect(); |
| 52 void initializeRootRect(); | 66 void initializeRootRect(); |
| 53 void clipToRoot(); | 67 void clipToRoot(); |
| 54 void mapTargetRectToTargetFrameCoordinates(); | 68 void mapTargetRectToTargetFrameCoordinates(); |
| 55 void mapRootRectToRootFrameCoordinates(); | 69 void mapRootRectToRootFrameCoordinates(); |
| 56 void mapRootRectToTargetFrameCoordinates(); | 70 void mapIntersectionRectToTargetFrameCoordinates(); |
| 57 Element* root() const; | |
| 58 LayoutObject* getRootLayoutObject() const; | |
| 59 void applyRootMargin(); | 71 void applyRootMargin(); |
| 60 | 72 |
| 61 Member<Node> m_root; | 73 LayoutObject* m_root; |
| 62 Member<Element> m_target; | 74 LayoutObject* m_target; |
| 63 const Vector<Length> m_rootMargin; | 75 const Vector<Length> m_rootMargin; |
| 64 const ReportRootBounds m_shouldReportRootBounds; | |
| 65 LayoutRect m_targetRect; | 76 LayoutRect m_targetRect; |
| 66 LayoutRect m_intersectionRect; | 77 LayoutRect m_intersectionRect; |
| 67 LayoutRect m_rootRect; | 78 LayoutRect m_rootRect; |
| 68 bool m_doesIntersect = false; | 79 unsigned m_shouldReportRootBounds : 1; |
|
xjz
2016/12/07 01:01:14
const?
szager1
2016/12/07 01:30:49
Done.
| |
| 80 unsigned m_rootIsImplicit : 1; | |
|
xjz
2016/12/07 01:01:14
ditto: const
szager1
2016/12/07 01:30:49
Done.
| |
| 81 unsigned m_doesIntersect : 1; | |
| 82 unsigned m_isValid : 1; | |
|
xjz
2016/12/07 01:01:14
ditto: const
szager1
2016/12/07 01:30:49
Done.
| |
| 69 }; | 83 }; |
| 70 | 84 |
| 71 } // namespace blink | 85 } // namespace blink |
| 72 | 86 |
| 73 #endif // IntersectionGeometry_h | 87 #endif // IntersectionGeometry_h |
| OLD | NEW |