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..831caf281c5b2bcf81dd8992e859e28fc5388575 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 {?string|!Element=} expandedTitle |
|
lushnikov
2016/07/12 02:51:55
let's only have Element here
luoe
2016/07/13 18:06:28
Done.
|
| * @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) |
| { |
| this._object = object; |
| this._editable = true; |
| @@ -43,10 +44,24 @@ 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 (typeof expandedTitle === "string") { |
|
lushnikov
2016/07/12 02:51:55
this will go away once you have only Element as in
luoe
2016/07/13 18:06:28
Done.
|
| + this.expandedTitleElement = this.element.createChild("span"); |
| + this.expandedTitleElement.textContent = expandedTitle || ""; |
| + } else if (!!expandedTitle) { |
| + this.expandedTitleElement = expandedTitle; |
| + this.element.appendChild(expandedTitle); |
| + } |
| + |
| + if (this.expandedTitleElement) |
| + this.expandedTitleElement.classList.add("hidden"); |
|
lushnikov
2016/07/12 02:51:55
Let's use hidden attribute here and everywhere
th
luoe
2016/07/13 18:06:28
Done.
|
| this.element._section = this; |
| this.registerRequiredCSS("components/objectValue.css"); |
| @@ -71,7 +86,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(); |
| @@ -176,14 +191,24 @@ WebInspector.ObjectPropertiesSection.RootElement.prototype = { |
| onexpand: function() |
| { |
| - if (this.treeOutline) |
| + if (this.treeOutline) { |
| this.treeOutline.element.classList.add("expanded"); |
| + if (this.treeOutline.expandedTitleElement) { |
| + this.treeOutline.titleElement.classList.add("hidden"); |
| + this.treeOutline.expandedTitleElement.classList.remove("hidden"); |
| + } |
| + } |
| }, |
| oncollapse: function() |
| { |
| - if (this.treeOutline) |
| + if (this.treeOutline) { |
| this.treeOutline.element.classList.remove("expanded"); |
| + if (this.treeOutline.expandedTitleElement) { |
| + this.treeOutline.titleElement.classList.remove("hidden"); |
| + this.treeOutline.expandedTitleElement.classList.add("hidden"); |
| + } |
| + } |
| }, |
| /** |
| @@ -283,8 +308,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 +323,28 @@ WebInspector.ObjectPropertyTreeElement.prototype = { |
| this._updateExpandable(); |
| }, |
| + /** |
| + * @override |
| + */ |
| + onexpand: function() |
| + { |
| + if (this.expandedValueElement) { |
| + this.valueElement.classList.add("hidden"); |
|
lushnikov
2016/07/12 02:51:55
let's extract a _showExpandedValueElement(visible)
luoe
2016/07/13 18:06:28
No longer needed when children are swapped.
|
| + this.expandedValueElement.classList.remove("hidden"); |
| + } |
| + }, |
| + |
| + /** |
| + * @override |
| + */ |
| + oncollapse: function() |
| + { |
| + if (this.expandedValueElement) { |
| + this.valueElement.classList.remove("hidden"); |
| + this.expandedValueElement.classList.add("hidden"); |
| + } |
| + }, |
| + |
| update: function() |
| { |
| this.nameElement = WebInspector.ObjectPropertiesSection.createNameElement(this.property.name); |
| @@ -325,8 +372,14 @@ WebInspector.ObjectPropertyTreeElement.prototype = { |
| this.valueElement.title = WebInspector.UIString("No property getter"); |
| } |
| + var valueText = this.valueElement.textContent; |
| + if (this.property.value && valueText && valueText !== this.property.value.description && !this.property.wasThrown) |
|
lushnikov
2016/07/12 02:51:55
lets drop this optimization as well
luoe
2016/07/13 18:06:28
Done.
|
| + this.expandedValueElement = WebInspector.ObjectPropertiesSection.createExpandableTitleOrValueElement(this.property.value); |
| + |
| this.listItemElement.removeChildren(); |
| this.listItemElement.appendChildren(this.nameElement, separatorElement, this.valueElement); |
| + if (this.expandedValueElement) |
| + this.listItemElement.appendChild(this.expandedValueElement); |
| }, |
| _updatePropertyPath: function() |
| @@ -376,11 +429,12 @@ 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"); |
| + if (this.expandedValueElement) |
|
lushnikov
2016/07/12 02:51:55
i believe we'll always have expandedValueElement o
luoe
2016/07/13 18:06:28
We still need this because there are a few excepti
|
| + this.expandedValueElement.classList.add("hidden"); |
| this._prompt = new WebInspector.ObjectPropertyPrompt(); |
| @@ -401,7 +455,10 @@ WebInspector.ObjectPropertyTreeElement.prototype = { |
| _editingCancelled: function() |
| { |
| - this.valueElement.classList.remove("hidden"); |
| + if (this.expanded && this.expandedValueElement) |
| + this.expandedValueElement.classList.remove("hidden"); |
| + else |
| + this.valueElement.classList.remove("hidden"); |
| this._editingEnded(); |
| }, |
| @@ -1218,6 +1275,36 @@ 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.createExpandableTitleOrValueElement = function(value) |
| +{ |
| + if (!WebInspector.ObjectPropertiesSection.needsAlternateTitle(value)) |
| + return null; |
| + |
| + var valueElement = createElementWithClass("span", "value"); |
| + var type = value.type; |
|
lushnikov
2016/07/12 02:51:55
let's inline type, subtype & desct
luoe
2016/07/13 18:06:28
Done.
|
| + var subtype = value.subtype; |
| + var description = value.description; |
| + |
| + valueElement.setTextContentTruncatedIfNeeded(description || ""); |
| + valueElement.classList.add("object-value-" + (subtype || type)); |
| + valueElement.classList.add("hidden"); |
| + valueElement.title = description || ""; |
| + return valueElement; |
| +} |
| + |
| +/** |
| * @param {!WebInspector.RemoteObject} func |
| * @param {!Element} element |
| * @param {boolean} linkify |