| Index: third_party/WebKit/Source/core/page/scrolling/SnapCoordinator.cpp
|
| diff --git a/third_party/WebKit/Source/core/page/scrolling/SnapCoordinator.cpp b/third_party/WebKit/Source/core/page/scrolling/SnapCoordinator.cpp
|
| index 022f7a2a272cf758ab4af7fe93731a8109ff8664..9b5bc15b998e25fa96dd9a345b176447db31afa6 100644
|
| --- a/third_party/WebKit/Source/core/page/scrolling/SnapCoordinator.cpp
|
| +++ b/third_party/WebKit/Source/core/page/scrolling/SnapCoordinator.cpp
|
| @@ -15,18 +15,18 @@
|
|
|
| namespace blink {
|
|
|
| -SnapCoordinator::SnapCoordinator()
|
| - : m_snapContainers()
|
| +SnapCoordinator* SnapCoordinator::create(Client* client)
|
| {
|
| + return new SnapCoordinator(client);
|
| }
|
|
|
| -SnapCoordinator::~SnapCoordinator() { }
|
| -
|
| -SnapCoordinator* SnapCoordinator::create()
|
| +SnapCoordinator::SnapCoordinator(Client* client)
|
| + : m_client(client)
|
| {
|
| - return new SnapCoordinator();
|
| }
|
|
|
| +SnapCoordinator::~SnapCoordinator() { }
|
| +
|
| // Returns the scroll container that can be affected by this snap area.
|
| static LayoutBox* findSnapContainer(const LayoutBox& snapArea)
|
| {
|
| @@ -147,6 +147,27 @@ Vector<double> SnapCoordinator::snapOffsets(const ContainerNode& element, Scroll
|
| return result;
|
| }
|
|
|
| +
|
| +
|
| +void SnapCoordinator::notifyLayoutUpdated()
|
| +{
|
| + // TODO(majidvp): This should be replaced with compositor worker precommit
|
| + for (const LayoutBox* container : m_snapContainers) {
|
| + ContainerNode& containerNode = toContainerNode(*container->node());
|
| + SnapOffsets newOffsets;
|
| + newOffsets.horizontal = snapOffsets(containerNode, HorizontalScrollbar);
|
| + newOffsets.vertical = snapOffsets(containerNode, VerticalScrollbar);
|
| +
|
| + // report only if it is different from the cached value
|
| + if (m_offsetMap.contains(container) && m_offsetMap.get(container) == newOffsets)
|
| + continue;
|
| + m_offsetMap.set(container, newOffsets);
|
| + if (m_client)
|
| + m_client->didUpdateSnapOffsets(*container, newOffsets);
|
| + }
|
| +}
|
| +
|
| +
|
| #ifndef NDEBUG
|
|
|
| void SnapCoordinator::showSnapAreaMap()
|
| @@ -168,4 +189,9 @@ void SnapCoordinator::showSnapAreasFor(const LayoutBox* container)
|
|
|
| #endif
|
|
|
| +bool operator==(const SnapOffsets& a, const SnapOffsets& b)
|
| +{
|
| + return a.horizontal == b.horizontal && a.vertical == b.vertical;
|
| +}
|
| +
|
| } // namespace blink
|
|
|