Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(663)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/console/ConsoleView.js

Issue 2565113002: DevTools: update console viewport scroll when prompt is resized (Closed)
Patch Set: return to first approach Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 if (this._viewport.stickToBottom()) 369 if (this._viewport.stickToBottom())
370 this._immediatelyScrollToBottom(); 370 this._immediatelyScrollToBottom();
371 else 371 else
372 super.restoreScrollPositions(); 372 super.restoreScrollPositions();
373 } 373 }
374 374
375 /** 375 /**
376 * @override 376 * @override
377 */ 377 */
378 onResize() { 378 onResize() {
379 this._scheduleViewportRefresh(); 379 this.scheduleViewportRefresh();
380 this._hidePromptSuggestBox(); 380 this._hidePromptSuggestBox();
381 if (this._viewport.stickToBottom()) 381 if (this._viewport.stickToBottom())
382 this._immediatelyScrollToBottom(); 382 this._immediatelyScrollToBottom();
383 for (var i = 0; i < this._visibleViewMessages.length; ++i) 383 for (var i = 0; i < this._visibleViewMessages.length; ++i)
384 this._visibleViewMessages[i].onResize(); 384 this._visibleViewMessages[i].onResize();
385 } 385 }
386 386
387 _hidePromptSuggestBox() { 387 _hidePromptSuggestBox() {
388 this._prompt.clearAutocomplete(); 388 this._prompt.clearAutocomplete();
389 } 389 }
390 390
391 _scheduleViewportRefresh() { 391 scheduleViewportRefresh() {
392 /** 392 /**
393 * @this {Console.ConsoleView} 393 * @this {Console.ConsoleView}
394 * @return {!Promise.<undefined>} 394 * @return {!Promise.<undefined>}
395 */ 395 */
396 function invalidateViewport() { 396 function invalidateViewport() {
397 if (this._muteViewportUpdates) { 397 if (this._muteViewportUpdates) {
398 this._maybeDirtyWhileMuted = true; 398 this._maybeDirtyWhileMuted = true;
399 return Promise.resolve(); 399 return Promise.resolve();
400 } 400 }
401 if (this._needsFullUpdate) { 401 if (this._needsFullUpdate) {
402 this._updateMessageList(); 402 this._updateMessageList();
403 delete this._needsFullUpdate; 403 delete this._needsFullUpdate;
404 } else { 404 } else {
405 this._viewport.invalidate(); 405 this._viewport.invalidate();
406 } 406 }
407 return Promise.resolve(); 407 return Promise.resolve();
408 } 408 }
409 if (this._muteViewportUpdates) { 409 if (this._muteViewportUpdates) {
410 this._maybeDirtyWhileMuted = true; 410 this._maybeDirtyWhileMuted = true;
411 this._scheduleViewportRefreshForTest(true); 411 this.scheduleViewportRefreshForTest(true);
412 return; 412 return;
413 } else { 413 } else {
414 this._scheduleViewportRefreshForTest(false); 414 this.scheduleViewportRefreshForTest(false);
415 } 415 }
416 this._viewportThrottler.schedule(invalidateViewport.bind(this)); 416 this._viewportThrottler.schedule(invalidateViewport.bind(this));
417 } 417 }
418 418
419 /** 419 /**
420 * @param {boolean} muted 420 * @param {boolean} muted
421 */ 421 */
422 _scheduleViewportRefreshForTest(muted) { 422 scheduleViewportRefreshForTest(muted) {
dgozman 2016/12/14 17:28:43 Why made this public? It's not intended to be used
423 // This functions is sniffed in tests. 423 // This functions is sniffed in tests.
424 } 424 }
425 425
426 _immediatelyScrollToBottom() { 426 _immediatelyScrollToBottom() {
427 // This will scroll viewport and trigger its refresh. 427 // This will scroll viewport and trigger its refresh.
428 this._viewport.setStickToBottom(true); 428 this._viewport.setStickToBottom(true);
429 this._promptElement.scrollIntoView(true); 429 this._promptElement.scrollIntoView(true);
430 } 430 }
431 431
432 _updateFilterStatus() { 432 _updateFilterStatus() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 this._urlToMessageCount[message.url] = 1; 474 this._urlToMessageCount[message.url] = 1;
475 475
476 if (!insertedInMiddle) { 476 if (!insertedInMiddle) {
477 this._appendMessageToEnd(viewMessage); 477 this._appendMessageToEnd(viewMessage);
478 this._updateFilterStatus(); 478 this._updateFilterStatus();
479 this._searchableView.updateSearchMatchesCount(this._regexMatchRanges.lengt h); 479 this._searchableView.updateSearchMatchesCount(this._regexMatchRanges.lengt h);
480 } else { 480 } else {
481 this._needsFullUpdate = true; 481 this._needsFullUpdate = true;
482 } 482 }
483 483
484 this._scheduleViewportRefresh(); 484 this.scheduleViewportRefresh();
485 this._consoleMessageAddedForTest(viewMessage); 485 this._consoleMessageAddedForTest(viewMessage);
486 } 486 }
487 487
488 /** 488 /**
489 * @param {!Common.Event} event 489 * @param {!Common.Event} event
490 */ 490 */
491 _onConsoleMessageUpdated(event) { 491 _onConsoleMessageUpdated(event) {
492 var message = /** @type {!SDK.ConsoleMessage} */ (event.data); 492 var message = /** @type {!SDK.ConsoleMessage} */ (event.data);
493 var viewMessage = message[this._viewMessageSymbol]; 493 var viewMessage = message[this._viewMessageSymbol];
494 if (viewMessage) { 494 if (viewMessage) {
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 // retrieved from crbug.com/575409. 1004 // retrieved from crbug.com/575409.
1005 this._waitForScrollTimeout = setTimeout(updateViewportState.bind(this), 200) ; 1005 this._waitForScrollTimeout = setTimeout(updateViewportState.bind(this), 200) ;
1006 1006
1007 /** 1007 /**
1008 * @this {!Console.ConsoleView} 1008 * @this {!Console.ConsoleView}
1009 */ 1009 */
1010 function updateViewportState() { 1010 function updateViewportState() {
1011 this._muteViewportUpdates = false; 1011 this._muteViewportUpdates = false;
1012 this._viewport.setStickToBottom(this._messagesElement.isScrolledToBottom() ); 1012 this._viewport.setStickToBottom(this._messagesElement.isScrolledToBottom() );
1013 if (this._maybeDirtyWhileMuted) { 1013 if (this._maybeDirtyWhileMuted) {
1014 this._scheduleViewportRefresh(); 1014 this.scheduleViewportRefresh();
1015 delete this._maybeDirtyWhileMuted; 1015 delete this._maybeDirtyWhileMuted;
1016 } 1016 }
1017 delete this._waitForScrollTimeout; 1017 delete this._waitForScrollTimeout;
1018 this._updateViewportStickinessForTest(); 1018 this._updateViewportStickinessForTest();
1019 } 1019 }
1020 } 1020 }
1021 1021
1022 _updateViewportStickinessForTest() { 1022 _updateViewportStickinessForTest() {
1023 // This method is sniffed in tests. 1023 // This method is sniffed in tests.
1024 } 1024 }
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 return true; 1336 return true;
1337 } 1337 }
1338 return false; 1338 return false;
1339 } 1339 }
1340 }; 1340 };
1341 1341
1342 /** 1342 /**
1343 * @typedef {{messageIndex: number, matchIndex: number}} 1343 * @typedef {{messageIndex: number, matchIndex: number}}
1344 */ 1344 */
1345 Console.ConsoleView.RegexMatchRange; 1345 Console.ConsoleView.RegexMatchRange;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698