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

Side by Side 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 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 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 } 2167 }
2168 } 2168 }
2169 2169
2170 PlatformChromeClient* FrameView::GetChromeClient() const { 2170 PlatformChromeClient* FrameView::GetChromeClient() const {
2171 Page* page = GetFrame().GetPage(); 2171 Page* page = GetFrame().GetPage();
2172 if (!page) 2172 if (!page)
2173 return nullptr; 2173 return nullptr;
2174 return &page->GetChromeClient(); 2174 return &page->GetChromeClient();
2175 } 2175 }
2176 2176
2177 SmoothScrollSequencer* FrameView::GetSmoothScrollSequencer() const {
2178 Page* page = GetFrame().GetPage();
2179 if (!page)
2180 return nullptr;
2181 return page->GetSmoothScrollSequencer();
2182 }
2183
2177 void FrameView::ContentsResized() { 2184 void FrameView::ContentsResized() {
2178 if (frame_->IsMainFrame() && frame_->GetDocument()) { 2185 if (frame_->IsMainFrame() && frame_->GetDocument()) {
2179 if (TextAutosizer* text_autosizer = 2186 if (TextAutosizer* text_autosizer =
2180 frame_->GetDocument()->GetTextAutosizer()) 2187 frame_->GetDocument()->GetTextAutosizer())
2181 text_autosizer->UpdatePageInfoInAllFrames(); 2188 text_autosizer->UpdatePageInfoInAllFrames();
2182 } 2189 }
2183 2190
2184 ScrollableArea::ContentsResized(); 2191 ScrollableArea::ContentsResized();
2185 SetNeedsLayout(); 2192 SetNeedsLayout();
2186 } 2193 }
(...skipping 2445 matching lines...) Expand 10 before | Expand all | Expand 10 after
4632 return mode == kScrollbarAuto || mode == kScrollbarAlwaysOn; 4639 return mode == kScrollbarAuto || mode == kScrollbarAlwaysOn;
4633 } 4640 }
4634 4641
4635 bool FrameView::ShouldPlaceVerticalScrollbarOnLeft() const { 4642 bool FrameView::ShouldPlaceVerticalScrollbarOnLeft() const {
4636 return false; 4643 return false;
4637 } 4644 }
4638 4645
4639 LayoutRect FrameView::ScrollIntoView(const LayoutRect& rect_in_content, 4646 LayoutRect FrameView::ScrollIntoView(const LayoutRect& rect_in_content,
4640 const ScrollAlignment& align_x, 4647 const ScrollAlignment& align_x,
4641 const ScrollAlignment& align_y, 4648 const ScrollAlignment& align_y,
4649 bool is_smooth,
4642 ScrollType scroll_type) { 4650 ScrollType scroll_type) {
4643 LayoutRect view_rect(VisibleContentRect()); 4651 LayoutRect view_rect(VisibleContentRect());
4644 LayoutRect expose_rect = ScrollAlignment::GetRectToExpose( 4652 LayoutRect expose_rect = ScrollAlignment::GetRectToExpose(
4645 view_rect, rect_in_content, align_x, align_y); 4653 view_rect, rect_in_content, align_x, align_y);
4646 if (expose_rect != view_rect) { 4654 if (expose_rect != view_rect) {
4647 SetScrollOffset( 4655 ScrollOffset target_offset(expose_rect.X().ToFloat(),
4648 ScrollOffset(expose_rect.X().ToFloat(), expose_rect.Y().ToFloat()), 4656 expose_rect.Y().ToFloat());
4649 scroll_type); 4657 if (is_smooth) {
4658 DCHECK(scroll_type == kProgrammaticScroll);
4659 GetSmoothScrollSequencer()->QueueAnimation(this, target_offset);
4660 } else {
4661 SetScrollOffset(target_offset, scroll_type);
4662 }
4650 } 4663 }
4651 4664
4652 // Scrolling the FrameView cannot change the input rect's location relative to 4665 // Scrolling the FrameView cannot change the input rect's location relative to
4653 // the document. 4666 // the document.
4654 return rect_in_content; 4667 return rect_in_content;
4655 } 4668 }
4656 4669
4657 IntRect FrameView::ScrollCornerRect() const { 4670 IntRect FrameView::ScrollCornerRect() const {
4658 IntRect corner_rect; 4671 IntRect corner_rect;
4659 4672
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
5425 void FrameView::SetAnimationHost( 5438 void FrameView::SetAnimationHost(
5426 std::unique_ptr<CompositorAnimationHost> host) { 5439 std::unique_ptr<CompositorAnimationHost> host) {
5427 animation_host_ = std::move(host); 5440 animation_host_ = std::move(host);
5428 } 5441 }
5429 5442
5430 LayoutUnit FrameView::CaretWidth() const { 5443 LayoutUnit FrameView::CaretWidth() const {
5431 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); 5444 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1));
5432 } 5445 }
5433 5446
5434 } // namespace blink 5447 } // namespace blink
OLDNEW
« 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