From 3cde644d8c67c20056922d5d5833926ea4025be3 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Sun, 8 Nov 2015 14:49:02 -0800 Subject: [PATCH] Bug 1038663 (part 5, attempt 2) - Change GetSpacingFlags(). r=heycam. --- layout/generic/nsTextFrame.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index fcfbe3f06d5c..30adc9e14074 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -1645,6 +1645,26 @@ WordSpacing(nsIFrame* aFrame, const nsStyleText* aStyleText = nullptr) return 0; } +// Returns gfxTextRunFactory::TEXT_ENABLE_SPACING if non-standard +// letter-spacing or word-spacing is present. +static uint32_t +GetSpacingFlags(nsIFrame* aFrame, const nsStyleText* aStyleText = nullptr) +{ + if (aFrame->IsSVGText()) { + return 0; + } + + const nsStyleText* styleText = aFrame->StyleText(); + const nsStyleCoord& ls = styleText->mLetterSpacing; + const nsStyleCoord& ws = styleText->mWordSpacing; + + bool nonStandardSpacing = + (eStyleUnit_Coord == ls.GetUnit() && ls.GetCoordValue() != 0) || + (eStyleUnit_Coord == ws.GetUnit() && ws.GetCoordValue() != 0); + + return nonStandardSpacing ? gfxTextRunFactory::TEXT_ENABLE_SPACING : 0; +} + bool BuildTextRunsScanner::ContinueTextRunAcrossFrames(nsTextFrame* aFrame1, nsTextFrame* aFrame2) { @@ -1796,12 +1816,6 @@ BuildTextRunsScanner::GetNextBreakBeforeFrame(uint32_t* aIndex) return static_cast(mLineBreakBeforeFrames.ElementAt(index)); } -static uint32_t -GetSpacingFlags(nscoord spacing) -{ - return spacing ? gfxTextRunFactory::TEXT_ENABLE_SPACING : 0; -} - static gfxFontGroup* GetFontGroupForFrame(nsIFrame* aFrame, float aFontSizeInflation, nsFontMetrics** aOutFontMetrics = nullptr) @@ -1957,8 +1971,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer) if (NS_STYLE_TEXT_TRANSFORM_NONE != textStyle->mTextTransform) { anyTextTransformStyle = true; } - textFlags |= GetSpacingFlags(LetterSpacing(f)); - textFlags |= GetSpacingFlags(WordSpacing(f)); + textFlags |= GetSpacingFlags(f); nsTextFrameUtils::CompressionMode compression = GetCSSWhitespaceToCompressionMode(f, textStyle); if ((enabledJustification || f->ShouldSuppressLineBreak()) &&