LayoutTests:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Aug 2006 04:22:22 +0000 (04:22 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Aug 2006 04:22:22 +0000 (04:22 +0000)
        Reviewed by Darin.

        - added a test to check keyboard events fired from the ObjC API:
          http://bugzilla.opendarwin.org/show_bug.cgi?id=9736

        * fast/events/objc-keyboard-event-creation-expected.txt: Added.
        * fast/events/objc-keyboard-event-creation.html: Added.

WebCore:

        Reviewed by Darin.

        - added ObjC wrappers for the KeyboardEvent and WheelEvent initializers
          http://bugzilla.opendarwin.org/show_bug.cgi?id=9736

        * bindings/objc/DOMEvents.mm:
        (-[DOMKeyboardEvent initKeyboardEvent::::::::::]):
        * bindings/objc/DOMEventsNonstandard.mm:
        (-[DOMWheelEvent initWheelEvent:::::::::::]):
        * bindings/objc/DOMPrivate.h:

        - added an initializer for the WheelEvent

        * dom/WheelEvent.cpp:
        (WebCore::WheelEvent::initWheelEvent):
        * dom/WheelEvent.h:

WebKitTools:

        Reviewed by Darin.

        - added a function to create a few DOMKeyboardEvents and dispatch
          them to a specified HTML element
          http://bugzilla.opendarwin.org/show_bug.cgi?id=9736

        * DumpRenderTree/EventSendingController.m:
        (+[EventSendingController isSelectorExcludedFromWebScript:]):
        (+[EventSendingController webScriptNameForSelector:]):
        (-[EventSendingController fireKeyboardEventsToElement:]):

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

LayoutTests/ChangeLog
LayoutTests/fast/events/objc-keyboard-event-creation-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/objc-keyboard-event-creation.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bindings/objc/DOMEvents.mm
WebCore/bindings/objc/DOMEventsNonstandard.mm
WebCore/bindings/objc/DOMPrivate.h
WebCore/dom/WheelEvent.cpp
WebCore/dom/WheelEvent.h
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/EventSendingController.m

index 88d76823e121cf859f4ed984f5bbe842f1da2d9e..d2ce7c8641782239be999c0f6a9948a147072dbf 100644 (file)
@@ -1,3 +1,13 @@
+2006-08-15  Jonas Witt <jonas.witt@gmail.com>
+
+        Reviewed by Darin.
+
+        - added a test to check keyboard events fired from the ObjC API:
+          http://bugzilla.opendarwin.org/show_bug.cgi?id=9736
+
+        * fast/events/objc-keyboard-event-creation-expected.txt: Added.
+        * fast/events/objc-keyboard-event-creation.html: Added.
+
 2006-08-15  Geoffrey Garen  <ggaren@apple.com>
 
         Layout test for <rdar://problem/4661982> (crash in KHTMLParser::popBlock)
diff --git a/LayoutTests/fast/events/objc-keyboard-event-creation-expected.txt b/LayoutTests/fast/events/objc-keyboard-event-creation-expected.txt
new file mode 100644 (file)
index 0000000..a8f18e5
--- /dev/null
@@ -0,0 +1,9 @@
+This tests that DOMKeyboardEvents are created correctly in the ObjC API. See bug 9736.
+
+keydown - key: U+000041@0 (keyCode/charCode: 0/0) modifiers: true,false,false,false
+
+keypress - key: U+000045@1 (keyCode/charCode: 0/0) modifiers: false,true,false,false
+
+keyup - key: U+000056@0 (keyCode/charCode: 0/0) modifiers: false,false,false,false
+
+
diff --git a/LayoutTests/fast/events/objc-keyboard-event-creation.html b/LayoutTests/fast/events/objc-keyboard-event-creation.html
new file mode 100644 (file)
index 0000000..9afccf1
--- /dev/null
@@ -0,0 +1,34 @@
+<html>
+<head>
+<script>
+
+function keyevent(event) {
+    var p = document.createElement("p");
+    p.appendChild(document.createTextNode(event.type + " - key: " + event.keyIdentifier + "@" + event.keyLocation + " (keyCode/charCode: " + event.keyCode + "/" + event.charCode + ")" + " modifiers: " + event.ctrlKey + "," + event.altKey + "," + event.shiftKey + "," + event.metaKey));
+    document.getElementById("result").appendChild(p);
+}
+
+function init() {
+    var input = document.getElementById("testinput");
+    input.addEventListener("keydown", keyevent, true);
+    input.addEventListener("keypress", keyevent, true);
+    input.addEventListener("keyup", keyevent, true);
+   
+    if (layoutTestController)
+        layoutTestController.dumpAsText();
+    
+    if (eventSender)
+        eventSender.fireKeyboardEventsToElement(input);
+}
+</script>
+</head>
+<body onload="init()">
+    <form>
+        <input type="text" size="50" id="testinput" />
+    </form>
+   
+    <p>This tests that DOMKeyboardEvents are created correctly in the ObjC API. See bug <a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=9736">9736</a>.</p>
+   
+    <div id="result"></div>
+</body>
+</html>
index dc2e9930009de3521c9a03b57e838bed84674618..58de99072dae916fc22a918c96c3a4019b6a5d01 100644 (file)
@@ -1,3 +1,22 @@
+2006-08-15  Jonas Witt <jonas.witt@gmail.com>
+
+        Reviewed by Darin.
+
+        - added ObjC wrappers for the KeyboardEvent and WheelEvent initializers
+          http://bugzilla.opendarwin.org/show_bug.cgi?id=9736
+
+        * bindings/objc/DOMEvents.mm:
+        (-[DOMKeyboardEvent initKeyboardEvent::::::::::]):
+        * bindings/objc/DOMEventsNonstandard.mm:
+        (-[DOMWheelEvent initWheelEvent:::::::::::]):
+        * bindings/objc/DOMPrivate.h:
+
+        - added an initializer for the WheelEvent
+
+        * dom/WheelEvent.cpp:
+        (WebCore::WheelEvent::initWheelEvent):
+        * dom/WheelEvent.h:
+
 2006-08-15  Mark Rowe  <opendarwin.org@bdash.net.nz>
 
         Reviewed by Tim H.
index 320bbdce70a758d06c6b7287222738d3dd3232be..1eb937c6d00c339eed80d577174cb381f19b72db 100644 (file)
@@ -213,6 +213,11 @@ ALLOW_DOM_CAST(Event)
     return NO;
 }
 
+- (void)initKeyboardEvent:(NSString *)typeArg :(BOOL)canBubbleArg :(BOOL)cancelableArg :(DOMAbstractView *)viewArg :(NSString *)keyIdentifierArg :(unsigned)keyLocationArg :(BOOL)ctrlKeyArg :(BOOL)altKeyArg :(BOOL)shiftKeyArg :(BOOL)metaKeyArg {
+    [self _keyboardEvent]->initKeyboardEvent(typeArg, canBubbleArg, cancelableArg,
+        [viewArg _abstractView], keyIdentifierArg, keyLocationArg, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, false);
+}
+
 @end
 
 @implementation DOMMouseEvent
index a53f25c8cfd3788898a280d78b9ea877003bdb36..c1ac617012cc252d6dcc3e9cae5010d1a45b4e44 100644 (file)
@@ -28,6 +28,7 @@
 #import "DOMPrivate.h"
 
 #import "DOMEventsInternal.h"
+#import "DOMViewsInternal.h"
 #import "DOMInternal.h"
 #import "KeyboardEvent.h"
 #import "WheelEvent.h"
@@ -91,6 +92,13 @@ ALLOW_DOM_CAST(Event)
     return [self _wheelEvent]->wheelDelta();
 }
 
+- (void)initWheelEvent:(BOOL)horizontal :(int)wheelDelta :(DOMAbstractView *)viewArg :(int)screenXArg :(int)screenYArg :(int)clientX :(int)clientY :(BOOL)ctrlKeyArg :(BOOL)altKeyArg :(BOOL)shiftKeyArg :(BOOL)metaKeyArg
+{
+    [self _wheelEvent]->initWheelEvent(horizontal, wheelDelta, [viewArg _abstractView], 
+        screenXArg, screenYArg, clientX, clientY,
+        ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg);
+}
+
 @end
 
 @implementation DOMKeyboardEvent (NonStandardAdditions)
index ca15a91dd05bb63d84ef2206b8426da3347a714e..1f5d36f93436a8b82ae414b7687f6c8ed46f7217 100644 (file)
 @interface DOMHTMLSelectElement(FormsAutoFillTransition)
 - (void)_activateItemAtIndex:(int)index;
 @end
+
+@interface DOMKeyboardEvent(PublicPending)
+- (void)initKeyboardEvent:(NSString *)typeArg :(BOOL)canBubbleArg :(BOOL)cancelableArg :(DOMAbstractView *)viewArg :(NSString *)keyIdentifierArg :(unsigned)keyLocationArg :(BOOL)ctrlKeyArg :(BOOL)altKeyArg :(BOOL)shiftKeyArg :(BOOL)metaKeyArg;
+@end
+
+@interface DOMWheelEvent(PublicPending)
+- (void)initWheelEvent:(BOOL)horizontal :(int)wheelDelta :(DOMAbstractView *)viewArg :(int)screenXArg :(int)screenYArg :(int)clientX :(int)clientY :(BOOL)ctrlKeyArg :(BOOL)altKeyArg :(BOOL)shiftKeyArg :(BOOL)metaKeyArg;
+@end
+
index 737d2d1f4082df0f429af5f66908c9bfc5f13d04..6eabed46fe201a29d617590880d399d347f3579b 100644 (file)
@@ -48,6 +48,29 @@ WheelEvent::WheelEvent(bool horizontal, int wheelDelta, AbstractView* view,
 {
 }
 
+void WheelEvent::initWheelEvent(bool horizontal, int wheelDelta, AbstractView* view,
+                                int screenX, int screenY, int pageX, int pageY,
+                                bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
+{
+    if (dispatched())
+        return;
+    
+    initUIEvent(horizontal ? khtmlHorizontalmousewheelEvent : mousewheelEvent, 
+                true, true, view, 0);
+    
+    m_screenX = screenX;
+    m_screenY = screenY;
+    m_ctrlKey = ctrlKey;
+    m_altKey = altKey;
+    m_shiftKey = shiftKey;
+    m_metaKey = metaKey;
+    m_horizontal = horizontal;
+    m_wheelDelta = wheelDelta;
+    
+    initCoordinates(pageX, pageY);
+}
+
+
 bool WheelEvent::isWheelEvent() const
 {
     return true;
index c485838b58a49aac335b45b34aeac049d41cfbd2..4f2da2d690a2bee1004d29409aa98e0876f0a3e6 100644 (file)
@@ -37,6 +37,10 @@ namespace WebCore {
         WheelEvent(bool horizontal, int wheelDelta, AbstractView*,
                    int screenX, int screenY, int pageX, int pageY,
                    bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
+
+        void initWheelEvent(bool horizontal, int wheelDelta, AbstractView*,
+                            int screenX, int screenY, int pageX, int pageY,
+                            bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
         
         bool isHorizontal() const { return m_horizontal; }
         int wheelDelta() const { return m_wheelDelta; }
index 7cd8ab1adcfd23b8716cb06316a51e1a8fd8d6d3..1b72b3fbe21de8b142b51f31ed09a1cd922c72a1 100644 (file)
@@ -1,3 +1,16 @@
+2006-08-15  Jonas Witt <jonas.witt@gmail.com>
+
+        Reviewed by Darin.
+
+        - added a function to create a few DOMKeyboardEvents and dispatch
+          them to a specified HTML element
+          http://bugzilla.opendarwin.org/show_bug.cgi?id=9736
+
+        * DumpRenderTree/EventSendingController.m:
+        (+[EventSendingController isSelectorExcludedFromWebScript:]):
+        (+[EventSendingController webScriptNameForSelector:]):
+        (-[EventSendingController fireKeyboardEventsToElement:]):
+
 2006-08-15  Duncan Wilcox  <duncan@mclink.it>
 
         Reviewed and tweaked by Darin.
index 80e50ff1918fd6266cd4ad69a50dbda0380d72cd..9b0b2cc3c13edb4066507cf6448820898cf73219 100644 (file)
@@ -99,7 +99,8 @@ NSArray *webkitDomEventNames;
             || aSelector == @selector(mouseMoveToX:Y:)
             || aSelector == @selector(leapForward:)
             || aSelector == @selector(keyDown:withModifiers:)
-            || aSelector == @selector(enableDOMUIEventLogging:))
+            || aSelector == @selector(enableDOMUIEventLogging:)
+            || aSelector == @selector(fireKeyboardEventsToElement:))
         return NO;
     return YES;
 }
@@ -114,6 +115,8 @@ NSArray *webkitDomEventNames;
         return @"keyDown";
     if (aSelector == @selector(enableDOMUIEventLogging:))
         return @"enableDOMUIEventLogging";
+    if (aSelector == @selector(fireKeyboardEventsToElement:))
+        return @"fireKeyboardEventsToElement";
     return nil;
 }
 
@@ -379,4 +382,36 @@ NSArray *webkitDomEventNames;
     }
 }
 
+// FIXME: It's not good to have a test hard-wired into this controller like this.
+// Instead we need to get testing framework based on the Objective-C bindings
+// to work well enough that we can test that way instead.
+- (void)fireKeyboardEventsToElement:(WebScriptObject *)element {
+    
+    if (![element isKindOfClass:[DOMHTMLElement class]]) {
+        return;
+    }
+    
+    DOMHTMLElement *target = (DOMHTMLElement*)element;
+    DOMDocument *document = [target ownerDocument];
+    
+    // Keyboard Event 1
+    
+    DOMEvent *domEvent = [document createEvent:@"KeyboardEvent"];
+    [(DOMKeyboardEvent*)domEvent initKeyboardEvent:@"keydown" :YES :YES :[document defaultView] :@"U+000041" :0 :YES :NO :NO :NO];
+    [target dispatchEvent:domEvent];  
+        
+    // Keyboard Event 2
+    
+    domEvent = [document createEvent:@"KeyboardEvent"];
+    [(DOMKeyboardEvent*)domEvent initKeyboardEvent:@"keypress" :YES :YES :[document defaultView] :@"U+000045" :1 :NO :YES :NO :NO];
+    [target dispatchEvent:domEvent];    
+    
+    // Keyboard Event 3
+    
+    domEvent = [document createEvent:@"KeyboardEvent"];
+    [(DOMKeyboardEvent*)domEvent initKeyboardEvent:@"keyup" :YES :YES :[document defaultView] :@"U+000056" :0 :NO :NO :NO :NO];
+    [target dispatchEvent:domEvent];   
+    
+}
+
 @end