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

Side by Side Diff: third_party/WebKit/Source/core/layout/ScrollAlignment.cpp

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Revised according to the comments. We are still missing tests. Created 3 years, 10 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 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 namespace blink { 48 namespace blink {
49 49
50 const ScrollAlignment ScrollAlignment::alignCenterIfNeeded = { 50 const ScrollAlignment ScrollAlignment::alignCenterIfNeeded = {
51 ScrollAlignmentNoScroll, ScrollAlignmentCenter, ScrollAlignmentClosestEdge}; 51 ScrollAlignmentNoScroll, ScrollAlignmentCenter, ScrollAlignmentClosestEdge};
52 const ScrollAlignment ScrollAlignment::alignToEdgeIfNeeded = { 52 const ScrollAlignment ScrollAlignment::alignToEdgeIfNeeded = {
53 ScrollAlignmentNoScroll, ScrollAlignmentClosestEdge, 53 ScrollAlignmentNoScroll, ScrollAlignmentClosestEdge,
54 ScrollAlignmentClosestEdge}; 54 ScrollAlignmentClosestEdge};
55 const ScrollAlignment ScrollAlignment::alignCenterAlways = { 55 const ScrollAlignment ScrollAlignment::alignCenterAlways = {
56 ScrollAlignmentCenter, ScrollAlignmentCenter, ScrollAlignmentCenter}; 56 ScrollAlignmentCenter, ScrollAlignmentCenter, ScrollAlignmentCenter};
57 const ScrollAlignment ScrollAlignment::alignClosestEdgeAlways = {
58 ScrollAlignmentClosestEdge, ScrollAlignmentClosestEdge,
59 ScrollAlignmentClosestEdge};
57 const ScrollAlignment ScrollAlignment::alignTopAlways = { 60 const ScrollAlignment ScrollAlignment::alignTopAlways = {
58 ScrollAlignmentTop, ScrollAlignmentTop, ScrollAlignmentTop}; 61 ScrollAlignmentTop, ScrollAlignmentTop, ScrollAlignmentTop};
59 const ScrollAlignment ScrollAlignment::alignBottomAlways = { 62 const ScrollAlignment ScrollAlignment::alignBottomAlways = {
60 ScrollAlignmentBottom, ScrollAlignmentBottom, ScrollAlignmentBottom}; 63 ScrollAlignmentBottom, ScrollAlignmentBottom, ScrollAlignmentBottom};
64 const ScrollAlignment ScrollAlignment::alignLeftAlways = {
65 ScrollAlignmentLeft, ScrollAlignmentLeft, ScrollAlignmentLeft};
66 const ScrollAlignment ScrollAlignment::alignRightAlways = {
67 ScrollAlignmentRight, ScrollAlignmentRight, ScrollAlignmentRight};
61 68
62 #define MIN_INTERSECT_FOR_REVEAL 32 69 #define MIN_INTERSECT_FOR_REVEAL 32
63 70
64 LayoutRect ScrollAlignment::getRectToExpose(const LayoutRect& visibleRect, 71 LayoutRect ScrollAlignment::getRectToExpose(const LayoutRect& visibleRect,
65 const LayoutRect& exposeRect, 72 const LayoutRect& exposeRect,
66 const ScrollAlignment& alignX, 73 const ScrollAlignment& alignX,
67 const ScrollAlignment& alignY) { 74 const ScrollAlignment& alignY) {
68 // Prevent degenerate cases by giving the visible rect a minimum non-0 size. 75 // Prevent degenerate cases by giving the visible rect a minimum non-0 size.
69 LayoutRect nonZeroVisibleRect(visibleRect); 76 LayoutRect nonZeroVisibleRect(visibleRect);
70 LayoutUnit minimumLayoutUnit; 77 LayoutUnit minimumLayoutUnit;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 else if (scrollY == ScrollAlignmentCenter) 173 else if (scrollY == ScrollAlignmentCenter)
167 y = exposeRect.y() + 174 y = exposeRect.y() +
168 (exposeRect.height() - nonZeroVisibleRect.height()) / 2; 175 (exposeRect.height() - nonZeroVisibleRect.height()) / 2;
169 else 176 else
170 y = exposeRect.y(); 177 y = exposeRect.y();
171 178
172 return LayoutRect(LayoutPoint(x, y), nonZeroVisibleRect.size()); 179 return LayoutRect(LayoutPoint(x, y), nonZeroVisibleRect.size());
173 } 180 }
174 181
175 } // namespace blink 182 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698