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 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1145 | 1145 |
| 1146 int LocalDOMWindow::innerHeight() const | 1146 int LocalDOMWindow::innerHeight() const |
| 1147 { | 1147 { |
| 1148 if (!frame()) | 1148 if (!frame()) |
| 1149 return 0; | 1149 return 0; |
| 1150 | 1150 |
| 1151 FrameView* view = frame()->view(); | 1151 FrameView* view = frame()->view(); |
| 1152 if (!view) | 1152 if (!view) |
| 1153 return 0; | 1153 return 0; |
| 1154 | 1154 |
| 1155 FrameHost* host = frame()->host(); | |
| 1156 if (!host) | |
| 1157 return 0; | |
| 1158 | |
| 1155 // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer. | 1159 // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer. |
| 1156 if (Frame* parent = frame()->tree().parent()) { | 1160 if (Frame* parent = frame()->tree().parent()) { |
| 1157 if (parent && parent->isLocalFrame()) | 1161 if (parent && parent->isLocalFrame()) |
| 1158 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee ts(); | 1162 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee ts(); |
| 1159 } | 1163 } |
| 1160 | 1164 |
| 1161 return adjustForAbsoluteZoom(view->visibleContentRect(IncludeScrollbars).hei ght(), frame()->pageZoomFactor()); | 1165 FloatSize viewportSize = host->settings().pinchVirtualViewportEnabled() && f rame()->isMainFrame() |
| 1166 ? host->pinchViewport().visibleRect().size() | |
| 1167 : view->visibleContentRect(IncludeScrollbars).size(); | |
| 1168 | |
| 1169 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(), frame() ->pageZoomFactor()); | |
| 1162 } | 1170 } |
| 1163 | 1171 |
| 1164 int LocalDOMWindow::innerWidth() const | 1172 int LocalDOMWindow::innerWidth() const |
| 1165 { | 1173 { |
| 1166 if (!frame()) | 1174 if (!frame()) |
| 1167 return 0; | 1175 return 0; |
| 1168 | 1176 |
| 1169 FrameView* view = frame()->view(); | 1177 FrameView* view = frame()->view(); |
| 1170 if (!view) | 1178 if (!view) |
| 1171 return 0; | 1179 return 0; |
| 1172 | 1180 |
| 1181 FrameHost* host = frame()->host(); | |
| 1182 if (!host) | |
| 1183 return 0; | |
| 1184 | |
| 1173 // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer. | 1185 // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer. |
| 1174 if (Frame* parent = frame()->tree().parent()) { | 1186 if (Frame* parent = frame()->tree().parent()) { |
| 1175 if (parent && parent->isLocalFrame()) | 1187 if (parent && parent->isLocalFrame()) |
| 1176 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee ts(); | 1188 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee ts(); |
| 1177 } | 1189 } |
| 1178 | 1190 |
| 1179 return adjustForAbsoluteZoom(view->visibleContentRect(IncludeScrollbars).wid th(), frame()->pageZoomFactor()); | 1191 FloatSize viewportSize = host->settings().pinchVirtualViewportEnabled() && f rame()->isMainFrame() |
| 1192 ? host->pinchViewport().visibleRect().size() | |
| 1193 : view->visibleContentRect(IncludeScrollbars).size(); | |
| 1194 | |
| 1195 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).width(), frame()- >pageZoomFactor()); | |
| 1180 } | 1196 } |
| 1181 | 1197 |
| 1182 int LocalDOMWindow::screenX() const | 1198 int LocalDOMWindow::screenX() const |
| 1183 { | 1199 { |
| 1184 if (!frame()) | 1200 if (!frame()) |
| 1185 return 0; | 1201 return 0; |
| 1186 | 1202 |
| 1187 FrameHost* host = frame()->host(); | 1203 FrameHost* host = frame()->host(); |
| 1188 if (!host) | 1204 if (!host) |
| 1189 return 0; | 1205 return 0; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1209 | 1225 |
| 1210 double LocalDOMWindow::scrollX() const | 1226 double LocalDOMWindow::scrollX() const |
| 1211 { | 1227 { |
| 1212 if (!frame()) | 1228 if (!frame()) |
| 1213 return 0; | 1229 return 0; |
| 1214 | 1230 |
| 1215 FrameView* view = frame()->view(); | 1231 FrameView* view = frame()->view(); |
| 1216 if (!view) | 1232 if (!view) |
| 1217 return 0; | 1233 return 0; |
| 1218 | 1234 |
| 1235 FrameHost* host = frame()->host(); | |
| 1236 if (!host) | |
| 1237 return 0; | |
| 1238 | |
| 1219 frame()->document()->updateLayoutIgnorePendingStylesheets(); | 1239 frame()->document()->updateLayoutIgnorePendingStylesheets(); |
| 1220 | 1240 |
| 1221 return adjustScrollForAbsoluteZoom(view->scrollX(), frame()->pageZoomFactor( )); | 1241 double viewportX = view->scrollX(); |
| 1242 | |
| 1243 if (host->settings().pinchVirtualViewportEnabled() && frame()->isMainFrame() ) | |
| 1244 viewportX += host->pinchViewport().location().x(); | |
| 1245 | |
| 1246 return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor()); | |
| 1222 } | 1247 } |
| 1223 | 1248 |
| 1224 double LocalDOMWindow::scrollY() const | 1249 double LocalDOMWindow::scrollY() const |
| 1225 { | 1250 { |
| 1226 if (!frame()) | 1251 if (!frame()) |
| 1227 return 0; | 1252 return 0; |
| 1228 | 1253 |
| 1229 FrameView* view = frame()->view(); | 1254 FrameView* view = frame()->view(); |
| 1230 if (!view) | 1255 if (!view) |
| 1231 return 0; | 1256 return 0; |
| 1232 | 1257 |
| 1258 FrameHost* host = frame()->host(); | |
| 1259 if (!host) | |
| 1260 return 0; | |
| 1261 | |
| 1233 frame()->document()->updateLayoutIgnorePendingStylesheets(); | 1262 frame()->document()->updateLayoutIgnorePendingStylesheets(); |
| 1234 | 1263 |
| 1235 return adjustScrollForAbsoluteZoom(view->scrollY(), frame()->pageZoomFactor( )); | 1264 double viewportY = view->scrollY(); |
| 1265 | |
| 1266 if (host->settings().pinchVirtualViewportEnabled() && frame()->isMainFrame() ) | |
| 1267 viewportY += host->pinchViewport().location().y(); | |
| 1268 | |
| 1269 return adjustScrollForAbsoluteZoom(viewportY, frame()->pageZoomFactor()); | |
| 1236 } | 1270 } |
| 1237 | 1271 |
| 1238 bool LocalDOMWindow::closed() const | 1272 bool LocalDOMWindow::closed() const |
| 1239 { | 1273 { |
| 1240 return !frame() || !frame()->host(); | 1274 return !frame() || !frame()->host(); |
| 1241 } | 1275 } |
| 1242 | 1276 |
| 1243 unsigned LocalDOMWindow::length() const | 1277 unsigned LocalDOMWindow::length() const |
| 1244 { | 1278 { |
| 1245 if (!isCurrentlyDisplayedInFrame()) | 1279 if (!isCurrentlyDisplayedInFrame()) |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1390 return true; | 1424 return true; |
| 1391 } | 1425 } |
| 1392 | 1426 |
| 1393 if (ScrollableArea::scrollBehaviorFromString(scrollOptions.behavior(), scrol lBehavior)) | 1427 if (ScrollableArea::scrollBehaviorFromString(scrollOptions.behavior(), scrol lBehavior)) |
| 1394 return true; | 1428 return true; |
| 1395 | 1429 |
| 1396 exceptionState.throwTypeError("The ScrollBehavior provided is invalid."); | 1430 exceptionState.throwTypeError("The ScrollBehavior provided is invalid."); |
| 1397 return false; | 1431 return false; |
| 1398 } | 1432 } |
| 1399 | 1433 |
| 1434 static void scrollViewportTo(LocalFrame* frame, DoublePoint offset, ScrollBehavi or scrollBehavior) | |
| 1435 { | |
| 1436 FrameView* view = frame->view(); | |
| 1437 if (!view) | |
| 1438 return; | |
| 1439 | |
| 1440 FrameHost* host = frame->host(); | |
| 1441 if (!host) | |
| 1442 return; | |
| 1443 | |
| 1444 view->setScrollPosition(offset, scrollBehavior); | |
| 1445 | |
| 1446 if (host->settings().pinchVirtualViewportEnabled() && frame->isMainFrame()) { | |
| 1447 PinchViewport& pinchViewport = frame->host()->pinchViewport(); | |
| 1448 DoubleSize excessDelta = offset - DoublePoint(pinchViewport.visibleRectI nDocument().location()); | |
| 1449 pinchViewport.move(FloatPoint(excessDelta.width(), excessDelta.height()) ); | |
|
Rick Byers
2014/11/18 20:53:31
How does this interact with smooth scrolling? It
bokan
2014/11/18 23:21:50
This is a change, though is ScrollBehavior gone li
Rick Byers
2014/11/20 19:23:31
Oh right, it is. CSSOMSmoothScroll is still marke
| |
| 1450 } | |
| 1451 } | |
| 1452 | |
| 1400 void LocalDOMWindow::scrollBy(double x, double y, ScrollBehavior scrollBehavior) const | 1453 void LocalDOMWindow::scrollBy(double x, double y, ScrollBehavior scrollBehavior) const |
| 1401 { | 1454 { |
| 1402 if (!isCurrentlyDisplayedInFrame()) | 1455 if (!isCurrentlyDisplayedInFrame()) |
| 1403 return; | 1456 return; |
| 1404 | 1457 |
| 1405 document()->updateLayoutIgnorePendingStylesheets(); | 1458 document()->updateLayoutIgnorePendingStylesheets(); |
| 1406 | 1459 |
| 1407 FrameView* view = frame()->view(); | 1460 FrameView* view = frame()->view(); |
| 1408 if (!view) | 1461 if (!view) |
| 1409 return; | 1462 return; |
| 1410 | 1463 |
| 1464 FrameHost* host = frame()->host(); | |
| 1465 if (!host) | |
| 1466 return; | |
| 1467 | |
| 1411 if (std::isnan(x) || std::isnan(y)) | 1468 if (std::isnan(x) || std::isnan(y)) |
| 1412 return; | 1469 return; |
| 1413 | 1470 |
| 1471 DoublePoint currentOffset = host->settings().pinchVirtualViewportEnabled() & & frame()->isMainFrame() | |
| 1472 ? DoublePoint(host->pinchViewport().visibleRectInDocument().location()) | |
| 1473 : view->scrollPositionDouble(); | |
| 1474 | |
| 1414 DoubleSize scaledOffset(x * frame()->pageZoomFactor(), y * frame()->pageZoom Factor()); | 1475 DoubleSize scaledOffset(x * frame()->pageZoomFactor(), y * frame()->pageZoom Factor()); |
| 1415 view->scrollBy(scaledOffset, scrollBehavior); | 1476 scrollViewportTo(frame(), currentOffset + scaledOffset, scrollBehavior); |
|
Rick Byers
2014/11/18 20:53:31
There are a couple other places in the code that c
bokan
2014/11/18 23:21:50
Technically yes, but they're only used from Spacia
Rick Byers
2014/11/20 19:23:30
SGTM, thanks.
| |
| 1416 } | 1477 } |
| 1417 | 1478 |
| 1418 void LocalDOMWindow::scrollBy(double x, double y, const ScrollOptions& scrollOpt ions, ExceptionState &exceptionState) const | 1479 void LocalDOMWindow::scrollBy(double x, double y, const ScrollOptions& scrollOpt ions, ExceptionState &exceptionState) const |
| 1419 { | 1480 { |
| 1420 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; | 1481 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; |
| 1421 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio nState)) | 1482 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio nState)) |
| 1422 return; | 1483 return; |
| 1423 scrollBy(x, y, scrollBehavior); | 1484 scrollBy(x, y, scrollBehavior); |
| 1424 } | 1485 } |
| 1425 | 1486 |
| 1426 void LocalDOMWindow::scrollTo(double x, double y, ScrollBehavior scrollBehavior) const | 1487 void LocalDOMWindow::scrollTo(double x, double y, ScrollBehavior scrollBehavior) const |
| 1427 { | 1488 { |
| 1428 if (!isCurrentlyDisplayedInFrame()) | 1489 if (!isCurrentlyDisplayedInFrame()) |
| 1429 return; | 1490 return; |
| 1430 | 1491 |
| 1431 document()->updateLayoutIgnorePendingStylesheets(); | 1492 document()->updateLayoutIgnorePendingStylesheets(); |
| 1432 | 1493 |
| 1433 RefPtrWillBeRawPtr<FrameView> view = frame()->view(); | |
| 1434 if (!view) | |
| 1435 return; | |
| 1436 | |
| 1437 if (std::isnan(x) || std::isnan(y)) | 1494 if (std::isnan(x) || std::isnan(y)) |
| 1438 return; | 1495 return; |
| 1439 | 1496 |
| 1440 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa ctor()); | 1497 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa ctor()); |
| 1441 view->setScrollPosition(layoutPos, scrollBehavior); | 1498 scrollViewportTo(frame(), layoutPos, scrollBehavior); |
| 1442 } | 1499 } |
| 1443 | 1500 |
| 1444 void LocalDOMWindow::scrollTo(double x, double y, const ScrollOptions& scrollOpt ions, ExceptionState& exceptionState) const | 1501 void LocalDOMWindow::scrollTo(double x, double y, const ScrollOptions& scrollOpt ions, ExceptionState& exceptionState) const |
| 1445 { | 1502 { |
| 1446 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; | 1503 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; |
| 1447 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio nState)) | 1504 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio nState)) |
| 1448 return; | 1505 return; |
| 1449 scrollTo(x, y, scrollBehavior); | 1506 scrollTo(x, y, scrollBehavior); |
| 1450 } | 1507 } |
| 1451 | 1508 |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1959 return m_frameObserver->frame(); | 2016 return m_frameObserver->frame(); |
| 1960 } | 2017 } |
| 1961 | 2018 |
| 1962 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate) | 2019 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate) |
| 1963 { | 2020 { |
| 1964 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. | 2021 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. |
| 1965 return v8::Handle<v8::Object>(); | 2022 return v8::Handle<v8::Object>(); |
| 1966 } | 2023 } |
| 1967 | 2024 |
| 1968 } // namespace blink | 2025 } // namespace blink |
| OLD | NEW |