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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
index 42bae0b72a85e2141f46a13709ba8223a6526927..5529d4b831590eb5623e2651513692373b0f3baf 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
@@ -86,6 +86,12 @@
namespace blink {
+static LayoutRect localToAbsolute(LayoutBox& offset, LayoutRect rect) {
+ return LayoutRect(
+ offset.localToAbsoluteQuad(FloatQuad(FloatRect(rect)), UseTransforms)
+ .boundingBox());
+}
+
PaintLayerScrollableAreaRareData::PaintLayerScrollableAreaRareData() {}
const int ResizerControlExpandRatioForTouch = 2;
@@ -1644,24 +1650,18 @@ LayoutRect PaintLayerScrollableArea::scrollIntoView(
ScrollOffset newScrollOffset(clampScrollOffset(roundedIntSize(
toScrollOffset(FloatPoint(r.location()) + oldScrollOffset))));
- if (newScrollOffset == oldScrollOffset) {
- return LayoutRect(
- box()
- .localToAbsoluteQuad(FloatQuad(FloatRect(intersection(
- layerBounds, localExposeRect))),
- UseTransforms)
- .boundingBox());
+ if (newScrollOffset != oldScrollOffset) {
bokan 2017/01/04 19:41:24 I think there's no reason to keep the `if`, it's s
+ setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant);
+ ScrollOffset scrollOffsetDifference = getScrollOffset() - oldScrollOffset;
+ localExposeRect.move(-LayoutSize(scrollOffsetDifference));
}
-
- setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant);
- ScrollOffset scrollOffsetDifference = getScrollOffset() - oldScrollOffset;
- localExposeRect.move(-LayoutSize(scrollOffsetDifference));
- return LayoutRect(
- box()
- .localToAbsoluteQuad(
- FloatQuad(FloatRect(intersection(layerBounds, localExposeRect))),
- UseTransforms)
- .boundingBox());
+ LayoutRect intersect =
+ localToAbsolute(box(), intersection(layerBounds, localExposeRect));
+ if (intersect.isEmpty() && !layerBounds.isEmpty() &&
+ !localExposeRect.isEmpty()) {
+ return localToAbsolute(box(), localExposeRect);
+ }
+ return intersect;
}
void PaintLayerScrollableArea::updateScrollableAreaSet(bool hasOverflow) {
« 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