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

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

Issue 2613643002: DevTools: migrate from external Maps to symbols in the bindings objects. (Closed)
Patch Set: Created 3 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js
diff --git a/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js b/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js
index d92525dc66dee1154efdd393b42c3e8c1f148e5d..f1110ab032e4c20c428ad0846e633ef6022148de 100644
--- a/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js
+++ b/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js
@@ -58,15 +58,12 @@ Workspace.UISourceCode = class extends Common.Object {
this._contentType = contentType;
/** @type {?Promise<?string>} */
this._requestContentPromise = null;
- /** @type {!Multimap<string, !Workspace.UISourceCode.LineMarker>} */
- this._decorations = new Multimap();
-
- /** @type {!Array.<!Workspace.Revision>} */
- this.history = [];
-
- /** @type {!Array<!Workspace.UISourceCode.Message>} */
- this._messages = [];
-
+ /** @type {?Multimap<string, !Workspace.UISourceCode.LineMarker>} */
+ this._decorations = null;
dgozman 2017/01/04 01:04:08 Do "Multimap|undefined" and don't assign here.
pfeldman 2017/01/04 01:13:48 should be = null;
+ /** @type {?Array.<!Workspace.Revision>} */
+ this._history = [];
dgozman 2017/01/04 01:04:08 ditto
pfeldman 2017/01/04 01:13:48 Acknowledged.
+ /** @type {?Array<!Workspace.UISourceCode.Message>} */
+ this._messages = null;
dgozman 2017/01/04 01:04:08 ditto
pfeldman 2017/01/04 01:13:48 Acknowledged.
this._contentLoaded = false;
/** @type {?string} */
this._content = null;
@@ -313,10 +310,14 @@ Workspace.UISourceCode = class extends Common.Object {
this._contentLoaded = true;
this._requestContentPromise = null;
- var lastRevision = this.history.length ? this.history[this.history.length - 1] : null;
+
+ if (!this._history)
+ this._history = [];
+
+ var lastRevision = this._history.length ? this._history[this._history.length - 1] : null;
if (!lastRevision || lastRevision._content !== this._content) {
var revision = new Workspace.Revision(this, this._content, new Date());
- this.history.push(revision);
+ this._history.push(revision);
}
this._innerResetWorkingCopy();
@@ -383,7 +384,7 @@ Workspace.UISourceCode = class extends Common.Object {
return;
this.addRevision(content);
- this.history = [];
+ this._history = null;
callback(this);
}
@@ -392,6 +393,15 @@ Workspace.UISourceCode = class extends Common.Object {
}
/**
+ * @return {!Array<!Workspace.Revision>}
+ */
+ history() {
+ if (!this._history)
+ this._history = [];
+ return this._history;
+ }
+
+ /**
* @return {string}
*/
workingCopy() {
@@ -518,7 +528,7 @@ Workspace.UISourceCode = class extends Common.Object {
* @return {!Array<!Workspace.UISourceCode.Message>}
*/
messages() {
- return this._messages.slice();
+ return this._messages ? this._messages.slice() : [];
}
/**
@@ -541,6 +551,8 @@ Workspace.UISourceCode = class extends Common.Object {
*/
addMessage(level, text, range) {
var message = new Workspace.UISourceCode.Message(this, level, text, range);
+ if (!this._messages)
+ this._messages = [];
this._messages.push(message);
this.dispatchEventToListeners(Workspace.UISourceCode.Events.MessageAdded, message);
return message;
@@ -550,15 +562,16 @@ Workspace.UISourceCode = class extends Common.Object {
* @param {!Workspace.UISourceCode.Message} message
*/
removeMessage(message) {
- if (this._messages.remove(message))
+ if (this._messages && this._messages.remove(message))
this.dispatchEventToListeners(Workspace.UISourceCode.Events.MessageRemoved, message);
}
_removeAllMessages() {
- var messages = this._messages;
- this._messages = [];
- for (var message of messages)
+ if (!this._messages)
+ return;
+ for (var message of this._messages)
this.dispatchEventToListeners(Workspace.UISourceCode.Events.MessageRemoved, message);
+ this._messages = null;
}
/**
@@ -577,6 +590,8 @@ Workspace.UISourceCode = class extends Common.Object {
*/
addDecoration(range, type, data) {
var marker = new Workspace.UISourceCode.LineMarker(range, type, data);
+ if (!this._decorations)
+ this._decorations = new Multimap();
this._decorations.set(type, marker);
this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationAdded, marker);
}
@@ -585,6 +600,8 @@ Workspace.UISourceCode = class extends Common.Object {
* @param {string} type
*/
removeDecorationsForType(type) {
+ if (!this._decorations)
+ return;
var markers = this._decorations.get(type);
this._decorations.removeAll(type);
markers.forEach(marker => {
@@ -596,10 +613,12 @@ Workspace.UISourceCode = class extends Common.Object {
* @return {!Array<!Workspace.UISourceCode.LineMarker>}
*/
allDecorations() {
- return this._decorations.valuesArray();
+ return this._decorations ? this._decorations.valuesArray() : [];
}
removeAllDecorations() {
+ if (!this._decorations)
+ return;
var decorationList = this._decorations.valuesArray();
this._decorations.clear();
decorationList.forEach(
@@ -608,10 +627,10 @@ Workspace.UISourceCode = class extends Common.Object {
/**
* @param {string} type
- * @return {!Set<!Workspace.UISourceCode.LineMarker>}
+ * @return {?Set<!Workspace.UISourceCode.LineMarker>}
*/
decorationsForType(type) {
- return this._decorations.get(type);
+ return this._decorations ? this._decorations.get(type) : null;
}
};

Powered by Google App Engine
This is Rietveld 408576698