Chromium Code Reviews| 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 |