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

Unified Diff: Source/core/frame/DOMWindow.cpp

Issue 146003002: Bindings for CSSOM View smooth scroll API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address review comments Created 6 years, 11 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
« no previous file with comments | « Source/core/frame/DOMWindow.h ('k') | Source/core/frame/Window.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/DOMWindow.cpp
diff --git a/Source/core/frame/DOMWindow.cpp b/Source/core/frame/DOMWindow.cpp
index ea86affedd389f572972222687c5d3db4cd050ac..4bc827e01f375d4f7127bf752ad384bd35a7d75c 100644
--- a/Source/core/frame/DOMWindow.cpp
+++ b/Source/core/frame/DOMWindow.cpp
@@ -1385,8 +1385,27 @@ double DOMWindow::devicePixelRatio() const
return m_frame->devicePixelRatio();
}
-void DOMWindow::scrollBy(int x, int y) const
+static bool scrollBehaviorFromScrollOptions(const Dictionary& scrollOptions, ScrollBehavior& scrollBehavior, ExceptionState& exceptionState)
{
+ String scrollBehaviorString;
+ if (!scrollOptions.get("behavior", scrollBehaviorString)) {
+ scrollBehavior = ScrollBehaviorAuto;
+ return true;
+ }
+
+ if (ScrollableArea::scrollBehaviorFromString(scrollBehaviorString, scrollBehavior))
+ return true;
+
+ exceptionState.throwTypeError("The ScrollBehavior provided is invalid.");
+ return false;
+}
+
+void DOMWindow::scrollBy(int x, int y, const Dictionary& scrollOptions, ExceptionState &exceptionState) const
+{
+ ScrollBehavior scrollBehavior = ScrollBehaviorAuto;
+ if (RuntimeEnabledFeatures::cssomSmoothScrollEnabled() && !scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptionState))
+ return;
+
if (!isCurrentlyDisplayedInFrame())
return;
@@ -1396,13 +1415,17 @@ void DOMWindow::scrollBy(int x, int y) const
if (!view)
return;
-
IntSize scaledOffset(x * m_frame->pageZoomFactor(), y * m_frame->pageZoomFactor());
+ // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instantly.
view->scrollBy(scaledOffset);
}
-void DOMWindow::scrollTo(int x, int y) const
+void DOMWindow::scrollTo(int x, int y, const Dictionary& scrollOptions, ExceptionState& exceptionState) const
{
+ ScrollBehavior scrollBehavior = ScrollBehaviorAuto;
+ if (RuntimeEnabledFeatures::cssomSmoothScrollEnabled() && !scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptionState))
+ return;
+
if (!isCurrentlyDisplayedInFrame())
return;
@@ -1413,6 +1436,7 @@ void DOMWindow::scrollTo(int x, int y) const
return;
IntPoint layoutPos(x * m_frame->pageZoomFactor(), y * m_frame->pageZoomFactor());
+ // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instantly.
view->setScrollPosition(layoutPos);
}
« no previous file with comments | « Source/core/frame/DOMWindow.h ('k') | Source/core/frame/Window.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698