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

Unified Diff: third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js

Issue 2139043002: DevTools: show alternate title onexpand of object in console (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove complex value editing from tests Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js
diff --git a/third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js b/third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js
index 6507123c6119cdb4b2ea6e884d0304431da71bc9..7fe1c1d502ccd870353ca1dc48f2e56d12351278 100644
--- a/third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js
+++ b/third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js
@@ -43,10 +43,22 @@ WebInspector.ObjectPropertiesSection = function(object, title, linkifier, emptyP
this.setFocusable(false);
this._objectTreeElement = new WebInspector.ObjectPropertiesSection.RootElement(object, linkifier, emptyPlaceholder, ignoreHasOwnProperty, extraProperties);
this.appendChild(this._objectTreeElement);
- if (typeof title === "string" || !title)
- this.element.createChild("span").textContent = title || "";
- else
+ if (typeof title === "string" || !title) {
+ this.titleElement = this.element.createChild("span");
+ this.titleElement.textContent = title || "";
+ } else {
+ this.titleElement = title;
this.element.appendChild(title);
+ }
+
+ if (object.description && WebInspector.ObjectPropertiesSection._needsAlternateTitle(object)) {
lushnikov 2016/08/03 22:34:49 Let's not make it static without a need - it's eas
luoe 2016/08/05 01:12:47 Unfortunately, I don't think we can easily make th
+ this.expandedTitleElement = createElement("span");
+ this.expandedTitleElement.createTextChild(object.description);
+
+ var note = this.expandedTitleElement.createChild("span", "object-state-note");
+ note.classList.add("info-note");
+ note.title = WebInspector.UIString("Value below was evaluated just now.");
+ }
this.element._section = this;
this.registerRequiredCSS("components/objectValue.css");
@@ -174,16 +186,36 @@ WebInspector.ObjectPropertiesSection.RootElement = function(object, linkifier, e
WebInspector.ObjectPropertiesSection.RootElement.prototype = {
lushnikov 2016/08/03 22:34:48 stray line
luoe 2016/08/05 01:12:47 Done.
+ /**
+ * @override
+ */
onexpand: function()
{
- if (this.treeOutline)
+ if (this.treeOutline) {
this.treeOutline.element.classList.add("expanded");
+ this._toggleExpandedTitleElement();
+ }
},
+ /**
+ * @override
+ */
oncollapse: function()
{
- if (this.treeOutline)
+ if (this.treeOutline) {
this.treeOutline.element.classList.remove("expanded");
+ this._toggleExpandedTitleElement();
+ }
+ },
+
+ _toggleExpandedTitleElement: function()
lushnikov 2016/08/03 22:34:48 let's make it straightforward: /** * @param {bo
luoe 2016/08/05 01:12:47 Done.
+ {
+ if (!this.treeOutline.expandedTitleElement)
+ return;
+ if (this.expanded)
+ this.treeOutline.element.replaceChild(this.treeOutline.expandedTitleElement, this.treeOutline.titleElement);
+ else
+ this.treeOutline.element.replaceChild(this.treeOutline.titleElement, this.treeOutline.expandedTitleElement);
},
/**
@@ -283,8 +315,8 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
*/
ondblclick: function(event)
{
- var editableElement = this.valueElement;
- if (!this.property.value.customPreview() && (this.property.writable || this.property.setter) && event.target.isSelfOrDescendant(editableElement))
+ var inEditableElement = event.target.isSelfOrDescendant(this.valueElement) || (this.expandedValueElement && event.target.isSelfOrDescendant(this.expandedValueElement));
+ if (!this.property.value.customPreview() && inEditableElement && (this.property.writable || this.property.setter))
this._startEditing();
return false;
},
@@ -298,6 +330,32 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
this._updateExpandable();
},
+ /**
+ * @override
+ */
+ onexpand: function()
+ {
+ this._toggleExpandedValueElement();
+ },
+
+ /**
+ * @override
+ */
+ oncollapse: function()
+ {
+ this._toggleExpandedValueElement();
+ },
+
+ _toggleExpandedValueElement: function()
lushnikov 2016/08/03 22:34:49 Like with title: _setExpandedValueElement: functi
luoe 2016/08/05 01:12:47 Done.
+ {
+ if (!this.expandedValueElement)
+ return;
+ if (this.expanded)
+ this.listItemElement.replaceChild(this.expandedValueElement, this.valueElement);
+ else
+ this.listItemElement.replaceChild(this.valueElement, this.expandedValueElement);
+ },
+
update: function()
{
this.nameElement = WebInspector.ObjectPropertiesSection.createNameElement(this.property.name);
@@ -325,6 +383,10 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
this.valueElement.title = WebInspector.UIString("No property getter");
}
+ var valueText = this.valueElement.textContent;
+ if (this.property.value && valueText && !this.property.wasThrown)
+ this.expandedValueElement = WebInspector.ObjectPropertiesSection._createExpandedValueElement(this.property.value);
lushnikov 2016/08/03 22:34:48 this._createExpandedValueElement(this.property.val
luoe 2016/08/05 01:12:47 Done.
+
this.listItemElement.removeChildren();
this.listItemElement.appendChildren(this.nameElement, separatorElement, this.valueElement);
},
@@ -376,11 +438,10 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
this._editableDiv.setTextContentTruncatedIfNeeded(text, WebInspector.UIString("<string is too large to edit>"));
var originalContent = this._editableDiv.textContent;
- this.valueElement.classList.add("hidden");
-
// Lie about our children to prevent expanding on double click and to collapse subproperties.
this.setExpandable(false);
this.listItemElement.classList.add("editing-sub-part");
+ this.valueElement.classList.add("hidden");
this._prompt = new WebInspector.ObjectPropertyPrompt();
@@ -468,7 +529,7 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
// Call updateSiblings since their value might be based on the value that just changed.
var parent = this.parent;
parent.invalidateChildren();
- parent.expand();
+ parent.onpopulate();
}
}
},
@@ -1094,6 +1155,31 @@ WebInspector.ObjectPropertiesSection.createValueElement = function(value, wasThr
}
/**
+ * @param {!WebInspector.RemoteObject} object
+ * @return {boolean}
+ */
+WebInspector.ObjectPropertiesSection._needsAlternateTitle = function(object)
+{
+ return object && object.hasChildren && !object.customPreview() && object.subtype !== "node" && object.type !== "function" && (object.type !== "object" || object.preview);
+}
+
+/**
+ * @param {!WebInspector.RemoteObject} value
+ * @return {?Element}
+ */
+WebInspector.ObjectPropertiesSection._createExpandedValueElement = function(value)
+{
+ if (!WebInspector.ObjectPropertiesSection._needsAlternateTitle(value))
+ return null;
+
+ var valueElement = createElementWithClass("span", "value");
+ valueElement.setTextContentTruncatedIfNeeded(value.description || "");
+ valueElement.classList.add("object-value-" + (value.subtype || value.type));
+ valueElement.title = value.description || "";
+ return valueElement;
+}
+
+/**
* @param {!WebInspector.RemoteObject} func
* @param {!Element} element
* @param {boolean} linkify

Powered by Google App Engine
This is Rietveld 408576698