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

Unified Diff: third_party/WebKit/Source/core/layout/IntersectionGeometry.h

Issue 2553103004: Refactor IntersectionGeometry class and move it to core/layout. (Closed)
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/IntersectionGeometry.h
diff --git a/third_party/WebKit/Source/core/dom/IntersectionGeometry.h b/third_party/WebKit/Source/core/layout/IntersectionGeometry.h
similarity index 50%
rename from third_party/WebKit/Source/core/dom/IntersectionGeometry.h
rename to third_party/WebKit/Source/core/layout/IntersectionGeometry.h
index ba944567f2d01b48de94a0b0e07e48e10882ce95..b4ea87ab918105bfe38e63b694074092a6928af1 100644
--- a/third_party/WebKit/Source/core/dom/IntersectionGeometry.h
+++ b/third_party/WebKit/Source/core/layout/IntersectionGeometry.h
@@ -12,28 +12,38 @@
namespace blink {
-class Node;
class Element;
class LayoutObject;
-class IntersectionGeometry final
- : public GarbageCollectedFinalized<IntersectionGeometry> {
+// Computes the intersection between an ancestor (root) element and a
+// descendant (target) element, with overflow and CSS clipping applied, but not
+// paint occlusion.
+//
+// If the root argument to the constructor is null, computes the intersection
+// of the target with the top-level frame viewport (AKA the "implicit root").
+class IntersectionGeometry {
+ STACK_ALLOCATED()
public:
- enum ReportRootBounds {
- kShouldReportRootBounds,
- kShouldNotReportRootBounds,
- };
-
- IntersectionGeometry(Node* root,
- Element* target,
+ IntersectionGeometry(Element* root,
+ Element& target,
const Vector<Length>& rootMargin,
- ReportRootBounds shouldReportRootBounds);
+ bool shouldReportRootBounds);
~IntersectionGeometry();
void computeGeometry();
+
+ LayoutObject* root() const { return m_root; }
+ LayoutObject* target() const { return m_target; }
+
+ // Client rect in the coordinate system of the frame containing target.
LayoutRect targetRect() const { return m_targetRect; }
+
+ // Client rect in the coordinate system of the frame containing target.
LayoutRect intersectionRect() const { return m_intersectionRect; }
+
+ // Client rect in the coordinate system of the frame containing root.
LayoutRect rootRect() const { return m_rootRect; }
+
bool doesIntersect() const { return m_doesIntersect; }
IntRect intersectionIntRect() const {
@@ -44,28 +54,32 @@ class IntersectionGeometry final
IntRect rootIntRect() const { return pixelSnappedIntRect(m_rootRect); }
- DECLARE_TRACE();
-
private:
- void initializeGeometry();
+ bool initializeGeometry(Element* root, Element& target);
void initializeTargetRect();
void initializeRootRect();
void clipToRoot();
void mapTargetRectToTargetFrameCoordinates();
void mapRootRectToRootFrameCoordinates();
- void mapRootRectToTargetFrameCoordinates();
- Element* root() const;
- LayoutObject* getRootLayoutObject() const;
+ void mapIntersectionRectToTargetFrameCoordinates();
void applyRootMargin();
- Member<Node> m_root;
- Member<Element> m_target;
+ // Returns true iff it's possible to compute an intersection between root
+ // and target.
+ bool isValid() const { return m_isValid; }
+ bool rootIsImplicit() const { return m_rootIsImplicit; }
+ bool shouldReportRootBounds() const { return m_shouldReportRootBounds; }
+
+ LayoutObject* m_root;
+ LayoutObject* m_target;
const Vector<Length> m_rootMargin;
- const ReportRootBounds m_shouldReportRootBounds;
LayoutRect m_targetRect;
LayoutRect m_intersectionRect;
LayoutRect m_rootRect;
- bool m_doesIntersect = false;
+ unsigned m_doesIntersect : 1;
+ const unsigned m_shouldReportRootBounds : 1;
ojan 2016/12/10 01:18:26 What does this "const" do?
szager1 2016/12/10 01:47:11 It means that it can only be assigned to in the co
+ const unsigned m_rootIsImplicit : 1;
+ const unsigned m_isValid : 1;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698