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

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

Issue 1188563005: Compute snap offsets (both repeat and element based) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: remove m_frame Created 5 years, 2 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..47a440374ce1398870c7f9bddba80b699b9bf071
--- /dev/null
+++ b/third_party/WebKit/Source/core/page/scrolling/SnapCoordinator.h
@@ -0,0 +1,60 @@
+// Copyright 2015 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/dom/Element.h"
+#include "platform/heap/Handle.h"
+#include "platform/scroll/ScrollTypes.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
+
+namespace blink {
+
+using SnapElementSet = WillBeHeapHashSet<RawPtrWillBeWeakMember<const Element>>;
+using SnapElementMap = WillBeHeapHashMap<RawPtrWillBeWeakMember<const Element>, OwnPtrWillBeMember<SnapElementSet>>;
+
+class ComputedStyle;
+struct LengthPoint;
+
+// Snap Coordinator keeps track of snap containers and all of their associated
+// snap elements. It also contains the logic to generate the final list of snap
+// offsets for any snap container.
+class CORE_EXPORT SnapCoordinator final : public NoBaseWillBeGarbageCollected<SnapCoordinator> {
+ WTF_MAKE_NONCOPYABLE(SnapCoordinator);
+
+public:
+ static PassOwnPtrWillBeRawPtr<SnapCoordinator> create();
+ ~SnapCoordinator();
+ DEFINE_INLINE_TRACE() {}
+
+ void snapContainerDidChange(const Element&, ScrollSnapType);
+ void snapElementDidChange(const Element&, Vector<LengthPoint> snapCoordinates);
+
+#ifndef NDEBUG
+ void showSnapElementMap();
+ void showSnapElementsFor(const Element*);
+#endif
+
+private:
+ friend class SnapCoordinatorTest;
+ explicit SnapCoordinator();
+
+ Vector<double> snapOffsets(const Element&, ScrollbarOrientation);
+ const Element* findSnapContainer(const Element&);
+ void addSnapContainer(const Element&);
+ void addSnapElement(const Element&, const Element&);
+ void removeSnapContainer(const Element&);
+ void removeSnapElement(const Element&);
+
+ SnapElementSet& ensureSnapElementSet(const Element&);
+
+ SnapElementMap m_elementMap;
+};
+
+} // namespace blink
+
+#endif // SnapCoordinator_h

Powered by Google App Engine
This is Rietveld 408576698