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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Added SimTest. 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/paint/PaintLayerScrollableArea.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
index 98c634e298f3e9b6b6d2a31cc326aaeefac8c51c..d4dba5b1fea1d328c96c274c13c3197a6354d16e 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
@@ -210,6 +210,13 @@ HostWindow* PaintLayerScrollableArea::getHostWindow() const {
return nullptr;
}
+ProgrammaticScrollCoordinator*
+PaintLayerScrollableArea::getProgrammaticScrollCoordinator() const {
+ if (Page* page = box().frame()->page())
+ return page->scrollingCoordinator()->programmaticScrollCoordinator();
+ return nullptr;
+}
+
GraphicsLayer* PaintLayerScrollableArea::layerForScrolling() const {
return layer()->hasCompositedLayerMapping()
? layer()->compositedLayerMapping()->scrollingContentsLayer()
@@ -1634,7 +1641,8 @@ LayoutRect PaintLayerScrollableArea::scrollIntoView(
const LayoutRect& rect,
const ScrollAlignment& alignX,
const ScrollAlignment& alignY,
- ScrollType scrollType) {
+ ScrollType scrollType,
+ bool isSmooth) {
LayoutRect localExposeRect(
box()
.absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms)
@@ -1648,7 +1656,12 @@ LayoutRect PaintLayerScrollableArea::scrollIntoView(
ScrollOffset oldScrollOffset = getScrollOffset();
ScrollOffset newScrollOffset(clampScrollOffset(roundedIntSize(
toScrollOffset(FloatPoint(r.location()) + oldScrollOffset))));
- setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant);
+ if (isSmooth) {
+ DCHECK(scrollType != UserScroll);
+ getProgrammaticScrollCoordinator()->queueAnimation(this, newScrollOffset);
+ } else {
+ setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant);
+ }
ScrollOffset scrollOffsetDifference = getScrollOffset() - oldScrollOffset;
localExposeRect.move(-LayoutSize(scrollOffsetDifference));

Powered by Google App Engine
This is Rietveld 408576698