| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @param {!WebInspector.RemoteObject} object | 7 * @param {!WebInspector.RemoteObject} object |
| 8 * @param {!Array.<*>=} prefixML | 8 * @param {!Array.<*>=} prefixML |
| 9 */ | 9 */ |
| 10 WebInspector.CustomPreviewSection = function(object, prefixML) | 10 WebInspector.CustomPreviewSection = function(object, prefixML) |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 else | 195 else |
| 196 parent.removeChild(this._cachedContent); | 196 parent.removeChild(this._cachedContent); |
| 197 }, | 197 }, |
| 198 | 198 |
| 199 _loadBody: function() | 199 _loadBody: function() |
| 200 { | 200 { |
| 201 /** | 201 /** |
| 202 * @suppressReceiverCheck | 202 * @suppressReceiverCheck |
| 203 * @suppressGlobalPropertiesCheck | 203 * @suppressGlobalPropertiesCheck |
| 204 * @suppress {undefinedVars} | 204 * @suppress {undefinedVars} |
| 205 * @this {?} | 205 * @this {Object} |
| 206 * @param {*=} formatter |
| 206 */ | 207 */ |
| 207 function load() | 208 function load(formatter) |
| 208 { | 209 { |
| 209 /** | 210 /** |
| 210 * @param {*} jsonMLObject | 211 * @param {*} jsonMLObject |
| 211 * @throws {string} error message | 212 * @throws {string} error message |
| 212 */ | 213 */ |
| 213 function substituteObjectTagsInCustomPreview(jsonMLObject) | 214 function substituteObjectTagsInCustomPreview(jsonMLObject) |
| 214 { | 215 { |
| 215 if (!jsonMLObject || (typeof jsonMLObject !== "object") || (type
of jsonMLObject.splice !== "function")) | 216 if (!jsonMLObject || (typeof jsonMLObject !== "object") || (type
of jsonMLObject.splice !== "function")) |
| 216 return; | 217 return; |
| 217 | 218 |
| 218 var obj = jsonMLObject.length; | 219 var obj = jsonMLObject.length; |
| 219 if (!(typeof obj === "number" && obj >>> 0 === obj && (obj > 0 |
| 1 / obj > 0))) | 220 if (!(typeof obj === "number" && obj >>> 0 === obj && (obj > 0 |
| 1 / obj > 0))) |
| 220 return; | 221 return; |
| 221 | 222 |
| 222 var startIndex = 1; | 223 var startIndex = 1; |
| 223 if (jsonMLObject[0] === "object") { | 224 if (jsonMLObject[0] === "object") { |
| 224 var attributes = jsonMLObject[1]; | 225 var attributes = jsonMLObject[1]; |
| 225 var originObject = attributes["object"]; | 226 var originObject = attributes["object"]; |
| 226 if (typeof originObject === "undefined") | 227 if (typeof originObject === "undefined") |
| 227 throw "Illegal format: obligatory attribute \"object\" i
sn't specified"; | 228 throw "Illegal format: obligatory attribute \"object\" i
sn't specified"; |
| 228 | 229 |
| 229 jsonMLObject[1] = bindRemoteObject(originObject, false, fals
e, null, false); | 230 jsonMLObject[1] = bindRemoteObject(originObject, false, fals
e, null, false); |
| 230 startIndex = 2; | 231 startIndex = 2; |
| 231 } | 232 } |
| 232 | |
| 233 for (var i = startIndex; i < jsonMLObject.length; ++i) | 233 for (var i = startIndex; i < jsonMLObject.length; ++i) |
| 234 substituteObjectTagsInCustomPreview(jsonMLObject[i]); | 234 substituteObjectTagsInCustomPreview(jsonMLObject[i]); |
| 235 } | 235 } |
| 236 | 236 |
| 237 try { | 237 try { |
| 238 var formatter = window["devtoolsFormatter"]; | |
| 239 if (!formatter) | |
| 240 return null; | |
| 241 | |
| 242 var body = formatter.body(this); | 238 var body = formatter.body(this); |
| 243 substituteObjectTagsInCustomPreview(body); | 239 substituteObjectTagsInCustomPreview(body); |
| 244 return body; | 240 return body; |
| 245 } catch (e) { | 241 } catch (e) { |
| 246 console.error("Custom Formatter Failed: " + e); | 242 console.error("Custom Formatter Failed: " + e); |
| 247 return null; | 243 return null; |
| 248 } | 244 } |
| 249 } | 245 } |
| 250 | 246 |
| 251 this._object.callFunctionJSON(load, [], onBodyLoaded.bind(this)); | 247 var customPreview = this._object.customPreview(); |
| 248 this._object.callFunctionJSON(load, [{objectId: customPreview.formatterO
bjectId}], onBodyLoaded.bind(this)); |
| 252 | 249 |
| 253 /** | 250 /** |
| 254 * @param {*} bodyJsonML | 251 * @param {*} bodyJsonML |
| 255 * @this {WebInspector.CustomPreviewSection} | 252 * @this {WebInspector.CustomPreviewSection} |
| 256 */ | 253 */ |
| 257 function onBodyLoaded(bodyJsonML) | 254 function onBodyLoaded(bodyJsonML) |
| 258 { | 255 { |
| 259 if (!bodyJsonML) | 256 if (!bodyJsonML) |
| 260 return; | 257 return; |
| 261 | 258 |
| 262 this._cachedContent = this._renderJSONMLTag(bodyJsonML); | 259 this._cachedContent = this._renderJSONMLTag(bodyJsonML); |
| 263 this._toggleExpand(); | 260 this._toggleExpand(); |
| 264 } | 261 } |
| 265 } | 262 } |
| 266 } | 263 } |
| OLD | NEW |