Permalink
Browse files

Forgot FBTrace version of cssPanel.js

  • Loading branch information...
1 parent 18a441c commit 61f8ebd8d4f35563248a194f40c656aa559455bd @jc4rp3nt3r committed Oct 1, 2012
Showing with 27 additions and 6 deletions.
  1. +4 −4 extension/content/firebug/css/cssPanel.js
  2. +23 −2 trace/FBTrace/chrome/firebug/content/css/cssPanel.js
@@ -1457,13 +1457,13 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
href = element.ownerDocument.location.href;
if (href.indexOf('.less') !== -1) { // if this is a less file
- var doc = Css.getDocumentForStyleSheet(rule.parentStyleSheet),
- styleSheet = doc ? doc.styleSheets[instance] : null;
+ var oDoc = Css.getDocumentForStyleSheet(rule.parentStyleSheet),
+ oStyleSheet = oDoc ? oDoc.styleSheets[instance] : null;
- if(styleSheet && this.context.sourceCache) {
+ if(oStyleSheet && this.context.sourceCache) {
var regExDotLess = /\/\* ([^:]*):L(\d*) \*\// // regex for parsing dotLess Comments. format: /* /path/css-file.less:L123 */
, iLineIndex = line-1 // a counter for the current line index
- , arrCss = this.context.sourceCache.load(styleSheet.href); // handle to the css doc, type = array of text strings per line
+ , arrCss = this.context.sourceCache.load(oStyleSheet.href); // handle to the css doc, type = array of text strings per line
while(iLineIndex >= 0 && line - iLineIndex < 5) { // prevent index out of bounds and stop looking after 5 lines
if (regExDotLess.test(arrCss[iLineIndex])) {
@@ -1375,14 +1375,35 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
getSourceLink: function(target, rule)
{
var element = rule.parentStyleSheet.ownerNode;
+ var line = getRuleLine(rule);
+ var instance = Css.getInstanceForStyleSheet(rule.parentStyleSheet);
var href = rule.parentStyleSheet.href; // Null means inline
// http://code.google.com/p/fbug/issues/detail?id=452
if (!href)
href = element.ownerDocument.location.href;
+
+ if (href.indexOf('.less') !== -1) { // if this is a less file
+ var oDoc = Css.getDocumentForStyleSheet(rule.parentStyleSheet),
+ oStyleSheet = oDoc ? oDoc.styleSheets[instance] : null;
+
+ if(oStyleSheet && this.context.sourceCache) {
+ var regExDotLess = /\/\* ([^:]*):L(\d*) \*\// // regex for parsing dotLess Comments. format: /* /path/css-file.less:L123 */
+ , iLineIndex = line-1 // a counter for the current line index
+ , arrCss = this.context.sourceCache.load(oStyleSheet.href); // handle to the css doc, type = array of text strings per line
+
+ while(iLineIndex >= 0 && line - iLineIndex < 5) { // prevent index out of bounds and stop looking after 5 lines
+ if (regExDotLess.test(arrCss[iLineIndex])) {
+ var arrMatch = arrCss[iLineIndex].match(regExDotLess);
+ href = arrMatch[1]; // Update the handle to the file
+ line = arrMatch[2]; // and the line based on the comment
+ break;
+ }
+ iLineIndex -= 1;
+ }
+ }
+ }
- var line = getRuleLine(rule);
- var instance = Css.getInstanceForStyleSheet(rule.parentStyleSheet);
var sourceLink = new SourceLink.SourceLink(href, line, "css", rule, instance);
return sourceLink;

0 comments on commit 61f8ebd

Please sign in to comment.