From ae2f706e781550da00a8440e44f20bbb7bd24c30 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Sun, 17 Oct 2010 16:26:08 +0100 Subject: Fix Webkit review comments for document.createTouch See WebKit bug https://bugs.webkit.org/show_bug.cgi?id=47676 for details. Change-Id: I232445c78d59ed3d13c9bcd86b9fa9590ffae552 --- .../fast/events/touch/document-create-touch-expected.txt | 7 +++++++ .../fast/events/touch/script-tests/document-create-touch.js | 10 ++++++++++ WebCore/dom/Document.cpp | 7 ++++++- WebCore/dom/Document.h | 2 +- WebCore/dom/Document.idl | 7 ++++--- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/LayoutTests/fast/events/touch/document-create-touch-expected.txt b/LayoutTests/fast/events/touch/document-create-touch-expected.txt index c1c647f..2bf33cb 100644 --- a/LayoutTests/fast/events/touch/document-create-touch-expected.txt +++ b/LayoutTests/fast/events/touch/document-create-touch-expected.txt @@ -18,6 +18,13 @@ PASS emptyTouch.pageX is 0 PASS emptyTouch.pageY is 0 PASS emptyTouch.screenX is 0 PASS emptyTouch.screenY is 0 +PASS badParamsTouch is non-null. +PASS badParamsTouch.target is null +PASS badParamsTouch.identifier is 0 +PASS badParamsTouch.pageX is 0 +PASS badParamsTouch.pageY is 0 +PASS badParamsTouch.screenX is 0 +PASS badParamsTouch.screenY is 104 PASS successfullyParsed is true TEST COMPLETE diff --git a/LayoutTests/fast/events/touch/script-tests/document-create-touch.js b/LayoutTests/fast/events/touch/script-tests/document-create-touch.js index dd383ac..c51c7e3 100644 --- a/LayoutTests/fast/events/touch/script-tests/document-create-touch.js +++ b/LayoutTests/fast/events/touch/script-tests/document-create-touch.js @@ -27,5 +27,15 @@ shouldBe("emptyTouch.pageY", "0"); shouldBe("emptyTouch.screenX", "0"); shouldBe("emptyTouch.screenY", "0"); +// Try invoking with incorrect parameter types. +var badParamsTouch = document.createTouch(function(x) { return x; }, 12, 'a', 'b', 'c', function(x) { return x; }, 104); +shouldBeNonNull("badParamsTouch"); +shouldBeNull("badParamsTouch.target"); +shouldBe("badParamsTouch.identifier", "0"); +shouldBe("badParamsTouch.pageX", "0"); +shouldBe("badParamsTouch.pageY", "0"); +shouldBe("badParamsTouch.screenX", "0"); +shouldBe("badParamsTouch.screenY", "104"); + successfullyParsed = true; isSuccessfullyParsed(); diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp index bffc07c..2ad8b50 100644 --- a/WebCore/dom/Document.cpp +++ b/WebCore/dom/Document.cpp @@ -4827,8 +4827,13 @@ void Document::decrementLoadEventDelayCount() } #if ENABLE(TOUCH_EVENTS) -PassRefPtr Document::createTouch(DOMWindow* window, Node* target, int identifier, int pageX, int pageY, int screenX, int screenY, ExceptionCode&) const +PassRefPtr Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, ExceptionCode&) const { + // FIXME: It's not clear from the documentation at + // http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html + // when this method should throw and nor is it by inspection of iOS behavior. It would be nice to verify any cases where it throws under iOS + // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=47819 + // Ditto for the createTouchList method below. Frame* frame = window ? window->frame() : this->frame(); return Touch::create(frame, target, identifier, screenX, screenY, pageX, pageY); } diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h index 41a486a..e119d40 100644 --- a/WebCore/dom/Document.h +++ b/WebCore/dom/Document.h @@ -1047,7 +1047,7 @@ public: bool isDelayingLoadEvent() const { return m_loadEventDelayCount; } #if ENABLE(TOUCH_EVENTS) - PassRefPtr createTouch(DOMWindow*, Node*, int identifier, int pageX, int pageY, int screenX, int screenY, ExceptionCode&) const; + PassRefPtr createTouch(DOMWindow*, EventTarget*, int identifier, int pageX, int pageY, int screenX, int screenY, ExceptionCode&) const; PassRefPtr createTouchList(ExceptionCode&) const; #endif diff --git a/WebCore/dom/Document.idl b/WebCore/dom/Document.idl index 02eb30d..f05a430 100644 --- a/WebCore/dom/Document.idl +++ b/WebCore/dom/Document.idl @@ -321,9 +321,12 @@ module core { attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchmove; attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchend; attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchcancel; + attribute [DontEnum, Conditional=FULLSCREEN_API] EventListener onwebkitfullscreenchange; +#endif + #if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS [ReturnsNew] Touch createTouch(in DOMWindow window, - in Node target, + in EventTarget target, in long identifier, in long pageX, in long pageY, @@ -333,8 +336,6 @@ module core { [ReturnsNew] TouchList createTouchList() raises (DOMException); #endif - attribute [DontEnum, Conditional=FULLSCREEN_API] EventListener onwebkitfullscreenchange; -#endif #if defined(LANGUAGE_CPP) && LANGUAGE_CPP // Extra WebCore methods exposed to allow compile-time casting in C++ -- cgit v1.1