From 1ca68445da14d1eb816d236773f5559d1f93845e Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Mon, 26 Aug 2019 09:26:22 +0000 Subject: [PATCH] Bug 1574066 - Correctly count glyphs when determining text decoration intercepts. r=jfkthame Differential Revision: https://phabricator.services.mozilla.com/D43396 --HG-- extra : moz-landing-system : lando --- layout/painting/nsCSSRendering.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/layout/painting/nsCSSRendering.cpp b/layout/painting/nsCSSRendering.cpp index 813d2a688f02..008795441661 100644 --- a/layout/painting/nsCSSRendering.cpp +++ b/layout/painting/nsCSSRendering.cpp @@ -3820,13 +3820,8 @@ static uint32_t CountAllGlyphs( const gfxTextRun* aTextRun, const gfxTextRun::CompressedGlyph* aCompressedGlyph, uint32_t aStringStart, uint32_t aStringEnd) { - bool hasDetailed = aTextRun->HasDetailedGlyphs(); uint32_t totalGlyphCount = 0; - if (!hasDetailed) { - return aStringEnd - aStringStart; - } - for (const gfxTextRun::CompressedGlyph* cg = aCompressedGlyph + aStringStart; cg < aCompressedGlyph + aStringEnd; ++cg) { totalGlyphCount += cg->IsSimpleGlyph() ? 1 : cg->GetGlyphCount(); @@ -3884,8 +3879,6 @@ static sk_sp CreateTextBlob( SkTextBlobBuilder builder; const SkTextBlobBuilder::RunBuffer& run = builder.allocRunPos(aFont, len); - bool hasDetailed = aTextRun->HasDetailedGlyphs(); - // RTL text should be read in by glyph starting at aStringEnd - 1 down until // aStringStart. bool isRTL = aTextRun->IsRightToLeft(); @@ -3907,7 +3900,7 @@ static sk_sp CreateTextBlob( AddSimpleGlyph(run, aCompressedGlyph[currIndex], i, aAppUnitsPerDevPixel, aTextPos); i++; - } else if (hasDetailed) { + } else { // if it's detailed, potentially add multiple into run.glyphs uint32_t count = aCompressedGlyph[currIndex].GetGlyphCount(); if (count > 0) { @@ -3932,6 +3925,8 @@ static sk_sp CreateTextBlob( currIndex += step; } + MOZ_ASSERT(i == len, "glyph count error!"); + return builder.make(); }