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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Created 3 years, 10 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 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 } 2046 }
2047 } 2047 }
2048 2048
2049 HostWindow* FrameView::getHostWindow() const { 2049 HostWindow* FrameView::getHostWindow() const {
2050 Page* page = frame().page(); 2050 Page* page = frame().page();
2051 if (!page) 2051 if (!page)
2052 return nullptr; 2052 return nullptr;
2053 return &page->chromeClient(); 2053 return &page->chromeClient();
2054 } 2054 }
2055 2055
2056 ProgrammaticScrollCoordinator* FrameView::getProgrammaticScrollCoordinator()
2057 const {
2058 Page* page = frame().page();
2059 if (!page)
2060 return nullptr;
2061 return page->scrollingCoordinator()->programmaticScrollCoordinator();
2062 }
2063
2056 void FrameView::contentsResized() { 2064 void FrameView::contentsResized() {
2057 if (m_frame->isMainFrame() && m_frame->document()) { 2065 if (m_frame->isMainFrame() && m_frame->document()) {
2058 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer()) 2066 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer())
2059 textAutosizer->updatePageInfoInAllFrames(); 2067 textAutosizer->updatePageInfoInAllFrames();
2060 } 2068 }
2061 2069
2062 ScrollableArea::contentsResized(); 2070 ScrollableArea::contentsResized();
2063 setNeedsLayout(); 2071 setNeedsLayout();
2064 } 2072 }
2065 2073
(...skipping 2305 matching lines...) Expand 10 before | Expand all | Expand 10 after
4371 return false; 4379 return false;
4372 } 4380 }
4373 4381
4374 Widget* FrameView::getWidget() { 4382 Widget* FrameView::getWidget() {
4375 return this; 4383 return this;
4376 } 4384 }
4377 4385
4378 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, 4386 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent,
4379 const ScrollAlignment& alignX, 4387 const ScrollAlignment& alignX,
4380 const ScrollAlignment& alignY, 4388 const ScrollAlignment& alignY,
4381 ScrollType scrollType) { 4389 ScrollType scrollType,
4390 ScrollBehavior scrollBehavior) {
4382 LayoutRect viewRect(visibleContentRect()); 4391 LayoutRect viewRect(visibleContentRect());
4383 LayoutRect exposeRect = 4392 LayoutRect exposeRect =
4384 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY); 4393 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY);
4385 if (exposeRect != viewRect) { 4394 if (exposeRect != viewRect) {
4386 setScrollOffset( 4395 if (scrollType == ProgrammaticScroll &&
4387 ScrollOffset(exposeRect.x().toFloat(), exposeRect.y().toFloat()), 4396 scrollBehavior == ScrollBehaviorSmooth) {
bokan 2017/02/02 22:51:50 Add a DCHECK that we don't have a UserScroll passi
sunyunjia 2017/02/10 23:25:20 Done.
4388 scrollType); 4397 getProgrammaticScrollCoordinator()->queueAnimation(
4398 this,
4399 ScrollOffset(exposeRect.x().toFloat(), exposeRect.y().toFloat()));
4400 } else {
4401 setScrollOffset(
4402 ScrollOffset(exposeRect.x().toFloat(), exposeRect.y().toFloat()),
4403 scrollType);
4404 }
4389 } 4405 }
4390
4391 // Scrolling the FrameView cannot change the input rect's location relative to 4406 // Scrolling the FrameView cannot change the input rect's location relative to
4392 // the document. 4407 // the document.
4393 return rectInContent; 4408 return rectInContent;
4394 } 4409 }
4395 4410
4396 IntRect FrameView::scrollCornerRect() const { 4411 IntRect FrameView::scrollCornerRect() const {
4397 IntRect cornerRect; 4412 IntRect cornerRect;
4398 4413
4399 if (hasOverlayScrollbars()) 4414 if (hasOverlayScrollbars())
4400 return cornerRect; 4415 return cornerRect;
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
5084 std::unique_ptr<CompositorAnimationTimeline> timeline) { 5099 std::unique_ptr<CompositorAnimationTimeline> timeline) {
5085 m_animationTimeline = std::move(timeline); 5100 m_animationTimeline = std::move(timeline);
5086 } 5101 }
5087 5102
5088 void FrameView::setAnimationHost( 5103 void FrameView::setAnimationHost(
5089 std::unique_ptr<CompositorAnimationHost> host) { 5104 std::unique_ptr<CompositorAnimationHost> host) {
5090 m_animationHost = std::move(host); 5105 m_animationHost = std::move(host);
5091 } 5106 }
5092 5107
5093 } // namespace blink 5108 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698