From 90b8e844aa72513e0f109936de16de2844863279 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 5 Nov 2015 16:33:37 -0800 Subject: [PATCH] Bug 1038663 (part 5) - Change GetSpacingFlags(). r=heycam. Again, this doesn't make sense in isolation, but it will make it easier to allow for percentage word-spacing in a subsequent patch. --HG-- extra : rebase_source : 5a120273b4191ae3ac9ae0532e56eb870558d4d6 --- 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()) &&