diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp index 8eb5bfa45e8..bff14f371c0 100644 --- a/layout/generic/nsTextFrameThebes.cpp +++ b/layout/generic/nsTextFrameThebes.cpp @@ -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), diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 77d0a507471..fb58a293afa 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -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); } diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index acdb6fe2610..7403e994a53 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -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, diff --git a/layout/style/nsStyleContext.cpp b/layout/style/nsStyleContext.cpp index 508e4cf9d32..32b676b9f21 100644 --- a/layout/style/nsStyleContext.cpp +++ b/layout/style/nsStyleContext.cpp @@ -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 diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 92bbee1e4d3..7a07397e059 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -1786,7 +1786,7 @@ nsStyleText::nsStyleText(void) mLetterSpacing.SetNormalValue(); mLineHeight.SetNormalValue(); mTextIndent.SetCoordValue(0); - mWordSpacing.SetNormalValue(); + mWordSpacing = 0; mTextShadow = nsnull; } diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index a78ae8cbf11..ceb9a041f37 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -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 mTextShadow; // [inherited] NULL in case of a zero-length diff --git a/layout/style/test/test_value_computation.html b/layout/style/test/test_value_computation.html index 9f871c69f54..20b949ec77c 100644 --- a/layout/style/test/test_value_computation.html +++ b/layout/style/test/test_value_computation.html @@ -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" ],