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

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 SimTest. Created 3 years, 9 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 2042 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 } 2053 }
2054 } 2054 }
2055 2055
2056 HostWindow* FrameView::getHostWindow() const { 2056 HostWindow* FrameView::getHostWindow() const {
2057 Page* page = frame().page(); 2057 Page* page = frame().page();
2058 if (!page) 2058 if (!page)
2059 return nullptr; 2059 return nullptr;
2060 return &page->chromeClient(); 2060 return &page->chromeClient();
2061 } 2061 }
2062 2062
2063 ProgrammaticScrollCoordinator* FrameView::getProgrammaticScrollCoordinator()
2064 const {
2065 Page* page = frame().page();
2066 if (!page)
2067 return nullptr;
2068 return page->scrollingCoordinator()->programmaticScrollCoordinator();
2069 }
2070
2063 void FrameView::contentsResized() { 2071 void FrameView::contentsResized() {
2064 if (m_frame->isMainFrame() && m_frame->document()) { 2072 if (m_frame->isMainFrame() && m_frame->document()) {
2065 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer()) 2073 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer())
2066 textAutosizer->updatePageInfoInAllFrames(); 2074 textAutosizer->updatePageInfoInAllFrames();
2067 } 2075 }
2068 2076
2069 ScrollableArea::contentsResized(); 2077 ScrollableArea::contentsResized();
2070 setNeedsLayout(); 2078 setNeedsLayout();
2071 } 2079 }
2072 2080
(...skipping 2377 matching lines...) Expand 10 before | Expand all | Expand 10 after
4450 return false; 4458 return false;
4451 } 4459 }
4452 4460
4453 Widget* FrameView::getWidget() { 4461 Widget* FrameView::getWidget() {
4454 return this; 4462 return this;
4455 } 4463 }
4456 4464
4457 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, 4465 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent,
4458 const ScrollAlignment& alignX, 4466 const ScrollAlignment& alignX,
4459 const ScrollAlignment& alignY, 4467 const ScrollAlignment& alignY,
4460 ScrollType scrollType) { 4468 ScrollType scrollType,
4469 bool isSmooth) {
4461 LayoutRect viewRect(visibleContentRect()); 4470 LayoutRect viewRect(visibleContentRect());
4462 LayoutRect exposeRect = 4471 LayoutRect exposeRect =
4463 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY); 4472 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY);
4464 if (exposeRect != viewRect) { 4473 if (exposeRect != viewRect) {
4465 setScrollOffset( 4474 if (isSmooth) {
4466 ScrollOffset(exposeRect.x().toFloat(), exposeRect.y().toFloat()), 4475 DCHECK(scrollType != UserScroll);
4467 scrollType); 4476 getProgrammaticScrollCoordinator()->queueAnimation(
4477 this,
4478 ScrollOffset(exposeRect.x().toFloat(), exposeRect.y().toFloat()));
bokan 2017/03/28 16:29:53 Store the ScrollOffset in a variable above, outsid
sunyunjia 2017/04/07 13:53:20 Done.
4479 } else {
4480 setScrollOffset(
4481 ScrollOffset(exposeRect.x().toFloat(), exposeRect.y().toFloat()),
4482 scrollType);
4483 }
4468 } 4484 }
4469
4470 // Scrolling the FrameView cannot change the input rect's location relative to 4485 // Scrolling the FrameView cannot change the input rect's location relative to
4471 // the document. 4486 // the document.
4472 return rectInContent; 4487 return rectInContent;
4473 } 4488 }
4474 4489
4475 IntRect FrameView::scrollCornerRect() const { 4490 IntRect FrameView::scrollCornerRect() const {
4476 IntRect cornerRect; 4491 IntRect cornerRect;
4477 4492
4478 if (hasOverlayScrollbars()) 4493 if (hasOverlayScrollbars())
4479 return cornerRect; 4494 return cornerRect;
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
5185 void FrameView::setAnimationHost( 5200 void FrameView::setAnimationHost(
5186 std::unique_ptr<CompositorAnimationHost> host) { 5201 std::unique_ptr<CompositorAnimationHost> host) {
5187 m_animationHost = std::move(host); 5202 m_animationHost = std::move(host);
5188 } 5203 }
5189 5204
5190 LayoutUnit FrameView::caretWidth() const { 5205 LayoutUnit FrameView::caretWidth() const {
5191 return LayoutUnit(getHostWindow()->windowToViewportScalar(1)); 5206 return LayoutUnit(getHostWindow()->windowToViewportScalar(1));
5192 } 5207 }
5193 5208
5194 } // namespace blink 5209 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698