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

Unified Diff: 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: Clean up TODOs Created 5 years, 3 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: Source/core/page/scrolling/SnapCoordinator.h
diff --git a/Source/core/page/scrolling/SnapCoordinator.h b/Source/core/page/scrolling/SnapCoordinator.h
new file mode 100644
index 0000000000000000000000000000000000000000..0f461738ec1d174aae1e05c0f2cac027ade9b983
--- /dev/null
+++ b/Source/core/page/scrolling/SnapCoordinator.h
@@ -0,0 +1,68 @@
+// 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 ContainerNode>, OwnPtrWillBeMember<SnapElementSet>>;
+// using SnapContainerMap = WillBeHeapHashMap<RawPtrWillBeWeakMember<const Element>, RawPtrWillBeWeakMember<const ContainerNode>>;
+
+class ContainerNode;
+class ComputedStyle;
+
+// 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(LocalFrame&);
+ ~SnapCoordinator();
+ DEFINE_INLINE_TRACE() {
+ visitor->trace(m_frame);
+ }
+
+ void styleChanged(const Node*, const ComputedStyle*);
esprehn 2015/09/24 17:37:41 I don't want general "styleChanged" hooks, please
majidvp 2015/10/15 21:47:03 Done. Now only exposing snap{Element,Container}Did
+
+ void detach(const ContainerNode&);
+ void attach(const ContainerNode&);
esprehn 2015/09/24 17:37:41 Expose a real API, don't generically hook attach/d
majidvp 2015/10/15 21:47:03 Done. Now only exposing snap{Element,Container}Did
+
+#ifndef NDEBUG
+ void showSnapElementMap();
+ void showSnapElementsFor(const ContainerNode*);
+#endif
+
+private:
+ friend class SnapCoordinatorTest;
+ explicit SnapCoordinator(LocalFrame&);
+
+ Vector<double> snapOffsets(const ContainerNode&, ScrollbarOrientation);
+ const ContainerNode* findSnapContainer(const Element&);
+ void snapContainerDidChange(const ContainerNode&);
+ void snapElementDidChange(const Element&);
+ void addSnapContainer(const ContainerNode&);
+ void removeSnapContainer(const ContainerNode&);
+ void addSnapElement(const ContainerNode&, const Element&);
+ void removeSnapElement(const Element&);
+
+ SnapElementSet& ensureSnapElementSet(const ContainerNode&);
+
+ SnapElementMap m_elementMap;
+ RawPtrWillBeMember<LocalFrame> m_frame;
esprehn 2015/09/24 17:37:41 You never actually use Frame, why does it have thi
majidvp 2015/10/15 21:47:03 Done. Moved it to document.
+};
+
+} // namespace blink
+
+#endif // SnapCoordinator_h

Powered by Google App Engine
This is Rietveld 408576698