Add dppx and dpcm units to parser dimensions

dppx is currently supported by Firefox > 16.
This can be used to target retina setups:
@media (min-resolution: 2dppx) {}

http://www.w3.org/TR/css3-values/#resolution
This commit is contained in:
Philip Harrison
2012-08-10 15:04:58 +01:00
parent be74f9a837
commit 4c4e2bfdcd
3 changed files with 22 additions and 11 deletions

View File

@@ -691,13 +691,13 @@ less.Parser = function Parser(env) {
var value, c = input.charCodeAt(i);
if ((c > 57 || c < 45) || c === 47) return;
if (value = $(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn|dpi|rem|vw|vh|vm|ch)?/)) {
if (value = $(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn|dpi|dpcm|dppx|rem|vw|vh|vm|ch)?/)) {
return new(tree.Dimension)(value[1], value[2]);
}
},
//
// A Ratio
// A Ratio
//
// 16/9
//
@@ -707,7 +707,7 @@ less.Parser = function Parser(env) {
if (value = $(/^(\d+\/\d+)/)) {
return new(tree.Ratio)(value[1]);
}
}
},
//
@@ -751,13 +751,13 @@ less.Parser = function Parser(env) {
var a, b;
if (! peek(/^[@\w.%-]+\/[@\w.-]+/)) return;
save();
if ((a = $(this.entity)) && $('/') && (b = $(this.entity))) {
return new(tree.Shorthand)(a, b);
}
restore();
},
@@ -1166,18 +1166,18 @@ less.Parser = function Parser(env) {
hasBlock, hasIdentifier;
if (input.charAt(i) !== '@') return;
if (value = $(this['import']) || $(this.media)) {
return value;
}
name = $(/^@[a-z-]+/);
nonVendorSpecificName = name;
if (name.charAt(1) == '-' && name.indexOf('-', 2) > 0) {
nonVendorSpecificName = "@" + name.slice(name.indexOf('-', 2) + 1);
}
switch(nonVendorSpecificName) {
case "@font-face":
hasBlock = true;
@@ -1209,11 +1209,11 @@ less.Parser = function Parser(env) {
hasIdentifier = true;
break;
}
if (hasIdentifier) {
name += " " + ($(/^[^{]+/) || '').trim();
}
if (hasBlock)
{
if (rules = $(this.block)) {