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

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

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

Powered by Google App Engine
This is Rietveld 408576698