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

Unified Diff: third_party/WebKit/Source/devtools/front_end/source_frame/SourceCodeDiff.js

Issue 2762443002: DevTools: Only show gutter diff for Network UISourceCodes (Closed)
Patch Set: doc 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/source_frame/UISourceCodeFrame.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/source_frame/SourceCodeDiff.js
diff --git a/third_party/WebKit/Source/devtools/front_end/source_frame/SourceCodeDiff.js b/third_party/WebKit/Source/devtools/front_end/source_frame/SourceCodeDiff.js
index 1bf24458ab9f3e865ceb7755df6ee1458ebf5222..546aab6840ac8bcfe0258a33126ec820dc2fb0c2 100644
--- a/third_party/WebKit/Source/devtools/front_end/source_frame/SourceCodeDiff.js
+++ b/third_party/WebKit/Source/devtools/front_end/source_frame/SourceCodeDiff.js
@@ -7,19 +7,31 @@
SourceFrame.SourceCodeDiff = class {
/**
* @param {!WorkspaceDiff.WorkspaceDiff} workspaceDiff
- * @param {!Workspace.UISourceCode} uiSourceCode
* @param {!TextEditor.CodeMirrorTextEditor} textEditor
*/
- constructor(workspaceDiff, uiSourceCode, textEditor) {
+ constructor(workspaceDiff, textEditor) {
this._textEditor = textEditor;
this._decorations = [];
this._textEditor.installGutter(SourceFrame.SourceCodeDiff.DiffGutterType, true);
- this._uiSourceCode = uiSourceCode;
+ this._uiSourceCode = null;
this._workspaceDiff = workspaceDiff;
/** @type {!Array<!TextEditor.TextEditorPositionHandle>}*/
this._animatedLines = [];
- this._workspaceDiff.subscribeToDiffChange(this._uiSourceCode, this._update, this);
+ this._update();
+ }
+
+ /**
+ * @param {?Workspace.UISourceCode} uiSourceCode
+ */
+ setUISourceCode(uiSourceCode) {
+ if (uiSourceCode === this._uiSourceCode)
+ return;
+ if (this._uiSourceCode)
+ this._workspaceDiff.unsubscribeFromDiffChange(this._uiSourceCode, this._update, this);
+ if (uiSourceCode)
+ this._workspaceDiff.subscribeToDiffChange(uiSourceCode, this._update, this);
+ this._uiSourceCode = uiSourceCode;
this._update();
}
@@ -155,15 +167,21 @@ SourceFrame.SourceCodeDiff = class {
}
_update() {
- this._workspaceDiff.requestDiff(this._uiSourceCode).then(this._innerUpdate.bind(this));
+ if (this._uiSourceCode)
+ this._workspaceDiff.requestDiff(this._uiSourceCode).then(this._innerUpdate.bind(this));
+ else
+ this._innerUpdate(null);
}
/**
* @param {?Diff.Diff.DiffArray} lineDiff
*/
_innerUpdate(lineDiff) {
- if (!lineDiff)
+ if (!lineDiff) {
+ this._updateDecorations(this._decorations, []);
+ this._decorations = [];
return;
+ }
/** @type {!Map<number, !SourceFrame.SourceCodeDiff.GutterDecoration>} */
var oldDecorations = new Map();
@@ -201,7 +219,8 @@ SourceFrame.SourceCodeDiff = class {
}
dispose() {
- WorkspaceDiff.workspaceDiff().unsubscribeFromDiffChange(this._uiSourceCode, this._update, this);
+ if (this._uiSourceCode)
+ WorkspaceDiff.workspaceDiff().unsubscribeFromDiffChange(this._uiSourceCode, this._update, this);
}
};
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/source_frame/UISourceCodeFrame.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698