зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1765093 - patch 3 - Also use the new gfxTextRun::GetLineHeightMetrics to optimize GetAscentAndDescentInAppUnits. r=emilio
This accelerates web-exposed SVG APIs such as getExtentOfChar() by avoiding the expensive MeasureText() call when we're just getting the line-height metrics. Differential Revision: https://phabricator.services.mozilla.com/D145717
This commit is contained in:
Родитель
6e0eb71134
Коммит
e7bef911d2
|
@ -845,10 +845,10 @@ gfxTextRun::Metrics gfxTextRun::MeasureText(
|
|||
return accumulatedMetrics;
|
||||
}
|
||||
|
||||
void gfxTextRun::GetLineHeightMetrics(gfxFloat& aAscent,
|
||||
void gfxTextRun::GetLineHeightMetrics(Range aRange, gfxFloat& aAscent,
|
||||
gfxFloat& aDescent) const {
|
||||
Metrics accumulatedMetrics;
|
||||
GlyphRunIterator iter(this, Range(this));
|
||||
GlyphRunIterator iter(this, aRange);
|
||||
while (iter.NextRun()) {
|
||||
gfxFont* font = iter.GetGlyphRun()->mFont;
|
||||
auto metrics =
|
||||
|
|
|
@ -312,7 +312,11 @@ class gfxTextRun : public gfxShapedText {
|
|||
aDrawTargetForTightBoundingBox, aProvider);
|
||||
}
|
||||
|
||||
void GetLineHeightMetrics(gfxFloat& aAscent, gfxFloat& aDescent) const;
|
||||
void GetLineHeightMetrics(Range aRange, gfxFloat& aAscent,
|
||||
gfxFloat& aDescent) const;
|
||||
void GetLineHeightMetrics(gfxFloat& aAscent, gfxFloat& aDescent) const {
|
||||
GetLineHeightMetrics(Range(this), aAscent, aDescent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes just the advance width for a substring.
|
||||
|
|
|
@ -126,13 +126,7 @@ static void GetAscentAndDescentInAppUnits(nsTextFrame* aFrame,
|
|||
gfxTextRun::Range range = ConvertOriginalToSkipped(
|
||||
it, aFrame->GetContentOffset(), aFrame->GetContentLength());
|
||||
|
||||
// We pass in null for the PropertyProvider since letter-spacing and
|
||||
// word-spacing should not affect the ascent and descent values we get.
|
||||
gfxTextRun::Metrics metrics =
|
||||
textRun->MeasureText(range, gfxFont::LOOSE_INK_EXTENTS, nullptr, nullptr);
|
||||
|
||||
aAscent = metrics.mAscent;
|
||||
aDescent = metrics.mDescent;
|
||||
textRun->GetLineHeightMetrics(range, aAscent, aDescent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче