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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Added web platform test. 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 2129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 } 2140 }
2141 } 2141 }
2142 2142
2143 PlatformChromeClient* FrameView::GetChromeClient() const { 2143 PlatformChromeClient* FrameView::GetChromeClient() const {
2144 Page* page = GetFrame().GetPage(); 2144 Page* page = GetFrame().GetPage();
2145 if (!page) 2145 if (!page)
2146 return nullptr; 2146 return nullptr;
2147 return &page->GetChromeClient(); 2147 return &page->GetChromeClient();
2148 } 2148 }
2149 2149
2150 SmoothScrollSequencer* FrameView::GetSmoothScrollSequencer() const {
2151 Page* page = GetFrame().GetPage();
2152 if (!page)
2153 return nullptr;
2154 return page->GetSmoothScrollSequencer();
2155 }
2156
2150 void FrameView::ContentsResized() { 2157 void FrameView::ContentsResized() {
2151 if (frame_->IsMainFrame() && frame_->GetDocument()) { 2158 if (frame_->IsMainFrame() && frame_->GetDocument()) {
2152 if (TextAutosizer* text_autosizer = 2159 if (TextAutosizer* text_autosizer =
2153 frame_->GetDocument()->GetTextAutosizer()) 2160 frame_->GetDocument()->GetTextAutosizer())
2154 text_autosizer->UpdatePageInfoInAllFrames(); 2161 text_autosizer->UpdatePageInfoInAllFrames();
2155 } 2162 }
2156 2163
2157 ScrollableArea::ContentsResized(); 2164 ScrollableArea::ContentsResized();
2158 SetNeedsLayout(); 2165 SetNeedsLayout();
2159 } 2166 }
(...skipping 2468 matching lines...) Expand 10 before | Expand all | Expand 10 after
4628 return mode == kScrollbarAuto || mode == kScrollbarAlwaysOn; 4635 return mode == kScrollbarAuto || mode == kScrollbarAlwaysOn;
4629 } 4636 }
4630 4637
4631 bool FrameView::ShouldPlaceVerticalScrollbarOnLeft() const { 4638 bool FrameView::ShouldPlaceVerticalScrollbarOnLeft() const {
4632 return false; 4639 return false;
4633 } 4640 }
4634 4641
4635 LayoutRect FrameView::ScrollIntoView(const LayoutRect& rect_in_content, 4642 LayoutRect FrameView::ScrollIntoView(const LayoutRect& rect_in_content,
4636 const ScrollAlignment& align_x, 4643 const ScrollAlignment& align_x,
4637 const ScrollAlignment& align_y, 4644 const ScrollAlignment& align_y,
4638 ScrollType scroll_type) { 4645 ScrollType scroll_type,
4646 bool is_smooth) {
4639 LayoutRect view_rect(VisibleContentRect()); 4647 LayoutRect view_rect(VisibleContentRect());
4640 LayoutRect expose_rect = ScrollAlignment::GetRectToExpose( 4648 LayoutRect expose_rect = ScrollAlignment::GetRectToExpose(
4641 view_rect, rect_in_content, align_x, align_y); 4649 view_rect, rect_in_content, align_x, align_y);
4642 if (expose_rect != view_rect) { 4650 if (expose_rect != view_rect) {
4643 SetScrollOffset( 4651 ScrollOffset target_offset(expose_rect.X().ToFloat(),
4644 ScrollOffset(expose_rect.X().ToFloat(), expose_rect.Y().ToFloat()), 4652 expose_rect.Y().ToFloat());
4645 scroll_type); 4653 if (is_smooth) {
4654 DCHECK(scroll_type != kUserScroll);
4655 GetSmoothScrollSequencer()->QueueAnimation(this, target_offset);
4656 } else {
4657 SetScrollOffset(target_offset, scroll_type);
4658 }
4646 } 4659 }
4647 4660
4648 // Scrolling the FrameView cannot change the input rect's location relative to 4661 // Scrolling the FrameView cannot change the input rect's location relative to
4649 // the document. 4662 // the document.
4650 return rect_in_content; 4663 return rect_in_content;
4651 } 4664 }
4652 4665
4653 IntRect FrameView::ScrollCornerRect() const { 4666 IntRect FrameView::ScrollCornerRect() const {
4654 IntRect corner_rect; 4667 IntRect corner_rect;
4655 4668
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
5390 void FrameView::SetAnimationHost( 5403 void FrameView::SetAnimationHost(
5391 std::unique_ptr<CompositorAnimationHost> host) { 5404 std::unique_ptr<CompositorAnimationHost> host) {
5392 animation_host_ = std::move(host); 5405 animation_host_ = std::move(host);
5393 } 5406 }
5394 5407
5395 LayoutUnit FrameView::CaretWidth() const { 5408 LayoutUnit FrameView::CaretWidth() const {
5396 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); 5409 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1));
5397 } 5410 }
5398 5411
5399 } // namespace blink 5412 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698