| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SnapCoordinator_h | 5 #ifndef SnapCoordinator_h |
| 6 #define SnapCoordinator_h | 6 #define SnapCoordinator_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/css/CSSPrimitiveValueMappings.h" | 9 #include "core/css/CSSPrimitiveValueMappings.h" |
| 10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| 11 #include "platform/wtf/Vector.h" | 11 #include "platform/wtf/Vector.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 class ContainerNode; | |
| 16 class LayoutBox; | 15 class LayoutBox; |
| 17 struct LengthPoint; | 16 struct ScrollSnapType; |
| 17 struct ScrollSnapAlign; |
| 18 | 18 |
| 19 // Snap Coordinator keeps track of snap containers and all of their associated | 19 // Snap Coordinator keeps track of snap containers and all of their associated |
| 20 // snap areas. It also contains the logic to generate the list of valid snap | 20 // snap areas. It also contains the logic to generate the list of valid snap |
| 21 // positions for a given snap container. | 21 // positions for a given snap container. |
| 22 // | 22 // |
| 23 // Snap container: | 23 // Snap container: |
| 24 // An scroll container that has 'scroll-snap-type' value other | 24 // An scroll container that has 'scroll-snap-type' value other |
| 25 // than 'none'. | 25 // than 'none'. |
| 26 // Snap area: | 26 // Snap area: |
| 27 // A snap container's descendant that contributes snap positions. An element | 27 // A snap container's descendant that contributes snap positions. An element |
| 28 // only contributes snap positions to its nearest ancestor (on the element’s | 28 // only contributes snap positions to its nearest ancestor (on the element’s |
| 29 // containing block chain) scroll container. | 29 // containing block chain) scroll container. |
| 30 // | 30 // |
| 31 // For more information see spec: https://drafts.csswg.org/css-snappoints/ | 31 // For more information see spec: https://drafts.csswg.org/css-snappoints/ |
| 32 class CORE_EXPORT SnapCoordinator final | 32 class CORE_EXPORT SnapCoordinator final |
| 33 : public GarbageCollectedFinalized<SnapCoordinator> { | 33 : public GarbageCollectedFinalized<SnapCoordinator> { |
| 34 WTF_MAKE_NONCOPYABLE(SnapCoordinator); | 34 WTF_MAKE_NONCOPYABLE(SnapCoordinator); |
| 35 | 35 |
| 36 public: | 36 public: |
| 37 static SnapCoordinator* Create(); | 37 static SnapCoordinator* Create(); |
| 38 ~SnapCoordinator(); | 38 ~SnapCoordinator(); |
| 39 DEFINE_INLINE_TRACE() {} | 39 DEFINE_INLINE_TRACE() {} |
| 40 | 40 |
| 41 void SnapContainerDidChange(LayoutBox&, ScrollSnapType); | 41 void SnapContainerDidChange(LayoutBox&, ScrollSnapType); |
| 42 void SnapAreaDidChange(LayoutBox&, | 42 void SnapAreaDidChange(LayoutBox&, ScrollSnapAlign); |
| 43 const Vector<LengthPoint>& snap_coordinates); | |
| 44 | 43 |
| 45 #ifndef NDEBUG | 44 #ifndef NDEBUG |
| 46 void ShowSnapAreaMap(); | 45 void ShowSnapAreaMap(); |
| 47 void ShowSnapAreasFor(const LayoutBox*); | 46 void ShowSnapAreasFor(const LayoutBox*); |
| 48 #endif | 47 #endif |
| 49 | 48 |
| 50 private: | 49 private: |
| 51 friend class SnapCoordinatorTest; | 50 friend class SnapCoordinatorTest; |
| 52 explicit SnapCoordinator(); | 51 explicit SnapCoordinator(); |
| 53 | 52 |
| 54 Vector<double> SnapOffsets(const ContainerNode&, ScrollbarOrientation); | |
| 55 | |
| 56 HashSet<const LayoutBox*> snap_containers_; | 53 HashSet<const LayoutBox*> snap_containers_; |
| 57 }; | 54 }; |
| 58 | 55 |
| 59 } // namespace blink | 56 } // namespace blink |
| 60 | 57 |
| 61 #endif // SnapCoordinator_h | 58 #endif // SnapCoordinator_h |
| OLD | NEW |