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

Side by Side Diff: Source/core/frame/LocalDOMWindow.cpp

Issue 1158673006: Replace various ScrollableArea scroll methods with setScrollPosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Build fix Created 5 years, 6 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 | « Source/core/frame/FrameView.cpp ('k') | Source/core/frame/LocalFrame.cpp » ('j') | 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, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 FrameView* view = frame()->view(); 1128 FrameView* view = frame()->view();
1129 if (!view) 1129 if (!view)
1130 return; 1130 return;
1131 1131
1132 x = ScrollableArea::normalizeNonFiniteScroll(x); 1132 x = ScrollableArea::normalizeNonFiniteScroll(x);
1133 y = ScrollableArea::normalizeNonFiniteScroll(y); 1133 y = ScrollableArea::normalizeNonFiniteScroll(y);
1134 1134
1135 DoublePoint currentOffset = view->scrollableArea()->scrollPositionDouble(); 1135 DoublePoint currentOffset = view->scrollableArea()->scrollPositionDouble();
1136 DoubleSize scaledDelta(x * frame()->pageZoomFactor(), y * frame()->pageZoomF actor()); 1136 DoubleSize scaledDelta(x * frame()->pageZoomFactor(), y * frame()->pageZoomF actor());
1137 1137
1138 view->scrollableArea()->setScrollPosition(currentOffset + scaledDelta, scrol lBehavior); 1138 view->scrollableArea()->setScrollPosition(currentOffset + scaledDelta, Progr ammaticScroll, scrollBehavior);
1139 } 1139 }
1140 1140
1141 void LocalDOMWindow::scrollBy(const ScrollToOptions& scrollToOptions) const 1141 void LocalDOMWindow::scrollBy(const ScrollToOptions& scrollToOptions) const
1142 { 1142 {
1143 double x = 0.0; 1143 double x = 0.0;
1144 double y = 0.0; 1144 double y = 0.0;
1145 if (scrollToOptions.hasLeft()) 1145 if (scrollToOptions.hasLeft())
1146 x = scrollToOptions.left(); 1146 x = scrollToOptions.left();
1147 if (scrollToOptions.hasTop()) 1147 if (scrollToOptions.hasTop())
1148 y = scrollToOptions.top(); 1148 y = scrollToOptions.top();
(...skipping 13 matching lines...) Expand all
1162 1162
1163 x = ScrollableArea::normalizeNonFiniteScroll(x); 1163 x = ScrollableArea::normalizeNonFiniteScroll(x);
1164 y = ScrollableArea::normalizeNonFiniteScroll(y); 1164 y = ScrollableArea::normalizeNonFiniteScroll(y);
1165 1165
1166 // It is only necessary to have an up-to-date layout if the position may be clamped, 1166 // It is only necessary to have an up-to-date layout if the position may be clamped,
1167 // which is never the case for (0, 0). 1167 // which is never the case for (0, 0).
1168 if (x || y) 1168 if (x || y)
1169 document()->updateLayoutIgnorePendingStylesheets(); 1169 document()->updateLayoutIgnorePendingStylesheets();
1170 1170
1171 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa ctor()); 1171 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa ctor());
1172 view->scrollableArea()->setScrollPosition(layoutPos, ScrollBehaviorAuto); 1172 view->scrollableArea()->setScrollPosition(layoutPos, ProgrammaticScroll, Scr ollBehaviorAuto);
1173 } 1173 }
1174 1174
1175 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const 1175 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const
1176 { 1176 {
1177 if (!isCurrentlyDisplayedInFrame()) 1177 if (!isCurrentlyDisplayedInFrame())
1178 return; 1178 return;
1179 1179
1180 FrameView* view = frame()->view(); 1180 FrameView* view = frame()->view();
1181 if (!view) 1181 if (!view)
1182 return; 1182 return;
(...skipping 15 matching lines...) Expand all
1198 scaledY = currentOffset.y(); 1198 scaledY = currentOffset.y();
1199 1199
1200 if (scrollToOptions.hasLeft()) 1200 if (scrollToOptions.hasLeft())
1201 scaledX = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.left( )) * frame()->pageZoomFactor(); 1201 scaledX = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.left( )) * frame()->pageZoomFactor();
1202 1202
1203 if (scrollToOptions.hasTop()) 1203 if (scrollToOptions.hasTop())
1204 scaledY = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.top() ) * frame()->pageZoomFactor(); 1204 scaledY = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.top() ) * frame()->pageZoomFactor();
1205 1205
1206 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; 1206 ScrollBehavior scrollBehavior = ScrollBehaviorAuto;
1207 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB ehavior); 1207 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB ehavior);
1208 view->scrollableArea()->setScrollPosition(DoublePoint(scaledX, scaledY), scr ollBehavior); 1208 view->scrollableArea()->setScrollPosition(DoublePoint(scaledX, scaledY), Pro grammaticScroll, scrollBehavior);
1209 } 1209 }
1210 1210
1211 void LocalDOMWindow::moveBy(int x, int y, bool hasX, bool hasY) const 1211 void LocalDOMWindow::moveBy(int x, int y, bool hasX, bool hasY) const
1212 { 1212 {
1213 if (!hasX || !hasY) 1213 if (!hasX || !hasY)
1214 UseCounter::count(document(), UseCounter::WindowMoveResizeMissingArgumen ts); 1214 UseCounter::count(document(), UseCounter::WindowMoveResizeMissingArgumen ts);
1215 1215
1216 if (!frame() || !frame()->isMainFrame()) 1216 if (!frame() || !frame()->isMainFrame())
1217 return; 1217 return;
1218 1218
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 DOMWindow::trace(visitor); 1513 DOMWindow::trace(visitor);
1514 DOMWindowLifecycleNotifier::trace(visitor); 1514 DOMWindowLifecycleNotifier::trace(visitor);
1515 } 1515 }
1516 1516
1517 LocalFrame* LocalDOMWindow::frame() const 1517 LocalFrame* LocalDOMWindow::frame() const
1518 { 1518 {
1519 return m_frameObserver->frame(); 1519 return m_frameObserver->frame();
1520 } 1520 }
1521 1521
1522 } // namespace blink 1522 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.cpp ('k') | Source/core/frame/LocalFrame.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698