зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1251995 part 1 - Add helper functions to simplify code. r=jfkthame
MozReview-Commit-ID: 6UBvmEpo12f --HG-- extra : rebase_source : e967015366b727f199fe3febedc70f1f43f19725
This commit is contained in:
Родитель
1d43d61105
Коммит
5b1f34e2f6
|
@ -3499,13 +3499,9 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcess
|
|||
|
||||
virtual nscoord GetWidth()
|
||||
{
|
||||
gfxTextRun::Metrics textRunMetrics = mTextRun->MeasureText(0,
|
||||
mTextRun->GetLength(),
|
||||
mDoMeasureBoundingBox ?
|
||||
gfxFont::TIGHT_INK_EXTENTS :
|
||||
gfxFont::LOOSE_INK_EXTENTS,
|
||||
mDrawTarget,
|
||||
nullptr);
|
||||
gfxTextRun::Metrics textRunMetrics = mTextRun->MeasureText(
|
||||
mDoMeasureBoundingBox ? gfxFont::TIGHT_INK_EXTENTS
|
||||
: gfxFont::LOOSE_INK_EXTENTS, mDrawTarget);
|
||||
|
||||
// this only measures the height; the total width is gotten from the
|
||||
// the return value of ProcessText.
|
||||
|
@ -3535,13 +3531,10 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcess
|
|||
// glyph string on OS X and DWrite where textrun widths may
|
||||
// involve fractional pixels.
|
||||
gfxTextRun::Metrics textRunMetrics =
|
||||
mTextRun->MeasureText(0,
|
||||
mTextRun->GetLength(),
|
||||
mDoMeasureBoundingBox ?
|
||||
gfxFont::TIGHT_INK_EXTENTS :
|
||||
gfxFont::LOOSE_INK_EXTENTS,
|
||||
mDrawTarget,
|
||||
nullptr);
|
||||
mTextRun->MeasureText(mDoMeasureBoundingBox ?
|
||||
gfxFont::TIGHT_INK_EXTENTS :
|
||||
gfxFont::LOOSE_INK_EXTENTS,
|
||||
mDrawTarget);
|
||||
inlineCoord += textRunMetrics.mAdvanceWidth;
|
||||
// old code was:
|
||||
// point.x += width * mAppUnitsPerDevPixel;
|
||||
|
|
|
@ -2071,8 +2071,7 @@ gfxFontGroup::GetHyphenWidth(gfxTextRun::PropertyProvider *aProvider)
|
|||
nsAutoPtr<gfxTextRun>
|
||||
hyphRun(MakeHyphenTextRun(dt,
|
||||
aProvider->GetAppUnitsPerDevUnit()));
|
||||
mHyphenWidth = hyphRun.get() ?
|
||||
hyphRun->GetAdvanceWidth(0, hyphRun->GetLength(), nullptr) : 0;
|
||||
mHyphenWidth = hyphRun.get() ? hyphRun->GetAdvanceWidth() : 0;
|
||||
}
|
||||
}
|
||||
return mHyphenWidth;
|
||||
|
|
|
@ -270,6 +270,13 @@ public:
|
|||
DrawTarget* aDrawTargetForTightBoundingBox,
|
||||
PropertyProvider* aProvider);
|
||||
|
||||
Metrics MeasureText(gfxFont::BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aDrawTargetForTightBoundingBox,
|
||||
PropertyProvider* aProvider = nullptr) {
|
||||
return MeasureText(0, GetLength(), aBoundingBoxType,
|
||||
aDrawTargetForTightBoundingBox, aProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes just the advance width for a substring.
|
||||
* Uses GetSpacing from aBreakProvider.
|
||||
|
@ -281,6 +288,10 @@ public:
|
|||
PropertyProvider *aProvider,
|
||||
PropertyProvider::Spacing* aSpacing = nullptr);
|
||||
|
||||
gfxFloat GetAdvanceWidth() {
|
||||
return GetAdvanceWidth(0, GetLength(), nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all stored line breaks for the given range (both before and after),
|
||||
* and then set the line-break state before aStart to aBreakBefore and
|
||||
|
|
|
@ -803,7 +803,7 @@ TextOverflow::Marker::SetupString(nsIFrame* aFrame)
|
|||
if (mStyle->mType == NS_STYLE_TEXT_OVERFLOW_ELLIPSIS) {
|
||||
gfxTextRun* textRun = GetEllipsisTextRun(aFrame);
|
||||
if (textRun) {
|
||||
mISize = textRun->GetAdvanceWidth(0, textRun->GetLength(), nullptr);
|
||||
mISize = textRun->GetAdvanceWidth();
|
||||
} else {
|
||||
mISize = 0;
|
||||
}
|
||||
|
|
|
@ -5189,8 +5189,7 @@ nsTextFrame::UpdateTextEmphasis(WritingMode aWM, PropertyProvider& aProvider)
|
|||
EmphasisMarkInfo* info = new EmphasisMarkInfo;
|
||||
info->textRun =
|
||||
GenerateTextRunForEmphasisMarks(this, fm, aWM, styleText);
|
||||
info->advance =
|
||||
info->textRun->GetAdvanceWidth(0, info->textRun->GetLength(), nullptr);
|
||||
info->advance = info->textRun->GetAdvanceWidth();
|
||||
|
||||
// Calculate the baseline offset
|
||||
LogicalSide side = styleText->TextEmphasisSide(aWM);
|
||||
|
@ -5844,8 +5843,7 @@ AddHyphenToMetrics(nsTextFrame* aTextFrame, gfxTextRun* aBaseTextRun,
|
|||
return;
|
||||
|
||||
gfxTextRun::Metrics hyphenMetrics =
|
||||
hyphenTextRun->MeasureText(0, hyphenTextRun->GetLength(), aBoundingBoxType,
|
||||
aDrawTarget, nullptr);
|
||||
hyphenTextRun->MeasureText(aBoundingBoxType, aDrawTarget);
|
||||
if (aTextFrame->GetWritingMode().IsLineInverted()) {
|
||||
hyphenMetrics.mBoundingBox.y = -hyphenMetrics.mBoundingBox.YMost();
|
||||
}
|
||||
|
@ -6629,7 +6627,7 @@ nsTextFrame::DrawTextRun(gfxContext* const aCtx,
|
|||
// For right-to-left text runs, the soft-hyphen is positioned at the left
|
||||
// of the text, minus its own width
|
||||
gfxFloat hyphenBaselineX = aTextBaselinePt.x + mTextRun->GetDirection() * aAdvanceWidth -
|
||||
(mTextRun->IsRightToLeft() ? hyphenTextRun->GetAdvanceWidth(0, hyphenTextRun->GetLength(), nullptr) : 0);
|
||||
(mTextRun->IsRightToLeft() ? hyphenTextRun->GetAdvanceWidth() : 0);
|
||||
::DrawTextRun(hyphenTextRun.get(), aCtx,
|
||||
gfxPoint(hyphenBaselineX, aTextBaselinePt.y),
|
||||
0, hyphenTextRun->GetLength(),
|
||||
|
|
|
@ -1021,9 +1021,7 @@ static nsBoundingMetrics
|
|||
MeasureTextRun(DrawTarget* aDrawTarget, gfxTextRun* aTextRun)
|
||||
{
|
||||
gfxTextRun::Metrics metrics =
|
||||
aTextRun->MeasureText(0, aTextRun->GetLength(),
|
||||
gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS,
|
||||
aDrawTarget, nullptr);
|
||||
aTextRun->MeasureText(gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS, aDrawTarget);
|
||||
|
||||
nsBoundingMetrics bm;
|
||||
bm.leftBearing = NSToCoordFloor(metrics.mBoundingBox.X());
|
||||
|
|
|
@ -342,8 +342,7 @@ GetBaselinePosition(nsTextFrame* aFrame,
|
|||
{
|
||||
WritingMode writingMode = aFrame->GetWritingMode();
|
||||
gfxTextRun::Metrics metrics =
|
||||
aTextRun->MeasureText(0, aTextRun->GetLength(), gfxFont::LOOSE_INK_EXTENTS,
|
||||
nullptr, nullptr);
|
||||
aTextRun->MeasureText(gfxFont::LOOSE_INK_EXTENTS, nullptr);
|
||||
|
||||
switch (aDominantBaseline) {
|
||||
case NS_STYLE_DOMINANT_BASELINE_HANGING:
|
||||
|
|
Загрузка…
Ссылка в новой задаче