Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @param {!WebInspector.RemoteObject} object | 7 * @param {!WebInspector.RemoteObject} object |
| 8 */ | 8 */ |
| 9 WebInspector.CustomPreviewSection = function(object) | 9 WebInspector.CustomPreviewSection = function(object) |
| 10 { | 10 { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 this._header.classList.add("custom-expandable-section-header"); | 30 this._header.classList.add("custom-expandable-section-header"); |
| 31 this._header.addEventListener("click", this._onClick.bind(this), false); | 31 this._header.addEventListener("click", this._onClick.bind(this), false); |
| 32 } | 32 } |
| 33 | 33 |
| 34 this._sectionElement.appendChild(this._header); | 34 this._sectionElement.appendChild(this._header); |
| 35 } | 35 } |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * @constructor | 38 * @constructor |
| 39 * @param {!WebInspector.RemoteObject} object | 39 * @param {!WebInspector.RemoteObject} object |
| 40 * @param {boolean=} expand | |
| 41 * @return {!Element} | |
| 42 */ | 40 */ |
| 43 WebInspector.CustomPreviewSection.createInShadow = function(object, expand) | 41 WebInspector.CustomPreviewComponent = function(object) |
| 44 { | 42 { |
| 45 var customPreviewSection = new WebInspector.CustomPreviewSection(object); | 43 this._object = object; |
| 46 var element = WebInspector.CustomPreviewSection._createComponentRoot(); | 44 this._customPreviewSection = new WebInspector.CustomPreviewSection(object); |
| 47 var shadowRoot = element.createShadowRoot(); | 45 |
| 46 this.element = WebInspector.CustomPreviewSection._createComponentRoot(); | |
| 47 this.element.addEventListener("contextmenu", this._contextMenuEventFired.bin d(this), false); | |
| 48 | |
| 49 var shadowRoot = this.element.createShadowRoot(); | |
| 48 shadowRoot.appendChild(WebInspector.View.createStyleElement("components/cust omPreviewSection.css")); | 50 shadowRoot.appendChild(WebInspector.View.createStyleElement("components/cust omPreviewSection.css")); |
| 49 shadowRoot.appendChild(customPreviewSection.element()); | 51 shadowRoot.appendChild(this._customPreviewSection.element()); |
| 52 } | |
| 50 | 53 |
| 51 if (expand && object.customPreview().hasBody) | 54 WebInspector.CustomPreviewComponent.prototype = { |
| 52 customPreviewSection._loadBody(); | 55 expandIfPossible: function() |
| 53 return element; | 56 { |
| 57 if (this._object.customPreview().hasBody && this._customPreviewSection) | |
| 58 this._customPreviewSection._loadBody(); | |
| 59 }, | |
| 60 | |
| 61 /** | |
| 62 * @param {!Event} event | |
| 63 */ | |
| 64 _contextMenuEventFired: function(event) | |
| 65 { | |
| 66 var contextMenu = new WebInspector.ContextMenu(event); | |
| 67 if (this._customPreviewSection) | |
| 68 contextMenu.appendItem(WebInspector.UIString.capitalize("Disassemble in ^native JS ^object" ), this._disassemble.bind(this)); | |
|
pfeldman
2015/04/28 16:20:40
Show as JavaScript Object
| |
| 69 contextMenu.appendApplicableItems(this._object); | |
| 70 contextMenu.show(); | |
| 71 }, | |
| 72 | |
| 73 _disassemble: function() | |
| 74 { | |
| 75 this.element.shadowRoot.textContent = ""; | |
| 76 this._customPreviewSection = null; | |
| 77 this.element.shadowRoot.appendChild(WebInspector.CustomPreviewSection._c reateStandardPreview(this._object)); | |
| 78 } | |
| 54 } | 79 } |
| 55 | 80 |
| 56 /** | 81 /** |
| 57 * @return {!Element} | 82 * @return {!Element} |
| 58 */ | 83 */ |
| 59 WebInspector.CustomPreviewSection._createComponentRoot = function() | 84 WebInspector.CustomPreviewSection._createComponentRoot = function() |
| 60 { | 85 { |
| 61 var element = createElement("span"); | 86 var element = createElement("span"); |
| 62 WebInspector.installComponentRootStyles(element); | 87 WebInspector.installComponentRootStyles(element); |
| 63 element.classList.add("source-code"); | 88 element.classList.add("source-code"); |
| 64 return element; | 89 return element; |
| 65 } | 90 } |
| 66 | 91 |
| 92 WebInspector.CustomPreviewSection._createStandardPreview = function(object) | |
| 93 { | |
| 94 var header = createElement("span"); | |
| 95 var componentRoot = WebInspector.CustomPreviewSection._createComponentRoot() ; | |
| 96 header.appendChild(componentRoot); | |
| 97 var shadowRoot = componentRoot.createShadowRoot(); | |
| 98 shadowRoot.appendChild(WebInspector.View.createStyleElement("components/obje ctValue.css")); | |
| 99 shadowRoot.appendChild(WebInspector.ObjectPropertiesSection.createValueEleme nt(object, false)); | |
|
pfeldman
2015/04/28 16:20:40
should createValueElement add objectValue on its o
| |
| 100 if (!object.hasChildren) | |
| 101 return header; | |
| 102 | |
| 103 var objectPropertiesSection = new WebInspector.ObjectPropertiesSection(objec t, header); | |
| 104 return objectPropertiesSection.element; | |
| 105 } | |
| 106 | |
| 67 WebInspector.CustomPreviewSection._tagsWhiteList = new Set(["span", "div", "ol", "li","table", "tr", "td"]); | 107 WebInspector.CustomPreviewSection._tagsWhiteList = new Set(["span", "div", "ol", "li","table", "tr", "td"]); |
| 68 | 108 |
| 69 WebInspector.CustomPreviewSection.prototype = { | 109 WebInspector.CustomPreviewSection.prototype = { |
| 70 | 110 |
| 71 /** | 111 /** |
| 72 * @return {!Element} | 112 * @return {!Element} |
| 73 */ | 113 */ |
| 74 element: function() | 114 element: function() |
| 75 { | 115 { |
| 76 return this._sectionElement; | 116 return this._sectionElement; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 * @return {!Node} | 165 * @return {!Node} |
| 126 */ | 166 */ |
| 127 _layoutObjectTag: function(objectTag) | 167 _layoutObjectTag: function(objectTag) |
| 128 { | 168 { |
| 129 objectTag.shift(); | 169 objectTag.shift(); |
| 130 var attributes = objectTag.shift(); | 170 var attributes = objectTag.shift(); |
| 131 var remoteObject = this._object.target().runtimeModel.createRemoteObject (/** @type {!RuntimeAgent.RemoteObject} */ (attributes)); | 171 var remoteObject = this._object.target().runtimeModel.createRemoteObject (/** @type {!RuntimeAgent.RemoteObject} */ (attributes)); |
| 132 if (remoteObject.customPreview()) | 172 if (remoteObject.customPreview()) |
| 133 return (new WebInspector.CustomPreviewSection(remoteObject)).element (); | 173 return (new WebInspector.CustomPreviewSection(remoteObject)).element (); |
| 134 | 174 |
| 135 var header = createElement("span"); | 175 var sectionElement = WebInspector.CustomPreviewSection._createStandardPr eview(remoteObject); |
| 136 var componentRoot = WebInspector.CustomPreviewSection._createComponentRo ot(); | 176 sectionElement.classList.toggle("custom-expandable-section-standard-sect ion", remoteObject.hasChildren); |
| 137 header.appendChild(componentRoot); | |
| 138 var shadowRoot = componentRoot.createShadowRoot(); | |
| 139 shadowRoot.appendChild(WebInspector.View.createStyleElement("components/ objectValue.css")); | |
| 140 shadowRoot.appendChild(WebInspector.ObjectPropertiesSection.createValueE lement(remoteObject, false)); | |
| 141 if (!remoteObject.hasChildren) | |
| 142 return header; | |
| 143 | |
| 144 var objectPropertiesSection = new WebInspector.ObjectPropertiesSection(r emoteObject, header); | |
| 145 var sectionElement = objectPropertiesSection.element; | |
| 146 sectionElement.classList.add("custom-expandable-section-standard-section "); | |
| 147 return sectionElement; | 177 return sectionElement; |
| 148 }, | 178 }, |
| 149 | 179 |
| 150 /** | 180 /** |
| 151 * @param {!Node} parentElement | 181 * @param {!Node} parentElement |
| 152 * @param {!Array.<*>} jsonMLTags | 182 * @param {!Array.<*>} jsonMLTags |
| 153 */ | 183 */ |
| 154 _appendJsonMLTags: function(parentElement, jsonMLTags) | 184 _appendJsonMLTags: function(parentElement, jsonMLTags) |
| 155 { | 185 { |
| 156 for (var i = 0; i < jsonMLTags.length; ++i) | 186 for (var i = 0; i < jsonMLTags.length; ++i) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 { | 270 { |
| 241 if (!bodyJsonML) | 271 if (!bodyJsonML) |
| 242 return; | 272 return; |
| 243 | 273 |
| 244 this._cachedContent = this._renderJSONMLTag(bodyJsonML); | 274 this._cachedContent = this._renderJSONMLTag(bodyJsonML); |
| 245 this._sectionElement.appendChild(this._cachedContent); | 275 this._sectionElement.appendChild(this._cachedContent); |
| 246 this._toggleExpand(); | 276 this._toggleExpand(); |
| 247 } | 277 } |
| 248 } | 278 } |
| 249 } | 279 } |
| OLD | NEW |