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

Unified Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Fixed nits. Created 3 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/paint/PaintLayerScrollableArea.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
index 917f80223fe50cbf616a53685b2703981fbb96c9..563ee839f9ea781d1b0e761f7d9b5c31d68fc348 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
@@ -209,6 +209,13 @@ PlatformChromeClient* PaintLayerScrollableArea::GetChromeClient() const {
return nullptr;
}
+SmoothScrollSequencer* PaintLayerScrollableArea::GetSmoothScrollSequencer()
+ const {
+ if (Page* page = Box().GetFrame()->GetPage())
+ return page->GetSmoothScrollSequencer();
+ return nullptr;
+}
+
GraphicsLayer* PaintLayerScrollableArea::LayerForScrolling() const {
return Layer()->HasCompositedLayerMapping()
? Layer()->GetCompositedLayerMapping()->ScrollingContentsLayer()
@@ -1740,6 +1747,7 @@ LayoutRect PaintLayerScrollableArea::ScrollIntoView(
const LayoutRect& rect,
const ScrollAlignment& align_x,
const ScrollAlignment& align_y,
+ bool is_smooth,
ScrollType scroll_type) {
LayoutRect local_expose_rect(
Box()
@@ -1753,8 +1761,14 @@ LayoutRect PaintLayerScrollableArea::ScrollIntoView(
ScrollOffset old_scroll_offset = GetScrollOffset();
ScrollOffset new_scroll_offset(ClampScrollOffset(RoundedIntSize(
ToScrollOffset(FloatPoint(r.Location()) + old_scroll_offset))));
- SetScrollOffset(new_scroll_offset, scroll_type, kScrollBehaviorInstant);
- ScrollOffset scroll_offset_difference = GetScrollOffset() - old_scroll_offset;
+ if (is_smooth) {
+ DCHECK(scroll_type == kProgrammaticScroll);
+ GetSmoothScrollSequencer()->QueueAnimation(this, new_scroll_offset);
+ } else {
+ SetScrollOffset(new_scroll_offset, scroll_type, kScrollBehaviorInstant);
+ }
+ ScrollOffset scroll_offset_difference =
+ ClampScrollOffset(new_scroll_offset) - old_scroll_offset;
local_expose_rect.Move(-LayoutSize(scroll_offset_difference));
LayoutRect intersect =

Powered by Google App Engine
This is Rietveld 408576698