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

Unified Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Change the default setting. 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/frame/FrameView.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
index ac0dea61f5fd09dba165e76d92681dff8b919eb6..5bc2e7eb3667f7d2738b9dea0f446d710cb32ccb 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -2174,6 +2174,13 @@ PlatformChromeClient* FrameView::GetChromeClient() const {
return &page->GetChromeClient();
}
+SmoothScrollSequencer* FrameView::GetSmoothScrollSequencer() const {
+ Page* page = GetFrame().GetPage();
+ if (!page)
+ return nullptr;
+ return page->GetSmoothScrollSequencer();
+}
+
void FrameView::ContentsResized() {
if (frame_->IsMainFrame() && frame_->GetDocument()) {
if (TextAutosizer* text_autosizer =
@@ -4639,14 +4646,20 @@ bool FrameView::ShouldPlaceVerticalScrollbarOnLeft() const {
LayoutRect FrameView::ScrollIntoView(const LayoutRect& rect_in_content,
const ScrollAlignment& align_x,
const ScrollAlignment& align_y,
+ bool is_smooth,
ScrollType scroll_type) {
LayoutRect view_rect(VisibleContentRect());
LayoutRect expose_rect = ScrollAlignment::GetRectToExpose(
view_rect, rect_in_content, align_x, align_y);
if (expose_rect != view_rect) {
- SetScrollOffset(
- ScrollOffset(expose_rect.X().ToFloat(), expose_rect.Y().ToFloat()),
- scroll_type);
+ ScrollOffset target_offset(expose_rect.X().ToFloat(),
+ expose_rect.Y().ToFloat());
+ if (is_smooth) {
+ DCHECK(scroll_type == kProgrammaticScroll);
+ GetSmoothScrollSequencer()->QueueAnimation(this, target_offset);
+ } else {
+ SetScrollOffset(target_offset, scroll_type);
+ }
}
// Scrolling the FrameView cannot change the input rect's location relative to
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.h ('k') | third_party/WebKit/Source/core/frame/LocalDOMWindow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698