| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 Components.ObjectPopoverHelper = class extends UI.PopoverHelper { | 34 ObjectUI.ObjectPopoverHelper = class extends UI.PopoverHelper { |
| 35 /** | 35 /** |
| 36 * @param {!Element} panelElement | 36 * @param {!Element} panelElement |
| 37 * @param {function(!Element, !Event):(!Element|!AnchorBox|undefined)} getAnch
or | 37 * @param {function(!Element, !Event):(!Element|!AnchorBox|undefined)} getAnch
or |
| 38 * @param {function(!Element, function(!SDK.RemoteObject, boolean, !Element=):
undefined, string):undefined} queryObject | 38 * @param {function(!Element, function(!SDK.RemoteObject, boolean, !Element=):
undefined, string):undefined} queryObject |
| 39 * @param {function()=} onHide | 39 * @param {function()=} onHide |
| 40 * @param {boolean=} disableOnClick | 40 * @param {boolean=} disableOnClick |
| 41 */ | 41 */ |
| 42 constructor(panelElement, getAnchor, queryObject, onHide, disableOnClick) { | 42 constructor(panelElement, getAnchor, queryObject, onHide, disableOnClick) { |
| 43 super(panelElement, disableOnClick); | 43 super(panelElement, disableOnClick); |
| 44 this.initializeCallbacks(getAnchor, this._showObjectPopover.bind(this), this
._onHideObjectPopover.bind(this)); | 44 this.initializeCallbacks(getAnchor, this._showObjectPopover.bind(this), this
._onHideObjectPopover.bind(this)); |
| 45 this._queryObject = queryObject; | 45 this._queryObject = queryObject; |
| 46 this._onHideCallback = onHide; | 46 this._onHideCallback = onHide; |
| 47 this._popoverObjectGroup = 'popover'; | 47 this._popoverObjectGroup = 'popover'; |
| 48 panelElement.addEventListener('scroll', this.hidePopover.bind(this), true); | 48 panelElement.addEventListener('scroll', this.hidePopover.bind(this), true); |
| 49 } | 49 } |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * @param {!Element} element | 52 * @param {!Element} element |
| 53 * @param {!UI.Popover} popover | 53 * @param {!UI.Popover} popover |
| 54 */ | 54 */ |
| 55 _showObjectPopover(element, popover) { | 55 _showObjectPopover(element, popover) { |
| 56 /** | 56 /** |
| 57 * @param {!SDK.RemoteObject} funcObject | 57 * @param {!SDK.RemoteObject} funcObject |
| 58 * @param {!Element} popoverContentElement | 58 * @param {!Element} popoverContentElement |
| 59 * @param {!Element} popoverValueElement | 59 * @param {!Element} popoverValueElement |
| 60 * @param {!Element} anchorElement | 60 * @param {!Element} anchorElement |
| 61 * @param {?Array.<!SDK.RemoteObjectProperty>} properties | 61 * @param {?Array.<!SDK.RemoteObjectProperty>} properties |
| 62 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties | 62 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties |
| 63 * @this {Components.ObjectPopoverHelper} | 63 * @this {ObjectUI.ObjectPopoverHelper} |
| 64 */ | 64 */ |
| 65 function didGetFunctionProperties( | 65 function didGetFunctionProperties( |
| 66 funcObject, popoverContentElement, popoverValueElement, anchorElement, p
roperties, internalProperties) { | 66 funcObject, popoverContentElement, popoverValueElement, anchorElement, p
roperties, internalProperties) { |
| 67 if (internalProperties) { | 67 if (internalProperties) { |
| 68 for (var i = 0; i < internalProperties.length; i++) { | 68 for (var i = 0; i < internalProperties.length; i++) { |
| 69 if (internalProperties[i].name === '[[TargetFunction]]') { | 69 if (internalProperties[i].name === '[[TargetFunction]]') { |
| 70 funcObject = internalProperties[i].value; | 70 funcObject = internalProperties[i].value; |
| 71 break; | 71 break; |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 Components.ObjectPropertiesSection.formatObjectAsFunction(funcObject, popo
verValueElement, true); | 75 ObjectUI.ObjectPropertiesSection.formatObjectAsFunction(funcObject, popove
rValueElement, true); |
| 76 funcObject.debuggerModel() | 76 funcObject.debuggerModel() |
| 77 .functionDetailsPromise(funcObject) | 77 .functionDetailsPromise(funcObject) |
| 78 .then(didGetFunctionDetails.bind(this, popoverContentElement, anchorEl
ement)); | 78 .then(didGetFunctionDetails.bind(this, popoverContentElement, anchorEl
ement)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * @param {!Element} popoverContentElement | 82 * @param {!Element} popoverContentElement |
| 83 * @param {!Element} anchorElement | 83 * @param {!Element} anchorElement |
| 84 * @param {?SDK.DebuggerModel.FunctionDetails} response | 84 * @param {?SDK.DebuggerModel.FunctionDetails} response |
| 85 * @this {Components.ObjectPopoverHelper} | 85 * @this {ObjectUI.ObjectPopoverHelper} |
| 86 */ | 86 */ |
| 87 function didGetFunctionDetails(popoverContentElement, anchorElement, respons
e) { | 87 function didGetFunctionDetails(popoverContentElement, anchorElement, respons
e) { |
| 88 if (!response || popover.disposed) | 88 if (!response || popover.disposed) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 var container = createElementWithClass('div', 'object-popover-container'); | 91 var container = createElementWithClass('div', 'object-popover-container'); |
| 92 var title = container.createChild('div', 'function-popover-title source-co
de'); | 92 var title = container.createChild('div', 'function-popover-title source-co
de'); |
| 93 var functionName = title.createChild('span', 'function-name'); | 93 var functionName = title.createChild('span', 'function-name'); |
| 94 functionName.textContent = UI.beautifyFunctionName(response.functionName); | 94 functionName.textContent = UI.beautifyFunctionName(response.functionName); |
| 95 | 95 |
| 96 var rawLocation = response.location; | 96 var rawLocation = response.location; |
| 97 var linkContainer = title.createChild('div', 'function-title-link-containe
r'); | 97 var linkContainer = title.createChild('div', 'function-title-link-containe
r'); |
| 98 if (rawLocation && Runtime.experiments.isEnabled('continueToFirstInvocatio
n')) { | 98 if (rawLocation && Runtime.experiments.isEnabled('continueToFirstInvocatio
n')) { |
| 99 var sectionToolbar = new UI.Toolbar('function-location-step-into', linkC
ontainer); | 99 var sectionToolbar = new UI.Toolbar('function-location-step-into', linkC
ontainer); |
| 100 var stepInto = new UI.ToolbarButton(Common.UIString('Continue to first i
nvocation'), 'largeicon-step-in'); | 100 var stepInto = new UI.ToolbarButton(Common.UIString('Continue to first i
nvocation'), 'largeicon-step-in'); |
| 101 stepInto.addEventListener(UI.ToolbarButton.Events.Click, () => rawLocati
on.continueToLocation()); | 101 stepInto.addEventListener(UI.ToolbarButton.Events.Click, () => rawLocati
on.continueToLocation()); |
| 102 sectionToolbar.appendToolbarItem(stepInto); | 102 sectionToolbar.appendToolbarItem(stepInto); |
| 103 } | 103 } |
| 104 var sourceURL = rawLocation && rawLocation.script() ? rawLocation.script()
.sourceURL : null; | 104 var sourceURL = rawLocation && rawLocation.script() ? rawLocation.script()
.sourceURL : null; |
| 105 if (rawLocation && sourceURL) | 105 if (rawLocation && sourceURL) |
| 106 linkContainer.appendChild(this._lazyLinkifier().linkifyRawLocation(rawLo
cation, sourceURL)); | 106 linkContainer.appendChild(this._lazyLinkifier().linkifyRawLocation(rawLo
cation, sourceURL)); |
| 107 container.appendChild(popoverContentElement); | 107 container.appendChild(popoverContentElement); |
| 108 popover.showForAnchor(container, anchorElement); | 108 popover.showForAnchor(container, anchorElement); |
| 109 } | 109 } |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * @param {!SDK.RemoteObject} result | 112 * @param {!SDK.RemoteObject} result |
| 113 * @param {boolean} wasThrown | 113 * @param {boolean} wasThrown |
| 114 * @param {!Element=} anchorOverride | 114 * @param {!Element=} anchorOverride |
| 115 * @this {Components.ObjectPopoverHelper} | 115 * @this {ObjectUI.ObjectPopoverHelper} |
| 116 */ | 116 */ |
| 117 function didQueryObject(result, wasThrown, anchorOverride) { | 117 function didQueryObject(result, wasThrown, anchorOverride) { |
| 118 if (popover.disposed) | 118 if (popover.disposed) |
| 119 return; | 119 return; |
| 120 if (wasThrown) { | 120 if (wasThrown) { |
| 121 this.hidePopover(); | 121 this.hidePopover(); |
| 122 return; | 122 return; |
| 123 } | 123 } |
| 124 this._objectTarget = result.target(); | 124 this._objectTarget = result.target(); |
| 125 var anchorElement = anchorOverride || element; | 125 var anchorElement = anchorOverride || element; |
| 126 var description = result.description.trimEnd(Components.ObjectPopoverHelpe
r.MaxPopoverTextLength); | 126 var description = result.description.trimEnd(ObjectUI.ObjectPopoverHelper.
MaxPopoverTextLength); |
| 127 var popoverContentElement = null; | 127 var popoverContentElement = null; |
| 128 if (result.type !== 'object') { | 128 if (result.type !== 'object') { |
| 129 popoverContentElement = createElement('span'); | 129 popoverContentElement = createElement('span'); |
| 130 UI.appendStyle(popoverContentElement, 'components/objectValue.css'); | 130 UI.appendStyle(popoverContentElement, 'object_ui/objectValue.css'); |
| 131 var valueElement = popoverContentElement.createChild('span', 'monospace
object-value-' + result.type); | 131 var valueElement = popoverContentElement.createChild('span', 'monospace
object-value-' + result.type); |
| 132 valueElement.style.whiteSpace = 'pre'; | 132 valueElement.style.whiteSpace = 'pre'; |
| 133 | 133 |
| 134 if (result.type === 'string') | 134 if (result.type === 'string') |
| 135 valueElement.createTextChildren('"', description, '"'); | 135 valueElement.createTextChildren('"', description, '"'); |
| 136 else if (result.type !== 'function') | 136 else if (result.type !== 'function') |
| 137 valueElement.textContent = description; | 137 valueElement.textContent = description; |
| 138 | 138 |
| 139 if (result.type === 'function') { | 139 if (result.type === 'function') { |
| 140 result.getOwnProperties( | 140 result.getOwnProperties( |
| 141 false /* generatePreview */, | 141 false /* generatePreview */, |
| 142 didGetFunctionProperties.bind(this, result, popoverContentElement,
valueElement, anchorElement)); | 142 didGetFunctionProperties.bind(this, result, popoverContentElement,
valueElement, anchorElement)); |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 145 popover.showForAnchor(popoverContentElement, anchorElement); | 145 popover.showForAnchor(popoverContentElement, anchorElement); |
| 146 } else { | 146 } else { |
| 147 if (result.subtype === 'node') { | 147 if (result.subtype === 'node') { |
| 148 SDK.DOMModel.highlightObjectAsDOMNode(result); | 148 SDK.DOMModel.highlightObjectAsDOMNode(result); |
| 149 this._resultHighlightedAsDOM = true; | 149 this._resultHighlightedAsDOM = true; |
| 150 } | 150 } |
| 151 | 151 |
| 152 if (result.customPreview()) { | 152 if (result.customPreview()) { |
| 153 var customPreviewComponent = new Components.CustomPreviewComponent(res
ult); | 153 var customPreviewComponent = new ObjectUI.CustomPreviewComponent(resul
t); |
| 154 customPreviewComponent.expandIfPossible(); | 154 customPreviewComponent.expandIfPossible(); |
| 155 popoverContentElement = customPreviewComponent.element; | 155 popoverContentElement = customPreviewComponent.element; |
| 156 } else { | 156 } else { |
| 157 popoverContentElement = createElement('div'); | 157 popoverContentElement = createElement('div'); |
| 158 this._titleElement = popoverContentElement.createChild('div', 'monospa
ce'); | 158 this._titleElement = popoverContentElement.createChild('div', 'monospa
ce'); |
| 159 this._titleElement.createChild('span', 'source-frame-popover-title').t
extContent = description; | 159 this._titleElement.createChild('span', 'source-frame-popover-title').t
extContent = description; |
| 160 var section = new Components.ObjectPropertiesSection(result, '', this.
_lazyLinkifier()); | 160 var section = new ObjectUI.ObjectPropertiesSection(result, '', this._l
azyLinkifier()); |
| 161 section.element.classList.add('source-frame-popover-tree'); | 161 section.element.classList.add('source-frame-popover-tree'); |
| 162 section.titleLessMode(); | 162 section.titleLessMode(); |
| 163 popoverContentElement.appendChild(section.element); | 163 popoverContentElement.appendChild(section.element); |
| 164 } | 164 } |
| 165 var popoverWidth = 300; | 165 var popoverWidth = 300; |
| 166 var popoverHeight = 250; | 166 var popoverHeight = 250; |
| 167 popover.showForAnchor(popoverContentElement, anchorElement, popoverWidth
, popoverHeight); | 167 popover.showForAnchor(popoverContentElement, anchorElement, popoverWidth
, popoverHeight); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 this._queryObject(element, didQueryObject.bind(this), this._popoverObjectGro
up); | 170 this._queryObject(element, didQueryObject.bind(this), this._popoverObjectGro
up); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 190 /** | 190 /** |
| 191 * @return {!Components.Linkifier} | 191 * @return {!Components.Linkifier} |
| 192 */ | 192 */ |
| 193 _lazyLinkifier() { | 193 _lazyLinkifier() { |
| 194 if (!this._linkifier) | 194 if (!this._linkifier) |
| 195 this._linkifier = new Components.Linkifier(); | 195 this._linkifier = new Components.Linkifier(); |
| 196 return this._linkifier; | 196 return this._linkifier; |
| 197 } | 197 } |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 Components.ObjectPopoverHelper.MaxPopoverTextLength = 10000; | 200 ObjectUI.ObjectPopoverHelper.MaxPopoverTextLength = 10000; |
| OLD | NEW |