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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalFrameView.cpp

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Rebase 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 } 2120 }
2121 } 2121 }
2122 2122
2123 PlatformChromeClient* LocalFrameView::GetChromeClient() const { 2123 PlatformChromeClient* LocalFrameView::GetChromeClient() const {
2124 Page* page = GetFrame().GetPage(); 2124 Page* page = GetFrame().GetPage();
2125 if (!page) 2125 if (!page)
2126 return nullptr; 2126 return nullptr;
2127 return &page->GetChromeClient(); 2127 return &page->GetChromeClient();
2128 } 2128 }
2129 2129
2130 SmoothScrollSequencer* LocalFrameView::GetSmoothScrollSequencer() const {
2131 Page* page = GetFrame().GetPage();
2132 if (!page)
2133 return nullptr;
2134 return page->GetSmoothScrollSequencer();
2135 }
2136
2130 void LocalFrameView::ContentsResized() { 2137 void LocalFrameView::ContentsResized() {
2131 if (frame_->IsMainFrame() && frame_->GetDocument()) { 2138 if (frame_->IsMainFrame() && frame_->GetDocument()) {
2132 if (TextAutosizer* text_autosizer = 2139 if (TextAutosizer* text_autosizer =
2133 frame_->GetDocument()->GetTextAutosizer()) 2140 frame_->GetDocument()->GetTextAutosizer())
2134 text_autosizer->UpdatePageInfoInAllFrames(); 2141 text_autosizer->UpdatePageInfoInAllFrames();
2135 } 2142 }
2136 2143
2137 ScrollableArea::ContentsResized(); 2144 ScrollableArea::ContentsResized();
2138 SetNeedsLayout(); 2145 SetNeedsLayout();
2139 } 2146 }
(...skipping 2463 matching lines...) Expand 10 before | Expand all | Expand 10 after
4603 return mode == kScrollbarAuto || mode == kScrollbarAlwaysOn; 4610 return mode == kScrollbarAuto || mode == kScrollbarAlwaysOn;
4604 } 4611 }
4605 4612
4606 bool LocalFrameView::ShouldPlaceVerticalScrollbarOnLeft() const { 4613 bool LocalFrameView::ShouldPlaceVerticalScrollbarOnLeft() const {
4607 return false; 4614 return false;
4608 } 4615 }
4609 4616
4610 LayoutRect LocalFrameView::ScrollIntoView(const LayoutRect& rect_in_content, 4617 LayoutRect LocalFrameView::ScrollIntoView(const LayoutRect& rect_in_content,
4611 const ScrollAlignment& align_x, 4618 const ScrollAlignment& align_x,
4612 const ScrollAlignment& align_y, 4619 const ScrollAlignment& align_y,
4620 bool is_smooth,
4613 ScrollType scroll_type) { 4621 ScrollType scroll_type) {
4614 LayoutRect view_rect(VisibleContentRect()); 4622 LayoutRect view_rect(VisibleContentRect());
4615 LayoutRect expose_rect = ScrollAlignment::GetRectToExpose( 4623 LayoutRect expose_rect = ScrollAlignment::GetRectToExpose(
4616 view_rect, rect_in_content, align_x, align_y); 4624 view_rect, rect_in_content, align_x, align_y);
4617 if (expose_rect != view_rect) { 4625 if (expose_rect != view_rect) {
4618 SetScrollOffset( 4626 ScrollOffset target_offset(expose_rect.X().ToFloat(),
4619 ScrollOffset(expose_rect.X().ToFloat(), expose_rect.Y().ToFloat()), 4627 expose_rect.Y().ToFloat());
4620 scroll_type); 4628 if (is_smooth) {
4629 DCHECK(scroll_type == kProgrammaticScroll);
4630 GetSmoothScrollSequencer()->QueueAnimation(this, target_offset);
4631 } else {
4632 SetScrollOffset(target_offset, scroll_type);
4633 }
4621 } 4634 }
4622 4635
4623 // Scrolling the LocalFrameView cannot change the input rect's location 4636 // Scrolling the LocalFrameView cannot change the input rect's location
4624 // relative to the document. 4637 // relative to the document.
4625 return rect_in_content; 4638 return rect_in_content;
4626 } 4639 }
4627 4640
4628 IntRect LocalFrameView::ScrollCornerRect() const { 4641 IntRect LocalFrameView::ScrollCornerRect() const {
4629 IntRect corner_rect; 4642 IntRect corner_rect;
4630 4643
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
5392 void LocalFrameView::SetAnimationHost( 5405 void LocalFrameView::SetAnimationHost(
5393 std::unique_ptr<CompositorAnimationHost> host) { 5406 std::unique_ptr<CompositorAnimationHost> host) {
5394 animation_host_ = std::move(host); 5407 animation_host_ = std::move(host);
5395 } 5408 }
5396 5409
5397 LayoutUnit LocalFrameView::CaretWidth() const { 5410 LayoutUnit LocalFrameView::CaretWidth() const {
5398 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); 5411 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1));
5399 } 5412 }
5400 5413
5401 } // namespace blink 5414 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698