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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.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) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu> 9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@gmail.com> 10 * Christian Biesinger <cbiesinger@gmail.com>
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 visitor->trace(m_scrollAnchor); 203 visitor->trace(m_scrollAnchor);
204 ScrollableArea::trace(visitor); 204 ScrollableArea::trace(visitor);
205 } 205 }
206 206
207 HostWindow* PaintLayerScrollableArea::getHostWindow() const { 207 HostWindow* PaintLayerScrollableArea::getHostWindow() const {
208 if (Page* page = box().frame()->page()) 208 if (Page* page = box().frame()->page())
209 return &page->chromeClient(); 209 return &page->chromeClient();
210 return nullptr; 210 return nullptr;
211 } 211 }
212 212
213 ProgrammaticScrollCoordinator*
214 PaintLayerScrollableArea::getProgrammaticScrollCoordinator() const {
215 if (Page* page = box().frame()->page())
216 return page->scrollingCoordinator()->programmaticScrollCoordinator();
217 return nullptr;
218 }
219
213 GraphicsLayer* PaintLayerScrollableArea::layerForScrolling() const { 220 GraphicsLayer* PaintLayerScrollableArea::layerForScrolling() const {
214 return layer()->hasCompositedLayerMapping() 221 return layer()->hasCompositedLayerMapping()
215 ? layer()->compositedLayerMapping()->scrollingContentsLayer() 222 ? layer()->compositedLayerMapping()->scrollingContentsLayer()
216 : 0; 223 : 0;
217 } 224 }
218 225
219 GraphicsLayer* PaintLayerScrollableArea::layerForHorizontalScrollbar() const { 226 GraphicsLayer* PaintLayerScrollableArea::layerForHorizontalScrollbar() const {
220 // See crbug.com/343132. 227 // See crbug.com/343132.
221 DisableCompositingQueryAsserts disabler; 228 DisableCompositingQueryAsserts disabler;
222 229
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 document.updateStyleAndLayout(); 1634 document.updateStyleAndLayout();
1628 1635
1629 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to 1636 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to
1630 // keep the point under the cursor in view. 1637 // keep the point under the cursor in view.
1631 } 1638 }
1632 1639
1633 LayoutRect PaintLayerScrollableArea::scrollIntoView( 1640 LayoutRect PaintLayerScrollableArea::scrollIntoView(
1634 const LayoutRect& rect, 1641 const LayoutRect& rect,
1635 const ScrollAlignment& alignX, 1642 const ScrollAlignment& alignX,
1636 const ScrollAlignment& alignY, 1643 const ScrollAlignment& alignY,
1637 ScrollType scrollType) { 1644 ScrollType scrollType,
1645 bool isSmooth) {
1638 LayoutRect localExposeRect( 1646 LayoutRect localExposeRect(
1639 box() 1647 box()
1640 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms) 1648 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms)
1641 .boundingBox()); 1649 .boundingBox());
1642 localExposeRect.move(-box().borderLeft(), -box().borderTop()); 1650 localExposeRect.move(-box().borderLeft(), -box().borderTop());
1643 LayoutRect layerBounds(LayoutPoint(), 1651 LayoutRect layerBounds(LayoutPoint(),
1644 LayoutSize(box().clientWidth(), box().clientHeight())); 1652 LayoutSize(box().clientWidth(), box().clientHeight()));
1645 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect, 1653 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect,
1646 alignX, alignY); 1654 alignX, alignY);
1647 1655
1648 ScrollOffset oldScrollOffset = getScrollOffset(); 1656 ScrollOffset oldScrollOffset = getScrollOffset();
1649 ScrollOffset newScrollOffset(clampScrollOffset(roundedIntSize( 1657 ScrollOffset newScrollOffset(clampScrollOffset(roundedIntSize(
1650 toScrollOffset(FloatPoint(r.location()) + oldScrollOffset)))); 1658 toScrollOffset(FloatPoint(r.location()) + oldScrollOffset))));
1651 setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant); 1659 if (isSmooth) {
1660 DCHECK(scrollType != UserScroll);
1661 getProgrammaticScrollCoordinator()->queueAnimation(this, newScrollOffset);
1662 } else {
1663 setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant);
1664 }
1652 ScrollOffset scrollOffsetDifference = getScrollOffset() - oldScrollOffset; 1665 ScrollOffset scrollOffsetDifference = getScrollOffset() - oldScrollOffset;
1653 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); 1666 localExposeRect.move(-LayoutSize(scrollOffsetDifference));
1654 1667
1655 LayoutRect intersect = 1668 LayoutRect intersect =
1656 localToAbsolute(box(), intersection(layerBounds, localExposeRect)); 1669 localToAbsolute(box(), intersection(layerBounds, localExposeRect));
1657 if (intersect.isEmpty() && !layerBounds.isEmpty() && 1670 if (intersect.isEmpty() && !layerBounds.isEmpty() &&
1658 !localExposeRect.isEmpty()) { 1671 !localExposeRect.isEmpty()) {
1659 return localToAbsolute(box(), localExposeRect); 1672 return localToAbsolute(box(), localExposeRect);
1660 } 1673 }
1661 return intersect; 1674 return intersect;
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 2127
2115 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: 2128 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
2116 clampScrollableAreas() { 2129 clampScrollableAreas() {
2117 for (auto& scrollableArea : *s_needsClamp) 2130 for (auto& scrollableArea : *s_needsClamp)
2118 scrollableArea->clampScrollOffsetAfterOverflowChange(); 2131 scrollableArea->clampScrollOffsetAfterOverflowChange();
2119 delete s_needsClamp; 2132 delete s_needsClamp;
2120 s_needsClamp = nullptr; 2133 s_needsClamp = nullptr;
2121 } 2134 }
2122 2135
2123 } // namespace blink 2136 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698