| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * @unrestricted | 28 * @unrestricted |
| 29 */ | 29 */ |
| 30 WebInspector.ObjectPropertiesSection = class extends TreeOutlineInShadow { | 30 Components.ObjectPropertiesSection = class extends TreeOutlineInShadow { |
| 31 /** | 31 /** |
| 32 * @param {!WebInspector.RemoteObject} object | 32 * @param {!SDK.RemoteObject} object |
| 33 * @param {?string|!Element=} title | 33 * @param {?string|!Element=} title |
| 34 * @param {!WebInspector.Linkifier=} linkifier | 34 * @param {!Components.Linkifier=} linkifier |
| 35 * @param {?string=} emptyPlaceholder | 35 * @param {?string=} emptyPlaceholder |
| 36 * @param {boolean=} ignoreHasOwnProperty | 36 * @param {boolean=} ignoreHasOwnProperty |
| 37 * @param {!Array.<!WebInspector.RemoteObjectProperty>=} extraProperties | 37 * @param {!Array.<!SDK.RemoteObjectProperty>=} extraProperties |
| 38 */ | 38 */ |
| 39 constructor(object, title, linkifier, emptyPlaceholder, ignoreHasOwnProperty,
extraProperties) { | 39 constructor(object, title, linkifier, emptyPlaceholder, ignoreHasOwnProperty,
extraProperties) { |
| 40 super(); | 40 super(); |
| 41 this._object = object; | 41 this._object = object; |
| 42 this._editable = true; | 42 this._editable = true; |
| 43 this.hideOverflow(); | 43 this.hideOverflow(); |
| 44 this.setFocusable(false); | 44 this.setFocusable(false); |
| 45 this._objectTreeElement = new WebInspector.ObjectPropertiesSection.RootEleme
nt( | 45 this._objectTreeElement = new Components.ObjectPropertiesSection.RootElement
( |
| 46 object, linkifier, emptyPlaceholder, ignoreHasOwnProperty, extraProperti
es); | 46 object, linkifier, emptyPlaceholder, ignoreHasOwnProperty, extraProperti
es); |
| 47 this.appendChild(this._objectTreeElement); | 47 this.appendChild(this._objectTreeElement); |
| 48 if (typeof title === 'string' || !title) { | 48 if (typeof title === 'string' || !title) { |
| 49 this.titleElement = this.element.createChild('span'); | 49 this.titleElement = this.element.createChild('span'); |
| 50 this.titleElement.textContent = title || ''; | 50 this.titleElement.textContent = title || ''; |
| 51 } else { | 51 } else { |
| 52 this.titleElement = title; | 52 this.titleElement = title; |
| 53 this.element.appendChild(title); | 53 this.element.appendChild(title); |
| 54 } | 54 } |
| 55 | 55 |
| 56 if (object.description && WebInspector.ObjectPropertiesSection._needsAlterna
teTitle(object)) { | 56 if (object.description && Components.ObjectPropertiesSection._needsAlternate
Title(object)) { |
| 57 this.expandedTitleElement = createElement('span'); | 57 this.expandedTitleElement = createElement('span'); |
| 58 this.expandedTitleElement.createTextChild(object.description); | 58 this.expandedTitleElement.createTextChild(object.description); |
| 59 | 59 |
| 60 var note = this.expandedTitleElement.createChild('span', 'object-state-not
e'); | 60 var note = this.expandedTitleElement.createChild('span', 'object-state-not
e'); |
| 61 note.classList.add('info-note'); | 61 note.classList.add('info-note'); |
| 62 note.title = WebInspector.UIString('Value below was evaluated just now.'); | 62 note.title = Common.UIString('Value below was evaluated just now.'); |
| 63 } | 63 } |
| 64 | 64 |
| 65 this.element._section = this; | 65 this.element._section = this; |
| 66 this.registerRequiredCSS('components/objectValue.css'); | 66 this.registerRequiredCSS('components/objectValue.css'); |
| 67 this.registerRequiredCSS('components/objectPropertiesSection.css'); | 67 this.registerRequiredCSS('components/objectPropertiesSection.css'); |
| 68 this.rootElement().childrenListElement.classList.add('source-code', 'object-
properties-section'); | 68 this.rootElement().childrenListElement.classList.add('source-code', 'object-
properties-section'); |
| 69 } | 69 } |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * @param {!WebInspector.RemoteObject} object | 72 * @param {!SDK.RemoteObject} object |
| 73 * @param {!WebInspector.Linkifier=} linkifier | 73 * @param {!Components.Linkifier=} linkifier |
| 74 * @param {boolean=} skipProto | 74 * @param {boolean=} skipProto |
| 75 * @return {!Element} | 75 * @return {!Element} |
| 76 */ | 76 */ |
| 77 static defaultObjectPresentation(object, linkifier, skipProto) { | 77 static defaultObjectPresentation(object, linkifier, skipProto) { |
| 78 var componentRoot = createElementWithClass('span', 'source-code'); | 78 var componentRoot = createElementWithClass('span', 'source-code'); |
| 79 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(componentRoot,
'components/objectValue.css'); | 79 var shadowRoot = UI.createShadowRootWithCoreStyles(componentRoot, 'component
s/objectValue.css'); |
| 80 shadowRoot.appendChild(WebInspector.ObjectPropertiesSection.createValueEleme
nt(object, false)); | 80 shadowRoot.appendChild(Components.ObjectPropertiesSection.createValueElement
(object, false)); |
| 81 if (!object.hasChildren) | 81 if (!object.hasChildren) |
| 82 return componentRoot; | 82 return componentRoot; |
| 83 | 83 |
| 84 var objectPropertiesSection = new WebInspector.ObjectPropertiesSection(objec
t, componentRoot, linkifier); | 84 var objectPropertiesSection = new Components.ObjectPropertiesSection(object,
componentRoot, linkifier); |
| 85 objectPropertiesSection.editable = false; | 85 objectPropertiesSection.editable = false; |
| 86 if (skipProto) | 86 if (skipProto) |
| 87 objectPropertiesSection.skipProto(); | 87 objectPropertiesSection.skipProto(); |
| 88 | 88 |
| 89 return objectPropertiesSection.element; | 89 return objectPropertiesSection.element; |
| 90 } | 90 } |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * @param {!WebInspector.RemoteObjectProperty} propertyA | 93 * @param {!SDK.RemoteObjectProperty} propertyA |
| 94 * @param {!WebInspector.RemoteObjectProperty} propertyB | 94 * @param {!SDK.RemoteObjectProperty} propertyB |
| 95 * @return {number} | 95 * @return {number} |
| 96 */ | 96 */ |
| 97 static CompareProperties(propertyA, propertyB) { | 97 static CompareProperties(propertyA, propertyB) { |
| 98 var a = propertyA.name; | 98 var a = propertyA.name; |
| 99 var b = propertyB.name; | 99 var b = propertyB.name; |
| 100 if (a === '__proto__') | 100 if (a === '__proto__') |
| 101 return 1; | 101 return 1; |
| 102 if (b === '__proto__') | 102 if (b === '__proto__') |
| 103 return -1; | 103 return -1; |
| 104 if (propertyA.symbol && !propertyB.symbol) | 104 if (propertyA.symbol && !propertyB.symbol) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 121 return nameElement; | 121 return nameElement; |
| 122 } | 122 } |
| 123 | 123 |
| 124 /** | 124 /** |
| 125 * @param {?string=} description | 125 * @param {?string=} description |
| 126 * @return {string} valueText | 126 * @return {string} valueText |
| 127 */ | 127 */ |
| 128 static valueTextForFunctionDescription(description) { | 128 static valueTextForFunctionDescription(description) { |
| 129 var text = description.replace(/^function [gs]et /, 'function '); | 129 var text = description.replace(/^function [gs]et /, 'function '); |
| 130 var functionPrefixWithArguments = | 130 var functionPrefixWithArguments = |
| 131 new RegExp(WebInspector.ObjectPropertiesSection._functionPrefixSource.so
urce + '([^)]*)'); | 131 new RegExp(Components.ObjectPropertiesSection._functionPrefixSource.sour
ce + '([^)]*)'); |
| 132 var matches = functionPrefixWithArguments.exec(text); | 132 var matches = functionPrefixWithArguments.exec(text); |
| 133 if (!matches) { | 133 if (!matches) { |
| 134 // process shorthand methods | 134 // process shorthand methods |
| 135 matches = /[^(]*(\([^)]*)/.exec(text); | 135 matches = /[^(]*(\([^)]*)/.exec(text); |
| 136 } | 136 } |
| 137 var match = matches ? matches[1] : null; | 137 var match = matches ? matches[1] : null; |
| 138 return match ? match.replace(/\n/g, ' ') + ')' : (text || ''); | 138 return match ? match.replace(/\n/g, ' ') + ')' : (text || ''); |
| 139 } | 139 } |
| 140 | 140 |
| 141 /** | 141 /** |
| 142 * @param {!WebInspector.RemoteObject} value | 142 * @param {!SDK.RemoteObject} value |
| 143 * @param {boolean} wasThrown | 143 * @param {boolean} wasThrown |
| 144 * @param {!Element=} parentElement | 144 * @param {!Element=} parentElement |
| 145 * @param {!WebInspector.Linkifier=} linkifier | 145 * @param {!Components.Linkifier=} linkifier |
| 146 * @return {!Element} | 146 * @return {!Element} |
| 147 */ | 147 */ |
| 148 static createValueElementWithCustomSupport(value, wasThrown, parentElement, li
nkifier) { | 148 static createValueElementWithCustomSupport(value, wasThrown, parentElement, li
nkifier) { |
| 149 if (value.customPreview()) { | 149 if (value.customPreview()) { |
| 150 var result = (new WebInspector.CustomPreviewComponent(value)).element; | 150 var result = (new Components.CustomPreviewComponent(value)).element; |
| 151 result.classList.add('object-properties-section-custom-section'); | 151 result.classList.add('object-properties-section-custom-section'); |
| 152 return result; | 152 return result; |
| 153 } | 153 } |
| 154 return WebInspector.ObjectPropertiesSection.createValueElement(value, wasThr
own, parentElement, linkifier); | 154 return Components.ObjectPropertiesSection.createValueElement(value, wasThrow
n, parentElement, linkifier); |
| 155 } | 155 } |
| 156 | 156 |
| 157 /** | 157 /** |
| 158 * @param {!WebInspector.RemoteObject} value | 158 * @param {!SDK.RemoteObject} value |
| 159 * @param {boolean} wasThrown | 159 * @param {boolean} wasThrown |
| 160 * @param {!Element=} parentElement | 160 * @param {!Element=} parentElement |
| 161 * @param {!WebInspector.Linkifier=} linkifier | 161 * @param {!Components.Linkifier=} linkifier |
| 162 * @return {!Element} | 162 * @return {!Element} |
| 163 */ | 163 */ |
| 164 static createValueElement(value, wasThrown, parentElement, linkifier) { | 164 static createValueElement(value, wasThrown, parentElement, linkifier) { |
| 165 var valueElement = createElementWithClass('span', 'value'); | 165 var valueElement = createElementWithClass('span', 'value'); |
| 166 var type = value.type; | 166 var type = value.type; |
| 167 var subtype = value.subtype; | 167 var subtype = value.subtype; |
| 168 var description = value.description; | 168 var description = value.description; |
| 169 var prefix; | 169 var prefix; |
| 170 var valueText; | 170 var valueText; |
| 171 var suffix; | 171 var suffix; |
| 172 if (wasThrown) { | 172 if (wasThrown) { |
| 173 prefix = '[Exception: '; | 173 prefix = '[Exception: '; |
| 174 valueText = description; | 174 valueText = description; |
| 175 suffix = ']'; | 175 suffix = ']'; |
| 176 } else if (type === 'string' && typeof description === 'string') { | 176 } else if (type === 'string' && typeof description === 'string') { |
| 177 // Render \n as a nice unicode cr symbol. | 177 // Render \n as a nice unicode cr symbol. |
| 178 prefix = '"'; | 178 prefix = '"'; |
| 179 valueText = description.replace(/\n/g, '\u21B5'); | 179 valueText = description.replace(/\n/g, '\u21B5'); |
| 180 suffix = '"'; | 180 suffix = '"'; |
| 181 } else if (type === 'function') { | 181 } else if (type === 'function') { |
| 182 valueText = WebInspector.ObjectPropertiesSection.valueTextForFunctionDescr
iption(description); | 182 valueText = Components.ObjectPropertiesSection.valueTextForFunctionDescrip
tion(description); |
| 183 } else if (type !== 'object' || subtype !== 'node') { | 183 } else if (type !== 'object' || subtype !== 'node') { |
| 184 valueText = description; | 184 valueText = description; |
| 185 } | 185 } |
| 186 if (type !== 'number' || valueText.indexOf('e') === -1) { | 186 if (type !== 'number' || valueText.indexOf('e') === -1) { |
| 187 valueElement.setTextContentTruncatedIfNeeded(valueText || ''); | 187 valueElement.setTextContentTruncatedIfNeeded(valueText || ''); |
| 188 if (prefix) | 188 if (prefix) |
| 189 valueElement.insertBefore(createTextNode(prefix), valueElement.firstChil
d); | 189 valueElement.insertBefore(createTextNode(prefix), valueElement.firstChil
d); |
| 190 if (suffix) | 190 if (suffix) |
| 191 valueElement.createTextChild(suffix); | 191 valueElement.createTextChild(suffix); |
| 192 } else { | 192 } else { |
| 193 var numberParts = valueText.split('e'); | 193 var numberParts = valueText.split('e'); |
| 194 var mantissa = valueElement.createChild('span', 'object-value-scientific-n
otation-mantissa'); | 194 var mantissa = valueElement.createChild('span', 'object-value-scientific-n
otation-mantissa'); |
| 195 mantissa.textContent = numberParts[0]; | 195 mantissa.textContent = numberParts[0]; |
| 196 var exponent = valueElement.createChild('span', 'object-value-scientific-n
otation-exponent'); | 196 var exponent = valueElement.createChild('span', 'object-value-scientific-n
otation-exponent'); |
| 197 exponent.textContent = 'e' + numberParts[1]; | 197 exponent.textContent = 'e' + numberParts[1]; |
| 198 valueElement.classList.add('object-value-scientific-notation-number'); | 198 valueElement.classList.add('object-value-scientific-notation-number'); |
| 199 if (parentElement) // FIXME: do it in the caller. | 199 if (parentElement) // FIXME: do it in the caller. |
| 200 parentElement.classList.add('hbox'); | 200 parentElement.classList.add('hbox'); |
| 201 } | 201 } |
| 202 | 202 |
| 203 if (wasThrown) | 203 if (wasThrown) |
| 204 valueElement.classList.add('error'); | 204 valueElement.classList.add('error'); |
| 205 if (subtype || type) | 205 if (subtype || type) |
| 206 valueElement.classList.add('object-value-' + (subtype || type)); | 206 valueElement.classList.add('object-value-' + (subtype || type)); |
| 207 | 207 |
| 208 if (type === 'object' && subtype === 'node' && description) { | 208 if (type === 'object' && subtype === 'node' && description) { |
| 209 WebInspector.DOMPresentationUtils.createSpansForNodeTitle(valueElement, de
scription); | 209 Components.DOMPresentationUtils.createSpansForNodeTitle(valueElement, desc
ription); |
| 210 valueElement.addEventListener('click', mouseClick, false); | 210 valueElement.addEventListener('click', mouseClick, false); |
| 211 valueElement.addEventListener('mousemove', mouseMove, false); | 211 valueElement.addEventListener('mousemove', mouseMove, false); |
| 212 valueElement.addEventListener('mouseleave', mouseLeave, false); | 212 valueElement.addEventListener('mouseleave', mouseLeave, false); |
| 213 } else { | 213 } else { |
| 214 valueElement.title = description || ''; | 214 valueElement.title = description || ''; |
| 215 } | 215 } |
| 216 | 216 |
| 217 if (type === 'object' && subtype === 'internal#location') { | 217 if (type === 'object' && subtype === 'internal#location') { |
| 218 var rawLocation = value.debuggerModel().createRawLocationByScriptId( | 218 var rawLocation = value.debuggerModel().createRawLocationByScriptId( |
| 219 value.value.scriptId, value.value.lineNumber, value.value.columnNumber
); | 219 value.value.scriptId, value.value.lineNumber, value.value.columnNumber
); |
| 220 if (rawLocation && linkifier) | 220 if (rawLocation && linkifier) |
| 221 return linkifier.linkifyRawLocation(rawLocation, ''); | 221 return linkifier.linkifyRawLocation(rawLocation, ''); |
| 222 valueElement.textContent = '<unknown>'; | 222 valueElement.textContent = '<unknown>'; |
| 223 } | 223 } |
| 224 | 224 |
| 225 function mouseMove() { | 225 function mouseMove() { |
| 226 WebInspector.DOMModel.highlightObjectAsDOMNode(value); | 226 SDK.DOMModel.highlightObjectAsDOMNode(value); |
| 227 } | 227 } |
| 228 | 228 |
| 229 function mouseLeave() { | 229 function mouseLeave() { |
| 230 WebInspector.DOMModel.hideDOMNodeHighlight(); | 230 SDK.DOMModel.hideDOMNodeHighlight(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 /** | 233 /** |
| 234 * @param {!Event} event | 234 * @param {!Event} event |
| 235 */ | 235 */ |
| 236 function mouseClick(event) { | 236 function mouseClick(event) { |
| 237 WebInspector.Revealer.reveal(value); | 237 Common.Revealer.reveal(value); |
| 238 event.consume(true); | 238 event.consume(true); |
| 239 } | 239 } |
| 240 | 240 |
| 241 return valueElement; | 241 return valueElement; |
| 242 } | 242 } |
| 243 | 243 |
| 244 /** | 244 /** |
| 245 * @param {!WebInspector.RemoteObject} object | 245 * @param {!SDK.RemoteObject} object |
| 246 * @return {boolean} | 246 * @return {boolean} |
| 247 */ | 247 */ |
| 248 static _needsAlternateTitle(object) { | 248 static _needsAlternateTitle(object) { |
| 249 return object && object.hasChildren && !object.customPreview() && object.sub
type !== 'node' && | 249 return object && object.hasChildren && !object.customPreview() && object.sub
type !== 'node' && |
| 250 object.type !== 'function' && (object.type !== 'object' || object.previe
w); | 250 object.type !== 'function' && (object.type !== 'object' || object.previe
w); |
| 251 } | 251 } |
| 252 | 252 |
| 253 /** | 253 /** |
| 254 * @param {!WebInspector.RemoteObject} func | 254 * @param {!SDK.RemoteObject} func |
| 255 * @param {!Element} element | 255 * @param {!Element} element |
| 256 * @param {boolean} linkify | 256 * @param {boolean} linkify |
| 257 * @param {boolean=} includePreview | 257 * @param {boolean=} includePreview |
| 258 */ | 258 */ |
| 259 static formatObjectAsFunction(func, element, linkify, includePreview) { | 259 static formatObjectAsFunction(func, element, linkify, includePreview) { |
| 260 func.debuggerModel().functionDetailsPromise(func).then(didGetDetails); | 260 func.debuggerModel().functionDetailsPromise(func).then(didGetDetails); |
| 261 | 261 |
| 262 /** | 262 /** |
| 263 * @param {?WebInspector.DebuggerModel.FunctionDetails} response | 263 * @param {?SDK.DebuggerModel.FunctionDetails} response |
| 264 */ | 264 */ |
| 265 function didGetDetails(response) { | 265 function didGetDetails(response) { |
| 266 if (!response) { | 266 if (!response) { |
| 267 var valueText = WebInspector.ObjectPropertiesSection.valueTextForFunctio
nDescription(func.description); | 267 var valueText = Components.ObjectPropertiesSection.valueTextForFunctionD
escription(func.description); |
| 268 element.createTextChild(valueText); | 268 element.createTextChild(valueText); |
| 269 return; | 269 return; |
| 270 } | 270 } |
| 271 | 271 |
| 272 var matched = func.description.match(WebInspector.ObjectPropertiesSection.
_functionPrefixSource); | 272 var matched = func.description.match(Components.ObjectPropertiesSection._f
unctionPrefixSource); |
| 273 if (matched) { | 273 if (matched) { |
| 274 var prefix = createElementWithClass('span', 'object-value-function-prefi
x'); | 274 var prefix = createElementWithClass('span', 'object-value-function-prefi
x'); |
| 275 prefix.textContent = matched[0]; | 275 prefix.textContent = matched[0]; |
| 276 element.appendChild(prefix); | 276 element.appendChild(prefix); |
| 277 } | 277 } |
| 278 | 278 |
| 279 if (linkify && response && response.location) { | 279 if (linkify && response && response.location) { |
| 280 var anchor = createElement('span'); | 280 var anchor = createElement('span'); |
| 281 element.classList.add('linkified'); | 281 element.classList.add('linkified'); |
| 282 element.appendChild(anchor); | 282 element.appendChild(anchor); |
| 283 element.addEventListener( | 283 element.addEventListener( |
| 284 'click', WebInspector.Revealer.reveal.bind(WebInspector.Revealer, re
sponse.location, undefined)); | 284 'click', Common.Revealer.reveal.bind(Common.Revealer, response.locat
ion, undefined)); |
| 285 element = anchor; | 285 element = anchor; |
| 286 } | 286 } |
| 287 | 287 |
| 288 var text = func.description.substring(0, 200); | 288 var text = func.description.substring(0, 200); |
| 289 if (includePreview) { | 289 if (includePreview) { |
| 290 element.createTextChild( | 290 element.createTextChild( |
| 291 text.replace(WebInspector.ObjectPropertiesSection._functionPrefixSou
rce, '') + | 291 text.replace(Components.ObjectPropertiesSection._functionPrefixSourc
e, '') + |
| 292 (func.description.length > 200 ? '\u2026' : '')); | 292 (func.description.length > 200 ? '\u2026' : '')); |
| 293 return; | 293 return; |
| 294 } | 294 } |
| 295 | 295 |
| 296 // Now parse description and get the real params and title. | 296 // Now parse description and get the real params and title. |
| 297 self.runtime.extension(WebInspector.TokenizerFactory).instance().then(proc
essTokens); | 297 self.runtime.extension(Common.TokenizerFactory).instance().then(processTok
ens); |
| 298 | 298 |
| 299 var params = null; | 299 var params = null; |
| 300 var functionName = response ? response.functionName : ''; | 300 var functionName = response ? response.functionName : ''; |
| 301 | 301 |
| 302 /** | 302 /** |
| 303 * @param {!WebInspector.TokenizerFactory} tokenizerFactory | 303 * @param {!Common.TokenizerFactory} tokenizerFactory |
| 304 */ | 304 */ |
| 305 function processTokens(tokenizerFactory) { | 305 function processTokens(tokenizerFactory) { |
| 306 var tokenize = tokenizerFactory.createTokenizer('text/javascript'); | 306 var tokenize = tokenizerFactory.createTokenizer('text/javascript'); |
| 307 tokenize(text, processToken); | 307 tokenize(text, processToken); |
| 308 element.createTextChild((functionName || 'anonymous') + '(' + (params ||
[]).join(', ') + ')'); | 308 element.createTextChild((functionName || 'anonymous') + '(' + (params ||
[]).join(', ') + ')'); |
| 309 } | 309 } |
| 310 | 310 |
| 311 var doneProcessing = false; | 311 var doneProcessing = false; |
| 312 | 312 |
| 313 /** | 313 /** |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 */ | 352 */ |
| 353 objectTreeElement() { | 353 objectTreeElement() { |
| 354 return this._objectTreeElement; | 354 return this._objectTreeElement; |
| 355 } | 355 } |
| 356 | 356 |
| 357 enableContextMenu() { | 357 enableContextMenu() { |
| 358 this.element.addEventListener('contextmenu', this._contextMenuEventFired.bin
d(this), false); | 358 this.element.addEventListener('contextmenu', this._contextMenuEventFired.bin
d(this), false); |
| 359 } | 359 } |
| 360 | 360 |
| 361 _contextMenuEventFired(event) { | 361 _contextMenuEventFired(event) { |
| 362 var contextMenu = new WebInspector.ContextMenu(event); | 362 var contextMenu = new UI.ContextMenu(event); |
| 363 contextMenu.appendApplicableItems(this._object); | 363 contextMenu.appendApplicableItems(this._object); |
| 364 contextMenu.show(); | 364 contextMenu.show(); |
| 365 } | 365 } |
| 366 | 366 |
| 367 titleLessMode() { | 367 titleLessMode() { |
| 368 this._objectTreeElement.listItemElement.classList.add('hidden'); | 368 this._objectTreeElement.listItemElement.classList.add('hidden'); |
| 369 this._objectTreeElement.childrenListElement.classList.add('title-less-mode')
; | 369 this._objectTreeElement.childrenListElement.classList.add('title-less-mode')
; |
| 370 this._objectTreeElement.expand(); | 370 this._objectTreeElement.expand(); |
| 371 } | 371 } |
| 372 }; | 372 }; |
| 373 | 373 |
| 374 /** @const */ | 374 /** @const */ |
| 375 WebInspector.ObjectPropertiesSection._arrayLoadThreshold = 100; | 375 Components.ObjectPropertiesSection._arrayLoadThreshold = 100; |
| 376 | 376 |
| 377 | 377 |
| 378 /** | 378 /** |
| 379 * @unrestricted | 379 * @unrestricted |
| 380 */ | 380 */ |
| 381 WebInspector.ObjectPropertiesSection.RootElement = class extends TreeElement { | 381 Components.ObjectPropertiesSection.RootElement = class extends TreeElement { |
| 382 /** | 382 /** |
| 383 * @param {!WebInspector.RemoteObject} object | 383 * @param {!SDK.RemoteObject} object |
| 384 * @param {!WebInspector.Linkifier=} linkifier | 384 * @param {!Components.Linkifier=} linkifier |
| 385 * @param {?string=} emptyPlaceholder | 385 * @param {?string=} emptyPlaceholder |
| 386 * @param {boolean=} ignoreHasOwnProperty | 386 * @param {boolean=} ignoreHasOwnProperty |
| 387 * @param {!Array.<!WebInspector.RemoteObjectProperty>=} extraProperties | 387 * @param {!Array.<!SDK.RemoteObjectProperty>=} extraProperties |
| 388 */ | 388 */ |
| 389 constructor(object, linkifier, emptyPlaceholder, ignoreHasOwnProperty, extraPr
operties) { | 389 constructor(object, linkifier, emptyPlaceholder, ignoreHasOwnProperty, extraPr
operties) { |
| 390 var contentElement = createElement('content'); | 390 var contentElement = createElement('content'); |
| 391 super(contentElement); | 391 super(contentElement); |
| 392 | 392 |
| 393 this._object = object; | 393 this._object = object; |
| 394 this._extraProperties = extraProperties || []; | 394 this._extraProperties = extraProperties || []; |
| 395 this._ignoreHasOwnProperty = !!ignoreHasOwnProperty; | 395 this._ignoreHasOwnProperty = !!ignoreHasOwnProperty; |
| 396 this._emptyPlaceholder = emptyPlaceholder; | 396 this._emptyPlaceholder = emptyPlaceholder; |
| 397 | 397 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 * @return {boolean} | 440 * @return {boolean} |
| 441 */ | 441 */ |
| 442 ondblclick(e) { | 442 ondblclick(e) { |
| 443 return true; | 443 return true; |
| 444 } | 444 } |
| 445 | 445 |
| 446 /** | 446 /** |
| 447 * @override | 447 * @override |
| 448 */ | 448 */ |
| 449 onpopulate() { | 449 onpopulate() { |
| 450 WebInspector.ObjectPropertyTreeElement._populate( | 450 Components.ObjectPropertyTreeElement._populate( |
| 451 this, this._object, !!this.treeOutline._skipProto, this._linkifier, this
._emptyPlaceholder, | 451 this, this._object, !!this.treeOutline._skipProto, this._linkifier, this
._emptyPlaceholder, |
| 452 this._ignoreHasOwnProperty, this._extraProperties); | 452 this._ignoreHasOwnProperty, this._extraProperties); |
| 453 } | 453 } |
| 454 }; | 454 }; |
| 455 | 455 |
| 456 /** | 456 /** |
| 457 * @unrestricted | 457 * @unrestricted |
| 458 */ | 458 */ |
| 459 WebInspector.ObjectPropertyTreeElement = class extends TreeElement { | 459 Components.ObjectPropertyTreeElement = class extends TreeElement { |
| 460 /** | 460 /** |
| 461 * @param {!WebInspector.RemoteObjectProperty} property | 461 * @param {!SDK.RemoteObjectProperty} property |
| 462 * @param {!WebInspector.Linkifier=} linkifier | 462 * @param {!Components.Linkifier=} linkifier |
| 463 */ | 463 */ |
| 464 constructor(property, linkifier) { | 464 constructor(property, linkifier) { |
| 465 // Pass an empty title, the title gets made later in onattach. | 465 // Pass an empty title, the title gets made later in onattach. |
| 466 super(); | 466 super(); |
| 467 | 467 |
| 468 this.property = property; | 468 this.property = property; |
| 469 this.toggleOnClick = true; | 469 this.toggleOnClick = true; |
| 470 this.selectable = false; | 470 this.selectable = false; |
| 471 /** @type {!Array.<!Object>} */ | 471 /** @type {!Array.<!Object>} */ |
| 472 this._highlightChanges = []; | 472 this._highlightChanges = []; |
| 473 this._linkifier = linkifier; | 473 this._linkifier = linkifier; |
| 474 } | 474 } |
| 475 | 475 |
| 476 /** | 476 /** |
| 477 * @param {!TreeElement} treeElement | 477 * @param {!TreeElement} treeElement |
| 478 * @param {!WebInspector.RemoteObject} value | 478 * @param {!SDK.RemoteObject} value |
| 479 * @param {boolean} skipProto | 479 * @param {boolean} skipProto |
| 480 * @param {!WebInspector.Linkifier=} linkifier | 480 * @param {!Components.Linkifier=} linkifier |
| 481 * @param {?string=} emptyPlaceholder | 481 * @param {?string=} emptyPlaceholder |
| 482 * @param {boolean=} flattenProtoChain | 482 * @param {boolean=} flattenProtoChain |
| 483 * @param {!Array.<!WebInspector.RemoteObjectProperty>=} extraProperties | 483 * @param {!Array.<!SDK.RemoteObjectProperty>=} extraProperties |
| 484 * @param {!WebInspector.RemoteObject=} targetValue | 484 * @param {!SDK.RemoteObject=} targetValue |
| 485 */ | 485 */ |
| 486 static _populate( | 486 static _populate( |
| 487 treeElement, | 487 treeElement, |
| 488 value, | 488 value, |
| 489 skipProto, | 489 skipProto, |
| 490 linkifier, | 490 linkifier, |
| 491 emptyPlaceholder, | 491 emptyPlaceholder, |
| 492 flattenProtoChain, | 492 flattenProtoChain, |
| 493 extraProperties, | 493 extraProperties, |
| 494 targetValue) { | 494 targetValue) { |
| 495 if (value.arrayLength() > WebInspector.ObjectPropertiesSection._arrayLoadThr
eshold) { | 495 if (value.arrayLength() > Components.ObjectPropertiesSection._arrayLoadThres
hold) { |
| 496 treeElement.removeChildren(); | 496 treeElement.removeChildren(); |
| 497 WebInspector.ArrayGroupingTreeElement._populateArray(treeElement, value, 0
, value.arrayLength() - 1, linkifier); | 497 Components.ArrayGroupingTreeElement._populateArray(treeElement, value, 0,
value.arrayLength() - 1, linkifier); |
| 498 return; | 498 return; |
| 499 } | 499 } |
| 500 | 500 |
| 501 /** | 501 /** |
| 502 * @param {?Array.<!WebInspector.RemoteObjectProperty>} properties | 502 * @param {?Array.<!SDK.RemoteObjectProperty>} properties |
| 503 * @param {?Array.<!WebInspector.RemoteObjectProperty>} internalProperties | 503 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties |
| 504 */ | 504 */ |
| 505 function callback(properties, internalProperties) { | 505 function callback(properties, internalProperties) { |
| 506 treeElement.removeChildren(); | 506 treeElement.removeChildren(); |
| 507 if (!properties) | 507 if (!properties) |
| 508 return; | 508 return; |
| 509 | 509 |
| 510 extraProperties = extraProperties || []; | 510 extraProperties = extraProperties || []; |
| 511 for (var i = 0; i < extraProperties.length; ++i) | 511 for (var i = 0; i < extraProperties.length; ++i) |
| 512 properties.push(extraProperties[i]); | 512 properties.push(extraProperties[i]); |
| 513 | 513 |
| 514 WebInspector.ObjectPropertyTreeElement.populateWithProperties( | 514 Components.ObjectPropertyTreeElement.populateWithProperties( |
| 515 treeElement, properties, internalProperties, skipProto, targetValue ||
value, linkifier, emptyPlaceholder); | 515 treeElement, properties, internalProperties, skipProto, targetValue ||
value, linkifier, emptyPlaceholder); |
| 516 } | 516 } |
| 517 | 517 |
| 518 if (flattenProtoChain) | 518 if (flattenProtoChain) |
| 519 value.getAllProperties(false, callback); | 519 value.getAllProperties(false, callback); |
| 520 else | 520 else |
| 521 WebInspector.RemoteObject.loadFromObjectPerProto(value, callback); | 521 SDK.RemoteObject.loadFromObjectPerProto(value, callback); |
| 522 } | 522 } |
| 523 | 523 |
| 524 /** | 524 /** |
| 525 * @param {!TreeElement} treeNode | 525 * @param {!TreeElement} treeNode |
| 526 * @param {!Array.<!WebInspector.RemoteObjectProperty>} properties | 526 * @param {!Array.<!SDK.RemoteObjectProperty>} properties |
| 527 * @param {?Array.<!WebInspector.RemoteObjectProperty>} internalProperties | 527 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties |
| 528 * @param {boolean} skipProto | 528 * @param {boolean} skipProto |
| 529 * @param {?WebInspector.RemoteObject} value | 529 * @param {?SDK.RemoteObject} value |
| 530 * @param {!WebInspector.Linkifier=} linkifier | 530 * @param {!Components.Linkifier=} linkifier |
| 531 * @param {?string=} emptyPlaceholder | 531 * @param {?string=} emptyPlaceholder |
| 532 */ | 532 */ |
| 533 static populateWithProperties( | 533 static populateWithProperties( |
| 534 treeNode, | 534 treeNode, |
| 535 properties, | 535 properties, |
| 536 internalProperties, | 536 internalProperties, |
| 537 skipProto, | 537 skipProto, |
| 538 value, | 538 value, |
| 539 linkifier, | 539 linkifier, |
| 540 emptyPlaceholder) { | 540 emptyPlaceholder) { |
| 541 properties.sort(WebInspector.ObjectPropertiesSection.CompareProperties); | 541 properties.sort(Components.ObjectPropertiesSection.CompareProperties); |
| 542 | 542 |
| 543 var tailProperties = []; | 543 var tailProperties = []; |
| 544 var protoProperty = null; | 544 var protoProperty = null; |
| 545 for (var i = 0; i < properties.length; ++i) { | 545 for (var i = 0; i < properties.length; ++i) { |
| 546 var property = properties[i]; | 546 var property = properties[i]; |
| 547 property.parentObject = value; | 547 property.parentObject = value; |
| 548 if (property.name === '__proto__' && !property.isAccessorProperty()) { | 548 if (property.name === '__proto__' && !property.isAccessorProperty()) { |
| 549 protoProperty = property; | 549 protoProperty = property; |
| 550 continue; | 550 continue; |
| 551 } | 551 } |
| 552 | 552 |
| 553 if (property.isOwn && property.getter) { | 553 if (property.isOwn && property.getter) { |
| 554 var getterProperty = new WebInspector.RemoteObjectProperty('get ' + prop
erty.name, property.getter, false); | 554 var getterProperty = new SDK.RemoteObjectProperty('get ' + property.name
, property.getter, false); |
| 555 getterProperty.parentObject = value; | 555 getterProperty.parentObject = value; |
| 556 tailProperties.push(getterProperty); | 556 tailProperties.push(getterProperty); |
| 557 } | 557 } |
| 558 if (property.isOwn && property.setter) { | 558 if (property.isOwn && property.setter) { |
| 559 var setterProperty = new WebInspector.RemoteObjectProperty('set ' + prop
erty.name, property.setter, false); | 559 var setterProperty = new SDK.RemoteObjectProperty('set ' + property.name
, property.setter, false); |
| 560 setterProperty.parentObject = value; | 560 setterProperty.parentObject = value; |
| 561 tailProperties.push(setterProperty); | 561 tailProperties.push(setterProperty); |
| 562 } | 562 } |
| 563 var canShowProperty = property.getter || !property.isAccessorProperty(); | 563 var canShowProperty = property.getter || !property.isAccessorProperty(); |
| 564 if (canShowProperty && property.name !== '__proto__') | 564 if (canShowProperty && property.name !== '__proto__') |
| 565 treeNode.appendChild(new WebInspector.ObjectPropertyTreeElement(property
, linkifier)); | 565 treeNode.appendChild(new Components.ObjectPropertyTreeElement(property,
linkifier)); |
| 566 } | 566 } |
| 567 for (var i = 0; i < tailProperties.length; ++i) | 567 for (var i = 0; i < tailProperties.length; ++i) |
| 568 treeNode.appendChild(new WebInspector.ObjectPropertyTreeElement(tailProper
ties[i], linkifier)); | 568 treeNode.appendChild(new Components.ObjectPropertyTreeElement(tailProperti
es[i], linkifier)); |
| 569 if (!skipProto && protoProperty) | 569 if (!skipProto && protoProperty) |
| 570 treeNode.appendChild(new WebInspector.ObjectPropertyTreeElement(protoPrope
rty, linkifier)); | 570 treeNode.appendChild(new Components.ObjectPropertyTreeElement(protoPropert
y, linkifier)); |
| 571 | 571 |
| 572 if (internalProperties) { | 572 if (internalProperties) { |
| 573 for (var i = 0; i < internalProperties.length; i++) { | 573 for (var i = 0; i < internalProperties.length; i++) { |
| 574 internalProperties[i].parentObject = value; | 574 internalProperties[i].parentObject = value; |
| 575 var treeElement = new WebInspector.ObjectPropertyTreeElement(internalPro
perties[i], linkifier); | 575 var treeElement = new Components.ObjectPropertyTreeElement(internalPrope
rties[i], linkifier); |
| 576 if (internalProperties[i].name === '[[Entries]]') { | 576 if (internalProperties[i].name === '[[Entries]]') { |
| 577 treeElement.setExpandable(true); | 577 treeElement.setExpandable(true); |
| 578 treeElement.expand(); | 578 treeElement.expand(); |
| 579 } | 579 } |
| 580 treeNode.appendChild(treeElement); | 580 treeNode.appendChild(treeElement); |
| 581 } | 581 } |
| 582 } | 582 } |
| 583 | 583 |
| 584 WebInspector.ObjectPropertyTreeElement._appendEmptyPlaceholderIfNeeded(treeN
ode, emptyPlaceholder); | 584 Components.ObjectPropertyTreeElement._appendEmptyPlaceholderIfNeeded(treeNod
e, emptyPlaceholder); |
| 585 } | 585 } |
| 586 | 586 |
| 587 /** | 587 /** |
| 588 * @param {!TreeElement} treeNode | 588 * @param {!TreeElement} treeNode |
| 589 * @param {?string=} emptyPlaceholder | 589 * @param {?string=} emptyPlaceholder |
| 590 */ | 590 */ |
| 591 static _appendEmptyPlaceholderIfNeeded(treeNode, emptyPlaceholder) { | 591 static _appendEmptyPlaceholderIfNeeded(treeNode, emptyPlaceholder) { |
| 592 if (treeNode.childCount()) | 592 if (treeNode.childCount()) |
| 593 return; | 593 return; |
| 594 var title = createElementWithClass('div', 'gray-info-message'); | 594 var title = createElementWithClass('div', 'gray-info-message'); |
| 595 title.textContent = emptyPlaceholder || WebInspector.UIString('No Properties
'); | 595 title.textContent = emptyPlaceholder || Common.UIString('No Properties'); |
| 596 var infoElement = new TreeElement(title); | 596 var infoElement = new TreeElement(title); |
| 597 treeNode.appendChild(infoElement); | 597 treeNode.appendChild(infoElement); |
| 598 } | 598 } |
| 599 | 599 |
| 600 /** | 600 /** |
| 601 * @param {?WebInspector.RemoteObject} object | 601 * @param {?SDK.RemoteObject} object |
| 602 * @param {!Array.<string>} propertyPath | 602 * @param {!Array.<string>} propertyPath |
| 603 * @param {function(?WebInspector.RemoteObject, boolean=)} callback | 603 * @param {function(?SDK.RemoteObject, boolean=)} callback |
| 604 * @return {!Element} | 604 * @return {!Element} |
| 605 */ | 605 */ |
| 606 static createRemoteObjectAccessorPropertySpan(object, propertyPath, callback)
{ | 606 static createRemoteObjectAccessorPropertySpan(object, propertyPath, callback)
{ |
| 607 var rootElement = createElement('span'); | 607 var rootElement = createElement('span'); |
| 608 var element = rootElement.createChild('span'); | 608 var element = rootElement.createChild('span'); |
| 609 element.textContent = WebInspector.UIString('(...)'); | 609 element.textContent = Common.UIString('(...)'); |
| 610 if (!object) | 610 if (!object) |
| 611 return rootElement; | 611 return rootElement; |
| 612 element.classList.add('object-value-calculate-value-button'); | 612 element.classList.add('object-value-calculate-value-button'); |
| 613 element.title = WebInspector.UIString('Invoke property getter'); | 613 element.title = Common.UIString('Invoke property getter'); |
| 614 element.addEventListener('click', onInvokeGetterClick, false); | 614 element.addEventListener('click', onInvokeGetterClick, false); |
| 615 | 615 |
| 616 function onInvokeGetterClick(event) { | 616 function onInvokeGetterClick(event) { |
| 617 event.consume(); | 617 event.consume(); |
| 618 object.getProperty(propertyPath, callback); | 618 object.getProperty(propertyPath, callback); |
| 619 } | 619 } |
| 620 | 620 |
| 621 return rootElement; | 621 return rootElement; |
| 622 } | 622 } |
| 623 | 623 |
| 624 /** | 624 /** |
| 625 * @param {!RegExp} regex | 625 * @param {!RegExp} regex |
| 626 * @param {string=} additionalCssClassName | 626 * @param {string=} additionalCssClassName |
| 627 * @return {boolean} | 627 * @return {boolean} |
| 628 */ | 628 */ |
| 629 setSearchRegex(regex, additionalCssClassName) { | 629 setSearchRegex(regex, additionalCssClassName) { |
| 630 var cssClasses = WebInspector.highlightedSearchResultClassName; | 630 var cssClasses = UI.highlightedSearchResultClassName; |
| 631 if (additionalCssClassName) | 631 if (additionalCssClassName) |
| 632 cssClasses += ' ' + additionalCssClassName; | 632 cssClasses += ' ' + additionalCssClassName; |
| 633 this.revertHighlightChanges(); | 633 this.revertHighlightChanges(); |
| 634 | 634 |
| 635 this._applySearch(regex, this.nameElement, cssClasses); | 635 this._applySearch(regex, this.nameElement, cssClasses); |
| 636 var valueType = this.property.value.type; | 636 var valueType = this.property.value.type; |
| 637 if (valueType !== 'object') | 637 if (valueType !== 'object') |
| 638 this._applySearch(regex, this.valueElement, cssClasses); | 638 this._applySearch(regex, this.valueElement, cssClasses); |
| 639 | 639 |
| 640 return !!this._highlightChanges.length; | 640 return !!this._highlightChanges.length; |
| 641 } | 641 } |
| 642 | 642 |
| 643 /** | 643 /** |
| 644 * @param {!RegExp} regex | 644 * @param {!RegExp} regex |
| 645 * @param {!Element} element | 645 * @param {!Element} element |
| 646 * @param {string} cssClassName | 646 * @param {string} cssClassName |
| 647 */ | 647 */ |
| 648 _applySearch(regex, element, cssClassName) { | 648 _applySearch(regex, element, cssClassName) { |
| 649 var ranges = []; | 649 var ranges = []; |
| 650 var content = element.textContent; | 650 var content = element.textContent; |
| 651 regex.lastIndex = 0; | 651 regex.lastIndex = 0; |
| 652 var match = regex.exec(content); | 652 var match = regex.exec(content); |
| 653 while (match) { | 653 while (match) { |
| 654 ranges.push(new WebInspector.SourceRange(match.index, match[0].length)); | 654 ranges.push(new Common.SourceRange(match.index, match[0].length)); |
| 655 match = regex.exec(content); | 655 match = regex.exec(content); |
| 656 } | 656 } |
| 657 if (ranges.length) | 657 if (ranges.length) |
| 658 WebInspector.highlightRangesWithStyleClass(element, ranges, cssClassName,
this._highlightChanges); | 658 UI.highlightRangesWithStyleClass(element, ranges, cssClassName, this._high
lightChanges); |
| 659 } | 659 } |
| 660 | 660 |
| 661 revertHighlightChanges() { | 661 revertHighlightChanges() { |
| 662 WebInspector.revertDomChanges(this._highlightChanges); | 662 UI.revertDomChanges(this._highlightChanges); |
| 663 this._highlightChanges = []; | 663 this._highlightChanges = []; |
| 664 } | 664 } |
| 665 | 665 |
| 666 /** | 666 /** |
| 667 * @override | 667 * @override |
| 668 */ | 668 */ |
| 669 onpopulate() { | 669 onpopulate() { |
| 670 var propertyValue = /** @type {!WebInspector.RemoteObject} */ (this.property
.value); | 670 var propertyValue = /** @type {!SDK.RemoteObject} */ (this.property.value); |
| 671 console.assert(propertyValue); | 671 console.assert(propertyValue); |
| 672 var skipProto = this.treeOutline ? this.treeOutline._skipProto : true; | 672 var skipProto = this.treeOutline ? this.treeOutline._skipProto : true; |
| 673 var targetValue = this.property.name !== '__proto__' ? propertyValue : this.
property.parentObject; | 673 var targetValue = this.property.name !== '__proto__' ? propertyValue : this.
property.parentObject; |
| 674 WebInspector.ObjectPropertyTreeElement._populate( | 674 Components.ObjectPropertyTreeElement._populate( |
| 675 this, propertyValue, skipProto, this._linkifier, undefined, undefined, u
ndefined, targetValue); | 675 this, propertyValue, skipProto, this._linkifier, undefined, undefined, u
ndefined, targetValue); |
| 676 } | 676 } |
| 677 | 677 |
| 678 /** | 678 /** |
| 679 * @override | 679 * @override |
| 680 * @return {boolean} | 680 * @return {boolean} |
| 681 */ | 681 */ |
| 682 ondblclick(event) { | 682 ondblclick(event) { |
| 683 var inEditableElement = event.target.isSelfOrDescendant(this.valueElement) |
| | 683 var inEditableElement = event.target.isSelfOrDescendant(this.valueElement) |
| |
| 684 (this.expandedValueElement && event.target.isSelfOrDescendant(this.expan
dedValueElement)); | 684 (this.expandedValueElement && event.target.isSelfOrDescendant(this.expan
dedValueElement)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 715 _showExpandedValueElement(value) { | 715 _showExpandedValueElement(value) { |
| 716 if (!this.expandedValueElement) | 716 if (!this.expandedValueElement) |
| 717 return; | 717 return; |
| 718 if (value) | 718 if (value) |
| 719 this.listItemElement.replaceChild(this.expandedValueElement, this.valueEle
ment); | 719 this.listItemElement.replaceChild(this.expandedValueElement, this.valueEle
ment); |
| 720 else | 720 else |
| 721 this.listItemElement.replaceChild(this.valueElement, this.expandedValueEle
ment); | 721 this.listItemElement.replaceChild(this.valueElement, this.expandedValueEle
ment); |
| 722 } | 722 } |
| 723 | 723 |
| 724 /** | 724 /** |
| 725 * @param {!WebInspector.RemoteObject} value | 725 * @param {!SDK.RemoteObject} value |
| 726 * @return {?Element} | 726 * @return {?Element} |
| 727 */ | 727 */ |
| 728 _createExpandedValueElement(value) { | 728 _createExpandedValueElement(value) { |
| 729 if (!WebInspector.ObjectPropertiesSection._needsAlternateTitle(value)) | 729 if (!Components.ObjectPropertiesSection._needsAlternateTitle(value)) |
| 730 return null; | 730 return null; |
| 731 | 731 |
| 732 var valueElement = createElementWithClass('span', 'value'); | 732 var valueElement = createElementWithClass('span', 'value'); |
| 733 valueElement.setTextContentTruncatedIfNeeded(value.description || ''); | 733 valueElement.setTextContentTruncatedIfNeeded(value.description || ''); |
| 734 valueElement.classList.add('object-value-' + (value.subtype || value.type)); | 734 valueElement.classList.add('object-value-' + (value.subtype || value.type)); |
| 735 valueElement.title = value.description || ''; | 735 valueElement.title = value.description || ''; |
| 736 return valueElement; | 736 return valueElement; |
| 737 } | 737 } |
| 738 | 738 |
| 739 update() { | 739 update() { |
| 740 this.nameElement = WebInspector.ObjectPropertiesSection.createNameElement(th
is.property.name); | 740 this.nameElement = Components.ObjectPropertiesSection.createNameElement(this
.property.name); |
| 741 if (!this.property.enumerable) | 741 if (!this.property.enumerable) |
| 742 this.nameElement.classList.add('object-properties-section-dimmed'); | 742 this.nameElement.classList.add('object-properties-section-dimmed'); |
| 743 if (this.property.synthetic) | 743 if (this.property.synthetic) |
| 744 this.nameElement.classList.add('synthetic-property'); | 744 this.nameElement.classList.add('synthetic-property'); |
| 745 | 745 |
| 746 this._updatePropertyPath(); | 746 this._updatePropertyPath(); |
| 747 this.nameElement.addEventListener('contextmenu', this._contextMenuFired.bind
(this, this.property), false); | 747 this.nameElement.addEventListener('contextmenu', this._contextMenuFired.bind
(this, this.property), false); |
| 748 | 748 |
| 749 var separatorElement = createElementWithClass('span', 'object-properties-sec
tion-separator'); | 749 var separatorElement = createElementWithClass('span', 'object-properties-sec
tion-separator'); |
| 750 separatorElement.textContent = ': '; | 750 separatorElement.textContent = ': '; |
| 751 | 751 |
| 752 if (this.property.value) { | 752 if (this.property.value) { |
| 753 this.valueElement = WebInspector.ObjectPropertiesSection.createValueElemen
tWithCustomSupport( | 753 this.valueElement = Components.ObjectPropertiesSection.createValueElementW
ithCustomSupport( |
| 754 this.property.value, this.property.wasThrown, this.listItemElement, th
is._linkifier); | 754 this.property.value, this.property.wasThrown, this.listItemElement, th
is._linkifier); |
| 755 this.valueElement.addEventListener('contextmenu', this._contextMenuFired.b
ind(this, this.property), false); | 755 this.valueElement.addEventListener('contextmenu', this._contextMenuFired.b
ind(this, this.property), false); |
| 756 } else if (this.property.getter) { | 756 } else if (this.property.getter) { |
| 757 this.valueElement = WebInspector.ObjectPropertyTreeElement.createRemoteObj
ectAccessorPropertySpan( | 757 this.valueElement = Components.ObjectPropertyTreeElement.createRemoteObjec
tAccessorPropertySpan( |
| 758 this.property.parentObject, [this.property.name], this._onInvokeGetter
Click.bind(this)); | 758 this.property.parentObject, [this.property.name], this._onInvokeGetter
Click.bind(this)); |
| 759 } else { | 759 } else { |
| 760 this.valueElement = createElementWithClass('span', 'object-value-undefined
'); | 760 this.valueElement = createElementWithClass('span', 'object-value-undefined
'); |
| 761 this.valueElement.textContent = WebInspector.UIString('<unreadable>'); | 761 this.valueElement.textContent = Common.UIString('<unreadable>'); |
| 762 this.valueElement.title = WebInspector.UIString('No property getter'); | 762 this.valueElement.title = Common.UIString('No property getter'); |
| 763 } | 763 } |
| 764 | 764 |
| 765 var valueText = this.valueElement.textContent; | 765 var valueText = this.valueElement.textContent; |
| 766 if (this.property.value && valueText && !this.property.wasThrown) | 766 if (this.property.value && valueText && !this.property.wasThrown) |
| 767 this.expandedValueElement = this._createExpandedValueElement(this.property
.value); | 767 this.expandedValueElement = this._createExpandedValueElement(this.property
.value); |
| 768 | 768 |
| 769 this.listItemElement.removeChildren(); | 769 this.listItemElement.removeChildren(); |
| 770 this.listItemElement.appendChildren(this.nameElement, separatorElement, this
.valueElement); | 770 this.listItemElement.appendChildren(this.nameElement, separatorElement, this
.valueElement); |
| 771 } | 771 } |
| 772 | 772 |
| 773 _updatePropertyPath() { | 773 _updatePropertyPath() { |
| 774 if (this.nameElement.title) | 774 if (this.nameElement.title) |
| 775 return; | 775 return; |
| 776 | 776 |
| 777 var useDotNotation = /^(_|\$|[A-Z])(_|\$|[A-Z]|\d)*$/i; | 777 var useDotNotation = /^(_|\$|[A-Z])(_|\$|[A-Z]|\d)*$/i; |
| 778 var isInteger = /^[1-9]\d*$/; | 778 var isInteger = /^[1-9]\d*$/; |
| 779 var name = this.property.name; | 779 var name = this.property.name; |
| 780 var parentPath = this.parent.nameElement ? this.parent.nameElement.title : '
'; | 780 var parentPath = this.parent.nameElement ? this.parent.nameElement.title : '
'; |
| 781 if (useDotNotation.test(name)) | 781 if (useDotNotation.test(name)) |
| 782 this.nameElement.title = parentPath + '.' + name; | 782 this.nameElement.title = parentPath + '.' + name; |
| 783 else if (isInteger.test(name)) | 783 else if (isInteger.test(name)) |
| 784 this.nameElement.title = parentPath + '[' + name + ']'; | 784 this.nameElement.title = parentPath + '[' + name + ']'; |
| 785 else | 785 else |
| 786 this.nameElement.title = parentPath + '["' + name + '"]'; | 786 this.nameElement.title = parentPath + '["' + name + '"]'; |
| 787 } | 787 } |
| 788 | 788 |
| 789 /** | 789 /** |
| 790 * @param {!WebInspector.RemoteObjectProperty} property | 790 * @param {!SDK.RemoteObjectProperty} property |
| 791 * @param {!Event} event | 791 * @param {!Event} event |
| 792 */ | 792 */ |
| 793 _contextMenuFired(property, event) { | 793 _contextMenuFired(property, event) { |
| 794 var contextMenu = new WebInspector.ContextMenu(event); | 794 var contextMenu = new UI.ContextMenu(event); |
| 795 if (property.symbol) | 795 if (property.symbol) |
| 796 contextMenu.appendApplicableItems(property.symbol); | 796 contextMenu.appendApplicableItems(property.symbol); |
| 797 if (property.value) | 797 if (property.value) |
| 798 contextMenu.appendApplicableItems(property.value); | 798 contextMenu.appendApplicableItems(property.value); |
| 799 var copyPathHandler = InspectorFrontendHost.copyText.bind(InspectorFrontendH
ost, this.nameElement.title); | 799 var copyPathHandler = InspectorFrontendHost.copyText.bind(InspectorFrontendH
ost, this.nameElement.title); |
| 800 contextMenu.beforeShow(() => { | 800 contextMenu.beforeShow(() => { |
| 801 contextMenu.appendItem(WebInspector.UIString.capitalize('Copy ^property ^p
ath'), copyPathHandler); | 801 contextMenu.appendItem(Common.UIString.capitalize('Copy ^property ^path'),
copyPathHandler); |
| 802 }); | 802 }); |
| 803 contextMenu.show(); | 803 contextMenu.show(); |
| 804 } | 804 } |
| 805 | 805 |
| 806 _startEditing() { | 806 _startEditing() { |
| 807 if (this._prompt || !this.treeOutline._editable || this._readOnly) | 807 if (this._prompt || !this.treeOutline._editable || this._readOnly) |
| 808 return; | 808 return; |
| 809 | 809 |
| 810 this._editableDiv = this.listItemElement.createChild('span'); | 810 this._editableDiv = this.listItemElement.createChild('span'); |
| 811 | 811 |
| 812 var text = this.property.value.description; | 812 var text = this.property.value.description; |
| 813 if (this.property.value.type === 'string' && typeof text === 'string') | 813 if (this.property.value.type === 'string' && typeof text === 'string') |
| 814 text = '"' + text + '"'; | 814 text = '"' + text + '"'; |
| 815 | 815 |
| 816 this._editableDiv.setTextContentTruncatedIfNeeded(text, WebInspector.UIStrin
g('<string is too large to edit>')); | 816 this._editableDiv.setTextContentTruncatedIfNeeded(text, Common.UIString('<st
ring is too large to edit>')); |
| 817 var originalContent = this._editableDiv.textContent; | 817 var originalContent = this._editableDiv.textContent; |
| 818 | 818 |
| 819 // Lie about our children to prevent expanding on double click and to collap
se subproperties. | 819 // Lie about our children to prevent expanding on double click and to collap
se subproperties. |
| 820 this.setExpandable(false); | 820 this.setExpandable(false); |
| 821 this.listItemElement.classList.add('editing-sub-part'); | 821 this.listItemElement.classList.add('editing-sub-part'); |
| 822 this.valueElement.classList.add('hidden'); | 822 this.valueElement.classList.add('hidden'); |
| 823 | 823 |
| 824 this._prompt = new WebInspector.ObjectPropertyPrompt(); | 824 this._prompt = new Components.ObjectPropertyPrompt(); |
| 825 | 825 |
| 826 var proxyElement = | 826 var proxyElement = |
| 827 this._prompt.attachAndStartEditing(this._editableDiv, this._editingCommi
tted.bind(this, originalContent)); | 827 this._prompt.attachAndStartEditing(this._editableDiv, this._editingCommi
tted.bind(this, originalContent)); |
| 828 this.listItemElement.getComponentSelection().setBaseAndExtent(this._editable
Div, 0, this._editableDiv, 1); | 828 this.listItemElement.getComponentSelection().setBaseAndExtent(this._editable
Div, 0, this._editableDiv, 1); |
| 829 proxyElement.addEventListener('keydown', this._promptKeyDown.bind(this, orig
inalContent), false); | 829 proxyElement.addEventListener('keydown', this._promptKeyDown.bind(this, orig
inalContent), false); |
| 830 } | 830 } |
| 831 | 831 |
| 832 _editingEnded() { | 832 _editingEnded() { |
| 833 this._prompt.detach(); | 833 this._prompt.detach(); |
| 834 delete this._prompt; | 834 delete this._prompt; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 event.consume(); | 871 event.consume(); |
| 872 this._editingCancelled(); | 872 this._editingCancelled(); |
| 873 return; | 873 return; |
| 874 } | 874 } |
| 875 } | 875 } |
| 876 | 876 |
| 877 /** | 877 /** |
| 878 * @param {string} expression | 878 * @param {string} expression |
| 879 */ | 879 */ |
| 880 _applyExpression(expression) { | 880 _applyExpression(expression) { |
| 881 var property = WebInspector.RemoteObject.toCallArgument(this.property.symbol
|| this.property.name); | 881 var property = SDK.RemoteObject.toCallArgument(this.property.symbol || this.
property.name); |
| 882 expression = expression.trim(); | 882 expression = expression.trim(); |
| 883 if (expression) | 883 if (expression) |
| 884 this.property.parentObject.setPropertyValue(property, expression, callback
.bind(this)); | 884 this.property.parentObject.setPropertyValue(property, expression, callback
.bind(this)); |
| 885 else | 885 else |
| 886 this.property.parentObject.deleteProperty(property, callback.bind(this)); | 886 this.property.parentObject.deleteProperty(property, callback.bind(this)); |
| 887 | 887 |
| 888 /** | 888 /** |
| 889 * @param {?Protocol.Error} error | 889 * @param {?Protocol.Error} error |
| 890 * @this {WebInspector.ObjectPropertyTreeElement} | 890 * @this {Components.ObjectPropertyTreeElement} |
| 891 */ | 891 */ |
| 892 function callback(error) { | 892 function callback(error) { |
| 893 if (error) { | 893 if (error) { |
| 894 this.update(); | 894 this.update(); |
| 895 return; | 895 return; |
| 896 } | 896 } |
| 897 | 897 |
| 898 if (!expression) { | 898 if (!expression) { |
| 899 // The property was deleted, so remove this tree element. | 899 // The property was deleted, so remove this tree element. |
| 900 this.parent.removeChild(this); | 900 this.parent.removeChild(this); |
| 901 } else { | 901 } else { |
| 902 // Call updateSiblings since their value might be based on the value tha
t just changed. | 902 // Call updateSiblings since their value might be based on the value tha
t just changed. |
| 903 var parent = this.parent; | 903 var parent = this.parent; |
| 904 parent.invalidateChildren(); | 904 parent.invalidateChildren(); |
| 905 parent.onpopulate(); | 905 parent.onpopulate(); |
| 906 } | 906 } |
| 907 } | 907 } |
| 908 } | 908 } |
| 909 | 909 |
| 910 /** | 910 /** |
| 911 * @param {?WebInspector.RemoteObject} result | 911 * @param {?SDK.RemoteObject} result |
| 912 * @param {boolean=} wasThrown | 912 * @param {boolean=} wasThrown |
| 913 */ | 913 */ |
| 914 _onInvokeGetterClick(result, wasThrown) { | 914 _onInvokeGetterClick(result, wasThrown) { |
| 915 if (!result) | 915 if (!result) |
| 916 return; | 916 return; |
| 917 this.property.value = result; | 917 this.property.value = result; |
| 918 this.property.wasThrown = wasThrown; | 918 this.property.wasThrown = wasThrown; |
| 919 | 919 |
| 920 this.update(); | 920 this.update(); |
| 921 this.invalidateChildren(); | 921 this.invalidateChildren(); |
| 922 this._updateExpandable(); | 922 this._updateExpandable(); |
| 923 } | 923 } |
| 924 | 924 |
| 925 _updateExpandable() { | 925 _updateExpandable() { |
| 926 if (this.property.value) | 926 if (this.property.value) |
| 927 this.setExpandable( | 927 this.setExpandable( |
| 928 !this.property.value.customPreview() && this.property.value.hasChildre
n && !this.property.wasThrown); | 928 !this.property.value.customPreview() && this.property.value.hasChildre
n && !this.property.wasThrown); |
| 929 else | 929 else |
| 930 this.setExpandable(false); | 930 this.setExpandable(false); |
| 931 } | 931 } |
| 932 }; | 932 }; |
| 933 | 933 |
| 934 | 934 |
| 935 /** | 935 /** |
| 936 * @unrestricted | 936 * @unrestricted |
| 937 */ | 937 */ |
| 938 WebInspector.ArrayGroupingTreeElement = class extends TreeElement { | 938 Components.ArrayGroupingTreeElement = class extends TreeElement { |
| 939 /** | 939 /** |
| 940 * @param {!WebInspector.RemoteObject} object | 940 * @param {!SDK.RemoteObject} object |
| 941 * @param {number} fromIndex | 941 * @param {number} fromIndex |
| 942 * @param {number} toIndex | 942 * @param {number} toIndex |
| 943 * @param {number} propertyCount | 943 * @param {number} propertyCount |
| 944 * @param {!WebInspector.Linkifier=} linkifier | 944 * @param {!Components.Linkifier=} linkifier |
| 945 */ | 945 */ |
| 946 constructor(object, fromIndex, toIndex, propertyCount, linkifier) { | 946 constructor(object, fromIndex, toIndex, propertyCount, linkifier) { |
| 947 super(String.sprintf('[%d \u2026 %d]', fromIndex, toIndex), true); | 947 super(String.sprintf('[%d \u2026 %d]', fromIndex, toIndex), true); |
| 948 this.toggleOnClick = true; | 948 this.toggleOnClick = true; |
| 949 this.selectable = false; | 949 this.selectable = false; |
| 950 this._fromIndex = fromIndex; | 950 this._fromIndex = fromIndex; |
| 951 this._toIndex = toIndex; | 951 this._toIndex = toIndex; |
| 952 this._object = object; | 952 this._object = object; |
| 953 this._readOnly = true; | 953 this._readOnly = true; |
| 954 this._propertyCount = propertyCount; | 954 this._propertyCount = propertyCount; |
| 955 this._linkifier = linkifier; | 955 this._linkifier = linkifier; |
| 956 } | 956 } |
| 957 | 957 |
| 958 /** | 958 /** |
| 959 * @param {!TreeElement} treeNode | 959 * @param {!TreeElement} treeNode |
| 960 * @param {!WebInspector.RemoteObject} object | 960 * @param {!SDK.RemoteObject} object |
| 961 * @param {number} fromIndex | 961 * @param {number} fromIndex |
| 962 * @param {number} toIndex | 962 * @param {number} toIndex |
| 963 * @param {!WebInspector.Linkifier=} linkifier | 963 * @param {!Components.Linkifier=} linkifier |
| 964 */ | 964 */ |
| 965 static _populateArray(treeNode, object, fromIndex, toIndex, linkifier) { | 965 static _populateArray(treeNode, object, fromIndex, toIndex, linkifier) { |
| 966 WebInspector.ArrayGroupingTreeElement._populateRanges(treeNode, object, from
Index, toIndex, true, linkifier); | 966 Components.ArrayGroupingTreeElement._populateRanges(treeNode, object, fromIn
dex, toIndex, true, linkifier); |
| 967 } | 967 } |
| 968 | 968 |
| 969 /** | 969 /** |
| 970 * @param {!TreeElement} treeNode | 970 * @param {!TreeElement} treeNode |
| 971 * @param {!WebInspector.RemoteObject} object | 971 * @param {!SDK.RemoteObject} object |
| 972 * @param {number} fromIndex | 972 * @param {number} fromIndex |
| 973 * @param {number} toIndex | 973 * @param {number} toIndex |
| 974 * @param {boolean} topLevel | 974 * @param {boolean} topLevel |
| 975 * @param {!WebInspector.Linkifier=} linkifier | 975 * @param {!Components.Linkifier=} linkifier |
| 976 * @this {WebInspector.ArrayGroupingTreeElement} | 976 * @this {Components.ArrayGroupingTreeElement} |
| 977 */ | 977 */ |
| 978 static _populateRanges(treeNode, object, fromIndex, toIndex, topLevel, linkifi
er) { | 978 static _populateRanges(treeNode, object, fromIndex, toIndex, topLevel, linkifi
er) { |
| 979 object.callFunctionJSON( | 979 object.callFunctionJSON( |
| 980 packRanges, | 980 packRanges, |
| 981 [ | 981 [ |
| 982 {value: fromIndex}, {value: toIndex}, {value: WebInspector.ArrayGroupi
ngTreeElement._bucketThreshold}, | 982 {value: fromIndex}, {value: toIndex}, {value: Components.ArrayGrouping
TreeElement._bucketThreshold}, |
| 983 {value: WebInspector.ArrayGroupingTreeElement._sparseIterationThreshol
d}, | 983 {value: Components.ArrayGroupingTreeElement._sparseIterationThreshold}
, |
| 984 {value: WebInspector.ArrayGroupingTreeElement._getOwnPropertyNamesThre
shold} | 984 {value: Components.ArrayGroupingTreeElement._getOwnPropertyNamesThresh
old} |
| 985 ], | 985 ], |
| 986 callback); | 986 callback); |
| 987 | 987 |
| 988 /** | 988 /** |
| 989 * Note: must declare params as optional. | 989 * Note: must declare params as optional. |
| 990 * @param {number=} fromIndex | 990 * @param {number=} fromIndex |
| 991 * @param {number=} toIndex | 991 * @param {number=} toIndex |
| 992 * @param {number=} bucketThreshold | 992 * @param {number=} bucketThreshold |
| 993 * @param {number=} sparseIterationThreshold | 993 * @param {number=} sparseIterationThreshold |
| 994 * @param {number=} getOwnPropertyNamesThreshold | 994 * @param {number=} getOwnPropertyNamesThreshold |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 return {ranges: ranges, skipGetOwnPropertyNames: skipGetOwnPropertyNames}; | 1061 return {ranges: ranges, skipGetOwnPropertyNames: skipGetOwnPropertyNames}; |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 function callback(result) { | 1064 function callback(result) { |
| 1065 if (!result) | 1065 if (!result) |
| 1066 return; | 1066 return; |
| 1067 var ranges = /** @type {!Array.<!Array.<number>>} */ (result.ranges); | 1067 var ranges = /** @type {!Array.<!Array.<number>>} */ (result.ranges); |
| 1068 if (ranges.length === 1) { | 1068 if (ranges.length === 1) { |
| 1069 WebInspector.ArrayGroupingTreeElement._populateAsFragment( | 1069 Components.ArrayGroupingTreeElement._populateAsFragment( |
| 1070 treeNode, object, ranges[0][0], ranges[0][1], linkifier); | 1070 treeNode, object, ranges[0][0], ranges[0][1], linkifier); |
| 1071 } else { | 1071 } else { |
| 1072 for (var i = 0; i < ranges.length; ++i) { | 1072 for (var i = 0; i < ranges.length; ++i) { |
| 1073 var fromIndex = ranges[i][0]; | 1073 var fromIndex = ranges[i][0]; |
| 1074 var toIndex = ranges[i][1]; | 1074 var toIndex = ranges[i][1]; |
| 1075 var count = ranges[i][2]; | 1075 var count = ranges[i][2]; |
| 1076 if (fromIndex === toIndex) | 1076 if (fromIndex === toIndex) |
| 1077 WebInspector.ArrayGroupingTreeElement._populateAsFragment(treeNode,
object, fromIndex, toIndex, linkifier); | 1077 Components.ArrayGroupingTreeElement._populateAsFragment(treeNode, ob
ject, fromIndex, toIndex, linkifier); |
| 1078 else | 1078 else |
| 1079 treeNode.appendChild( | 1079 treeNode.appendChild( |
| 1080 new WebInspector.ArrayGroupingTreeElement(object, fromIndex, toI
ndex, count, linkifier)); | 1080 new Components.ArrayGroupingTreeElement(object, fromIndex, toInd
ex, count, linkifier)); |
| 1081 } | 1081 } |
| 1082 } | 1082 } |
| 1083 if (topLevel) | 1083 if (topLevel) |
| 1084 WebInspector.ArrayGroupingTreeElement._populateNonIndexProperties( | 1084 Components.ArrayGroupingTreeElement._populateNonIndexProperties( |
| 1085 treeNode, object, result.skipGetOwnPropertyNames, linkifier); | 1085 treeNode, object, result.skipGetOwnPropertyNames, linkifier); |
| 1086 } | 1086 } |
| 1087 } | 1087 } |
| 1088 | 1088 |
| 1089 /** | 1089 /** |
| 1090 * @param {!TreeElement} treeNode | 1090 * @param {!TreeElement} treeNode |
| 1091 * @param {!WebInspector.RemoteObject} object | 1091 * @param {!SDK.RemoteObject} object |
| 1092 * @param {number} fromIndex | 1092 * @param {number} fromIndex |
| 1093 * @param {number} toIndex | 1093 * @param {number} toIndex |
| 1094 * @param {!WebInspector.Linkifier=} linkifier | 1094 * @param {!Components.Linkifier=} linkifier |
| 1095 * @this {WebInspector.ArrayGroupingTreeElement} | 1095 * @this {Components.ArrayGroupingTreeElement} |
| 1096 */ | 1096 */ |
| 1097 static _populateAsFragment(treeNode, object, fromIndex, toIndex, linkifier) { | 1097 static _populateAsFragment(treeNode, object, fromIndex, toIndex, linkifier) { |
| 1098 object.callFunction( | 1098 object.callFunction( |
| 1099 buildArrayFragment, | 1099 buildArrayFragment, |
| 1100 [ | 1100 [ |
| 1101 {value: fromIndex}, {value: toIndex}, | 1101 {value: fromIndex}, {value: toIndex}, |
| 1102 {value: WebInspector.ArrayGroupingTreeElement._sparseIterationThreshol
d} | 1102 {value: Components.ArrayGroupingTreeElement._sparseIterationThreshold} |
| 1103 ], | 1103 ], |
| 1104 processArrayFragment.bind(this)); | 1104 processArrayFragment.bind(this)); |
| 1105 | 1105 |
| 1106 /** | 1106 /** |
| 1107 * @suppressReceiverCheck | 1107 * @suppressReceiverCheck |
| 1108 * @this {Object} | 1108 * @this {Object} |
| 1109 * @param {number=} fromIndex // must declare optional | 1109 * @param {number=} fromIndex // must declare optional |
| 1110 * @param {number=} toIndex // must declare optional | 1110 * @param {number=} toIndex // must declare optional |
| 1111 * @param {number=} sparseIterationThreshold // must declare optional | 1111 * @param {number=} sparseIterationThreshold // must declare optional |
| 1112 */ | 1112 */ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1123 var name = ownPropertyNames[i]; | 1123 var name = ownPropertyNames[i]; |
| 1124 var index = name >>> 0; | 1124 var index = name >>> 0; |
| 1125 if (String(index) === name && fromIndex <= index && index <= toIndex) | 1125 if (String(index) === name && fromIndex <= index && index <= toIndex) |
| 1126 result[index] = this[index]; | 1126 result[index] = this[index]; |
| 1127 } | 1127 } |
| 1128 } | 1128 } |
| 1129 return result; | 1129 return result; |
| 1130 } | 1130 } |
| 1131 | 1131 |
| 1132 /** | 1132 /** |
| 1133 * @param {?WebInspector.RemoteObject} arrayFragment | 1133 * @param {?SDK.RemoteObject} arrayFragment |
| 1134 * @param {boolean=} wasThrown | 1134 * @param {boolean=} wasThrown |
| 1135 * @this {WebInspector.ArrayGroupingTreeElement} | 1135 * @this {Components.ArrayGroupingTreeElement} |
| 1136 */ | 1136 */ |
| 1137 function processArrayFragment(arrayFragment, wasThrown) { | 1137 function processArrayFragment(arrayFragment, wasThrown) { |
| 1138 if (!arrayFragment || wasThrown) | 1138 if (!arrayFragment || wasThrown) |
| 1139 return; | 1139 return; |
| 1140 arrayFragment.getAllProperties(false, processProperties.bind(this)); | 1140 arrayFragment.getAllProperties(false, processProperties.bind(this)); |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 /** @this {WebInspector.ArrayGroupingTreeElement} */ | 1143 /** @this {Components.ArrayGroupingTreeElement} */ |
| 1144 function processProperties(properties, internalProperties) { | 1144 function processProperties(properties, internalProperties) { |
| 1145 if (!properties) | 1145 if (!properties) |
| 1146 return; | 1146 return; |
| 1147 | 1147 |
| 1148 properties.sort(WebInspector.ObjectPropertiesSection.CompareProperties); | 1148 properties.sort(Components.ObjectPropertiesSection.CompareProperties); |
| 1149 for (var i = 0; i < properties.length; ++i) { | 1149 for (var i = 0; i < properties.length; ++i) { |
| 1150 properties[i].parentObject = this._object; | 1150 properties[i].parentObject = this._object; |
| 1151 var childTreeElement = new WebInspector.ObjectPropertyTreeElement(proper
ties[i], linkifier); | 1151 var childTreeElement = new Components.ObjectPropertyTreeElement(properti
es[i], linkifier); |
| 1152 childTreeElement._readOnly = true; | 1152 childTreeElement._readOnly = true; |
| 1153 treeNode.appendChild(childTreeElement); | 1153 treeNode.appendChild(childTreeElement); |
| 1154 } | 1154 } |
| 1155 } | 1155 } |
| 1156 } | 1156 } |
| 1157 | 1157 |
| 1158 /** | 1158 /** |
| 1159 * @param {!TreeElement} treeNode | 1159 * @param {!TreeElement} treeNode |
| 1160 * @param {!WebInspector.RemoteObject} object | 1160 * @param {!SDK.RemoteObject} object |
| 1161 * @param {boolean} skipGetOwnPropertyNames | 1161 * @param {boolean} skipGetOwnPropertyNames |
| 1162 * @param {!WebInspector.Linkifier=} linkifier | 1162 * @param {!Components.Linkifier=} linkifier |
| 1163 * @this {WebInspector.ArrayGroupingTreeElement} | 1163 * @this {Components.ArrayGroupingTreeElement} |
| 1164 */ | 1164 */ |
| 1165 static _populateNonIndexProperties(treeNode, object, skipGetOwnPropertyNames,
linkifier) { | 1165 static _populateNonIndexProperties(treeNode, object, skipGetOwnPropertyNames,
linkifier) { |
| 1166 object.callFunction(buildObjectFragment, [{value: skipGetOwnPropertyNames}],
processObjectFragment.bind(this)); | 1166 object.callFunction(buildObjectFragment, [{value: skipGetOwnPropertyNames}],
processObjectFragment.bind(this)); |
| 1167 | 1167 |
| 1168 /** | 1168 /** |
| 1169 * @param {boolean=} skipGetOwnPropertyNames | 1169 * @param {boolean=} skipGetOwnPropertyNames |
| 1170 * @suppressReceiverCheck | 1170 * @suppressReceiverCheck |
| 1171 * @this {Object} | 1171 * @this {Object} |
| 1172 */ | 1172 */ |
| 1173 function buildObjectFragment(skipGetOwnPropertyNames) { | 1173 function buildObjectFragment(skipGetOwnPropertyNames) { |
| 1174 var result = {__proto__: this.__proto__}; | 1174 var result = {__proto__: this.__proto__}; |
| 1175 if (skipGetOwnPropertyNames) | 1175 if (skipGetOwnPropertyNames) |
| 1176 return result; | 1176 return result; |
| 1177 var names = Object.getOwnPropertyNames(this); | 1177 var names = Object.getOwnPropertyNames(this); |
| 1178 for (var i = 0; i < names.length; ++i) { | 1178 for (var i = 0; i < names.length; ++i) { |
| 1179 var name = names[i]; | 1179 var name = names[i]; |
| 1180 // Array index check according to the ES5-15.4. | 1180 // Array index check according to the ES5-15.4. |
| 1181 if (String(name >>> 0) === name && name >>> 0 !== 0xffffffff) | 1181 if (String(name >>> 0) === name && name >>> 0 !== 0xffffffff) |
| 1182 continue; | 1182 continue; |
| 1183 var descriptor = Object.getOwnPropertyDescriptor(this, name); | 1183 var descriptor = Object.getOwnPropertyDescriptor(this, name); |
| 1184 if (descriptor) | 1184 if (descriptor) |
| 1185 Object.defineProperty(result, name, descriptor); | 1185 Object.defineProperty(result, name, descriptor); |
| 1186 } | 1186 } |
| 1187 return result; | 1187 return result; |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 /** | 1190 /** |
| 1191 * @param {?WebInspector.RemoteObject} arrayFragment | 1191 * @param {?SDK.RemoteObject} arrayFragment |
| 1192 * @param {boolean=} wasThrown | 1192 * @param {boolean=} wasThrown |
| 1193 * @this {WebInspector.ArrayGroupingTreeElement} | 1193 * @this {Components.ArrayGroupingTreeElement} |
| 1194 */ | 1194 */ |
| 1195 function processObjectFragment(arrayFragment, wasThrown) { | 1195 function processObjectFragment(arrayFragment, wasThrown) { |
| 1196 if (!arrayFragment || wasThrown) | 1196 if (!arrayFragment || wasThrown) |
| 1197 return; | 1197 return; |
| 1198 arrayFragment.getOwnProperties(processProperties.bind(this)); | 1198 arrayFragment.getOwnProperties(processProperties.bind(this)); |
| 1199 } | 1199 } |
| 1200 | 1200 |
| 1201 /** | 1201 /** |
| 1202 * @param {?Array.<!WebInspector.RemoteObjectProperty>} properties | 1202 * @param {?Array.<!SDK.RemoteObjectProperty>} properties |
| 1203 * @param {?Array.<!WebInspector.RemoteObjectProperty>=} internalProperties | 1203 * @param {?Array.<!SDK.RemoteObjectProperty>=} internalProperties |
| 1204 * @this {WebInspector.ArrayGroupingTreeElement} | 1204 * @this {Components.ArrayGroupingTreeElement} |
| 1205 */ | 1205 */ |
| 1206 function processProperties(properties, internalProperties) { | 1206 function processProperties(properties, internalProperties) { |
| 1207 if (!properties) | 1207 if (!properties) |
| 1208 return; | 1208 return; |
| 1209 properties.sort(WebInspector.ObjectPropertiesSection.CompareProperties); | 1209 properties.sort(Components.ObjectPropertiesSection.CompareProperties); |
| 1210 for (var i = 0; i < properties.length; ++i) { | 1210 for (var i = 0; i < properties.length; ++i) { |
| 1211 properties[i].parentObject = this._object; | 1211 properties[i].parentObject = this._object; |
| 1212 var childTreeElement = new WebInspector.ObjectPropertyTreeElement(proper
ties[i], linkifier); | 1212 var childTreeElement = new Components.ObjectPropertyTreeElement(properti
es[i], linkifier); |
| 1213 childTreeElement._readOnly = true; | 1213 childTreeElement._readOnly = true; |
| 1214 treeNode.appendChild(childTreeElement); | 1214 treeNode.appendChild(childTreeElement); |
| 1215 } | 1215 } |
| 1216 } | 1216 } |
| 1217 } | 1217 } |
| 1218 | 1218 |
| 1219 /** | 1219 /** |
| 1220 * @override | 1220 * @override |
| 1221 */ | 1221 */ |
| 1222 onpopulate() { | 1222 onpopulate() { |
| 1223 if (this._propertyCount >= WebInspector.ArrayGroupingTreeElement._bucketThre
shold) { | 1223 if (this._propertyCount >= Components.ArrayGroupingTreeElement._bucketThresh
old) { |
| 1224 WebInspector.ArrayGroupingTreeElement._populateRanges( | 1224 Components.ArrayGroupingTreeElement._populateRanges( |
| 1225 this, this._object, this._fromIndex, this._toIndex, false, this._linki
fier); | 1225 this, this._object, this._fromIndex, this._toIndex, false, this._linki
fier); |
| 1226 return; | 1226 return; |
| 1227 } | 1227 } |
| 1228 WebInspector.ArrayGroupingTreeElement._populateAsFragment( | 1228 Components.ArrayGroupingTreeElement._populateAsFragment( |
| 1229 this, this._object, this._fromIndex, this._toIndex, this._linkifier); | 1229 this, this._object, this._fromIndex, this._toIndex, this._linkifier); |
| 1230 } | 1230 } |
| 1231 | 1231 |
| 1232 /** | 1232 /** |
| 1233 * @override | 1233 * @override |
| 1234 */ | 1234 */ |
| 1235 onattach() { | 1235 onattach() { |
| 1236 this.listItemElement.classList.add('object-properties-section-name'); | 1236 this.listItemElement.classList.add('object-properties-section-name'); |
| 1237 } | 1237 } |
| 1238 }; | 1238 }; |
| 1239 | 1239 |
| 1240 WebInspector.ArrayGroupingTreeElement._bucketThreshold = 100; | 1240 Components.ArrayGroupingTreeElement._bucketThreshold = 100; |
| 1241 WebInspector.ArrayGroupingTreeElement._sparseIterationThreshold = 250000; | 1241 Components.ArrayGroupingTreeElement._sparseIterationThreshold = 250000; |
| 1242 WebInspector.ArrayGroupingTreeElement._getOwnPropertyNamesThreshold = 500000; | 1242 Components.ArrayGroupingTreeElement._getOwnPropertyNamesThreshold = 500000; |
| 1243 | 1243 |
| 1244 | 1244 |
| 1245 /** | 1245 /** |
| 1246 * @unrestricted | 1246 * @unrestricted |
| 1247 */ | 1247 */ |
| 1248 WebInspector.ObjectPropertyPrompt = class extends WebInspector.TextPrompt { | 1248 Components.ObjectPropertyPrompt = class extends UI.TextPrompt { |
| 1249 constructor() { | 1249 constructor() { |
| 1250 super(); | 1250 super(); |
| 1251 this.initialize(WebInspector.JavaScriptAutocomplete.completionsForTextPrompt
InCurrentContext); | 1251 this.initialize(Components.JavaScriptAutocomplete.completionsForTextPromptIn
CurrentContext); |
| 1252 this.setSuggestBoxEnabled(true); | 1252 this.setSuggestBoxEnabled(true); |
| 1253 } | 1253 } |
| 1254 }; | 1254 }; |
| 1255 | 1255 |
| 1256 | 1256 |
| 1257 WebInspector.ObjectPropertiesSection._functionPrefixSource = /^(?:async\s)?funct
ion\*?\s/; | 1257 Components.ObjectPropertiesSection._functionPrefixSource = /^(?:async\s)?functio
n\*?\s/; |
| 1258 | 1258 |
| 1259 | 1259 |
| 1260 /** | 1260 /** |
| 1261 * @unrestricted | 1261 * @unrestricted |
| 1262 */ | 1262 */ |
| 1263 WebInspector.ObjectPropertiesSectionExpandController = class { | 1263 Components.ObjectPropertiesSectionExpandController = class { |
| 1264 constructor() { | 1264 constructor() { |
| 1265 /** @type {!Set.<string>} */ | 1265 /** @type {!Set.<string>} */ |
| 1266 this._expandedProperties = new Set(); | 1266 this._expandedProperties = new Set(); |
| 1267 } | 1267 } |
| 1268 | 1268 |
| 1269 /** | 1269 /** |
| 1270 * @param {string} id | 1270 * @param {string} id |
| 1271 * @param {!WebInspector.ObjectPropertiesSection} section | 1271 * @param {!Components.ObjectPropertiesSection} section |
| 1272 */ | 1272 */ |
| 1273 watchSection(id, section) { | 1273 watchSection(id, section) { |
| 1274 section.addEventListener(TreeOutline.Events.ElementAttached, this._elementAt
tached, this); | 1274 section.addEventListener(TreeOutline.Events.ElementAttached, this._elementAt
tached, this); |
| 1275 section.addEventListener(TreeOutline.Events.ElementExpanded, this._elementEx
panded, this); | 1275 section.addEventListener(TreeOutline.Events.ElementExpanded, this._elementEx
panded, this); |
| 1276 section.addEventListener(TreeOutline.Events.ElementCollapsed, this._elementC
ollapsed, this); | 1276 section.addEventListener(TreeOutline.Events.ElementCollapsed, this._elementC
ollapsed, this); |
| 1277 section[WebInspector.ObjectPropertiesSectionExpandController._treeOutlineId]
= id; | 1277 section[Components.ObjectPropertiesSectionExpandController._treeOutlineId] =
id; |
| 1278 | 1278 |
| 1279 if (this._expandedProperties.has(id)) | 1279 if (this._expandedProperties.has(id)) |
| 1280 section.expand(); | 1280 section.expand(); |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 /** | 1283 /** |
| 1284 * @param {string} id | 1284 * @param {string} id |
| 1285 */ | 1285 */ |
| 1286 stopWatchSectionsWithId(id) { | 1286 stopWatchSectionsWithId(id) { |
| 1287 for (var property of this._expandedProperties) { | 1287 for (var property of this._expandedProperties) { |
| 1288 if (property.startsWith(id + ':')) | 1288 if (property.startsWith(id + ':')) |
| 1289 this._expandedProperties.delete(property); | 1289 this._expandedProperties.delete(property); |
| 1290 } | 1290 } |
| 1291 } | 1291 } |
| 1292 | 1292 |
| 1293 /** | 1293 /** |
| 1294 * @param {!WebInspector.Event} event | 1294 * @param {!Common.Event} event |
| 1295 */ | 1295 */ |
| 1296 _elementAttached(event) { | 1296 _elementAttached(event) { |
| 1297 var element = /** @type {!TreeElement} */ (event.data); | 1297 var element = /** @type {!TreeElement} */ (event.data); |
| 1298 if (element.isExpandable() && this._expandedProperties.has(this._propertyPat
h(element))) | 1298 if (element.isExpandable() && this._expandedProperties.has(this._propertyPat
h(element))) |
| 1299 element.expand(); | 1299 element.expand(); |
| 1300 } | 1300 } |
| 1301 | 1301 |
| 1302 /** | 1302 /** |
| 1303 * @param {!WebInspector.Event} event | 1303 * @param {!Common.Event} event |
| 1304 */ | 1304 */ |
| 1305 _elementExpanded(event) { | 1305 _elementExpanded(event) { |
| 1306 var element = /** @type {!TreeElement} */ (event.data); | 1306 var element = /** @type {!TreeElement} */ (event.data); |
| 1307 this._expandedProperties.add(this._propertyPath(element)); | 1307 this._expandedProperties.add(this._propertyPath(element)); |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 /** | 1310 /** |
| 1311 * @param {!WebInspector.Event} event | 1311 * @param {!Common.Event} event |
| 1312 */ | 1312 */ |
| 1313 _elementCollapsed(event) { | 1313 _elementCollapsed(event) { |
| 1314 var element = /** @type {!TreeElement} */ (event.data); | 1314 var element = /** @type {!TreeElement} */ (event.data); |
| 1315 this._expandedProperties.delete(this._propertyPath(element)); | 1315 this._expandedProperties.delete(this._propertyPath(element)); |
| 1316 } | 1316 } |
| 1317 | 1317 |
| 1318 /** | 1318 /** |
| 1319 * @param {!TreeElement} treeElement | 1319 * @param {!TreeElement} treeElement |
| 1320 * @return {string} | 1320 * @return {string} |
| 1321 */ | 1321 */ |
| 1322 _propertyPath(treeElement) { | 1322 _propertyPath(treeElement) { |
| 1323 var cachedPropertyPath = treeElement[WebInspector.ObjectPropertiesSectionExp
andController._cachedPathSymbol]; | 1323 var cachedPropertyPath = treeElement[Components.ObjectPropertiesSectionExpan
dController._cachedPathSymbol]; |
| 1324 if (cachedPropertyPath) | 1324 if (cachedPropertyPath) |
| 1325 return cachedPropertyPath; | 1325 return cachedPropertyPath; |
| 1326 | 1326 |
| 1327 var current = treeElement; | 1327 var current = treeElement; |
| 1328 var rootElement = treeElement.treeOutline.objectTreeElement(); | 1328 var rootElement = treeElement.treeOutline.objectTreeElement(); |
| 1329 | 1329 |
| 1330 var result; | 1330 var result; |
| 1331 | 1331 |
| 1332 while (current !== rootElement) { | 1332 while (current !== rootElement) { |
| 1333 var currentName = ''; | 1333 var currentName = ''; |
| 1334 if (current.property) | 1334 if (current.property) |
| 1335 currentName = current.property.name; | 1335 currentName = current.property.name; |
| 1336 else | 1336 else |
| 1337 currentName = typeof current.title === 'string' ? current.title : curren
t.title.textContent; | 1337 currentName = typeof current.title === 'string' ? current.title : curren
t.title.textContent; |
| 1338 | 1338 |
| 1339 result = currentName + (result ? '.' + result : ''); | 1339 result = currentName + (result ? '.' + result : ''); |
| 1340 current = current.parent; | 1340 current = current.parent; |
| 1341 } | 1341 } |
| 1342 var treeOutlineId = treeElement.treeOutline[WebInspector.ObjectPropertiesSec
tionExpandController._treeOutlineId]; | 1342 var treeOutlineId = treeElement.treeOutline[Components.ObjectPropertiesSecti
onExpandController._treeOutlineId]; |
| 1343 result = treeOutlineId + (result ? ':' + result : ''); | 1343 result = treeOutlineId + (result ? ':' + result : ''); |
| 1344 treeElement[WebInspector.ObjectPropertiesSectionExpandController._cachedPath
Symbol] = result; | 1344 treeElement[Components.ObjectPropertiesSectionExpandController._cachedPathSy
mbol] = result; |
| 1345 return result; | 1345 return result; |
| 1346 } | 1346 } |
| 1347 }; | 1347 }; |
| 1348 | 1348 |
| 1349 WebInspector.ObjectPropertiesSectionExpandController._cachedPathSymbol = Symbol(
'cachedPath'); | 1349 Components.ObjectPropertiesSectionExpandController._cachedPathSymbol = Symbol('c
achedPath'); |
| 1350 WebInspector.ObjectPropertiesSectionExpandController._treeOutlineId = Symbol('tr
eeOutlineId'); | 1350 Components.ObjectPropertiesSectionExpandController._treeOutlineId = Symbol('tree
OutlineId'); |
| OLD | NEW |