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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBox.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/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 31ceec9b105e93d326f8a53f172fd79b5fb0e0ec..a35862c461793a1fd504d8c8cc86ad5e55166bba 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -648,7 +648,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;
@@ -669,14 +670,18 @@ void LayoutBox::ScrollRectToVisible(const LayoutRect& rect,
!ContainingBlock()->Style()->LineClamp().IsNone();
}
+ bool is_smooth = scroll_behavior == kScrollBehaviorSmooth ||
+ (scroll_behavior == kScrollBehaviorAuto &&
+ Style()->GetScrollBehavior() == kScrollBehaviorSmooth);
+
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, is_smooth, scroll_type);
if (new_rect.IsEmpty())
return;
} else if (!parent_box && CanBeProgramaticallyScrolled()) {
@@ -685,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, is_smooth, scroll_type);
} else {
frame_view->LayoutViewportScrollableArea()->ScrollIntoView(
- rect_to_scroll, align_x, align_y, scroll_type);
+ rect_to_scroll, align_x, align_y, is_smooth, scroll_type);
}
if (owner_element && owner_element->GetLayoutObject()) {
if (frame_view->SafeToPropagateScrollToParent()) {
@@ -718,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