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

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

Issue 220903002: DevTools: wrap DebuggerAgent.Location with DebuggerModel.Location. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: All 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
« no previous file with comments | « Source/devtools/front_end/CPUProfilerModel.js ('k') | Source/devtools/front_end/ConsoleModel.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/CSSStyleModel.js
diff --git a/Source/devtools/front_end/CSSStyleModel.js b/Source/devtools/front_end/CSSStyleModel.js
index e83204509a24e566cc538952693d9706490aeecb..04d84e373d612a7ddc7d39658d597e9d588637a4 100644
--- a/Source/devtools/front_end/CSSStyleModel.js
+++ b/Source/devtools/front_end/CSSStyleModel.js
@@ -30,11 +30,12 @@
/**
* @constructor
- * @extends {WebInspector.Object}
+ * @extends {WebInspector.TargetAwareObject}
* @param {!WebInspector.Target} target
*/
WebInspector.CSSStyleModel = function(target)
{
+ WebInspector.TargetAwareObject.call(this, target);
this._domModel = target.domModel;
this._agent = target.cssAgent();
this._pendingCommandsMajorState = [];
@@ -592,7 +593,7 @@ WebInspector.CSSStyleModel.prototype = {
return uiLocation || null;
},
- __proto__: WebInspector.Object.prototype
+ __proto__: WebInspector.TargetAwareObject.prototype
}
/**
@@ -687,13 +688,35 @@ WebInspector.CSSStyleModel.LiveLocation.prototype = {
* @param {number} lineNumber
* @param {number=} columnNumber
*/
-WebInspector.CSSLocation = function(url, lineNumber, columnNumber)
+WebInspector.CSSLocation = function(target, url, lineNumber, columnNumber)
{
+ this._cssModel = target.cssModel;
this.url = url;
this.lineNumber = lineNumber;
this.columnNumber = columnNumber || 0;
}
+WebInspector.CSSLocation.prototype = {
+ /**
+ * @param {?CSSAgent.StyleSheetId} styleSheetId
+ * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate
+ * @return {?WebInspector.LiveLocation}
+ */
+ createLiveLocation: function(styleSheetId, updateDelegate)
+ {
+ var header = styleSheetId ? this._cssModel.styleSheetHeaderForId(styleSheetId) : null;
+ return new WebInspector.CSSStyleModel.LiveLocation(this._cssModel, header, this, updateDelegate);
+ },
+
+ /**
+ * @return {?WebInspector.UILocation}
+ */
+ toUILocation: function()
+ {
+ return this._cssModel.rawLocationToUILocation(this);
+ }
+}
+
/**
* @constructor
* @param {!WebInspector.CSSStyleModel} cssModel
@@ -981,7 +1004,7 @@ WebInspector.CSSRule.prototype = {
var url = styleSheetHeader.resourceURL();
if (!url)
return;
- this.rawLocation = new WebInspector.CSSLocation(url, this.lineNumberInSource(0), this.columnNumberInSource(0));
+ this.rawLocation = new WebInspector.CSSLocation(this._cssModel.target(), url, this.lineNumberInSource(0), this.columnNumberInSource(0));
},
/**
@@ -1230,8 +1253,8 @@ WebInspector.CSSProperty.prototype = {
var line = forName ? range.startLine : range.endLine;
// End of range is exclusive, so subtract 1 from the end offset.
var column = forName ? range.startColumn : range.endColumn - (this.text && this.text.endsWith(";") ? 2 : 1);
- var rawLocation = new WebInspector.CSSLocation(url, line, column);
- return this.ownerStyle._cssModel.rawLocationToUILocation(rawLocation);
+ var rawLocation = new WebInspector.CSSLocation(this.ownerStyle._cssModel.target(), url, line, column);
+ return rawLocation.toUILocation();
}
}
@@ -1383,7 +1406,7 @@ WebInspector.CSSStyleSheetHeader.prototype = {
rawLocationToUILocation: function(lineNumber, columnNumber)
{
var uiLocation = null;
- var rawLocation = new WebInspector.CSSLocation(this.resourceURL(), lineNumber, columnNumber);
+ var rawLocation = new WebInspector.CSSLocation(this._cssModel.target(), this.resourceURL(), lineNumber, columnNumber);
for (var i = this._sourceMappings.length - 1; !uiLocation && i >= 0; --i)
uiLocation = this._sourceMappings[i].rawLocationToUILocation(rawLocation);
return uiLocation;
« no previous file with comments | « Source/devtools/front_end/CPUProfilerModel.js ('k') | Source/devtools/front_end/ConsoleModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698