| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) IBM Corp. 2009 All rights reserved. | 2 * Copyright (C) IBM Corp. 2009 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 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 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 * @implements {WebInspector.ActionDelegate} | 31 * @implements {UI.ActionDelegate} |
| 32 * @implements {WebInspector.ToolbarItem.ItemsProvider} | 32 * @implements {UI.ToolbarItem.ItemsProvider} |
| 33 * @implements {WebInspector.ContextMenu.Provider} | 33 * @implements {UI.ContextMenu.Provider} |
| 34 * @unrestricted | 34 * @unrestricted |
| 35 */ | 35 */ |
| 36 WebInspector.WatchExpressionsSidebarPane = class extends WebInspector.ThrottledW
idget { | 36 Sources.WatchExpressionsSidebarPane = class extends UI.ThrottledWidget { |
| 37 constructor() { | 37 constructor() { |
| 38 super(); | 38 super(); |
| 39 this.registerRequiredCSS('components/objectValue.css'); | 39 this.registerRequiredCSS('components/objectValue.css'); |
| 40 | 40 |
| 41 /** @type {!Array.<!WebInspector.WatchExpression>} */ | 41 /** @type {!Array.<!Sources.WatchExpression>} */ |
| 42 this._watchExpressions = []; | 42 this._watchExpressions = []; |
| 43 this._watchExpressionsSetting = WebInspector.settings.createLocalSetting('wa
tchExpressions', []); | 43 this._watchExpressionsSetting = Common.settings.createLocalSetting('watchExp
ressions', []); |
| 44 | 44 |
| 45 this._addButton = new WebInspector.ToolbarButton(WebInspector.UIString('Add
expression'), 'largeicon-add'); | 45 this._addButton = new UI.ToolbarButton(Common.UIString('Add expression'), 'l
argeicon-add'); |
| 46 this._addButton.addEventListener('click', this._addButtonClicked.bind(this))
; | 46 this._addButton.addEventListener('click', this._addButtonClicked.bind(this))
; |
| 47 this._refreshButton = new WebInspector.ToolbarButton(WebInspector.UIString('
Refresh'), 'largeicon-refresh'); | 47 this._refreshButton = new UI.ToolbarButton(Common.UIString('Refresh'), 'larg
eicon-refresh'); |
| 48 this._refreshButton.addEventListener('click', this._refreshButtonClicked.bin
d(this)); | 48 this._refreshButton.addEventListener('click', this._refreshButtonClicked.bin
d(this)); |
| 49 | 49 |
| 50 this._bodyElement = this.element.createChild('div', 'vbox watch-expressions'
); | 50 this._bodyElement = this.element.createChild('div', 'vbox watch-expressions'
); |
| 51 this._bodyElement.addEventListener('contextmenu', this._contextMenu.bind(thi
s), false); | 51 this._bodyElement.addEventListener('contextmenu', this._contextMenu.bind(thi
s), false); |
| 52 this._expandController = new WebInspector.ObjectPropertiesSectionExpandContr
oller(); | 52 this._expandController = new Components.ObjectPropertiesSectionExpandControl
ler(); |
| 53 | 53 |
| 54 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext,
this.update, this); | 54 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this.update, this); |
| 55 WebInspector.context.addFlavorChangeListener(WebInspector.DebuggerModel.Call
Frame, this.update, this); | 55 UI.context.addFlavorChangeListener(SDK.DebuggerModel.CallFrame, this.update,
this); |
| 56 this._linkifier = new WebInspector.Linkifier(); | 56 this._linkifier = new Components.Linkifier(); |
| 57 this.update(); | 57 this.update(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * @override | 61 * @override |
| 62 * @return {!Array<!WebInspector.ToolbarItem>} | 62 * @return {!Array<!UI.ToolbarItem>} |
| 63 */ | 63 */ |
| 64 toolbarItems() { | 64 toolbarItems() { |
| 65 return [this._addButton, this._refreshButton]; | 65 return [this._addButton, this._refreshButton]; |
| 66 } | 66 } |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * @return {boolean} | 69 * @return {boolean} |
| 70 */ | 70 */ |
| 71 hasExpressions() { | 71 hasExpressions() { |
| 72 return !!this._watchExpressionsSetting.get().length; | 72 return !!this._watchExpressionsSetting.get().length; |
| 73 } | 73 } |
| 74 | 74 |
| 75 _saveExpressions() { | 75 _saveExpressions() { |
| 76 var toSave = []; | 76 var toSave = []; |
| 77 for (var i = 0; i < this._watchExpressions.length; i++) | 77 for (var i = 0; i < this._watchExpressions.length; i++) |
| 78 if (this._watchExpressions[i].expression()) | 78 if (this._watchExpressions[i].expression()) |
| 79 toSave.push(this._watchExpressions[i].expression()); | 79 toSave.push(this._watchExpressions[i].expression()); |
| 80 | 80 |
| 81 this._watchExpressionsSetting.set(toSave); | 81 this._watchExpressionsSetting.set(toSave); |
| 82 } | 82 } |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * @param {!WebInspector.Event=} event | 85 * @param {!Common.Event=} event |
| 86 */ | 86 */ |
| 87 _addButtonClicked(event) { | 87 _addButtonClicked(event) { |
| 88 if (event) | 88 if (event) |
| 89 event.consume(true); | 89 event.consume(true); |
| 90 WebInspector.viewManager.showView('sources.watch'); | 90 UI.viewManager.showView('sources.watch'); |
| 91 this._createWatchExpression(null).startEditing(); | 91 this._createWatchExpression(null).startEditing(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * @param {!WebInspector.Event} event | 95 * @param {!Common.Event} event |
| 96 */ | 96 */ |
| 97 _refreshButtonClicked(event) { | 97 _refreshButtonClicked(event) { |
| 98 event.consume(); | 98 event.consume(); |
| 99 this.update(); | 99 this.update(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 /** | 102 /** |
| 103 * @override | 103 * @override |
| 104 * @return {!Promise.<?>} | 104 * @return {!Promise.<?>} |
| 105 */ | 105 */ |
| 106 doUpdate() { | 106 doUpdate() { |
| 107 this._linkifier.reset(); | 107 this._linkifier.reset(); |
| 108 this._bodyElement.removeChildren(); | 108 this._bodyElement.removeChildren(); |
| 109 this._watchExpressions = []; | 109 this._watchExpressions = []; |
| 110 this._emptyElement = this._bodyElement.createChild('div', 'gray-info-message
'); | 110 this._emptyElement = this._bodyElement.createChild('div', 'gray-info-message
'); |
| 111 this._emptyElement.textContent = WebInspector.UIString('No Watch Expressions
'); | 111 this._emptyElement.textContent = Common.UIString('No Watch Expressions'); |
| 112 var watchExpressionStrings = this._watchExpressionsSetting.get(); | 112 var watchExpressionStrings = this._watchExpressionsSetting.get(); |
| 113 for (var i = 0; i < watchExpressionStrings.length; ++i) { | 113 for (var i = 0; i < watchExpressionStrings.length; ++i) { |
| 114 var expression = watchExpressionStrings[i]; | 114 var expression = watchExpressionStrings[i]; |
| 115 if (!expression) | 115 if (!expression) |
| 116 continue; | 116 continue; |
| 117 | 117 |
| 118 this._createWatchExpression(expression); | 118 this._createWatchExpression(expression); |
| 119 } | 119 } |
| 120 return Promise.resolve(); | 120 return Promise.resolve(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 /** | 123 /** |
| 124 * @param {?string} expression | 124 * @param {?string} expression |
| 125 * @return {!WebInspector.WatchExpression} | 125 * @return {!Sources.WatchExpression} |
| 126 */ | 126 */ |
| 127 _createWatchExpression(expression) { | 127 _createWatchExpression(expression) { |
| 128 this._emptyElement.classList.add('hidden'); | 128 this._emptyElement.classList.add('hidden'); |
| 129 var watchExpression = new WebInspector.WatchExpression(expression, this._exp
andController, this._linkifier); | 129 var watchExpression = new Sources.WatchExpression(expression, this._expandCo
ntroller, this._linkifier); |
| 130 watchExpression.addEventListener( | 130 watchExpression.addEventListener( |
| 131 WebInspector.WatchExpression.Events.ExpressionUpdated, this._watchExpres
sionUpdated.bind(this)); | 131 Sources.WatchExpression.Events.ExpressionUpdated, this._watchExpressionU
pdated.bind(this)); |
| 132 this._bodyElement.appendChild(watchExpression.element()); | 132 this._bodyElement.appendChild(watchExpression.element()); |
| 133 this._watchExpressions.push(watchExpression); | 133 this._watchExpressions.push(watchExpression); |
| 134 return watchExpression; | 134 return watchExpression; |
| 135 } | 135 } |
| 136 | 136 |
| 137 /** | 137 /** |
| 138 * @param {!WebInspector.Event} event | 138 * @param {!Common.Event} event |
| 139 */ | 139 */ |
| 140 _watchExpressionUpdated(event) { | 140 _watchExpressionUpdated(event) { |
| 141 var watchExpression = /** @type {!WebInspector.WatchExpression} */ (event.ta
rget); | 141 var watchExpression = /** @type {!Sources.WatchExpression} */ (event.target)
; |
| 142 if (!watchExpression.expression()) { | 142 if (!watchExpression.expression()) { |
| 143 this._watchExpressions.remove(watchExpression); | 143 this._watchExpressions.remove(watchExpression); |
| 144 this._bodyElement.removeChild(watchExpression.element()); | 144 this._bodyElement.removeChild(watchExpression.element()); |
| 145 this._emptyElement.classList.toggle('hidden', !!this._watchExpressions.len
gth); | 145 this._emptyElement.classList.toggle('hidden', !!this._watchExpressions.len
gth); |
| 146 } | 146 } |
| 147 | 147 |
| 148 this._saveExpressions(); | 148 this._saveExpressions(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 /** | 151 /** |
| 152 * @param {!Event} event | 152 * @param {!Event} event |
| 153 */ | 153 */ |
| 154 _contextMenu(event) { | 154 _contextMenu(event) { |
| 155 var contextMenu = new WebInspector.ContextMenu(event); | 155 var contextMenu = new UI.ContextMenu(event); |
| 156 this._populateContextMenu(contextMenu, event); | 156 this._populateContextMenu(contextMenu, event); |
| 157 contextMenu.show(); | 157 contextMenu.show(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 /** | 160 /** |
| 161 * @param {!WebInspector.ContextMenu} contextMenu | 161 * @param {!UI.ContextMenu} contextMenu |
| 162 * @param {!Event} event | 162 * @param {!Event} event |
| 163 */ | 163 */ |
| 164 _populateContextMenu(contextMenu, event) { | 164 _populateContextMenu(contextMenu, event) { |
| 165 var isEditing = false; | 165 var isEditing = false; |
| 166 for (var watchExpression of this._watchExpressions) | 166 for (var watchExpression of this._watchExpressions) |
| 167 isEditing |= watchExpression.isEditing(); | 167 isEditing |= watchExpression.isEditing(); |
| 168 | 168 |
| 169 if (!isEditing) | 169 if (!isEditing) |
| 170 contextMenu.appendItem( | 170 contextMenu.appendItem( |
| 171 WebInspector.UIString.capitalize('Add ^watch ^expression'), this._addB
uttonClicked.bind(this)); | 171 Common.UIString.capitalize('Add ^watch ^expression'), this._addButtonC
licked.bind(this)); |
| 172 | 172 |
| 173 if (this._watchExpressions.length > 1) | 173 if (this._watchExpressions.length > 1) |
| 174 contextMenu.appendItem( | 174 contextMenu.appendItem( |
| 175 WebInspector.UIString.capitalize('Delete ^all ^watch ^expressions'), t
his._deleteAllButtonClicked.bind(this)); | 175 Common.UIString.capitalize('Delete ^all ^watch ^expressions'), this._d
eleteAllButtonClicked.bind(this)); |
| 176 | 176 |
| 177 var target = event.deepElementFromPoint(); | 177 var target = event.deepElementFromPoint(); |
| 178 if (!target) | 178 if (!target) |
| 179 return; | 179 return; |
| 180 for (var watchExpression of this._watchExpressions) | 180 for (var watchExpression of this._watchExpressions) |
| 181 if (watchExpression.element().isSelfOrAncestor(target)) | 181 if (watchExpression.element().isSelfOrAncestor(target)) |
| 182 watchExpression._populateContextMenu(contextMenu, event); | 182 watchExpression._populateContextMenu(contextMenu, event); |
| 183 } | 183 } |
| 184 | 184 |
| 185 _deleteAllButtonClicked() { | 185 _deleteAllButtonClicked() { |
| 186 this._watchExpressions = []; | 186 this._watchExpressions = []; |
| 187 this._saveExpressions(); | 187 this._saveExpressions(); |
| 188 this.update(); | 188 this.update(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 /** | 191 /** |
| 192 * @override | 192 * @override |
| 193 * @param {!WebInspector.Context} context | 193 * @param {!UI.Context} context |
| 194 * @param {string} actionId | 194 * @param {string} actionId |
| 195 * @return {boolean} | 195 * @return {boolean} |
| 196 */ | 196 */ |
| 197 handleAction(context, actionId) { | 197 handleAction(context, actionId) { |
| 198 var frame = WebInspector.context.flavor(WebInspector.UISourceCodeFrame); | 198 var frame = UI.context.flavor(Sources.UISourceCodeFrame); |
| 199 if (!frame) | 199 if (!frame) |
| 200 return false; | 200 return false; |
| 201 var text = frame.textEditor.text(frame.textEditor.selection()); | 201 var text = frame.textEditor.text(frame.textEditor.selection()); |
| 202 WebInspector.viewManager.showView('sources.watch'); | 202 UI.viewManager.showView('sources.watch'); |
| 203 this.doUpdate(); | 203 this.doUpdate(); |
| 204 this._createWatchExpression(text); | 204 this._createWatchExpression(text); |
| 205 this._saveExpressions(); | 205 this._saveExpressions(); |
| 206 return true; | 206 return true; |
| 207 } | 207 } |
| 208 | 208 |
| 209 /** | 209 /** |
| 210 * @override | 210 * @override |
| 211 * @param {!Event} event | 211 * @param {!Event} event |
| 212 * @param {!WebInspector.ContextMenu} contextMenu | 212 * @param {!UI.ContextMenu} contextMenu |
| 213 * @param {!Object} target | 213 * @param {!Object} target |
| 214 */ | 214 */ |
| 215 appendApplicableItems(event, contextMenu, target) { | 215 appendApplicableItems(event, contextMenu, target) { |
| 216 contextMenu.appendAction('sources.add-to-watch'); | 216 contextMenu.appendAction('sources.add-to-watch'); |
| 217 } | 217 } |
| 218 }; | 218 }; |
| 219 | 219 |
| 220 /** | 220 /** |
| 221 * @unrestricted | 221 * @unrestricted |
| 222 */ | 222 */ |
| 223 WebInspector.WatchExpression = class extends WebInspector.Object { | 223 Sources.WatchExpression = class extends Common.Object { |
| 224 /** | 224 /** |
| 225 * @param {?string} expression | 225 * @param {?string} expression |
| 226 * @param {!WebInspector.ObjectPropertiesSectionExpandController} expandContro
ller | 226 * @param {!Components.ObjectPropertiesSectionExpandController} expandControll
er |
| 227 * @param {!WebInspector.Linkifier} linkifier | 227 * @param {!Components.Linkifier} linkifier |
| 228 */ | 228 */ |
| 229 constructor(expression, expandController, linkifier) { | 229 constructor(expression, expandController, linkifier) { |
| 230 super(); | 230 super(); |
| 231 this._expression = expression; | 231 this._expression = expression; |
| 232 this._expandController = expandController; | 232 this._expandController = expandController; |
| 233 this._element = createElementWithClass('div', 'watch-expression monospace'); | 233 this._element = createElementWithClass('div', 'watch-expression monospace'); |
| 234 this._editing = false; | 234 this._editing = false; |
| 235 this._linkifier = linkifier; | 235 this._linkifier = linkifier; |
| 236 | 236 |
| 237 this._createWatchExpression(null); | 237 this._createWatchExpression(null); |
| 238 this.update(); | 238 this.update(); |
| 239 } | 239 } |
| 240 | 240 |
| 241 /** | 241 /** |
| 242 * @return {!Element} | 242 * @return {!Element} |
| 243 */ | 243 */ |
| 244 element() { | 244 element() { |
| 245 return this._element; | 245 return this._element; |
| 246 } | 246 } |
| 247 | 247 |
| 248 /** | 248 /** |
| 249 * @return {?string} | 249 * @return {?string} |
| 250 */ | 250 */ |
| 251 expression() { | 251 expression() { |
| 252 return this._expression; | 252 return this._expression; |
| 253 } | 253 } |
| 254 | 254 |
| 255 update() { | 255 update() { |
| 256 var currentExecutionContext = WebInspector.context.flavor(WebInspector.Execu
tionContext); | 256 var currentExecutionContext = UI.context.flavor(SDK.ExecutionContext); |
| 257 if (currentExecutionContext && this._expression) | 257 if (currentExecutionContext && this._expression) |
| 258 currentExecutionContext.evaluate( | 258 currentExecutionContext.evaluate( |
| 259 this._expression, WebInspector.WatchExpression._watchObjectGroupId, fa
lse, true, false, false, false, | 259 this._expression, Sources.WatchExpression._watchObjectGroupId, false,
true, false, false, false, |
| 260 this._createWatchExpression.bind(this)); | 260 this._createWatchExpression.bind(this)); |
| 261 } | 261 } |
| 262 | 262 |
| 263 startEditing() { | 263 startEditing() { |
| 264 this._editing = true; | 264 this._editing = true; |
| 265 this._element.removeChild(this._objectPresentationElement); | 265 this._element.removeChild(this._objectPresentationElement); |
| 266 var newDiv = this._element.createChild('div'); | 266 var newDiv = this._element.createChild('div'); |
| 267 newDiv.textContent = this._nameElement.textContent; | 267 newDiv.textContent = this._nameElement.textContent; |
| 268 this._textPrompt = new WebInspector.ObjectPropertyPrompt(); | 268 this._textPrompt = new Components.ObjectPropertyPrompt(); |
| 269 this._textPrompt.renderAsBlock(); | 269 this._textPrompt.renderAsBlock(); |
| 270 var proxyElement = this._textPrompt.attachAndStartEditing(newDiv, this._fini
shEditing.bind(this)); | 270 var proxyElement = this._textPrompt.attachAndStartEditing(newDiv, this._fini
shEditing.bind(this)); |
| 271 proxyElement.classList.add('watch-expression-text-prompt-proxy'); | 271 proxyElement.classList.add('watch-expression-text-prompt-proxy'); |
| 272 proxyElement.addEventListener('keydown', this._promptKeyDown.bind(this), fal
se); | 272 proxyElement.addEventListener('keydown', this._promptKeyDown.bind(this), fal
se); |
| 273 this._element.getComponentSelection().setBaseAndExtent(newDiv, 0, newDiv, 1)
; | 273 this._element.getComponentSelection().setBaseAndExtent(newDiv, 0, newDiv, 1)
; |
| 274 } | 274 } |
| 275 | 275 |
| 276 /** | 276 /** |
| 277 * @return {boolean} | 277 * @return {boolean} |
| 278 */ | 278 */ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 307 } | 307 } |
| 308 | 308 |
| 309 /** | 309 /** |
| 310 * @param {?string} newExpression | 310 * @param {?string} newExpression |
| 311 */ | 311 */ |
| 312 _updateExpression(newExpression) { | 312 _updateExpression(newExpression) { |
| 313 if (this._expression) | 313 if (this._expression) |
| 314 this._expandController.stopWatchSectionsWithId(this._expression); | 314 this._expandController.stopWatchSectionsWithId(this._expression); |
| 315 this._expression = newExpression; | 315 this._expression = newExpression; |
| 316 this.update(); | 316 this.update(); |
| 317 this.dispatchEventToListeners(WebInspector.WatchExpression.Events.Expression
Updated); | 317 this.dispatchEventToListeners(Sources.WatchExpression.Events.ExpressionUpdat
ed); |
| 318 } | 318 } |
| 319 | 319 |
| 320 /** | 320 /** |
| 321 * @param {!Event} event | 321 * @param {!Event} event |
| 322 */ | 322 */ |
| 323 _deleteWatchExpression(event) { | 323 _deleteWatchExpression(event) { |
| 324 event.consume(true); | 324 event.consume(true); |
| 325 this._updateExpression(null); | 325 this._updateExpression(null); |
| 326 } | 326 } |
| 327 | 327 |
| 328 /** | 328 /** |
| 329 * @param {?WebInspector.RemoteObject} result | 329 * @param {?SDK.RemoteObject} result |
| 330 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails | 330 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails |
| 331 */ | 331 */ |
| 332 _createWatchExpression(result, exceptionDetails) { | 332 _createWatchExpression(result, exceptionDetails) { |
| 333 this._result = result; | 333 this._result = result; |
| 334 | 334 |
| 335 var headerElement = createElementWithClass('div', 'watch-expression-header')
; | 335 var headerElement = createElementWithClass('div', 'watch-expression-header')
; |
| 336 var deleteButton = headerElement.createChild('button', 'watch-expression-del
ete-button'); | 336 var deleteButton = headerElement.createChild('button', 'watch-expression-del
ete-button'); |
| 337 deleteButton.title = WebInspector.UIString('Delete watch expression'); | 337 deleteButton.title = Common.UIString('Delete watch expression'); |
| 338 deleteButton.addEventListener('click', this._deleteWatchExpression.bind(this
), false); | 338 deleteButton.addEventListener('click', this._deleteWatchExpression.bind(this
), false); |
| 339 | 339 |
| 340 var titleElement = headerElement.createChild('div', 'watch-expression-title'
); | 340 var titleElement = headerElement.createChild('div', 'watch-expression-title'
); |
| 341 this._nameElement = WebInspector.ObjectPropertiesSection.createNameElement(t
his._expression); | 341 this._nameElement = Components.ObjectPropertiesSection.createNameElement(thi
s._expression); |
| 342 if (!!exceptionDetails || !result) { | 342 if (!!exceptionDetails || !result) { |
| 343 this._valueElement = createElementWithClass('span', 'watch-expression-erro
r value'); | 343 this._valueElement = createElementWithClass('span', 'watch-expression-erro
r value'); |
| 344 titleElement.classList.add('dimmed'); | 344 titleElement.classList.add('dimmed'); |
| 345 this._valueElement.textContent = WebInspector.UIString('<not available>'); | 345 this._valueElement.textContent = Common.UIString('<not available>'); |
| 346 } else { | 346 } else { |
| 347 this._valueElement = WebInspector.ObjectPropertiesSection.createValueEleme
ntWithCustomSupport( | 347 this._valueElement = Components.ObjectPropertiesSection.createValueElement
WithCustomSupport( |
| 348 result, !!exceptionDetails, titleElement, this._linkifier); | 348 result, !!exceptionDetails, titleElement, this._linkifier); |
| 349 } | 349 } |
| 350 var separatorElement = createElementWithClass('span', 'watch-expressions-sep
arator'); | 350 var separatorElement = createElementWithClass('span', 'watch-expressions-sep
arator'); |
| 351 separatorElement.textContent = ': '; | 351 separatorElement.textContent = ': '; |
| 352 titleElement.appendChildren(this._nameElement, separatorElement, this._value
Element); | 352 titleElement.appendChildren(this._nameElement, separatorElement, this._value
Element); |
| 353 | 353 |
| 354 this._element.removeChildren(); | 354 this._element.removeChildren(); |
| 355 this._objectPropertiesSection = null; | 355 this._objectPropertiesSection = null; |
| 356 if (!exceptionDetails && result && result.hasChildren && !result.customPrevi
ew()) { | 356 if (!exceptionDetails && result && result.hasChildren && !result.customPrevi
ew()) { |
| 357 headerElement.classList.add('watch-expression-object-header'); | 357 headerElement.classList.add('watch-expression-object-header'); |
| 358 this._objectPropertiesSection = new WebInspector.ObjectPropertiesSection(r
esult, headerElement, this._linkifier); | 358 this._objectPropertiesSection = new Components.ObjectPropertiesSection(res
ult, headerElement, this._linkifier); |
| 359 this._objectPresentationElement = this._objectPropertiesSection.element; | 359 this._objectPresentationElement = this._objectPropertiesSection.element; |
| 360 this._expandController.watchSection(/** @type {string} */ (this._expressio
n), this._objectPropertiesSection); | 360 this._expandController.watchSection(/** @type {string} */ (this._expressio
n), this._objectPropertiesSection); |
| 361 var objectTreeElement = this._objectPropertiesSection.objectTreeElement(); | 361 var objectTreeElement = this._objectPropertiesSection.objectTreeElement(); |
| 362 objectTreeElement.toggleOnClick = false; | 362 objectTreeElement.toggleOnClick = false; |
| 363 objectTreeElement.listItemElement.addEventListener('click', this._onSectio
nClick.bind(this), false); | 363 objectTreeElement.listItemElement.addEventListener('click', this._onSectio
nClick.bind(this), false); |
| 364 objectTreeElement.listItemElement.addEventListener('dblclick', this._dblCl
ickOnWatchExpression.bind(this)); | 364 objectTreeElement.listItemElement.addEventListener('dblclick', this._dblCl
ickOnWatchExpression.bind(this)); |
| 365 } else { | 365 } else { |
| 366 this._objectPresentationElement = headerElement; | 366 this._objectPresentationElement = headerElement; |
| 367 this._objectPresentationElement.addEventListener('dblclick', this._dblClic
kOnWatchExpression.bind(this)); | 367 this._objectPresentationElement.addEventListener('dblclick', this._dblClic
kOnWatchExpression.bind(this)); |
| 368 } | 368 } |
| 369 | 369 |
| 370 this._element.appendChild(this._objectPresentationElement); | 370 this._element.appendChild(this._objectPresentationElement); |
| 371 } | 371 } |
| 372 | 372 |
| 373 /** | 373 /** |
| 374 * @param {!Event} event | 374 * @param {!Event} event |
| 375 */ | 375 */ |
| 376 _onSectionClick(event) { | 376 _onSectionClick(event) { |
| 377 event.consume(true); | 377 event.consume(true); |
| 378 if (event.detail === 1) { | 378 if (event.detail === 1) { |
| 379 this._preventClickTimeout = setTimeout(handleClick.bind(this), 333); | 379 this._preventClickTimeout = setTimeout(handleClick.bind(this), 333); |
| 380 } else { | 380 } else { |
| 381 clearTimeout(this._preventClickTimeout); | 381 clearTimeout(this._preventClickTimeout); |
| 382 delete this._preventClickTimeout; | 382 delete this._preventClickTimeout; |
| 383 } | 383 } |
| 384 | 384 |
| 385 /** | 385 /** |
| 386 * @this {WebInspector.WatchExpression} | 386 * @this {Sources.WatchExpression} |
| 387 */ | 387 */ |
| 388 function handleClick() { | 388 function handleClick() { |
| 389 if (!this._objectPropertiesSection) | 389 if (!this._objectPropertiesSection) |
| 390 return; | 390 return; |
| 391 | 391 |
| 392 var objectTreeElement = this._objectPropertiesSection.objectTreeElement(); | 392 var objectTreeElement = this._objectPropertiesSection.objectTreeElement(); |
| 393 if (objectTreeElement.expanded) | 393 if (objectTreeElement.expanded) |
| 394 objectTreeElement.collapse(); | 394 objectTreeElement.collapse(); |
| 395 else | 395 else |
| 396 objectTreeElement.expand(); | 396 objectTreeElement.expand(); |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 | 399 |
| 400 /** | 400 /** |
| 401 * @param {!Event} event | 401 * @param {!Event} event |
| 402 */ | 402 */ |
| 403 _promptKeyDown(event) { | 403 _promptKeyDown(event) { |
| 404 if (isEnterKey(event) || isEscKey(event)) | 404 if (isEnterKey(event) || isEscKey(event)) |
| 405 this._finishEditing(event, isEscKey(event)); | 405 this._finishEditing(event, isEscKey(event)); |
| 406 } | 406 } |
| 407 | 407 |
| 408 /** | 408 /** |
| 409 * @param {!WebInspector.ContextMenu} contextMenu | 409 * @param {!UI.ContextMenu} contextMenu |
| 410 * @param {!Event} event | 410 * @param {!Event} event |
| 411 */ | 411 */ |
| 412 _populateContextMenu(contextMenu, event) { | 412 _populateContextMenu(contextMenu, event) { |
| 413 if (!this.isEditing()) | 413 if (!this.isEditing()) |
| 414 contextMenu.appendItem( | 414 contextMenu.appendItem( |
| 415 WebInspector.UIString.capitalize('Delete ^watch ^expression'), this._u
pdateExpression.bind(this, null)); | 415 Common.UIString.capitalize('Delete ^watch ^expression'), this._updateE
xpression.bind(this, null)); |
| 416 | 416 |
| 417 if (!this.isEditing() && this._result && (this._result.type === 'number' ||
this._result.type === 'string')) | 417 if (!this.isEditing() && this._result && (this._result.type === 'number' ||
this._result.type === 'string')) |
| 418 contextMenu.appendItem(WebInspector.UIString.capitalize('Copy ^value'), th
is._copyValueButtonClicked.bind(this)); | 418 contextMenu.appendItem(Common.UIString.capitalize('Copy ^value'), this._co
pyValueButtonClicked.bind(this)); |
| 419 | 419 |
| 420 var target = event.deepElementFromPoint(); | 420 var target = event.deepElementFromPoint(); |
| 421 if (target && this._valueElement.isSelfOrAncestor(target)) | 421 if (target && this._valueElement.isSelfOrAncestor(target)) |
| 422 contextMenu.appendApplicableItems(this._result); | 422 contextMenu.appendApplicableItems(this._result); |
| 423 } | 423 } |
| 424 | 424 |
| 425 _copyValueButtonClicked() { | 425 _copyValueButtonClicked() { |
| 426 InspectorFrontendHost.copyText(this._valueElement.textContent); | 426 InspectorFrontendHost.copyText(this._valueElement.textContent); |
| 427 } | 427 } |
| 428 }; | 428 }; |
| 429 | 429 |
| 430 WebInspector.WatchExpression._watchObjectGroupId = 'watch-group'; | 430 Sources.WatchExpression._watchObjectGroupId = 'watch-group'; |
| 431 | 431 |
| 432 /** @enum {symbol} */ | 432 /** @enum {symbol} */ |
| 433 WebInspector.WatchExpression.Events = { | 433 Sources.WatchExpression.Events = { |
| 434 ExpressionUpdated: Symbol('ExpressionUpdated') | 434 ExpressionUpdated: Symbol('ExpressionUpdated') |
| 435 }; | 435 }; |
| OLD | NEW |