2011-01-08 Chang Shu <chang.shu@nokia.com>
authorchang.shu@nokia.com <chang.shu@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Jan 2011 01:08:41 +0000 (01:08 +0000)
committerchang.shu@nokia.com <chang.shu@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Jan 2011 01:08:41 +0000 (01:08 +0000)
        Reviewed by Kenneth Rohde Christiansen.

        Support createTouchList with Touch list for test automation.
        https://bugs.webkit.org/show_bug.cgi?id=51196

        Added test cases that take Touch objects when creating TouchList.

        * fast/events/touch/document-create-touch-list-expected.txt:
        * fast/events/touch/script-tests/document-create-touch-list.js:
2011-01-08  Chang Shu  <chang.shu@nokia.com>

        Reviewed by Kenneth Rohde Christiansen.

        Support createTouchList with Touch list for test automation.
        Implemented JS/V8 custom functions for createTouchList.
        https://bugs.webkit.org/show_bug.cgi?id=51196

        * bindings/js/JSDocumentCustom.cpp:
        (WebCore::JSDocument::createTouchList):
        * bindings/v8/custom/V8DocumentCustom.cpp:
        (WebCore::V8Document::createTouchListCallback):
        * dom/Document.idl:
        * dom/TouchEvent.cpp:
        (WebCore::TouchEvent::initTouchEvent):

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

LayoutTests/ChangeLog
LayoutTests/fast/events/touch/document-create-touch-list-expected.txt
LayoutTests/fast/events/touch/script-tests/document-create-touch-list.js
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDocumentCustom.cpp
Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
Source/WebCore/dom/Document.idl
Source/WebCore/dom/TouchEvent.cpp

index 15e8e57033553d6ff40685f5b23bf450feab109f..6a7743e3660d76679ea761661c85ba455fdf7fab 100644 (file)
@@ -1,3 +1,15 @@
+2011-01-08  Chang Shu  <chang.shu@nokia.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Support createTouchList with Touch list for test automation.
+        https://bugs.webkit.org/show_bug.cgi?id=51196
+
+        Added test cases that take Touch objects when creating TouchList.
+
+        * fast/events/touch/document-create-touch-list-expected.txt:
+        * fast/events/touch/script-tests/document-create-touch-list.js:
+
 2011-01-08  Chang Shu  <chang.shu@nokia.com>
 
         Reviewed by Ryosuke Niwa.
index 99d578c2f50464895174a93ba2f620932218dc4d..c664b2acf95b213f59306daa46f20876751fb847 100644 (file)
@@ -8,6 +8,11 @@ PASS touchList is non-null.
 PASS touchList.length is 0
 PASS touchList.item(0) is null
 PASS touchList.item(1) is null
+PASS ts.touches.length is 2
+PASS ts.touches[0].identifier is 12341
+PASS ts.touches[0].clientX is 60
+PASS ts.touches[1].screenY is 120
+PASS ts.ctrlKey is true
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 9c87c9ad7c771fbc3c089d7e8592a08d73515f59..526badc79b8b2ba0cdc86810986409690f32f62b 100644 (file)
@@ -2,11 +2,43 @@ description("This tests support for the document.createTouchList API.");
 
 shouldBeTrue('"createTouchList" in document');
 
+// Test createTouchList with no arguments.
 var touchList = document.createTouchList();
 shouldBeNonNull("touchList");
 shouldBe("touchList.length", "0");
 shouldBeNull("touchList.item(0)");
 shouldBeNull("touchList.item(1)");
 
+// Test createTouchList with Touch objects as arguments.
+try {
+    var t = document.createTouch(window, document.body, 12341, 60, 65, 100, 105);
+    var t2 = document.createTouch(window, document.body, 12342, 50, 55, 115, 120);
+    var tl = document.createTouchList(t, t2);
+
+    var evt = document.createEvent("TouchEvent");
+    evt.initTouchEvent(tl, tl, tl, "touchstart", window, 0, 0, 0, 0, true, false, false, false);
+
+    document.body.addEventListener("touchstart", function handleTouchStart(ev) {
+        ts = ev;
+        shouldBe("ts.touches.length", "2");
+        shouldBe("ts.touches[0].identifier", "12341");
+        shouldBe("ts.touches[0].clientX", "60");
+        shouldBe("ts.touches[1].screenY", "120");
+        shouldBe("ts.ctrlKey", "true");
+    });
+
+    document.body.dispatchEvent(evt);
+} catch(e) {
+    testFailed("An exception was thrown: " + e.message);
+}
+
+// Test createTouchList with invalid arguments which throws exceptions.
+try {
+    var tl = document.createTouchList(1, 2);
+} catch(e) {
+    testFailed("An exception was thrown: " + e.message);
+}
+
 successfullyParsed = true;
 isSuccessfullyParsed();
+
index 04ec2f4adc2b16bdf87576dcdf400a1ab2e83572..efb906106a70c41e3518dd0f18590da1153d5432 100644 (file)
@@ -1,3 +1,19 @@
+2011-01-08  Chang Shu  <chang.shu@nokia.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Support createTouchList with Touch list for test automation.
+        Implemented JS/V8 custom functions for createTouchList.
+        https://bugs.webkit.org/show_bug.cgi?id=51196
+
+        * bindings/js/JSDocumentCustom.cpp:
+        (WebCore::JSDocument::createTouchList):
+        * bindings/v8/custom/V8DocumentCustom.cpp:
+        (WebCore::V8Document::createTouchListCallback):
+        * dom/Document.idl:
+        * dom/TouchEvent.cpp:
+        (WebCore::TouchEvent::initTouchEvent):
+
 2011-01-08  Benjamin Poulain  <benjamin.poulain@nokia.com>
 
         Reviewed by Kenneth Rohde Christiansen.
index 5f61e2a39a6e8dc65e195d1088de87dfa71f923d..4cc176c84bcf65bf4542652c737d0a245ae10154 100644 (file)
 #include "JSDOMWindowCustom.h"
 #include "JSHTMLDocument.h"
 #include "JSLocation.h"
+#include "JSTouch.h"
+#include "JSTouchList.h"
 #include "Location.h"
 #include "ScriptController.h"
+#include "TouchList.h"
 
 #if ENABLE(SVG)
 #include "JSSVGDocument.h"
@@ -124,4 +127,16 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Document* documen
     return wrapper;
 }
 
+#if ENABLE(TOUCH_EVENTS)
+JSValue JSDocument::createTouchList(ExecState* exec)
+{
+    RefPtr<TouchList> touchList = TouchList::create();
+
+    for (int i = 0; i < exec->argumentCount(); i++)
+        touchList->append(toTouch(exec->argument(i)));
+
+    return toJS(exec, touchList.release());
+}
+#endif
+
 } // namespace WebCore
index 9fa9f809a7c4d85fc58f6d0329d19f0e2ab586a0..cda07373c12f639d94a16956c7d9da694e8fb782 100644 (file)
@@ -35,6 +35,7 @@
 #include "Document.h"
 #include "ExceptionCode.h"
 #include "Node.h"
+#include "TouchList.h"
 #include "XPathNSResolver.h"
 #include "XPathResult.h"
 
@@ -46,6 +47,8 @@
 #include "V8IsolatedContext.h"
 #include "V8Node.h"
 #include "V8Proxy.h"
+#include "V8Touch.h"
+#include "V8TouchList.h"
 #if ENABLE(3D_CANVAS)
 #include "V8WebGLRenderingContext.h"
 #endif
@@ -163,4 +166,19 @@ v8::Handle<v8::Value> toV8(Document* impl, bool forceNewObject)
     return wrapper;
 }
 
+#if ENABLE(TOUCH_EVENTS)
+v8::Handle<v8::Value> V8Document::createTouchListCallback(const v8::Arguments& args)
+{
+    RefPtr<TouchList> touchList = TouchList::create();
+
+    for (int i = 0; i < args.Length(); i++) {
+        if (!args[i]->IsObject())
+            return v8::Undefined();
+        touchList->append(V8Touch::toNative(args[i]->ToObject()));
+    }
+
+    return toV8(touchList.release());
+}
+#endif
+
 } // namespace WebCore
index 89f53ec89b473ddb2392f7e756696e047e307be2..8d7a71ba120620d56c88e7906c1a801e833a5d3b 100644 (file)
@@ -333,7 +333,7 @@ module core {
                                                          in long ScreenX,
                                                          in long screenY)
             raises (DOMException);
-        [ReturnsNew, EnabledAtRuntime] TouchList createTouchList()
+        [ReturnsNew, EnabledAtRuntime, Custom] TouchList createTouchList()
             raises (DOMException);
 #endif
 
index 88d3e6fa3f022eb4c635cd8d22f77f2e89914bcc..225e3aef5574a0045c2a721d81162c1b7349be21 100644 (file)
@@ -61,6 +61,9 @@ void TouchEvent::initTouchEvent(TouchList* touches, TouchList* targetTouches,
 
     initUIEvent(type, true, true, view, 0);
 
+    m_touches = touches;
+    m_targetTouches = targetTouches;
+    m_changedTouches = changedTouches;
     m_screenX = screenX;
     m_screenY = screenY;
     m_ctrlKey = ctrlKey;