Skip to content

Commit

Permalink
!important must be recognized correctly for fonts (related to issue
Browse files Browse the repository at this point in the history
2495)
  • Loading branch information
SebastianZ committed Apr 29, 2012
1 parent e7e2865 commit cb3ac18
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions extension/content/firebug/css/cssElementPanel.js
Expand Up @@ -80,7 +80,7 @@ CSSElementPanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
CSSFontPropValueTag: CSSFontPropValueTag:
SPAN({"class": "cssFontPropValue"}, SPAN({"class": "cssFontPropValue"},
FOR("part", "$propValueParts", FOR("part", "$propValueParts",
SPAN({"class": "$part.class"}, "$part.value"), SPAN({"class": "$part.type|getClass"}, "$part.value"),
SPAN({"class": "cssFontPropSeparator"}, "$part|getSeparator") SPAN({"class": "cssFontPropSeparator"}, "$part|getSeparator")
) )
), ),
Expand All @@ -90,10 +90,25 @@ CSSElementPanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
if (part.type == "otherProps") if (part.type == "otherProps")
return " "; return " ";


if (part.last) if (part.lastFont || part.type == "important")
return ""; return "";


return ","; return ",";
},

getClass: function(type)
{
switch (type)
{
case "used":
return "cssPropValueUsed";

case "unused":
return "cssPropValueUnused";

default:
return "";
}
} }
}), }),


Expand Down Expand Up @@ -685,8 +700,8 @@ function getFontPropValueParts(element, value)
"fantasy": 1, "fantasy": 1,
"monospace": 1, "monospace": 1,
}; };
const reFontFamilies = new RegExp("^(.*(\\d+(\\.\\d+)?(em|ex|ch|rem|cm|mm|in|pt|pc|px|%)|"+ const reFontFamilies = new RegExp("(^(.*(\\d+(\\.\\d+)?(em|ex|ch|rem|cm|mm|in|pt|pc|px|%)|"+
"x{0,2}-(small|large)|medium|larger|smaller)) (.*)$|.*"); "x{0,2}-(small|large)|medium|larger|smaller)) (.*?)|.*?)( !important)?$");
var matches = reFontFamilies.exec(value); var matches = reFontFamilies.exec(value);
var parts = []; var parts = [];
var i = 0; var i = 0;
Expand All @@ -695,14 +710,14 @@ function getFontPropValueParts(element, value)
return; return;


var fonts; var fonts;
if (matches[6]) if (matches[7])
{ {
parts.push({type: "otherProps", value: matches[1]}); parts.push({type: "otherProps", value: matches[2]});
fonts = matches[6].split(","); fonts = matches[7].split(",");
} }
else else
{ {
fonts = matches[0].split(","); fonts = matches[1].split(",");
} }


var usedFonts = Fonts.getFonts(element); var usedFonts = Fonts.getFonts(element);
Expand All @@ -727,13 +742,15 @@ function getFontPropValueParts(element, value)
} }


if (!isUsedFont) if (!isUsedFont)
parts.push({type: "unused", class: "cssPropValueUnused", value: fonts[i]}); parts.push({type: "unused", value: fonts[i]});

} }


// xxxsz: Domplate doesn't allow to check for the last element in an array yet, // xxxsz: Domplate doesn't allow to check for the last element in an array yet,
// so use this as hack // so use this as hack
parts[parts.length-1].last = true; parts[parts.length-1].lastFont = true;

if (matches[8])
parts.push({type: "important", value: " !important"});


return parts; return parts;
} }
Expand Down

0 comments on commit cb3ac18

Please sign in to comment.