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

Unified Diff: Source/devtools/front_end/TextRange.js

Issue 220403005: DevTools: synchronize links in StylesSidebarPane on edits. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix tests Created 6 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
Index: Source/devtools/front_end/TextRange.js
diff --git a/Source/devtools/front_end/TextRange.js b/Source/devtools/front_end/TextRange.js
index b7b6c05e4da04574ec302ab637867b3158b2551e..30a2972186bdd6e6af9301a2bc586e6eb6b728ea 100644
--- a/Source/devtools/front_end/TextRange.js
+++ b/Source/devtools/front_end/TextRange.js
@@ -89,6 +89,16 @@ WebInspector.TextRange.prototype = {
},
/**
+ * @param {!WebInspector.TextRange} range
+ * @return {boolean}
+ */
+ follows: function(range)
+ {
+ return (range.endLine === this.startLine && range.endColumn <= this.startColumn)
+ || range.endLine < this.startLine;
+ },
+
+ /**
* @return {number}
*/
get linesCount()
@@ -173,6 +183,29 @@ WebInspector.TextRange.prototype = {
},
/**
+ * @param {!WebInspector.TextRange} originalRange
+ * @param {!WebInspector.TextRange} editedRange
+ * @return {!WebInspector.TextRange}
+ */
+ rebaseAfterTextEdit: function(originalRange, editedRange)
+ {
+ console.assert(originalRange.startLine === editedRange.startLine);
+ console.assert(originalRange.startColumn === editedRange.startColumn);
+ var rebase = this.clone();
+ if (!this.follows(originalRange))
+ return rebase;
+ var lineDelta = editedRange.endLine - originalRange.endLine;
+ var columnDelta = editedRange.endColumn - originalRange.endColumn;
+ rebase.startLine += lineDelta;
+ rebase.endLine += lineDelta;
+ if (rebase.startLine === editedRange.endLine)
+ rebase.startColumn += columnDelta;
+ if (rebase.endLine === editedRange.endLine)
+ rebase.endColumn += columnDelta;
+ return rebase;
+ },
+
+ /**
* @return {string}
*/
toString: function()

Powered by Google App Engine
This is Rietveld 408576698