Make 'word-spacing: normal' just compute to '0', since that's what CSS 2.1 says to do, and thus change nsStyleText::mWordSpacing from nsStyleCoord to nscoord. (Bug 470705) r+sr=roc

This commit is contained in:
L. David Baron 2008-12-27 20:58:14 -05:00
parent d67ed87895
commit 8458c5b6b6
7 changed files with 25 additions and 17 deletions

View File

@ -1359,9 +1359,8 @@ BuildTextRunsScanner::GetNextBreakBeforeFrame(PRUint32* aIndex)
}
static PRUint32
GetSpacingFlags(const nsStyleCoord& aStyleCoord)
GetSpacingFlags(nscoord spacing)
{
nscoord spacing = StyleToCoord(aStyleCoord);
if (!spacing)
return 0;
if (spacing > 0)
@ -1529,7 +1528,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
if (NS_STYLE_TEXT_TRANSFORM_NONE != textStyle->mTextTransform) {
anyTextTransformStyle = PR_TRUE;
}
textFlags |= GetSpacingFlags(textStyle->mLetterSpacing);
textFlags |= GetSpacingFlags(StyleToCoord(textStyle->mLetterSpacing));
textFlags |= GetSpacingFlags(textStyle->mWordSpacing);
nsTextFrameUtils::CompressionMode compression =
CSSWhitespaceToCompressionMode[textStyle->mWhiteSpace];
@ -2140,7 +2139,7 @@ public:
mLineContainer(aLineContainer),
mFrame(aFrame), mStart(aStart), mTempIterator(aStart),
mTabWidths(nsnull), mLength(aLength),
mWordSpacing(StyleToCoord(mTextStyle->mWordSpacing)),
mWordSpacing(mTextStyle->mWordSpacing),
mLetterSpacing(StyleToCoord(mTextStyle->mLetterSpacing)),
mJustificationSpacing(0),
mHyphenWidth(-1),
@ -2163,7 +2162,7 @@ public:
mFrame(aFrame), mStart(aStart), mTempIterator(aStart),
mTabWidths(nsnull),
mLength(aFrame->GetContentLength()),
mWordSpacing(StyleToCoord(mTextStyle->mWordSpacing)),
mWordSpacing(mTextStyle->mWordSpacing),
mLetterSpacing(StyleToCoord(mTextStyle->mLetterSpacing)),
mJustificationSpacing(0),
mHyphenWidth(-1),

View File

@ -2129,7 +2129,7 @@ nsComputedDOMStyle::GetWordSpacing(nsIDOMCSSValue** aValue)
nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
SetValueToCoord(val, GetStyleText()->mWordSpacing);
val->SetAppUnits(GetStyleText()->mWordSpacing);
return CallQueryInterface(val, aValue);
}

View File

@ -3006,9 +3006,22 @@ nsRuleNode::ComputeTextData(void* aStartStruct,
NS_STYLE_WHITESPACE_NORMAL, 0);
// word-spacing: normal, length, inherit
SetCoord(textData.mWordSpacing, text->mWordSpacing, parentText->mWordSpacing,
SETCOORD_LH | SETCOORD_NORMAL | SETCOORD_INITIAL_NORMAL,
aContext, mPresContext, inherited);
nsStyleCoord tempCoord;
if (SetCoord(textData.mWordSpacing, tempCoord,
nsStyleCoord(parentText->mWordSpacing),
SETCOORD_LH | SETCOORD_NORMAL | SETCOORD_INITIAL_NORMAL,
aContext, mPresContext, inherited)) {
if (tempCoord.GetUnit() == eStyleUnit_Coord) {
text->mWordSpacing = tempCoord.GetCoordValue();
} else if (tempCoord.GetUnit() == eStyleUnit_Normal) {
text->mWordSpacing = 0;
} else {
NS_NOTREACHED("unexpected unit");
}
} else {
NS_ASSERTION(textData.mWordSpacing.GetUnit() == eCSSUnit_Null,
"unexpected unit");
}
// word-wrap: enum, normal, inherit, initial
SetDiscrete(textData.mWordWrap, text->mWordWrap, inherited,

View File

@ -707,9 +707,8 @@ void nsStyleContext::DumpRegressionData(nsPresContext* aPresContext, FILE* out,
text->mLineHeight.ToString(str);
fprintf(out, "%s ", NS_ConvertUTF16toUTF8(str).get());
text->mTextIndent.ToString(str);
fprintf(out, "%s ", NS_ConvertUTF16toUTF8(str).get());
text->mWordSpacing.ToString(str);
fprintf(out, "%s ", NS_ConvertUTF16toUTF8(str).get());
fprintf(out, "%s %d", NS_ConvertUTF16toUTF8(str).get(),
(int)text->mWordSpacing);
fprintf(out, "\" />\n");
// TEXT RESET

View File

@ -1786,7 +1786,7 @@ nsStyleText::nsStyleText(void)
mLetterSpacing.SetNormalValue();
mLineHeight.SetNormalValue();
mTextIndent.SetCoordValue(0);
mWordSpacing.SetNormalValue();
mWordSpacing = 0;
mTextShadow = nsnull;
}

View File

@ -787,7 +787,7 @@ struct nsStyleText {
nsStyleCoord mLetterSpacing; // [inherited] coord, normal
nsStyleCoord mLineHeight; // [inherited] coord, factor, normal
nsStyleCoord mTextIndent; // [inherited] coord, percent
nsStyleCoord mWordSpacing; // [inherited] coord, normal
nscoord mWordSpacing; // [inherited]
nsRefPtr<nsCSSShadowArray> mTextShadow; // [inherited] NULL in case of a zero-length

View File

@ -49,9 +49,6 @@ var gBadComputed = {
// The 'medium' keyword should be computing to '3px', not 'medium'.
"outline-width": [ "3px" ],
// 'normal' should compute to 0
"word-spacing": [ "0", "0px", "-0em" ],
// These values are treated as auto.
"page-break-after": [ "avoid" ],
"page-break-before": [ "avoid" ],