| 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(); | |
| 1214 | |
| 1215 if (std::isnan(x) || std::isnan(y)) | 1213 if (std::isnan(x) || std::isnan(y)) |
| 1216 return; | 1214 return; |
| 1217 | 1215 |
| 1216 // It is only necessary to have an up-to-date layout if the position may be
clamped, |
| 1217 // which is never the case for (0, 0). |
| 1218 if (x || y) |
| 1219 document()->updateLayoutIgnorePendingStylesheets(); |
| 1220 |
| 1218 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa
ctor()); | 1221 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa
ctor()); |
| 1219 scrollViewportTo(frame(), layoutPos, ScrollBehaviorAuto); | 1222 scrollViewportTo(frame(), layoutPos, ScrollBehaviorAuto); |
| 1220 } | 1223 } |
| 1221 | 1224 |
| 1222 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const | 1225 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const |
| 1223 { | 1226 { |
| 1224 if (!isCurrentlyDisplayedInFrame()) | 1227 if (!isCurrentlyDisplayedInFrame()) |
| 1225 return; | 1228 return; |
| 1226 | 1229 |
| 1227 document()->updateLayoutIgnorePendingStylesheets(); | |
| 1228 | |
| 1229 FrameView* view = frame()->view(); | 1230 FrameView* view = frame()->view(); |
| 1230 if (!view) | 1231 if (!view) |
| 1231 return; | 1232 return; |
| 1232 | 1233 |
| 1233 FrameHost* host = frame()->host(); | 1234 FrameHost* host = frame()->host(); |
| 1234 if (!host) | 1235 if (!host) |
| 1235 return; | 1236 return; |
| 1236 | 1237 |
| 1238 // It is only necessary to have an up-to-date layout if the position may be
clamped, |
| 1239 // which is never the case for (0, 0). |
| 1240 if (!scrollToOptions.hasLeft() |
| 1241 || !scrollToOptions.hasTop() |
| 1242 || scrollToOptions.left() |
| 1243 || scrollToOptions.top()) { |
| 1244 document()->updateLayoutIgnorePendingStylesheets(); |
| 1245 } |
| 1246 |
| 1237 double scaledX = 0.0; | 1247 double scaledX = 0.0; |
| 1238 double scaledY = 0.0; | 1248 double scaledY = 0.0; |
| 1239 | 1249 |
| 1240 DoublePoint currentOffset = frame()->isMainFrame() | 1250 DoublePoint currentOffset = frame()->isMainFrame() |
| 1241 ? DoublePoint(host->pinchViewport().visibleRectInDocument().location()) | 1251 ? DoublePoint(host->pinchViewport().visibleRectInDocument().location()) |
| 1242 : view->scrollableArea()->scrollPositionDouble(); | 1252 : view->scrollableArea()->scrollPositionDouble(); |
| 1243 scaledX = currentOffset.x(); | 1253 scaledX = currentOffset.x(); |
| 1244 scaledY = currentOffset.y(); | 1254 scaledY = currentOffset.y(); |
| 1245 | 1255 |
| 1246 if (scrollToOptions.hasLeft()) { | 1256 if (scrollToOptions.hasLeft()) { |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1651 return m_frameObserver->frame(); | 1661 return m_frameObserver->frame(); |
| 1652 } | 1662 } |
| 1653 | 1663 |
| 1654 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte
xt, v8::Isolate* isolate) | 1664 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte
xt, v8::Isolate* isolate) |
| 1655 { | 1665 { |
| 1656 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. | 1666 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. |
| 1657 return v8::Handle<v8::Object>(); | 1667 return v8::Handle<v8::Object>(); |
| 1658 } | 1668 } |
| 1659 | 1669 |
| 1660 } // namespace blink | 1670 } // namespace blink |
| OLD | NEW |