WebCore:
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Dec 2007 00:47:41 +0000 (00:47 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Dec 2007 00:47:41 +0000 (00:47 +0000)
        Reviewed by Mitz.

        Move window scrolling, moving and resizing methods from KJS::Window
        to WebCore::DOMWindow so that there bindings can be autogenerated.

        Tests: fast/dom/Window/window-resize-and-move-arguments.html
               fast/dom/Window/window-scroll-arguments.html

        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/kjs_window.cpp:
        (KJS::Window::getValueProperty): Remove extraneous allowsAccessFrom check.
        (KJS::WindowProtoFuncOpen::callAsFunction):
        (KJS::WindowProtoFuncNotImplemented::callAsFunction): Remove extraneous allowsAccessFrom check.
        * bindings/js/kjs_window.h:
        * bindings/scripts/CodeGeneratorJS.pm: Add new extended attribute
        to ensure that the no less than the declared number of attributes
        is allowed.
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::adjustWindowRect): Moved from kjs_window.
        (WebCore::DOMWindow::scrollBy):
        (WebCore::DOMWindow::scrollTo):
        (WebCore::DOMWindow::moveBy):
        (WebCore::DOMWindow::moveTo):
        (WebCore::DOMWindow::resizeBy):
        (WebCore::DOMWindow::resizeTo):
        * page/DOMWindow.h:
        (WebCore::DOMWindow::scroll):
        * page/DOMWindow.idl:

LayoutTests:

        Reviewed by Sam W.

        Split the ENABLE_SVG_EXPERIMENTAL_FEATURES flag into separate flags.

        Fixes <rdar://problem/5620249> Must disable SVG animation
        <rdar://problem/5612772> Disable SVG filters on Mac to match Windows behavior

        These layout test changes are caused by some of the experimental
        features no longer being enabled by default.

        * fast/dom/Window/window-properties-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-blend-01-b-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-color-01-b-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-composite-02-b-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-comptran-01-b-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-conv-01-f-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-diffuse-01-f-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-displace-01-f-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-example-01-b-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-felem-01-b-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-gauss-01-b-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-image-01-b-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-light-01-f-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-morph-01-f-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-offset-01-b-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-specular-01-f-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-tile-01-b-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/filters-turb-01-f-expected.txt:
        * platform/mac/svg/custom/empty-merge-expected.txt:
        * platform/mac/svg/custom/feComponentTransfer-Discrete-expected.txt:
        * platform/mac/svg/custom/feComponentTransfer-Gamma-expected.txt:
        * platform/mac/svg/custom/feComponentTransfer-Linear-expected.txt:
        * platform/mac/svg/custom/feComponentTransfer-Table-expected.txt:
        * platform/mac/svg/custom/feDisplacementMap-01-expected.txt:
        * platform/mac/svg/custom/filter-source-alpha-expected.txt:
        * platform/mac/svg/custom/image-with-transform-clip-filter-expected.txt:
        * platform/mac/svg/custom/invalid-css-expected.txt:
        * platform/mac/svg/custom/non-opaque-filters-expected.txt:
        * platform/mac/svg/custom/text-filter-expected.txt:
        * platform/mac/svg/custom/visibility-override-filter-expected.txt:
        * svg/batik/filters/filterRegions-expected.txt:
        * svg/batik/text/textEffect-expected.txt:
        * svg/batik/text/textEffect3-expected.txt:
        * svg/batik/text/textFeatures-expected.txt:
        * svg/batik/text/textProperties-expected.txt:
        * svg/custom/js-svg-constructors-expected.txt:
        * svg/dom/font-face-elements-expected.txt:
        * svg/webarchive/svg-feimage-subresources-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28570 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/Window/window-resize-and-move-arguments-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Window/window-resize-and-move-arguments.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/window-scroll-arguments-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Window/window-scroll-arguments.html [new file with mode: 0644]
LayoutTests/http/tests/security/cross-frame-access-get-expected.txt
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/kjs_window.cpp
WebCore/bindings/js/kjs_window.h
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/page/DOMWindow.cpp
WebCore/page/DOMWindow.h
WebCore/page/DOMWindow.idl

index ea73b21..cf16e23 100644 (file)
         * svg/dom/font-face-elements-expected.txt:
         * svg/webarchive/svg-feimage-subresources-expected.txt:
 
+2007-12-08  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Mitz.
+
+        Test that calling window scrolling, moving and resizing methods with
+        less than 2 arguments is not allowed and that calling them with more
+        than 2 is allowed.
+
+        * fast/dom/Window/window-resize-and-move-arguments-expected.txt: Added.
+        * fast/dom/Window/window-resize-and-move-arguments.html: Added.
+        * fast/dom/Window/window-scroll-arguments-expected.txt: Added.
+        * fast/dom/Window/window-scroll-arguments.html: Added.
+        * http/tests/security/cross-frame-access-get-expected.txt:
+
 2007-12-08  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Adele Peterson.
 
         - test that re-inserting a parser-generated <style> element applies its
-          sylesheet.
+          stylesheet.
 
         * fast/dom/HTMLStyleElement: Added.
         * fast/dom/HTMLStyleElement/insert-parser-generated.html: Added.
diff --git a/LayoutTests/fast/dom/Window/window-resize-and-move-arguments-expected.txt b/LayoutTests/fast/dom/Window/window-resize-and-move-arguments-expected.txt
new file mode 100644 (file)
index 0000000..04b2e07
--- /dev/null
@@ -0,0 +1,57 @@
+This test makes sure that we don't allow calling the window moving and resizing methods with less than 2 arguments and that we do allow calling them with more.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+window.resizeTo Tests
+
+Testing - resizeTo with 0 arguments
+PASS window.outerWidth is resetWidth
+PASS window.outerHeight is resetHeight
+Testing - resizeTo with 1 argument
+PASS window.outerWidth is resetWidth
+PASS window.outerHeight is resetHeight
+Testing - resizeTo with more than 2 arguments
+PASS window.outerWidth is width
+PASS window.outerHeight is height
+
+window.resizeBy Tests
+
+Testing - resizeBy with 0 arguments
+PASS window.outerWidth is resetWidth
+PASS window.outerHeight is resetHeight
+Testing - resizeBy with 1 argument
+PASS window.outerWidth is resetWidth
+PASS window.outerHeight is resetHeight
+Testing - resizeBy with more than 2 arguments
+PASS window.outerWidth is resetWidth + x
+PASS window.outerHeight is resetHeight + y
+
+window.moveTo Tests
+
+Testing - moveTo with 0 arguments
+PASS window.screenX is resetX
+PASS window.screenY is resetY
+Testing - moveTo with 1 argument
+PASS window.screenX is resetX
+PASS window.screenY is resetY
+Testing - moveTo with more than 2 arguments
+PASS window.screenX is x + screen.availLeft
+PASS window.screenY is y + screen.availTop
+
+window.moveBy Tests
+
+Testing - moveBy with 0 arguments
+PASS window.screenX is resetX
+PASS window.screenY is resetY
+Testing - moveBy with 1 argument
+PASS window.screenX is resetX
+PASS window.screenY is resetY
+Testing - moveBy with more than 2 arguments
+PASS window.screenX is resetX + x
+PASS window.screenY is resetY + y
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Window/window-resize-and-move-arguments.html b/LayoutTests/fast/dom/Window/window-resize-and-move-arguments.html
new file mode 100644 (file)
index 0000000..af5320c
--- /dev/null
@@ -0,0 +1,139 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+    <link rel="stylesheet" href="../../js/resources/js-test-style.css">
+    <script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script language="JavaScript" type="text/javascript">
+    var resetWidth;
+    var resetHeight;
+    var resetX;
+    var resetY;
+
+    var width = 100;
+    var height = 200;
+    var x = 25;
+    var y = 50;
+
+    function reset()
+    {
+        window.moveTo(0,0);
+        window.resizeTo(800,600);
+        resetWidth = window.outerWidth;
+        resetHeight = window.outerHeight;
+        resetX = window.screenX;
+        resetY = window.screenY;
+    }
+
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    reset();
+
+    description("This test makes sure that we don't allow calling the window moving and resizing\
+    methods with less than 2 arguments and that we do allow calling them with more.");
+
+    // resizeTo /////////////////////////
+    debug('');
+    debug('window.resizeTo Tests');
+    debug('');
+
+    debug("Testing - resizeTo with 0 arguments");
+    window.resizeTo();
+    shouldBe('window.outerWidth', 'resetWidth');
+    shouldBe('window.outerHeight', 'resetHeight');
+    reset();
+
+    debug("Testing - resizeTo with 1 argument");
+    window.resizeTo(x);
+    shouldBe('window.outerWidth', 'resetWidth');
+    shouldBe('window.outerHeight', 'resetHeight');
+    reset();
+
+    debug("Testing - resizeTo with more than 2 arguments");
+    window.resizeTo(width, height, 200, "text");
+    shouldBe('window.outerWidth', 'width');
+    shouldBe('window.outerHeight', 'height');
+    reset();
+
+    // resizeBy /////////////////////////
+    debug('');
+    debug('window.resizeBy Tests');
+    debug('');
+
+    debug("Testing - resizeBy with 0 arguments");
+    window.resizeBy();
+    shouldBe('window.outerWidth', 'resetWidth');
+    shouldBe('window.outerHeight', 'resetHeight');
+    reset();
+
+    debug("Testing - resizeBy with 1 argument");
+    window.resizeBy(x);
+    shouldBe('window.outerWidth', 'resetWidth');
+    shouldBe('window.outerHeight', 'resetHeight');
+    reset();
+
+    debug("Testing - resizeBy with more than 2 arguments");
+    window.resizeBy(x, y, 200, "text");
+    shouldBe('window.outerWidth', 'resetWidth + x');
+    shouldBe('window.outerHeight', 'resetHeight + y');
+    reset();
+
+
+    // moveTo /////////////////////////
+    debug('');
+    debug('window.moveTo Tests');
+    debug('');
+
+    debug("Testing - moveTo with 0 arguments");
+    window.moveTo();
+    shouldBe('window.screenX', 'resetX');
+    shouldBe('window.screenY', 'resetY');
+    reset();
+
+    debug("Testing - moveTo with 1 argument");
+    window.moveTo(x);
+    shouldBe('window.screenX', 'resetX');
+    shouldBe('window.screenY', 'resetY');
+    reset();
+
+    debug("Testing - moveTo with more than 2 arguments");
+    window.moveTo(x, y, 200, "text");
+    shouldBe('window.screenX', 'x + screen.availLeft');
+    shouldBe('window.screenY', 'y + screen.availTop');
+    reset();
+
+
+
+    // moveBy /////////////////////////
+    debug('');
+    debug('window.moveBy Tests');
+    debug('');
+
+    debug("Testing - moveBy with 0 arguments");
+    window.moveBy();
+    shouldBe('window.screenX', 'resetX');
+    shouldBe('window.screenY', 'resetY');
+    reset();
+
+    debug("Testing - moveBy with 1 argument");
+    window.moveBy(x);
+    shouldBe('window.screenX', 'resetX');
+    shouldBe('window.screenY', 'resetY');
+    reset();
+
+    debug("Testing - moveBy with more than 2 arguments");
+    window.moveBy(x, y, 200, "text");
+    shouldBe('window.screenX', 'resetX + x');
+    shouldBe('window.screenY', 'resetY + y');
+
+    reset();
+
+    var successfullyParsed = true;
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/Window/window-scroll-arguments-expected.txt b/LayoutTests/fast/dom/Window/window-scroll-arguments-expected.txt
new file mode 100644 (file)
index 0000000..d34f9d9
--- /dev/null
@@ -0,0 +1,45 @@
+This test makes sure that we don't allow calling the window scrolling methods with less than 2 arguments and that we do allow calling them with more.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+window.scrollTo Tests
+
+Testing - scrollTo with 0 arguments
+PASS window.scrollX is resetX
+PASS window.scrollY is resetY
+Testing - scrollTo with 1 argument
+PASS window.scrollX is resetX
+PASS window.scrollY is resetY
+Testing - scrollTo with more than 2 arguments
+PASS window.scrollX is x
+PASS window.scrollY is y
+
+window.scroll Tests
+
+Testing - scroll with 0 arguments
+PASS window.scrollX is resetX
+PASS window.scrollY is resetY
+Testing - scroll with 1 argument
+PASS window.scrollX is resetX
+PASS window.scrollY is resetY
+Testing - scroll with more than 2 arguments
+PASS window.scrollX is x
+PASS window.scrollY is y
+
+window.scrollBy Tests
+
+Testing - scrollBy with 0 arguments
+PASS window.scrollX is resetX
+PASS window.scrollY is resetY
+Testing - scrollBy with 1 argument
+PASS window.scrollX is resetX
+PASS window.scrollY is resetY
+Testing - scrollBy with more than 2 arguments
+PASS window.scrollX is resetX + x
+PASS window.scrollY is resetY + y
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This box should force the window to have a scrollable area to test.
diff --git a/LayoutTests/fast/dom/Window/window-scroll-arguments.html b/LayoutTests/fast/dom/Window/window-scroll-arguments.html
new file mode 100644 (file)
index 0000000..a31fc0f
--- /dev/null
@@ -0,0 +1,106 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+    <link rel="stylesheet" href="../../js/resources/js-test-style.css">
+    <script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<div style="height: 1000px; width: 1000px; border: 1px solid black;">This box should force the window to have a scrollable area to test.</div>
+<script language="JavaScript" type="text/javascript">
+    var resetX;
+    var resetY;
+
+    var x = 25;
+    var y = 50;
+
+    function reset()
+    {
+        window.scrollTo(0,0);
+        resetX = window.scrollX;
+        resetY = window.scrollY;
+    }
+
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    reset();
+
+    description("This test makes sure that we don't allow calling the window scrolling\
+    methods with less than 2 arguments and that we do allow calling them with more.");
+
+    // scrollTo /////////////////////////
+    debug('');
+    debug('window.scrollTo Tests');
+    debug('');
+
+    debug("Testing - scrollTo with 0 arguments");
+    window.scrollTo();
+    shouldBe('window.scrollX', 'resetX');
+    shouldBe('window.scrollY', 'resetY');
+    reset();
+
+    debug("Testing - scrollTo with 1 argument");
+    window.scrollTo(x);
+    shouldBe('window.scrollX', 'resetX');
+    shouldBe('window.scrollY', 'resetY');
+    reset();
+
+    debug("Testing - scrollTo with more than 2 arguments");
+    window.scrollTo(x, y, 200, "text");
+    shouldBe('window.scrollX', 'x');
+    shouldBe('window.scrollY', 'y');
+    reset();
+
+    // scroll /////////////////////////
+    debug('');
+    debug('window.scroll Tests');
+    debug('');
+
+    debug("Testing - scroll with 0 arguments");
+    window.scroll();
+    shouldBe('window.scrollX', 'resetX');
+    shouldBe('window.scrollY', 'resetY');
+    reset();
+
+    debug("Testing - scroll with 1 argument");
+    window.scroll(x);
+    shouldBe('window.scrollX', 'resetX');
+    shouldBe('window.scrollY', 'resetY');
+    reset();
+
+    debug("Testing - scroll with more than 2 arguments");
+    window.scroll(x, y, 200, "text");
+    shouldBe('window.scrollX', 'x');
+    shouldBe('window.scrollY', 'y');
+    reset();
+
+    // scrollBy /////////////////////////
+    debug('');
+    debug('window.scrollBy Tests');
+    debug('');
+
+    debug("Testing - scrollBy with 0 arguments");
+    window.scrollBy();
+    shouldBe('window.scrollX', 'resetX');
+    shouldBe('window.scrollY', 'resetY');
+    reset();
+
+    debug("Testing - scrollBy with 1 argument");
+    window.scrollBy(x);
+    shouldBe('window.scrollX', 'resetX');
+    shouldBe('window.scrollY', 'resetY');
+    reset();
+
+    debug("Testing - scrollBy with more than 2 arguments");
+    window.scrollBy(x, y, 200, "text");
+    shouldBe('window.scrollX', 'resetX + x');
+    shouldBe('window.scrollY', 'resetY + y');
+    reset();
+
+    var successfullyParsed = true;
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
index b3067d5..55d8195 100644 (file)
@@ -362,8 +362,6 @@ CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http
 
 CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-get.html. Domains, protocols and ports must match.
 
-CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-get.html. Domains, protocols and ports must match.
-
 This test checks cross-frame access security (rdar://problem/5251309).
 
 
index 967e3ca..4d1210f 100644 (file)
@@ -1,3 +1,34 @@
+2007-12-08  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Mitz.
+
+        Move window scrolling, moving and resizing methods from KJS::Window
+        to WebCore::DOMWindow so that there bindings can be autogenerated.
+
+        Tests: fast/dom/Window/window-resize-and-move-arguments.html
+               fast/dom/Window/window-scroll-arguments.html
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/kjs_window.cpp:
+        (KJS::Window::getValueProperty): Remove extraneous allowsAccessFrom check.
+        (KJS::WindowProtoFuncOpen::callAsFunction):
+        (KJS::WindowProtoFuncNotImplemented::callAsFunction): Remove extraneous allowsAccessFrom check.
+        * bindings/js/kjs_window.h:
+        * bindings/scripts/CodeGeneratorJS.pm: Add new extended attribute
+        to ensure that the no less than the declared number of attributes
+        is allowed.
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::adjustWindowRect): Moved from kjs_window.
+        (WebCore::DOMWindow::scrollBy):
+        (WebCore::DOMWindow::scrollTo):
+        (WebCore::DOMWindow::moveBy):
+        (WebCore::DOMWindow::moveTo):
+        (WebCore::DOMWindow::resizeBy):
+        (WebCore::DOMWindow::resizeTo):
+        * page/DOMWindow.h:
+        (WebCore::DOMWindow::scroll):
+        * page/DOMWindow.idl:
+
 2007-12-08  Kevin Ollivier  <kevino@theolliviers.com>
 
         Reviewed by Alp Toker.
index ac4afd0..adc5027 100644 (file)
                BC1A3793097C6FB10019F3D8 /* js */ = {
                        isa = PBXGroup;
                        children = (
-                               B22277AF0D00BEDC0071B782 /* JSSVGLazyEventListener.cpp */,
-                               B22277B00D00BEDC0071B782 /* JSSVGLazyEventListener.h */,
                                14DFB33F0A7DF7630018F769 /* Derived Sources */,
                                BC4EDEF70C08F414007EDD49 /* Custom */,
                                93F8B3060A300FEA00F61AB8 /* CodeGeneratorJS.pm */,
                                BCB7735F0C17853D00132BA4 /* JSNodeFilterCondition.h */,
                                8574D1F10ADE6122004CBA11 /* JSSVGElementWrapperFactory.cpp */,
                                8574D1F20ADE6122004CBA11 /* JSSVGElementWrapperFactory.h */,
+                               B22277AF0D00BEDC0071B782 /* JSSVGLazyEventListener.cpp */,
+                               B22277B00D00BEDC0071B782 /* JSSVGLazyEventListener.h */,
                                B21127A50B3186770009BE53 /* JSSVGPODTypeWrapper.h */,
                                B2D3FC890C2212CB00CF3618 /* JSSVGTransformListCustom.cpp */,
                                93B70D4109EB0C7C009D8468 /* JSXMLHttpRequest.cpp */,
index 908d315..fca75e6 100644 (file)
@@ -154,13 +154,6 @@ const ClassInfo Window::info = { "Window", 0, &WindowTable };
 # -- Functions --
   atob                  &WindowProtoFuncAToB::create                DontDelete|Function 1
   btoa                  &WindowProtoFuncBToA::create                DontDelete|Function 1
-  scroll                &WindowProtoFuncScrollTo::create            DontDelete|Function 2
-  scrollBy              &WindowProtoFuncScrollBy::create            DontDelete|Function 2
-  scrollTo              &WindowProtoFuncScrollTo::create            DontDelete|Function 2
-  moveBy                &WindowProtoFuncMoveBy::create              DontDelete|Function 2
-  moveTo                &WindowProtoFuncMoveTo::create              DontDelete|Function 2
-  resizeBy              &WindowProtoFuncResizeBy::create            DontDelete|Function 2
-  resizeTo              &WindowProtoFuncResizeTo::create            DontDelete|Function 2
   open                  &WindowProtoFuncOpen::create                DontDelete|Function 3
   setTimeout            &WindowProtoFuncSetTimeout::create          DontDelete|Function 2
   clearTimeout          &WindowProtoFuncClearTimeout::create        DontDelete|Function 1
@@ -507,8 +500,6 @@ JSValue *Window::getValueProperty(ExecState *exec, int token) const
 
    switch (token) {
    case Crypto:
-      if (!allowsAccessFrom(exec))
-        return jsUndefined();
       return jsUndefined(); // FIXME: implement this
    case DOMException:
       if (!allowsAccessFrom(exec))
@@ -620,7 +611,7 @@ JSValue *Window::getValueProperty(ExecState *exec, int token) const
     case Onunload:
      return getListener(exec, unloadEvent);
    }
-   ASSERT(0);
+   ASSERT_NOT_REACHED();
    return jsUndefined();
 }
 
@@ -1159,47 +1150,6 @@ static void parseWindowFeatures(const String& features, WindowFeatures& windowFe
     }
 }
 
-// Explain the 4 things this function does.
-// 1) Validates the pending changes are not changing to NaN
-// 2) Constrains the window rect to no smaller than 100 in each dimension and no
-//    bigger than the the float rect's dimensions.
-// 3) Constrain window rect to within the top and left boundaries of the screen rect
-// 4) Constraint the window rect to within the bottom and right boundaries of the
-//    screen rect.
-// 5) Translate the window rect coordinates to be within the coordinate space of
-//    the screen rect.
-static void adjustWindowRect(const FloatRect& screen, FloatRect& window, const FloatRect& pendingChanges)
-{
-    // Make sure we're in a valid state before adjusting dimensions
-    ASSERT(!isnan(screen.x()) && !isnan(screen.y()) && !isnan(screen.width()) && !isnan(screen.height()) &&
-           !isnan(window.x()) && !isnan(window.y()) && !isnan(window.width()) && !isnan(window.height()));
-    
-    // Update window values if they are not NaN
-    if (!isnan(pendingChanges.x()))
-        window.setX(pendingChanges.x());
-    if (!isnan(pendingChanges.y()))
-        window.setY(pendingChanges.y());
-    if (!isnan(pendingChanges.width()))
-        window.setWidth(pendingChanges.width());
-    if (!isnan(pendingChanges.height()))
-        window.setHeight(pendingChanges.height());
-    
-    // Resize the window to between 100 and the screen width and height if it's
-    // outside of those ranges.
-    window.setWidth(min(max(100.0f, window.width()), screen.width()));
-    window.setHeight(min(max(100.0f, window.height()), screen.height()));
-    
-    // Constrain the window to the top and left of the screen if it's left or
-    // above it.
-    window.setX(max(window.x(), screen.x()));
-    window.setY(max(window.y(), screen.y()));
-
-    // Constrain the window to the bottom and right of the screen if it's past
-    // the right or below it.
-    window.setX(window.x() - max(0.0f, window.right() - screen.width() - screen.x()));
-    window.setY(window.y() - max(0.0f, window.bottom() - screen.height() - screen.y()));
-}
-
 JSValue* WindowProtoFuncAToB::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
 {
     if (!thisObj->inherits(&Window::info))
@@ -1316,7 +1266,7 @@ JSValue* WindowProtoFuncOpen::callAsFunction(ExecState* exec, JSObject* thisObj,
     String features = valueToStringWithUndefinedOrNullCheck(exec, args[2]);
     parseWindowFeatures(features, windowFeatures);
     FloatRect windowRect(windowFeatures.x, windowFeatures.y, windowFeatures.width, windowFeatures.height);
-    adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), windowRect, windowRect);
+    WebCore::DOMWindow::adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), windowRect, windowRect);
 
     windowFeatures.x = windowRect.x();
     windowFeatures.y = windowRect.y();
@@ -1331,130 +1281,6 @@ JSValue* WindowProtoFuncOpen::callAsFunction(ExecState* exec, JSObject* thisObj,
     return Window::retrieve(frame); // global object
 }
 
-JSValue* WindowProtoFuncScrollBy::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
-{
-    if (!thisObj->inherits(&Window::info))
-        return throwError(exec, TypeError);
-    Window* window = static_cast<Window*>(thisObj);
-    Frame* frame = window->impl()->frame();
-    if (!frame)
-        return jsUndefined();
-
-    FrameView *widget = frame->view();
-
-    window->updateLayout();
-    if(args.size() >= 2 && widget)
-      widget->scrollBy(args[0]->toInt32(exec), args[1]->toInt32(exec));
-    return jsUndefined();
-}
-
-JSValue* WindowProtoFuncScrollTo::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
-{
-    // Also the implementation for window.scroll()
-
-    if (!thisObj->inherits(&Window::info))
-        return throwError(exec, TypeError);
-    Window* window = static_cast<Window*>(thisObj);
-    Frame* frame = window->impl()->frame();
-    if (!frame)
-        return jsUndefined();
-
-    FrameView *widget = frame->view();
-
-    window->updateLayout();
-    if (args.size() >= 2 && widget)
-      widget->setContentsPos(args[0]->toInt32(exec), args[1]->toInt32(exec));
-    return jsUndefined();
-}
-
-JSValue* WindowProtoFuncMoveBy::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
-{
-    if (!thisObj->inherits(&Window::info))
-        return throwError(exec, TypeError);
-    Window* window = static_cast<Window*>(thisObj);
-    Frame* frame = window->impl()->frame();
-    if (!frame)
-        return jsUndefined();
-
-    Page* page = frame->page();
-
-    if (args.size() >= 2 && page) {
-      FloatRect fr = page->chrome()->windowRect();
-      FloatRect update = fr;
-      update.move(args[0]->toFloat(exec), args[1]->toFloat(exec));
-      // Security check (the spec talks about UniversalBrowserWrite to disable this check...)
-      adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
-      page->chrome()->setWindowRect(fr);
-    }
-    return jsUndefined();
-}
-
-JSValue* WindowProtoFuncMoveTo::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
-{
-    if (!thisObj->inherits(&Window::info))
-        return throwError(exec, TypeError);
-    Window* window = static_cast<Window*>(thisObj);
-    Frame* frame = window->impl()->frame();
-    if (!frame)
-        return jsUndefined();
-
-    Page* page = frame->page();
-
-    if (args.size() >= 2 && page) {
-      FloatRect fr = page->chrome()->windowRect();
-      FloatRect sr = screenAvailableRect(page->mainFrame()->view());
-      fr.setLocation(sr.location());
-      FloatRect update = fr;
-      update.move(args[0]->toFloat(exec), args[1]->toFloat(exec));     
-      // Security check (the spec talks about UniversalBrowserWrite to disable this check...)
-      adjustWindowRect(sr, fr, update);
-      page->chrome()->setWindowRect(fr);
-    }
-    return jsUndefined();
-}
-
-JSValue* WindowProtoFuncResizeBy::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
-{
-    if (!thisObj->inherits(&Window::info))
-        return throwError(exec, TypeError);
-    Window* window = static_cast<Window*>(thisObj);
-    Frame* frame = window->impl()->frame();
-    if (!frame)
-        return jsUndefined();
-
-    Page* page = frame->page();
-
-    if (args.size() >= 2 && page) {
-      FloatRect fr = page->chrome()->windowRect();
-      FloatSize dest = fr.size() + FloatSize(args[0]->toFloat(exec), args[1]->toFloat(exec));
-      FloatRect update(fr.location(), dest);
-      adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
-      page->chrome()->setWindowRect(fr);
-    }
-    return jsUndefined();
-}
-
-JSValue* WindowProtoFuncResizeTo::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
-{
-    if (!thisObj->inherits(&Window::info))
-        return throwError(exec, TypeError);
-    Window* window = static_cast<Window*>(thisObj);
-    Frame* frame = window->impl()->frame();
-    if (!frame)
-        return jsUndefined();
-
-    Page* page = frame->page();
-
-    if (args.size() >= 2 && page) {
-      FloatRect fr = page->chrome()->windowRect();
-      FloatSize dest = FloatSize(args[0]->toFloat(exec), args[1]->toFloat(exec));
-      FloatRect update(fr.location(), dest);
-      adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
-      page->chrome()->setWindowRect(fr);
-    }
-    return jsUndefined();
-}
-
 JSValue* WindowProtoFuncSetTimeout::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
 {
     if (!thisObj->inherits(&Window::info))
@@ -1591,28 +1417,11 @@ JSValue* WindowProtoFuncNotImplemented::callAsFunction(ExecState* exec, JSObject
 {
     if (!thisObj->inherits(&Window::info))
         return throwError(exec, TypeError);
-    Window* window = static_cast<Window*>(thisObj);
-    Frame* frame = window->impl()->frame();
-    if (!frame)
-        return jsUndefined();
 
-    // If anyone implements these, they need the safe script security check.
-    if (!window->allowsAccessFrom(exec))
-        return jsUndefined();
     // Not implemented.
     return jsUndefined();
 }
 
-void Window::updateLayout() const
-{
-  Frame* frame = impl()->frame();
-  if (!frame)
-    return;
-  WebCore::Document* docimpl = frame->document();
-  if (docimpl)
-    docimpl->updateLayoutIgnorePendingStylesheets();
-}
-
 void Window::setReturnValueSlot(JSValue** slot)
 { 
     d->m_returnValueSlot = slot; 
index be9ec31..52a25fc 100644 (file)
@@ -163,8 +163,6 @@ namespace KJS {
         XSLTProcessor_
     };
 
-    void updateLayout() const;
-
   private:
     JSValue* getListener(ExecState*, const WebCore::AtomicString& eventType) const;
     void setListener(ExecState*, const WebCore::AtomicString& eventType, JSValue* func);
@@ -186,12 +184,6 @@ namespace KJS {
     macro(WindowProtoFuncAToB) \
     macro(WindowProtoFuncBToA) \
     macro(WindowProtoFuncOpen) \
-    macro(WindowProtoFuncScrollBy) \
-    macro(WindowProtoFuncScrollTo) \
-    macro(WindowProtoFuncMoveBy) \
-    macro(WindowProtoFuncMoveTo) \
-    macro(WindowProtoFuncResizeBy) \
-    macro(WindowProtoFuncResizeTo) \
     macro(WindowProtoFuncSetTimeout) \
     macro(WindowProtoFuncClearTimeout) \
     macro(WindowProtoFuncSetInterval) \
index 6ade73b..7ec5626 100644 (file)
@@ -1098,9 +1098,15 @@ sub GenerateImplementation
                     push(@implContent, "    JSSVGPODTypeWrapper<$podType>* wrapper = castedThisObj->impl();\n");
                     push(@implContent, "    $podType imp(*wrapper);\n\n");
                 } else {
-                    push(@implContent, "    $implClassName* imp = static_cast<$implClassName*>(castedThisObj->impl());\n\n");
+                    push(@implContent, "    $implClassName* imp = static_cast<$implClassName*>(castedThisObj->impl());\n");
                 }
 
+                my $numParameters = @{$function->parameters};
+
+                if ($function->signature->extendedAttributes->{"RequiresAllArguments"}) {
+                        push(@implContent, "    if (args.size() < $numParameters)\n");
+                        push(@implContent, "        return jsUndefined();\n");
+                }
 
                 if (@{$function->raisesExceptions}) {
                     push(@implContent, "    ExceptionCode ec = 0;\n");
@@ -1115,7 +1121,6 @@ sub GenerateImplementation
                 my $paramIndex = 0;
                 my $functionString = "imp" . ($podType ? "." : "->") . $function->signature->name . "(";
 
-                my $numParameters = @{$function->parameters};
                 my $hasOptionalArguments = 0;
 
                 foreach my $parameter (@{$function->parameters}) {
index 8185ac6..2fd0bc7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "CSSStyleSelector.h"
 #include "Chrome.h"
 #include "Console.h"
-#include "Database.h"
 #include "DOMSelection.h"
+#include "Database.h"
 #include "Document.h"
 #include "Element.h"
+#include "FloatRect.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameTree.h"
 #include "PlatformScreen.h"
 #include "PlatformString.h"
 #include "Screen.h"
+#include <algorithm>
+#include <wtf/MathExtras.h>
+
+using std::min;
+using std::max;
 
 namespace WebCore {
 
+// This function:
+// 1) Validates the pending changes are not changing to NaN
+// 2) Constrains the window rect to no smaller than 100 in each dimension and no
+//    bigger than the the float rect's dimensions.
+// 3) Constrain window rect to within the top and left boundaries of the screen rect
+// 4) Constraint the window rect to within the bottom and right boundaries of the
+//    screen rect.
+// 5) Translate the window rect coordinates to be within the coordinate space of
+//    the screen rect.
+void DOMWindow::adjustWindowRect(const FloatRect& screen, FloatRect& window, const FloatRect& pendingChanges)
+{
+    // Make sure we're in a valid state before adjusting dimensions
+    ASSERT(!isnan(screen.x()) && !isnan(screen.y()) && !isnan(screen.width()) && !isnan(screen.height()) &&
+           !isnan(window.x()) && !isnan(window.y()) && !isnan(window.width()) && !isnan(window.height()));
+    
+    // Update window values if they are not NaN
+    if (!isnan(pendingChanges.x()))
+        window.setX(pendingChanges.x());
+    if (!isnan(pendingChanges.y()))
+        window.setY(pendingChanges.y());
+    if (!isnan(pendingChanges.width()))
+        window.setWidth(pendingChanges.width());
+    if (!isnan(pendingChanges.height()))
+        window.setHeight(pendingChanges.height());
+    
+    // Resize the window to between 100 and the screen width and height if it's
+    // outside of those ranges.
+    window.setWidth(min(max(100.0f, window.width()), screen.width()));
+    window.setHeight(min(max(100.0f, window.height()), screen.height()));
+    
+    // Constrain the window to the top and left of the screen if it's left or
+    // above it.
+    window.setX(max(window.x(), screen.x()));
+    window.setY(max(window.y(), screen.y()));
+
+    // Constrain the window to the bottom and right of the screen if it's past
+    // the right or below it.
+    window.setX(window.x() - max(0.0f, window.right() - screen.width() - screen.x()));
+    window.setY(window.y() - max(0.0f, window.bottom() - screen.height() - screen.y()));
+}
+
 DOMWindow::DOMWindow(Frame* frame)
     : m_frame(frame)
 {
@@ -577,4 +624,106 @@ PassRefPtr<Database> DOMWindow::openDatabase(const String& name, const String& v
 }
 #endif
 
+void DOMWindow::scrollBy(int x, int y) const
+{
+    if (!m_frame)
+        return;
+
+    Document* doc = m_frame->document();
+    ASSERT(doc);
+    if (doc)
+        doc->updateLayoutIgnorePendingStylesheets();
+
+    FrameView* view = m_frame->view();
+    if (!view)
+        return;
+
+    view->scrollBy(x, y);
+}
+
+void DOMWindow::scrollTo(int x, int y) const
+{
+    if (!m_frame)
+        return;
+
+    Document* doc = m_frame->document();
+    ASSERT(doc);
+    if (doc)
+        doc->updateLayoutIgnorePendingStylesheets();
+
+    FrameView* view = m_frame->view();
+    if (!view)
+        return;
+
+    view->setContentsPos(x, y);
+}
+
+void DOMWindow::moveBy(float x, float y) const
+{
+    if (!m_frame)
+        return;
+
+    Page* page = m_frame->page();
+    if (!page)
+        return;
+
+    FloatRect fr = page->chrome()->windowRect();
+    FloatRect update = fr;
+    update.move(x, y);
+    // Security check (the spec talks about UniversalBrowserWrite to disable this check...)
+    adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
+    page->chrome()->setWindowRect(fr);
+}
+
+void DOMWindow::moveTo(float x, float y) const
+{
+    if (!m_frame)
+        return;
+
+    Page* page = m_frame->page();
+    if (!page)
+        return;
+
+    FloatRect fr = page->chrome()->windowRect();
+    FloatRect sr = screenAvailableRect(page->mainFrame()->view());
+    fr.setLocation(sr.location());
+    FloatRect update = fr;
+    update.move(x, y);     
+    // Security check (the spec talks about UniversalBrowserWrite to disable this check...)
+    adjustWindowRect(sr, fr, update);
+    page->chrome()->setWindowRect(fr);
+}
+
+void DOMWindow::resizeBy(float x, float y) const
+{
+    if (!m_frame)
+        return;
+
+    Page* page = m_frame->page();
+    if (!page)
+        return;
+
+    FloatRect fr = page->chrome()->windowRect();
+    FloatSize dest = fr.size() + FloatSize(x, y);
+    FloatRect update(fr.location(), dest);
+    adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
+    page->chrome()->setWindowRect(fr);
+}
+
+void DOMWindow::resizeTo(float width, float height) const
+{
+    if (!m_frame)
+        return;
+
+    Page* page = m_frame->page();
+    if (!page)
+        return;
+
+    FloatRect fr = page->chrome()->windowRect();
+    FloatSize dest = FloatSize(width, height);
+    FloatRect update(fr.location(), dest);
+    adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
+    page->chrome()->setWindowRect(fr);
+}
+
 } // namespace WebCore
index 59e0b6c..9a536b4 100644 (file)
@@ -37,10 +37,11 @@ namespace WebCore {
     class CSSRuleList;
     class CSSStyleDeclaration;
     class Console;
-    class Database;
     class DOMSelection;
+    class Database;
     class Document;
     class Element;
+    class FloatRect;
     class Frame;
     class History;
     class Screen;
@@ -57,6 +58,8 @@ namespace WebCore {
 
         void clear();
 
+        static void adjustWindowRect(const FloatRect& screen, FloatRect& window, const FloatRect& pendingChanges);
+
         // DOM Level 0
         Screen* screen() const;
         History* history() const;
@@ -139,6 +142,16 @@ namespace WebCore {
 
         Console* console() const;
 
+        void scrollBy(int x, int y) const;
+        void scrollTo(int x, int y) const;
+        void scroll(int x, int y) const { scrollTo(x, y); }
+
+        void moveBy(float x, float y) const;
+        void moveTo(float x, float y) const;
+
+        void resizeBy(float x, float y) const;
+        void resizeTo(float width, float height) const;
+
     private:
         Frame* m_frame;
         mutable RefPtr<Screen> m_screen;
index 2cd3c4d..64f774c 100644 (file)
@@ -75,6 +75,14 @@ module window {
         readonly attribute long pageXOffset;
         readonly attribute long pageYOffset;
 
+        [RequiresAllArguments] void scrollBy(in long x, in long y);
+        [RequiresAllArguments] void scrollTo(in long x, in long y);
+        [RequiresAllArguments] void scroll(in long x, in long y);
+        [RequiresAllArguments] void moveBy(in float x, in float y); // FIXME: this should take longs not floats.
+        [RequiresAllArguments] void moveTo(in float x, in float y); // FIXME: this should take longs not floats.
+        [RequiresAllArguments] void resizeBy(in float x, in float y); // FIXME: this should take longs not floats.
+        [RequiresAllArguments] void resizeTo(in float width, in float height); // FIXME: this should take longs not floats.
+
         readonly attribute [DoNotCheckDomainSecurity] boolean closed;
 
         readonly attribute [DoNotCheckDomainSecurity] unsigned long length;