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

Unified Diff: third_party/WebKit/Source/devtools/front_end/common/TextRange.js

Issue 1809533003: DevTools: remove illusionary caching from String.prototype.lineEndings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: String.prototype.lineEndings -> String.prototype.computeLineEndings Created 4 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: third_party/WebKit/Source/devtools/front_end/common/TextRange.js
diff --git a/third_party/WebKit/Source/devtools/front_end/common/TextRange.js b/third_party/WebKit/Source/devtools/front_end/common/TextRange.js
index a9b7f2728d7cb71b9a5f74805377d59d2828a68e..661674001f50b36d5e80655679bd78f992623689 100644
--- a/third_party/WebKit/Source/devtools/front_end/common/TextRange.js
+++ b/third_party/WebKit/Source/devtools/front_end/common/TextRange.js
@@ -225,17 +225,6 @@ WebInspector.TextRange.prototype = {
},
/**
- * @param {string} text
- * @return {!WebInspector.SourceRange}
- */
- toSourceRange: function(text)
- {
- var start = text.offsetFromPosition(this.startLine, this.startColumn);
- var end = text.offsetFromPosition(this.endLine, this.endColumn);
- return new WebInspector.SourceRange(start, end - start);
- },
-
- /**
* @param {!WebInspector.TextRange} originalRange
* @param {!WebInspector.TextRange} editedRange
* @return {!WebInspector.TextRange}
@@ -268,27 +257,6 @@ WebInspector.TextRange.prototype = {
},
/**
- * @param {string} text
- * @param {string} replacement
- * @return {string}
- */
- replaceInText: function(text, replacement)
- {
- var sourceRange = this.toSourceRange(text);
- return text.substring(0, sourceRange.offset) + replacement + text.substring(sourceRange.offset + sourceRange.length);
- },
-
- /**
- * @param {string} text
- * @return {string}
- */
- extract: function(text)
- {
- var sourceRange = this.toSourceRange(text);
- return text.substr(sourceRange.offset, sourceRange.length);
- },
-
- /**
* @param {number} lineNumber
* @param {number} columnNumber
* @return {boolean}
@@ -314,7 +282,7 @@ WebInspector.TextRange.fromEdit = function(oldRange, newText)
{
var endLine = oldRange.startLine;
var endColumn = oldRange.startColumn + newText.length;
- var lineEndings = newText.lineEndings();
+ var lineEndings = newText.computeLineEndings();
if (lineEndings.length > 1) {
endLine = oldRange.startLine + lineEndings.length - 1;
var len = lineEndings.length;
@@ -340,7 +308,7 @@ WebInspector.SourceRange = function(offset, length)
WebInspector.SourceRange.prototype = {
/**
- * @param {string} text
+ * @param {!WebInspector.Text} text
* @return {!WebInspector.TextRange}
*/
toTextRange: function(text)
@@ -350,7 +318,7 @@ WebInspector.SourceRange.prototype = {
return new WebInspector.TextRange(p1.lineNumber, p1.columnNumber, p2.lineNumber, p2.columnNumber);
/**
- * @param {string} text
+ * @param {!WebInspector.Text} text
* @param {number} offset
* @return {!{lineNumber: number, columnNumber: number}}
*/
@@ -385,13 +353,5 @@ WebInspector.SourceEdit.prototype = {
{
return WebInspector.TextRange.fromEdit(this.oldRange, this.newText);
},
-
- /**
- * @param {string} text
- * @return {string}
- */
- applyToText: function(text)
- {
- return this.oldRange.replaceInText(text, this.newText);
- },
}
+

Powered by Google App Engine
This is Rietveld 408576698