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

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

Issue 1187193005: DevTools: migrate from CSS.setPropertyText to CSS.setStyleText (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: for landing Created 5 years, 6 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 | « Source/core/inspector/InspectorStyleTextEditor.cpp ('k') | Source/devtools/front_end/common/TextUtils.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/common/TextRange.js
diff --git a/Source/devtools/front_end/common/TextRange.js b/Source/devtools/front_end/common/TextRange.js
index 61734236a862b36c141325efafb38ea728aed311..9c1bcd987e2a5935218523d15168961bda1724a1 100644
--- a/Source/devtools/front_end/common/TextRange.js
+++ b/Source/devtools/front_end/common/TextRange.js
@@ -157,7 +157,7 @@ WebInspector.TextRange.prototype = {
},
/**
- * @return {!Object}
+ * @return {!{startLine: number, startColumn: number, endLine: number, endColumn: number}}
*/
serializeToObject: function()
{
@@ -206,6 +206,36 @@ WebInspector.TextRange.prototype = {
},
/**
+ * @param {number} line
+ * @param {number} column
+ * @return {!WebInspector.TextRange}
+ */
+ relativeTo: function(line, column)
+ {
+ var relative = this.clone();
+
+ if (this.startLine == line)
+ relative.startColumn -= column;
+ if (this.endLine == line)
+ relative.endColumn -= column;
+
+ relative.startLine -= line;
+ relative.endLine -= line;
+ return relative;
+ },
+
+ /**
+ * @param {string} text
+ * @return {!WebInspector.SourceRange}
+ */
+ toSourceRange: function(text)
+ {
+ var start = (this.startLine ? text.lineEndings()[this.startLine - 1] + 1 : 0) + this.startColumn;
+ var end = (this.endLine ? text.lineEndings()[this.endLine - 1] + 1 : 0) + this.endColumn;
+ return new WebInspector.SourceRange(start, end - start);
+ },
+
+ /**
* @param {!WebInspector.TextRange} originalRange
* @param {!WebInspector.TextRange} editedRange
* @return {!WebInspector.TextRange}
@@ -235,6 +265,17 @@ WebInspector.TextRange.prototype = {
toString: function()
{
return JSON.stringify(this);
+ },
+
+ /**
+ * @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);
}
}
« no previous file with comments | « Source/core/inspector/InspectorStyleTextEditor.cpp ('k') | Source/devtools/front_end/common/TextUtils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698