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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js

Issue 2752333002: DevTools: more efficiently dispose messages on console clear (Closed)
Patch Set: Set instead of array Created 3 years, 9 months 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/source_frame/UISourceCodeFrame.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 this._name = url; 55 this._name = url;
56 } 56 }
57 57
58 this._contentType = contentType; 58 this._contentType = contentType;
59 /** @type {?Promise<?string>} */ 59 /** @type {?Promise<?string>} */
60 this._requestContentPromise = null; 60 this._requestContentPromise = null;
61 /** @type {?Multimap<string, !Workspace.UISourceCode.LineMarker>} */ 61 /** @type {?Multimap<string, !Workspace.UISourceCode.LineMarker>} */
62 this._decorations = null; 62 this._decorations = null;
63 /** @type {?Array.<!Workspace.Revision>} */ 63 /** @type {?Array.<!Workspace.Revision>} */
64 this._history = null; 64 this._history = null;
65 /** @type {?Array<!Workspace.UISourceCode.Message>} */ 65 /** @type {?Set<!Workspace.UISourceCode.Message>} */
66 this._messages = null; 66 this._messages = null;
67 this._contentLoaded = false; 67 this._contentLoaded = false;
68 /** @type {?string} */ 68 /** @type {?string} */
69 this._content = null; 69 this._content = null;
70 this._forceLoadOnCheckContent = false; 70 this._forceLoadOnCheckContent = false;
71 this._checkingContent = false; 71 this._checkingContent = false;
72 /** @type {?string} */ 72 /** @type {?string} */
73 this._lastAcceptedContent = null; 73 this._lastAcceptedContent = null;
74 /** @type {?string} */ 74 /** @type {?string} */
75 this._workingCopy = null; 75 this._workingCopy = null;
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 * @param {number=} columnNumber 518 * @param {number=} columnNumber
519 * @return {!Workspace.UILocation} 519 * @return {!Workspace.UILocation}
520 */ 520 */
521 uiLocation(lineNumber, columnNumber) { 521 uiLocation(lineNumber, columnNumber) {
522 if (typeof columnNumber === 'undefined') 522 if (typeof columnNumber === 'undefined')
523 columnNumber = 0; 523 columnNumber = 0;
524 return new Workspace.UILocation(this, lineNumber, columnNumber); 524 return new Workspace.UILocation(this, lineNumber, columnNumber);
525 } 525 }
526 526
527 /** 527 /**
528 * @return {!Array<!Workspace.UISourceCode.Message>} 528 * @return {!Set<!Workspace.UISourceCode.Message>}
529 */ 529 */
530 messages() { 530 messages() {
531 return this._messages ? this._messages.slice() : []; 531 return this._messages ? new Set(this._messages) : new Set();
532 } 532 }
533 533
534 /** 534 /**
535 * @param {!Workspace.UISourceCode.Message.Level} level 535 * @param {!Workspace.UISourceCode.Message.Level} level
536 * @param {string} text 536 * @param {string} text
537 * @param {number} lineNumber 537 * @param {number} lineNumber
538 * @param {number=} columnNumber 538 * @param {number=} columnNumber
539 * @return {!Workspace.UISourceCode.Message} message 539 * @return {!Workspace.UISourceCode.Message} message
540 */ 540 */
541 addLineMessage(level, text, lineNumber, columnNumber) { 541 addLineMessage(level, text, lineNumber, columnNumber) {
542 return this.addMessage( 542 return this.addMessage(
543 level, text, new Common.TextRange(lineNumber, columnNumber || 0, lineNum ber, columnNumber || 0)); 543 level, text, new Common.TextRange(lineNumber, columnNumber || 0, lineNum ber, columnNumber || 0));
544 } 544 }
545 545
546 /** 546 /**
547 * @param {!Workspace.UISourceCode.Message.Level} level 547 * @param {!Workspace.UISourceCode.Message.Level} level
548 * @param {string} text 548 * @param {string} text
549 * @param {!Common.TextRange} range 549 * @param {!Common.TextRange} range
550 * @return {!Workspace.UISourceCode.Message} message 550 * @return {!Workspace.UISourceCode.Message} message
551 */ 551 */
552 addMessage(level, text, range) { 552 addMessage(level, text, range) {
553 var message = new Workspace.UISourceCode.Message(this, level, text, range); 553 var message = new Workspace.UISourceCode.Message(this, level, text, range);
554 if (!this._messages) 554 if (!this._messages)
555 this._messages = []; 555 this._messages = new Set();
556 this._messages.push(message); 556 this._messages.add(message);
557 this.dispatchEventToListeners(Workspace.UISourceCode.Events.MessageAdded, me ssage); 557 this.dispatchEventToListeners(Workspace.UISourceCode.Events.MessageAdded, me ssage);
558 return message; 558 return message;
559 } 559 }
560 560
561 /** 561 /**
562 * @param {!Workspace.UISourceCode.Message} message 562 * @param {!Workspace.UISourceCode.Message} message
563 */ 563 */
564 removeMessage(message) { 564 removeMessage(message) {
565 if (this._messages && this._messages.remove(message)) 565 if (this._messages && this._messages.delete(message))
566 this.dispatchEventToListeners(Workspace.UISourceCode.Events.MessageRemoved , message); 566 this.dispatchEventToListeners(Workspace.UISourceCode.Events.MessageRemoved , message);
567 } 567 }
568 568
569 _removeAllMessages() { 569 _removeAllMessages() {
570 if (!this._messages) 570 if (!this._messages)
571 return; 571 return;
572 for (var message of this._messages) 572 for (var message of this._messages)
573 this.dispatchEventToListeners(Workspace.UISourceCode.Events.MessageRemoved , message); 573 this.dispatchEventToListeners(Workspace.UISourceCode.Events.MessageRemoved , message);
574 this._messages = null; 574 this._messages = null;
575 } 575 }
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 Workspace.UISourceCodeMetadata = class { 920 Workspace.UISourceCodeMetadata = class {
921 /** 921 /**
922 * @param {?Date} modificationTime 922 * @param {?Date} modificationTime
923 * @param {?number} contentSize 923 * @param {?number} contentSize
924 */ 924 */
925 constructor(modificationTime, contentSize) { 925 constructor(modificationTime, contentSize) {
926 this.modificationTime = modificationTime; 926 this.modificationTime = modificationTime;
927 this.contentSize = contentSize; 927 this.contentSize = contentSize;
928 } 928 }
929 }; 929 };
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/source_frame/UISourceCodeFrame.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698