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

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: DevTools: show alternate title onexpand of object in console Created 4 years, 5 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 8a90167861e000ce05cd0598db3064392ac35312..660fff0c6e37b33e0164de0271d4b50f4ee729cd 100644
--- a/third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js
+++ b/third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js
@@ -29,12 +29,13 @@
* @extends {TreeOutlineInShadow}
* @param {!WebInspector.RemoteObject} object
* @param {?string|!Element=} title
+ * @param {?Element=} expandedTitle
* @param {!WebInspector.Linkifier=} linkifier
* @param {?string=} emptyPlaceholder
* @param {boolean=} ignoreHasOwnProperty
* @param {!Array.<!WebInspector.RemoteObjectProperty>=} extraProperties
*/
-WebInspector.ObjectPropertiesSection = function(object, title, linkifier, emptyPlaceholder, ignoreHasOwnProperty, extraProperties)
+WebInspector.ObjectPropertiesSection = function(object, title, expandedTitle, linkifier, emptyPlaceholder, ignoreHasOwnProperty, extraProperties)
lushnikov 2016/07/20 23:54:26 Let's look if we can reduce amount of arguments he
luoe 2016/07/22 22:30:58 Good call, by moving needsAlternateTitle() into OP
{
this._object = object;
this._editable = true;
@@ -43,10 +44,16 @@ 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 (expandedTitle)
+ this.expandedTitleElement = expandedTitle;
this.element._section = this;
this.registerRequiredCSS("components/objectValue.css");
@@ -71,7 +78,7 @@ WebInspector.ObjectPropertiesSection.defaultObjectPresentation = function(object
if (!object.hasChildren)
return componentRoot;
- var objectPropertiesSection = new WebInspector.ObjectPropertiesSection(object, componentRoot, linkifier);
+ var objectPropertiesSection = new WebInspector.ObjectPropertiesSection(object, componentRoot, null, linkifier);
objectPropertiesSection.editable = false;
if (skipProto)
objectPropertiesSection.skipProto();
@@ -174,16 +181,28 @@ WebInspector.ObjectPropertiesSection.RootElement = function(object, linkifier, e
WebInspector.ObjectPropertiesSection.RootElement.prototype = {
+ /**
+ * @override
+ */
onexpand: function()
{
- if (this.treeOutline)
+ if (this.treeOutline) {
this.treeOutline.element.classList.add("expanded");
+ if (this.treeOutline.expandedTitleElement)
+ this.treeOutline.titleElement.swapChildren(this.treeOutline.expandedTitleElement);
+ }
},
+ /**
+ * @override
+ */
oncollapse: function()
{
- if (this.treeOutline)
+ if (this.treeOutline) {
this.treeOutline.element.classList.remove("expanded");
+ if (this.treeOutline.expandedTitleElement)
+ this.treeOutline.titleElement.swapChildren(this.treeOutline.expandedTitleElement);
+ }
},
/**
@@ -283,8 +302,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 +317,24 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
this._updateExpandable();
},
+ /**
+ * @override
+ */
+ onexpand: function()
+ {
+ if (this.expandedValueElement)
+ this.valueElement.swapChildren(this.expandedValueElement);
+ },
+
+ /**
+ * @override
+ */
+ oncollapse: function()
+ {
+ if (this.expandedValueElement)
+ this.valueElement.swapChildren(this.expandedValueElement);
+ },
+
update: function()
{
this.nameElement = WebInspector.ObjectPropertiesSection.createNameElement(this.property.name);
@@ -325,6 +362,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.createExpandableValueElement(this.property.value);
+
this.listItemElement.removeChildren();
this.listItemElement.appendChildren(this.nameElement, separatorElement, this.valueElement);
},
@@ -376,11 +417,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 +508,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();
}
};
},
@@ -1218,6 +1258,31 @@ WebInspector.ObjectPropertiesSection.createValueElement = function(value, wasThr
}
/**
+ * @param {!WebInspector.RemoteObject} value
+ * @return {boolean}
+ */
+WebInspector.ObjectPropertiesSection.needsAlternateTitle = function(value)
+{
+ return value && !value.customPreview() && value.hasChildren && value.subtype !== "node" && value.type !== "function";
+}
+
+/**
+ * @param {!WebInspector.RemoteObject} value
+ * @return {?Element}
+ */
+WebInspector.ObjectPropertiesSection.createExpandableValueElement = 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