зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1081867 - Convert textrun metrics to physical coordinates before merging with visual-overflow region. r=smontagu
This commit is contained in:
Родитель
73f7730794
Коммит
1428512193
|
@ -2103,7 +2103,8 @@ gfxFont::Measure(gfxTextRun *aTextRun,
|
|||
uint32_t aStart, uint32_t aEnd,
|
||||
BoundingBoxType aBoundingBoxType,
|
||||
gfxContext *aRefContext,
|
||||
Spacing *aSpacing)
|
||||
Spacing *aSpacing,
|
||||
uint16_t aOrientation)
|
||||
{
|
||||
// If aBoundingBoxType is TIGHT_HINTED_OUTLINE_EXTENTS
|
||||
// and the underlying cairo font may be antialiased,
|
||||
|
@ -2119,14 +2120,15 @@ gfxFont::Measure(gfxTextRun *aTextRun,
|
|||
if (mNonAAFont) {
|
||||
return mNonAAFont->Measure(aTextRun, aStart, aEnd,
|
||||
TIGHT_HINTED_OUTLINE_EXTENTS,
|
||||
aRefContext, aSpacing);
|
||||
aRefContext, aSpacing, aOrientation);
|
||||
}
|
||||
}
|
||||
|
||||
const int32_t appUnitsPerDevUnit = aTextRun->GetAppUnitsPerDevUnit();
|
||||
// Current position in appunits
|
||||
gfxFont::Orientation orientation =
|
||||
aTextRun->IsVertical() ? gfxFont::eVertical : gfxFont::eHorizontal;
|
||||
aOrientation == gfxTextRunFactory::TEXT_ORIENT_VERTICAL_UPRIGHT
|
||||
? gfxFont::eVertical : gfxFont::eHorizontal;
|
||||
const gfxFont::Metrics& fontMetrics = GetMetrics(orientation);
|
||||
|
||||
RunMetrics metrics;
|
||||
|
|
|
@ -1556,7 +1556,7 @@ public:
|
|||
uint32_t aStart, uint32_t aEnd,
|
||||
BoundingBoxType aBoundingBoxType,
|
||||
gfxContext *aContextForTightBoundingBox,
|
||||
Spacing *aSpacing);
|
||||
Spacing *aSpacing, uint16_t aOrientation);
|
||||
/**
|
||||
* Line breaks have been changed at the beginning and/or end of a substring
|
||||
* of the text. Reshaping may be required; glyph updating is permitted.
|
||||
|
|
|
@ -167,11 +167,13 @@ gfxMacFont::Measure(gfxTextRun *aTextRun,
|
|||
uint32_t aStart, uint32_t aEnd,
|
||||
BoundingBoxType aBoundingBoxType,
|
||||
gfxContext *aRefContext,
|
||||
Spacing *aSpacing)
|
||||
Spacing *aSpacing,
|
||||
uint16_t aOrientation)
|
||||
{
|
||||
gfxFont::RunMetrics metrics =
|
||||
gfxFont::Measure(aTextRun, aStart, aEnd,
|
||||
aBoundingBoxType, aRefContext, aSpacing);
|
||||
aBoundingBoxType, aRefContext, aSpacing,
|
||||
aOrientation);
|
||||
|
||||
// if aBoundingBoxType is not TIGHT_HINTED_OUTLINE_EXTENTS then we need to add
|
||||
// a pixel column each side of the bounding box in case of antialiasing "bleed"
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
uint32_t aStart, uint32_t aEnd,
|
||||
BoundingBoxType aBoundingBoxType,
|
||||
gfxContext *aContextForTightBoundingBox,
|
||||
Spacing *aSpacing);
|
||||
Spacing *aSpacing, uint16_t aOrientation);
|
||||
|
||||
virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont> GetScaledFont(mozilla::gfx::DrawTarget *aTarget);
|
||||
|
||||
|
|
|
@ -690,13 +690,15 @@ gfxTextRun::AccumulateMetricsForRun(gfxFont *aFont,
|
|||
gfxContext *aRefContext,
|
||||
PropertyProvider *aProvider,
|
||||
uint32_t aSpacingStart, uint32_t aSpacingEnd,
|
||||
uint16_t aOrientation,
|
||||
Metrics *aMetrics)
|
||||
{
|
||||
nsAutoTArray<PropertyProvider::Spacing,200> spacingBuffer;
|
||||
bool haveSpacing = GetAdjustedSpacingArray(aStart, aEnd, aProvider,
|
||||
aSpacingStart, aSpacingEnd, &spacingBuffer);
|
||||
Metrics metrics = aFont->Measure(this, aStart, aEnd, aBoundingBoxType, aRefContext,
|
||||
haveSpacing ? spacingBuffer.Elements() : nullptr);
|
||||
haveSpacing ? spacingBuffer.Elements() : nullptr,
|
||||
aOrientation);
|
||||
aMetrics->CombineWith(metrics, IsRightToLeft());
|
||||
}
|
||||
|
||||
|
@ -704,7 +706,7 @@ void
|
|||
gfxTextRun::AccumulatePartialLigatureMetrics(gfxFont *aFont,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
gfxFont::BoundingBoxType aBoundingBoxType, gfxContext *aRefContext,
|
||||
PropertyProvider *aProvider, Metrics *aMetrics)
|
||||
PropertyProvider *aProvider, uint16_t aOrientation, Metrics *aMetrics)
|
||||
{
|
||||
if (aStart >= aEnd)
|
||||
return;
|
||||
|
@ -717,7 +719,7 @@ gfxTextRun::AccumulatePartialLigatureMetrics(gfxFont *aFont,
|
|||
Metrics metrics;
|
||||
AccumulateMetricsForRun(aFont, data.mLigatureStart, data.mLigatureEnd,
|
||||
aBoundingBoxType, aRefContext,
|
||||
aProvider, aStart, aEnd, &metrics);
|
||||
aProvider, aStart, aEnd, aOrientation, &metrics);
|
||||
|
||||
// Clip the bounding box to the ligature part
|
||||
gfxFloat bboxLeft = metrics.mBoundingBox.X();
|
||||
|
@ -757,7 +759,8 @@ gfxTextRun::MeasureText(uint32_t aStart, uint32_t aLength,
|
|||
ShrinkToLigatureBoundaries(&ligatureRunStart, &ligatureRunEnd);
|
||||
|
||||
AccumulatePartialLigatureMetrics(font, start, ligatureRunStart,
|
||||
aBoundingBoxType, aRefContext, aProvider, &accumulatedMetrics);
|
||||
aBoundingBoxType, aRefContext, aProvider,
|
||||
iter.GetGlyphRun()->mOrientation, &accumulatedMetrics);
|
||||
|
||||
// XXX This sucks. We have to get glyph extents just so we can detect
|
||||
// glyphs outside the font box, even when aBoundingBoxType is LOOSE,
|
||||
|
@ -767,10 +770,11 @@ gfxTextRun::MeasureText(uint32_t aStart, uint32_t aLength,
|
|||
AccumulateMetricsForRun(font,
|
||||
ligatureRunStart, ligatureRunEnd, aBoundingBoxType,
|
||||
aRefContext, aProvider, ligatureRunStart, ligatureRunEnd,
|
||||
&accumulatedMetrics);
|
||||
iter.GetGlyphRun()->mOrientation, &accumulatedMetrics);
|
||||
|
||||
AccumulatePartialLigatureMetrics(font, ligatureRunEnd, end,
|
||||
aBoundingBoxType, aRefContext, aProvider, &accumulatedMetrics);
|
||||
aBoundingBoxType, aRefContext, aProvider,
|
||||
iter.GetGlyphRun()->mOrientation, &accumulatedMetrics);
|
||||
}
|
||||
|
||||
return accumulatedMetrics;
|
||||
|
|
|
@ -684,6 +684,7 @@ private:
|
|||
gfxFont::BoundingBoxType aBoundingBoxType,
|
||||
gfxContext *aRefContext,
|
||||
PropertyProvider *aProvider,
|
||||
uint16_t aOrientation,
|
||||
Metrics *aMetrics);
|
||||
|
||||
// **** measurement helper ****
|
||||
|
@ -692,6 +693,7 @@ private:
|
|||
gfxContext *aRefContext,
|
||||
PropertyProvider *aProvider,
|
||||
uint32_t aSpacingStart, uint32_t aSpacingEnd,
|
||||
uint16_t aOrientation,
|
||||
Metrics *aMetrics);
|
||||
|
||||
// **** drawing helper ****
|
||||
|
|
|
@ -7578,7 +7578,13 @@ nsTextFrame::ComputeTightBounds(gfxContext* aContext) const
|
|||
aContext, &provider);
|
||||
// mAscent should be the same as metrics.mAscent, but it's what we use to
|
||||
// paint so that's the one we'll use.
|
||||
return RoundOut(metrics.mBoundingBox) + nsPoint(0, mAscent);
|
||||
nsRect boundingBox = RoundOut(metrics.mBoundingBox) + nsPoint(0, mAscent);
|
||||
if (mTextRun->IsVertical()) {
|
||||
// Swap line-relative textMetrics dimensions to physical coordinates.
|
||||
Swap(boundingBox.x, boundingBox.y);
|
||||
Swap(boundingBox.width, boundingBox.height);
|
||||
}
|
||||
return boundingBox;
|
||||
}
|
||||
|
||||
/* virtual */ nsresult
|
||||
|
@ -8284,6 +8290,11 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
|||
// Handle text that runs outside its normal bounds.
|
||||
nsRect boundingBox = RoundOut(textMetrics.mBoundingBox) + nsPoint(0, mAscent);
|
||||
aMetrics.SetOverflowAreasToDesiredBounds();
|
||||
if (mTextRun->IsVertical()) {
|
||||
// Swap line-relative textMetrics dimensions to physical coordinates.
|
||||
Swap(boundingBox.x, boundingBox.y);
|
||||
Swap(boundingBox.width, boundingBox.height);
|
||||
}
|
||||
aMetrics.VisualOverflow().UnionRect(aMetrics.VisualOverflow(), boundingBox);
|
||||
|
||||
// When we have text decorations, we don't need to compute their overflow now
|
||||
|
@ -8530,7 +8541,13 @@ nsTextFrame::RecomputeOverflow(const nsHTMLReflowState& aBlockReflowState)
|
|||
gfxFont::LOOSE_INK_EXTENTS, nullptr,
|
||||
&provider);
|
||||
nsRect &vis = result.VisualOverflow();
|
||||
vis.UnionRect(vis, RoundOut(textMetrics.mBoundingBox) + nsPoint(0, mAscent));
|
||||
nsRect boundingBox = RoundOut(textMetrics.mBoundingBox) + nsPoint(0, mAscent);
|
||||
if (mTextRun->IsVertical()) {
|
||||
// Swap line-relative textMetrics dimensions to physical coordinates.
|
||||
Swap(boundingBox.x, boundingBox.y);
|
||||
Swap(boundingBox.width, boundingBox.height);
|
||||
}
|
||||
vis.UnionRect(vis, boundingBox);
|
||||
UnionAdditionalOverflow(PresContext(), aBlockReflowState.frame, provider,
|
||||
&vis, true);
|
||||
return result;
|
||||
|
|
Загрузка…
Ссылка в новой задаче