| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 /** @type {!Array.<!WebInspector.ConsoleViewMessage>} */ | 129 /** @type {!Array.<!WebInspector.ConsoleViewMessage>} */ |
| 130 this._consoleMessages = []; | 130 this._consoleMessages = []; |
| 131 this._viewMessageSymbol = Symbol("viewMessage"); | 131 this._viewMessageSymbol = Symbol("viewMessage"); |
| 132 | 132 |
| 133 this._prompt = new WebInspector.TextPromptWithHistory(WebInspector.Execution
ContextSelector.completionsForTextPromptInCurrentContext); | 133 this._prompt = new WebInspector.TextPromptWithHistory(WebInspector.Execution
ContextSelector.completionsForTextPromptInCurrentContext); |
| 134 this._prompt.setSuggestBoxEnabled(true); | 134 this._prompt.setSuggestBoxEnabled(true); |
| 135 this._prompt.setAutocompletionTimeout(0); | 135 this._prompt.setAutocompletionTimeout(0); |
| 136 this._prompt.renderAsBlock(); | 136 this._prompt.renderAsBlock(); |
| 137 var proxyElement = this._prompt.attach(this._promptElement); | 137 var proxyElement = this._prompt.attach(this._promptElement); |
| 138 proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this), fal
se); | 138 proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this), fal
se); |
| 139 proxyElement.addEventListener("input", this._promptInput.bind(this), false); | |
| 140 | 139 |
| 141 this._consoleHistorySetting = WebInspector.settings.createLocalSetting("cons
oleHistory", []); | 140 this._consoleHistorySetting = WebInspector.settings.createLocalSetting("cons
oleHistory", []); |
| 142 var historyData = this._consoleHistorySetting.get(); | 141 var historyData = this._consoleHistorySetting.get(); |
| 143 this._prompt.history().setHistoryData(historyData); | 142 this._prompt.history().setHistoryData(historyData); |
| 144 | 143 |
| 145 this._consoleHistoryAutocompleteSetting = WebInspector.moduleSetting("consol
eHistoryAutocomplete"); | 144 this._consoleHistoryAutocompleteSetting = WebInspector.moduleSetting("consol
eHistoryAutocomplete"); |
| 146 this._consoleHistoryAutocompleteSetting.addChangeListener(this._consoleHisto
ryAutocompleteChanged, this); | 145 this._consoleHistoryAutocompleteSetting.addChangeListener(this._consoleHisto
ryAutocompleteChanged, this); |
| 147 this._consoleHistoryAutocompleteChanged(); | 146 this._consoleHistoryAutocompleteChanged(); |
| 148 | 147 |
| 149 this._updateFilterStatus(); | 148 this._updateFilterStatus(); |
| 150 WebInspector.moduleSetting("consoleTimestampsEnabled").addChangeListener(thi
s._consoleTimestampsSettingChanged, this); | 149 WebInspector.moduleSetting("consoleTimestampsEnabled").addChangeListener(thi
s._consoleTimestampsSettingChanged, this); |
| 151 | 150 |
| 152 this._registerWithMessageSink(); | 151 this._registerWithMessageSink(); |
| 153 WebInspector.targetManager.observeTargets(this); | 152 WebInspector.targetManager.observeTargets(this); |
| 154 | 153 |
| 155 this._initConsoleMessages(); | 154 this._initConsoleMessages(); |
| 156 | 155 |
| 157 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext,
this._executionContextChanged, this); | 156 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext,
this._executionContextChanged, this); |
| 158 | |
| 159 this._messagesElement.addEventListener("mousedown", this._updateStickToBotto
mOnMouseDown.bind(this), false); | |
| 160 this._messagesElement.addEventListener("mouseup", this._updateStickToBottomO
nMouseUp.bind(this), false); | |
| 161 this._messagesElement.addEventListener("mouseleave", this._updateStickToBott
omOnMouseUp.bind(this), false); | |
| 162 this._messagesElement.addEventListener("wheel", this._updateStickToBottomOnW
heel.bind(this), false); | |
| 163 } | 157 } |
| 164 | 158 |
| 165 WebInspector.ConsoleView.persistedHistorySize = 300; | 159 WebInspector.ConsoleView.persistedHistorySize = 300; |
| 166 | 160 |
| 167 WebInspector.ConsoleView.prototype = { | 161 WebInspector.ConsoleView.prototype = { |
| 168 /** | 162 /** |
| 169 * @return {!WebInspector.SearchableView} | 163 * @return {!WebInspector.SearchableView} |
| 170 */ | 164 */ |
| 171 searchableView: function() | 165 searchableView: function() |
| 172 { | 166 { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 if (this._promptElement === WebInspector.currentFocusElement()) | 337 if (this._promptElement === WebInspector.currentFocusElement()) |
| 344 return; | 338 return; |
| 345 // Set caret position before setting focus in order to avoid scrolling | 339 // Set caret position before setting focus in order to avoid scrolling |
| 346 // by focus(). | 340 // by focus(). |
| 347 this._prompt.moveCaretToEndOfPrompt(); | 341 this._prompt.moveCaretToEndOfPrompt(); |
| 348 WebInspector.setCurrentFocusElement(this._promptElement); | 342 WebInspector.setCurrentFocusElement(this._promptElement); |
| 349 }, | 343 }, |
| 350 | 344 |
| 351 restoreScrollPositions: function() | 345 restoreScrollPositions: function() |
| 352 { | 346 { |
| 353 if (this._viewport.stickToBottom()) | 347 if (this._viewport.scrolledToBottom()) |
| 354 this._immediatelyScrollToBottom(); | 348 this._immediatelyScrollToBottom(); |
| 355 else | 349 else |
| 356 WebInspector.Widget.prototype.restoreScrollPositions.call(this); | 350 WebInspector.Widget.prototype.restoreScrollPositions.call(this); |
| 357 }, | 351 }, |
| 358 | 352 |
| 359 onResize: function() | 353 onResize: function() |
| 360 { | 354 { |
| 361 this._scheduleViewportRefresh(); | 355 this._scheduleViewportRefresh(); |
| 362 this._hidePromptSuggestBox(); | 356 this._hidePromptSuggestBox(); |
| 363 if (this._viewport.stickToBottom()) | 357 if (this._viewport.scrolledToBottom()) |
| 364 this._immediatelyScrollToBottom(); | 358 this._immediatelyScrollToBottom(); |
| 365 for (var i = 0; i < this._visibleViewMessages.length; ++i) | 359 for (var i = 0; i < this._visibleViewMessages.length; ++i) |
| 366 this._visibleViewMessages[i].onResize(); | 360 this._visibleViewMessages[i].onResize(); |
| 367 }, | 361 }, |
| 368 | 362 |
| 369 _hidePromptSuggestBox: function() | 363 _hidePromptSuggestBox: function() |
| 370 { | 364 { |
| 371 this._prompt.hideSuggestBox(); | 365 this._prompt.hideSuggestBox(); |
| 372 this._prompt.clearAutoComplete(true); | 366 this._prompt.clearAutoComplete(true); |
| 373 }, | 367 }, |
| 374 | 368 |
| 375 _scheduleViewportRefresh: function() | 369 _scheduleViewportRefresh: function() |
| 376 { | 370 { |
| 377 /** | 371 /** |
| 378 * @this {WebInspector.ConsoleView} | 372 * @this {WebInspector.ConsoleView} |
| 379 * @return {!Promise.<undefined>} | 373 * @return {!Promise.<undefined>} |
| 380 */ | 374 */ |
| 381 function invalidateViewport() | 375 function invalidateViewport() |
| 382 { | 376 { |
| 383 if (this._muteViewportUpdates) { | |
| 384 this._maybeDirtyWhileMuted = true; | |
| 385 return Promise.resolve(); | |
| 386 } | |
| 387 if (this._needsFullUpdate) { | 377 if (this._needsFullUpdate) { |
| 388 this._updateMessageList(); | 378 this._updateMessageList(); |
| 389 delete this._needsFullUpdate; | 379 delete this._needsFullUpdate; |
| 390 } else { | 380 } else { |
| 391 this._viewport.invalidate(); | 381 this._viewport.invalidate(); |
| 392 } | 382 } |
| 393 return Promise.resolve(); | 383 return Promise.resolve(); |
| 394 } | 384 } |
| 395 if (this._muteViewportUpdates) { | |
| 396 this._maybeDirtyWhileMuted = true; | |
| 397 this._scheduleViewportRefreshForTest(true); | |
| 398 return; | |
| 399 } else { | |
| 400 this._scheduleViewportRefreshForTest(false); | |
| 401 } | |
| 402 this._viewportThrottler.schedule(invalidateViewport.bind(this)); | 385 this._viewportThrottler.schedule(invalidateViewport.bind(this)); |
| 403 }, | 386 }, |
| 404 | 387 |
| 405 /** | |
| 406 * @param {boolean} muted | |
| 407 */ | |
| 408 _scheduleViewportRefreshForTest: function(muted) | |
| 409 { | |
| 410 // This functions is sniffed in tests. | |
| 411 }, | |
| 412 | |
| 413 _immediatelyScrollToBottom: function() | 388 _immediatelyScrollToBottom: function() |
| 414 { | 389 { |
| 415 // This will scroll viewport and trigger its refresh. | 390 // This will scroll viewport and trigger its refresh. |
| 416 this._viewport.setStickToBottom(true); | |
| 417 this._promptElement.scrollIntoView(true); | 391 this._promptElement.scrollIntoView(true); |
| 418 }, | 392 }, |
| 419 | 393 |
| 420 _updateFilterStatus: function() | 394 _updateFilterStatus: function() |
| 421 { | 395 { |
| 422 this._filterStatusTextElement.textContent = WebInspector.UIString(this._
hiddenByFilterCount === 1 ? "%d message is hidden by filters." : "%d messages ar
e hidden by filters.", this._hiddenByFilterCount); | 396 this._filterStatusTextElement.textContent = WebInspector.UIString(this._
hiddenByFilterCount === 1 ? "%d message is hidden by filters." : "%d messages ar
e hidden by filters.", this._hiddenByFilterCount); |
| 423 this._filterStatusMessageElement.style.display = this._hiddenByFilterCou
nt ? "" : "none"; | 397 this._filterStatusMessageElement.style.display = this._hiddenByFilterCou
nt ? "" : "none"; |
| 424 }, | 398 }, |
| 425 | 399 |
| 426 /** | 400 /** |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Enter), WebInspecto
r.UIString("Execute command")); | 737 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Enter), WebInspecto
r.UIString("Execute command")); |
| 764 }, | 738 }, |
| 765 | 739 |
| 766 _clearPromptBackwards: function() | 740 _clearPromptBackwards: function() |
| 767 { | 741 { |
| 768 this._prompt.setText(""); | 742 this._prompt.setText(""); |
| 769 }, | 743 }, |
| 770 | 744 |
| 771 _promptKeyDown: function(event) | 745 _promptKeyDown: function(event) |
| 772 { | 746 { |
| 773 this._updateStickToBottomOnWheel(); | |
| 774 if (isEnterKey(event)) { | 747 if (isEnterKey(event)) { |
| 775 this._enterKeyPressed(event); | 748 this._enterKeyPressed(event); |
| 776 return; | 749 return; |
| 777 } | 750 } |
| 778 | 751 |
| 779 var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); | 752 var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); |
| 780 var handler = this._shortcuts[shortcut]; | 753 var handler = this._shortcuts[shortcut]; |
| 781 if (handler) { | 754 if (handler) { |
| 782 handler(); | 755 handler(); |
| 783 event.preventDefault(); | 756 event.preventDefault(); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 this._currentMatchRangeIndex = index; | 988 this._currentMatchRangeIndex = index; |
| 1016 this._searchableView.updateCurrentMatchIndex(index); | 989 this._searchableView.updateCurrentMatchIndex(index); |
| 1017 matchRange = this._regexMatchRanges[index]; | 990 matchRange = this._regexMatchRanges[index]; |
| 1018 var message = this._visibleViewMessages[matchRange.messageIndex]; | 991 var message = this._visibleViewMessages[matchRange.messageIndex]; |
| 1019 var highlightNode = message.searchHighlightNode(matchRange.matchIndex); | 992 var highlightNode = message.searchHighlightNode(matchRange.matchIndex); |
| 1020 highlightNode.classList.add(WebInspector.highlightedCurrentSearchResultC
lassName); | 993 highlightNode.classList.add(WebInspector.highlightedCurrentSearchResultC
lassName); |
| 1021 this._viewport.scrollItemIntoView(matchRange.messageIndex); | 994 this._viewport.scrollItemIntoView(matchRange.messageIndex); |
| 1022 highlightNode.scrollIntoViewIfNeeded(); | 995 highlightNode.scrollIntoViewIfNeeded(); |
| 1023 }, | 996 }, |
| 1024 | 997 |
| 1025 _updateStickToBottomOnMouseDown: function() | |
| 1026 { | |
| 1027 this._muteViewportUpdates = true; | |
| 1028 this._viewport.setStickToBottom(false); | |
| 1029 if (this._waitForScrollTimeout) { | |
| 1030 clearTimeout(this._waitForScrollTimeout); | |
| 1031 delete this._waitForScrollTimeout; | |
| 1032 } | |
| 1033 }, | |
| 1034 | |
| 1035 _updateStickToBottomOnMouseUp: function() | |
| 1036 { | |
| 1037 if (!this._muteViewportUpdates) | |
| 1038 return; | |
| 1039 | |
| 1040 // Delay querying isScrolledToBottom to give time for smooth scroll | |
| 1041 // events to arrive. The value for the longest timeout duration is | |
| 1042 // retrieved from crbug.com/575409. | |
| 1043 this._waitForScrollTimeout = setTimeout(updateViewportState.bind(this),
200); | |
| 1044 | |
| 1045 /** | |
| 1046 * @this {!WebInspector.ConsoleView} | |
| 1047 */ | |
| 1048 function updateViewportState() | |
| 1049 { | |
| 1050 this._muteViewportUpdates = false; | |
| 1051 this._viewport.setStickToBottom(this._messagesElement.isScrolledToBo
ttom()); | |
| 1052 if (this._maybeDirtyWhileMuted) { | |
| 1053 this._scheduleViewportRefresh(); | |
| 1054 delete this._maybeDirtyWhileMuted; | |
| 1055 } | |
| 1056 delete this._waitForScrollTimeout; | |
| 1057 this._updateViewportStickinessForTest(); | |
| 1058 } | |
| 1059 }, | |
| 1060 | |
| 1061 _updateViewportStickinessForTest: function() | |
| 1062 { | |
| 1063 // This method is sniffed in tests. | |
| 1064 }, | |
| 1065 | |
| 1066 _updateStickToBottomOnWheel: function() | |
| 1067 { | |
| 1068 this._updateStickToBottomOnMouseDown(); | |
| 1069 this._updateStickToBottomOnMouseUp(); | |
| 1070 }, | |
| 1071 | |
| 1072 _promptInput: function(event) | |
| 1073 { | |
| 1074 // Scroll to the bottom, except when the prompt is the only visible item
. | |
| 1075 if (this.itemCount() !== 0 && this._viewport.firstVisibleIndex() !== thi
s.itemCount()) | |
| 1076 this._immediatelyScrollToBottom(); | |
| 1077 }, | |
| 1078 | |
| 1079 __proto__: WebInspector.VBox.prototype | 998 __proto__: WebInspector.VBox.prototype |
| 1080 } | 999 } |
| 1081 | 1000 |
| 1082 /** | 1001 /** |
| 1083 * @constructor | 1002 * @constructor |
| 1084 * @extends {WebInspector.Object} | 1003 * @extends {WebInspector.Object} |
| 1085 * @param {!WebInspector.ConsoleView} view | 1004 * @param {!WebInspector.ConsoleView} view |
| 1086 */ | 1005 */ |
| 1087 WebInspector.ConsoleViewFilter = function(view) | 1006 WebInspector.ConsoleViewFilter = function(view) |
| 1088 { | 1007 { |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1411 return true; | 1330 return true; |
| 1412 } | 1331 } |
| 1413 return false; | 1332 return false; |
| 1414 } | 1333 } |
| 1415 } | 1334 } |
| 1416 | 1335 |
| 1417 /** | 1336 /** |
| 1418 * @typedef {{messageIndex: number, matchIndex: number}} | 1337 * @typedef {{messageIndex: number, matchIndex: number}} |
| 1419 */ | 1338 */ |
| 1420 WebInspector.ConsoleView.RegexMatchRange; | 1339 WebInspector.ConsoleView.RegexMatchRange; |
| OLD | NEW |