From def92d1b8e9d373e2f6f27c366d578d97d8960c6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:50 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- layout/generic/nsTextRunTransformations.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'layout/generic/nsTextRunTransformations.cpp') diff --git a/layout/generic/nsTextRunTransformations.cpp b/layout/generic/nsTextRunTransformations.cpp index d18a7ec293..de9fd31fda 100644 --- a/layout/generic/nsTextRunTransformations.cpp +++ b/layout/generic/nsTextRunTransformations.cpp @@ -80,6 +80,26 @@ bool nsTransformedTextRun::SetPotentialLineBreaks(Range aRange, return changed; } +void nsTransformedTextRun::SetEmergencyWrapPositions() { + // This parallels part of what gfxShapedText::SetupClusterBoundaries() does + // for normal textruns. + bool prevWasHyphen = false; + for (uint32_t pos : IntegerRange(mString.Length())) { + const char16_t ch = mString[pos]; + if (prevWasHyphen) { + if (nsContentUtils::IsAlphanumeric(ch)) { + mCharacterGlyphs[pos].SetCanBreakBefore( + CompressedGlyph::FLAG_BREAK_TYPE_EMERGENCY_WRAP); + } + prevWasHyphen = false; + } + if (nsContentUtils::IsHyphen(ch) && pos && + nsContentUtils::IsAlphanumeric(mString[pos - 1])) { + prevWasHyphen = true; + } + } +} + size_t nsTransformedTextRun::SizeOfExcludingThis( mozilla::MallocSizeOf aMallocSizeOf) { size_t total = gfxTextRun::SizeOfExcludingThis(aMallocSizeOf); -- cgit v1.2.3