| 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 14 matching lines...) Expand all Loading... |
| 25 WebInspector.console.error("Broken formatter: header should be an elemen
t node."); | 25 WebInspector.console.error("Broken formatter: header should be an elemen
t node."); |
| 26 return; | 26 return; |
| 27 } | 27 } |
| 28 | 28 |
| 29 if (customPreview.hasBody) { | 29 if (customPreview.hasBody) { |
| 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 */ | 40 */ |
| 41 WebInspector.CustomPreviewComponent = function(object) | 41 WebInspector.CustomPreviewComponent = function(object) |
| 42 { | 42 { |
| 43 this._object = object; | 43 this._object = object; |
| 44 this._customPreviewSection = new WebInspector.CustomPreviewSection(object); | 44 this._customPreviewSection = new WebInspector.CustomPreviewSection(object); |
| 45 this.element = createElementWithClass("span", "source-code"); | 45 this.element = createElementWithClass("span", "source-code"); |
| 46 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element, "
components/customPreviewSection.css"); | 46 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element, "
components/customPreviewSection.css"); |
| 47 this.element.addEventListener("contextmenu", this._contextMenuEventFired.bin
d(this), false); | 47 this.element.addEventListener("contextmenu", this._contextMenuEventFired.bin
d(this), false); |
| 48 shadowRoot.appendChild(this._customPreviewSection.element()); | 48 shadowRoot.appendChild(this._customPreviewSection.element()); |
| 49 } | 49 }; |
| 50 | 50 |
| 51 WebInspector.CustomPreviewComponent.prototype = { | 51 WebInspector.CustomPreviewComponent.prototype = { |
| 52 expandIfPossible: function() | 52 expandIfPossible: function() |
| 53 { | 53 { |
| 54 if (this._object.customPreview().hasBody && this._customPreviewSection) | 54 if (this._object.customPreview().hasBody && this._customPreviewSection) |
| 55 this._customPreviewSection._loadBody(); | 55 this._customPreviewSection._loadBody(); |
| 56 }, | 56 }, |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * @param {!Event} event | 59 * @param {!Event} event |
| 60 */ | 60 */ |
| 61 _contextMenuEventFired: function(event) | 61 _contextMenuEventFired: function(event) |
| 62 { | 62 { |
| 63 var contextMenu = new WebInspector.ContextMenu(event); | 63 var contextMenu = new WebInspector.ContextMenu(event); |
| 64 if (this._customPreviewSection) | 64 if (this._customPreviewSection) |
| 65 contextMenu.appendItem(WebInspector.UIString.capitalize("Show as Jav
ascript ^object"), this._disassemble.bind(this)); | 65 contextMenu.appendItem(WebInspector.UIString.capitalize("Show as Jav
ascript ^object"), this._disassemble.bind(this)); |
| 66 contextMenu.appendApplicableItems(this._object); | 66 contextMenu.appendApplicableItems(this._object); |
| 67 contextMenu.show(); | 67 contextMenu.show(); |
| 68 }, | 68 }, |
| 69 | 69 |
| 70 _disassemble: function() | 70 _disassemble: function() |
| 71 { | 71 { |
| 72 this.element.shadowRoot.textContent = ""; | 72 this.element.shadowRoot.textContent = ""; |
| 73 this._customPreviewSection = null; | 73 this._customPreviewSection = null; |
| 74 this.element.shadowRoot.appendChild(WebInspector.ObjectPropertiesSection
.defaultObjectPresentation(this._object)); | 74 this.element.shadowRoot.appendChild(WebInspector.ObjectPropertiesSection
.defaultObjectPresentation(this._object)); |
| 75 } | 75 } |
| 76 } | 76 }; |
| 77 | 77 |
| 78 WebInspector.CustomPreviewSection._tagsWhiteList = new Set(["span", "div", "ol",
"li","table", "tr", "td"]); | 78 WebInspector.CustomPreviewSection._tagsWhiteList = new Set(["span", "div", "ol",
"li","table", "tr", "td"]); |
| 79 | 79 |
| 80 WebInspector.CustomPreviewSection.prototype = { | 80 WebInspector.CustomPreviewSection.prototype = { |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * @return {!Element} | 83 * @return {!Element} |
| 84 */ | 84 */ |
| 85 element: function() | 85 element: function() |
| 86 { | 86 { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 function onBodyLoaded(bodyJsonML) | 241 function onBodyLoaded(bodyJsonML) |
| 242 { | 242 { |
| 243 if (!bodyJsonML) | 243 if (!bodyJsonML) |
| 244 return; | 244 return; |
| 245 | 245 |
| 246 this._cachedContent = this._renderJSONMLTag(bodyJsonML); | 246 this._cachedContent = this._renderJSONMLTag(bodyJsonML); |
| 247 this._sectionElement.appendChild(this._cachedContent); | 247 this._sectionElement.appendChild(this._cachedContent); |
| 248 this._toggleExpand(); | 248 this._toggleExpand(); |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 } | 251 }; |
| OLD | NEW |