Diff
Modified: trunk/LayoutTests/ChangeLog (136520 => 136521)
--- trunk/LayoutTests/ChangeLog 2012-12-04 17:58:44 UTC (rev 136520)
+++ trunk/LayoutTests/ChangeLog 2012-12-04 18:04:21 UTC (rev 136521)
@@ -1,3 +1,20 @@
+2012-12-04 Ken Kania <[email protected]>
+
+ Inspector: Introduce Input.dispatchKeyEvent and DOM.focus for typing simulation.
+ https://bugs.webkit.org/show_bug.cgi?id=103530
+
+ Reviewed by Yury Semikhatsky.
+
+ Input.dispatchKeyEvent simply calls EventHandler::keyEvent with the key event data
+ from the command parameters. The client will be responsible for providing proper
+ events to simulate desired typing behavior.
+ DOM.focus calls focus on a dom element.
+
+ * inspector-protocol/dom-focus-expected.txt: Added.
+ * inspector-protocol/dom-focus.html: Added.
+ * inspector-protocol/input/dispatchKeyEvent-expected.txt: Added.
+ * inspector-protocol/input/dispatchKeyEvent.html: Added.
+
2012-12-04 Emil A Eklund <[email protected]>
Unreviewed mathml rebaseline.
Added: trunk/LayoutTests/inspector-protocol/dom-focus-expected.txt (0 => 136521)
--- trunk/LayoutTests/inspector-protocol/dom-focus-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector-protocol/dom-focus-expected.txt 2012-12-04 18:04:21 UTC (rev 136521)
@@ -0,0 +1,3 @@
+
+focused
+
Added: trunk/LayoutTests/inspector-protocol/dom-focus.html (0 => 136521)
--- trunk/LayoutTests/inspector-protocol/dom-focus.html (rev 0)
+++ trunk/LayoutTests/inspector-protocol/dom-focus.html 2012-12-04 18:04:21 UTC (rev 136521)
@@ -0,0 +1,51 @@
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script>
+
+window.addEventListener("load", function() {
+ document.querySelector("#second").addEventListener("focus", onFocus);
+
+ function onFocus() {
+ log("focused");
+ }
+});
+
+function test()
+{
+ InspectorTest.sendCommand("DOM.getDocument", {}, onGotDocument);
+
+ function onGotDocument(msg) {
+ if (msg.error) {
+ InspectorTest.log(msg.error.message);
+ InspectorTest.completeTest();
+ return;
+ }
+ var node = msg.result.root;
+ InspectorTest.sendCommand("DOM.querySelector", { "nodeId": node.nodeId, "selector": "#second" }, onQuerySelector);
+ }
+
+ function onQuerySelector(msg) {
+ if (msg.error) {
+ InspectorTest.log(msg.error.message);
+ InspectorTest.completeTest();
+ return;
+ }
+ var node = msg.result;
+ InspectorTest.sendCommand("DOM.focus", { "nodeId": node.nodeId }, onFocus);
+ }
+
+ function onFocus(msg) {
+ if (msg.error)
+ InspectorTest.log(msg.error);
+ InspectorTest.completeTest();
+ }
+}
+
+</script>
+</head>
+<body _onload_="runTest()">
+<input></input>
+<input id="second"></input>
+</body>
+</html>
Added: trunk/LayoutTests/inspector-protocol/input/dispatchKeyEvent-expected.txt (0 => 136521)
--- trunk/LayoutTests/inspector-protocol/input/dispatchKeyEvent-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector-protocol/input/dispatchKeyEvent-expected.txt 2012-12-04 18:04:21 UTC (rev 136521)
@@ -0,0 +1,17 @@
+-----Event-----
+type: keydown
+keyCode: 65
+keyIdentifier: U+0041
+
+-----Event-----
+type: keypress
+shiftKey
+keyCode: 65
+charCode: 65
+
+-----Event-----
+type: keyup
+keyCode: 65
+keyIdentifier: U+0041
+
+
Added: trunk/LayoutTests/inspector-protocol/input/dispatchKeyEvent.html (0 => 136521)
--- trunk/LayoutTests/inspector-protocol/input/dispatchKeyEvent.html (rev 0)
+++ trunk/LayoutTests/inspector-protocol/input/dispatchKeyEvent.html 2012-12-04 18:04:21 UTC (rev 136521)
@@ -0,0 +1,73 @@
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script>
+
+window.addEventListener("keydown", logEvent);
+window.addEventListener("keypress", logEvent);
+window.addEventListener("keyup", logEvent);
+
+function logEvent(event) {
+ log("-----Event-----");
+ log("type: " + event.type);
+ if (event.altKey)
+ log("altKey");
+ if (event.ctrlKey)
+ log("ctrlKey");
+ if (event.metaKey)
+ log("metaKey");
+ if (event.shiftKey)
+ log("shiftKey");
+ if (event.keyCode)
+ log("keyCode: " + event.keyCode);
+ if (event.keyIdentifier)
+ log("keyIdentifier: " + event.keyIdentifier);
+ if (event.charCode)
+ log("charCode: " + event.charCode);
+ if (event.text)
+ log("text: " + event.text);
+ log("");
+}
+
+function test()
+{
+ var events = [
+ {
+ "type": "rawKeyDown",
+ "windowsVirtualKeyCode": 65, // VK_A
+ "keyIdentifier": "U+0041",
+ },
+ {
+ "type": "char",
+ "modifiers": 8, // shift
+ "text": "A",
+ "unmodifiedText": "a",
+ },
+ {
+ "type": "keyUp",
+ "windowsVirtualKeyCode": 65,
+ "keyIdentifier": "U+0041"
+ }
+ ];
+
+ InspectorTest.sendCommand("Input.dispatchKeyEvent", events.shift(), continueTest);
+
+ function continueTest(msg) {
+ if (msg.error) {
+ InspectorTest.log("Error: " + msg.error.message);
+ InspectorTest.completeTest();
+ return;
+ }
+
+ if (events.length)
+ InspectorTest.sendCommand("Input.dispatchKeyEvent", events.shift(), continueTest);
+ else
+ InspectorTest.completeTest();
+ }
+}
+
+</script>
+</head>
+<body _onload_="runTest()">
+</body>
+</html>
Modified: trunk/Source/WebCore/CMakeLists.txt (136520 => 136521)
--- trunk/Source/WebCore/CMakeLists.txt 2012-12-04 17:58:44 UTC (rev 136520)
+++ trunk/Source/WebCore/CMakeLists.txt 2012-12-04 18:04:21 UTC (rev 136521)
@@ -1598,6 +1598,7 @@
inspector/InspectorFrontendHost.cpp
inspector/InspectorHistory.cpp
inspector/InspectorIndexedDBAgent.cpp
+ inspector/InspectorInputAgent.cpp
inspector/InspectorInstrumentation.cpp
inspector/InspectorMemoryAgent.cpp
inspector/InspectorOverlay.cpp
Modified: trunk/Source/WebCore/ChangeLog (136520 => 136521)
--- trunk/Source/WebCore/ChangeLog 2012-12-04 17:58:44 UTC (rev 136520)
+++ trunk/Source/WebCore/ChangeLog 2012-12-04 18:04:21 UTC (rev 136521)
@@ -1,3 +1,44 @@
+2012-12-04 Ken Kania <[email protected]>
+
+ Inspector: Introduce Input.dispatchKeyEvent and DOM.focus for typing simulation.
+ https://bugs.webkit.org/show_bug.cgi?id=103530
+
+ Reviewed by Yury Semikhatsky.
+
+ Input.dispatchKeyEvent simply calls EventHandler::keyEvent with the key event data
+ from the command parameters. The client will be responsible for providing proper
+ events to simulate desired typing behavior.
+ DOM.focus calls focus on a dom element.
+
+ Tests: inspector-protocol/dom-focus.html
+ inspector-protocol/input-dispatchKeyEvent.html
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * inspector/Inspector.json:
+ * inspector/InspectorAllInOne.cpp:
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::InspectorController):
+ * inspector/InspectorDOMAgent.cpp:
+ (WebCore::InspectorDOMAgent::focus):
+ (WebCore):
+ (WebCore::InspectorDOMAgent::resolveNode):
+ * inspector/InspectorDOMAgent.h:
+ (InspectorDOMAgent):
+ * inspector/InspectorInputAgent.cpp: Added.
+ (WebCore):
+ (WebCore::InspectorInputAgent::InspectorInputAgent):
+ (WebCore::InspectorInputAgent::~InspectorInputAgent):
+ (WebCore::InspectorInputAgent::dispatchKeyEvent):
+ * inspector/InspectorInputAgent.h: Added.
+ (WebCore):
+ (InspectorInputAgent):
+ (WebCore::InspectorInputAgent::create):
+
2012-12-04 Dan Bernstein <[email protected]>
FontPlatformData has unnecessary m_textOrientation member
Modified: trunk/Source/WebCore/GNUmakefile.list.am (136520 => 136521)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-12-04 17:58:44 UTC (rev 136520)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-12-04 18:04:21 UTC (rev 136521)
@@ -3740,6 +3740,8 @@
Source/WebCore/inspector/InspectorHistory.h \
Source/WebCore/inspector/InspectorIndexedDBAgent.h \
Source/WebCore/inspector/InspectorIndexedDBAgent.cpp \
+ Source/WebCore/inspector/InspectorInputAgent.cpp \
+ Source/WebCore/inspector/InspectorInputAgent.h \
Source/WebCore/inspector/InspectorInstrumentation.cpp \
Source/WebCore/inspector/InspectorInstrumentation.h \
Source/WebCore/inspector/InspectorMemoryAgent.cpp \
Modified: trunk/Source/WebCore/Target.pri (136520 => 136521)
--- trunk/Source/WebCore/Target.pri 2012-12-04 17:58:44 UTC (rev 136520)
+++ trunk/Source/WebCore/Target.pri 2012-12-04 18:04:21 UTC (rev 136521)
@@ -772,6 +772,7 @@
inspector/InspectorFrontendClientLocal.cpp \
inspector/InspectorFrontendHost.cpp \
inspector/InspectorHistory.cpp \
+ inspector/InspectorInputAgent.cpp \
inspector/InspectorInstrumentation.cpp \
inspector/InspectorMemoryAgent.cpp \
inspector/InspectorOverlay.cpp \
Modified: trunk/Source/WebCore/WebCore.gypi (136520 => 136521)
--- trunk/Source/WebCore/WebCore.gypi 2012-12-04 17:58:44 UTC (rev 136520)
+++ trunk/Source/WebCore/WebCore.gypi 2012-12-04 18:04:21 UTC (rev 136521)
@@ -2880,6 +2880,8 @@
'inspector/InspectorHistory.h',
'inspector/InspectorIndexedDBAgent.cpp',
'inspector/InspectorIndexedDBAgent.h',
+ 'inspector/InspectorInputAgent.cpp',
+ 'inspector/InspectorInputAgent.h',
'inspector/InspectorInstrumentation.cpp',
'inspector/InspectorInstrumentation.h',
'inspector/InspectorMemoryAgent.cpp',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (136520 => 136521)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-12-04 17:58:44 UTC (rev 136520)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-12-04 18:04:21 UTC (rev 136521)
@@ -75446,6 +75446,30 @@
>
</File>
<File
+ RelativePath="..\inspector\InspectorInputAgent.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Production|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\inspector\InspectorInputAgent.h"
+ >
+ </File>
+ <File
RelativePath="..\inspector\InspectorInstrumentation.cpp"
>
<FileConfiguration
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (136520 => 136521)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-12-04 17:58:44 UTC (rev 136520)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-12-04 18:04:21 UTC (rev 136521)
@@ -1475,6 +1475,8 @@
4B6FA6F70C39E4A100087011 /* SmartReplaceCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B6FA6F60C39E4A100087011 /* SmartReplaceCF.cpp */; };
4B8AF4AA0B1CE02B00687690 /* ClipboardAccessPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8AF4A90B1CE02B00687690 /* ClipboardAccessPolicy.h */; settings = {ATTRIBUTES = (Private, ); }; };
4BAE95B10B2FA9CE00AED8A0 /* EditorDeleteAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAE95B00B2FA9CE00AED8A0 /* EditorDeleteAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 4D273CF91669420800259CA1 /* InspectorInputAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D273CF71669420800259CA1 /* InspectorInputAgent.cpp */; };
+ 4D273CFA1669420800259CA1 /* InspectorInputAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D273CF81669420800259CA1 /* InspectorInputAgent.h */; };
4E1959210A39DABA00220FE5 /* MediaFeatureNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */; };
4E1959220A39DABA00220FE5 /* MediaFeatureNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */; };
4E1959290A39DACC00220FE5 /* MediaQuery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4E1959230A39DACC00220FE5 /* MediaQuery.cpp */; };
@@ -8731,6 +8733,8 @@
4B6FA6F60C39E4A100087011 /* SmartReplaceCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartReplaceCF.cpp; sourceTree = "<group>"; };
4B8AF4A90B1CE02B00687690 /* ClipboardAccessPolicy.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ClipboardAccessPolicy.h; sourceTree = "<group>"; };
4BAE95B00B2FA9CE00AED8A0 /* EditorDeleteAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditorDeleteAction.h; sourceTree = "<group>"; };
+ 4D273CF71669420800259CA1 /* InspectorInputAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorInputAgent.cpp; sourceTree = "<group>"; };
+ 4D273CF81669420800259CA1 /* InspectorInputAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorInputAgent.h; sourceTree = "<group>"; };
4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaFeatureNames.cpp; sourceTree = "<group>"; };
4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaFeatureNames.h; sourceTree = "<group>"; };
4E1959230A39DACC00220FE5 /* MediaQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQuery.cpp; sourceTree = "<group>"; };
@@ -14886,6 +14890,8 @@
7A54857E14E02D51006AE05A /* InspectorHistory.h */,
7ACD88D114C08BD60084EDD2 /* InspectorIndexedDBAgent.cpp */,
7ACD88D214C08BD60084EDD2 /* InspectorIndexedDBAgent.h */,
+ 4D273CF71669420800259CA1 /* InspectorInputAgent.cpp */,
+ 4D273CF81669420800259CA1 /* InspectorInputAgent.h */,
20D629241253690B00081543 /* InspectorInstrumentation.cpp */,
20D629251253690B00081543 /* InspectorInstrumentation.h */,
7AA51DD3148506A900AD2752 /* InspectorMemoryAgent.cpp */,
@@ -24066,6 +24072,7 @@
7A0E770F10C00A8800A0276E /* InspectorFrontendHost.h in Headers */,
7A54858014E02D51006AE05A /* InspectorHistory.h in Headers */,
7ACD88D414C08BD60084EDD2 /* InspectorIndexedDBAgent.h in Headers */,
+ 4D273CFA1669420800259CA1 /* InspectorInputAgent.h in Headers */,
20D629271253690B00081543 /* InspectorInstrumentation.h in Headers */,
7AA51DD6148506A900AD2752 /* InspectorMemoryAgent.h in Headers */,
4F6FDD651341DEDD001F8EE3 /* InspectorPageAgent.h in Headers */,
@@ -27277,6 +27284,7 @@
7A0E770E10C00A8800A0276E /* InspectorFrontendHost.cpp in Sources */,
7A54857F14E02D51006AE05A /* InspectorHistory.cpp in Sources */,
7ACD88D314C08BD60084EDD2 /* InspectorIndexedDBAgent.cpp in Sources */,
+ 4D273CF91669420800259CA1 /* InspectorInputAgent.cpp in Sources */,
20D629261253690B00081543 /* InspectorInstrumentation.cpp in Sources */,
7AA51DD5148506A900AD2752 /* InspectorMemoryAgent.cpp in Sources */,
7C522D4B15B477E8009B7C95 /* InspectorOverlay.cpp in Sources */,
Modified: trunk/Source/WebCore/inspector/Inspector.json (136520 => 136521)
--- trunk/Source/WebCore/inspector/Inspector.json 2012-12-04 17:58:44 UTC (rev 136520)
+++ trunk/Source/WebCore/inspector/Inspector.json 2012-12-04 18:04:21 UTC (rev 136521)
@@ -1944,6 +1944,14 @@
"name": "markUndoableState",
"description": "Marks last undoable state.",
"hidden": true
+ },
+ {
+ "name": "focus",
+ "parameters": [
+ { "name": "nodeId", "$ref": "DOM.NodeId", "description": "Id of the node to focus." }
+ ],
+ "description": "Focuses the given element.",
+ "hidden": true
}
],
"events": [
@@ -3250,5 +3258,31 @@
}
],
"events": []
+ },
+ {
+ "domain": "Input",
+ "hidden": true,
+ "types": [],
+ "commands": [
+ {
+ "name": "dispatchKeyEvent",
+ "parameters": [
+ { "name": "type", "type": "string", "enum": ["keyDown", "keyUp", "rawKeyDown", "char"], "description": "Type of the key event." },
+ { "name": "modifiers", "type": "integer", "optional": true, "description": "Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0)." },
+ { "name": "timestamp", "type": "number", "optional": true, "description": "Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time)." },
+ { "name": "text", "type": "string", "optional": true, "description": "Text as generated by processing a virtual key code with a keyboard layout. Not needed for for <code>keyUp</code> and <code>rawKeyDown</code> events (default: \"\")" },
+ { "name": "unmodifiedText", "type": "string", "optional": true, "description": "Text that would have been generated by the keyboard if no modifiers were pressed (except for shift). Useful for shortcut (accelerator) key handling (default: \"\")." },
+ { "name": "keyIdentifier", "type": "string", "optional": true, "description": "Unique key identifier (e.g., 'U+0041') (default: \"\")." },
+ { "name": "windowsVirtualKeyCode", "type": "integer", "optional": true, "description": "Windows virtual key code (default: 0)." },
+ { "name": "nativeVirtualKeyCode", "type": "integer", "optional": true, "description": "Native virtual key code (default: 0)." },
+ { "name": "macCharCode", "type": "integer", "optional": true, "description": "Mac character code (default: 0)." },
+ { "name": "autoRepeat", "type": "boolean", "optional": true, "description": "Whether the event was generated from auto repeat (default: false)." },
+ { "name": "isKeypad", "type": "boolean", "optional": true, "description": "Whether the event was generated from the keypad (default: false)." },
+ { "name": "isSystemKey", "type": "boolean", "optional": true, "description": "Whether the event was a system key event (default: false)." }
+ ],
+ "description": "Dispatches a key event to the page."
+ }
+ ],
+ "events": []
}]
}
Modified: trunk/Source/WebCore/inspector/InspectorAllInOne.cpp (136520 => 136521)
--- trunk/Source/WebCore/inspector/InspectorAllInOne.cpp 2012-12-04 17:58:44 UTC (rev 136520)
+++ trunk/Source/WebCore/inspector/InspectorAllInOne.cpp 2012-12-04 18:04:21 UTC (rev 136521)
@@ -57,6 +57,7 @@
#include "InspectorFrontendHost.cpp"
#include "InspectorHistory.cpp"
#include "InspectorIndexedDBAgent.cpp"
+#include "InspectorInputAgent.cpp"
#include "InspectorInstrumentation.cpp"
#include "InspectorMemoryAgent.cpp"
#include "InspectorOverlay.cpp"
Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (136520 => 136521)
--- trunk/Source/WebCore/inspector/InspectorController.cpp 2012-12-04 17:58:44 UTC (rev 136520)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp 2012-12-04 18:04:21 UTC (rev 136521)
@@ -55,6 +55,7 @@
#include "InspectorFrontend.h"
#include "InspectorFrontendClient.h"
#include "InspectorIndexedDBAgent.h"
+#include "InspectorInputAgent.h"
#include "InspectorInstrumentation.h"
#include "InspectorMemoryAgent.h"
#include "InspectorOverlay.h"
@@ -151,6 +152,8 @@
m_agents.append(InspectorCanvasAgent::create(m_instrumentingAgents.get(), m_state.get(), page, m_injectedScriptManager.get()));
+ m_agents.append(InspectorInputAgent::create(m_instrumentingAgents.get(), m_state.get(), page));
+
ASSERT_ARG(inspectorClient, inspectorClient);
m_injectedScriptManager->injectedScriptHost()->init(m_inspectorAgent
, consoleAgent
Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (136520 => 136521)
--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2012-12-04 17:58:44 UTC (rev 136520)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2012-12-04 18:04:21 UTC (rev 136521)
@@ -52,6 +52,7 @@
#include "Document.h"
#include "DocumentFragment.h"
#include "DocumentType.h"
+#include "Element.h"
#include "ElementShadow.h"
#include "Event.h"
#include "EventContext.h"
@@ -1156,17 +1157,29 @@
m_history->markUndoableState();
}
-void InspectorDOMAgent::resolveNode(ErrorString* error, int nodeId, const String* const objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result)
+void InspectorDOMAgent::focus(ErrorString* errorString, int nodeId)
{
+ Element* element = assertElement(errorString, nodeId);
+ if (!element)
+ return;
+ if (!element->isFocusable()) {
+ *errorString = "Element is not focusable";
+ return;
+ }
+ element->focus();
+}
+
+void InspectorDOMAgent::resolveNode(ErrorString* errorString, int nodeId, const String* const objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result)
+{
String objectGroupName = objectGroup ? *objectGroup : "";
Node* node = nodeForId(nodeId);
if (!node) {
- *error = "No node with given id found";
+ *errorString = "No node with given id found";
return;
}
RefPtr<TypeBuilder::Runtime::RemoteObject> object = resolveNode(node, objectGroupName);
if (!object) {
- *error = "Node with given id does not belong to the document";
+ *errorString = "Node with given id does not belong to the document";
return;
}
result = object;
Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.h (136520 => 136521)
--- trunk/Source/WebCore/inspector/InspectorDOMAgent.h 2012-12-04 17:58:44 UTC (rev 136520)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.h 2012-12-04 18:04:21 UTC (rev 136521)
@@ -147,6 +147,7 @@
virtual void undo(ErrorString*);
virtual void redo(ErrorString*);
virtual void markUndoableState(ErrorString*);
+ virtual void focus(ErrorString*, int nodeId);
void getEventListeners(Node*, Vector<EventListenerInfo>& listenersArray, bool includeAncestors);
Added: trunk/Source/WebCore/inspector/InspectorInputAgent.cpp (0 => 136521)
--- trunk/Source/WebCore/inspector/InspectorInputAgent.cpp (rev 0)
+++ trunk/Source/WebCore/inspector/InspectorInputAgent.cpp 2012-12-04 18:04:21 UTC (rev 136521)
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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.
+ */
+
+#include "config.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "InspectorInputAgent.h"
+
+#include "EventHandler.h"
+#include "Frame.h"
+#include "Page.h"
+#include "PlatformEvent.h"
+#include "PlatformKeyboardEvent.h"
+
+#include <wtf/CurrentTime.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+InspectorInputAgent::InspectorInputAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, Page* page)
+ : InspectorBaseAgent<InspectorInputAgent>("Input", instrumentingAgents, inspectorState)
+ , m_page(page)
+{
+}
+
+InspectorInputAgent::~InspectorInputAgent()
+{
+}
+
+void InspectorInputAgent::dispatchKeyEvent(ErrorString* error, const String& type, const int* modifiers, const double* timestamp, const String* text, const String* unmodifiedText, const String* keyIdentifier, const int* windowsVirtualKeyCode, const int* nativeVirtualKeyCode, const int* macCharCode, const bool* autoRepeat, const bool* isKeypad, const bool* isSystemKey)
+{
+ PlatformEvent::Type convertedType;
+ if (type == "keyDown")
+ convertedType = PlatformEvent::KeyDown;
+ else if (type == "keyUp")
+ convertedType = PlatformEvent::KeyUp;
+ else if (type == "char")
+ convertedType = PlatformEvent::Char;
+ else if (type == "rawKeyDown")
+ convertedType = PlatformEvent::RawKeyDown;
+ else {
+ *error = "Unrecognized type: " + type;
+ return;
+ }
+
+ PlatformKeyboardEvent event(
+ convertedType,
+ text ? *text : "",
+ unmodifiedText ? *unmodifiedText : "",
+ keyIdentifier ? *keyIdentifier : "",
+ windowsVirtualKeyCode ? *windowsVirtualKeyCode : 0,
+ nativeVirtualKeyCode ? *nativeVirtualKeyCode : 0,
+ macCharCode ? *macCharCode : 0,
+ autoRepeat ? *autoRepeat : false,
+ isKeypad ? *isKeypad : false,
+ isSystemKey ? *isSystemKey : false,
+ static_cast<PlatformEvent::Modifiers>(modifiers ? *modifiers : 0),
+ timestamp ? *timestamp : currentTime());
+ m_page->mainFrame()->eventHandler()->keyEvent(event);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
Added: trunk/Source/WebCore/inspector/InspectorInputAgent.h (0 => 136521)
--- trunk/Source/WebCore/inspector/InspectorInputAgent.h (rev 0)
+++ trunk/Source/WebCore/inspector/InspectorInputAgent.h 2012-12-04 18:04:21 UTC (rev 136521)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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.
+ */
+
+#ifndef InspectorInputAgent_h
+#define InspectorInputAgent_h
+
+#if ENABLE(INSPECTOR)
+
+#include "InspectorBaseAgent.h"
+
+#include <wtf/Noncopyable.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+class InspectorState;
+class Page;
+
+typedef String ErrorString;
+
+class InspectorInputAgent : public InspectorBaseAgent<InspectorInputAgent>, public InspectorBackendDispatcher::InputCommandHandler {
+ WTF_MAKE_NONCOPYABLE(InspectorInputAgent);
+public:
+ static PassOwnPtr<InspectorInputAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, Page* page)
+ {
+ return adoptPtr(new InspectorInputAgent(instrumentingAgents, inspectorState, page));
+ }
+
+ ~InspectorInputAgent();
+
+ // Methods called from the frontend for simulating input.
+ virtual void dispatchKeyEvent(ErrorString*, const String& type, const int* modifiers, const double* timestamp, const String* text, const String* unmodifiedText, const String* keyIdentifier, const int* windowsVirtualKeyCode, const int* nativeVirtualKeyCode, const int* macCharCode, const bool* autoRepeat, const bool* isKeypad, const bool* isSystemKey);
+
+private:
+ InspectorInputAgent(InstrumentingAgents*, InspectorState*, Page*);
+
+ Page* m_page;
+};
+
+#endif // ENABLE(INSPECTOR)
+
+} // namespace WebCore
+
+#endif // !defined(InspectorInputAgent_h)