diff --git a/mozilla/content/base/src/nsRuleNode.cpp b/mozilla/content/base/src/nsRuleNode.cpp index d4b3871e4ed..ee9c9b55294 100644 --- a/mozilla/content/base/src/nsRuleNode.cpp +++ b/mozilla/content/base/src/nsRuleNode.cpp @@ -1623,7 +1623,7 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContex static void SetFont(nsIPresContext* aPresContext, nsStyleContext* aContext, - nscoord aMinFontSize, PRBool aUseDocumentFonts, PRBool aChromeOverride, + nscoord aMinFontSize, PRBool aUseDocumentFonts, PRBool aIsGeneric, const nsRuleDataFont& aFontData, const nsFont& aDefaultFont, const nsStyleFont* aParentFont, nsStyleFont* aFont, PRBool& aInherited) @@ -1637,7 +1637,7 @@ SetFont(nsIPresContext* aPresContext, nsStyleContext* aContext, if (eCSSUnit_String == aFontData.mFamily.GetUnit()) { // set the correct font if we are using DocumentFonts OR we are overriding for XUL // MJA: bug 31816 - if (aChromeOverride || aUseDocumentFonts) { + if (aUseDocumentFonts) { if (!aIsGeneric) { // only bother appending fallback fonts if this isn't a fallback generic font itself aFont->mFont.name.Append((PRUnichar)','); @@ -1855,13 +1855,7 @@ SetFont(nsIPresContext* aPresContext, nsStyleContext* aContext, aFont->mSize = nsStyleFont::ZoomText(aPresContext, aFont->mSize); // enforce the user' specified minimum font-size on the value that we expose - if (aChromeOverride) { - // the chrome is unconstrained, it always uses our cascading size - aFont->mFont.size = aFont->mSize; - } - else { - aFont->mFont.size = PR_MAX(aFont->mSize, aMinFontSize); - } + aFont->mFont.size = PR_MAX(aFont->mSize, aMinFontSize); // font-size-adjust: number, none, inherit if (eCSSUnit_Number == aFontData.mSizeAdjust.GetUnit()) { @@ -1887,7 +1881,7 @@ static void SetGenericFont(nsIPresContext* aPresContext, nsStyleContext* aContext, const nsRuleDataFont& aFontData, PRUint8 aGenericFontID, nscoord aMinFontSize, PRBool aUseDocumentFonts, - PRBool aChromeOverride, nsStyleFont* aFont) + nsStyleFont* aFont) { // walk up the contexts until a context with the desired generic font nsAutoVoidArray contextPath; @@ -1950,8 +1944,7 @@ SetGenericFont(nsIPresContext* aPresContext, nsStyleContext* aContext, // Compute the delta from the information that the rules specified fontData.mFamily.Reset(); // avoid unnecessary operations in SetFont() - SetFont(aPresContext, context, aMinFontSize, - aUseDocumentFonts, aChromeOverride, PR_TRUE, + SetFont(aPresContext, context, aMinFontSize, aUseDocumentFonts, PR_TRUE, fontData, *defaultFont, &parentFont, aFont, dummy); // XXX Not sure if we need to do this here @@ -1967,8 +1960,7 @@ SetGenericFont(nsIPresContext* aPresContext, nsStyleContext* aContext, // Finish off by applying our own rules. In this case, aFontData // already has the current cascading information that we want. We // can just compute the delta from the parent. - SetFont(aPresContext, aContext, aMinFontSize, - aUseDocumentFonts, aChromeOverride, PR_TRUE, + SetFont(aPresContext, aContext, aMinFontSize, aUseDocumentFonts, PR_TRUE, aFontData, *defaultFont, &parentFont, aFont, dummy); } @@ -2018,8 +2010,9 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, // See if there is a minimum font-size constraint to honor nscoord minimumFontSize = 0; // unconstrained by default mPresContext->GetCachedIntPref(kPresContext_MinimumFontSize, minimumFontSize); + if (minimumFontSize < 0) + minimumFontSize = 0; - PRBool chromeOverride = PR_FALSE; PRBool useDocumentFonts = PR_TRUE; // Figure out if we are a generic font @@ -2030,7 +2023,7 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, // MJA: bug 31816 // if we are not using document fonts, but this is a XUL document, - // then we set the chromeOverride flag to use the document fonts anyway + // then we use the document fonts anyway mPresContext->GetCachedBoolPref(kPresContext_UseDocumentFonts, useDocumentFonts); if (!useDocumentFonts) { // check if the prefs have been disabled for this shell @@ -2049,15 +2042,14 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, // We only need to know this to determine if we have to use the // document fonts (overriding the useDocumentFonts flag), or to // determine if we have to override the minimum font-size constraint. - if (!useDocumentFonts || minimumFontSize > 0) { - chromeOverride = IsChrome(mPresContext); - // XXXldb Just fix up |useDocumentFonts| here and drop the - // |chromeOverride| variable from here on! + if ((!useDocumentFonts || minimumFontSize > 0) && IsChrome(mPresContext)) { + useDocumentFonts = PR_TRUE; + minimumFontSize = 0; } // If we don't have to use document fonts, then we are only entitled // to use the user's default variable-width font and fixed-width font - if (!useDocumentFonts && !chromeOverride) { + if (!useDocumentFonts) { if (generic != kGenericFont_moz_fixed) generic = kGenericFont_NONE; } @@ -2070,15 +2062,14 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsFont* defaultFont; mPresContext->GetDefaultFont(generic, &defaultFont); SetFont(mPresContext, aContext, minimumFontSize, - useDocumentFonts, chromeOverride, PR_FALSE, + useDocumentFonts, PR_FALSE, fontData, *defaultFont, parentFont, font, inherited); } else { // re-calculate the font as a generic font inherited = PR_TRUE; SetGenericFont(mPresContext, aContext, fontData, - generic, minimumFontSize, useDocumentFonts, - chromeOverride, font); + generic, minimumFontSize, useDocumentFonts, font); } // Set our generic font's bit to inform our descendants font->mFlags &= ~NS_STYLE_FONT_FACE_MASK; diff --git a/mozilla/content/html/style/src/nsCSSDeclaration.cpp b/mozilla/content/html/style/src/nsCSSDeclaration.cpp index a5e1bed0082..3d923b016e6 100644 --- a/mozilla/content/html/style/src/nsCSSDeclaration.cpp +++ b/mozilla/content/html/style/src/nsCSSDeclaration.cpp @@ -194,16 +194,27 @@ PRBool nsCSSDeclaration::AppendValueToString(nsCSSProperty aProperty, nsAString& } break; case eCSSType_Rect: { const nsCSSRect *rect = NS_STATIC_CAST(const nsCSSRect*, storage); - aResult.Append(NS_LITERAL_STRING("rect(")); - AppendCSSValueToString(aProperty, rect->mTop, aResult); - NS_NAMED_LITERAL_STRING(comma, ", "); - aResult.Append(comma); - AppendCSSValueToString(aProperty, rect->mRight, aResult); - aResult.Append(comma); - AppendCSSValueToString(aProperty, rect->mBottom, aResult); - aResult.Append(comma); - AppendCSSValueToString(aProperty, rect->mLeft, aResult); - aResult.Append(PRUnichar(')')); + if (rect->mTop.GetUnit() == eCSSUnit_Inherit || + rect->mTop.GetUnit() == eCSSUnit_Initial) { + NS_ASSERTION(rect->mRight.GetUnit() == rect->mTop.GetUnit(), + "Top inherit or initial, right isn't. Fix the parser!"); + NS_ASSERTION(rect->mBottom.GetUnit() == rect->mTop.GetUnit(), + "Top inherit or initial, bottom isn't. Fix the parser!"); + NS_ASSERTION(rect->mLeft.GetUnit() == rect->mTop.GetUnit(), + "Top inherit or initial, left isn't. Fix the parser!"); + AppendCSSValueToString(aProperty, rect->mTop, aResult); + } else { + aResult.Append(NS_LITERAL_STRING("rect(")); + AppendCSSValueToString(aProperty, rect->mTop, aResult); + NS_NAMED_LITERAL_STRING(comma, ", "); + aResult.Append(comma); + AppendCSSValueToString(aProperty, rect->mRight, aResult); + aResult.Append(comma); + AppendCSSValueToString(aProperty, rect->mBottom, aResult); + aResult.Append(comma); + AppendCSSValueToString(aProperty, rect->mLeft, aResult); + aResult.Append(PRUnichar(')')); + } } break; case eCSSType_ValueList: { const nsCSSValueList* val = diff --git a/mozilla/content/html/style/src/nsCSSParser.cpp b/mozilla/content/html/style/src/nsCSSParser.cpp index 17a574e4768..cf08f6e3f6f 100644 --- a/mozilla/content/html/style/src/nsCSSParser.cpp +++ b/mozilla/content/html/style/src/nsCSSParser.cpp @@ -4760,24 +4760,30 @@ CSSParserImpl::DoParseRect(nsCSSRect& aRect, nsresult& aErrorCode) if (! GetToken(aErrorCode, PR_TRUE)) { return PR_FALSE; } - if ((eCSSToken_Ident == mToken.mType) && - mToken.mIdent.EqualsIgnoreCase("auto")) { - if (ExpectEndProperty(aErrorCode, PR_TRUE)) { - aRect.SetAllSidesTo(nsCSSValue(eCSSUnit_Auto)); - return PR_TRUE; - } - } else if ((eCSSToken_Ident == mToken.mType) && - mToken.mIdent.EqualsIgnoreCase("inherit")) { - if (ExpectEndProperty(aErrorCode, PR_TRUE)) { - aRect.SetAllSidesTo(nsCSSValue(eCSSUnit_Inherit)); - return PR_TRUE; - } - } - else if ((eCSSToken_Ident == mToken.mType) && - mToken.mIdent.EqualsIgnoreCase("-moz-initial")) { - if (ExpectEndProperty(aErrorCode, PR_TRUE)) { - aRect.SetAllSidesTo(nsCSSValue(eCSSUnit_Initial)); - return PR_TRUE; + if (eCSSToken_Ident == mToken.mType) { + nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(mToken.mIdent); + switch (keyword) { + case eCSSKeyword_auto: + if (ExpectEndProperty(aErrorCode, PR_TRUE)) { + aRect.SetAllSidesTo(nsCSSValue(eCSSUnit_Auto)); + return PR_TRUE; + } + break; + case eCSSKeyword_inherit: + if (ExpectEndProperty(aErrorCode, PR_TRUE)) { + aRect.SetAllSidesTo(nsCSSValue(eCSSUnit_Inherit)); + return PR_TRUE; + } + break; + case eCSSKeyword__moz_initial: + if (ExpectEndProperty(aErrorCode, PR_TRUE)) { + aRect.SetAllSidesTo(nsCSSValue(eCSSUnit_Initial)); + return PR_TRUE; + } + break; + default: + UngetToken(); + break; } } else if ((eCSSToken_Function == mToken.mType) && mToken.mIdent.EqualsIgnoreCase("rect")) { @@ -5147,11 +5153,12 @@ PRBool CSSParserImpl::ParseFamily(nsresult& aErrorCode, nsCSSValue& aValue) } if (eCSSToken_Ident == tk->mType) { if (firstOne) { - if (tk->mIdent.EqualsIgnoreCase("inherit")) { + nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(tk->mIdent); + if (keyword == eCSSKeyword_inherit) { aValue.SetInheritValue(); return PR_TRUE; } - else if (tk->mIdent.EqualsIgnoreCase("initial")) { + else if (keyword == eCSSKeyword__moz_initial) { aValue.SetInitialValue(); return PR_TRUE; }