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 // FIXME: This class shouldn't be explicitly moving the viewport around. crbug.c
om/371896 |
| 1435 static void scrollViewportTo(LocalFrame* frame, DoublePoint offset, ScrollBehavi
or scrollBehavior) |
| 1436 { |
| 1437 FrameView* view = frame->view(); |
| 1438 if (!view) |
| 1439 return; |
| 1440 |
| 1441 FrameHost* host = frame->host(); |
| 1442 if (!host) |
| 1443 return; |
| 1444 |
| 1445 view->setScrollPosition(offset, scrollBehavior); |
| 1446 |
| 1447 if (host->settings().pinchVirtualViewportEnabled() && frame->isMainFrame())
{ |
| 1448 PinchViewport& pinchViewport = frame->host()->pinchViewport(); |
| 1449 DoubleSize excessDelta = offset - DoublePoint(pinchViewport.visibleRectI
nDocument().location()); |
| 1450 pinchViewport.move(FloatPoint(excessDelta.width(), excessDelta.height())
); |
| 1451 } |
| 1452 } |
| 1453 |
1400 void LocalDOMWindow::scrollBy(double x, double y, ScrollBehavior scrollBehavior)
const | 1454 void LocalDOMWindow::scrollBy(double x, double y, ScrollBehavior scrollBehavior)
const |
1401 { | 1455 { |
1402 if (!isCurrentlyDisplayedInFrame()) | 1456 if (!isCurrentlyDisplayedInFrame()) |
1403 return; | 1457 return; |
1404 | 1458 |
1405 document()->updateLayoutIgnorePendingStylesheets(); | 1459 document()->updateLayoutIgnorePendingStylesheets(); |
1406 | 1460 |
1407 FrameView* view = frame()->view(); | 1461 FrameView* view = frame()->view(); |
1408 if (!view) | 1462 if (!view) |
1409 return; | 1463 return; |
1410 | 1464 |
| 1465 FrameHost* host = frame()->host(); |
| 1466 if (!host) |
| 1467 return; |
| 1468 |
1411 if (std::isnan(x) || std::isnan(y)) | 1469 if (std::isnan(x) || std::isnan(y)) |
1412 return; | 1470 return; |
1413 | 1471 |
| 1472 DoublePoint currentOffset = host->settings().pinchVirtualViewportEnabled() &
& frame()->isMainFrame() |
| 1473 ? DoublePoint(host->pinchViewport().visibleRectInDocument().location()) |
| 1474 : view->scrollPositionDouble(); |
| 1475 |
1414 DoubleSize scaledOffset(x * frame()->pageZoomFactor(), y * frame()->pageZoom
Factor()); | 1476 DoubleSize scaledOffset(x * frame()->pageZoomFactor(), y * frame()->pageZoom
Factor()); |
1415 view->scrollBy(scaledOffset, scrollBehavior); | 1477 scrollViewportTo(frame(), currentOffset + scaledOffset, scrollBehavior); |
1416 } | 1478 } |
1417 | 1479 |
1418 void LocalDOMWindow::scrollBy(double x, double y, const ScrollOptions& scrollOpt
ions, ExceptionState &exceptionState) const | 1480 void LocalDOMWindow::scrollBy(double x, double y, const ScrollOptions& scrollOpt
ions, ExceptionState &exceptionState) const |
1419 { | 1481 { |
1420 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; | 1482 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; |
1421 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio
nState)) | 1483 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio
nState)) |
1422 return; | 1484 return; |
1423 scrollBy(x, y, scrollBehavior); | 1485 scrollBy(x, y, scrollBehavior); |
1424 } | 1486 } |
1425 | 1487 |
1426 void LocalDOMWindow::scrollTo(double x, double y, ScrollBehavior scrollBehavior)
const | 1488 void LocalDOMWindow::scrollTo(double x, double y, ScrollBehavior scrollBehavior)
const |
1427 { | 1489 { |
1428 if (!isCurrentlyDisplayedInFrame()) | 1490 if (!isCurrentlyDisplayedInFrame()) |
1429 return; | 1491 return; |
1430 | 1492 |
1431 document()->updateLayoutIgnorePendingStylesheets(); | 1493 document()->updateLayoutIgnorePendingStylesheets(); |
1432 | 1494 |
1433 RefPtrWillBeRawPtr<FrameView> view = frame()->view(); | |
1434 if (!view) | |
1435 return; | |
1436 | |
1437 if (std::isnan(x) || std::isnan(y)) | 1495 if (std::isnan(x) || std::isnan(y)) |
1438 return; | 1496 return; |
1439 | 1497 |
1440 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa
ctor()); | 1498 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa
ctor()); |
1441 view->setScrollPosition(layoutPos, scrollBehavior); | 1499 scrollViewportTo(frame(), layoutPos, scrollBehavior); |
1442 } | 1500 } |
1443 | 1501 |
1444 void LocalDOMWindow::scrollTo(double x, double y, const ScrollOptions& scrollOpt
ions, ExceptionState& exceptionState) const | 1502 void LocalDOMWindow::scrollTo(double x, double y, const ScrollOptions& scrollOpt
ions, ExceptionState& exceptionState) const |
1445 { | 1503 { |
1446 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; | 1504 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; |
1447 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio
nState)) | 1505 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio
nState)) |
1448 return; | 1506 return; |
1449 scrollTo(x, y, scrollBehavior); | 1507 scrollTo(x, y, scrollBehavior); |
1450 } | 1508 } |
1451 | 1509 |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1959 return m_frameObserver->frame(); | 2017 return m_frameObserver->frame(); |
1960 } | 2018 } |
1961 | 2019 |
1962 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte
xt, v8::Isolate* isolate) | 2020 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte
xt, v8::Isolate* isolate) |
1963 { | 2021 { |
1964 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. | 2022 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. |
1965 return v8::Handle<v8::Object>(); | 2023 return v8::Handle<v8::Object>(); |
1966 } | 2024 } |
1967 | 2025 |
1968 } // namespace blink | 2026 } // namespace blink |
OLD | NEW |