зеркало из https://github.com/mozilla/pjs.git
Bug 412237. Don't parse negative fontsize attributes in MathML elements. r+sr=dbaron
This commit is contained in:
Родитель
22e51a82e6
Коммит
9dd304552a
|
@ -222,7 +222,7 @@ Implementation here:
|
||||||
/* static */ PRBool
|
/* static */ PRBool
|
||||||
nsMathMLElement::ParseNumericValue(const nsString& aString,
|
nsMathMLElement::ParseNumericValue(const nsString& aString,
|
||||||
nsCSSValue& aCSSValue,
|
nsCSSValue& aCSSValue,
|
||||||
PRBool aRequireLengthUnit)
|
PRUint32 aFlags)
|
||||||
{
|
{
|
||||||
nsAutoString str(aString);
|
nsAutoString str(aString);
|
||||||
str.CompressWhitespace(); // aString is const in this code...
|
str.CompressWhitespace(); // aString is const in this code...
|
||||||
|
@ -237,6 +237,8 @@ nsMathMLElement::ParseNumericValue(const nsString& aString,
|
||||||
PRInt32 i = 0;
|
PRInt32 i = 0;
|
||||||
PRUnichar c = str[0];
|
PRUnichar c = str[0];
|
||||||
if (c == '-') {
|
if (c == '-') {
|
||||||
|
if (!(aFlags & PARSE_ALLOW_NEGATIVE))
|
||||||
|
return PR_FALSE;
|
||||||
number.Append(c);
|
number.Append(c);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
@ -270,16 +272,16 @@ nsMathMLElement::ParseNumericValue(const nsString& aString,
|
||||||
|
|
||||||
nsCSSUnit cssUnit;
|
nsCSSUnit cssUnit;
|
||||||
if (unit.IsEmpty()) {
|
if (unit.IsEmpty()) {
|
||||||
if (aRequireLengthUnit) {
|
if (aFlags & PARSE_ALLOW_UNITLESS) {
|
||||||
// We are supposed to have a length unit, but there isn't one.
|
// no explicit unit, this is a number that will act as a multiplier
|
||||||
|
cssUnit = eCSSUnit_Number;
|
||||||
|
} else {
|
||||||
|
// We are supposed to have a unit, but there isn't one.
|
||||||
// If the value is 0 we can just call it "pixels" otherwise
|
// If the value is 0 we can just call it "pixels" otherwise
|
||||||
// this is illegal.
|
// this is illegal.
|
||||||
if (floatValue != 0.0)
|
if (floatValue != 0.0)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
cssUnit = eCSSUnit_Pixel;
|
cssUnit = eCSSUnit_Pixel;
|
||||||
} else {
|
|
||||||
// no explicit unit, this is a number that will act as a multiplier
|
|
||||||
cssUnit = eCSSUnit_Number;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (unit.EqualsLiteral("%")) {
|
else if (unit.EqualsLiteral("%")) {
|
||||||
|
@ -328,7 +330,7 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
||||||
if (value && value->Type() == nsAttrValue::eString &&
|
if (value && value->Type() == nsAttrValue::eString &&
|
||||||
aData->mFontData->mScriptMinSize.GetUnit() == eCSSUnit_Null) {
|
aData->mFontData->mScriptMinSize.GetUnit() == eCSSUnit_Null) {
|
||||||
ParseNumericValue(value->GetStringValue(),
|
ParseNumericValue(value->GetStringValue(),
|
||||||
aData->mFontData->mScriptMinSize, PR_TRUE);
|
aData->mFontData->mScriptMinSize, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
value = aAttributes->GetAttr(nsGkAtoms::scriptlevel_);
|
value = aAttributes->GetAttr(nsGkAtoms::scriptlevel_);
|
||||||
|
@ -363,7 +365,7 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
||||||
if (value && value->Type() == nsAttrValue::eString &&
|
if (value && value->Type() == nsAttrValue::eString &&
|
||||||
aData->mFontData->mSize.GetUnit() == eCSSUnit_Null) {
|
aData->mFontData->mSize.GetUnit() == eCSSUnit_Null) {
|
||||||
nsAutoString str(value->GetStringValue());
|
nsAutoString str(value->GetStringValue());
|
||||||
if (!ParseNumericValue(str, aData->mFontData->mSize, PR_TRUE) &&
|
if (!ParseNumericValue(str, aData->mFontData->mSize, 0) &&
|
||||||
parseSizeKeywords) {
|
parseSizeKeywords) {
|
||||||
static const char sizes[3][7] = { "small", "normal", "big" };
|
static const char sizes[3][7] = { "small", "normal", "big" };
|
||||||
static const PRInt32 values[NS_ARRAY_LENGTH(sizes)] = {
|
static const PRInt32 values[NS_ARRAY_LENGTH(sizes)] = {
|
||||||
|
|
|
@ -78,9 +78,13 @@ public:
|
||||||
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
|
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
|
||||||
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
|
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PARSE_ALLOW_UNITLESS = 0x01, // unitless 0 will be turned into 0px
|
||||||
|
PARSE_ALLOW_NEGATIVE = 0x02
|
||||||
|
};
|
||||||
static PRBool ParseNumericValue(const nsString& aString,
|
static PRBool ParseNumericValue(const nsString& aString,
|
||||||
nsCSSValue& aCSSValue,
|
nsCSSValue& aCSSValue,
|
||||||
PRBool aRequireLengthUnit);
|
PRUint32 aFlags);
|
||||||
|
|
||||||
static void MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
static void MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
||||||
nsRuleData* aRuleData);
|
nsRuleData* aRuleData);
|
||||||
|
|
|
@ -218,7 +218,9 @@ public:
|
||||||
static PRBool
|
static PRBool
|
||||||
ParseNumericValue(const nsString& aString,
|
ParseNumericValue(const nsString& aString,
|
||||||
nsCSSValue& aCSSValue) {
|
nsCSSValue& aCSSValue) {
|
||||||
return nsMathMLElement::ParseNumericValue(aString, aCSSValue, PR_FALSE);
|
return nsMathMLElement::ParseNumericValue(aString, aCSSValue,
|
||||||
|
nsMathMLElement::PARSE_ALLOW_NEGATIVE |
|
||||||
|
nsMathMLElement::PARSE_ALLOW_UNITLESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static nscoord
|
static nscoord
|
||||||
|
|
Загрузка…
Ссылка в новой задаче