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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Sequenced-smooth-scrolls only happen on main thread for now. 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 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 } 2135 }
2136 } 2136 }
2137 2137
2138 PlatformChromeClient* LocalFrameView::GetChromeClient() const { 2138 PlatformChromeClient* LocalFrameView::GetChromeClient() const {
2139 Page* page = GetFrame().GetPage(); 2139 Page* page = GetFrame().GetPage();
2140 if (!page) 2140 if (!page)
2141 return nullptr; 2141 return nullptr;
2142 return &page->GetChromeClient(); 2142 return &page->GetChromeClient();
2143 } 2143 }
2144 2144
2145 SmoothScrollSequencer* LocalFrameView::GetSmoothScrollSequencer() const {
2146 Page* page = GetFrame().GetPage();
2147 if (!page)
2148 return nullptr;
2149 return page->GetSmoothScrollSequencer();
2150 }
2151
2145 void LocalFrameView::ContentsResized() { 2152 void LocalFrameView::ContentsResized() {
2146 if (frame_->IsMainFrame() && frame_->GetDocument()) { 2153 if (frame_->IsMainFrame() && frame_->GetDocument()) {
2147 if (TextAutosizer* text_autosizer = 2154 if (TextAutosizer* text_autosizer =
2148 frame_->GetDocument()->GetTextAutosizer()) 2155 frame_->GetDocument()->GetTextAutosizer())
2149 text_autosizer->UpdatePageInfoInAllFrames(); 2156 text_autosizer->UpdatePageInfoInAllFrames();
2150 } 2157 }
2151 2158
2152 ScrollableArea::ContentsResized(); 2159 ScrollableArea::ContentsResized();
2153 SetNeedsLayout(); 2160 SetNeedsLayout();
2154 } 2161 }
(...skipping 2469 matching lines...) Expand 10 before | Expand all | Expand 10 after
4624 return mode == kScrollbarAuto || mode == kScrollbarAlwaysOn; 4631 return mode == kScrollbarAuto || mode == kScrollbarAlwaysOn;
4625 } 4632 }
4626 4633
4627 bool LocalFrameView::ShouldPlaceVerticalScrollbarOnLeft() const { 4634 bool LocalFrameView::ShouldPlaceVerticalScrollbarOnLeft() const {
4628 return false; 4635 return false;
4629 } 4636 }
4630 4637
4631 LayoutRect LocalFrameView::ScrollIntoView(const LayoutRect& rect_in_content, 4638 LayoutRect LocalFrameView::ScrollIntoView(const LayoutRect& rect_in_content,
4632 const ScrollAlignment& align_x, 4639 const ScrollAlignment& align_x,
4633 const ScrollAlignment& align_y, 4640 const ScrollAlignment& align_y,
4641 bool is_smooth,
4634 ScrollType scroll_type) { 4642 ScrollType scroll_type) {
4635 LayoutRect view_rect(VisibleContentRect()); 4643 LayoutRect view_rect(VisibleContentRect());
4636 LayoutRect expose_rect = ScrollAlignment::GetRectToExpose( 4644 LayoutRect expose_rect = ScrollAlignment::GetRectToExpose(
4637 view_rect, rect_in_content, align_x, align_y); 4645 view_rect, rect_in_content, align_x, align_y);
4638 if (expose_rect != view_rect) { 4646 if (expose_rect != view_rect) {
4639 SetScrollOffset( 4647 ScrollOffset target_offset(expose_rect.X().ToFloat(),
4640 ScrollOffset(expose_rect.X().ToFloat(), expose_rect.Y().ToFloat()), 4648 expose_rect.Y().ToFloat());
4641 scroll_type); 4649 if (is_smooth) {
4650 DCHECK(scroll_type == kProgrammaticScroll);
4651 GetSmoothScrollSequencer()->QueueAnimation(this, target_offset);
4652 } else {
4653 SetScrollOffset(target_offset, scroll_type);
4654 }
4642 } 4655 }
4643 4656
4644 // Scrolling the LocalFrameView cannot change the input rect's location 4657 // Scrolling the LocalFrameView cannot change the input rect's location
4645 // relative to the document. 4658 // relative to the document.
4646 return rect_in_content; 4659 return rect_in_content;
4647 } 4660 }
4648 4661
4649 IntRect LocalFrameView::ScrollCornerRect() const { 4662 IntRect LocalFrameView::ScrollCornerRect() const {
4650 IntRect corner_rect; 4663 IntRect corner_rect;
4651 4664
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
5399 void LocalFrameView::SetAnimationHost( 5412 void LocalFrameView::SetAnimationHost(
5400 std::unique_ptr<CompositorAnimationHost> host) { 5413 std::unique_ptr<CompositorAnimationHost> host) {
5401 animation_host_ = std::move(host); 5414 animation_host_ = std::move(host);
5402 } 5415 }
5403 5416
5404 LayoutUnit LocalFrameView::CaretWidth() const { 5417 LayoutUnit LocalFrameView::CaretWidth() const {
5405 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); 5418 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1));
5406 } 5419 }
5407 5420
5408 } // namespace blink 5421 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698