Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 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 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 this._filterStatusMessageElement.createTextChild(" "); | 96 this._filterStatusMessageElement.createTextChild(" "); |
| 97 var resetFiltersLink = this._filterStatusMessageElement.createChild("span", "console-info link"); | 97 var resetFiltersLink = this._filterStatusMessageElement.createChild("span", "console-info link"); |
| 98 resetFiltersLink.textContent = WebInspector.UIString("Show all messages."); | 98 resetFiltersLink.textContent = WebInspector.UIString("Show all messages."); |
| 99 resetFiltersLink.addEventListener("click", this._filter.reset.bind(this._fil ter), true); | 99 resetFiltersLink.addEventListener("click", this._filter.reset.bind(this._fil ter), true); |
| 100 | 100 |
| 101 this._topGroup = WebInspector.ConsoleGroup.createTopGroup(); | 101 this._topGroup = WebInspector.ConsoleGroup.createTopGroup(); |
| 102 this._currentGroup = this._topGroup; | 102 this._currentGroup = this._topGroup; |
| 103 | 103 |
| 104 this._promptElement = this._messagesElement.createChild("div", "source-code" ); | 104 this._promptElement = this._messagesElement.createChild("div", "source-code" ); |
| 105 this._promptElement.id = "console-prompt"; | 105 this._promptElement.id = "console-prompt"; |
| 106 this._promptElement.spellcheck = false; | 106 this._promptElement.addEventListener("input", this._promptInput.bind(this), false); |
|
dgozman
2016/09/12 21:38:57
Should we use CodeMirror api instead? Does it inte
einbinder
2016/09/13 01:07:59
CodeMirror promises to let these events fall throu
| |
| 107 | |
| 108 this._searchableView.setDefaultFocusedElement(this._promptElement); | |
| 109 | 107 |
| 110 // FIXME: This is a workaround for the selection machinery bug. See crbug.co m/410899 | 108 // FIXME: This is a workaround for the selection machinery bug. See crbug.co m/410899 |
| 111 var selectAllFixer = this._messagesElement.createChild("div", "console-view- fix-select-all"); | 109 var selectAllFixer = this._messagesElement.createChild("div", "console-view- fix-select-all"); |
| 112 selectAllFixer.textContent = "."; | 110 selectAllFixer.textContent = "."; |
| 113 | 111 |
| 114 this._showAllMessagesCheckbox = new WebInspector.ToolbarCheckbox(WebInspecto r.UIString("Show all messages")); | 112 this._showAllMessagesCheckbox = new WebInspector.ToolbarCheckbox(WebInspecto r.UIString("Show all messages")); |
| 115 this._showAllMessagesCheckbox.inputElement.checked = true; | 113 this._showAllMessagesCheckbox.inputElement.checked = true; |
| 116 this._showAllMessagesCheckbox.inputElement.addEventListener("change", this._ updateMessageList.bind(this), false); | 114 this._showAllMessagesCheckbox.inputElement.addEventListener("change", this._ updateMessageList.bind(this), false); |
| 117 | 115 |
| 118 this._showAllMessagesCheckbox.element.classList.add("hidden"); | 116 this._showAllMessagesCheckbox.element.classList.add("hidden"); |
| 119 | 117 |
| 120 toolbar.appendToolbarItem(this._showAllMessagesCheckbox); | 118 toolbar.appendToolbarItem(this._showAllMessagesCheckbox); |
| 121 | 119 |
| 122 this._registerShortcuts(); | 120 this._registerShortcuts(); |
| 123 | 121 |
| 124 this._messagesElement.addEventListener("contextmenu", this._handleContextMen uEvent.bind(this), false); | 122 this._messagesElement.addEventListener("contextmenu", this._handleContextMen uEvent.bind(this), false); |
| 125 WebInspector.moduleSetting("monitoringXHREnabled").addChangeListener(this._m onitoringXHREnabledSettingChanged, this); | 123 WebInspector.moduleSetting("monitoringXHREnabled").addChangeListener(this._m onitoringXHREnabledSettingChanged, this); |
| 126 | 124 |
| 127 this._linkifier = new WebInspector.Linkifier(); | 125 this._linkifier = new WebInspector.Linkifier(); |
| 128 | 126 |
| 129 /** @type {!Array.<!WebInspector.ConsoleViewMessage>} */ | 127 /** @type {!Array.<!WebInspector.ConsoleViewMessage>} */ |
| 130 this._consoleMessages = []; | 128 this._consoleMessages = []; |
| 131 this._viewMessageSymbol = Symbol("viewMessage"); | 129 this._viewMessageSymbol = Symbol("viewMessage"); |
| 132 | 130 |
| 133 this._prompt = new WebInspector.TextPromptWithHistory(WebInspector.Execution ContextSelector.completionsForTextPromptInCurrentContext); | |
| 134 this._prompt.setSuggestBoxEnabled(true); | |
| 135 this._prompt.setAutocompletionTimeout(0); | |
| 136 this._prompt.renderAsBlock(); | |
| 137 var proxyElement = this._prompt.attach(this._promptElement); | |
| 138 proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this), fal se); | |
| 139 proxyElement.addEventListener("input", this._promptInput.bind(this), false); | |
| 140 | 131 |
| 141 this._consoleHistorySetting = WebInspector.settings.createLocalSetting("cons oleHistory", []); | 132 this._consoleHistorySetting = WebInspector.settings.createLocalSetting("cons oleHistory", []); |
| 142 var historyData = this._consoleHistorySetting.get(); | 133 this._needsFocus = false; |
| 143 this._prompt.history().setHistoryData(historyData); | 134 |
| 135 WebInspector.ConsolePrompt.create().then(promptCreated.bind(this)); | |
| 136 | |
| 137 /** | |
| 138 * @this {WebInspector.ConsoleView} | |
| 139 * @param {!WebInspector.ConsolePrompt} prompt | |
| 140 */ | |
| 141 function promptCreated(prompt) | |
|
dgozman
2016/09/12 21:38:57
I'd rather move asynchronicity to ConsolePrompt it
einbinder
2016/09/13 01:07:59
Done.
| |
| 142 { | |
| 143 this._prompt = prompt; | |
| 144 this._prompt.attach(this._promptElement); | |
| 145 this._prompt.addKeyDownHandler(this._promptKeyDown.bind(this)); | |
| 146 this._searchableView.setDefaultFocusedElement(this._prompt.element); | |
| 147 | |
| 148 var historyData = this._consoleHistorySetting.get(); | |
| 149 this._prompt.history().setHistoryData(historyData); | |
| 150 this._consoleHistoryAutocompleteChanged(); | |
| 151 if (this._needsFocus) | |
| 152 this.focus(); | |
| 153 } | |
| 144 | 154 |
| 145 this._consoleHistoryAutocompleteSetting = WebInspector.moduleSetting("consol eHistoryAutocomplete"); | 155 this._consoleHistoryAutocompleteSetting = WebInspector.moduleSetting("consol eHistoryAutocomplete"); |
| 146 this._consoleHistoryAutocompleteSetting.addChangeListener(this._consoleHisto ryAutocompleteChanged, this); | 156 this._consoleHistoryAutocompleteSetting.addChangeListener(this._consoleHisto ryAutocompleteChanged, this); |
| 147 this._consoleHistoryAutocompleteChanged(); | |
| 148 | 157 |
| 149 this._updateFilterStatus(); | 158 this._updateFilterStatus(); |
| 150 WebInspector.moduleSetting("consoleTimestampsEnabled").addChangeListener(thi s._consoleTimestampsSettingChanged, this); | 159 WebInspector.moduleSetting("consoleTimestampsEnabled").addChangeListener(thi s._consoleTimestampsSettingChanged, this); |
| 151 | 160 |
| 152 this._registerWithMessageSink(); | 161 this._registerWithMessageSink(); |
| 153 WebInspector.targetManager.observeTargets(this); | 162 WebInspector.targetManager.observeTargets(this); |
| 154 | 163 |
| 155 this._initConsoleMessages(); | 164 this._initConsoleMessages(); |
| 156 | 165 |
| 157 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executionContextChanged, this); | 166 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executionContextChanged, this); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 169 * @return {!WebInspector.SearchableView} | 178 * @return {!WebInspector.SearchableView} |
| 170 */ | 179 */ |
| 171 searchableView: function() | 180 searchableView: function() |
| 172 { | 181 { |
| 173 return this._searchableView; | 182 return this._searchableView; |
| 174 }, | 183 }, |
| 175 | 184 |
| 176 _clearHistory: function() | 185 _clearHistory: function() |
| 177 { | 186 { |
| 178 this._consoleHistorySetting.set([]); | 187 this._consoleHistorySetting.set([]); |
| 179 this._prompt.history().setHistoryData([]); | 188 if (this._prompt) |
| 189 this._prompt.history().setHistoryData([]); | |
| 180 }, | 190 }, |
| 181 | 191 |
| 182 _consoleHistoryAutocompleteChanged: function() | 192 _consoleHistoryAutocompleteChanged: function() |
| 183 { | 193 { |
| 184 this._prompt.setAddCompletionsFromHistory(this._consoleHistoryAutocomple teSetting.get()); | 194 if (this._prompt) |
|
dgozman
2016/09/12 21:38:57
Could this even happen without a prompt? What abou
einbinder
2016/09/13 01:07:59
Removed.
| |
| 195 this._prompt.setAddCompletionsFromHistory(this._consoleHistoryAutoco mpleteSetting.get()); | |
| 185 }, | 196 }, |
| 186 | 197 |
| 187 _initConsoleMessages: function() | 198 _initConsoleMessages: function() |
| 188 { | 199 { |
| 189 var mainTarget = WebInspector.targetManager.mainTarget(); | 200 var mainTarget = WebInspector.targetManager.mainTarget(); |
| 190 var resourceTreeModel = mainTarget && WebInspector.ResourceTreeModel.fro mTarget(mainTarget); | 201 var resourceTreeModel = mainTarget && WebInspector.ResourceTreeModel.fro mTarget(mainTarget); |
| 191 var resourcesLoaded = !resourceTreeModel || resourceTreeModel.cachedReso urcesLoaded(); | 202 var resourcesLoaded = !resourceTreeModel || resourceTreeModel.cachedReso urcesLoaded(); |
| 192 if (!mainTarget || !resourcesLoaded) { | 203 if (!mainTarget || !resourcesLoaded) { |
| 193 WebInspector.targetManager.addModelListener(WebInspector.ResourceTre eModel, WebInspector.ResourceTreeModel.Events.CachedResourcesLoaded, this._onRes ourceTreeModelLoaded, this); | 204 WebInspector.targetManager.addModelListener(WebInspector.ResourceTre eModel, WebInspector.ResourceTreeModel.Events.CachedResourcesLoaded, this._onRes ourceTreeModelLoaded, this); |
| 194 return; | 205 return; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 208 this._fetchMultitargetMessages(); | 219 this._fetchMultitargetMessages(); |
| 209 }, | 220 }, |
| 210 | 221 |
| 211 _fetchMultitargetMessages: function() | 222 _fetchMultitargetMessages: function() |
| 212 { | 223 { |
| 213 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso leModel.Events.ConsoleCleared, this._consoleCleared, this); | 224 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso leModel.Events.ConsoleCleared, this._consoleCleared, this); |
| 214 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso leModel.Events.MessageAdded, this._onConsoleMessageAdded, this); | 225 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso leModel.Events.MessageAdded, this._onConsoleMessageAdded, this); |
| 215 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso leModel.Events.MessageUpdated, this._onConsoleMessageUpdated, this); | 226 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso leModel.Events.MessageUpdated, this._onConsoleMessageUpdated, this); |
| 216 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso leModel.Events.CommandEvaluated, this._commandEvaluated, this); | 227 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso leModel.Events.CommandEvaluated, this._commandEvaluated, this); |
| 217 WebInspector.multitargetConsoleModel.messages().forEach(this._addConsole Message, this); | 228 WebInspector.multitargetConsoleModel.messages().forEach(this._addConsole Message, this); |
| 229 this._viewport.invalidate(); | |
| 218 }, | 230 }, |
| 219 | 231 |
| 220 /** | 232 /** |
| 221 * @override | 233 * @override |
| 222 * @return {number} | 234 * @return {number} |
| 223 */ | 235 */ |
| 224 itemCount: function() | 236 itemCount: function() |
| 225 { | 237 { |
| 226 return this._visibleViewMessages.length; | 238 return this._visibleViewMessages.length; |
| 227 }, | 239 }, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 { | 328 { |
| 317 var enabled = /** @type {boolean} */ (event.data); | 329 var enabled = /** @type {boolean} */ (event.data); |
| 318 this._updateMessageList(); | 330 this._updateMessageList(); |
| 319 this._consoleMessages.forEach(function(viewMessage) { | 331 this._consoleMessages.forEach(function(viewMessage) { |
| 320 viewMessage.updateTimestamp(enabled); | 332 viewMessage.updateTimestamp(enabled); |
| 321 }); | 333 }); |
| 322 }, | 334 }, |
| 323 | 335 |
| 324 _executionContextChanged: function() | 336 _executionContextChanged: function() |
| 325 { | 337 { |
| 326 this._prompt.clearAutoComplete(); | 338 if (this._prompt) |
| 339 this._prompt.clearAutoComplete(); | |
| 327 if (!this._showAllMessagesCheckbox.checked()) | 340 if (!this._showAllMessagesCheckbox.checked()) |
| 328 this._updateMessageList(); | 341 this._updateMessageList(); |
| 329 }, | 342 }, |
| 330 | 343 |
| 331 willHide: function() | 344 willHide: function() |
| 332 { | 345 { |
| 333 this._hidePromptSuggestBox(); | 346 this._hidePromptSuggestBox(); |
| 334 }, | 347 }, |
| 335 | 348 |
| 336 wasShown: function() | 349 wasShown: function() |
| 337 { | 350 { |
| 338 this._viewport.refresh(); | 351 this._viewport.refresh(); |
| 339 if (!this._prompt.isCaretInsidePrompt()) | 352 this.focus(); |
| 340 this._prompt.moveCaretToEndOfPrompt(); | |
| 341 }, | 353 }, |
| 342 | 354 |
| 343 focus: function() | 355 focus: function() |
| 344 { | 356 { |
| 345 if (this._promptElement === WebInspector.currentFocusElement()) | 357 if (!this._prompt){ |
| 358 this._needsFocus = true; | |
| 359 return; | |
| 360 } | |
| 361 if (this._prompt.hasFocus()) | |
| 346 return; | 362 return; |
| 347 // Set caret position before setting focus in order to avoid scrolling | 363 // Set caret position before setting focus in order to avoid scrolling |
| 348 // by focus(). | 364 // by focus(). |
| 349 this._prompt.moveCaretToEndOfPrompt(); | 365 this._prompt.moveCaretToEndOfPrompt(); |
| 350 WebInspector.setCurrentFocusElement(this._promptElement); | 366 this._prompt.focus(); |
| 367 this._needsFocus = false; | |
| 351 }, | 368 }, |
| 352 | 369 |
| 353 restoreScrollPositions: function() | 370 restoreScrollPositions: function() |
| 354 { | 371 { |
| 355 if (this._viewport.stickToBottom()) | 372 if (this._viewport.stickToBottom()) |
| 356 this._immediatelyScrollToBottom(); | 373 this._immediatelyScrollToBottom(); |
| 357 else | 374 else |
| 358 WebInspector.Widget.prototype.restoreScrollPositions.call(this); | 375 WebInspector.Widget.prototype.restoreScrollPositions.call(this); |
| 359 }, | 376 }, |
| 360 | 377 |
| 361 onResize: function() | 378 onResize: function() |
| 362 { | 379 { |
| 363 this._scheduleViewportRefresh(); | 380 this._scheduleViewportRefresh(); |
| 364 this._hidePromptSuggestBox(); | 381 this._hidePromptSuggestBox(); |
| 365 if (this._viewport.stickToBottom()) | 382 if (this._viewport.stickToBottom()) |
| 366 this._immediatelyScrollToBottom(); | 383 this._immediatelyScrollToBottom(); |
| 367 for (var i = 0; i < this._visibleViewMessages.length; ++i) | 384 for (var i = 0; i < this._visibleViewMessages.length; ++i) |
| 368 this._visibleViewMessages[i].onResize(); | 385 this._visibleViewMessages[i].onResize(); |
| 369 }, | 386 }, |
| 370 | 387 |
| 371 _hidePromptSuggestBox: function() | 388 _hidePromptSuggestBox: function() |
| 372 { | 389 { |
| 373 this._prompt.clearAutoComplete(); | 390 if (this._prompt) |
| 391 this._prompt.clearAutoComplete(); | |
| 374 }, | 392 }, |
| 375 | 393 |
| 376 _scheduleViewportRefresh: function() | 394 _scheduleViewportRefresh: function() |
| 377 { | 395 { |
| 378 /** | 396 /** |
| 379 * @this {WebInspector.ConsoleView} | 397 * @this {WebInspector.ConsoleView} |
| 380 * @return {!Promise.<undefined>} | 398 * @return {!Promise.<undefined>} |
| 381 */ | 399 */ |
| 382 function invalidateViewport() | 400 function invalidateViewport() |
| 383 { | 401 { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 return new WebInspector.ConsoleViewMessage(message, this._linkifier, nestingLevel); | 568 return new WebInspector.ConsoleViewMessage(message, this._linkifier, nestingLevel); |
| 551 } | 569 } |
| 552 }, | 570 }, |
| 553 | 571 |
| 554 _consoleCleared: function() | 572 _consoleCleared: function() |
| 555 { | 573 { |
| 556 this._currentMatchRangeIndex = -1; | 574 this._currentMatchRangeIndex = -1; |
| 557 this._consoleMessages = []; | 575 this._consoleMessages = []; |
| 558 this._updateMessageList(); | 576 this._updateMessageList(); |
| 559 this._hidePromptSuggestBox(); | 577 this._hidePromptSuggestBox(); |
| 578 this._viewport.setStickToBottom(true); | |
|
dgozman
2016/09/12 21:38:57
Nice catch!
| |
| 560 this._linkifier.reset(); | 579 this._linkifier.reset(); |
| 561 }, | 580 }, |
| 562 | 581 |
| 563 _handleContextMenuEvent: function(event) | 582 _handleContextMenuEvent: function(event) |
| 564 { | 583 { |
| 565 if (event.target.enclosingNodeOrSelfWithNodeName("a")) | 584 if (event.target.enclosingNodeOrSelfWithNodeName("a")) |
| 566 return; | 585 return; |
| 567 | 586 |
| 568 var contextMenu = new WebInspector.ContextMenu(event); | 587 var contextMenu = new WebInspector.ContextMenu(event); |
| 569 if (event.target.isSelfOrDescendant(this._promptElement)) { | 588 if (event.target.isSelfOrDescendant(this._promptElement)) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 var enabled = /** @type {boolean} */ (event.data); | 728 var enabled = /** @type {boolean} */ (event.data); |
| 710 WebInspector.targetManager.targets().forEach(function(target) {target.ne tworkAgent().setMonitoringXHREnabled(enabled);}); | 729 WebInspector.targetManager.targets().forEach(function(target) {target.ne tworkAgent().setMonitoringXHREnabled(enabled);}); |
| 711 }, | 730 }, |
| 712 | 731 |
| 713 /** | 732 /** |
| 714 * @param {!Event} event | 733 * @param {!Event} event |
| 715 */ | 734 */ |
| 716 _messagesClicked: function(event) | 735 _messagesClicked: function(event) |
| 717 { | 736 { |
| 718 var targetElement = event.deepElementFromPoint(); | 737 var targetElement = event.deepElementFromPoint(); |
| 719 if (!this._prompt.isCaretInsidePrompt() && (!targetElement || targetElem ent.isComponentSelectionCollapsed())) | 738 if (!targetElement || targetElement.isComponentSelectionCollapsed()) |
| 720 this._prompt.moveCaretToEndOfPrompt(); | 739 this.focus(); |
| 721 var groupMessage = event.target.enclosingNodeOrSelfWithClass("console-gr oup-title"); | 740 var groupMessage = event.target.enclosingNodeOrSelfWithClass("console-gr oup-title"); |
| 722 if (!groupMessage) | 741 if (!groupMessage) |
| 723 return; | 742 return; |
| 724 var consoleGroupViewMessage = groupMessage.parentElement.message; | 743 var consoleGroupViewMessage = groupMessage.parentElement.message; |
| 725 consoleGroupViewMessage.setCollapsed(!consoleGroupViewMessage.collapsed( )); | 744 consoleGroupViewMessage.setCollapsed(!consoleGroupViewMessage.collapsed( )); |
| 726 this._updateMessageList(); | 745 this._updateMessageList(); |
| 727 }, | 746 }, |
| 728 | 747 |
| 729 _registerShortcuts: function() | 748 _registerShortcuts: function() |
| 730 { | 749 { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 760 shortcut.makeDescriptor("P", shortcut.Modifiers.Alt) | 779 shortcut.makeDescriptor("P", shortcut.Modifiers.Alt) |
| 761 ]; | 780 ]; |
| 762 section.addRelatedKeys(keys, WebInspector.UIString("Next/previous co mmand")); | 781 section.addRelatedKeys(keys, WebInspector.UIString("Next/previous co mmand")); |
| 763 } | 782 } |
| 764 | 783 |
| 765 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Enter), WebInspecto r.UIString("Execute command")); | 784 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Enter), WebInspecto r.UIString("Execute command")); |
| 766 }, | 785 }, |
| 767 | 786 |
| 768 _clearPromptBackwards: function() | 787 _clearPromptBackwards: function() |
| 769 { | 788 { |
| 770 this._prompt.setText(""); | 789 if (this._prompt) |
| 790 this._prompt.setText(""); | |
| 771 }, | 791 }, |
| 772 | 792 |
| 793 /** | |
| 794 * @param {!KeyboardEvent} event | |
| 795 */ | |
| 773 _promptKeyDown: function(event) | 796 _promptKeyDown: function(event) |
| 774 { | 797 { |
| 775 if (event.key === "PageUp") { | 798 if (event.key === "PageUp") { |
| 776 this._updateStickToBottomOnWheel(); | 799 this._updateStickToBottomOnWheel(); |
| 777 return; | 800 return; |
| 778 } else if (isEnterKey(event)) { | 801 } else if (isEnterKey(event)) { |
| 779 this._enterKeyPressed(event); | 802 this._enterKeyPressed(event); |
| 780 return; | 803 return; |
| 781 } | 804 } |
| 782 | 805 |
| 783 var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); | 806 var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); |
| 784 var handler = this._shortcuts[shortcut]; | 807 var handler = this._shortcuts[shortcut]; |
| 785 if (handler) { | 808 if (handler) { |
| 786 handler(); | 809 handler(); |
| 787 event.preventDefault(); | 810 event.preventDefault(); |
| 788 } | 811 } |
| 789 }, | 812 }, |
| 790 | 813 |
| 791 _enterKeyPressed: function(event) | 814 _enterKeyPressed: function(event) |
| 792 { | 815 { |
| 793 if (event.altKey || event.ctrlKey || event.shiftKey) | 816 if (!this._prompt || event.altKey || event.ctrlKey || event.shiftKey || !this._prompt.hasFocus()) |
| 794 return; | 817 return; |
| 795 | 818 |
| 796 event.consume(true); | 819 event.consume(true); |
| 797 | 820 |
| 798 this._prompt.clearAutoComplete(); | 821 this._prompt.clearAutoComplete(); |
| 799 | 822 |
| 800 var str = this._prompt.text(); | 823 var str = this._prompt.text(); |
| 801 if (!str.length) | 824 if (!str.length) |
| 802 return; | 825 return; |
| 803 this._appendCommand(str, true); | 826 this._appendCommand(str, true); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 822 message.setOriginatingMessage(originatingConsoleMessage); | 845 message.setOriginatingMessage(originatingConsoleMessage); |
| 823 result.target().consoleModel.addMessage(message); | 846 result.target().consoleModel.addMessage(message); |
| 824 }, | 847 }, |
| 825 | 848 |
| 826 /** | 849 /** |
| 827 * @param {string} text | 850 * @param {string} text |
| 828 * @param {boolean} useCommandLineAPI | 851 * @param {boolean} useCommandLineAPI |
| 829 */ | 852 */ |
| 830 _appendCommand: function(text, useCommandLineAPI) | 853 _appendCommand: function(text, useCommandLineAPI) |
| 831 { | 854 { |
| 832 this._prompt.setText(""); | 855 if (this._prompt) |
| 856 this._prompt.setText(""); | |
| 833 var currentExecutionContext = WebInspector.context.flavor(WebInspector.E xecutionContext); | 857 var currentExecutionContext = WebInspector.context.flavor(WebInspector.E xecutionContext); |
| 834 if (currentExecutionContext) { | 858 if (currentExecutionContext) { |
| 835 WebInspector.ConsoleModel.evaluateCommandInConsole(currentExecutionC ontext, text, useCommandLineAPI); | 859 WebInspector.ConsoleModel.evaluateCommandInConsole(currentExecutionC ontext, text, useCommandLineAPI); |
| 836 if (WebInspector.inspectorView.currentPanel() && WebInspector.inspec torView.currentPanel().name === "console") | 860 if (WebInspector.inspectorView.currentPanel() && WebInspector.inspec torView.currentPanel().name === "console") |
| 837 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Ac tion.CommandEvaluatedInConsolePanel); | 861 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Ac tion.CommandEvaluatedInConsolePanel); |
| 838 } | 862 } |
| 839 }, | 863 }, |
| 840 | 864 |
| 841 /** | 865 /** |
| 842 * @param {!WebInspector.Event} event | 866 * @param {!WebInspector.Event} event |
| 843 */ | 867 */ |
| 844 _commandEvaluated: function(event) | 868 _commandEvaluated: function(event) |
| 845 { | 869 { |
| 870 if (!this._prompt) | |
| 871 return; | |
| 846 var data = /** @type {{result: ?WebInspector.RemoteObject, text: string, commandMessage: !WebInspector.ConsoleMessage, exceptionDetails: (!RuntimeAgent. ExceptionDetails|undefined)}} */ (event.data); | 872 var data = /** @type {{result: ?WebInspector.RemoteObject, text: string, commandMessage: !WebInspector.ConsoleMessage, exceptionDetails: (!RuntimeAgent. ExceptionDetails|undefined)}} */ (event.data); |
| 847 this._prompt.history().pushHistoryItem(data.text); | 873 this._prompt.history().pushHistoryItem(data.text); |
| 848 this._consoleHistorySetting.set(this._prompt.history().historyData().sli ce(-WebInspector.ConsoleView.persistedHistorySize)); | 874 this._consoleHistorySetting.set(this._prompt.history().historyData().sli ce(-WebInspector.ConsoleView.persistedHistorySize)); |
| 849 this._printResult(data.result, data.commandMessage, data.exceptionDetail s); | 875 this._printResult(data.result, data.commandMessage, data.exceptionDetail s); |
| 850 }, | 876 }, |
| 851 | 877 |
| 852 /** | 878 /** |
| 853 * @override | 879 * @override |
| 854 * @return {!Array.<!Element>} | 880 * @return {!Array.<!Element>} |
| 855 */ | 881 */ |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1415 return true; | 1441 return true; |
| 1416 } | 1442 } |
| 1417 return false; | 1443 return false; |
| 1418 } | 1444 } |
| 1419 } | 1445 } |
| 1420 | 1446 |
| 1421 /** | 1447 /** |
| 1422 * @typedef {{messageIndex: number, matchIndex: number}} | 1448 * @typedef {{messageIndex: number, matchIndex: number}} |
| 1423 */ | 1449 */ |
| 1424 WebInspector.ConsoleView.RegexMatchRange; | 1450 WebInspector.ConsoleView.RegexMatchRange; |
| OLD | NEW |