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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Rebase 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 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 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 } 2137 }
2138 } 2138 }
2139 2139
2140 PlatformChromeClient* FrameView::GetChromeClient() const { 2140 PlatformChromeClient* FrameView::GetChromeClient() const {
2141 Page* page = GetFrame().GetPage(); 2141 Page* page = GetFrame().GetPage();
2142 if (!page) 2142 if (!page)
2143 return nullptr; 2143 return nullptr;
2144 return &page->GetChromeClient(); 2144 return &page->GetChromeClient();
2145 } 2145 }
2146 2146
2147 SmoothScrollSequencer* FrameView::GetSmoothScrollSequencer() const {
2148 Page* page = GetFrame().GetPage();
2149 if (!page)
2150 return nullptr;
2151 return page->GetSmoothScrollSequencer();
2152 }
2153
2147 void FrameView::ContentsResized() { 2154 void FrameView::ContentsResized() {
2148 if (frame_->IsMainFrame() && frame_->GetDocument()) { 2155 if (frame_->IsMainFrame() && frame_->GetDocument()) {
2149 if (TextAutosizer* text_autosizer = 2156 if (TextAutosizer* text_autosizer =
2150 frame_->GetDocument()->GetTextAutosizer()) 2157 frame_->GetDocument()->GetTextAutosizer())
2151 text_autosizer->UpdatePageInfoInAllFrames(); 2158 text_autosizer->UpdatePageInfoInAllFrames();
2152 } 2159 }
2153 2160
2154 ScrollableArea::ContentsResized(); 2161 ScrollableArea::ContentsResized();
2155 SetNeedsLayout(); 2162 SetNeedsLayout();
2156 } 2163 }
(...skipping 2453 matching lines...) Expand 10 before | Expand all | Expand 10 after
4610 return mode == kScrollbarAuto || mode == kScrollbarAlwaysOn; 4617 return mode == kScrollbarAuto || mode == kScrollbarAlwaysOn;
4611 } 4618 }
4612 4619
4613 bool FrameView::ShouldPlaceVerticalScrollbarOnLeft() const { 4620 bool FrameView::ShouldPlaceVerticalScrollbarOnLeft() const {
4614 return false; 4621 return false;
4615 } 4622 }
4616 4623
4617 LayoutRect FrameView::ScrollIntoView(const LayoutRect& rect_in_content, 4624 LayoutRect FrameView::ScrollIntoView(const LayoutRect& rect_in_content,
4618 const ScrollAlignment& align_x, 4625 const ScrollAlignment& align_x,
4619 const ScrollAlignment& align_y, 4626 const ScrollAlignment& align_y,
4620 ScrollType scroll_type) { 4627 ScrollType scroll_type,
4628 bool is_smooth) {
4621 LayoutRect view_rect(VisibleContentRect()); 4629 LayoutRect view_rect(VisibleContentRect());
4622 LayoutRect expose_rect = ScrollAlignment::GetRectToExpose( 4630 LayoutRect expose_rect = ScrollAlignment::GetRectToExpose(
4623 view_rect, rect_in_content, align_x, align_y); 4631 view_rect, rect_in_content, align_x, align_y);
4624 if (expose_rect != view_rect) { 4632 if (expose_rect != view_rect) {
4625 SetScrollOffset( 4633 ScrollOffset target_offset(expose_rect.X().ToFloat(),
4626 ScrollOffset(expose_rect.X().ToFloat(), expose_rect.Y().ToFloat()), 4634 expose_rect.Y().ToFloat());
4627 scroll_type); 4635 if (is_smooth) {
4636 DCHECK(scroll_type != kUserScroll);
4637 GetSmoothScrollSequencer()->QueueAnimation(this, target_offset);
4638 } else {
4639 SetScrollOffset(target_offset, scroll_type);
4640 }
4628 } 4641 }
4629 4642
4630 // Scrolling the FrameView cannot change the input rect's location relative to 4643 // Scrolling the FrameView cannot change the input rect's location relative to
4631 // the document. 4644 // the document.
4632 return rect_in_content; 4645 return rect_in_content;
4633 } 4646 }
4634 4647
4635 IntRect FrameView::ScrollCornerRect() const { 4648 IntRect FrameView::ScrollCornerRect() const {
4636 IntRect corner_rect; 4649 IntRect corner_rect;
4637 4650
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
5362 void FrameView::SetAnimationHost( 5375 void FrameView::SetAnimationHost(
5363 std::unique_ptr<CompositorAnimationHost> host) { 5376 std::unique_ptr<CompositorAnimationHost> host) {
5364 animation_host_ = std::move(host); 5377 animation_host_ = std::move(host);
5365 } 5378 }
5366 5379
5367 LayoutUnit FrameView::CaretWidth() const { 5380 LayoutUnit FrameView::CaretWidth() const {
5368 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); 5381 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1));
5369 } 5382 }
5370 5383
5371 } // namespace blink 5384 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698