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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 this._updateFilterStatus(); | 148 this._updateFilterStatus(); |
149 WebInspector.moduleSetting("consoleTimestampsEnabled").addChangeListener(thi
s._consoleTimestampsSettingChanged, this); | 149 WebInspector.moduleSetting("consoleTimestampsEnabled").addChangeListener(thi
s._consoleTimestampsSettingChanged, this); |
150 | 150 |
151 this._registerWithMessageSink(); | 151 this._registerWithMessageSink(); |
152 WebInspector.targetManager.observeTargets(this); | 152 WebInspector.targetManager.observeTargets(this); |
153 | 153 |
154 this._initConsoleMessages(); | 154 this._initConsoleMessages(); |
155 | 155 |
156 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext,
this._executionContextChanged, this); | 156 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext,
this._executionContextChanged, this); |
| 157 |
| 158 this._messagesElement.addEventListener("mousedown", this._updateStickToBotto
mOnMouseDown.bind(this), false); |
| 159 this._messagesElement.addEventListener("mousewheel", this._updateStickToBott
omOnMouseWheel.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("keydown", this._updateStickToBottomO
nKeyDown.bind(this), true); |
157 } | 163 } |
158 | 164 |
159 WebInspector.ConsoleView.persistedHistorySize = 300; | 165 WebInspector.ConsoleView.persistedHistorySize = 300; |
160 | 166 |
161 WebInspector.ConsoleView.prototype = { | 167 WebInspector.ConsoleView.prototype = { |
162 /** | 168 /** |
163 * @return {!WebInspector.SearchableView} | 169 * @return {!WebInspector.SearchableView} |
164 */ | 170 */ |
165 searchableView: function() | 171 searchableView: function() |
166 { | 172 { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 if (this._promptElement === WebInspector.currentFocusElement()) | 352 if (this._promptElement === WebInspector.currentFocusElement()) |
347 return; | 353 return; |
348 // Set caret position before setting focus in order to avoid scrolling | 354 // Set caret position before setting focus in order to avoid scrolling |
349 // by focus(). | 355 // by focus(). |
350 this._prompt.moveCaretToEndOfPrompt(); | 356 this._prompt.moveCaretToEndOfPrompt(); |
351 WebInspector.setCurrentFocusElement(this._promptElement); | 357 WebInspector.setCurrentFocusElement(this._promptElement); |
352 }, | 358 }, |
353 | 359 |
354 restoreScrollPositions: function() | 360 restoreScrollPositions: function() |
355 { | 361 { |
356 if (this._viewport.scrolledToBottom()) | 362 if (this._viewport.stickToBottom()) |
357 this._immediatelyScrollToBottom(); | 363 this._immediatelyScrollToBottom(); |
358 else | 364 else |
359 WebInspector.Widget.prototype.restoreScrollPositions.call(this); | 365 WebInspector.Widget.prototype.restoreScrollPositions.call(this); |
360 }, | 366 }, |
361 | 367 |
362 onResize: function() | 368 onResize: function() |
363 { | 369 { |
364 this._scheduleViewportRefresh(); | 370 this._scheduleViewportRefresh(); |
365 this._hidePromptSuggestBox(); | 371 this._hidePromptSuggestBox(); |
366 if (this._viewport.scrolledToBottom()) | 372 if (this._viewport.stickToBottom()) |
367 this._immediatelyScrollToBottom(); | 373 this._immediatelyScrollToBottom(); |
368 for (var i = 0; i < this._visibleViewMessages.length; ++i) | 374 for (var i = 0; i < this._visibleViewMessages.length; ++i) |
369 this._visibleViewMessages[i].onResize(); | 375 this._visibleViewMessages[i].onResize(); |
370 }, | 376 }, |
371 | 377 |
372 _hidePromptSuggestBox: function() | 378 _hidePromptSuggestBox: function() |
373 { | 379 { |
374 this._prompt.hideSuggestBox(); | 380 this._prompt.hideSuggestBox(); |
375 this._prompt.clearAutoComplete(true); | 381 this._prompt.clearAutoComplete(true); |
376 }, | 382 }, |
377 | 383 |
378 _scheduleViewportRefresh: function() | 384 _scheduleViewportRefresh: function() |
379 { | 385 { |
380 /** | 386 /** |
381 * @this {WebInspector.ConsoleView} | 387 * @this {WebInspector.ConsoleView} |
382 * @return {!Promise.<undefined>} | 388 * @return {!Promise.<undefined>} |
383 */ | 389 */ |
384 function invalidateViewport() | 390 function invalidateViewport() |
385 { | 391 { |
| 392 if (this._muteViewportUpdates) |
| 393 return Promise.resolve(); |
386 if (this._needsFullUpdate) { | 394 if (this._needsFullUpdate) { |
387 this._updateMessageList(); | 395 this._updateMessageList(); |
388 delete this._needsFullUpdate; | 396 delete this._needsFullUpdate; |
389 } else { | 397 } else { |
390 this._viewport.invalidate(); | 398 this._viewport.invalidate(); |
391 } | 399 } |
392 return Promise.resolve(); | 400 return Promise.resolve(); |
393 } | 401 } |
| 402 if (this._muteViewportUpdates) |
| 403 return; |
394 this._viewportThrottler.schedule(invalidateViewport.bind(this)); | 404 this._viewportThrottler.schedule(invalidateViewport.bind(this)); |
395 }, | 405 }, |
396 | 406 |
397 _immediatelyScrollToBottom: function() | 407 _immediatelyScrollToBottom: function() |
398 { | 408 { |
399 // This will scroll viewport and trigger its refresh. | 409 // This will scroll viewport and trigger its refresh. |
| 410 this._viewport.setStickToBottom(true); |
400 this._promptElement.scrollIntoView(true); | 411 this._promptElement.scrollIntoView(true); |
401 }, | 412 }, |
402 | 413 |
403 _updateFilterStatus: function() | 414 _updateFilterStatus: function() |
404 { | 415 { |
405 this._filterStatusTextElement.textContent = WebInspector.UIString(this._
hiddenByFilterCount === 1 ? "%d message is hidden by filters." : "%d messages ar
e hidden by filters.", this._hiddenByFilterCount); | 416 this._filterStatusTextElement.textContent = WebInspector.UIString(this._
hiddenByFilterCount === 1 ? "%d message is hidden by filters." : "%d messages ar
e hidden by filters.", this._hiddenByFilterCount); |
406 this._filterStatusMessageElement.style.display = this._hiddenByFilterCou
nt ? "" : "none"; | 417 this._filterStatusMessageElement.style.display = this._hiddenByFilterCou
nt ? "" : "none"; |
407 }, | 418 }, |
408 | 419 |
409 /** | 420 /** |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 this._currentMatchRangeIndex = index; | 1007 this._currentMatchRangeIndex = index; |
997 this._searchableView.updateCurrentMatchIndex(index); | 1008 this._searchableView.updateCurrentMatchIndex(index); |
998 matchRange = this._regexMatchRanges[index]; | 1009 matchRange = this._regexMatchRanges[index]; |
999 var message = this._visibleViewMessages[matchRange.messageIndex]; | 1010 var message = this._visibleViewMessages[matchRange.messageIndex]; |
1000 var highlightNode = message.searchHighlightNode(matchRange.matchIndex); | 1011 var highlightNode = message.searchHighlightNode(matchRange.matchIndex); |
1001 highlightNode.classList.add(WebInspector.highlightedCurrentSearchResultC
lassName); | 1012 highlightNode.classList.add(WebInspector.highlightedCurrentSearchResultC
lassName); |
1002 this._viewport.scrollItemIntoView(matchRange.messageIndex); | 1013 this._viewport.scrollItemIntoView(matchRange.messageIndex); |
1003 highlightNode.scrollIntoViewIfNeeded(); | 1014 highlightNode.scrollIntoViewIfNeeded(); |
1004 }, | 1015 }, |
1005 | 1016 |
| 1017 _updateStickToBottomOnMouseDown: function() |
| 1018 { |
| 1019 this._muteViewportUpdates = true; |
| 1020 this._viewport.setStickToBottom(false); |
| 1021 this._wasScrolledToBottom = this._viewport.element.isScrolledToBottom(); |
| 1022 }, |
| 1023 |
| 1024 _updateStickToBottomOnMouseUp: function() |
| 1025 { |
| 1026 this._muteViewportUpdates = false; |
| 1027 if (this._wasScrolledToBottom) { |
| 1028 // When stuck to the bottom, clicking the gray area above the scroll |
| 1029 // thumb should scroll upwards and stop sticking. Smooth scroll |
| 1030 // events triggered by the click need to finish before querying |
| 1031 // isScrolledToBottom. The timeout value used is the longest smooth |
| 1032 // scroll duration, a value retrieved from crbug.com/575409. |
| 1033 setTimeout(updateViewportState.bind(this), 200); |
| 1034 } else { |
| 1035 // In another case, when users drag the scroll thumb to the bottom, |
| 1036 // the viewport should stick. Checking whether the mouse is released |
| 1037 // at the bottom of the viewport is not verifiable after an async |
| 1038 // timeout, so we do it immediately. |
| 1039 updateViewportState.call(this); |
| 1040 } |
| 1041 delete this._wasScrolledToBottom; |
| 1042 |
| 1043 /** |
| 1044 * @this {!WebInspector.ConsoleView} |
| 1045 */ |
| 1046 function updateViewportState() |
| 1047 { |
| 1048 this._viewport.setStickToBottom(this._viewport.element.isScrolledToB
ottom()); |
| 1049 this._scheduleViewportRefresh(); |
| 1050 } |
| 1051 }, |
| 1052 |
| 1053 _updateStickToBottomOnMouseWheel: function() |
| 1054 { |
| 1055 this._updateStickToBottomOnMouseDown(); |
| 1056 this._updateStickToBottomOnMouseUp(); |
| 1057 }, |
| 1058 |
| 1059 _updateStickToBottomOnKeyDown: function(event) |
| 1060 { |
| 1061 var isPageUpDown = event.keyCode === WebInspector.KeyboardShortcut.Keys.
PageDown.code || event.keyCode === WebInspector.KeyboardShortcut.Keys.PageUp.cod
e; |
| 1062 var isEsc = event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.cod
e; |
| 1063 if (isEsc) |
| 1064 return; |
| 1065 if (isPageUpDown) |
| 1066 this._updateStickToBottomOnMouseWheel(); |
| 1067 else |
| 1068 this._viewport.setStickToBottom(true); |
| 1069 }, |
| 1070 |
1006 __proto__: WebInspector.VBox.prototype | 1071 __proto__: WebInspector.VBox.prototype |
1007 } | 1072 } |
1008 | 1073 |
1009 /** | 1074 /** |
1010 * @constructor | 1075 * @constructor |
1011 * @extends {WebInspector.Object} | 1076 * @extends {WebInspector.Object} |
1012 * @param {!WebInspector.ConsoleView} view | 1077 * @param {!WebInspector.ConsoleView} view |
1013 */ | 1078 */ |
1014 WebInspector.ConsoleViewFilter = function(view) | 1079 WebInspector.ConsoleViewFilter = function(view) |
1015 { | 1080 { |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 return true; | 1403 return true; |
1339 } | 1404 } |
1340 return false; | 1405 return false; |
1341 } | 1406 } |
1342 } | 1407 } |
1343 | 1408 |
1344 /** | 1409 /** |
1345 * @typedef {{messageIndex: number, matchIndex: number}} | 1410 * @typedef {{messageIndex: number, matchIndex: number}} |
1346 */ | 1411 */ |
1347 WebInspector.ConsoleView.RegexMatchRange; | 1412 WebInspector.ConsoleView.RegexMatchRange; |
OLD | NEW |