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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/CSSProperty.js

Issue 1943763002: DevTools: [SASS] fix CSSWorkspaceBinding.propertyUILocation to account for comments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@super-sass
Patch Set: fix tests Created 4 years, 8 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 | « third_party/WebKit/Source/devtools/front_end/common/TextRange.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/sdk/CSSProperty.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/CSSProperty.js b/third_party/WebKit/Source/devtools/front_end/sdk/CSSProperty.js
index 45b37c0e81c0c919b36e2c039ebe79cf8a909aa4..604613aecdf4c88b5431bbff3b69212a16e6474b 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/CSSProperty.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/CSSProperty.js
@@ -28,6 +28,8 @@ WebInspector.CSSProperty = function(ownerStyle, index, name, value, important, d
this.text = text;
this.range = range ? WebInspector.TextRange.fromObject(range) : null;
this._active = true;
+ this._nameRange = null;
+ this._valueRange = null;
}
/**
@@ -49,6 +51,62 @@ WebInspector.CSSProperty.parsePayload = function(ownerStyle, index, payload)
}
WebInspector.CSSProperty.prototype = {
+ _ensureRanges: function()
+ {
+ if (this._nameRange && this._valueRange)
+ return;
+ var range = this.range;
+ var text = this.text ? new WebInspector.Text(this.text) : null;
+ if (!range || !text)
+ return;
+
+ var nameIndex = text.value().indexOf(this.name);
+ var valueIndex = text.value().lastIndexOf(this.value);
+ if (nameIndex === -1 || valueIndex === -1 || nameIndex > valueIndex)
+ return;
+
+ var nameSourceRange = new WebInspector.SourceRange(nameIndex, this.name.length);
+ var valueSourceRange = new WebInspector.SourceRange(valueIndex, this.value.length);
+
+ this._nameRange = rebase(text.toTextRange(nameSourceRange), range.startLine, range.startColumn);
+ this._valueRange = rebase(text.toTextRange(valueSourceRange), range.startLine, range.startColumn);
+
+ /**
+ * @param {!WebInspector.TextRange} oneLineRange
+ * @param {number} lineOffset
+ * @param {number} columnOffset
+ * @return {!WebInspector.TextRange}
+ */
+ function rebase(oneLineRange, lineOffset, columnOffset)
+ {
+ if (oneLineRange.startLine === 0) {
+ oneLineRange.startColumn += columnOffset;
+ oneLineRange.endColumn += columnOffset;
+ }
+ oneLineRange.startLine += lineOffset;
+ oneLineRange.endLine += lineOffset;
+ return oneLineRange;
+ }
+ },
+
+ /**
+ * @return {?WebInspector.TextRange}
+ */
+ nameRange: function()
+ {
+ this._ensureRanges();
+ return this._nameRange;
+ },
+
+ /**
+ * @return {?WebInspector.TextRange}
+ */
+ valueRange: function()
+ {
+ this._ensureRanges();
+ return this._valueRange;
+ },
+
/**
* @param {!WebInspector.CSSModel.Edit} edit
*/
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/common/TextRange.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698