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

Unified Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Revised according to the comments. We are still missing tests. Created 3 years, 10 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/frame/FrameView.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
index 492fabdffb528c5f48f0bcd315d3d5ef9b7dddf4..154222c1b9052cdbf44cae7300ba869ed29b6010 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -2053,6 +2053,14 @@ HostWindow* FrameView::getHostWindow() const {
return &page->chromeClient();
}
+ProgrammaticScrollCoordinator* FrameView::getProgrammaticScrollCoordinator()
+ const {
+ Page* page = frame().page();
+ if (!page)
+ return nullptr;
+ return page->scrollingCoordinator()->programmaticScrollCoordinator();
+}
+
void FrameView::contentsResized() {
if (m_frame->isMainFrame() && m_frame->document()) {
if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer())
@@ -4378,16 +4386,23 @@ Widget* FrameView::getWidget() {
LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent,
const ScrollAlignment& alignX,
const ScrollAlignment& alignY,
- ScrollType scrollType) {
+ ScrollType scrollType,
+ ScrollBehavior scrollBehavior) {
LayoutRect viewRect(visibleContentRect());
LayoutRect exposeRect =
ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY);
if (exposeRect != viewRect) {
- setScrollOffset(
- ScrollOffset(exposeRect.x().toFloat(), exposeRect.y().toFloat()),
- scrollType);
+ if (scrollBehavior == ScrollBehaviorSmooth) {
+ DCHECK(scrollType != UserScroll);
+ getProgrammaticScrollCoordinator()->queueAnimation(
+ this,
+ ScrollOffset(exposeRect.x().toFloat(), exposeRect.y().toFloat()));
+ } else {
+ setScrollOffset(
+ ScrollOffset(exposeRect.x().toFloat(), exposeRect.y().toFloat()),
+ scrollType);
+ }
}
-
// Scrolling the FrameView cannot change the input rect's location relative to
// the document.
return rectInContent;

Powered by Google App Engine
This is Rietveld 408576698