Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Side by Side Diff: Source/core/frame/LocalDOMWindow.cpp

Issue 774203003: Update Window API for CSSOM smooth scrolling to match the spec (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update expected results Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/LocalDOMWindow.h ('k') | Source/core/frame/ScrollOptions.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "core/frame/DOMWindowLifecycleNotifier.h" 61 #include "core/frame/DOMWindowLifecycleNotifier.h"
62 #include "core/frame/EventHandlerRegistry.h" 62 #include "core/frame/EventHandlerRegistry.h"
63 #include "core/frame/FrameConsole.h" 63 #include "core/frame/FrameConsole.h"
64 #include "core/frame/FrameHost.h" 64 #include "core/frame/FrameHost.h"
65 #include "core/frame/FrameView.h" 65 #include "core/frame/FrameView.h"
66 #include "core/frame/History.h" 66 #include "core/frame/History.h"
67 #include "core/frame/LocalFrame.h" 67 #include "core/frame/LocalFrame.h"
68 #include "core/frame/Location.h" 68 #include "core/frame/Location.h"
69 #include "core/frame/Navigator.h" 69 #include "core/frame/Navigator.h"
70 #include "core/frame/Screen.h" 70 #include "core/frame/Screen.h"
71 #include "core/frame/ScrollOptions.h" 71 #include "core/frame/ScrollToOptions.h"
72 #include "core/frame/Settings.h" 72 #include "core/frame/Settings.h"
73 #include "core/html/HTMLFrameOwnerElement.h" 73 #include "core/html/HTMLFrameOwnerElement.h"
74 #include "core/inspector/ConsoleMessage.h" 74 #include "core/inspector/ConsoleMessage.h"
75 #include "core/inspector/ConsoleMessageStorage.h" 75 #include "core/inspector/ConsoleMessageStorage.h"
76 #include "core/inspector/InspectorInstrumentation.h" 76 #include "core/inspector/InspectorInstrumentation.h"
77 #include "core/inspector/InspectorTraceEvents.h" 77 #include "core/inspector/InspectorTraceEvents.h"
78 #include "core/inspector/ScriptCallStack.h" 78 #include "core/inspector/ScriptCallStack.h"
79 #include "core/loader/DocumentLoader.h" 79 #include "core/loader/DocumentLoader.h"
80 #include "core/loader/FrameLoadRequest.h" 80 #include "core/loader/FrameLoadRequest.h"
81 #include "core/loader/FrameLoader.h" 81 #include "core/loader/FrameLoader.h"
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 } 1415 }
1416 1416
1417 double LocalDOMWindow::devicePixelRatio() const 1417 double LocalDOMWindow::devicePixelRatio() const
1418 { 1418 {
1419 if (!frame()) 1419 if (!frame())
1420 return 0.0; 1420 return 0.0;
1421 1421
1422 return frame()->devicePixelRatio(); 1422 return frame()->devicePixelRatio();
1423 } 1423 }
1424 1424
1425 static bool scrollBehaviorFromScrollOptions(const ScrollOptions& scrollOptions, ScrollBehavior& scrollBehavior, ExceptionState& exceptionState)
1426 {
1427 if (!scrollOptions.hasBehavior()) {
1428 scrollBehavior = ScrollBehaviorAuto;
1429 return true;
1430 }
1431
1432 if (ScrollableArea::scrollBehaviorFromString(scrollOptions.behavior(), scrol lBehavior))
1433 return true;
1434
1435 exceptionState.throwTypeError("The ScrollBehavior provided is invalid.");
1436 return false;
1437 }
1438
1439 // FIXME: This class shouldn't be explicitly moving the viewport around. crbug.c om/371896 1425 // FIXME: This class shouldn't be explicitly moving the viewport around. crbug.c om/371896
1440 static void scrollViewportTo(LocalFrame* frame, DoublePoint offset, ScrollBehavi or scrollBehavior) 1426 static void scrollViewportTo(LocalFrame* frame, DoublePoint offset, ScrollBehavi or scrollBehavior)
1441 { 1427 {
1442 FrameView* view = frame->view(); 1428 FrameView* view = frame->view();
1443 if (!view) 1429 if (!view)
1444 return; 1430 return;
1445 1431
1446 FrameHost* host = frame->host(); 1432 FrameHost* host = frame->host();
1447 if (!host) 1433 if (!host)
1448 return; 1434 return;
(...skipping 26 matching lines...) Expand all
1475 return; 1461 return;
1476 1462
1477 DoublePoint currentOffset = host->settings().pinchVirtualViewportEnabled() & & frame()->isMainFrame() 1463 DoublePoint currentOffset = host->settings().pinchVirtualViewportEnabled() & & frame()->isMainFrame()
1478 ? DoublePoint(host->pinchViewport().visibleRectInDocument().location()) 1464 ? DoublePoint(host->pinchViewport().visibleRectInDocument().location())
1479 : view->scrollPositionDouble(); 1465 : view->scrollPositionDouble();
1480 1466
1481 DoubleSize scaledOffset(x * frame()->pageZoomFactor(), y * frame()->pageZoom Factor()); 1467 DoubleSize scaledOffset(x * frame()->pageZoomFactor(), y * frame()->pageZoom Factor());
1482 scrollViewportTo(frame(), currentOffset + scaledOffset, scrollBehavior); 1468 scrollViewportTo(frame(), currentOffset + scaledOffset, scrollBehavior);
1483 } 1469 }
1484 1470
1485 void LocalDOMWindow::scrollBy(double x, double y, const ScrollOptions& scrollOpt ions, ExceptionState &exceptionState) const 1471 void LocalDOMWindow::scrollBy(const ScrollToOptions& scrollToOptions) const
1486 { 1472 {
1473 double x = 0.0;
1474 double y = 0.0;
1475 if (scrollToOptions.hasLeft())
1476 x = scrollToOptions.left();
1477 if (scrollToOptions.hasTop())
1478 y = scrollToOptions.top();
1487 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; 1479 ScrollBehavior scrollBehavior = ScrollBehaviorAuto;
1488 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio nState)) 1480 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB ehavior);
1489 return;
1490 scrollBy(x, y, scrollBehavior); 1481 scrollBy(x, y, scrollBehavior);
1491 } 1482 }
1492 1483
1493 void LocalDOMWindow::scrollTo(double x, double y, ScrollBehavior scrollBehavior) const 1484 void LocalDOMWindow::scrollTo(double x, double y) const
1494 { 1485 {
1495 if (!isCurrentlyDisplayedInFrame()) 1486 if (!isCurrentlyDisplayedInFrame())
1496 return; 1487 return;
1497 1488
1498 document()->updateLayoutIgnorePendingStylesheets(); 1489 document()->updateLayoutIgnorePendingStylesheets();
1499 1490
1500 if (std::isnan(x) || std::isnan(y)) 1491 if (std::isnan(x) || std::isnan(y))
1501 return; 1492 return;
1502 1493
1503 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa ctor()); 1494 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa ctor());
1504 scrollViewportTo(frame(), layoutPos, scrollBehavior); 1495 scrollViewportTo(frame(), layoutPos, ScrollBehaviorAuto);
1505 } 1496 }
1506 1497
1507 void LocalDOMWindow::scrollTo(double x, double y, const ScrollOptions& scrollOpt ions, ExceptionState& exceptionState) const 1498 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const
1508 { 1499 {
1500 if (!isCurrentlyDisplayedInFrame())
1501 return;
1502
1503 document()->updateLayoutIgnorePendingStylesheets();
1504
1505 FrameView* view = frame()->view();
1506 if (!view)
1507 return;
1508
1509 FrameHost* host = frame()->host();
1510 if (!host)
1511 return;
1512
1513 double scaledX = 0.0;
1514 double scaledY = 0.0;
1515
1516 DoublePoint currentOffset = host->settings().pinchVirtualViewportEnabled() & & frame()->isMainFrame()
1517 ? DoublePoint(host->pinchViewport().visibleRectInDocument().location())
1518 : view->scrollPositionDouble();
1519 scaledX = currentOffset.x();
1520 scaledY = currentOffset.y();
1521
1522 if (scrollToOptions.hasLeft()) {
1523 if (std::isnan(scrollToOptions.left()))
1524 return;
1525 scaledX = scrollToOptions.left() * frame()->pageZoomFactor();
1526 }
1527
1528 if (scrollToOptions.hasTop()) {
1529 if (std::isnan(scrollToOptions.top()))
1530 return;
1531 scaledY = scrollToOptions.top() * frame()->pageZoomFactor();
1532 }
1533
1509 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; 1534 ScrollBehavior scrollBehavior = ScrollBehaviorAuto;
1510 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio nState)) 1535 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB ehavior);
1511 return; 1536 scrollViewportTo(frame(), DoublePoint(scaledX, scaledY), scrollBehavior);
1512 scrollTo(x, y, scrollBehavior);
1513 } 1537 }
1514 1538
1515 void LocalDOMWindow::moveBy(float x, float y) const 1539 void LocalDOMWindow::moveBy(float x, float y) const
1516 { 1540 {
1517 if (!frame() || !frame()->isMainFrame()) 1541 if (!frame() || !frame()->isMainFrame())
1518 return; 1542 return;
1519 1543
1520 FrameHost* host = frame()->host(); 1544 FrameHost* host = frame()->host();
1521 if (!host) 1545 if (!host)
1522 return; 1546 return;
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 return m_frameObserver->frame(); 2047 return m_frameObserver->frame();
2024 } 2048 }
2025 2049
2026 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate) 2050 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate)
2027 { 2051 {
2028 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. 2052 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8].
2029 return v8::Handle<v8::Object>(); 2053 return v8::Handle<v8::Object>();
2030 } 2054 }
2031 2055
2032 } // namespace blink 2056 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/LocalDOMWindow.h ('k') | Source/core/frame/ScrollOptions.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698