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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Revised according to the comments. We are still missing tests. 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/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 24e8029cd76195d5c3b2fcb13c43c455ff6dd9f9..77cf2704cf0221381a406af2b109ecb93f3e2efb 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -630,7 +630,8 @@ void LayoutBox::scrollRectToVisible(const LayoutRect& rect,
const ScrollAlignment& alignX,
const ScrollAlignment& alignY,
ScrollType scrollType,
- bool makeVisibleInVisualViewport) {
+ bool makeVisibleInVisualViewport,
+ ScrollBehavior scrollBehavior) {
ASSERT(scrollType == ProgrammaticScroll || scrollType == UserScroll);
// Presumably the same issue as in setScrollTop. See crbug.com/343132.
DisableCompositingQueryAsserts disabler;
@@ -650,6 +651,13 @@ void LayoutBox::scrollRectToVisible(const LayoutRect& rect,
restrictedByLineClamp = !containingBlock()->style()->lineClamp().isNone();
}
+ ScrollBehavior behavior = ScrollBehaviorAuto;
bokan 2017/02/21 21:33:00 This should be ScrollBehaviorInstant so that we pa
sunyunjia 2017/02/24 19:11:48 Done.
+ if (scrollBehavior == ScrollBehaviorSmooth ||
+ (scrollBehavior == ScrollBehaviorAuto &&
+ style()->getScrollBehavior() == ScrollBehaviorSmooth)) {
+ behavior = ScrollBehaviorSmooth;
+ }
+
if (hasOverflowClip() && !restrictedByLineClamp) {
// Don't scroll to reveal an overflow layer that is restricted by the
// -webkit-line-clamp property. This will prevent us from revealing text
@@ -657,7 +665,7 @@ void LayoutBox::scrollRectToVisible(const LayoutRect& rect,
// TODO(eae): We probably don't need this any more as we don't share any
// code with the Safari RSS reeder.
newRect = getScrollableArea()->scrollIntoView(rectToScroll, alignX, alignY,
- scrollType);
+ scrollType, behavior);
if (newRect.isEmpty())
return;
} else if (!parentBox && canBeProgramaticallyScrolled()) {
@@ -665,11 +673,11 @@ void LayoutBox::scrollRectToVisible(const LayoutRect& rect,
HTMLFrameOwnerElement* ownerElement = document().localOwner();
if (!isDisallowedAutoscroll(ownerElement, frameView)) {
if (makeVisibleInVisualViewport) {
- frameView->getScrollableArea()->scrollIntoView(rectToScroll, alignX,
- alignY, scrollType);
+ frameView->getScrollableArea()->scrollIntoView(
+ rectToScroll, alignX, alignY, scrollType, behavior);
} else {
frameView->layoutViewportScrollableArea()->scrollIntoView(
- rectToScroll, alignX, alignY, scrollType);
+ rectToScroll, alignX, alignY, scrollType, behavior);
}
if (ownerElement && ownerElement->layoutObject()) {
if (frameView->safeToPropagateScrollToParent()) {
@@ -699,9 +707,10 @@ void LayoutBox::scrollRectToVisible(const LayoutRect& rect,
if (frame()->page()->autoscrollController().autoscrollInProgress())
parentBox = enclosingScrollableBox();
- if (parentBox)
+ if (parentBox) {
parentBox->scrollRectToVisible(newRect, alignX, alignY, scrollType,
- makeVisibleInVisualViewport);
+ makeVisibleInVisualViewport, scrollBehavior);
+ }
}
void LayoutBox::absoluteRects(Vector<IntRect>& rects,

Powered by Google App Engine
This is Rietveld 408576698