| Index: third_party/WebKit/Source/devtools/front_end/sources/SourceCodeDiff.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/sources/SourceCodeDiff.js b/third_party/WebKit/Source/devtools/front_end/sources/SourceCodeDiff.js
|
| index f05209071760327eff1485a5ad39320fe0f80b25..0a4aca42883564c1cc3ae65f8501415415b12aed 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/sources/SourceCodeDiff.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/sources/SourceCodeDiff.js
|
| @@ -4,17 +4,17 @@
|
| /**
|
| * @unrestricted
|
| */
|
| -WebInspector.SourceCodeDiff = class {
|
| +Sources.SourceCodeDiff = class {
|
| /**
|
| * @param {!Promise<?string>} diffBaseline
|
| - * @param {!WebInspector.CodeMirrorTextEditor} textEditor
|
| + * @param {!TextEditor.CodeMirrorTextEditor} textEditor
|
| */
|
| constructor(diffBaseline, textEditor) {
|
| this._textEditor = textEditor;
|
| this._decorations = [];
|
| - this._textEditor.installGutter(WebInspector.SourceCodeDiff.DiffGutterType, true);
|
| + this._textEditor.installGutter(Sources.SourceCodeDiff.DiffGutterType, true);
|
| this._diffBaseline = diffBaseline;
|
| - /** @type {!Array<!WebInspector.TextEditorPositionHandle>}*/
|
| + /** @type {!Array<!TextEditor.TextEditorPositionHandle>}*/
|
| this._animatedLines = [];
|
| }
|
|
|
| @@ -22,7 +22,7 @@ WebInspector.SourceCodeDiff = class {
|
| if (this._updateTimeout)
|
| clearTimeout(this._updateTimeout);
|
| this._updateTimeout =
|
| - setTimeout(this.updateDiffMarkersImmediately.bind(this), WebInspector.SourceCodeDiff.UpdateTimeout);
|
| + setTimeout(this.updateDiffMarkersImmediately.bind(this), Sources.SourceCodeDiff.UpdateTimeout);
|
| }
|
|
|
| updateDiffMarkersImmediately() {
|
| @@ -44,7 +44,7 @@ WebInspector.SourceCodeDiff = class {
|
| var changedLines = [];
|
| for (var i = 0; i < diff.length; ++i) {
|
| var diffEntry = diff[i];
|
| - if (diffEntry.type === WebInspector.SourceCodeDiff.GutterDecorationType.Delete)
|
| + if (diffEntry.type === Sources.SourceCodeDiff.GutterDecorationType.Delete)
|
| continue;
|
| for (var lineNumber = diffEntry.from; lineNumber < diffEntry.to; ++lineNumber) {
|
| var position = this._textEditor.textEditorPositionHandle(lineNumber, 0);
|
| @@ -58,7 +58,7 @@ WebInspector.SourceCodeDiff = class {
|
| }
|
|
|
| /**
|
| - * @param {!Array<!WebInspector.TextEditorPositionHandle>} newLines
|
| + * @param {!Array<!TextEditor.TextEditorPositionHandle>} newLines
|
| */
|
| _updateHighlightedLines(newLines) {
|
| if (this._animationTimeout)
|
| @@ -67,7 +67,7 @@ WebInspector.SourceCodeDiff = class {
|
| this._textEditor.operation(operation.bind(this));
|
|
|
| /**
|
| - * @this {WebInspector.SourceCodeDiff}
|
| + * @this {Sources.SourceCodeDiff}
|
| */
|
| function operation() {
|
| toggleLines.call(this, false);
|
| @@ -77,7 +77,7 @@ WebInspector.SourceCodeDiff = class {
|
|
|
| /**
|
| * @param {boolean} value
|
| - * @this {WebInspector.SourceCodeDiff}
|
| + * @this {Sources.SourceCodeDiff}
|
| */
|
| function toggleLines(value) {
|
| for (var i = 0; i < this._animatedLines.length; ++i) {
|
| @@ -89,8 +89,8 @@ WebInspector.SourceCodeDiff = class {
|
| }
|
|
|
| /**
|
| - * @param {!Array<!WebInspector.SourceCodeDiff.GutterDecoration>} removed
|
| - * @param {!Array<!WebInspector.SourceCodeDiff.GutterDecoration>} added
|
| + * @param {!Array<!Sources.SourceCodeDiff.GutterDecoration>} removed
|
| + * @param {!Array<!Sources.SourceCodeDiff.GutterDecoration>} added
|
| */
|
| _updateDecorations(removed, added) {
|
| this._textEditor.operation(operation);
|
| @@ -106,10 +106,10 @@ WebInspector.SourceCodeDiff = class {
|
| /**
|
| * @param {string} baseline
|
| * @param {string} current
|
| - * @return {!Array<!{type: !WebInspector.SourceCodeDiff.GutterDecorationType, from: number, to: number}>}
|
| + * @return {!Array<!{type: !Sources.SourceCodeDiff.GutterDecorationType, from: number, to: number}>}
|
| */
|
| _computeDiff(baseline, current) {
|
| - var diff = WebInspector.Diff.lineDiff(baseline.split('\n'), current.split('\n'));
|
| + var diff = Diff.Diff.lineDiff(baseline.split('\n'), current.split('\n'));
|
| var result = [];
|
| var hasAdded = false;
|
| var hasRemoved = false;
|
| @@ -118,7 +118,7 @@ WebInspector.SourceCodeDiff = class {
|
| var isInsideBlock = false;
|
| for (var i = 0; i < diff.length; ++i) {
|
| var token = diff[i];
|
| - if (token[0] === WebInspector.Diff.Operation.Equal) {
|
| + if (token[0] === Diff.Diff.Operation.Equal) {
|
| if (isInsideBlock)
|
| flush();
|
| currentLineNumber += token[1].length;
|
| @@ -130,7 +130,7 @@ WebInspector.SourceCodeDiff = class {
|
| blockStartLineNumber = currentLineNumber;
|
| }
|
|
|
| - if (token[0] === WebInspector.Diff.Operation.Delete) {
|
| + if (token[0] === Diff.Diff.Operation.Delete) {
|
| hasRemoved = true;
|
| } else {
|
| currentLineNumber += token[1].length;
|
| @@ -140,22 +140,22 @@ WebInspector.SourceCodeDiff = class {
|
| if (isInsideBlock)
|
| flush();
|
| if (result.length > 1 && result[0].from === 0 && result[1].from === 0) {
|
| - var merged = {type: WebInspector.SourceCodeDiff.GutterDecorationType.Modify, from: 0, to: result[1].to};
|
| + var merged = {type: Sources.SourceCodeDiff.GutterDecorationType.Modify, from: 0, to: result[1].to};
|
| result.splice(0, 2, merged);
|
| }
|
| return result;
|
|
|
| function flush() {
|
| - var type = WebInspector.SourceCodeDiff.GutterDecorationType.Insert;
|
| + var type = Sources.SourceCodeDiff.GutterDecorationType.Insert;
|
| var from = blockStartLineNumber;
|
| var to = currentLineNumber;
|
| if (hasAdded && hasRemoved) {
|
| - type = WebInspector.SourceCodeDiff.GutterDecorationType.Modify;
|
| + type = Sources.SourceCodeDiff.GutterDecorationType.Modify;
|
| } else if (!hasAdded && hasRemoved && from === 0 && to === 0) {
|
| - type = WebInspector.SourceCodeDiff.GutterDecorationType.Modify;
|
| + type = Sources.SourceCodeDiff.GutterDecorationType.Modify;
|
| to = 1;
|
| } else if (!hasAdded && hasRemoved) {
|
| - type = WebInspector.SourceCodeDiff.GutterDecorationType.Delete;
|
| + type = Sources.SourceCodeDiff.GutterDecorationType.Delete;
|
| from -= 1;
|
| }
|
| result.push({type: type, from: from, to: to});
|
| @@ -178,7 +178,7 @@ WebInspector.SourceCodeDiff = class {
|
|
|
| var diff = this._computeDiff(baseline, current);
|
|
|
| - /** @type {!Map<number, !WebInspector.SourceCodeDiff.GutterDecoration>} */
|
| + /** @type {!Map<number, !Sources.SourceCodeDiff.GutterDecoration>} */
|
| var oldDecorations = new Map();
|
| for (var i = 0; i < this._decorations.length; ++i) {
|
| var decoration = this._decorations[i];
|
| @@ -188,7 +188,7 @@ WebInspector.SourceCodeDiff = class {
|
| oldDecorations.set(lineNumber, decoration);
|
| }
|
|
|
| - /** @type {!Map<number, !{lineNumber: number, type: !WebInspector.SourceCodeDiff.GutterDecorationType}>} */
|
| + /** @type {!Map<number, !{lineNumber: number, type: !Sources.SourceCodeDiff.GutterDecorationType}>} */
|
| var newDecorations = new Map();
|
| for (var i = 0; i < diff.length; ++i) {
|
| var diffEntry = diff[i];
|
| @@ -198,7 +198,7 @@ WebInspector.SourceCodeDiff = class {
|
|
|
| var decorationDiff = oldDecorations.diff(newDecorations, (e1, e2) => e1.type === e2.type);
|
| var addedDecorations = decorationDiff.added.map(
|
| - entry => new WebInspector.SourceCodeDiff.GutterDecoration(this._textEditor, entry.lineNumber, entry.type));
|
| + entry => new Sources.SourceCodeDiff.GutterDecoration(this._textEditor, entry.lineNumber, entry.type));
|
|
|
| this._decorations = decorationDiff.equal.concat(addedDecorations);
|
| this._updateDecorations(decorationDiff.removed, addedDecorations);
|
| @@ -206,20 +206,20 @@ WebInspector.SourceCodeDiff = class {
|
| }
|
|
|
| /**
|
| - * @param {!Map<number, !{lineNumber: number, type: !WebInspector.SourceCodeDiff.GutterDecorationType}>} decorations
|
| + * @param {!Map<number, !{lineNumber: number, type: !Sources.SourceCodeDiff.GutterDecorationType}>} decorations
|
| */
|
| _decorationsSetForTest(decorations) {
|
| }
|
| };
|
|
|
| /** @type {number} */
|
| -WebInspector.SourceCodeDiff.UpdateTimeout = 200;
|
| +Sources.SourceCodeDiff.UpdateTimeout = 200;
|
|
|
| /** @type {string} */
|
| -WebInspector.SourceCodeDiff.DiffGutterType = 'CodeMirror-gutter-diff';
|
| +Sources.SourceCodeDiff.DiffGutterType = 'CodeMirror-gutter-diff';
|
|
|
| /** @enum {symbol} */
|
| -WebInspector.SourceCodeDiff.GutterDecorationType = {
|
| +Sources.SourceCodeDiff.GutterDecorationType = {
|
| Insert: Symbol('Insert'),
|
| Delete: Symbol('Delete'),
|
| Modify: Symbol('Modify'),
|
| @@ -228,21 +228,21 @@ WebInspector.SourceCodeDiff.GutterDecorationType = {
|
| /**
|
| * @unrestricted
|
| */
|
| -WebInspector.SourceCodeDiff.GutterDecoration = class {
|
| +Sources.SourceCodeDiff.GutterDecoration = class {
|
| /**
|
| - * @param {!WebInspector.CodeMirrorTextEditor} textEditor
|
| + * @param {!TextEditor.CodeMirrorTextEditor} textEditor
|
| * @param {number} lineNumber
|
| - * @param {!WebInspector.SourceCodeDiff.GutterDecorationType} type
|
| + * @param {!Sources.SourceCodeDiff.GutterDecorationType} type
|
| */
|
| constructor(textEditor, lineNumber, type) {
|
| this._textEditor = textEditor;
|
| this._position = this._textEditor.textEditorPositionHandle(lineNumber, 0);
|
| this._className = '';
|
| - if (type === WebInspector.SourceCodeDiff.GutterDecorationType.Insert)
|
| + if (type === Sources.SourceCodeDiff.GutterDecorationType.Insert)
|
| this._className = 'diff-entry-insert';
|
| - else if (type === WebInspector.SourceCodeDiff.GutterDecorationType.Delete)
|
| + else if (type === Sources.SourceCodeDiff.GutterDecorationType.Delete)
|
| this._className = 'diff-entry-delete';
|
| - else if (type === WebInspector.SourceCodeDiff.GutterDecorationType.Modify)
|
| + else if (type === Sources.SourceCodeDiff.GutterDecorationType.Modify)
|
| this._className = 'diff-entry-modify';
|
| this.type = type;
|
| }
|
| @@ -263,7 +263,7 @@ WebInspector.SourceCodeDiff.GutterDecoration = class {
|
| return;
|
| var element = createElementWithClass('div', 'diff-marker');
|
| element.textContent = '\u00A0';
|
| - this._textEditor.setGutterDecoration(location.lineNumber, WebInspector.SourceCodeDiff.DiffGutterType, element);
|
| + this._textEditor.setGutterDecoration(location.lineNumber, Sources.SourceCodeDiff.DiffGutterType, element);
|
| this._textEditor.toggleLineClass(location.lineNumber, this._className, true);
|
| }
|
|
|
| @@ -271,7 +271,7 @@ WebInspector.SourceCodeDiff.GutterDecoration = class {
|
| var location = this._position.resolve();
|
| if (!location)
|
| return;
|
| - this._textEditor.setGutterDecoration(location.lineNumber, WebInspector.SourceCodeDiff.DiffGutterType, null);
|
| + this._textEditor.setGutterDecoration(location.lineNumber, Sources.SourceCodeDiff.DiffGutterType, null);
|
| this._textEditor.toggleLineClass(location.lineNumber, this._className, false);
|
| }
|
| };
|
|
|