+2006-06-24 Jonas Witt <jonas.witt@gmail.com>
+
+ Reviewed by ggaren, landed by ap.
+
+ - test that DOMEvents are correctly handed to the ObjC API
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=9181
+
+ * fast/events/objc-event-api-expected.txt: Added.
+ * fast/events/objc-event-api.html: Added.
+
2006-06-23 Tim Omernick <timo@apple.com>
Reviewed by Tim Hatcher.
--- /dev/null
+event type: mouseover
+ target: <div>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 0
+ view: OK (document: OK)
+ button: 0
+ screenX: -9900
+ screenY: 10268
+ clientX: 100
+ clientY: 100
+ modifier keys: c:0 s:0 a:0 m:0
+event type: mousedown
+ target: <div>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 1
+ view: OK (document: OK)
+ button: 0
+ screenX: -9900
+ screenY: 10268
+ clientX: 100
+ clientY: 100
+ modifier keys: c:0 s:0 a:0 m:0
+event type: selectstart
+ target: <div>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+event type: mouseup
+ target: <div>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 1
+ view: OK (document: OK)
+ button: 0
+ screenX: -9900
+ screenY: 10268
+ clientX: 100
+ clientY: 100
+ modifier keys: c:0 s:0 a:0 m:0
+event type: click
+ target: <div>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 1
+ view: OK (document: OK)
+ button: 0
+ screenX: -9900
+ screenY: 10268
+ clientX: 100
+ clientY: 100
+ modifier keys: c:0 s:0 a:0 m:0
+event type: keydown
+ target: <body>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 0
+ view: OK (document: OK)
+ keyIdentifier: U+000041
+ keyLocation: 0
+ modifier keys: c:0 s:0 a:0 m:0
+ keyCode: 65
+ charCode: 97
+event type: keypress
+ target: <body>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 0
+ view: OK (document: OK)
+ keyIdentifier: U+000041
+ keyLocation: 0
+ modifier keys: c:0 s:0 a:0 m:0
+ keyCode: 97
+ charCode: 97
+event type: keydown
+ target: <body>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 0
+ view: OK (document: OK)
+ keyIdentifier: U+000042
+ keyLocation: 0
+ modifier keys: c:1 s:0 a:0 m:0
+ keyCode: 66
+ charCode: 98
+event type: keypress
+ target: <body>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 0
+ view: OK (document: OK)
+ keyIdentifier: U+000042
+ keyLocation: 0
+ modifier keys: c:1 s:0 a:0 m:0
+ keyCode: 98
+ charCode: 98
+event type: keydown
+ target: <body>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 0
+ view: OK (document: OK)
+ keyIdentifier: U+000044
+ keyLocation: 0
+ modifier keys: c:0 s:1 a:0 m:0
+ keyCode: 68
+ charCode: 100
+event type: keypress
+ target: <body>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 0
+ view: OK (document: OK)
+ keyIdentifier: U+000044
+ keyLocation: 0
+ modifier keys: c:0 s:1 a:0 m:0
+ keyCode: 100
+ charCode: 100
+event type: keydown
+ target: <body>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 0
+ view: OK (document: OK)
+ keyIdentifier: U+000045
+ keyLocation: 0
+ modifier keys: c:0 s:0 a:1 m:1
+ keyCode: 69
+ charCode: 101
+event type: keypress
+ target: <body>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 0
+ view: OK (document: OK)
+ keyIdentifier: U+000045
+ keyLocation: 0
+ modifier keys: c:0 s:0 a:1 m:1
+ keyCode: 101
+ charCode: 101
+event type: mousemove
+ target: <div>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 0
+ detail: 0
+ view: OK (document: OK)
+ button: 0
+ screenX: -9600
+ screenY: 10318
+ clientX: 400
+ clientY: 150
+ modifier keys: c:0 s:0 a:0 m:0
+event type: mousedown
+ target: <div>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 2
+ view: OK (document: OK)
+ button: 0
+ screenX: -9600
+ screenY: 10318
+ clientX: 400
+ clientY: 150
+ modifier keys: c:0 s:0 a:0 m:0
+event type: selectstart
+ target: <div>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 0 of P > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+event type: mousedown
+ target: <div>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 3
+ view: OK (document: OK)
+ button: 0
+ screenX: -9600
+ screenY: 10318
+ clientX: 400
+ clientY: 150
+ modifier keys: c:0 s:0 a:0 m:0
+event type: selectstart
+ target: <div>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 0 of P > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 0 of P > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+event type: mouseout
+ target: <div>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 0
+ view: OK (document: OK)
+ button: 0
+ screenX: -9999
+ screenY: 10169
+ clientX: 1
+ clientY: 1
+ modifier keys: c:0 s:0 a:0 m:0
+ relatedTarget: DOMHTMLHtmlElement (nodeName: HTML)
+event type: mouseover
+ target: <html>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 0
+ view: OK (document: OK)
+ button: 0
+ screenX: -9999
+ screenY: 10169
+ clientX: 1
+ clientY: 1
+ modifier keys: c:0 s:0 a:0 m:0
+ relatedTarget: DOMHTMLDivElement (nodeName: DIV)
+event type: mousemove
+ target: <html>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 0
+ detail: 0
+ view: OK (document: OK)
+ button: 0
+ screenX: -9999
+ screenY: 10169
+ clientX: 1
+ clientY: 1
+ modifier keys: c:0 s:0 a:0 m:0
+event type: selectstart
+ target: <html>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 0 of P > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 0 of P > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+event type: mouseup
+ target: <html>
+ eventPhase: 3
+ bubbles: 1
+ cancelable: 1
+ detail: 0
+ view: OK (document: OK)
+ button: 0
+ screenX: -9999
+ screenY: 10169
+ clientX: 1
+ clientY: 1
+ modifier keys: c:0 s:0 a:0 m:0
+Test
+This tests that DOMEvents are correctly handed to the ObjC API. See bug 9181.
+
+
--- /dev/null
+<html>
+<head>
+<script>
+function init() {
+ if (eventSender) {
+ layoutTestController.dumpAsText();
+
+ eventSender.mouseMoveTo(1,1);
+ eventSender.enableDOMUIEventLogging(document);
+
+ eventSender.mouseMoveTo(100,100);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.keyDown("a", "");
+ eventSender.keyDown("b", ["ctrlKey"]);
+ eventSender.keyDown("d", ["shiftKey"]);
+ eventSender.keyDown("e", ["altKey", "metaKey"]);
+
+ eventSender.mouseMoveTo(400,150);
+ eventSender.mouseClick();
+
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(1,1);
+ eventSender.mouseUp();
+ }
+}
+</script>
+</head>
+<body onload="init()">
+ <div id="clicktest" style="width: 300px; height: 200px; background-color: #8ad; text-align: center; padding: 50px;">Test</div>
+
+ <p>This tests that DOMEvents are correctly handed to the ObjC API. See bug <a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=9181">9181</a>.</p>
+</body>
+</html>
+2006-06-24 Jonas Witt <jonas.witt@gmail.com>
+
+ Reviewed by ggaren, landed by ap.
+
+ - http://bugzilla.opendarwin.org/show_bug.cgi?id=9181
+ Complete DOMUIEvent Obj-C API to reflect UIEvent
+
+ * WebCore.exp: add new classes DOMKeyboardEvent and DOMWheelEvent to the exported
+ symbols list of WebCore.framework
+
+ Updated DOMUIEvent to include all DOM Level 2 properties
+ Added DOMKeyboardEvent (DOM Level 3)
+ Added two non-W3C accessors (keyCode, charCode) of DOMKeyboardEvent to a separate file (DOMEventsNonstandard)
+ Added DOMWheelEvent (non-W3C) in separate file (DOMEventsNonstandard)
+ Added this file (DOMEventsNonstandard) to the build process
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/objc/DOM.h:
+ * bindings/objc/DOMEvents.h:
+ * bindings/objc/DOMEvents.mm:
+ (+[DOMEvent _eventWith:]):
+ (-[DOMUIEvent _UIEvent]):
+ (-[DOMUIEvent view]):
+ (-[DOMUIEvent detail]):
+ (-[DOMUIEvent initUIEvent:::::]):
+ (-[DOMKeyboardEvent _keyboardEvent]):
+ (-[DOMKeyboardEvent keyIdentifier]):
+ (-[DOMKeyboardEvent keyLocation]):
+ (-[DOMKeyboardEvent ctrlKey]):
+ (-[DOMKeyboardEvent shiftKey]):
+ (-[DOMKeyboardEvent altKey]):
+ (-[DOMKeyboardEvent metaKey]):
+ (-[DOMKeyboardEvent getModifierState:]):
+ (-[DOMMouseEvent button]):
+ * bindings/objc/DOMEventsNonstandard.mm: Added.
+ (-[DOMWheelEvent _wheelEvent]):
+ (-[DOMWheelEvent screenX]):
+ (-[DOMWheelEvent screenY]):
+ (-[DOMWheelEvent clientX]):
+ (-[DOMWheelEvent clientY]):
+ (-[DOMWheelEvent ctrlKey]):
+ (-[DOMWheelEvent shiftKey]):
+ (-[DOMWheelEvent altKey]):
+ (-[DOMWheelEvent metaKey]):
+ (-[DOMWheelEvent isHorizontal]):
+ (-[DOMWheelEvent wheelDelta]):
+ (-[DOMKeyboardEvent _keyboardEvent]):
+ (-[DOMKeyboardEvent keyCode]):
+ (-[DOMKeyboardEvent charCode]):
+ * bindings/objc/DOMPrivate.h:
+
2006-06-24 Mitz Pettel <opendarwin.org@mitzpettel.com>
Reviewed and landed by ap.
.objc_class_name_DOMHTMLTitleElement
.objc_class_name_DOMHTMLUListElement
.objc_class_name_DOMImplementation
+.objc_class_name_DOMKeyboardEvent
.objc_class_name_DOMMediaList
.objc_class_name_DOMMouseEvent
.objc_class_name_DOMMutationEvent
.objc_class_name_DOMText
.objc_class_name_DOMTreeWalker
.objc_class_name_DOMUIEvent
+.objc_class_name_DOMWheelEvent
.objc_class_name_WebCoreCache
.objc_class_name_WebCoreEncodings
.objc_class_name_WebCoreFileButton
D0B0556909C6700100307E43 /* CreateLinkCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0B0556709C6700100307E43 /* CreateLinkCommand.cpp */; };
DD763BB20992C2C900740B8E /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = DD763BB10992C2C900740B8E /* libxml2.dylib */; };
DD7CDF250A23CF9800069928 /* CSSUnknownRule.h in Headers */ = {isa = PBXBuildFile; fileRef = A80E6CCE0A1989CA007FB8C5 /* CSSUnknownRule.h */; };
+ E1052C320A4D70010072D99B /* DOMEventsNonstandard.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1052C310A4D70010072D99B /* DOMEventsNonstandard.mm */; };
E1EE773708F1086C00166870 /* WebCoreTextDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE773508F1086C00166870 /* WebCoreTextDecoder.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1EE773808F1086C00166870 /* WebCoreTextDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1EE773608F1086C00166870 /* WebCoreTextDecoder.mm */; };
E1F0424609839389006694EA /* xmlhttprequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F0424409839389006694EA /* xmlhttprequest.cpp */; };
D0B0556609C6700100307E43 /* CreateLinkCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CreateLinkCommand.h; sourceTree = "<group>"; };
D0B0556709C6700100307E43 /* CreateLinkCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CreateLinkCommand.cpp; sourceTree = "<group>"; };
DD763BB10992C2C900740B8E /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = /usr/lib/libxml2.dylib; sourceTree = "<absolute>"; };
+ E1052C310A4D70010072D99B /* DOMEventsNonstandard.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMEventsNonstandard.mm; sourceTree = "<group>"; };
E1EE773508F1086C00166870 /* WebCoreTextDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreTextDecoder.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
E1EE773608F1086C00166870 /* WebCoreTextDecoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreTextDecoder.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
E1F0424409839389006694EA /* xmlhttprequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xmlhttprequest.cpp; sourceTree = "<group>"; };
BC1A379B097C715F0019F3D8 /* DOMCSS.mm */,
BC1A379C097C715F0019F3D8 /* DOMEvents.h */,
BC1A379D097C715F0019F3D8 /* DOMEvents.mm */,
+ E1052C310A4D70010072D99B /* DOMEventsNonstandard.mm */,
BC1A379E097C715F0019F3D8 /* DOMEventsInternal.h */,
BC1A379F097C715F0019F3D8 /* DOMExtensions.h */,
BC1A37A0097C715F0019F3D8 /* DOMHTML.h */,
85031B500A44EFC700F992E0 /* WheelEvent.cpp in Sources */,
ABE7B5230A489F830031881C /* DeprecatedRenderSelect.cpp in Sources */,
51F11E150A48C2920034A24E /* SQLTransaction.cpp in Sources */,
+ E1052C320A4D70010072D99B /* DOMEventsNonstandard.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/*
* Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2006 Jonas Witt <jonas.witt@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#import "DOMEventsInternal.h"
#import "DOMInternal.h"
+#import "DOMPrivate.h"
#import "DOMViewsInternal.h"
#import "Document.h"
#import "Event.h"
#import "MouseEvent.h"
+#import "KeyboardEvent.h"
#import "MutationEvent.h"
#import "UIEvent.h"
ALLOW_DOM_CAST(Event)
+@class DOMWheelEvent;
+
@implementation DOMEvent
- (NSString *)type
return [[cachedInstance retain] autorelease];
Class wrapperClass = nil;
- if (impl->isMouseEvent()) {
+ if (impl->isWheelEvent()) {
+ wrapperClass = [DOMWheelEvent class];
+ } else if (impl->isMouseEvent()) {
wrapperClass = [DOMMouseEvent class];
} else if (impl->isMutationEvent()) {
wrapperClass = [DOMMutationEvent class];
+ } else if (impl->isKeyboardEvent()) {
+ wrapperClass = [DOMKeyboardEvent class];
} else if (impl->isUIEvent()) {
wrapperClass = [DOMUIEvent class];
} else {
@end
+@implementation DOMKeyboardEvent
+
+- (KeyboardEvent *)_keyboardEvent
+{
+ return static_cast<KeyboardEvent *>(DOM_cast<Event *>(_internal));
+}
+
+- (NSString*)keyIdentifier
+{
+ return (NSString *) [self _keyboardEvent]->keyIdentifier();
+}
+
+- (unsigned)keyLocation
+{
+ return [self _keyboardEvent]->keyLocation();
+}
+
+- (BOOL)ctrlKey
+{
+ return [self _keyboardEvent]->ctrlKey();
+}
+
+- (BOOL)shiftKey
+{
+ return [self _keyboardEvent]->shiftKey();
+}
+
+- (BOOL)altKey
+{
+ return [self _keyboardEvent]->altKey();
+}
+
+- (BOOL)metaKey
+{
+ return [self _keyboardEvent]->metaKey();
+}
+
+- (BOOL)getModifierState:(NSString *)keyIdentifierArg
+{
+ if ([keyIdentifierArg isEqualToString:@"Control"] && [self ctrlKey])
+ return YES;
+ if ([keyIdentifierArg isEqualToString:@"Shift"] && [self shiftKey])
+ return YES;
+ if ([keyIdentifierArg isEqualToString:@"Alt"] && [self altKey])
+ return YES;
+ if ([keyIdentifierArg isEqualToString:@"Meta"] && [self metaKey])
+ return YES;
+ return NO;
+}
+
+@end
+
@implementation DOMMouseEvent
- (MouseEvent *)_mouseEvent
--- /dev/null
+/*
+ * Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2006 Jonas Witt <jonas.witt@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "DOMPrivate.h"
+
+#import "DOMEventsInternal.h"
+#import "DOMInternal.h"
+#import "KeyboardEvent.h"
+#import "WheelEvent.h"
+
+using namespace WebCore;
+
+ALLOW_DOM_CAST(Event)
+
+@implementation DOMWheelEvent
+
+- (WheelEvent *)_wheelEvent
+{
+ return static_cast<WheelEvent *>(DOM_cast<Event *>(_internal));
+}
+
+- (int)screenX
+{
+ return [self _wheelEvent]->screenX();
+}
+
+- (int)screenY
+{
+ return [self _wheelEvent]->screenY();
+}
+
+- (int)clientX
+{
+ return [self _wheelEvent]->clientX();
+}
+
+- (int)clientY
+{
+ return [self _wheelEvent]->clientY();
+}
+
+- (BOOL)ctrlKey
+{
+ return [self _wheelEvent]->ctrlKey();
+}
+
+- (BOOL)shiftKey
+{
+ return [self _wheelEvent]->shiftKey();
+}
+
+- (BOOL)altKey {
+ return [self _wheelEvent]->altKey();
+}
+
+- (BOOL)metaKey {
+ return [self _wheelEvent]->metaKey();
+}
+
+- (BOOL)isHorizontal
+{
+ return [self _wheelEvent]->isHorizontal();
+}
+
+- (int)wheelDelta
+{
+ return [self _wheelEvent]->wheelDelta();
+}
+
+@end
+
+@implementation DOMKeyboardEvent (NonStandardAdditions)
+
+- (KeyboardEvent *)_keyboardEvent
+{
+ return static_cast<KeyboardEvent *>(DOM_cast<Event *>(_internal));
+}
+
+- (int)keyCode
+{
+ return [self _keyboardEvent]->keyCode();
+}
+
+- (int)charCode
+{
+ return [self _keyboardEvent]->charCode();
+}
+
+@end
#import <WebCore/DOMCSS.h>
#import <WebCore/DOMHTML.h>
#import <WebCore/DOMRange.h>
+#import <WebCore/DOMEvents.h>
@interface DOMRange (WebPrivate)
// uses same algorithm as innerText
- (DOMHTMLDocument *)createHTMLDocument:(NSString *)title;
@end
+enum {
+ DOM_KEY_LOCATION_STANDARD = 0x00,
+ DOM_KEY_LOCATION_LEFT = 0x01,
+ DOM_KEY_LOCATION_RIGHT = 0x02,
+ DOM_KEY_LOCATION_NUMPAD = 0x03,
+};
+
+@interface DOMKeyboardEvent : DOMUIEvent
+- (NSString*)keyIdentifier;
+- (unsigned)keyLocation;
+- (BOOL)ctrlKey;
+- (BOOL)shiftKey;
+- (BOOL)altKey;
+- (BOOL)metaKey;
+- (BOOL)getModifierState:(NSString *)keyIdentifierArg;
+@end
+
+@interface DOMKeyboardEvent (NonStandardAdditions)
+- (int)keyCode;
+- (int)charCode;
+@end
+
+@interface DOMWheelEvent : DOMUIEvent
+- (int)screenX;
+- (int)screenY;
+- (int)clientX;
+- (int)clientY;
+- (BOOL)ctrlKey;
+- (BOOL)shiftKey;
+- (BOOL)altKey;
+- (BOOL)metaKey;
+- (BOOL)isHorizontal;
+- (int)wheelDelta;
+@end
+
// END
// Pending DOM3 APIs
+2006-06-24 Jonas Witt <jonas.witt@gmail.com>
+
+ Reviewed by ggaren, landed by ap.
+
+ - http://bugzilla.opendarwin.org/show_bug.cgi?id=9181
+ Complete DOMUIEvent Obj-C API to reflect UIEvent
+
+ Add function to enable logging of all events of one DOM node to stdout.
+
+ * DumpRenderTree/EventSendingController.h:
+ * DumpRenderTree/EventSendingController.m:
+ (+[EventSendingController initialize]):
+ (+[EventSendingController isSelectorExcludedFromWebScript:]):
+ (+[EventSendingController webScriptNameForSelector:]):
+ (-[EventSendingController enableDOMUIEventLogging:]):
+ (-[EventSendingController handleEvent:]):
+
2006-06-23 Kevin Decker <kdecker@apple.com>
Reviewed by Tim Hatcher.
22181BD009DC8C4B008342E8 /* ObjCPluginFunction.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = ObjCPluginFunction.m; sourceTree = "<group>"; };
32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumpRenderTreePrefix.h; sourceTree = "<group>"; };
9335435F03D75502008635CE /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
- 9340995408540CAF007F3BC8 /* DumpRenderTree */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = DumpRenderTree; sourceTree = BUILT_PRODUCTS_DIR; };
+ 9340995408540CAF007F3BC8 /* DumpRenderTree */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DumpRenderTree; sourceTree = BUILT_PRODUCTS_DIR; };
93442CF408F8BA4900BFE8CA /* TextInputController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputController.h; sourceTree = "<group>"; };
93442CF508F8BA4900BFE8CA /* TextInputController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextInputController.m; sourceTree = "<group>"; };
A803FCB709CAAAB0009B2A37 /* EventSendingController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EventSendingController.h; sourceTree = "<group>"; };
#import <Cocoa/Cocoa.h>
-@interface EventSendingController : NSObject {
+#import <WebKit/WebKit.h>
+
+@interface EventSendingController : NSObject <DOMEventListener> {
BOOL down;
int clickCount;
NSTimeInterval lastClick;
double timeOffset;
}
+- (void)enableDOMUIEventLogging:(WebScriptObject *)node;
+
+- (void)handleEvent:(DOMEvent *)event;
+
@end
extern NSPoint lastMousePosition;
/*
* Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2006 Jonas Witt <jonas.witt@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#import <Carbon/Carbon.h> // for GetCurrentEventTime()
#import <WebKit/WebKit.h>
+#import <WebKit/DOMPrivate.h>
NSPoint lastMousePosition;
+NSArray *webkitDomEventNames;
+NSArray *webkitDomEventProperties;
@implementation EventSendingController
++ (void)initialize {
+ webkitDomEventNames = [[NSArray alloc] initWithObjects:
+ @"abort",
+ @"beforecopy",
+ @"beforecut",
+ @"beforepaste",
+ @"blur",
+ @"change",
+ @"click",
+ @"contextmenu",
+ @"copy",
+ @"cut",
+ @"dblclick",
+ @"drag",
+ @"dragend",
+ @"dragenter",
+ @"dragleave",
+ @"dragover",
+ @"dragstart",
+ @"drop",
+ @"error",
+ @"focus",
+ @"input",
+ @"keydown",
+ @"keypress",
+ @"keyup",
+ @"load",
+ @"mousedown",
+ @"mousemove",
+ @"mouseout",
+ @"mouseover",
+ @"mouseup",
+ @"mousewheel",
+ @"beforeunload",
+ @"paste",
+ @"readystatechange",
+ @"reset",
+ @"resize",
+ @"scroll",
+ @"search",
+ @"select",
+ @"selectstart",
+ @"submit",
+ @"textInput",
+ @"unload",
+ @"zoom",
+ nil];
+
+ webkitDomEventProperties = [[NSArray alloc] initWithObjects:
+ @"clientX",
+ @"clientY",
+ nil];
+}
+
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
{
if (aSelector == @selector(mouseDown)
|| aSelector == @selector(mouseClick)
|| aSelector == @selector(mouseMoveToX:Y:)
|| aSelector == @selector(leapForward:)
- || aSelector == @selector(keyDown:withModifiers:))
+ || aSelector == @selector(keyDown:withModifiers:)
+ || aSelector == @selector(enableDOMUIEventLogging:))
return NO;
return YES;
}
return @"leapForward";
if (aSelector == @selector(keyDown:withModifiers:))
return @"keyDown";
+ if (aSelector == @selector(enableDOMUIEventLogging:))
+ return @"enableDOMUIEventLogging";
return nil;
}
}
}
+- (void)enableDOMUIEventLogging:(WebScriptObject *)node
+{
+ NSEnumerator *eventEnumerator = [webkitDomEventNames objectEnumerator];
+ id eventName;
+ while ((eventName = [eventEnumerator nextObject])) {
+ [(id<DOMEventTarget>)node addEventListener:eventName :self :NO];
+ }
+}
+
+- (void)handleEvent:(DOMEvent *)event
+{
+ DOMNode *target = [event target];
+
+ printf("event type: %s\n", [[event type] UTF8String]);
+ printf(" target: <%s>\n", [[[target nodeName] lowercaseString] UTF8String]);
+
+ if ([event isKindOfClass:[DOMEvent class]]) {
+ printf(" eventPhase: %d\n", [event eventPhase]);
+ printf(" bubbles: %d\n", [event bubbles] ? 1 : 0);
+ printf(" cancelable: %d\n", [event cancelable] ? 1 : 0);
+ }
+
+ if ([event isKindOfClass:[DOMUIEvent class]]) {
+ printf(" detail: %d\n", [(DOMUIEvent*)event detail]);
+
+ DOMAbstractView *view = [(DOMUIEvent*)event view];
+ if (view) {
+ printf(" view: OK");
+ if ([view document])
+ printf(" (document: OK)");
+ printf("\n");
+ }
+ }
+
+ if ([event isKindOfClass:[DOMKeyboardEvent class]]) {
+ printf(" keyIdentifier: %s\n", [[(DOMKeyboardEvent*)event keyIdentifier] UTF8String]);
+ printf(" keyLocation: %d\n", [(DOMKeyboardEvent*)event keyLocation]);
+ printf(" modifier keys: c:%d s:%d a:%d m:%d\n",
+ [(DOMKeyboardEvent*)event ctrlKey] ? 1 : 0,
+ [(DOMKeyboardEvent*)event shiftKey] ? 1 : 0,
+ [(DOMKeyboardEvent*)event altKey] ? 1 : 0,
+ [(DOMKeyboardEvent*)event metaKey] ? 1 : 0);
+ printf(" keyCode: %d\n", [(DOMKeyboardEvent*)event keyCode]);
+ printf(" charCode: %d\n", [(DOMKeyboardEvent*)event charCode]);
+ }
+
+ if ([event isKindOfClass:[DOMMouseEvent class]]) {
+ printf(" button: %d\n", [(DOMMouseEvent*)event button]);
+ printf(" screenX: %d\n", [(DOMMouseEvent*)event screenX]);
+ printf(" screenY: %d\n", [(DOMMouseEvent*)event screenY]);
+ printf(" clientX: %d\n", [(DOMMouseEvent*)event clientX]);
+ printf(" clientY: %d\n", [(DOMMouseEvent*)event clientY]);
+ printf(" modifier keys: c:%d s:%d a:%d m:%d\n",
+ [(DOMMouseEvent*)event ctrlKey] ? 1 : 0,
+ [(DOMMouseEvent*)event shiftKey] ? 1 : 0,
+ [(DOMMouseEvent*)event altKey] ? 1 : 0,
+ [(DOMMouseEvent*)event metaKey] ? 1 : 0);
+ id relatedTarget = [(DOMMouseEvent*)event relatedTarget];
+ if (relatedTarget) {
+ printf(" relatedTarget: %s", [[[relatedTarget class] description] UTF8String]);
+ if ([relatedTarget isKindOfClass:[DOMNode class]])
+ printf(" (nodeName: %s)", [[(DOMNode*)relatedTarget nodeName] UTF8String]);
+ printf("\n");
+ }
+ }
+
+ if ([event isKindOfClass:[DOMMutationEvent class]]) {
+ printf(" prevValue: %s\n", [[(DOMMutationEvent*)event prevValue] UTF8String]);
+ printf(" newValue: %s\n", [[(DOMMutationEvent*)event newValue] UTF8String]);
+ printf(" attrName: %s\n", [[(DOMMutationEvent*)event attrName] UTF8String]);
+ printf(" attrChange: %d\n", [(DOMMutationEvent*)event attrChange]);
+ DOMNode *relatedNode = [(DOMMutationEvent*)event relatedNode];
+ if (relatedNode) {
+ printf(" relatedNode: %s (nodeName: %s)\n",
+ [[[relatedNode class] description] UTF8String],
+ [[relatedNode nodeName] UTF8String]);
+ }
+ }
+
+ if ([event isKindOfClass:[DOMWheelEvent class]]) {
+ printf(" screenX: %d\n", [(DOMWheelEvent*)event screenX]);
+ printf(" screenY: %d\n", [(DOMWheelEvent*)event screenY]);
+ printf(" clientX: %d\n", [(DOMWheelEvent*)event clientX]);
+ printf(" clientY: %d\n", [(DOMWheelEvent*)event clientY]);
+ printf(" modifier keys: c:%d s:%d a:%d m:%d\n",
+ [(DOMWheelEvent*)event ctrlKey] ? 1 : 0,
+ [(DOMWheelEvent*)event shiftKey] ? 1 : 0,
+ [(DOMWheelEvent*)event altKey] ? 1 : 0,
+ [(DOMWheelEvent*)event metaKey] ? 1 : 0);
+ printf(" isHorizontal: %d\n", [(DOMWheelEvent*)event isHorizontal] ? 1 : 0);
+ printf(" wheelDelta: %d\n", [(DOMWheelEvent*)event wheelDelta]);
+ }
+}
+
@end