Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js

Issue 1983423002: [DevTools] Move CommandLineAPI querySelector and querySelectorAll to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-bind-remote-object
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js
diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js
index e20c21d574958d1519ab7d2e255701e448bf1559..088e287db4daf6d69e90023ffced28746293a151 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js
+++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js
@@ -54,20 +54,6 @@ function push(array, var_args)
}
/**
- * @param {(!Arguments.<T>|!NodeList)} array
- * @param {number=} index
- * @return {!Array.<T>}
- * @template T
- */
-function slice(array, index)
-{
- var result = [];
- for (var i = index || 0, j = 0; i < array.length; ++i, ++j)
- result[j] = array[i];
- return result;
-}
-
-/**
* @param {*} obj
* @return {string}
* @suppress {uselessCode}
@@ -542,7 +528,7 @@ InjectedScript.prototype = {
{
// NOTE: This list contains only not native Command Line API methods. For full list: V8Console.
// NOTE: Argument names of these methods will be printed in the console, so use pretty names!
- var members = [ "$", "$$", "$x", "monitorEvents", "unmonitorEvents", "getEventListeners" ];
+ var members = [ "$x", "monitorEvents", "unmonitorEvents", "getEventListeners" ];
for (var member of members)
nativeCommandLineAPI[member] = CommandLineAPIImpl[member];
var functionToStringMap = new Map([
@@ -567,8 +553,8 @@ InjectedScript.prototype = {
["unmonitorEvents", "function unmonitorEvents(object, [types]) { [Command Line API] }"],
["getEventListeners", "function getEventListeners(node) { [Command Line API] }"]
]);
- for (let entry of functionToStringMap)
- nativeCommandLineAPI[entry[0]].toString = (() => entry[1]);
+ for (let func in nativeCommandLineAPI)
+ nativeCommandLineAPI[func].toString = (() => functionToStringMap.get(func));
return nativeCommandLineAPI;
},
@@ -1091,40 +1077,6 @@ InjectedScript.RemoteObject.prototype = {
var CommandLineAPIImpl = { __proto__: null }
/**
- * @param {string} selector
- * @param {!Node=} opt_startNode
- * @return {*}
- */
-CommandLineAPIImpl.$ = function (selector, opt_startNode)
-{
- if (CommandLineAPIImpl._canQuerySelectorOnNode(opt_startNode))
- return opt_startNode.querySelector(selector);
-
- return inspectedGlobalObject.document.querySelector(selector);
-}
-
-/**
- * @param {string} selector
- * @param {!Node=} opt_startNode
- * @return {*}
- */
-CommandLineAPIImpl.$$ = function (selector, opt_startNode)
-{
- if (CommandLineAPIImpl._canQuerySelectorOnNode(opt_startNode))
- return slice(opt_startNode.querySelectorAll(selector));
- return slice(inspectedGlobalObject.document.querySelectorAll(selector));
-}
-
-/**
- * @param {!Node=} node
- * @return {boolean}
- */
-CommandLineAPIImpl._canQuerySelectorOnNode = function(node)
-{
- return !!node && InjectedScriptHost.subtype(node) === "node" && (node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE);
-}
-
-/**
* @param {string} xpath
* @param {!Node=} opt_startNode
* @return {*}

Powered by Google App Engine
This is Rietveld 408576698