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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Rebase Created 3 years, 8 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 db2ee4b233d8dab7ebc5736b177856ad63136137..746b01b04c40e49660c88a3fc24107459abfceed 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -2102,6 +2102,13 @@ HostWindow* FrameView::getHostWindow() const {
return &page->chromeClient();
}
+SmoothScrollSequencer* FrameView::getSmoothScrollSequencer() const {
+ Page* page = frame().page();
+ if (!page)
+ return nullptr;
+ return page->smoothScrollSequencer();
+}
+
void FrameView::contentsResized() {
if (m_frame->isMainFrame() && m_frame->document()) {
if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer())
@@ -4496,16 +4503,21 @@ FrameViewBase* FrameView::getFrameViewBase() {
LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent,
const ScrollAlignment& alignX,
const ScrollAlignment& alignY,
- ScrollType scrollType) {
+ ScrollType scrollType,
+ bool isSmooth) {
LayoutRect viewRect(visibleContentRect());
LayoutRect exposeRect =
ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY);
if (exposeRect != viewRect) {
- setScrollOffset(
- ScrollOffset(exposeRect.x().toFloat(), exposeRect.y().toFloat()),
- scrollType);
+ ScrollOffset targetOffset(exposeRect.x().toFloat(),
+ exposeRect.y().toFloat());
+ if (isSmooth) {
+ DCHECK(scrollType != UserScroll);
+ getSmoothScrollSequencer()->queueAnimation(this, targetOffset);
+ } else {
+ setScrollOffset(targetOffset, scrollType);
+ }
}
-
bokan 2017/04/07 15:56:52 Nit: the blank line was fine
sunyunjia 2017/05/12 18:40:25 Done.
// 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