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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Rebase Created 3 years, 8 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 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 } 2095 }
2096 } 2096 }
2097 2097
2098 HostWindow* FrameView::getHostWindow() const { 2098 HostWindow* FrameView::getHostWindow() const {
2099 Page* page = frame().page(); 2099 Page* page = frame().page();
2100 if (!page) 2100 if (!page)
2101 return nullptr; 2101 return nullptr;
2102 return &page->chromeClient(); 2102 return &page->chromeClient();
2103 } 2103 }
2104 2104
2105 SmoothScrollSequencer* FrameView::getSmoothScrollSequencer() const {
2106 Page* page = frame().page();
2107 if (!page)
2108 return nullptr;
2109 return page->smoothScrollSequencer();
2110 }
2111
2105 void FrameView::contentsResized() { 2112 void FrameView::contentsResized() {
2106 if (m_frame->isMainFrame() && m_frame->document()) { 2113 if (m_frame->isMainFrame() && m_frame->document()) {
2107 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer()) 2114 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer())
2108 textAutosizer->updatePageInfoInAllFrames(); 2115 textAutosizer->updatePageInfoInAllFrames();
2109 } 2116 }
2110 2117
2111 ScrollableArea::contentsResized(); 2118 ScrollableArea::contentsResized();
2112 setNeedsLayout(); 2119 setNeedsLayout();
2113 } 2120 }
2114 2121
(...skipping 2374 matching lines...) Expand 10 before | Expand all | Expand 10 after
4489 return false; 4496 return false;
4490 } 4497 }
4491 4498
4492 FrameViewBase* FrameView::getFrameViewBase() { 4499 FrameViewBase* FrameView::getFrameViewBase() {
4493 return this; 4500 return this;
4494 } 4501 }
4495 4502
4496 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, 4503 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent,
4497 const ScrollAlignment& alignX, 4504 const ScrollAlignment& alignX,
4498 const ScrollAlignment& alignY, 4505 const ScrollAlignment& alignY,
4499 ScrollType scrollType) { 4506 ScrollType scrollType,
4507 bool isSmooth) {
4500 LayoutRect viewRect(visibleContentRect()); 4508 LayoutRect viewRect(visibleContentRect());
4501 LayoutRect exposeRect = 4509 LayoutRect exposeRect =
4502 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY); 4510 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY);
4503 if (exposeRect != viewRect) { 4511 if (exposeRect != viewRect) {
4504 setScrollOffset( 4512 ScrollOffset targetOffset(exposeRect.x().toFloat(),
4505 ScrollOffset(exposeRect.x().toFloat(), exposeRect.y().toFloat()), 4513 exposeRect.y().toFloat());
4506 scrollType); 4514 if (isSmooth) {
4515 DCHECK(scrollType != UserScroll);
4516 getSmoothScrollSequencer()->queueAnimation(this, targetOffset);
4517 } else {
4518 setScrollOffset(targetOffset, scrollType);
4519 }
4507 } 4520 }
4508
bokan 2017/04/07 15:56:52 Nit: the blank line was fine
sunyunjia 2017/05/12 18:40:25 Done.
4509 // Scrolling the FrameView cannot change the input rect's location relative to 4521 // Scrolling the FrameView cannot change the input rect's location relative to
4510 // the document. 4522 // the document.
4511 return rectInContent; 4523 return rectInContent;
4512 } 4524 }
4513 4525
4514 IntRect FrameView::scrollCornerRect() const { 4526 IntRect FrameView::scrollCornerRect() const {
4515 IntRect cornerRect; 4527 IntRect cornerRect;
4516 4528
4517 if (hasOverlayScrollbars()) 4529 if (hasOverlayScrollbars())
4518 return cornerRect; 4530 return cornerRect;
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
5267 void FrameView::setAnimationHost( 5279 void FrameView::setAnimationHost(
5268 std::unique_ptr<CompositorAnimationHost> host) { 5280 std::unique_ptr<CompositorAnimationHost> host) {
5269 m_animationHost = std::move(host); 5281 m_animationHost = std::move(host);
5270 } 5282 }
5271 5283
5272 LayoutUnit FrameView::caretWidth() const { 5284 LayoutUnit FrameView::caretWidth() const {
5273 return LayoutUnit(getHostWindow()->windowToViewportScalar(1)); 5285 return LayoutUnit(getHostWindow()->windowToViewportScalar(1));
5274 } 5286 }
5275 5287
5276 } // namespace blink 5288 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698