Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Forgot FBTrace version of cssPanel.js
  • Loading branch information
jc4rp3nt3r committed Oct 1, 2012
commit 61f8ebd8d4f35563248a194f40c656aa559455bd
8 changes: 4 additions & 4 deletions extension/content/firebug/css/cssPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down
25 changes: 23 additions & 2 deletions trace/FBTrace/chrome/firebug/content/css/cssPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down