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

Side by Side Diff: Source/core/inspector/InjectedScriptSource.js

Issue 464793002: DevTools: Simplify isArrayLike() in injected script and extend InjectedScriptHost.type() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 * @return {boolean} 145 * @return {boolean}
146 */ 146 */
147 function isArrayLike(obj) 147 function isArrayLike(obj)
148 { 148 {
149 try { 149 try {
150 if (typeof obj !== "object") 150 if (typeof obj !== "object")
151 return false; 151 return false;
152 if (typeof obj.splice === "function") 152 if (typeof obj.splice === "function")
153 return isFinite(obj.length); 153 return isFinite(obj.length);
154 var str = InjectedScriptHost.callFunction(Object.prototype.toString, obj ); 154 var str = InjectedScriptHost.callFunction(Object.prototype.toString, obj );
155 if (str === "[object Array]" || 155 if (str === "[object Arguments]")
156 str === "[object Arguments]" ||
157 str === "[object HTMLCollection]" ||
158 str === "[object NodeList]" ||
159 str === "[object DOMTokenList]")
160 return isFinite(obj.length); 156 return isFinite(obj.length);
161 } catch (e) { 157 } catch (e) {
162 } 158 }
163 return false; 159 return false;
164 } 160 }
165 161
166 /** 162 /**
167 * @param {number} a 163 * @param {number} a
168 * @param {number} b 164 * @param {number} b
169 * @return {number} 165 * @return {number}
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 * @return {?string} 971 * @return {?string}
976 */ 972 */
977 _subtype: function(obj) 973 _subtype: function(obj)
978 { 974 {
979 if (obj === null) 975 if (obj === null)
980 return "null"; 976 return "null";
981 977
982 if (this.isPrimitiveValue(obj)) 978 if (this.isPrimitiveValue(obj))
983 return null; 979 return null;
984 980
985 if (this._isHTMLAllCollection(obj))
986 return "array";
987
988 var preciseType = InjectedScriptHost.type(obj); 981 var preciseType = InjectedScriptHost.type(obj);
989 if (preciseType) 982 if (preciseType)
990 return preciseType; 983 return preciseType;
991 984
992 if (isArrayLike(obj)) 985 if (isArrayLike(obj))
993 return "array"; 986 return "array";
994 987
995 // If owning frame has navigated to somewhere else window properties wil l be undefined. 988 // If owning frame has navigated to somewhere else window properties wil l be undefined.
996 return null; 989 return null;
997 }, 990 },
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 */ 1694 */
1702 _logEvent: function(event) 1695 _logEvent: function(event)
1703 { 1696 {
1704 inspectedWindow.console.log(event.type, event); 1697 inspectedWindow.console.log(event.type, event);
1705 } 1698 }
1706 } 1699 }
1707 1700
1708 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); 1701 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl();
1709 return injectedScript; 1702 return injectedScript;
1710 }) 1703 })
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698