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

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

Issue 1333323003: SnapManager implementation using V8 Extras - {WIP} Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update with latest master Created 4 years, 6 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.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

Powered by Google App Engine
This is Rietveld 408576698