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

Side by Side Diff: Source/devtools/front_end/sdk/CSSStyleModel.js

Issue 404763002: DevTools: Inject styleSheetId in WebInspector.CSSLocation constructor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 }, 725 },
726 726
727 __proto__: WebInspector.LiveLocation.prototype 727 __proto__: WebInspector.LiveLocation.prototype
728 } 728 }
729 729
730 /** 730 /**
731 * @constructor 731 * @constructor
732 * @implements {WebInspector.RawLocation} 732 * @implements {WebInspector.RawLocation}
733 * @extends {WebInspector.SDKObject} 733 * @extends {WebInspector.SDKObject}
734 * @param {!WebInspector.Target} target 734 * @param {!WebInspector.Target} target
735 * @param {?CSSAgent.StyleSheetId} styleSheetId
735 * @param {string} url 736 * @param {string} url
736 * @param {number} lineNumber 737 * @param {number} lineNumber
737 * @param {number=} columnNumber 738 * @param {number=} columnNumber
738 */ 739 */
739 WebInspector.CSSLocation = function(target, url, lineNumber, columnNumber) 740 WebInspector.CSSLocation = function(target, styleSheetId, url, lineNumber, colum nNumber)
vsevik 2014/07/18 13:44:54 Let's make CSSLocation that always has a style she
740 { 741 {
741 WebInspector.SDKObject.call(this, target); 742 WebInspector.SDKObject.call(this, target);
742 this._cssModel = target.cssModel; 743 this._cssModel = target.cssModel;
744 this._styleSheetId = styleSheetId;
743 this.url = url; 745 this.url = url;
744 this.lineNumber = lineNumber; 746 this.lineNumber = lineNumber;
745 this.columnNumber = columnNumber || 0; 747 this.columnNumber = columnNumber || 0;
746 } 748 }
747 749
748 WebInspector.CSSLocation.prototype = { 750 WebInspector.CSSLocation.prototype = {
749 /** 751 /**
750 * @param {?CSSAgent.StyleSheetId} styleSheetId
751 * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDel egate 752 * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDel egate
752 * @return {?WebInspector.LiveLocation} 753 * @return {?WebInspector.LiveLocation}
753 */ 754 */
754 createLiveLocation: function(styleSheetId, updateDelegate) 755 createLiveLocation: function(updateDelegate)
755 { 756 {
756 var header = styleSheetId ? this._cssModel.styleSheetHeaderForId(styleSh eetId) : null; 757 var header = this._styleSheetId ? this._cssModel.styleSheetHeaderForId(t his._styleSheetId) : null;
757 return new WebInspector.CSSStyleModel.LiveLocation(this._cssModel, heade r, this, updateDelegate); 758 return new WebInspector.CSSStyleModel.LiveLocation(this._cssModel, heade r, this, updateDelegate);
758 }, 759 },
759 760
760 /** 761 /**
761 * @return {?WebInspector.UILocation} 762 * @return {?WebInspector.UILocation}
762 */ 763 */
763 toUILocation: function() 764 toUILocation: function()
764 { 765 {
765 return this._cssModel.rawLocationToUILocation(this); 766 return this._cssModel.rawLocationToUILocation(this);
766 }, 767 },
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 1103
1103 _setRawLocationAndFrameId: function() 1104 _setRawLocationAndFrameId: function()
1104 { 1105 {
1105 if (!this.styleSheetId) 1106 if (!this.styleSheetId)
1106 return; 1107 return;
1107 var styleSheetHeader = this._cssModel.styleSheetHeaderForId(this.styleSh eetId); 1108 var styleSheetHeader = this._cssModel.styleSheetHeaderForId(this.styleSh eetId);
1108 this.frameId = styleSheetHeader.frameId; 1109 this.frameId = styleSheetHeader.frameId;
1109 var url = styleSheetHeader.resourceURL(); 1110 var url = styleSheetHeader.resourceURL();
1110 if (!url) 1111 if (!url)
1111 return; 1112 return;
1112 this.rawLocation = new WebInspector.CSSLocation(this._cssModel.target(), url, this.lineNumberInSource(0), this.columnNumberInSource(0)); 1113 this.rawLocation = new WebInspector.CSSLocation(this._cssModel.target(), this.styleSheetId, url, this.lineNumberInSource(0), this.columnNumberInSource(0 ));
1113 }, 1114 },
1114 1115
1115 /** 1116 /**
1116 * @return {string} 1117 * @return {string}
1117 */ 1118 */
1118 resourceURL: function() 1119 resourceURL: function()
1119 { 1120 {
1120 if (!this.styleSheetId) 1121 if (!this.styleSheetId)
1121 return ""; 1122 return "";
1122 var styleSheetHeader = this._cssModel.styleSheetHeaderForId(this.styleSh eetId); 1123 var styleSheetHeader = this._cssModel.styleSheetHeaderForId(this.styleSh eetId);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 else 1355 else
1355 this.setText(this.text.substring(2, this.text.length - 2).trim(), tr ue, true, userCallback); 1356 this.setText(this.text.substring(2, this.text.length - 2).trim(), tr ue, true, userCallback);
1356 }, 1357 },
1357 1358
1358 /** 1359 /**
1359 * @param {boolean} forName 1360 * @param {boolean} forName
1360 * @return {?WebInspector.UILocation} 1361 * @return {?WebInspector.UILocation}
1361 */ 1362 */
1362 uiLocation: function(forName) 1363 uiLocation: function(forName)
1363 { 1364 {
1364 if (!this.range || !this.ownerStyle || !this.ownerStyle.parentRule) 1365 if (!this.range || !this.ownerStyle || !this.ownerStyle.parentRule || !t his.ownerStyle.styleSheetId)
1365 return null; 1366 return null;
1366 1367
1367 var url = this.ownerStyle.parentRule.resourceURL(); 1368 var url = this.ownerStyle.parentRule.resourceURL();
1368 if (!url) 1369 if (!url)
1369 return null; 1370 return null;
1370 1371
1371 var range = this.range; 1372 var range = this.range;
1372 var line = forName ? range.startLine : range.endLine; 1373 var line = forName ? range.startLine : range.endLine;
1373 // End of range is exclusive, so subtract 1 from the end offset. 1374 // End of range is exclusive, so subtract 1 from the end offset.
1374 var column = forName ? range.startColumn : range.endColumn - (this.text && this.text.endsWith(";") ? 2 : 1); 1375 var column = forName ? range.startColumn : range.endColumn - (this.text && this.text.endsWith(";") ? 2 : 1);
1375 var rawLocation = new WebInspector.CSSLocation(this.ownerStyle._cssModel .target(), url, line, column); 1376 var rawLocation = new WebInspector.CSSLocation(this.ownerStyle._cssModel .target(), this.ownerStyle.styleSheetId, url, line, column);
1376 return rawLocation.toUILocation(); 1377 return rawLocation.toUILocation();
1377 } 1378 }
1378 } 1379 }
1379 1380
1380 /** 1381 /**
1381 * @constructor 1382 * @constructor
1382 * @param {!CSSAgent.MediaQueryExpression} payload 1383 * @param {!CSSAgent.MediaQueryExpression} payload
1383 */ 1384 */
1384 WebInspector.CSSMediaQueryExpression = function(payload) 1385 WebInspector.CSSMediaQueryExpression = function(payload)
1385 { 1386 {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 }, 1611 },
1611 1612
1612 /** 1613 /**
1613 * @param {number} lineNumber 1614 * @param {number} lineNumber
1614 * @param {number=} columnNumber 1615 * @param {number=} columnNumber
1615 * @return {?WebInspector.UILocation} 1616 * @return {?WebInspector.UILocation}
1616 */ 1617 */
1617 rawLocationToUILocation: function(lineNumber, columnNumber) 1618 rawLocationToUILocation: function(lineNumber, columnNumber)
1618 { 1619 {
1619 var uiLocation = null; 1620 var uiLocation = null;
1620 var rawLocation = new WebInspector.CSSLocation(this._cssModel.target(), this.resourceURL(), lineNumber, columnNumber); 1621 var rawLocation = new WebInspector.CSSLocation(this._cssModel.target(), this.id, this.resourceURL(), lineNumber, columnNumber);
1621 for (var i = this._sourceMappings.length - 1; !uiLocation && i >= 0; --i ) 1622 for (var i = this._sourceMappings.length - 1; !uiLocation && i >= 0; --i )
1622 uiLocation = this._sourceMappings[i].rawLocationToUILocation(rawLoca tion); 1623 uiLocation = this._sourceMappings[i].rawLocationToUILocation(rawLoca tion);
1623 return uiLocation; 1624 return uiLocation;
1624 }, 1625 },
1625 1626
1626 /** 1627 /**
1627 * @param {!WebInspector.SourceMapping} sourceMapping 1628 * @param {!WebInspector.SourceMapping} sourceMapping
1628 */ 1629 */
1629 pushSourceMapping: function(sourceMapping) 1630 pushSourceMapping: function(sourceMapping)
1630 { 1631 {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 for (var i = 0; i < callbacks.length; ++i) 1841 for (var i = 0; i < callbacks.length; ++i)
1841 callbacks[i](computedStyle); 1842 callbacks[i](computedStyle);
1842 } 1843 }
1843 } 1844 }
1844 } 1845 }
1845 1846
1846 /** 1847 /**
1847 * @type {!WebInspector.CSSStyleModel} 1848 * @type {!WebInspector.CSSStyleModel}
1848 */ 1849 */
1849 WebInspector.cssModel; 1850 WebInspector.cssModel;
OLDNEW
« no previous file with comments | « Source/devtools/front_end/elements/StylesSidebarPane.js ('k') | Source/devtools/front_end/sdk/Linkifier.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698