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 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 } | 1378 } |
1379 | 1379 |
1380 double DOMWindow::devicePixelRatio() const | 1380 double DOMWindow::devicePixelRatio() const |
1381 { | 1381 { |
1382 if (!m_frame) | 1382 if (!m_frame) |
1383 return 0.0; | 1383 return 0.0; |
1384 | 1384 |
1385 return m_frame->devicePixelRatio(); | 1385 return m_frame->devicePixelRatio(); |
1386 } | 1386 } |
1387 | 1387 |
1388 void DOMWindow::scrollBy(int x, int y) const | 1388 static bool scrollBehaviorFromScrollOptions(const Dictionary& scrollOptions, Scr
ollBehavior& scrollBehavior, ExceptionState& exceptionState) |
1389 { | 1389 { |
| 1390 String scrollBehaviorString; |
| 1391 if (!scrollOptions.get("behavior", scrollBehaviorString)) { |
| 1392 scrollBehavior = ScrollBehaviorAuto; |
| 1393 return true; |
| 1394 } |
| 1395 |
| 1396 if (ScrollableArea::scrollBehaviorFromString(scrollBehaviorString, scrollBeh
avior)) |
| 1397 return true; |
| 1398 |
| 1399 exceptionState.throwTypeError("The ScrollBehavior provided is invalid."); |
| 1400 return false; |
| 1401 } |
| 1402 |
| 1403 void DOMWindow::scrollBy(int x, int y, const Dictionary& scrollOptions, Exceptio
nState &exceptionState) const |
| 1404 { |
| 1405 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; |
| 1406 if (RuntimeEnabledFeatures::cssomSmoothScrollEnabled() && !scrollBehaviorFro
mScrollOptions(scrollOptions, scrollBehavior, exceptionState)) |
| 1407 return; |
| 1408 |
1390 if (!isCurrentlyDisplayedInFrame()) | 1409 if (!isCurrentlyDisplayedInFrame()) |
1391 return; | 1410 return; |
1392 | 1411 |
1393 document()->updateLayoutIgnorePendingStylesheets(); | 1412 document()->updateLayoutIgnorePendingStylesheets(); |
1394 | 1413 |
1395 FrameView* view = m_frame->view(); | 1414 FrameView* view = m_frame->view(); |
1396 if (!view) | 1415 if (!view) |
1397 return; | 1416 return; |
1398 | 1417 |
1399 | |
1400 IntSize scaledOffset(x * m_frame->pageZoomFactor(), y * m_frame->pageZoomFac
tor()); | 1418 IntSize scaledOffset(x * m_frame->pageZoomFactor(), y * m_frame->pageZoomFac
tor()); |
| 1419 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant
ly. |
1401 view->scrollBy(scaledOffset); | 1420 view->scrollBy(scaledOffset); |
1402 } | 1421 } |
1403 | 1422 |
1404 void DOMWindow::scrollTo(int x, int y) const | 1423 void DOMWindow::scrollTo(int x, int y, const Dictionary& scrollOptions, Exceptio
nState& exceptionState) const |
1405 { | 1424 { |
| 1425 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; |
| 1426 if (RuntimeEnabledFeatures::cssomSmoothScrollEnabled() && !scrollBehaviorFro
mScrollOptions(scrollOptions, scrollBehavior, exceptionState)) |
| 1427 return; |
| 1428 |
1406 if (!isCurrentlyDisplayedInFrame()) | 1429 if (!isCurrentlyDisplayedInFrame()) |
1407 return; | 1430 return; |
1408 | 1431 |
1409 document()->updateLayoutIgnorePendingStylesheets(); | 1432 document()->updateLayoutIgnorePendingStylesheets(); |
1410 | 1433 |
1411 RefPtr<FrameView> view = m_frame->view(); | 1434 RefPtr<FrameView> view = m_frame->view(); |
1412 if (!view) | 1435 if (!view) |
1413 return; | 1436 return; |
1414 | 1437 |
1415 IntPoint layoutPos(x * m_frame->pageZoomFactor(), y * m_frame->pageZoomFacto
r()); | 1438 IntPoint layoutPos(x * m_frame->pageZoomFactor(), y * m_frame->pageZoomFacto
r()); |
| 1439 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant
ly. |
1416 view->setScrollPosition(layoutPos); | 1440 view->setScrollPosition(layoutPos); |
1417 } | 1441 } |
1418 | 1442 |
1419 void DOMWindow::moveBy(float x, float y) const | 1443 void DOMWindow::moveBy(float x, float y) const |
1420 { | 1444 { |
1421 if (!m_frame || !m_frame->isMainFrame()) | 1445 if (!m_frame || !m_frame->isMainFrame()) |
1422 return; | 1446 return; |
1423 | 1447 |
1424 FrameHost* host = m_frame->host(); | 1448 FrameHost* host = m_frame->host(); |
1425 if (!host) | 1449 if (!host) |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1866 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<DOMWindow>:
:lifecycleNotifier()); | 1890 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<DOMWindow>:
:lifecycleNotifier()); |
1867 } | 1891 } |
1868 | 1892 |
1869 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier() | 1893 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier() |
1870 { | 1894 { |
1871 return DOMWindowLifecycleNotifier::create(this); | 1895 return DOMWindowLifecycleNotifier::create(this); |
1872 } | 1896 } |
1873 | 1897 |
1874 | 1898 |
1875 } // namespace WebCore | 1899 } // namespace WebCore |
OLD | NEW |