Chromium Code Reviews| 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 |