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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp

Issue 2576963002: Scroll the position into view when the content is not visible. (Closed)
Patch Set: Merge the duplicate blocks. Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/scrolling/scroll-into-view-hidden-element.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 #include "platform/PlatformMouseEvent.h" 79 #include "platform/PlatformMouseEvent.h"
80 #include "platform/graphics/CompositorMutableProperties.h" 80 #include "platform/graphics/CompositorMutableProperties.h"
81 #include "platform/graphics/GraphicsLayer.h" 81 #include "platform/graphics/GraphicsLayer.h"
82 #include "platform/graphics/paint/DrawingRecorder.h" 82 #include "platform/graphics/paint/DrawingRecorder.h"
83 #include "platform/scroll/ScrollAnimatorBase.h" 83 #include "platform/scroll/ScrollAnimatorBase.h"
84 #include "platform/scroll/ScrollbarTheme.h" 84 #include "platform/scroll/ScrollbarTheme.h"
85 #include "public/platform/Platform.h" 85 #include "public/platform/Platform.h"
86 86
87 namespace blink { 87 namespace blink {
88 88
89 static LayoutRect localToAbsolute(LayoutBox& offset, LayoutRect rect) {
90 return LayoutRect(
91 offset.localToAbsoluteQuad(FloatQuad(FloatRect(rect)), UseTransforms)
92 .boundingBox());
93 }
94
89 PaintLayerScrollableAreaRareData::PaintLayerScrollableAreaRareData() {} 95 PaintLayerScrollableAreaRareData::PaintLayerScrollableAreaRareData() {}
90 96
91 const int ResizerControlExpandRatioForTouch = 2; 97 const int ResizerControlExpandRatioForTouch = 2;
92 98
93 PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer) 99 PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer)
94 : m_layer(layer), 100 : m_layer(layer),
95 m_nextTopmostScrollChild(0), 101 m_nextTopmostScrollChild(0),
96 m_topmostScrollChild(0), 102 m_topmostScrollChild(0),
97 m_inResizeMode(false), 103 m_inResizeMode(false),
98 m_scrollsOverflow(false), 104 m_scrollsOverflow(false),
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 localExposeRect.move(-box().borderLeft(), -box().borderTop()); 1643 localExposeRect.move(-box().borderLeft(), -box().borderTop());
1638 LayoutRect layerBounds(LayoutPoint(), 1644 LayoutRect layerBounds(LayoutPoint(),
1639 LayoutSize(box().clientWidth(), box().clientHeight())); 1645 LayoutSize(box().clientWidth(), box().clientHeight()));
1640 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect, 1646 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect,
1641 alignX, alignY); 1647 alignX, alignY);
1642 1648
1643 ScrollOffset oldScrollOffset = getScrollOffset(); 1649 ScrollOffset oldScrollOffset = getScrollOffset();
1644 ScrollOffset newScrollOffset(clampScrollOffset(roundedIntSize( 1650 ScrollOffset newScrollOffset(clampScrollOffset(roundedIntSize(
1645 toScrollOffset(FloatPoint(r.location()) + oldScrollOffset)))); 1651 toScrollOffset(FloatPoint(r.location()) + oldScrollOffset))));
1646 1652
1647 if (newScrollOffset == oldScrollOffset) { 1653 if (newScrollOffset != oldScrollOffset) {
bokan 2017/01/04 19:41:24 I think there's no reason to keep the `if`, it's s
1648 return LayoutRect( 1654 setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant);
1649 box() 1655 ScrollOffset scrollOffsetDifference = getScrollOffset() - oldScrollOffset;
1650 .localToAbsoluteQuad(FloatQuad(FloatRect(intersection( 1656 localExposeRect.move(-LayoutSize(scrollOffsetDifference));
1651 layerBounds, localExposeRect))),
1652 UseTransforms)
1653 .boundingBox());
1654 } 1657 }
1655 1658 LayoutRect intersect =
1656 setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant); 1659 localToAbsolute(box(), intersection(layerBounds, localExposeRect));
1657 ScrollOffset scrollOffsetDifference = getScrollOffset() - oldScrollOffset; 1660 if (intersect.isEmpty() && !layerBounds.isEmpty() &&
1658 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); 1661 !localExposeRect.isEmpty()) {
1659 return LayoutRect( 1662 return localToAbsolute(box(), localExposeRect);
1660 box() 1663 }
1661 .localToAbsoluteQuad( 1664 return intersect;
1662 FloatQuad(FloatRect(intersection(layerBounds, localExposeRect))),
1663 UseTransforms)
1664 .boundingBox());
1665 } 1665 }
1666 1666
1667 void PaintLayerScrollableArea::updateScrollableAreaSet(bool hasOverflow) { 1667 void PaintLayerScrollableArea::updateScrollableAreaSet(bool hasOverflow) {
1668 LocalFrame* frame = box().frame(); 1668 LocalFrame* frame = box().frame();
1669 if (!frame) 1669 if (!frame)
1670 return; 1670 return;
1671 1671
1672 FrameView* frameView = frame->view(); 1672 FrameView* frameView = frame->view();
1673 if (!frameView) 1673 if (!frameView)
1674 return; 1674 return;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 2034
2035 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: 2035 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
2036 clampScrollableAreas() { 2036 clampScrollableAreas() {
2037 for (auto& scrollableArea : *s_needsClamp) 2037 for (auto& scrollableArea : *s_needsClamp)
2038 scrollableArea->clampScrollOffsetAfterOverflowChange(); 2038 scrollableArea->clampScrollOffsetAfterOverflowChange();
2039 delete s_needsClamp; 2039 delete s_needsClamp;
2040 s_needsClamp = nullptr; 2040 s_needsClamp = nullptr;
2041 } 2041 }
2042 2042
2043 } // namespace blink 2043 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/scrolling/scroll-into-view-hidden-element.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698