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

Unified Diff: third_party/WebKit/Source/core/page/scrolling/SnapCoordinator.h

Issue 1970563002: Compute snap offsets according to CSS Scroll Snap Spec Level 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/page/scrolling/SnapCoordinator.h
diff --git a/third_party/WebKit/Source/core/page/scrolling/SnapCoordinator.h b/third_party/WebKit/Source/core/page/scrolling/SnapCoordinator.h
new file mode 100644
index 0000000000000000000000000000000000000000..b9063e662d53231161c4c3b496570d8c99ebebe9
--- /dev/null
+++ b/third_party/WebKit/Source/core/page/scrolling/SnapCoordinator.h
@@ -0,0 +1,58 @@
+// 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 SnapCoordinator_h
+#define SnapCoordinator_h
+
+#include "core/layout/LayoutBox.h"
+#include "platform/heap/Handle.h"
+#include "wtf/Vector.h"
+
+namespace blink {
+
+class ComputedStyle;
+class Element;
+struct LengthPoint;
+
+// Snap Coordinator keeps track of snap containers and all of their associated
+// snap areas. It also contains the logic to generate the list of valid snap
+// positions for a given snap container.
+//
+// Snap container:
+// An scroll container that has 'scroll-snap-type' value other
+// than 'none'.
+// Snap area:
+// A snap container's descendant that contributes snap positions. An element
+// only contributes snap positions to its nearest ancestor (on the element’s
+// containing block chain) scroll container.
+//
+// For more information see spec: https://drafts.csswg.org/css-snappoints/
+class CORE_EXPORT SnapCoordinator final : public GarbageCollectedFinalized<SnapCoordinator> {
+ WTF_MAKE_NONCOPYABLE(SnapCoordinator);
+
+public:
+ static SnapCoordinator* create();
+ ~SnapCoordinator();
+ DEFINE_INLINE_TRACE() {}
+
+ void snapContainerDidChange(LayoutBox&, ScrollSnapType);
+ void snapAreaDidChange(LayoutBox&, const Vector<LengthPoint>& snapCoordinates);
+
+#ifndef NDEBUG
+ void showSnapAreaMap();
+ void showSnapAreasFor(const LayoutBox*);
+#endif
+
+private:
+ friend class SnapCoordinatorTest;
+ explicit SnapCoordinator();
+
+ Vector<double> snapOffsets(const ContainerNode&, ScrollbarOrientation);
+
+ HashSet<const LayoutBox*> m_snapContainers;
+};
+
+} // namespace blink
+
+#endif // SnapCoordinator_h
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.cpp ('k') | third_party/WebKit/Source/core/page/scrolling/SnapCoordinator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698