Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1203 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; | 1203 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; |
| 1204 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB ehavior); | 1204 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB ehavior); |
| 1205 scrollBy(x, y, scrollBehavior); | 1205 scrollBy(x, y, scrollBehavior); |
| 1206 } | 1206 } |
| 1207 | 1207 |
| 1208 void LocalDOMWindow::scrollTo(double x, double y) const | 1208 void LocalDOMWindow::scrollTo(double x, double y) const |
| 1209 { | 1209 { |
| 1210 if (!isCurrentlyDisplayedInFrame()) | 1210 if (!isCurrentlyDisplayedInFrame()) |
| 1211 return; | 1211 return; |
| 1212 | 1212 |
| 1213 document()->updateLayoutIgnorePendingStylesheets(); | 1213 if (x || y) |
|
Rick Byers
2015/04/09 17:46:11
can you add a brief comment saying why? I.e. 'For
rune
2015/04/09 21:45:05
Done.
| |
| 1214 document()->updateLayoutIgnorePendingStylesheets(); | |
| 1214 | 1215 |
| 1215 if (std::isnan(x) || std::isnan(y)) | 1216 if (std::isnan(x) || std::isnan(y)) |
| 1216 return; | 1217 return; |
| 1217 | 1218 |
| 1218 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa ctor()); | 1219 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa ctor()); |
| 1219 scrollViewportTo(frame(), layoutPos, ScrollBehaviorAuto); | 1220 scrollViewportTo(frame(), layoutPos, ScrollBehaviorAuto); |
| 1220 } | 1221 } |
| 1221 | 1222 |
| 1222 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const | 1223 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const |
| 1223 { | 1224 { |
| 1224 if (!isCurrentlyDisplayedInFrame()) | 1225 if (!isCurrentlyDisplayedInFrame()) |
| 1225 return; | 1226 return; |
| 1226 | 1227 |
| 1227 document()->updateLayoutIgnorePendingStylesheets(); | |
| 1228 | |
| 1229 FrameView* view = frame()->view(); | 1228 FrameView* view = frame()->view(); |
| 1230 if (!view) | 1229 if (!view) |
| 1231 return; | 1230 return; |
| 1232 | 1231 |
| 1233 FrameHost* host = frame()->host(); | 1232 FrameHost* host = frame()->host(); |
| 1234 if (!host) | 1233 if (!host) |
| 1235 return; | 1234 return; |
| 1236 | 1235 |
| 1236 if (!scrollToOptions.hasLeft() | |
| 1237 || !scrollToOptions.hasTop() | |
| 1238 || scrollToOptions.left() | |
| 1239 || scrollToOptions.top()) { | |
| 1240 document()->updateLayoutIgnorePendingStylesheets(); | |
| 1241 } | |
| 1242 | |
| 1237 double scaledX = 0.0; | 1243 double scaledX = 0.0; |
| 1238 double scaledY = 0.0; | 1244 double scaledY = 0.0; |
| 1239 | 1245 |
| 1240 DoublePoint currentOffset = frame()->isMainFrame() | 1246 DoublePoint currentOffset = frame()->isMainFrame() |
| 1241 ? DoublePoint(host->pinchViewport().visibleRectInDocument().location()) | 1247 ? DoublePoint(host->pinchViewport().visibleRectInDocument().location()) |
| 1242 : view->scrollableArea()->scrollPositionDouble(); | 1248 : view->scrollableArea()->scrollPositionDouble(); |
| 1243 scaledX = currentOffset.x(); | 1249 scaledX = currentOffset.x(); |
| 1244 scaledY = currentOffset.y(); | 1250 scaledY = currentOffset.y(); |
| 1245 | 1251 |
| 1246 if (scrollToOptions.hasLeft()) { | 1252 if (scrollToOptions.hasLeft()) { |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1651 return m_frameObserver->frame(); | 1657 return m_frameObserver->frame(); |
| 1652 } | 1658 } |
| 1653 | 1659 |
| 1654 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate) | 1660 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate) |
| 1655 { | 1661 { |
| 1656 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. | 1662 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. |
| 1657 return v8::Handle<v8::Object>(); | 1663 return v8::Handle<v8::Object>(); |
| 1658 } | 1664 } |
| 1659 | 1665 |
| 1660 } // namespace blink | 1666 } // namespace blink |
| OLD | NEW |