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

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

Issue 1449623002: IntersectionObserver: second cut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Add RuntimeEnabled flags to all idl's, fix test expectations. Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/IntersectionObservation.h
diff --git a/third_party/WebKit/Source/core/dom/IntersectionObservation.h b/third_party/WebKit/Source/core/dom/IntersectionObservation.h
new file mode 100644
index 0000000000000000000000000000000000000000..e832c6213f2c2bae809479537a4c3a587e07aaff
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/IntersectionObservation.h
@@ -0,0 +1,54 @@
+// 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 IntersectionObservation_h
+#define IntersectionObservation_h
+
+#include "platform/geometry/LayoutRect.h"
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+class Element;
+class IntersectionObserver;
+
+class IntersectionObservation : public GarbageCollectedFinalized<IntersectionObservation> {
+public:
+ IntersectionObservation(IntersectionObserver&, Element&, bool shouldReportRootBounds);
+
+ struct IntersectionGeometry {
+ LayoutRect targetRect;
+ LayoutRect intersectionRect;
+ LayoutRect rootRect;
+ };
+
+ IntersectionObserver& observer() const { return *m_observer; }
+ Element* target() const { return m_target.get(); }
+ bool isActive() const { return m_active; }
+ void setActive(bool active) { m_active = active; }
+ unsigned lastThresholdIndex() const { return m_lastThresholdIndex; }
+ void setLastThresholdIndex(unsigned index) { m_lastThresholdIndex = index; }
+ bool shouldReportRootBounds() const { return m_shouldReportRootBounds; }
+
+ void computeIntersectionObservations(double timestamp);
+ void disconnect();
+
+ DECLARE_TRACE();
+
+private:
+ void initializeGeometry(IntersectionGeometry&);
+ void clipToRoot(LayoutRect&);
+ void clipToFrameView(IntersectionGeometry&);
+ bool computeGeometry(IntersectionGeometry&);
+
+ Member<IntersectionObserver> m_observer;
+ WeakPtrWillBeWeakMember<Element> m_target;
+ unsigned m_active : 1;
+ unsigned m_shouldReportRootBounds : 1;
+ unsigned m_lastThresholdIndex : 30;
+};
+
+} // namespace blink
+
+#endif // IntersectionObservation_h

Powered by Google App Engine
This is Rietveld 408576698