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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Rebase 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/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 5ac9de0dd96cd20cdc1b9a0df7524ce1bf754341..8a5b549ebe9ff9ae66b937e6e0549349861d9eed 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -645,7 +645,8 @@ void LayoutBox::ScrollRectToVisible(const LayoutRect& rect,
const ScrollAlignment& align_x,
const ScrollAlignment& align_y,
ScrollType scroll_type,
- bool make_visible_in_visual_viewport) {
+ bool make_visible_in_visual_viewport,
+ ScrollBehavior scroll_behavior) {
DCHECK(scroll_type == kProgrammaticScroll || scroll_type == kUserScroll);
// Presumably the same issue as in setScrollTop. See crbug.com/343132.
DisableCompositingQueryAsserts disabler;
@@ -666,14 +667,21 @@ void LayoutBox::ScrollRectToVisible(const LayoutRect& rect,
!ContainingBlock()->Style()->LineClamp().IsNone();
}
+ bool is_smooth = false;
+ if (scroll_behavior == kScrollBehaviorSmooth ||
+ (scroll_behavior == kScrollBehaviorAuto &&
+ Style()->GetScrollBehavior() == kScrollBehaviorSmooth)) {
+ is_smooth = true;
bokan 2017/05/15 17:15:28 This is another way of saying: bool is_smooth =
sunyunjia 2017/05/19 16:24:29 Done.
+ }
+
if (HasOverflowClip() && !restricted_by_line_clamp) {
// Don't scroll to reveal an overflow layer that is restricted by the
// -webkit-line-clamp property. This will prevent us from revealing text
// hidden by the slider in Safari RSS.
// TODO(eae): We probably don't need this any more as we don't share any
// code with the Safari RSS reeder.
- new_rect = GetScrollableArea()->ScrollIntoView(rect_to_scroll, align_x,
- align_y, scroll_type);
+ new_rect = GetScrollableArea()->ScrollIntoView(
+ rect_to_scroll, align_x, align_y, scroll_type, is_smooth);
if (new_rect.IsEmpty())
return;
} else if (!parent_box && CanBeProgramaticallyScrolled()) {
@@ -682,10 +690,10 @@ void LayoutBox::ScrollRectToVisible(const LayoutRect& rect,
if (!IsDisallowedAutoscroll(owner_element, frame_view)) {
if (make_visible_in_visual_viewport) {
frame_view->GetScrollableArea()->ScrollIntoView(
- rect_to_scroll, align_x, align_y, scroll_type);
+ rect_to_scroll, align_x, align_y, scroll_type, is_smooth);
} else {
frame_view->LayoutViewportScrollableArea()->ScrollIntoView(
- rect_to_scroll, align_x, align_y, scroll_type);
+ rect_to_scroll, align_x, align_y, scroll_type, is_smooth);
}
if (owner_element && owner_element->GetLayoutObject()) {
if (frame_view->SafeToPropagateScrollToParent()) {
@@ -715,9 +723,11 @@ void LayoutBox::ScrollRectToVisible(const LayoutRect& rect,
if (GetFrame()->GetPage()->GetAutoscrollController().AutoscrollInProgress())
parent_box = EnclosingScrollableBox();
- if (parent_box)
+ if (parent_box) {
parent_box->ScrollRectToVisible(new_rect, align_x, align_y, scroll_type,
- make_visible_in_visual_viewport);
+ make_visible_in_visual_viewport,
+ scroll_behavior);
+ }
}
void LayoutBox::AbsoluteRects(Vector<IntRect>& rects,

Powered by Google App Engine
This is Rietveld 408576698