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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Add a short comment. 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 67c3f34ec7647590a02d3f7e66262e8d33f2ef36..6b218ea0462f07f1c36f69ce79c2472386e1d88e 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,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()) {
@@ -682,10 +687,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()) {
@@ -715,9 +720,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,
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutListBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698