Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 visitor->trace(m_scrollAnchor); | 204 visitor->trace(m_scrollAnchor); |
| 205 ScrollableArea::trace(visitor); | 205 ScrollableArea::trace(visitor); |
| 206 } | 206 } |
| 207 | 207 |
| 208 HostWindow* PaintLayerScrollableArea::getHostWindow() const { | 208 HostWindow* PaintLayerScrollableArea::getHostWindow() const { |
| 209 if (Page* page = box().frame()->page()) | 209 if (Page* page = box().frame()->page()) |
| 210 return &page->chromeClient(); | 210 return &page->chromeClient(); |
| 211 return nullptr; | 211 return nullptr; |
| 212 } | 212 } |
| 213 | 213 |
| 214 ProgrammaticScrollCoordinator* | |
| 215 PaintLayerScrollableArea::getProgrammaticScrollCoordinator() const { | |
| 216 if (Page* page = box().frame()->page()) | |
| 217 return page->scrollingCoordinator()->programmaticScrollCoordinator(); | |
| 218 return nullptr; | |
| 219 } | |
| 220 | |
| 214 GraphicsLayer* PaintLayerScrollableArea::layerForScrolling() const { | 221 GraphicsLayer* PaintLayerScrollableArea::layerForScrolling() const { |
| 215 return layer()->hasCompositedLayerMapping() | 222 return layer()->hasCompositedLayerMapping() |
| 216 ? layer()->compositedLayerMapping()->scrollingContentsLayer() | 223 ? layer()->compositedLayerMapping()->scrollingContentsLayer() |
| 217 : 0; | 224 : 0; |
| 218 } | 225 } |
| 219 | 226 |
| 220 GraphicsLayer* PaintLayerScrollableArea::layerForHorizontalScrollbar() const { | 227 GraphicsLayer* PaintLayerScrollableArea::layerForHorizontalScrollbar() const { |
| 221 // See crbug.com/343132. | 228 // See crbug.com/343132. |
| 222 DisableCompositingQueryAsserts disabler; | 229 DisableCompositingQueryAsserts disabler; |
| 223 | 230 |
| (...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1623 document.updateStyleAndLayout(); | 1630 document.updateStyleAndLayout(); |
| 1624 | 1631 |
| 1625 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to | 1632 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to |
| 1626 // keep the point under the cursor in view. | 1633 // keep the point under the cursor in view. |
| 1627 } | 1634 } |
| 1628 | 1635 |
| 1629 LayoutRect PaintLayerScrollableArea::scrollIntoView( | 1636 LayoutRect PaintLayerScrollableArea::scrollIntoView( |
| 1630 const LayoutRect& rect, | 1637 const LayoutRect& rect, |
| 1631 const ScrollAlignment& alignX, | 1638 const ScrollAlignment& alignX, |
| 1632 const ScrollAlignment& alignY, | 1639 const ScrollAlignment& alignY, |
| 1633 ScrollType scrollType) { | 1640 ScrollType scrollType, |
| 1641 ScrollBehavior scrollBehavior) { | |
| 1634 LayoutRect localExposeRect( | 1642 LayoutRect localExposeRect( |
| 1635 box() | 1643 box() |
| 1636 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms) | 1644 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms) |
| 1637 .boundingBox()); | 1645 .boundingBox()); |
| 1638 localExposeRect.move(-box().borderLeft(), -box().borderTop()); | 1646 localExposeRect.move(-box().borderLeft(), -box().borderTop()); |
| 1639 LayoutRect layerBounds(LayoutPoint(), | 1647 LayoutRect layerBounds(LayoutPoint(), |
| 1640 LayoutSize(box().clientWidth(), box().clientHeight())); | 1648 LayoutSize(box().clientWidth(), box().clientHeight())); |
| 1641 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect, | 1649 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect, |
| 1642 alignX, alignY); | 1650 alignX, alignY); |
| 1643 | 1651 |
| 1644 ScrollOffset oldScrollOffset = getScrollOffset(); | 1652 ScrollOffset oldScrollOffset = getScrollOffset(); |
| 1645 ScrollOffset newScrollOffset(clampScrollOffset(roundedIntSize( | 1653 ScrollOffset newScrollOffset(clampScrollOffset(roundedIntSize( |
| 1646 toScrollOffset(FloatPoint(r.location()) + oldScrollOffset)))); | 1654 toScrollOffset(FloatPoint(r.location()) + oldScrollOffset)))); |
| 1647 setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant); | 1655 if (scrollType == ProgrammaticScroll && |
| 1656 scrollBehavior == ScrollBehaviorSmooth) { | |
| 1657 getProgrammaticScrollCoordinator()->queueAnimation(this, newScrollOffset); | |
|
bokan
2017/02/02 22:51:50
Hmm, maybe I'm missing something obvious here, but
sunyunjia
2017/02/10 23:25:20
Right! See here: https://docs.google.com/a/chromiu
bokan
2017/02/21 21:33:00
Got it. I think the name makes it sound like it's
| |
| 1658 } else { | |
| 1659 setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant); | |
| 1660 } | |
| 1648 ScrollOffset scrollOffsetDifference = getScrollOffset() - oldScrollOffset; | 1661 ScrollOffset scrollOffsetDifference = getScrollOffset() - oldScrollOffset; |
| 1649 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); | 1662 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); |
| 1650 | 1663 |
| 1651 LayoutRect intersect = | 1664 LayoutRect intersect = |
| 1652 localToAbsolute(box(), intersection(layerBounds, localExposeRect)); | 1665 localToAbsolute(box(), intersection(layerBounds, localExposeRect)); |
| 1653 if (intersect.isEmpty() && !layerBounds.isEmpty() && | 1666 if (intersect.isEmpty() && !layerBounds.isEmpty() && |
| 1654 !localExposeRect.isEmpty()) { | 1667 !localExposeRect.isEmpty()) { |
| 1655 return localToAbsolute(box(), localExposeRect); | 1668 return localToAbsolute(box(), localExposeRect); |
| 1656 } | 1669 } |
| 1657 return intersect; | 1670 return intersect; |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2117 | 2130 |
| 2118 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: | 2131 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: |
| 2119 clampScrollableAreas() { | 2132 clampScrollableAreas() { |
| 2120 for (auto& scrollableArea : *s_needsClamp) | 2133 for (auto& scrollableArea : *s_needsClamp) |
| 2121 scrollableArea->clampScrollOffsetAfterOverflowChange(); | 2134 scrollableArea->clampScrollOffsetAfterOverflowChange(); |
| 2122 delete s_needsClamp; | 2135 delete s_needsClamp; |
| 2123 s_needsClamp = nullptr; | 2136 s_needsClamp = nullptr; |
| 2124 } | 2137 } |
| 2125 | 2138 |
| 2126 } // namespace blink | 2139 } // namespace blink |
| OLD | NEW |