tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 08b764a4129fa4fb78ac7fe5bbe8c1106ac872ce
parent 3e61ddfa455283191db607ebf7983dd731fd0d94
Author: Jonathan Kew <jkew@mozilla.com>
Date:   Sat, 18 Oct 2025 07:26:08 +0000

Bug 1994197 - patch 1 - Use integer nscoord values rather than gfxFloat for gfxFont::Spacing fields. r=layout-reviewers,TYLin

Differential Revision: https://phabricator.services.mozilla.com/D268559

Diffstat:
Mgfx/thebes/gfxFont.h | 8+++-----
Mlayout/generic/nsTextFrame.cpp | 18+++++++++---------
Mlayout/generic/nsTextFrame.h | 4++--
3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h @@ -1652,13 +1652,11 @@ class gfxFont { * We let layout specify spacing on either side of any * character. We need to specify both before and after * spacing so that substring measurement can do the right things. - * These values are in appunits. They're always an integral number of - * appunits, but we specify them in floats in case very large spacing - * values are required. + * These values are in appunits. */ struct Spacing { - gfxFloat mBefore; - gfxFloat mAfter; + nscoord mBefore; + nscoord mAfter; }; /** * Metrics for a particular string diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp @@ -3879,8 +3879,8 @@ static gfxFloat ComputeTabWidthAppUnits(const nsIFrame* aFrame) { RefPtr font = fm->GetThebesFontGroup()->GetFirstValidFont(' '); auto metrics = font->GetMetrics(vertical ? nsFontMetrics::eVertical : nsFontMetrics::eHorizontal); - nscoord spaceWidth = nscoord( - NS_round(metrics.spaceWidth * cb->PresContext()->AppUnitsPerDevPixel())); + nscoord spaceWidth = NSToCoordRound(metrics.spaceWidth * + cb->PresContext()->AppUnitsPerDevPixel()); return spaces * (spaceWidth + styleText->mLetterSpacing.Resolve(fm->EmHeight()) + styleText->mWordSpacing.Resolve(spaceWidth)); @@ -4091,24 +4091,24 @@ bool nsTextFrame::PropertyProvider::GetSpacingInternal(Range aRange, // 0 - Gecko legacy model, spacing added to trailing side of letter // 1 - WebKit/Blink-compatible, spacing added to right-hand side // 2 - Symmetrical spacing, half added to each side - gfxFloat before, after; + nscoord before, after; switch (StaticPrefs::layout_css_letter_spacing_model()) { default: // use Gecko legacy behavior if pref value is unknown case 0: - before = 0.0; + before = 0; after = mLetterSpacing; break; case 1: if (mTextRun->IsRightToLeft()) { before = mLetterSpacing; - after = 0.0; + after = 0; } else { - before = 0.0; + before = 0; after = mLetterSpacing; } break; case 2: - before = mLetterSpacing / 2.0; + before = NSToCoordRound(mLetterSpacing * 0.5); after = mLetterSpacing - before; break; } @@ -4170,12 +4170,12 @@ bool nsTextFrame::PropertyProvider::GetSpacingInternal(Range aRange, uint32_t runOffsetInSubstring = run.GetSkippedOffset() - aRange.start; gfxSkipCharsIterator iter = run.GetPos(); for (int32_t i = 0; i < run.GetRunLength(); ++i) { - if (!atStart && before != 0.0 && + if (!atStart && before != 0 && CanAddSpacingBefore(mTextRun, run.GetSkippedOffset() + i, newlineIsSignificant)) { aSpacing[runOffsetInSubstring + i].mBefore += before; } - if (after != 0.0 && + if (after != 0 && CanAddSpacingAfter(mTextRun, run.GetSkippedOffset() + i, newlineIsSignificant)) { // End of a cluster, not in a ligature: put letter-spacing after it diff --git a/layout/generic/nsTextFrame.h b/layout/generic/nsTextFrame.h @@ -259,10 +259,10 @@ class nsTextFrame : public nsIFrame { int32_t mLength; // space for each whitespace char - const gfxFloat mWordSpacing; + const nscoord mWordSpacing; // space for each letter - const gfxFloat mLetterSpacing; + const nscoord mLetterSpacing; // If TextAutospace exists, inter-script spacing applies. Maybe<mozilla::TextAutospace> mTextAutospace;