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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Add a short comment. Created 3 years, 7 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/RootFrameViewport.cpp
diff --git a/third_party/WebKit/Source/core/frame/RootFrameViewport.cpp b/third_party/WebKit/Source/core/frame/RootFrameViewport.cpp
index ee56bd1fe8fe55e8983f89a21f5b4af5215b71d5..53896c238112a3da6a8f1bbb9c46b60085b5c1ef 100644
--- a/third_party/WebKit/Source/core/frame/RootFrameViewport.cpp
+++ b/third_party/WebKit/Source/core/frame/RootFrameViewport.cpp
@@ -209,6 +209,7 @@ ScrollBehavior RootFrameViewport::ScrollBehaviorStyle() const {
LayoutRect RootFrameViewport::ScrollIntoView(const LayoutRect& rect_in_content,
const ScrollAlignment& align_x,
const ScrollAlignment& align_y,
+ bool is_smooth,
ScrollType scroll_type) {
// We want to move the rect into the viewport that excludes the scrollbars so
// we intersect the visual viewport with the scrollbar-excluded frameView
@@ -229,8 +230,13 @@ LayoutRect RootFrameViewport::ScrollIntoView(const LayoutRect& rect_in_content,
LayoutRect target_viewport = ScrollAlignment::GetRectToExpose(
view_rect_in_content, rect_in_content, align_x, align_y);
if (target_viewport != view_rect_in_content) {
- SetScrollOffset(ScrollOffset(target_viewport.X(), target_viewport.Y()),
- scroll_type);
+ ScrollOffset target_offset(target_viewport.X(), target_viewport.Y());
+ if (is_smooth) {
+ DCHECK(scroll_type == kProgrammaticScroll);
+ GetSmoothScrollSequencer()->QueueAnimation(this, target_offset);
+ } else {
+ SetScrollOffset(target_offset, scroll_type);
+ }
}
// RootFrameViewport only changes the viewport relative to the document so we
@@ -431,6 +437,10 @@ PlatformChromeClient* RootFrameViewport::GetChromeClient() const {
return LayoutViewport().GetChromeClient();
}
+SmoothScrollSequencer* RootFrameViewport::GetSmoothScrollSequencer() const {
+ return LayoutViewport().GetSmoothScrollSequencer();
+}
+
void RootFrameViewport::ServiceScrollAnimations(double monotonic_time) {
ScrollableArea::ServiceScrollAnimations(monotonic_time);
LayoutViewport().ServiceScrollAnimations(monotonic_time);

Powered by Google App Engine
This is Rietveld 408576698