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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Created 3 years, 11 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 894d81f85ace408237a9936f9ac218ecd574e509..1516037a006f1eff66f90dc7b7e79d91d90cefbf 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
@@ -211,6 +211,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()
@@ -1630,7 +1637,8 @@ LayoutRect PaintLayerScrollableArea::scrollIntoView(
const LayoutRect& rect,
const ScrollAlignment& alignX,
const ScrollAlignment& alignY,
- ScrollType scrollType) {
+ ScrollType scrollType,
+ ScrollBehavior scrollBehavior) {
LayoutRect localExposeRect(
box()
.absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms)
@@ -1644,7 +1652,12 @@ LayoutRect PaintLayerScrollableArea::scrollIntoView(
ScrollOffset oldScrollOffset = getScrollOffset();
ScrollOffset newScrollOffset(clampScrollOffset(roundedIntSize(
toScrollOffset(FloatPoint(r.location()) + oldScrollOffset))));
- setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant);
+ if (scrollType == ProgrammaticScroll &&
+ scrollBehavior == ScrollBehaviorSmooth) {
+ getProgrammaticScrollCoordinator()->queueAnimation(this, newScrollOffset);
bokan 2017/02/02 22:51:50 Hmm, maybe I'm missing something obvious here, but
sunyunjia 2017/02/10 23:25:20 Right! See here: https://docs.google.com/a/chromiu
bokan 2017/02/21 21:33:00 Got it. I think the name makes it sound like it's
+ } else {
+ setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant);
+ }
ScrollOffset scrollOffsetDifference = getScrollOffset() - oldScrollOffset;
localExposeRect.move(-LayoutSize(scrollOffsetDifference));

Powered by Google App Engine
This is Rietveld 408576698