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

Unified Diff: Source/devtools/front_end/components/CustomPreviewSection.js

Issue 1096283003: Devtools:[CustomFormatter] Allow object tags in headers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix test with dcheck_always_on Created 5 years, 8 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
« no previous file with comments | « Source/core/inspector/InjectedScriptSource.js ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/components/CustomPreviewSection.js
diff --git a/Source/devtools/front_end/components/CustomPreviewSection.js b/Source/devtools/front_end/components/CustomPreviewSection.js
index 3245aca2f887f9c4c3360e152c835e435e79450f..1d9d6b1e7e16b8472716242cb431e1743d8f74ee 100644
--- a/Source/devtools/front_end/components/CustomPreviewSection.js
+++ b/Source/devtools/front_end/components/CustomPreviewSection.js
@@ -21,6 +21,11 @@ WebInspector.CustomPreviewSection = function(object)
return;
}
this._header = this._renderJSONMLTag(headerJSON);
+ if (this._header.nodeType === Node.TEXT_NODE) {
+ WebInspector.console.error("Broken formatter: header should be an element node.");
+ return;
+ }
+
if (customPreview.hasBody) {
this._header.classList.add("custom-expandable-section-header");
this._header.addEventListener("click", this._onClick.bind(this), false);
@@ -152,8 +157,12 @@ WebInspector.CustomPreviewSection.prototype = {
parentElement.appendChild(this._renderJSONMLTag(jsonMLTags[i]));
},
- _onClick: function()
+ /**
+ * @param {!Event} event
+ */
+ _onClick: function(event)
{
+ event.consume(true);
if (this._cachedContent)
this._toggleExpand();
else
@@ -175,8 +184,9 @@ WebInspector.CustomPreviewSection.prototype = {
* @suppress {undefinedVars}
* @this {Object}
* @param {*=} formatter
+ * @param {*=} config
*/
- function load(formatter)
+ function load(formatter, config)
{
/**
* @param {*} jsonMLObject
@@ -195,10 +205,11 @@ WebInspector.CustomPreviewSection.prototype = {
if (jsonMLObject[0] === "object") {
var attributes = jsonMLObject[1];
var originObject = attributes["object"];
+ var config = attributes["config"];
if (typeof originObject === "undefined")
throw "Illegal format: obligatory attribute \"object\" isn't specified";
- jsonMLObject[1] = bindRemoteObject(originObject, false, false, null, false);
+ jsonMLObject[1] = bindRemoteObject(originObject, false, false, null, false, config);
startIndex = 2;
}
for (var i = startIndex; i < jsonMLObject.length; ++i)
@@ -206,7 +217,7 @@ WebInspector.CustomPreviewSection.prototype = {
}
try {
- var body = formatter.body(this);
+ var body = formatter.body(this, config);
substituteObjectTagsInCustomPreview(body);
return body;
} catch (e) {
@@ -216,7 +227,10 @@ WebInspector.CustomPreviewSection.prototype = {
}
var customPreview = this._object.customPreview();
- this._object.callFunctionJSON(load, [{objectId: customPreview.formatterObjectId}], onBodyLoaded.bind(this));
+ var args = [{objectId: customPreview.formatterObjectId}];
+ if (customPreview.configObjectId)
+ args.push({objectId: customPreview.configObjectId});
+ this._object.callFunctionJSON(load, args, onBodyLoaded.bind(this));
/**
* @param {*} bodyJsonML
« no previous file with comments | « Source/core/inspector/InjectedScriptSource.js ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698