Changeset 50639 in webkit
- Timestamp:
- Nov 8, 2009 10:39:32 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r50638 r50639 1 2009-11-08 Keishi Hattori <casey.hattori@gmail.com> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: Inspector should support copy() in the command line 6 https://bugs.webkit.org/show_bug.cgi?id=31238 7 8 * inspector/InspectorBackend.cpp: 9 (WebCore::InspectorBackend::copyText): Added. 10 * inspector/InspectorBackend.h: Added copyText 11 * inspector/InspectorBackend.idl: Added copyText 12 * inspector/front-end/InjectedScript.js: 13 (InjectedScript._copy): Added. 14 (InjectedScript._ensureCommandLineAPIInstalled): 15 1 16 2009-11-08 Drew Wilson <atwilson@chromium.org> 2 17 -
trunk/WebCore/inspector/InspectorBackend.cpp
r50528 r50639 508 508 } 509 509 510 void InspectorBackend::copyText(const String& text) 511 { 512 Pasteboard::generalPasteboard()->writePlainText(text); 513 } 514 510 515 void InspectorBackend::highlight(long nodeId) 511 516 { -
trunk/WebCore/inspector/InspectorBackend.h
r50528 r50639 144 144 void deleteCookie(const String& cookieName, const String& domain); 145 145 146 void copyText(const String& text); 147 146 148 // Generic code called from custom implementations. 147 149 void highlight(long nodeId); -
trunk/WebCore/inspector/InspectorBackend.idl
r50528 r50639 118 118 // Called from InjectedScript. 119 119 // TODO: extract into a separate IDL. 120 void copyText(in DOMString text); 120 121 [Custom] DOMObject nodeForId(in long nodeId); 121 122 [Custom] long wrapObject(in DOMObject object, in DOMString objectGroup); -
trunk/WebCore/inspector/front-end/InjectedScript.js
r50574 r50639 904 904 } 905 905 906 InjectedScript._copy = function(o) 907 { 908 if (Object.type(o) === "node") { 909 var nodeId = InspectorController.pushNodePathToFrontend(o, false); 910 InspectorController.copyNode(nodeId); 911 } else { 912 InspectorController.copyText(o); 913 } 914 } 915 906 916 InjectedScript._ensureCommandLineAPIInstalled = function(evalFunction, evalObject) 907 917 { 908 918 if (evalFunction.call(evalObject, "window.console._inspectorCommandLineAPI")) 909 919 return; 910 var inspectorCommandLineAPI = evalFunction.call(evalObject, "window.console._inspectorCommandLineAPI = { \ 911 $: function() { return document.getElementById.apply(document, arguments) }, \ 912 $$: function() { return document.querySelectorAll.apply(document, arguments) }, \ 913 $x: function(xpath, context) { \ 914 var nodes = []; \ 915 try { \ 916 var doc = context || document; \ 917 var results = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); \ 918 var node; \ 919 while (node = results.iterateNext()) nodes.push(node); \ 920 } catch (e) {} \ 921 return nodes; \ 922 }, \ 923 dir: function() { return console.dir.apply(console, arguments) }, \ 924 dirxml: function() { return console.dirxml.apply(console, arguments) }, \ 925 keys: function(o) { var a = []; for (var k in o) a.push(k); return a; }, \ 926 values: function(o) { var a = []; for (var k in o) a.push(o[k]); return a; }, \ 927 profile: function() { return console.profile.apply(console, arguments) }, \ 928 profileEnd: function() { return console.profileEnd.apply(console, arguments) }, \ 929 _logEvent: function _inspectorCommandLineAPI_logEvent(e) { console.log(e.type, e); }, \ 930 _allEventTypes: [\"mouse\", \"key\", \"load\", \"unload\", \"abort\", \"error\", \ 931 \"select\", \"change\", \"submit\", \"reset\", \"focus\", \"blur\", \ 932 \"resize\", \"scroll\"], \ 933 _normalizeEventTypes: function(t) { \ 934 if (typeof t === \"undefined\") \ 935 t = console._inspectorCommandLineAPI._allEventTypes; \ 936 else if (typeof t === \"string\") \ 937 t = [t]; \ 938 var i, te = []; \ 939 for (i = 0; i < t.length; i++) { \ 940 if (t[i] === \"mouse\") \ 941 te.splice(0, 0, \"mousedown\", \"mouseup\", \"click\", \"dblclick\", \ 942 \"mousemove\", \"mouseover\", \"mouseout\"); \ 943 else if (t[i] === \"key\") \ 944 te.splice(0, 0, \"keydown\", \"keyup\", \"keypress\"); \ 945 else \ 946 te.push(t[i]); \ 947 } \ 948 return te; \ 949 }, \ 950 monitorEvents: function(o, t) { \ 951 if (!o || !o.addEventListener || !o.removeEventListener) \ 952 return; \ 953 t = console._inspectorCommandLineAPI._normalizeEventTypes(t); \ 954 for (i = 0; i < t.length; i++) { \ 955 o.removeEventListener(t[i], console._inspectorCommandLineAPI._logEvent, false); \ 956 o.addEventListener(t[i], console._inspectorCommandLineAPI._logEvent, false); \ 957 } \ 958 }, \ 959 unmonitorEvents: function(o, t) { \ 960 if (!o || !o.removeEventListener) \ 961 return; \ 962 t = console._inspectorCommandLineAPI._normalizeEventTypes(t); \ 963 for (i = 0; i < t.length; i++) { \ 964 o.removeEventListener(t[i], console._inspectorCommandLineAPI._logEvent, false); \ 965 } \ 966 }, \ 967 _inspectedNodes: [], \ 968 get $0() { return console._inspectorCommandLineAPI._inspectedNodes[0] }, \ 969 get $1() { return console._inspectorCommandLineAPI._inspectedNodes[1] }, \ 970 get $2() { return console._inspectorCommandLineAPI._inspectedNodes[2] }, \ 971 get $3() { return console._inspectorCommandLineAPI._inspectedNodes[3] }, \ 972 get $4() { return console._inspectorCommandLineAPI._inspectedNodes[4] } \ 920 var inspectorCommandLineAPI = evalFunction.call(evalObject, "window.console._inspectorCommandLineAPI = { \n\ 921 $: function() { return document.getElementById.apply(document, arguments) }, \n\ 922 $$: function() { return document.querySelectorAll.apply(document, arguments) }, \n\ 923 $x: function(xpath, context) \n\ 924 { \n\ 925 var nodes = []; \n\ 926 try { \n\ 927 var doc = context || document; \n\ 928 var results = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); \n\ 929 var node; \n\ 930 while (node = results.iterateNext()) nodes.push(node); \n\ 931 } catch (e) {} \n\ 932 return nodes; \n\ 933 }, \n\ 934 dir: function() { return console.dir.apply(console, arguments) }, \n\ 935 dirxml: function() { return console.dirxml.apply(console, arguments) }, \n\ 936 keys: function(o) { var a = []; for (var k in o) a.push(k); return a; }, \n\ 937 values: function(o) { var a = []; for (var k in o) a.push(o[k]); return a; }, \n\ 938 profile: function() { return console.profile.apply(console, arguments) }, \n\ 939 profileEnd: function() { return console.profileEnd.apply(console, arguments) }, \n\ 940 _logEvent: function _inspectorCommandLineAPI_logEvent(e) { console.log(e.type, e); }, \n\ 941 _allEventTypes: [\"mouse\", \"key\", \"load\", \"unload\", \"abort\", \"error\", \n\ 942 \"select\", \"change\", \"submit\", \"reset\", \"focus\", \"blur\", \n\ 943 \"resize\", \"scroll\"], \n\ 944 _normalizeEventTypes: function(t) \n\ 945 { \n\ 946 if (typeof t === \"undefined\") \n\ 947 t = console._inspectorCommandLineAPI._allEventTypes; \n\ 948 else if (typeof t === \"string\") \n\ 949 t = [t]; \n\ 950 var i, te = []; \n\ 951 for (i = 0; i < t.length; i++) { \n\ 952 if (t[i] === \"mouse\") \n\ 953 te.splice(0, 0, \"mousedown\", \"mouseup\", \"click\", \"dblclick\", \n\ 954 \"mousemove\", \"mouseover\", \"mouseout\"); \n\ 955 else if (t[i] === \"key\") \n\ 956 te.splice(0, 0, \"keydown\", \"keyup\", \"keypress\"); \n\ 957 else \n\ 958 te.push(t[i]); \n\ 959 } \n\ 960 return te; \n\ 961 }, \n\ 962 monitorEvents: function(o, t) \n\ 963 { \n\ 964 if (!o || !o.addEventListener || !o.removeEventListener) \n\ 965 return; \n\ 966 t = console._inspectorCommandLineAPI._normalizeEventTypes(t); \n\ 967 for (i = 0; i < t.length; i++) { \n\ 968 o.removeEventListener(t[i], console._inspectorCommandLineAPI._logEvent, false); \n\ 969 o.addEventListener(t[i], console._inspectorCommandLineAPI._logEvent, false); \n\ 970 } \n\ 971 }, \n\ 972 unmonitorEvents: function(o, t) \n\ 973 { \n\ 974 if (!o || !o.removeEventListener) \n\ 975 return; \n\ 976 t = console._inspectorCommandLineAPI._normalizeEventTypes(t); \n\ 977 for (i = 0; i < t.length; i++) { \n\ 978 o.removeEventListener(t[i], console._inspectorCommandLineAPI._logEvent, false); \n\ 979 } \n\ 980 }, \n\ 981 _inspectedNodes: [], \n\ 982 get $0() { return console._inspectorCommandLineAPI._inspectedNodes[0] }, \n\ 983 get $1() { return console._inspectorCommandLineAPI._inspectedNodes[1] }, \n\ 984 get $2() { return console._inspectorCommandLineAPI._inspectedNodes[2] }, \n\ 985 get $3() { return console._inspectorCommandLineAPI._inspectedNodes[3] }, \n\ 986 get $4() { return console._inspectorCommandLineAPI._inspectedNodes[4] }, \n\ 973 987 };"); 974 988 975 989 inspectorCommandLineAPI.clear = InspectorController.wrapCallback(InjectedScript._clearConsoleMessages); 976 990 inspectorCommandLineAPI.inspect = InspectorController.wrapCallback(InjectedScript._inspectObject); 991 inspectorCommandLineAPI.copy = InspectorController.wrapCallback(InjectedScript._copy); 977 992 } 978 993
Note: See TracChangeset
for help on using the changeset viewer.