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

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

Issue 2511143006: Detect change on the intersection of video and viewport. (Closed)
Patch Set: Addressed miu's comments. Created 4 years, 1 month 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/dom/IntersectionGeometry.h
diff --git a/third_party/WebKit/Source/core/dom/IntersectionGeometry.h b/third_party/WebKit/Source/core/dom/IntersectionGeometry.h
new file mode 100644
index 0000000000000000000000000000000000000000..99702479a1a0306a1f0b11541d9b28ec34155323
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/IntersectionGeometry.h
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IntersectionGeometry_h
+#define IntersectionGeometry_h
+
+#include "platform/Length.h"
+#include "platform/geometry/LayoutRect.h"
+#include "platform/heap/Handle.h"
+#include "wtf/Vector.h"
+
+namespace blink {
+
+class Node;
+class Element;
+class LayoutObject;
+
+class IntersectionGeometry final
+ : public GarbageCollectedFinalized<IntersectionGeometry> {
+ public:
+ IntersectionGeometry(Node* root,
+ Element* target,
+ const Vector<Length>& rootMargin,
+ bool shouldReportRootBounds);
+ ~IntersectionGeometry();
+
+ void computeGeometry();
+ LayoutRect targetRect() const { return m_targetRect; }
+ LayoutRect intersectionRect() const { return m_intersectionRect; }
+ LayoutRect rootRect() const { return m_rootRect; }
+ bool doesIntersect() const { return m_doesIntersect; }
+
+ IntRect intersectionIntRect() const {
+ return pixelSnappedIntRect(m_intersectionRect);
+ }
+
+ IntRect rootIntRect() const { return pixelSnappedIntRect(m_rootRect); }
+
+ DECLARE_TRACE();
+
+ private:
+ void initializeGeometry();
+ void initializeTargetRect();
+ void initializeRootRect();
+ void clipToRoot();
+ void mapTargetRectToTargetFrameCoordinates();
+ void mapRootRectToRootFrameCoordinates();
+ void mapRootRectToTargetFrameCoordinates();
+ Element* root() const;
+ LayoutObject* getRootLayoutObject() const;
szager1 2016/11/23 17:44:58 If there are methods on IntersectionObserver that
xjz 2016/11/23 23:43:25 Done.
+ void applyRootMargin();
+
+ Member<Node> m_root;
+ Member<Element> m_target;
+ const Vector<Length> m_rootMargin;
+ bool m_shouldReportRootBounds;
+ LayoutRect m_targetRect;
+ LayoutRect m_intersectionRect;
+ LayoutRect m_rootRect;
+ bool m_doesIntersect = false;
+};
+
+} // namespace blink
+
+#endif // IntersectionGeometry_h

Powered by Google App Engine
This is Rietveld 408576698