зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset bf004c055beb (bug 1251995)
This commit is contained in:
Родитель
1d0a6281ac
Коммит
b9f86983b1
|
@ -658,9 +658,10 @@ ContentEventHandler::AppendFontRanges(FontRangeArray& aFontRanges,
|
|||
}
|
||||
}
|
||||
|
||||
gfxTextRun::Range skipRange(iter.ConvertOriginalToSkipped(frameXPStart),
|
||||
iter.ConvertOriginalToSkipped(frameXPEnd));
|
||||
gfxTextRun::GlyphRunIterator runIter(textRun, skipRange);
|
||||
uint32_t skipStart = iter.ConvertOriginalToSkipped(frameXPStart);
|
||||
uint32_t skipEnd = iter.ConvertOriginalToSkipped(frameXPEnd);
|
||||
gfxTextRun::GlyphRunIterator runIter(
|
||||
textRun, skipStart, skipEnd - skipStart);
|
||||
int32_t lastXPEndOffset = frameXPStart;
|
||||
while (runIter.NextRun()) {
|
||||
gfxFont* font = runIter.GetGlyphRun()->mFont.get();
|
||||
|
|
|
@ -81,7 +81,7 @@ private:
|
|||
|
||||
class StubPropertyProvider : public gfxTextRun::PropertyProvider {
|
||||
public:
|
||||
virtual void GetHyphenationBreaks(gfxTextRun::Range aRange,
|
||||
virtual void GetHyphenationBreaks(uint32_t aStart, uint32_t aLength,
|
||||
bool* aBreakBefore) {
|
||||
NS_ERROR("This shouldn't be called because we never call BreakAndMeasureText");
|
||||
}
|
||||
|
@ -101,7 +101,8 @@ public:
|
|||
NS_ERROR("This shouldn't be called because we never enable hyphens");
|
||||
return 60;
|
||||
}
|
||||
virtual void GetSpacing(gfxTextRun::Range aRange, Spacing* aSpacing) {
|
||||
virtual void GetSpacing(uint32_t aStart, uint32_t aLength,
|
||||
Spacing* aSpacing) {
|
||||
NS_ERROR("This shouldn't be called because we never enable spacing");
|
||||
}
|
||||
};
|
||||
|
@ -324,11 +325,8 @@ nsFontMetrics::GetWidth(const char* aString, uint32_t aLength,
|
|||
|
||||
StubPropertyProvider provider;
|
||||
AutoTextRun textRun(this, aDrawTarget, aString, aLength);
|
||||
if (textRun.get()) {
|
||||
return NSToCoordRound(
|
||||
textRun->GetAdvanceWidth(Range(0, aLength), &provider));
|
||||
}
|
||||
return 0;
|
||||
return textRun.get() ?
|
||||
NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider)) : 0;
|
||||
}
|
||||
|
||||
nscoord
|
||||
|
@ -343,11 +341,8 @@ nsFontMetrics::GetWidth(const char16_t* aString, uint32_t aLength,
|
|||
|
||||
StubPropertyProvider provider;
|
||||
AutoTextRun textRun(this, aDrawTarget, aString, aLength);
|
||||
if (textRun.get()) {
|
||||
return NSToCoordRound(
|
||||
textRun->GetAdvanceWidth(Range(0, aLength), &provider));
|
||||
}
|
||||
return 0;
|
||||
return textRun.get() ?
|
||||
NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider)) : 0;
|
||||
}
|
||||
|
||||
// Draw a string using this font handle on the surface passed in.
|
||||
|
@ -365,16 +360,15 @@ nsFontMetrics::DrawString(const char *aString, uint32_t aLength,
|
|||
return;
|
||||
}
|
||||
gfxPoint pt(aX, aY);
|
||||
Range range(0, aLength);
|
||||
if (mTextRunRTL) {
|
||||
if (mVertical) {
|
||||
pt.y += textRun->GetAdvanceWidth(range, &provider);
|
||||
pt.y += textRun->GetAdvanceWidth(0, aLength, &provider);
|
||||
} else {
|
||||
pt.x += textRun->GetAdvanceWidth(range, &provider);
|
||||
pt.x += textRun->GetAdvanceWidth(0, aLength, &provider);
|
||||
}
|
||||
}
|
||||
textRun->Draw(aContext->ThebesContext(), pt, DrawMode::GLYPH_FILL,
|
||||
range, &provider, nullptr, nullptr);
|
||||
textRun->Draw(aContext->ThebesContext(), pt, DrawMode::GLYPH_FILL, 0, aLength,
|
||||
&provider, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -392,16 +386,15 @@ nsFontMetrics::DrawString(const char16_t* aString, uint32_t aLength,
|
|||
return;
|
||||
}
|
||||
gfxPoint pt(aX, aY);
|
||||
Range range(0, aLength);
|
||||
if (mTextRunRTL) {
|
||||
if (mVertical) {
|
||||
pt.y += textRun->GetAdvanceWidth(range, &provider);
|
||||
pt.y += textRun->GetAdvanceWidth(0, aLength, &provider);
|
||||
} else {
|
||||
pt.x += textRun->GetAdvanceWidth(range, &provider);
|
||||
pt.x += textRun->GetAdvanceWidth(0, aLength, &provider);
|
||||
}
|
||||
}
|
||||
textRun->Draw(aContext->ThebesContext(), pt, DrawMode::GLYPH_FILL,
|
||||
range, &provider, nullptr, nullptr);
|
||||
textRun->Draw(aContext->ThebesContext(), pt, DrawMode::GLYPH_FILL, 0, aLength,
|
||||
&provider, nullptr, nullptr);
|
||||
}
|
||||
|
||||
static nsBoundingMetrics
|
||||
|
@ -416,8 +409,8 @@ GetTextBoundingMetrics(nsFontMetrics* aMetrics, const char16_t* aString,
|
|||
AutoTextRun textRun(aMetrics, aDrawTarget, aString, aLength);
|
||||
nsBoundingMetrics m;
|
||||
if (textRun.get()) {
|
||||
gfxTextRun::Metrics theMetrics = textRun->MeasureText(
|
||||
gfxTextRun::Range(0, aLength), aType, aDrawTarget, &provider);
|
||||
gfxTextRun::Metrics theMetrics =
|
||||
textRun->MeasureText(0, aLength, aType, aDrawTarget, &provider);
|
||||
|
||||
m.leftBearing = NSToCoordFloor( theMetrics.mBoundingBox.X());
|
||||
m.rightBearing = NSToCoordCeil( theMetrics.mBoundingBox.XMost());
|
||||
|
|
|
@ -46,7 +46,6 @@ struct nsBoundingMetrics;
|
|||
class nsFontMetrics final
|
||||
{
|
||||
public:
|
||||
typedef gfxTextRun::Range Range;
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
|
||||
nsFontMetrics();
|
||||
|
|
|
@ -1943,7 +1943,7 @@ gfxFont::DrawEmphasisMarks(gfxTextRun* aShapedText, gfxPoint* aPt,
|
|||
const EmphasisMarkDrawParams& aParams)
|
||||
{
|
||||
gfxFloat& inlineCoord = aParams.isVertical ? aPt->y : aPt->x;
|
||||
gfxTextRun::Range markRange(aParams.mark);
|
||||
uint32_t markLength = aParams.mark->GetLength();
|
||||
|
||||
gfxFloat clusterStart = -std::numeric_limits<gfxFloat>::infinity();
|
||||
bool shouldDrawEmphasisMark = false;
|
||||
|
@ -1966,7 +1966,7 @@ gfxFont::DrawEmphasisMarks(gfxTextRun* aShapedText, gfxPoint* aPt,
|
|||
gfxFloat delta = (clusterAdvance + aParams.advance) / 2;
|
||||
inlineCoord -= delta;
|
||||
aParams.mark->Draw(aParams.context, *aPt, DrawMode::GLYPH_FILL,
|
||||
markRange, nullptr, nullptr, nullptr);
|
||||
0, markLength, nullptr, nullptr, nullptr);
|
||||
inlineCoord += delta;
|
||||
shouldDrawEmphasisMark = false;
|
||||
}
|
||||
|
@ -3187,8 +3187,7 @@ gfxFont::InitFakeSmallCapsRun(DrawTarget *aDrawTarget,
|
|||
MergeCharactersInTextRun(mergedRun, tempRun,
|
||||
charsToMergeArray.Elements(),
|
||||
deletedCharsArray.Elements());
|
||||
gfxTextRun::Range runRange(0, runLength);
|
||||
aTextRun->CopyGlyphDataFrom(mergedRun, runRange,
|
||||
aTextRun->CopyGlyphDataFrom(mergedRun, 0, runLength,
|
||||
aOffset + runStart);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -210,14 +210,15 @@ gfxTextRun::ReleaseFontGroup()
|
|||
}
|
||||
|
||||
bool
|
||||
gfxTextRun::SetPotentialLineBreaks(Range aRange, uint8_t *aBreakBefore)
|
||||
gfxTextRun::SetPotentialLineBreaks(uint32_t aStart, uint32_t aLength,
|
||||
uint8_t *aBreakBefore)
|
||||
{
|
||||
NS_ASSERTION(aRange.end <= GetLength(), "Overflow");
|
||||
NS_ASSERTION(aStart + aLength <= GetLength(), "Overflow");
|
||||
|
||||
uint32_t changed = 0;
|
||||
uint32_t i;
|
||||
CompressedGlyph *charGlyphs = mCharacterGlyphs + aRange.start;
|
||||
for (i = 0; i < aRange.Length(); ++i) {
|
||||
CompressedGlyph *charGlyphs = mCharacterGlyphs + aStart;
|
||||
for (i = 0; i < aLength; ++i) {
|
||||
uint8_t canBreak = aBreakBefore[i];
|
||||
if (canBreak && !charGlyphs[i].IsClusterStart()) {
|
||||
// This can happen ... there is no guarantee that our linebreaking rules
|
||||
|
@ -230,39 +231,39 @@ gfxTextRun::SetPotentialLineBreaks(Range aRange, uint8_t *aBreakBefore)
|
|||
}
|
||||
|
||||
gfxTextRun::LigatureData
|
||||
gfxTextRun::ComputeLigatureData(Range aPartRange, PropertyProvider *aProvider)
|
||||
gfxTextRun::ComputeLigatureData(uint32_t aPartStart, uint32_t aPartEnd,
|
||||
PropertyProvider *aProvider)
|
||||
{
|
||||
NS_ASSERTION(aPartRange.start < aPartRange.end,
|
||||
"Computing ligature data for empty range");
|
||||
NS_ASSERTION(aPartRange.end <= GetLength(), "Character length overflow");
|
||||
NS_ASSERTION(aPartStart < aPartEnd, "Computing ligature data for empty range");
|
||||
NS_ASSERTION(aPartEnd <= GetLength(), "Character length overflow");
|
||||
|
||||
LigatureData result;
|
||||
CompressedGlyph *charGlyphs = mCharacterGlyphs;
|
||||
|
||||
uint32_t i;
|
||||
for (i = aPartRange.start; !charGlyphs[i].IsLigatureGroupStart(); --i) {
|
||||
for (i = aPartStart; !charGlyphs[i].IsLigatureGroupStart(); --i) {
|
||||
NS_ASSERTION(i > 0, "Ligature at the start of the run??");
|
||||
}
|
||||
result.mRange.start = i;
|
||||
for (i = aPartRange.start + 1;
|
||||
i < GetLength() && !charGlyphs[i].IsLigatureGroupStart(); ++i) {
|
||||
result.mLigatureStart = i;
|
||||
for (i = aPartStart + 1; i < GetLength() && !charGlyphs[i].IsLigatureGroupStart(); ++i) {
|
||||
}
|
||||
result.mRange.end = i;
|
||||
result.mLigatureEnd = i;
|
||||
|
||||
int32_t ligatureWidth = GetAdvanceForGlyphs(result.mRange);
|
||||
int32_t ligatureWidth =
|
||||
GetAdvanceForGlyphs(result.mLigatureStart, result.mLigatureEnd);
|
||||
// Count the number of started clusters we have seen
|
||||
uint32_t totalClusterCount = 0;
|
||||
uint32_t partClusterIndex = 0;
|
||||
uint32_t partClusterCount = 0;
|
||||
for (i = result.mRange.start; i < result.mRange.end; ++i) {
|
||||
for (i = result.mLigatureStart; i < result.mLigatureEnd; ++i) {
|
||||
// Treat the first character of the ligature as the start of a
|
||||
// cluster for our purposes of allocating ligature width to its
|
||||
// characters.
|
||||
if (i == result.mRange.start || charGlyphs[i].IsClusterStart()) {
|
||||
if (i == result.mLigatureStart || charGlyphs[i].IsClusterStart()) {
|
||||
++totalClusterCount;
|
||||
if (i < aPartRange.start) {
|
||||
if (i < aPartStart) {
|
||||
++partClusterIndex;
|
||||
} else if (i < aPartRange.end) {
|
||||
} else if (i < aPartEnd) {
|
||||
++partClusterCount;
|
||||
}
|
||||
}
|
||||
|
@ -274,7 +275,7 @@ gfxTextRun::ComputeLigatureData(Range aPartRange, PropertyProvider *aProvider)
|
|||
// Any rounding errors are apportioned to the final part of the ligature,
|
||||
// so that measuring all parts of a ligature and summing them is equal to
|
||||
// the ligature width.
|
||||
if (aPartRange.end == result.mRange.end) {
|
||||
if (aPartEnd == result.mLigatureEnd) {
|
||||
gfxFloat allParts = totalClusterCount * (ligatureWidth / totalClusterCount);
|
||||
result.mPartWidth += ligatureWidth - allParts;
|
||||
}
|
||||
|
@ -295,14 +296,12 @@ gfxTextRun::ComputeLigatureData(Range aPartRange, PropertyProvider *aProvider)
|
|||
|
||||
if (aProvider && (mFlags & gfxTextRunFactory::TEXT_ENABLE_SPACING)) {
|
||||
gfxFont::Spacing spacing;
|
||||
if (aPartRange.start == result.mRange.start) {
|
||||
aProvider->GetSpacing(
|
||||
Range(aPartRange.start, aPartRange.start + 1), &spacing);
|
||||
if (aPartStart == result.mLigatureStart) {
|
||||
aProvider->GetSpacing(aPartStart, 1, &spacing);
|
||||
result.mPartWidth += spacing.mBefore;
|
||||
}
|
||||
if (aPartRange.end == result.mRange.end) {
|
||||
aProvider->GetSpacing(
|
||||
Range(aPartRange.end - 1, aPartRange.end), &spacing);
|
||||
if (aPartEnd == result.mLigatureEnd) {
|
||||
aProvider->GetSpacing(aPartEnd - 1, 1, &spacing);
|
||||
result.mPartWidth += spacing.mAfter;
|
||||
}
|
||||
}
|
||||
|
@ -311,34 +310,34 @@ gfxTextRun::ComputeLigatureData(Range aPartRange, PropertyProvider *aProvider)
|
|||
}
|
||||
|
||||
gfxFloat
|
||||
gfxTextRun::ComputePartialLigatureWidth(Range aPartRange,
|
||||
gfxTextRun::ComputePartialLigatureWidth(uint32_t aPartStart, uint32_t aPartEnd,
|
||||
PropertyProvider *aProvider)
|
||||
{
|
||||
if (aPartRange.start >= aPartRange.end)
|
||||
if (aPartStart >= aPartEnd)
|
||||
return 0;
|
||||
LigatureData data = ComputeLigatureData(aPartRange, aProvider);
|
||||
LigatureData data = ComputeLigatureData(aPartStart, aPartEnd, aProvider);
|
||||
return data.mPartWidth;
|
||||
}
|
||||
|
||||
int32_t
|
||||
gfxTextRun::GetAdvanceForGlyphs(Range aRange)
|
||||
gfxTextRun::GetAdvanceForGlyphs(uint32_t aStart, uint32_t aEnd)
|
||||
{
|
||||
int32_t advance = 0;
|
||||
for (auto i = aRange.start; i < aRange.end; ++i) {
|
||||
for (auto i = aStart; i < aEnd; ++i) {
|
||||
advance += GetAdvanceForGlyph(i);
|
||||
}
|
||||
return advance;
|
||||
}
|
||||
|
||||
static void
|
||||
GetAdjustedSpacing(gfxTextRun *aTextRun, gfxTextRun::Range aRange,
|
||||
GetAdjustedSpacing(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
|
||||
gfxTextRun::PropertyProvider *aProvider,
|
||||
gfxTextRun::PropertyProvider::Spacing *aSpacing)
|
||||
{
|
||||
if (aRange.start >= aRange.end)
|
||||
if (aStart >= aEnd)
|
||||
return;
|
||||
|
||||
aProvider->GetSpacing(aRange, aSpacing);
|
||||
aProvider->GetSpacing(aStart, aEnd - aStart, aSpacing);
|
||||
|
||||
#ifdef DEBUG
|
||||
// Check to see if we have spacing inside ligatures
|
||||
|
@ -346,13 +345,11 @@ GetAdjustedSpacing(gfxTextRun *aTextRun, gfxTextRun::Range aRange,
|
|||
const gfxTextRun::CompressedGlyph *charGlyphs = aTextRun->GetCharacterGlyphs();
|
||||
uint32_t i;
|
||||
|
||||
for (i = aRange.start; i < aRange.end; ++i) {
|
||||
for (i = aStart; i < aEnd; ++i) {
|
||||
if (!charGlyphs[i].IsLigatureGroupStart()) {
|
||||
NS_ASSERTION(i == aRange.start ||
|
||||
aSpacing[i - aRange.start].mBefore == 0,
|
||||
NS_ASSERTION(i == aStart || aSpacing[i - aStart].mBefore == 0,
|
||||
"Before-spacing inside a ligature!");
|
||||
NS_ASSERTION(i - 1 <= aRange.start ||
|
||||
aSpacing[i - 1 - aRange.start].mAfter == 0,
|
||||
NS_ASSERTION(i - 1 <= aStart || aSpacing[i - 1 - aStart].mAfter == 0,
|
||||
"After-spacing inside a ligature!");
|
||||
}
|
||||
}
|
||||
|
@ -360,53 +357,51 @@ GetAdjustedSpacing(gfxTextRun *aTextRun, gfxTextRun::Range aRange,
|
|||
}
|
||||
|
||||
bool
|
||||
gfxTextRun::GetAdjustedSpacingArray(Range aRange, PropertyProvider *aProvider,
|
||||
Range aSpacingRange,
|
||||
gfxTextRun::GetAdjustedSpacingArray(uint32_t aStart, uint32_t aEnd,
|
||||
PropertyProvider *aProvider,
|
||||
uint32_t aSpacingStart, uint32_t aSpacingEnd,
|
||||
nsTArray<PropertyProvider::Spacing> *aSpacing)
|
||||
{
|
||||
if (!aProvider || !(mFlags & gfxTextRunFactory::TEXT_ENABLE_SPACING))
|
||||
return false;
|
||||
if (!aSpacing->AppendElements(aRange.Length()))
|
||||
if (!aSpacing->AppendElements(aEnd - aStart))
|
||||
return false;
|
||||
auto spacingOffset = aSpacingRange.start - aRange.start;
|
||||
memset(aSpacing->Elements(), 0, sizeof(gfxFont::Spacing) * spacingOffset);
|
||||
GetAdjustedSpacing(this, aSpacingRange, aProvider,
|
||||
aSpacing->Elements() + spacingOffset);
|
||||
memset(aSpacing->Elements() + aSpacingRange.end - aRange.start, 0,
|
||||
sizeof(gfxFont::Spacing) * (aRange.end - aSpacingRange.end));
|
||||
memset(aSpacing->Elements(), 0, sizeof(gfxFont::Spacing)*(aSpacingStart - aStart));
|
||||
GetAdjustedSpacing(this, aSpacingStart, aSpacingEnd, aProvider,
|
||||
aSpacing->Elements() + aSpacingStart - aStart);
|
||||
memset(aSpacing->Elements() + aSpacingEnd - aStart, 0, sizeof(gfxFont::Spacing)*(aEnd - aSpacingEnd));
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
gfxTextRun::ShrinkToLigatureBoundaries(Range* aRange)
|
||||
gfxTextRun::ShrinkToLigatureBoundaries(uint32_t *aStart, uint32_t *aEnd)
|
||||
{
|
||||
if (aRange->start >= aRange->end)
|
||||
if (*aStart >= *aEnd)
|
||||
return;
|
||||
|
||||
CompressedGlyph *charGlyphs = mCharacterGlyphs;
|
||||
|
||||
while (aRange->start < aRange->end &&
|
||||
!charGlyphs[aRange->start].IsLigatureGroupStart()) {
|
||||
++aRange->start;
|
||||
while (*aStart < *aEnd && !charGlyphs[*aStart].IsLigatureGroupStart()) {
|
||||
++(*aStart);
|
||||
}
|
||||
if (aRange->end < GetLength()) {
|
||||
while (aRange->end > aRange->start &&
|
||||
!charGlyphs[aRange->end].IsLigatureGroupStart()) {
|
||||
--aRange->end;
|
||||
if (*aEnd < GetLength()) {
|
||||
while (*aEnd > *aStart && !charGlyphs[*aEnd].IsLigatureGroupStart()) {
|
||||
--(*aEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxTextRun::DrawGlyphs(gfxFont *aFont, Range aRange, gfxPoint *aPt,
|
||||
PropertyProvider *aProvider, Range aSpacingRange,
|
||||
gfxTextRun::DrawGlyphs(gfxFont *aFont, uint32_t aStart, uint32_t aEnd,
|
||||
gfxPoint *aPt, PropertyProvider *aProvider,
|
||||
uint32_t aSpacingStart, uint32_t aSpacingEnd,
|
||||
TextRunDrawParams& aParams, uint16_t aOrientation)
|
||||
{
|
||||
AutoTArray<PropertyProvider::Spacing,200> spacingBuffer;
|
||||
bool haveSpacing = GetAdjustedSpacingArray(aRange, aProvider,
|
||||
aSpacingRange, &spacingBuffer);
|
||||
bool haveSpacing = GetAdjustedSpacingArray(aStart, aEnd, aProvider,
|
||||
aSpacingStart, aSpacingEnd, &spacingBuffer);
|
||||
aParams.spacing = haveSpacing ? spacingBuffer.Elements() : nullptr;
|
||||
aFont->Draw(this, aRange.start, aRange.end, aPt, aParams, aOrientation);
|
||||
aFont->Draw(this, aStart, aEnd, aPt, aParams, aOrientation);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -434,16 +429,16 @@ ClipPartialLigature(const gfxTextRun* aTextRun,
|
|||
}
|
||||
|
||||
void
|
||||
gfxTextRun::DrawPartialLigature(gfxFont *aFont, Range aRange,
|
||||
gfxTextRun::DrawPartialLigature(gfxFont *aFont, uint32_t aStart, uint32_t aEnd,
|
||||
gfxPoint *aPt, PropertyProvider *aProvider,
|
||||
TextRunDrawParams& aParams, uint16_t aOrientation)
|
||||
{
|
||||
if (aRange.start >= aRange.end) {
|
||||
if (aStart >= aEnd) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Draw partial ligature. We hack this by clipping the ligature.
|
||||
LigatureData data = ComputeLigatureData(aRange, aProvider);
|
||||
LigatureData data = ComputeLigatureData(aStart, aEnd, aProvider);
|
||||
gfxRect clipExtents = aParams.context->GetClipExtents();
|
||||
gfxFloat start, end;
|
||||
if (aParams.isVerticalRun) {
|
||||
|
@ -478,8 +473,8 @@ gfxTextRun::DrawPartialLigature(gfxFont *aFont, Range aRange,
|
|||
pt = gfxPoint(aPt->x - aParams.direction * data.mPartAdvance, aPt->y);
|
||||
}
|
||||
|
||||
DrawGlyphs(aFont, data.mRange, &pt,
|
||||
aProvider, aRange, aParams, aOrientation);
|
||||
DrawGlyphs(aFont, data.mLigatureStart, data.mLigatureEnd, &pt,
|
||||
aProvider, aStart, aEnd, aParams, aOrientation);
|
||||
aParams.context->Restore();
|
||||
|
||||
if (aParams.isVerticalRun) {
|
||||
|
@ -494,9 +489,9 @@ gfxTextRun::DrawPartialLigature(gfxFont *aFont, Range aRange,
|
|||
// check whether the text run needs to be explicitly composited in order to
|
||||
// support opacity.
|
||||
static bool
|
||||
HasSyntheticBoldOrColor(gfxTextRun *aRun, gfxTextRun::Range aRange)
|
||||
HasSyntheticBoldOrColor(gfxTextRun *aRun, uint32_t aStart, uint32_t aLength)
|
||||
{
|
||||
gfxTextRun::GlyphRunIterator iter(aRun, aRange);
|
||||
gfxTextRun::GlyphRunIterator iter(aRun, aStart, aLength);
|
||||
while (iter.NextRun()) {
|
||||
gfxFont *font = iter.GetGlyphRun()->mFont;
|
||||
if (font) {
|
||||
|
@ -565,12 +560,12 @@ struct BufferAlphaColor {
|
|||
|
||||
void
|
||||
gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, DrawMode aDrawMode,
|
||||
Range aRange,
|
||||
uint32_t aStart, uint32_t aLength,
|
||||
PropertyProvider *aProvider, gfxFloat *aAdvanceWidth,
|
||||
gfxTextContextPaint *aContextPaint,
|
||||
gfxTextRunDrawCallbacks *aCallbacks)
|
||||
{
|
||||
NS_ASSERTION(aRange.end <= GetLength(), "Substring out of range");
|
||||
NS_ASSERTION(aStart + aLength <= GetLength(), "Substring out of range");
|
||||
NS_ASSERTION(aDrawMode == DrawMode::GLYPH_PATH ||
|
||||
!(int(aDrawMode) & int(DrawMode::GLYPH_PATH)),
|
||||
"GLYPH_PATH cannot be used with GLYPH_FILL, GLYPH_STROKE or GLYPH_STROKE_UNDERNEATH");
|
||||
|
@ -591,7 +586,7 @@ gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, DrawMode aDrawMode,
|
|||
// We don't need to draw anything;
|
||||
// but if the caller wants advance width, we need to compute it here
|
||||
if (aAdvanceWidth) {
|
||||
gfxTextRun::Metrics metrics = MeasureText(aRange,
|
||||
gfxTextRun::Metrics metrics = MeasureText(aStart, aLength,
|
||||
gfxFont::LOOSE_INK_EXTENTS,
|
||||
aContext->GetDrawTarget(),
|
||||
aProvider);
|
||||
|
@ -610,10 +605,10 @@ gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, DrawMode aDrawMode,
|
|||
|
||||
if (aDrawMode == DrawMode::GLYPH_FILL &&
|
||||
HasNonOpaqueNonTransparentColor(aContext, currentColor) &&
|
||||
HasSyntheticBoldOrColor(this, aRange)) {
|
||||
HasSyntheticBoldOrColor(this, aStart, aLength)) {
|
||||
needToRestore = true;
|
||||
// measure text, use the bounding box
|
||||
gfxTextRun::Metrics metrics = MeasureText(aRange,
|
||||
gfxTextRun::Metrics metrics = MeasureText(aStart, aLength,
|
||||
gfxFont::LOOSE_INK_EXTENTS,
|
||||
aContext->GetDrawTarget(),
|
||||
aProvider);
|
||||
|
@ -637,33 +632,34 @@ gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, DrawMode aDrawMode,
|
|||
params.dt = aContext->GetDrawTarget();
|
||||
params.fontSmoothingBGColor = aContext->GetFontSmoothingBackgroundColor();
|
||||
|
||||
GlyphRunIterator iter(this, aRange);
|
||||
GlyphRunIterator iter(this, aStart, aLength);
|
||||
gfxFloat advance = 0.0;
|
||||
|
||||
while (iter.NextRun()) {
|
||||
gfxFont *font = iter.GetGlyphRun()->mFont;
|
||||
uint32_t start = iter.GetStringStart();
|
||||
uint32_t end = iter.GetStringEnd();
|
||||
Range ligatureRange(start, end);
|
||||
ShrinkToLigatureBoundaries(&ligatureRange);
|
||||
uint32_t ligatureRunStart = start;
|
||||
uint32_t ligatureRunEnd = end;
|
||||
ShrinkToLigatureBoundaries(&ligatureRunStart, &ligatureRunEnd);
|
||||
|
||||
bool drawPartial = aDrawMode == DrawMode::GLYPH_FILL ||
|
||||
(aDrawMode == DrawMode::GLYPH_PATH && aCallbacks);
|
||||
gfxPoint origPt = aPt;
|
||||
|
||||
if (drawPartial) {
|
||||
DrawPartialLigature(font, Range(start, ligatureRange.start),
|
||||
&aPt, aProvider, params,
|
||||
DrawPartialLigature(font, start, ligatureRunStart, &aPt,
|
||||
aProvider, params,
|
||||
iter.GetGlyphRun()->mOrientation);
|
||||
}
|
||||
|
||||
DrawGlyphs(font, ligatureRange, &aPt,
|
||||
aProvider, ligatureRange, params,
|
||||
DrawGlyphs(font, ligatureRunStart, ligatureRunEnd, &aPt,
|
||||
aProvider, ligatureRunStart, ligatureRunEnd, params,
|
||||
iter.GetGlyphRun()->mOrientation);
|
||||
|
||||
if (drawPartial) {
|
||||
DrawPartialLigature(font, Range(ligatureRange.end, end),
|
||||
&aPt, aProvider, params,
|
||||
DrawPartialLigature(font, ligatureRunEnd, end, &aPt,
|
||||
aProvider, params,
|
||||
iter.GetGlyphRun()->mOrientation);
|
||||
}
|
||||
|
||||
|
@ -688,9 +684,10 @@ gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, DrawMode aDrawMode,
|
|||
void
|
||||
gfxTextRun::DrawEmphasisMarks(gfxContext *aContext, gfxTextRun* aMark,
|
||||
gfxFloat aMarkAdvance, gfxPoint aPt,
|
||||
Range aRange, PropertyProvider* aProvider)
|
||||
uint32_t aStart, uint32_t aLength,
|
||||
PropertyProvider* aProvider)
|
||||
{
|
||||
MOZ_ASSERT(aRange.end <= GetLength());
|
||||
MOZ_ASSERT(aStart + aLength <= GetLength());
|
||||
|
||||
EmphasisMarkDrawParams params;
|
||||
params.context = aContext;
|
||||
|
@ -702,65 +699,69 @@ gfxTextRun::DrawEmphasisMarks(gfxContext *aContext, gfxTextRun* aMark,
|
|||
gfxFloat& inlineCoord = params.isVertical ? aPt.y : aPt.x;
|
||||
gfxFloat direction = params.direction;
|
||||
|
||||
GlyphRunIterator iter(this, aRange);
|
||||
GlyphRunIterator iter(this, aStart, aLength);
|
||||
while (iter.NextRun()) {
|
||||
gfxFont* font = iter.GetGlyphRun()->mFont;
|
||||
uint32_t start = iter.GetStringStart();
|
||||
uint32_t end = iter.GetStringEnd();
|
||||
Range ligatureRange(start, end);
|
||||
ShrinkToLigatureBoundaries(&ligatureRange);
|
||||
uint32_t ligatureRunStart = start;
|
||||
uint32_t ligatureRunEnd = end;
|
||||
ShrinkToLigatureBoundaries(&ligatureRunStart, &ligatureRunEnd);
|
||||
|
||||
inlineCoord += direction * ComputePartialLigatureWidth(
|
||||
Range(start, ligatureRange.start), aProvider);
|
||||
inlineCoord += direction *
|
||||
ComputePartialLigatureWidth(start, ligatureRunStart, aProvider);
|
||||
|
||||
AutoTArray<PropertyProvider::Spacing, 200> spacingBuffer;
|
||||
bool haveSpacing = GetAdjustedSpacingArray(
|
||||
ligatureRange, aProvider, ligatureRange, &spacingBuffer);
|
||||
ligatureRunStart, ligatureRunEnd, aProvider,
|
||||
ligatureRunStart, ligatureRunEnd, &spacingBuffer);
|
||||
params.spacing = haveSpacing ? spacingBuffer.Elements() : nullptr;
|
||||
font->DrawEmphasisMarks(this, &aPt, ligatureRange.start,
|
||||
ligatureRange.Length(), params);
|
||||
font->DrawEmphasisMarks(this, &aPt, ligatureRunStart,
|
||||
ligatureRunEnd - ligatureRunStart, params);
|
||||
|
||||
inlineCoord += direction * ComputePartialLigatureWidth(
|
||||
Range(ligatureRange.end, end), aProvider);
|
||||
inlineCoord += direction *
|
||||
ComputePartialLigatureWidth(ligatureRunEnd, end, aProvider);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxTextRun::AccumulateMetricsForRun(gfxFont *aFont, Range aRange,
|
||||
gfxTextRun::AccumulateMetricsForRun(gfxFont *aFont,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
gfxFont::BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aRefDrawTarget,
|
||||
PropertyProvider *aProvider,
|
||||
Range aSpacingRange,
|
||||
uint32_t aSpacingStart, uint32_t aSpacingEnd,
|
||||
uint16_t aOrientation,
|
||||
Metrics *aMetrics)
|
||||
{
|
||||
AutoTArray<PropertyProvider::Spacing,200> spacingBuffer;
|
||||
bool haveSpacing = GetAdjustedSpacingArray(aRange, aProvider,
|
||||
aSpacingRange, &spacingBuffer);
|
||||
Metrics metrics = aFont->Measure(this, aRange.start, aRange.end,
|
||||
aBoundingBoxType, aRefDrawTarget,
|
||||
bool haveSpacing = GetAdjustedSpacingArray(aStart, aEnd, aProvider,
|
||||
aSpacingStart, aSpacingEnd, &spacingBuffer);
|
||||
Metrics metrics = aFont->Measure(this, aStart, aEnd, aBoundingBoxType,
|
||||
aRefDrawTarget,
|
||||
haveSpacing ? spacingBuffer.Elements() : nullptr,
|
||||
aOrientation);
|
||||
aMetrics->CombineWith(metrics, IsRightToLeft());
|
||||
}
|
||||
|
||||
void
|
||||
gfxTextRun::AccumulatePartialLigatureMetrics(gfxFont *aFont, Range aRange,
|
||||
gfxTextRun::AccumulatePartialLigatureMetrics(gfxFont *aFont,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
gfxFont::BoundingBoxType aBoundingBoxType, DrawTarget* aRefDrawTarget,
|
||||
PropertyProvider *aProvider, uint16_t aOrientation, Metrics *aMetrics)
|
||||
{
|
||||
if (aRange.start >= aRange.end)
|
||||
if (aStart >= aEnd)
|
||||
return;
|
||||
|
||||
// Measure partial ligature. We hack this by clipping the metrics in the
|
||||
// same way we clip the drawing.
|
||||
LigatureData data = ComputeLigatureData(aRange, aProvider);
|
||||
LigatureData data = ComputeLigatureData(aStart, aEnd, aProvider);
|
||||
|
||||
// First measure the complete ligature
|
||||
Metrics metrics;
|
||||
AccumulateMetricsForRun(aFont, data.mRange,
|
||||
AccumulateMetricsForRun(aFont, data.mLigatureStart, data.mLigatureEnd,
|
||||
aBoundingBoxType, aRefDrawTarget,
|
||||
aProvider, aRange, aOrientation, &metrics);
|
||||
aProvider, aStart, aEnd, aOrientation, &metrics);
|
||||
|
||||
// Clip the bounding box to the ligature part
|
||||
gfxFloat bboxLeft = metrics.mBoundingBox.X();
|
||||
|
@ -782,24 +783,24 @@ gfxTextRun::AccumulatePartialLigatureMetrics(gfxFont *aFont, Range aRange,
|
|||
}
|
||||
|
||||
gfxTextRun::Metrics
|
||||
gfxTextRun::MeasureText(Range aRange,
|
||||
gfxTextRun::MeasureText(uint32_t aStart, uint32_t aLength,
|
||||
gfxFont::BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aRefDrawTarget,
|
||||
PropertyProvider *aProvider)
|
||||
{
|
||||
NS_ASSERTION(aRange.end <= GetLength(), "Substring out of range");
|
||||
NS_ASSERTION(aStart + aLength <= GetLength(), "Substring out of range");
|
||||
|
||||
Metrics accumulatedMetrics;
|
||||
GlyphRunIterator iter(this, aRange);
|
||||
GlyphRunIterator iter(this, aStart, aLength);
|
||||
while (iter.NextRun()) {
|
||||
gfxFont *font = iter.GetGlyphRun()->mFont;
|
||||
uint32_t start = iter.GetStringStart();
|
||||
uint32_t end = iter.GetStringEnd();
|
||||
Range ligatureRange(start, end);
|
||||
ShrinkToLigatureBoundaries(&ligatureRange);
|
||||
uint32_t ligatureRunStart = start;
|
||||
uint32_t ligatureRunEnd = end;
|
||||
ShrinkToLigatureBoundaries(&ligatureRunStart, &ligatureRunEnd);
|
||||
|
||||
AccumulatePartialLigatureMetrics(
|
||||
font, Range(start, ligatureRange.start),
|
||||
AccumulatePartialLigatureMetrics(font, start, ligatureRunStart,
|
||||
aBoundingBoxType, aRefDrawTarget, aProvider,
|
||||
iter.GetGlyphRun()->mOrientation, &accumulatedMetrics);
|
||||
|
||||
|
@ -809,12 +810,11 @@ gfxTextRun::MeasureText(Range aRange,
|
|||
// by getting some ascent/descent from the font and using our stored
|
||||
// advance widths.
|
||||
AccumulateMetricsForRun(font,
|
||||
ligatureRange, aBoundingBoxType,
|
||||
aRefDrawTarget, aProvider, ligatureRange,
|
||||
ligatureRunStart, ligatureRunEnd, aBoundingBoxType,
|
||||
aRefDrawTarget, aProvider, ligatureRunStart, ligatureRunEnd,
|
||||
iter.GetGlyphRun()->mOrientation, &accumulatedMetrics);
|
||||
|
||||
AccumulatePartialLigatureMetrics(
|
||||
font, Range(ligatureRange.end, end),
|
||||
AccumulatePartialLigatureMetrics(font, ligatureRunEnd, end,
|
||||
aBoundingBoxType, aRefDrawTarget, aProvider,
|
||||
iter.GetGlyphRun()->mOrientation, &accumulatedMetrics);
|
||||
}
|
||||
|
@ -842,12 +842,13 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
|
|||
|
||||
NS_ASSERTION(aStart + aMaxLength <= GetLength(), "Substring out of range");
|
||||
|
||||
Range bufferRange(aStart, aStart +
|
||||
std::min<uint32_t>(aMaxLength, MEASUREMENT_BUFFER_SIZE));
|
||||
uint32_t bufferStart = aStart;
|
||||
uint32_t bufferLength = std::min<uint32_t>(aMaxLength, MEASUREMENT_BUFFER_SIZE);
|
||||
PropertyProvider::Spacing spacingBuffer[MEASUREMENT_BUFFER_SIZE];
|
||||
bool haveSpacing = aProvider && (mFlags & gfxTextRunFactory::TEXT_ENABLE_SPACING) != 0;
|
||||
if (haveSpacing) {
|
||||
GetAdjustedSpacing(this, bufferRange, aProvider, spacingBuffer);
|
||||
GetAdjustedSpacing(this, bufferStart, bufferStart + bufferLength, aProvider,
|
||||
spacingBuffer);
|
||||
}
|
||||
bool hyphenBuffer[MEASUREMENT_BUFFER_SIZE];
|
||||
bool haveHyphenation = aProvider &&
|
||||
|
@ -855,7 +856,8 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
|
|||
(aProvider->GetHyphensOption() == NS_STYLE_HYPHENS_MANUAL &&
|
||||
(mFlags & gfxTextRunFactory::TEXT_ENABLE_HYPHEN_BREAKS) != 0));
|
||||
if (haveHyphenation) {
|
||||
aProvider->GetHyphenationBreaks(bufferRange, hyphenBuffer);
|
||||
aProvider->GetHyphenationBreaks(bufferStart, bufferLength,
|
||||
hyphenBuffer);
|
||||
}
|
||||
|
||||
gfxFloat width = 0;
|
||||
|
@ -871,21 +873,23 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
|
|||
uint32_t end = aStart + aMaxLength;
|
||||
bool lastBreakUsedHyphenation = false;
|
||||
|
||||
Range ligatureRange(aStart, end);
|
||||
ShrinkToLigatureBoundaries(&ligatureRange);
|
||||
uint32_t ligatureRunStart = aStart;
|
||||
uint32_t ligatureRunEnd = end;
|
||||
ShrinkToLigatureBoundaries(&ligatureRunStart, &ligatureRunEnd);
|
||||
|
||||
uint32_t i;
|
||||
for (i = aStart; i < end; ++i) {
|
||||
if (i >= bufferRange.end) {
|
||||
if (i >= bufferStart + bufferLength) {
|
||||
// Fetch more spacing and hyphenation data
|
||||
bufferRange.start = i;
|
||||
bufferRange.end = std::min(aStart + aMaxLength,
|
||||
i + MEASUREMENT_BUFFER_SIZE);
|
||||
bufferStart = i;
|
||||
bufferLength = std::min(aStart + aMaxLength, i + MEASUREMENT_BUFFER_SIZE) - i;
|
||||
if (haveSpacing) {
|
||||
GetAdjustedSpacing(this, bufferRange, aProvider, spacingBuffer);
|
||||
GetAdjustedSpacing(this, bufferStart, bufferStart + bufferLength, aProvider,
|
||||
spacingBuffer);
|
||||
}
|
||||
if (haveHyphenation) {
|
||||
aProvider->GetHyphenationBreaks(bufferRange, hyphenBuffer);
|
||||
aProvider->GetHyphenationBreaks(bufferStart, bufferLength,
|
||||
hyphenBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -896,8 +900,8 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
|
|||
if (aSuppressBreak != eSuppressAllBreaks &&
|
||||
(aSuppressBreak != eSuppressInitialBreak || i > aStart)) {
|
||||
bool atNaturalBreak = mCharacterGlyphs[i].CanBreakBefore() == 1;
|
||||
bool atHyphenationBreak = !atNaturalBreak &&
|
||||
haveHyphenation && hyphenBuffer[i - bufferRange.start];
|
||||
bool atHyphenationBreak =
|
||||
!atNaturalBreak && haveHyphenation && hyphenBuffer[i - bufferStart];
|
||||
bool atBreak = atNaturalBreak || atHyphenationBreak;
|
||||
bool wordWrapping =
|
||||
aCanWordWrap && mCharacterGlyphs[i].IsClusterStart() &&
|
||||
|
@ -930,16 +934,14 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
|
|||
}
|
||||
|
||||
gfxFloat charAdvance;
|
||||
if (i >= ligatureRange.start && i < ligatureRange.end) {
|
||||
charAdvance = GetAdvanceForGlyphs(Range(i, i + 1));
|
||||
if (i >= ligatureRunStart && i < ligatureRunEnd) {
|
||||
charAdvance = GetAdvanceForGlyphs(i, i + 1);
|
||||
if (haveSpacing) {
|
||||
PropertyProvider::Spacing *space =
|
||||
&spacingBuffer[i - bufferRange.start];
|
||||
PropertyProvider::Spacing *space = &spacingBuffer[i - bufferStart];
|
||||
charAdvance += space->mBefore + space->mAfter;
|
||||
}
|
||||
} else {
|
||||
charAdvance =
|
||||
ComputePartialLigatureWidth(Range(i, i + 1), aProvider);
|
||||
charAdvance = ComputePartialLigatureWidth(i, i + 1, aProvider);
|
||||
}
|
||||
|
||||
advance += charAdvance;
|
||||
|
@ -976,13 +978,13 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
|
|||
}
|
||||
|
||||
if (aMetrics) {
|
||||
auto end = aStart + charsFit;
|
||||
*aMetrics = MeasureText(Range(aStart, end), aBoundingBoxType,
|
||||
*aMetrics = MeasureText(aStart, charsFit, aBoundingBoxType,
|
||||
aRefDrawTarget, aProvider);
|
||||
if (trimmableChars) {
|
||||
Metrics trimMetrics =
|
||||
MeasureText(Range(end - trimmableChars, end),
|
||||
aBoundingBoxType, aRefDrawTarget, aProvider);
|
||||
MeasureText(aStart + charsFit - trimmableChars,
|
||||
trimmableChars, aBoundingBoxType,
|
||||
aRefDrawTarget, aProvider);
|
||||
aMetrics->mAdvanceWidth -= trimMetrics.mAdvanceWidth;
|
||||
}
|
||||
}
|
||||
|
@ -1004,19 +1006,18 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
|
|||
}
|
||||
|
||||
gfxFloat
|
||||
gfxTextRun::GetAdvanceWidth(Range aRange, PropertyProvider *aProvider,
|
||||
gfxTextRun::GetAdvanceWidth(uint32_t aStart, uint32_t aLength,
|
||||
PropertyProvider *aProvider,
|
||||
PropertyProvider::Spacing* aSpacing)
|
||||
{
|
||||
NS_ASSERTION(aRange.end <= GetLength(), "Substring out of range");
|
||||
NS_ASSERTION(aStart + aLength <= GetLength(), "Substring out of range");
|
||||
|
||||
Range ligatureRange = aRange;
|
||||
ShrinkToLigatureBoundaries(&ligatureRange);
|
||||
uint32_t ligatureRunStart = aStart;
|
||||
uint32_t ligatureRunEnd = aStart + aLength;
|
||||
ShrinkToLigatureBoundaries(&ligatureRunStart, &ligatureRunEnd);
|
||||
|
||||
gfxFloat result =
|
||||
ComputePartialLigatureWidth(Range(aRange.start, ligatureRange.start),
|
||||
aProvider) +
|
||||
ComputePartialLigatureWidth(Range(ligatureRange.end, aRange.end),
|
||||
aProvider);
|
||||
gfxFloat result = ComputePartialLigatureWidth(aStart, ligatureRunStart, aProvider) +
|
||||
ComputePartialLigatureWidth(ligatureRunEnd, aStart + aLength, aProvider);
|
||||
|
||||
if (aSpacing) {
|
||||
aSpacing->mBefore = aSpacing->mAfter = 0;
|
||||
|
@ -1027,10 +1028,10 @@ gfxTextRun::GetAdvanceWidth(Range aRange, PropertyProvider *aProvider,
|
|||
if (aProvider && (mFlags & gfxTextRunFactory::TEXT_ENABLE_SPACING)) {
|
||||
uint32_t i;
|
||||
AutoTArray<PropertyProvider::Spacing,200> spacingBuffer;
|
||||
if (spacingBuffer.AppendElements(aRange.Length())) {
|
||||
GetAdjustedSpacing(this, ligatureRange, aProvider,
|
||||
if (spacingBuffer.AppendElements(aLength)) {
|
||||
GetAdjustedSpacing(this, ligatureRunStart, ligatureRunEnd, aProvider,
|
||||
spacingBuffer.Elements());
|
||||
for (i = 0; i < ligatureRange.Length(); ++i) {
|
||||
for (i = 0; i < ligatureRunEnd - ligatureRunStart; ++i) {
|
||||
PropertyProvider::Spacing *space = &spacingBuffer[i];
|
||||
result += space->mBefore + space->mAfter;
|
||||
}
|
||||
|
@ -1041,11 +1042,11 @@ gfxTextRun::GetAdvanceWidth(Range aRange, PropertyProvider *aProvider,
|
|||
}
|
||||
}
|
||||
|
||||
return result + GetAdvanceForGlyphs(ligatureRange);
|
||||
return result + GetAdvanceForGlyphs(ligatureRunStart, ligatureRunEnd);
|
||||
}
|
||||
|
||||
bool
|
||||
gfxTextRun::SetLineBreaks(Range aRange,
|
||||
gfxTextRun::SetLineBreaks(uint32_t aStart, uint32_t aLength,
|
||||
bool aLineBreakBefore, bool aLineBreakAfter,
|
||||
gfxFloat *aAdvanceWidthDelta)
|
||||
{
|
||||
|
@ -1243,11 +1244,12 @@ gfxTextRun::CopyGlyphDataFrom(gfxShapedWord *aShapedWord, uint32_t aOffset)
|
|||
}
|
||||
|
||||
void
|
||||
gfxTextRun::CopyGlyphDataFrom(gfxTextRun *aSource, Range aRange, uint32_t aDest)
|
||||
gfxTextRun::CopyGlyphDataFrom(gfxTextRun *aSource, uint32_t aStart,
|
||||
uint32_t aLength, uint32_t aDest)
|
||||
{
|
||||
NS_ASSERTION(aRange.end <= aSource->GetLength(),
|
||||
NS_ASSERTION(aStart + aLength <= aSource->GetLength(),
|
||||
"Source substring out of range");
|
||||
NS_ASSERTION(aDest + aRange.Length() <= GetLength(),
|
||||
NS_ASSERTION(aDest + aLength <= GetLength(),
|
||||
"Destination substring out of range");
|
||||
|
||||
if (aSource->mSkipDrawing) {
|
||||
|
@ -1255,9 +1257,9 @@ gfxTextRun::CopyGlyphDataFrom(gfxTextRun *aSource, Range aRange, uint32_t aDest)
|
|||
}
|
||||
|
||||
// Copy base glyph data, and DetailedGlyph data where present
|
||||
const CompressedGlyph *srcGlyphs = aSource->mCharacterGlyphs + aRange.start;
|
||||
const CompressedGlyph *srcGlyphs = aSource->mCharacterGlyphs + aStart;
|
||||
CompressedGlyph *dstGlyphs = mCharacterGlyphs + aDest;
|
||||
for (uint32_t i = 0; i < aRange.Length(); ++i) {
|
||||
for (uint32_t i = 0; i < aLength; ++i) {
|
||||
CompressedGlyph g = srcGlyphs[i];
|
||||
g.SetCanBreakBefore(!g.IsClusterStart() ?
|
||||
CompressedGlyph::FLAG_BREAK_TYPE_NONE :
|
||||
|
@ -1267,8 +1269,7 @@ gfxTextRun::CopyGlyphDataFrom(gfxTextRun *aSource, Range aRange, uint32_t aDest)
|
|||
if (count > 0) {
|
||||
DetailedGlyph *dst = AllocateDetailedGlyphs(i + aDest, count);
|
||||
if (dst) {
|
||||
DetailedGlyph *src =
|
||||
aSource->GetDetailedGlyphs(i + aRange.start);
|
||||
DetailedGlyph *src = aSource->GetDetailedGlyphs(i + aStart);
|
||||
if (src) {
|
||||
::memcpy(dst, src, count * sizeof(DetailedGlyph));
|
||||
} else {
|
||||
|
@ -1283,7 +1284,7 @@ gfxTextRun::CopyGlyphDataFrom(gfxTextRun *aSource, Range aRange, uint32_t aDest)
|
|||
}
|
||||
|
||||
// Copy glyph runs
|
||||
GlyphRunIterator iter(aSource, aRange);
|
||||
GlyphRunIterator iter(aSource, aStart, aLength);
|
||||
#ifdef DEBUG
|
||||
GlyphRun *prevRun = nullptr;
|
||||
#endif
|
||||
|
@ -1314,7 +1315,7 @@ gfxTextRun::CopyGlyphDataFrom(gfxTextRun *aSource, Range aRange, uint32_t aDest)
|
|||
"Ended font run in the middle of a cluster");
|
||||
|
||||
nsresult rv = AddGlyphRun(font, iter.GetGlyphRun()->mMatchType,
|
||||
start - aRange.start + aDest, false,
|
||||
start - aStart + aDest, false,
|
||||
iter.GetGlyphRun()->mOrientation);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
@ -1494,11 +1495,11 @@ gfxTextRun::ClusterIterator::NextCluster()
|
|||
return false;
|
||||
}
|
||||
|
||||
gfxTextRun::Range
|
||||
gfxTextRun::ClusterIterator::ClusterRange() const
|
||||
uint32_t
|
||||
gfxTextRun::ClusterIterator::ClusterLength() const
|
||||
{
|
||||
if (mCurrentChar == uint32_t(-1)) {
|
||||
return Range(0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t i = mCurrentChar,
|
||||
|
@ -1509,7 +1510,7 @@ gfxTextRun::ClusterIterator::ClusterRange() const
|
|||
}
|
||||
}
|
||||
|
||||
return Range(mCurrentChar, i);
|
||||
return i - mCurrentChar;
|
||||
}
|
||||
|
||||
gfxFloat
|
||||
|
@ -1519,7 +1520,7 @@ gfxTextRun::ClusterIterator::ClusterAdvance(PropertyProvider *aProvider) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
return mTextRun->GetAdvanceWidth(ClusterRange(), aProvider);
|
||||
return mTextRun->GetAdvanceWidth(mCurrentChar, ClusterLength(), aProvider);
|
||||
}
|
||||
|
||||
size_t
|
||||
|
|
|
@ -134,23 +134,10 @@ public:
|
|||
return mCharacterGlyphs[aPos].CharMayHaveEmphasisMark();
|
||||
}
|
||||
|
||||
// All offsets are in terms of the string passed into MakeTextRun.
|
||||
|
||||
// Describe range [start, end) of a text run. The range is
|
||||
// restricted to grapheme cluster boundaries.
|
||||
struct Range
|
||||
{
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
uint32_t Length() const { return end - start; }
|
||||
|
||||
Range() : start(0), end(0) {}
|
||||
Range(uint32_t aStart, uint32_t aEnd)
|
||||
: start(aStart), end(aEnd) {}
|
||||
explicit Range(gfxTextRun* aTextRun)
|
||||
: start(0), end(aTextRun->GetLength()) {}
|
||||
};
|
||||
|
||||
// All uint32_t aStart, uint32_t aLength ranges below are restricted to
|
||||
// grapheme cluster boundaries! All offsets are in terms of the string
|
||||
// passed into MakeTextRun.
|
||||
|
||||
// All coordinates are in layout/app units
|
||||
|
||||
/**
|
||||
|
@ -165,7 +152,8 @@ public:
|
|||
* @return true if this changed the linebreaks, false if the new line
|
||||
* breaks are the same as the old
|
||||
*/
|
||||
virtual bool SetPotentialLineBreaks(Range aRange, uint8_t *aBreakBefore);
|
||||
virtual bool SetPotentialLineBreaks(uint32_t aStart, uint32_t aLength,
|
||||
uint8_t *aBreakBefore);
|
||||
|
||||
/**
|
||||
* Layout provides PropertyProvider objects. These allow detection of
|
||||
|
@ -181,7 +169,8 @@ public:
|
|||
public:
|
||||
// Detect hyphenation break opportunities in the given range; breaks
|
||||
// not at cluster boundaries will be ignored.
|
||||
virtual void GetHyphenationBreaks(Range aRange, bool *aBreakBefore) = 0;
|
||||
virtual void GetHyphenationBreaks(uint32_t aStart, uint32_t aLength,
|
||||
bool *aBreakBefore) = 0;
|
||||
|
||||
// Returns the provider's hyphenation setting, so callers can decide
|
||||
// whether it is necessary to call GetHyphenationBreaks.
|
||||
|
@ -200,7 +189,8 @@ public:
|
|||
* CLUSTER_START, then character i-1 must have zero after-spacing and
|
||||
* character i must have zero before-spacing.
|
||||
*/
|
||||
virtual void GetSpacing(Range aRange, Spacing *aSpacing) = 0;
|
||||
virtual void GetSpacing(uint32_t aStart, uint32_t aLength,
|
||||
Spacing *aSpacing) = 0;
|
||||
|
||||
// Returns a gfxContext that can be used to measure the hyphen glyph.
|
||||
// Only called if the hyphen width is requested.
|
||||
|
@ -223,7 +213,7 @@ public:
|
|||
return mCurrentChar;
|
||||
}
|
||||
|
||||
Range ClusterRange() const;
|
||||
uint32_t ClusterLength() const;
|
||||
|
||||
gfxFloat ClusterAdvance(PropertyProvider *aProvider) const;
|
||||
|
||||
|
@ -240,21 +230,22 @@ public:
|
|||
* is returned here.
|
||||
*
|
||||
* Drawing should respect advance widths in the sense that for LTR runs,
|
||||
* Draw(ctx, pt, Range(start, middle), dirty, &provider, &advance) followed by
|
||||
* Draw(ctx, gfxPoint(pt.x + advance, pt.y), Range(middle, end),
|
||||
* Draw(ctx, pt, offset1, length1, dirty, &provider, &advance) followed by
|
||||
* Draw(ctx, gfxPoint(pt.x + advance, pt.y), offset1 + length1, length2,
|
||||
* dirty, &provider, nullptr) should have the same effect as
|
||||
* Draw(ctx, pt, Range(start, end), dirty, &provider, nullptr).
|
||||
* Draw(ctx, pt, offset1, length1+length2, dirty, &provider, nullptr).
|
||||
* For RTL runs the rule is:
|
||||
* Draw(ctx, pt, Range(middle, end), dirty, &provider, &advance) followed by
|
||||
* Draw(ctx, gfxPoint(pt.x + advance, pt.y), Range(start, middle),
|
||||
* Draw(ctx, pt, offset1 + length1, length2, dirty, &provider, &advance) followed by
|
||||
* Draw(ctx, gfxPoint(pt.x + advance, pt.y), offset1, length1,
|
||||
* dirty, &provider, nullptr) should have the same effect as
|
||||
* Draw(ctx, pt, Range(start, end), dirty, &provider, nullptr).
|
||||
* Draw(ctx, pt, offset1, length1+length2, dirty, &provider, nullptr).
|
||||
*
|
||||
* Glyphs should be drawn in logical content order, which can be significant
|
||||
* if they overlap (perhaps due to negative spacing).
|
||||
*/
|
||||
void Draw(gfxContext *aContext, gfxPoint aPt,
|
||||
DrawMode aDrawMode, Range aRange,
|
||||
DrawMode aDrawMode,
|
||||
uint32_t aStart, uint32_t aLength,
|
||||
PropertyProvider *aProvider,
|
||||
gfxFloat *aAdvanceWidth, gfxTextContextPaint *aContextPaint,
|
||||
gfxTextRunDrawCallbacks *aCallbacks = nullptr);
|
||||
|
@ -266,14 +257,15 @@ public:
|
|||
*/
|
||||
void DrawEmphasisMarks(gfxContext* aContext, gfxTextRun* aMark,
|
||||
gfxFloat aMarkAdvance, gfxPoint aPt,
|
||||
Range aRange, PropertyProvider* aProvider);
|
||||
uint32_t aStart, uint32_t aLength,
|
||||
PropertyProvider* aProvider);
|
||||
|
||||
/**
|
||||
* Computes the ReflowMetrics for a substring.
|
||||
* Uses GetSpacing from aBreakProvider.
|
||||
* @param aBoundingBoxType which kind of bounding box (loose/tight)
|
||||
*/
|
||||
Metrics MeasureText(Range aRange,
|
||||
Metrics MeasureText(uint32_t aStart, uint32_t aLength,
|
||||
gfxFont::BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aDrawTargetForTightBoundingBox,
|
||||
PropertyProvider* aProvider);
|
||||
|
@ -281,7 +273,7 @@ public:
|
|||
Metrics MeasureText(gfxFont::BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aDrawTargetForTightBoundingBox,
|
||||
PropertyProvider* aProvider = nullptr) {
|
||||
return MeasureText(Range(this), aBoundingBoxType,
|
||||
return MeasureText(0, GetLength(), aBoundingBoxType,
|
||||
aDrawTargetForTightBoundingBox, aProvider);
|
||||
}
|
||||
|
||||
|
@ -292,16 +284,17 @@ public:
|
|||
* the substring would be returned in it. NOTE: the spacing is
|
||||
* included in the advance width.
|
||||
*/
|
||||
gfxFloat GetAdvanceWidth(Range aRange, PropertyProvider *aProvider,
|
||||
gfxFloat GetAdvanceWidth(uint32_t aStart, uint32_t aLength,
|
||||
PropertyProvider *aProvider,
|
||||
PropertyProvider::Spacing* aSpacing = nullptr);
|
||||
|
||||
gfxFloat GetAdvanceWidth() {
|
||||
return GetAdvanceWidth(Range(this), nullptr);
|
||||
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 aRange.start to aBreakBefore and
|
||||
* and then set the line-break state before aStart to aBreakBefore and
|
||||
* after the last cluster to aBreakAfter.
|
||||
*
|
||||
* We require that before and after line breaks be consistent. For clusters
|
||||
|
@ -326,9 +319,9 @@ public:
|
|||
* @param aAdvanceWidthDelta if non-null, returns the change in advance
|
||||
* width of the given range.
|
||||
*/
|
||||
virtual bool SetLineBreaks(Range aRange,
|
||||
bool aLineBreakBefore, bool aLineBreakAfter,
|
||||
gfxFloat* aAdvanceWidthDelta);
|
||||
virtual bool SetLineBreaks(uint32_t aStart, uint32_t aLength,
|
||||
bool aLineBreakBefore, bool aLineBreakAfter,
|
||||
gfxFloat* aAdvanceWidthDelta);
|
||||
|
||||
enum SuppressBreak {
|
||||
eNoSuppressBreak,
|
||||
|
@ -441,11 +434,9 @@ public:
|
|||
|
||||
class GlyphRunIterator {
|
||||
public:
|
||||
GlyphRunIterator(gfxTextRun *aTextRun, Range aRange)
|
||||
: mTextRun(aTextRun)
|
||||
, mStartOffset(aRange.start)
|
||||
, mEndOffset(aRange.end) {
|
||||
mNextIndex = mTextRun->FindFirstGlyphRunContaining(aRange.start);
|
||||
GlyphRunIterator(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aLength)
|
||||
: mTextRun(aTextRun), mStartOffset(aStart), mEndOffset(aStart + aLength) {
|
||||
mNextIndex = mTextRun->FindFirstGlyphRunContaining(aStart);
|
||||
}
|
||||
bool NextRun();
|
||||
GlyphRun *GetGlyphRun() { return mGlyphRun; }
|
||||
|
@ -566,7 +557,8 @@ public:
|
|||
|
||||
// Copy glyph data for a range of characters from aSource to this
|
||||
// textrun.
|
||||
void CopyGlyphDataFrom(gfxTextRun *aSource, Range aRange, uint32_t aDest);
|
||||
void CopyGlyphDataFrom(gfxTextRun *aSource, uint32_t aStart,
|
||||
uint32_t aLength, uint32_t aDest);
|
||||
|
||||
nsExpirationState *GetExpirationState() { return &mExpirationState; }
|
||||
|
||||
|
@ -579,8 +571,9 @@ public:
|
|||
void ReleaseFontGroup();
|
||||
|
||||
struct LigatureData {
|
||||
// textrun range of the containing ligature
|
||||
Range mRange;
|
||||
// textrun offsets of the start and end of the containing ligature
|
||||
uint32_t mLigatureStart;
|
||||
uint32_t mLigatureEnd;
|
||||
// appunits advance to the start of the ligature part within the ligature;
|
||||
// never includes any spacing
|
||||
gfxFloat mPartAdvance;
|
||||
|
@ -676,15 +669,16 @@ private:
|
|||
// **** general helpers ****
|
||||
|
||||
// Get the total advance for a range of glyphs.
|
||||
int32_t GetAdvanceForGlyphs(Range aRange);
|
||||
int32_t GetAdvanceForGlyphs(uint32_t aStart, uint32_t aEnd);
|
||||
|
||||
// Spacing for characters outside the range aSpacingStart/aSpacingEnd
|
||||
// is assumed to be zero; such characters are not passed to aProvider.
|
||||
// This is useful to protect aProvider from being passed character indices
|
||||
// it is not currently able to handle.
|
||||
bool GetAdjustedSpacingArray(Range aRange, PropertyProvider *aProvider,
|
||||
Range aSpacingRange,
|
||||
nsTArray<PropertyProvider::Spacing> *aSpacing);
|
||||
bool GetAdjustedSpacingArray(uint32_t aStart, uint32_t aEnd,
|
||||
PropertyProvider *aProvider,
|
||||
uint32_t aSpacingStart, uint32_t aSpacingEnd,
|
||||
nsTArray<PropertyProvider::Spacing> *aSpacing);
|
||||
|
||||
CompressedGlyph& EnsureComplexGlyph(uint32_t aIndex)
|
||||
{
|
||||
|
@ -697,20 +691,20 @@ private:
|
|||
// to handle requests that begin or end inside a ligature)
|
||||
|
||||
// if aProvider is null then mBeforeSpacing and mAfterSpacing are set to zero
|
||||
LigatureData ComputeLigatureData(Range aPartRange,
|
||||
LigatureData ComputeLigatureData(uint32_t aPartStart, uint32_t aPartEnd,
|
||||
PropertyProvider *aProvider);
|
||||
gfxFloat ComputePartialLigatureWidth(Range aPartRange,
|
||||
gfxFloat ComputePartialLigatureWidth(uint32_t aPartStart, uint32_t aPartEnd,
|
||||
PropertyProvider *aProvider);
|
||||
void DrawPartialLigature(gfxFont *aFont, Range aRange,
|
||||
void DrawPartialLigature(gfxFont *aFont, uint32_t aStart, uint32_t aEnd,
|
||||
gfxPoint *aPt, PropertyProvider *aProvider,
|
||||
TextRunDrawParams& aParams, uint16_t aOrientation);
|
||||
// Advance aRange.start to the start of the nearest ligature, back
|
||||
// up aRange.end to the nearest ligature end; may result in
|
||||
// aRange->start == aRange->end.
|
||||
void ShrinkToLigatureBoundaries(Range* aRange);
|
||||
// Advance aStart to the start of the nearest ligature; back up aEnd
|
||||
// to the nearest ligature end; may result in *aStart == *aEnd
|
||||
void ShrinkToLigatureBoundaries(uint32_t *aStart, uint32_t *aEnd);
|
||||
// result in appunits
|
||||
gfxFloat GetPartialLigatureWidth(Range aRange, PropertyProvider *aProvider);
|
||||
void AccumulatePartialLigatureMetrics(gfxFont *aFont, Range aRange,
|
||||
gfxFloat GetPartialLigatureWidth(uint32_t aStart, uint32_t aEnd, PropertyProvider *aProvider);
|
||||
void AccumulatePartialLigatureMetrics(gfxFont *aFont,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
gfxFont::BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aRefDrawTarget,
|
||||
PropertyProvider *aProvider,
|
||||
|
@ -718,17 +712,18 @@ private:
|
|||
Metrics *aMetrics);
|
||||
|
||||
// **** measurement helper ****
|
||||
void AccumulateMetricsForRun(gfxFont *aFont, Range aRange,
|
||||
void AccumulateMetricsForRun(gfxFont *aFont, uint32_t aStart, uint32_t aEnd,
|
||||
gfxFont::BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aRefDrawTarget,
|
||||
PropertyProvider *aProvider,
|
||||
Range aSpacingRange,
|
||||
uint32_t aSpacingStart, uint32_t aSpacingEnd,
|
||||
uint16_t aOrientation,
|
||||
Metrics *aMetrics);
|
||||
|
||||
// **** drawing helper ****
|
||||
void DrawGlyphs(gfxFont *aFont, Range aRange, gfxPoint *aPt,
|
||||
PropertyProvider *aProvider, Range aSpacingRange,
|
||||
void DrawGlyphs(gfxFont *aFont, uint32_t aStart, uint32_t aEnd,
|
||||
gfxPoint *aPt, PropertyProvider *aProvider,
|
||||
uint32_t aSpacingStart, uint32_t aSpacingEnd,
|
||||
TextRunDrawParams& aParams, uint16_t aOrientation);
|
||||
|
||||
// XXX this should be changed to a GlyphRun plus a maybe-null GlyphRun*,
|
||||
|
|
|
@ -773,15 +773,12 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
|||
}
|
||||
if (!child)
|
||||
return;
|
||||
|
||||
typedef gfxTextRun::Range Range;
|
||||
|
||||
// Copy potential linebreaks into child so they're preserved
|
||||
// (and also child will be shaped appropriately)
|
||||
NS_ASSERTION(convertedString.Length() == canBreakBeforeArray.Length(),
|
||||
"Dropped characters or break-before values somewhere!");
|
||||
Range range(0, uint32_t(canBreakBeforeArray.Length()));
|
||||
child->SetPotentialLineBreaks(range, canBreakBeforeArray.Elements());
|
||||
child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(),
|
||||
canBreakBeforeArray.Elements());
|
||||
if (transformedChild) {
|
||||
transformedChild->FinishSettingProperties(aRefDrawTarget, aMFR);
|
||||
}
|
||||
|
@ -799,6 +796,6 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
|||
// We can't steal the data because the child may be cached and stealing
|
||||
// the data would break the cache.
|
||||
aTextRun->ResetGlyphRuns();
|
||||
aTextRun->CopyGlyphDataFrom(child, Range(child), 0);
|
||||
aTextRun->CopyGlyphDataFrom(child, 0, child->GetLength(), 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ nsDisplayTextOverflowMarker::PaintTextToContext(nsRenderingContext* aCtx,
|
|||
"Ellipsis textruns should always be LTR!");
|
||||
gfxPoint gfxPt(pt.x, pt.y);
|
||||
textRun->Draw(aCtx->ThebesContext(), gfxPt, DrawMode::GLYPH_FILL,
|
||||
gfxTextRun::Range(textRun), nullptr, nullptr, nullptr);
|
||||
0, textRun->GetLength(), nullptr, nullptr, nullptr);
|
||||
}
|
||||
} else {
|
||||
RefPtr<nsFontMetrics> fm;
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -45,7 +45,6 @@ class nsTextFrame : public nsTextFrameBase {
|
|||
typedef mozilla::gfx::Point Point;
|
||||
typedef mozilla::gfx::Rect Rect;
|
||||
typedef mozilla::gfx::Size Size;
|
||||
typedef gfxTextRun::Range Range;
|
||||
|
||||
public:
|
||||
NS_DECL_QUERYFRAME_TARGET(nsTextFrame)
|
||||
|
@ -407,7 +406,8 @@ public:
|
|||
const gfxPoint& aTextBaselinePt,
|
||||
const gfxRect& aDirtyRect,
|
||||
PropertyProvider& aProvider,
|
||||
Range aRange,
|
||||
uint32_t aContentOffset,
|
||||
uint32_t aContentLength,
|
||||
nsTextPaintStyle& aTextPaintStyle,
|
||||
const nsCharClipDisplayItem::ClipEdges& aClipEdges,
|
||||
gfxTextContextPaint* aContextPaint,
|
||||
|
@ -422,7 +422,8 @@ public:
|
|||
const gfxPoint& aTextBaselinePt,
|
||||
const gfxRect& aDirtyRect,
|
||||
PropertyProvider& aProvider,
|
||||
Range aContentRange,
|
||||
uint32_t aContentOffset,
|
||||
uint32_t aContentLength,
|
||||
nsTextPaintStyle& aTextPaintStyle,
|
||||
SelectionDetails* aDetails,
|
||||
SelectionType* aAllTypes,
|
||||
|
@ -434,7 +435,8 @@ public:
|
|||
const gfxPoint& aTextBaselinePt,
|
||||
const gfxRect& aDirtyRect,
|
||||
PropertyProvider& aProvider,
|
||||
Range aContentRange,
|
||||
uint32_t aContentOffset,
|
||||
uint32_t aContentLength,
|
||||
nsTextPaintStyle& aTextPaintStyle,
|
||||
SelectionDetails* aDetails,
|
||||
SelectionType aSelectionType,
|
||||
|
@ -443,7 +445,7 @@ public:
|
|||
void DrawEmphasisMarks(gfxContext* aContext,
|
||||
mozilla::WritingMode aWM,
|
||||
const gfxPoint& aTextBaselinePt,
|
||||
Range aRange,
|
||||
uint32_t aOffset, uint32_t aLength,
|
||||
const nscolor* aDecorationOverrideColor,
|
||||
PropertyProvider& aProvider);
|
||||
|
||||
|
@ -596,7 +598,8 @@ protected:
|
|||
nsRect UpdateTextEmphasis(mozilla::WritingMode aWM,
|
||||
PropertyProvider& aProvider);
|
||||
|
||||
void PaintOneShadow(Range aRange,
|
||||
void PaintOneShadow(uint32_t aOffset,
|
||||
uint32_t aLength,
|
||||
nsCSSShadowItem* aShadowDetails,
|
||||
PropertyProvider* aProvider,
|
||||
const nsRect& aDirtyRect,
|
||||
|
@ -610,7 +613,7 @@ protected:
|
|||
uint32_t aBlurFlags);
|
||||
|
||||
void PaintShadows(nsCSSShadowArray* aShadow,
|
||||
Range aRange,
|
||||
uint32_t aOffset, uint32_t aLength,
|
||||
const nsRect& aDirtyRect,
|
||||
const gfxPoint& aFramePt,
|
||||
const gfxPoint& aTextBaselinePt,
|
||||
|
@ -696,7 +699,8 @@ protected:
|
|||
|
||||
void DrawTextRun(gfxContext* const aCtx,
|
||||
const gfxPoint& aTextBaselinePt,
|
||||
Range aRange,
|
||||
uint32_t aOffset,
|
||||
uint32_t aLength,
|
||||
PropertyProvider& aProvider,
|
||||
nscolor aTextColor,
|
||||
gfxFloat& aAdvanceWidth,
|
||||
|
@ -708,7 +712,8 @@ protected:
|
|||
const gfxRect& aDirtyRect,
|
||||
const gfxPoint& aFramePt,
|
||||
const gfxPoint& aTextBaselinePt,
|
||||
Range aRange,
|
||||
uint32_t aOffset,
|
||||
uint32_t aLength,
|
||||
PropertyProvider& aProvider,
|
||||
const nsTextPaintStyle& aTextStyle,
|
||||
nscolor aTextColor,
|
||||
|
@ -724,7 +729,8 @@ protected:
|
|||
const gfxRect& aDirtyRect,
|
||||
const gfxPoint& aFramePt,
|
||||
const gfxPoint& aTextBaselinePt,
|
||||
Range aRange,
|
||||
uint32_t aOffset,
|
||||
uint32_t aLength,
|
||||
PropertyProvider& aProvider,
|
||||
const nsTextPaintStyle& aTextStyle,
|
||||
nscolor aTextColor,
|
||||
|
|
|
@ -69,11 +69,11 @@ nsTransformedTextRun::SetCapitalization(uint32_t aStart, uint32_t aLength,
|
|||
}
|
||||
|
||||
bool
|
||||
nsTransformedTextRun::SetPotentialLineBreaks(Range aRange,
|
||||
nsTransformedTextRun::SetPotentialLineBreaks(uint32_t aStart, uint32_t aLength,
|
||||
uint8_t* aBreakBefore)
|
||||
{
|
||||
bool changed =
|
||||
gfxTextRun::SetPotentialLineBreaks(aRange, aBreakBefore);
|
||||
gfxTextRun::SetPotentialLineBreaks(aStart, aLength, aBreakBefore);
|
||||
if (changed) {
|
||||
mNeedsRebuild = true;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ MergeCharactersInTextRun(gfxTextRun* aDest, gfxTextRun* aSrc,
|
|||
{
|
||||
aDest->ResetGlyphRuns();
|
||||
|
||||
gfxTextRun::GlyphRunIterator iter(aSrc, gfxTextRun::Range(aSrc));
|
||||
gfxTextRun::GlyphRunIterator iter(aSrc, 0, aSrc->GetLength());
|
||||
uint32_t offset = 0;
|
||||
AutoTArray<gfxTextRun::DetailedGlyph,2> glyphs;
|
||||
while (iter.NextRun()) {
|
||||
|
@ -646,8 +646,8 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
|||
// (and also child will be shaped appropriately)
|
||||
NS_ASSERTION(convertedString.Length() == canBreakBeforeArray.Length(),
|
||||
"Dropped characters or break-before values somewhere!");
|
||||
gfxTextRun::Range range(0, uint32_t(canBreakBeforeArray.Length()));
|
||||
child->SetPotentialLineBreaks(range, canBreakBeforeArray.Elements());
|
||||
child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(),
|
||||
canBreakBeforeArray.Elements());
|
||||
if (transformedChild) {
|
||||
transformedChild->FinishSettingProperties(aRefDrawTarget, aMFR);
|
||||
}
|
||||
|
@ -666,6 +666,6 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
|||
// We can't steal the data because the child may be cached and stealing
|
||||
// the data would break the cache.
|
||||
aTextRun->ResetGlyphRuns();
|
||||
aTextRun->CopyGlyphDataFrom(child, gfxTextRun::Range(child), 0);
|
||||
aTextRun->CopyGlyphDataFrom(child, 0, child->GetLength(), 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,8 @@ public:
|
|||
|
||||
void SetCapitalization(uint32_t aStart, uint32_t aLength,
|
||||
bool* aCapitalization);
|
||||
virtual bool SetPotentialLineBreaks(Range aRange, uint8_t* aBreakBefore);
|
||||
virtual bool SetPotentialLineBreaks(uint32_t aStart, uint32_t aLength,
|
||||
uint8_t* aBreakBefore);
|
||||
/**
|
||||
* Called after SetCapitalization and SetPotentialLineBreaks
|
||||
* are done and before we request any data from the textrun. Also always
|
||||
|
|
|
@ -60,8 +60,7 @@ nsresult
|
|||
nsFontFaceList::AddFontsFromTextRun(gfxTextRun* aTextRun,
|
||||
uint32_t aOffset, uint32_t aLength)
|
||||
{
|
||||
gfxTextRun::Range range(aOffset, aOffset + aLength);
|
||||
gfxTextRun::GlyphRunIterator iter(aTextRun, range);
|
||||
gfxTextRun::GlyphRunIterator iter(aTextRun, aOffset, aLength);
|
||||
while (iter.NextRun()) {
|
||||
gfxFontEntry *fe = iter.GetGlyphRun()->mFont->GetFontEntry();
|
||||
// if we have already listed this face, just make sure the match type is
|
||||
|
|
|
@ -2147,7 +2147,7 @@ nsMathMLChar::PaintForeground(nsPresContext* aPresContext,
|
|||
// XXXfredw verify if mGlyphs[0] is non-null to workaround bug 973322.
|
||||
if (mGlyphs[0]) {
|
||||
mGlyphs[0]->Draw(thebesContext, gfxPoint(0.0, mUnscaledAscent),
|
||||
DrawMode::GLYPH_FILL, Range(mGlyphs[0]),
|
||||
DrawMode::GLYPH_FILL, 0, mGlyphs[0]->GetLength(),
|
||||
nullptr, nullptr, nullptr);
|
||||
}
|
||||
break;
|
||||
|
@ -2304,7 +2304,7 @@ nsMathMLChar::PaintVertically(nsPresContext* aPresContext,
|
|||
if (!clipRect.IsEmpty()) {
|
||||
AutoPushClipRect clip(aThebesContext, oneDevPixel, clipRect);
|
||||
mGlyphs[i]->Draw(aThebesContext, gfxPoint(dx, dy),
|
||||
DrawMode::GLYPH_FILL, Range(mGlyphs[i]),
|
||||
DrawMode::GLYPH_FILL, 0, mGlyphs[i]->GetLength(),
|
||||
nullptr, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -2372,7 +2372,7 @@ nsMathMLChar::PaintVertically(nsPresContext* aPresContext,
|
|||
AutoPushClipRect clip(aThebesContext, oneDevPixel, clipRect);
|
||||
dy += bm.ascent;
|
||||
mGlyphs[3]->Draw(aThebesContext, gfxPoint(dx, dy),
|
||||
DrawMode::GLYPH_FILL, Range(mGlyphs[3]),
|
||||
DrawMode::GLYPH_FILL, 0, mGlyphs[3]->GetLength(),
|
||||
nullptr, nullptr, nullptr);
|
||||
dy += bm.descent;
|
||||
}
|
||||
|
@ -2476,7 +2476,7 @@ nsMathMLChar::PaintHorizontally(nsPresContext* aPresContext,
|
|||
if (!clipRect.IsEmpty()) {
|
||||
AutoPushClipRect clip(aThebesContext, oneDevPixel, clipRect);
|
||||
mGlyphs[i]->Draw(aThebesContext, gfxPoint(dx, dy),
|
||||
DrawMode::GLYPH_FILL, Range(mGlyphs[i]),
|
||||
DrawMode::GLYPH_FILL, 0, mGlyphs[i]->GetLength(),
|
||||
nullptr, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -2542,7 +2542,7 @@ nsMathMLChar::PaintHorizontally(nsPresContext* aPresContext,
|
|||
AutoPushClipRect clip(aThebesContext, oneDevPixel, clipRect);
|
||||
dx -= bm.leftBearing;
|
||||
mGlyphs[3]->Draw(aThebesContext, gfxPoint(dx, dy),
|
||||
DrawMode::GLYPH_FILL, Range(mGlyphs[3]),
|
||||
DrawMode::GLYPH_FILL, 0, mGlyphs[3]->GetLength(),
|
||||
nullptr, nullptr, nullptr);
|
||||
dx += bm.rightBearing;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "nsRect.h"
|
||||
#include "nsString.h"
|
||||
#include "nsBoundingMetrics.h"
|
||||
#include "gfxTextRun.h"
|
||||
#include "gfxFont.h"
|
||||
|
||||
class nsGlyphTable;
|
||||
class nsIFrame;
|
||||
|
@ -85,7 +85,6 @@ struct nsGlyphCode {
|
|||
class nsMathMLChar
|
||||
{
|
||||
public:
|
||||
typedef gfxTextRun::Range Range;
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
|
||||
// constructor and destructor
|
||||
|
|
|
@ -60,16 +60,34 @@ using namespace mozilla::gfx;
|
|||
* in original char indexes to skipped char indexes.
|
||||
*
|
||||
* @param aIterator The gfxSkipCharsIterator to use for the conversion.
|
||||
* @param aOriginalOffset The original offset.
|
||||
* @param aOriginalLength The original length.
|
||||
* @param aOriginalOffset The original offset (input).
|
||||
* @param aOriginalLength The original length (input).
|
||||
* @param aSkippedOffset The skipped offset (output).
|
||||
* @param aSkippedLength The skipped length (output).
|
||||
*/
|
||||
static gfxTextRun::Range
|
||||
static void
|
||||
ConvertOriginalToSkipped(gfxSkipCharsIterator& aIterator,
|
||||
uint32_t aOriginalOffset, uint32_t aOriginalLength)
|
||||
uint32_t aOriginalOffset, uint32_t aOriginalLength,
|
||||
uint32_t& aSkippedOffset, uint32_t& aSkippedLength)
|
||||
{
|
||||
uint32_t start = aIterator.ConvertOriginalToSkipped(aOriginalOffset);
|
||||
aSkippedOffset = aIterator.ConvertOriginalToSkipped(aOriginalOffset);
|
||||
aIterator.AdvanceOriginal(aOriginalLength);
|
||||
return gfxTextRun::Range(start, aIterator.GetSkippedOffset());
|
||||
aSkippedLength = aIterator.GetSkippedOffset() - aSkippedOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Using the specified gfxSkipCharsIterator, converts an offset and length
|
||||
* in original char indexes to skipped char indexes in place.
|
||||
*
|
||||
* @param aIterator The gfxSkipCharsIterator to use for the conversion.
|
||||
* @param aOriginalOffset The offset to convert from original to skipped.
|
||||
* @param aOriginalLength The length to convert from original to skipped.
|
||||
*/
|
||||
static void
|
||||
ConvertOriginalToSkipped(gfxSkipCharsIterator& aIterator,
|
||||
uint32_t& aOffset, uint32_t& aLength)
|
||||
{
|
||||
ConvertOriginalToSkipped(aIterator, aOffset, aLength, aOffset, aLength);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,11 +157,15 @@ GetAscentAndDescentInAppUnits(nsTextFrame* aFrame,
|
|||
gfxSkipCharsIterator it = aFrame->EnsureTextRun(nsTextFrame::eInflated);
|
||||
gfxTextRun* textRun = aFrame->GetTextRun(nsTextFrame::eInflated);
|
||||
|
||||
gfxTextRun::Range range = ConvertOriginalToSkipped(
|
||||
it, aFrame->GetContentOffset(), aFrame->GetContentLength());
|
||||
uint32_t offset, length;
|
||||
ConvertOriginalToSkipped(it,
|
||||
aFrame->GetContentOffset(),
|
||||
aFrame->GetContentLength(),
|
||||
offset, length);
|
||||
|
||||
gfxTextRun::Metrics metrics =
|
||||
textRun->MeasureText(range, gfxFont::LOOSE_INK_EXTENTS, nullptr, nullptr);
|
||||
textRun->MeasureText(offset, length, gfxFont::LOOSE_INK_EXTENTS, nullptr,
|
||||
nullptr);
|
||||
|
||||
aAscent = metrics.mAscent;
|
||||
aDescent = metrics.mDescent;
|
||||
|
@ -363,7 +385,7 @@ GetBaselinePosition(nsTextFrame* aFrame,
|
|||
}
|
||||
|
||||
/**
|
||||
* For a given text run, returns the range of skipped characters that comprise
|
||||
* For a given text run, returns the number of skipped characters that comprise
|
||||
* the ligature group and/or cluster that includes the character represented
|
||||
* by the specified gfxSkipCharsIterator.
|
||||
*
|
||||
|
@ -372,8 +394,8 @@ GetBaselinePosition(nsTextFrame* aFrame,
|
|||
* @param aIterator The gfxSkipCharsIterator to use for the current position
|
||||
* in the text run.
|
||||
*/
|
||||
static gfxTextRun::Range
|
||||
ClusterRange(gfxTextRun* aTextRun, const gfxSkipCharsIterator& aIterator)
|
||||
static uint32_t
|
||||
ClusterLength(gfxTextRun* aTextRun, const gfxSkipCharsIterator& aIterator)
|
||||
{
|
||||
uint32_t start = aIterator.GetSkippedOffset();
|
||||
uint32_t end = start + 1;
|
||||
|
@ -382,7 +404,7 @@ ClusterRange(gfxTextRun* aTextRun, const gfxSkipCharsIterator& aIterator)
|
|||
!aTextRun->IsClusterStart(end))) {
|
||||
end++;
|
||||
}
|
||||
return gfxTextRun::Range(start, end);
|
||||
return end - start;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -459,8 +481,6 @@ namespace mozilla {
|
|||
*/
|
||||
struct TextRenderedRun
|
||||
{
|
||||
typedef gfxTextRun::Range Range;
|
||||
|
||||
/**
|
||||
* Constructs a TextRenderedRun that is uninitialized except for mFrame
|
||||
* being null.
|
||||
|
@ -918,15 +938,17 @@ TextRenderedRun::GetRunUserSpaceRect(nsPresContext* aContext,
|
|||
gfxTextRun* textRun = mFrame->GetTextRun(nsTextFrame::eInflated);
|
||||
|
||||
// Get the content range for this rendered run.
|
||||
Range range = ConvertOriginalToSkipped(it, mTextFrameContentOffset,
|
||||
mTextFrameContentLength);
|
||||
if (range.Length() == 0) {
|
||||
uint32_t offset, length;
|
||||
ConvertOriginalToSkipped(it, mTextFrameContentOffset, mTextFrameContentLength,
|
||||
offset, length);
|
||||
if (length == 0) {
|
||||
return r;
|
||||
}
|
||||
|
||||
// Measure that range.
|
||||
gfxTextRun::Metrics metrics =
|
||||
textRun->MeasureText(range, gfxFont::LOOSE_INK_EXTENTS, nullptr, nullptr);
|
||||
textRun->MeasureText(offset, length, gfxFont::LOOSE_INK_EXTENTS,
|
||||
nullptr, nullptr);
|
||||
// Make sure it includes the font-box.
|
||||
gfxRect fontBox(0, -metrics.mAscent,
|
||||
metrics.mAdvanceWidth, metrics.mAscent + metrics.mDescent);
|
||||
|
@ -939,7 +961,7 @@ TextRenderedRun::GetRunUserSpaceRect(nsPresContext* aContext,
|
|||
gfxFloat x, width;
|
||||
if (aFlags & eNoHorizontalOverflow) {
|
||||
x = 0.0;
|
||||
width = textRun->GetAdvanceWidth(range, nullptr);
|
||||
width = textRun->GetAdvanceWidth(offset, length, nullptr);
|
||||
} else {
|
||||
x = metrics.mBoundingBox.x;
|
||||
width = metrics.mBoundingBox.width;
|
||||
|
@ -1036,12 +1058,13 @@ TextRenderedRun::GetClipEdges(nscoord& aVisIStartEdge,
|
|||
|
||||
// Get the covered content offset/length for this rendered run in skipped
|
||||
// characters, since that is what GetAdvanceWidth expects.
|
||||
Range runRange = ConvertOriginalToSkipped(it, mTextFrameContentOffset,
|
||||
mTextFrameContentLength);
|
||||
uint32_t runOffset, runLength, frameOffset, frameLength;
|
||||
ConvertOriginalToSkipped(it, mTextFrameContentOffset, mTextFrameContentLength,
|
||||
runOffset, runLength);
|
||||
|
||||
// Get the offset/length of the whole nsTextFrame.
|
||||
uint32_t frameOffset = mFrame->GetContentOffset();
|
||||
uint32_t frameLength = mFrame->GetContentLength();
|
||||
frameOffset = mFrame->GetContentOffset();
|
||||
frameLength = mFrame->GetContentLength();
|
||||
|
||||
// Trim the whole-nsTextFrame offset/length to remove any leading/trailing
|
||||
// white space, as the nsTextFrame when painting does not include them when
|
||||
|
@ -1052,17 +1075,19 @@ TextRenderedRun::GetClipEdges(nscoord& aVisIStartEdge,
|
|||
|
||||
// Convert the trimmed whole-nsTextFrame offset/length into skipped
|
||||
// characters.
|
||||
Range frameRange = ConvertOriginalToSkipped(it, frameOffset, frameLength);
|
||||
ConvertOriginalToSkipped(it, frameOffset, frameLength);
|
||||
|
||||
// Measure the advance width in the text run between the start of
|
||||
// frame's content and the start of the rendered run's content,
|
||||
nscoord startEdge = textRun->
|
||||
GetAdvanceWidth(Range(frameRange.start, runRange.start), nullptr);
|
||||
nscoord startEdge =
|
||||
textRun->GetAdvanceWidth(frameOffset, runOffset - frameOffset, nullptr);
|
||||
|
||||
// and between the end of the rendered run's content and the end
|
||||
// of the frame's content.
|
||||
nscoord endEdge = textRun->
|
||||
GetAdvanceWidth(Range(runRange.end, frameRange.end), nullptr);
|
||||
nscoord endEdge =
|
||||
textRun->GetAdvanceWidth(runOffset + runLength,
|
||||
frameOffset + frameLength - (runOffset + runLength),
|
||||
nullptr);
|
||||
|
||||
if (textRun->IsRightToLeft()) {
|
||||
aVisIStartEdge = endEdge;
|
||||
|
@ -1079,10 +1104,11 @@ TextRenderedRun::GetAdvanceWidth() const
|
|||
gfxSkipCharsIterator it = mFrame->EnsureTextRun(nsTextFrame::eInflated);
|
||||
gfxTextRun* textRun = mFrame->GetTextRun(nsTextFrame::eInflated);
|
||||
|
||||
Range range = ConvertOriginalToSkipped(it, mTextFrameContentOffset,
|
||||
mTextFrameContentLength);
|
||||
uint32_t offset, length;
|
||||
ConvertOriginalToSkipped(it, mTextFrameContentOffset, mTextFrameContentLength,
|
||||
offset, length);
|
||||
|
||||
return textRun->GetAdvanceWidth(range, nullptr);
|
||||
return textRun->GetAdvanceWidth(offset, length, nullptr);
|
||||
}
|
||||
|
||||
int32_t
|
||||
|
@ -1133,10 +1159,12 @@ TextRenderedRun::GetCharNumAtPosition(nsPresContext* aContext,
|
|||
|
||||
// Next check that the point lies horizontally within the left and right
|
||||
// edges of the text.
|
||||
Range range = ConvertOriginalToSkipped(it, mTextFrameContentOffset,
|
||||
mTextFrameContentLength);
|
||||
uint32_t offset, length;
|
||||
ConvertOriginalToSkipped(it, mTextFrameContentOffset, mTextFrameContentLength,
|
||||
offset, length);
|
||||
gfxFloat runAdvance =
|
||||
aContext->AppUnitsToGfxUnits(textRun->GetAdvanceWidth(range, nullptr));
|
||||
aContext->AppUnitsToGfxUnits(textRun->GetAdvanceWidth(offset, length,
|
||||
nullptr));
|
||||
|
||||
gfxFloat pos = writingMode.IsVertical() ? p.y : p.x;
|
||||
if (pos < 0 || pos >= runAdvance) {
|
||||
|
@ -1148,9 +1176,10 @@ TextRenderedRun::GetCharNumAtPosition(nsPresContext* aContext,
|
|||
// support letter-spacing and word-spacing.
|
||||
bool rtl = textRun->IsRightToLeft();
|
||||
for (int32_t i = mTextFrameContentLength - 1; i >= 0; i--) {
|
||||
range = ConvertOriginalToSkipped(it, mTextFrameContentOffset, i);
|
||||
ConvertOriginalToSkipped(it, mTextFrameContentOffset, i, offset, length);
|
||||
gfxFloat advance =
|
||||
aContext->AppUnitsToGfxUnits(textRun->GetAdvanceWidth(range, nullptr));
|
||||
aContext->AppUnitsToGfxUnits(textRun->GetAdvanceWidth(offset, length,
|
||||
nullptr));
|
||||
if ((rtl && pos < runAdvance - advance) ||
|
||||
(!rtl && pos >= advance)) {
|
||||
return i;
|
||||
|
@ -2108,8 +2137,6 @@ TextRenderedRunIterator::First()
|
|||
*/
|
||||
class CharIterator
|
||||
{
|
||||
typedef gfxTextRun::Range Range;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Values for the aFilter argument of the constructor, to indicate which
|
||||
|
@ -2601,12 +2628,12 @@ CharIterator::GetGlyphAdvance(nsPresContext* aContext) const
|
|||
GetOriginalGlyphOffsets(offset, length);
|
||||
|
||||
gfxSkipCharsIterator it = TextFrame()->EnsureTextRun(nsTextFrame::eInflated);
|
||||
Range range = ConvertOriginalToSkipped(it, offset, length);
|
||||
ConvertOriginalToSkipped(it, offset, length);
|
||||
|
||||
float cssPxPerDevPx = aContext->
|
||||
AppUnitsToFloatCSSPixels(aContext->AppUnitsPerDevPixel());
|
||||
|
||||
gfxFloat advance = mTextRun->GetAdvanceWidth(range, nullptr);
|
||||
gfxFloat advance = mTextRun->GetAdvanceWidth(offset, length, nullptr);
|
||||
return aContext->AppUnitsToGfxUnits(advance) *
|
||||
mLengthAdjustScaleFactor * cssPxPerDevPx;
|
||||
}
|
||||
|
@ -2617,9 +2644,8 @@ CharIterator::GetAdvance(nsPresContext* aContext) const
|
|||
float cssPxPerDevPx = aContext->
|
||||
AppUnitsToFloatCSSPixels(aContext->AppUnitsPerDevPixel());
|
||||
|
||||
uint32_t offset = mSkipCharsIterator.GetSkippedOffset();
|
||||
gfxFloat advance = mTextRun->
|
||||
GetAdvanceWidth(Range(offset, offset + 1), nullptr);
|
||||
gfxFloat advance =
|
||||
mTextRun->GetAdvanceWidth(mSkipCharsIterator.GetSkippedOffset(), 1, nullptr);
|
||||
return aContext->AppUnitsToGfxUnits(advance) *
|
||||
mLengthAdjustScaleFactor * cssPxPerDevPx;
|
||||
}
|
||||
|
@ -2635,12 +2661,12 @@ CharIterator::GetGlyphPartialAdvance(uint32_t aPartLength,
|
|||
length = aPartLength;
|
||||
|
||||
gfxSkipCharsIterator it = TextFrame()->EnsureTextRun(nsTextFrame::eInflated);
|
||||
Range range = ConvertOriginalToSkipped(it, offset, length);
|
||||
ConvertOriginalToSkipped(it, offset, length);
|
||||
|
||||
float cssPxPerDevPx = aContext->
|
||||
AppUnitsToFloatCSSPixels(aContext->AppUnitsPerDevPixel());
|
||||
|
||||
gfxFloat advance = mTextRun->GetAdvanceWidth(range, nullptr);
|
||||
gfxFloat advance = mTextRun->GetAdvanceWidth(offset, length, nullptr);
|
||||
return aContext->AppUnitsToGfxUnits(advance) *
|
||||
mLengthAdjustScaleFactor * cssPxPerDevPx;
|
||||
}
|
||||
|
@ -4192,10 +4218,10 @@ SVGTextFrame::GetSubStringLength(nsIContent* aContent,
|
|||
gfxSkipCharsIterator it =
|
||||
run.mFrame->EnsureTextRun(nsTextFrame::eInflated);
|
||||
gfxTextRun* textRun = run.mFrame->GetTextRun(nsTextFrame::eInflated);
|
||||
Range range = ConvertOriginalToSkipped(it, offset, length);
|
||||
ConvertOriginalToSkipped(it, offset, length);
|
||||
|
||||
// Accumulate the advance.
|
||||
textLength += textRun->GetAdvanceWidth(range, nullptr);
|
||||
textLength += textRun->GetAdvanceWidth(offset, length, nullptr);
|
||||
}
|
||||
|
||||
run = it.Next();
|
||||
|
@ -4694,9 +4720,8 @@ SVGTextFrame::DetermineCharPositions(nsTArray<nsPoint>& aPositions)
|
|||
!it.IsOriginalCharSkipped() &&
|
||||
(!textRun->IsLigatureGroupStart(it.GetSkippedOffset()) ||
|
||||
!textRun->IsClusterStart(it.GetSkippedOffset()))) {
|
||||
uint32_t offset = it.GetSkippedOffset();
|
||||
nscoord advance = textRun->
|
||||
GetAdvanceWidth(Range(offset, offset + 1), nullptr);
|
||||
nscoord advance = textRun->GetAdvanceWidth(it.GetSkippedOffset(), 1,
|
||||
nullptr);
|
||||
(textRun->IsVertical() ? position.y : position.x) +=
|
||||
textRun->IsRightToLeft() ? -advance : advance;
|
||||
aPositions.AppendElement(lastPosition);
|
||||
|
@ -4710,8 +4735,9 @@ SVGTextFrame::DetermineCharPositions(nsTArray<nsPoint>& aPositions)
|
|||
textRun->IsLigatureGroupStart(it.GetSkippedOffset()) &&
|
||||
textRun->IsClusterStart(it.GetSkippedOffset())) {
|
||||
// A real visible character.
|
||||
nscoord advance = textRun->
|
||||
GetAdvanceWidth(ClusterRange(textRun, it), nullptr);
|
||||
uint32_t length = ClusterLength(textRun, it);
|
||||
nscoord advance = textRun->GetAdvanceWidth(it.GetSkippedOffset(),
|
||||
length, nullptr);
|
||||
(textRun->IsVertical() ? position.y : position.x) +=
|
||||
textRun->IsRightToLeft() ? -advance : advance;
|
||||
lastPosition = position;
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "gfxMatrix.h"
|
||||
#include "gfxRect.h"
|
||||
#include "gfxSVGGlyphs.h"
|
||||
#include "gfxTextRun.h"
|
||||
#include "nsIContent.h" // for GetContent
|
||||
#include "nsStubMutationObserver.h"
|
||||
#include "nsSVGPaintServerFrame.h"
|
||||
|
@ -259,7 +258,6 @@ class SVGTextFrame final : public SVGTextFrameBase
|
|||
friend class MutationObserver;
|
||||
friend class nsDisplaySVGText;
|
||||
|
||||
typedef gfxTextRun::Range Range;
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
typedef mozilla::gfx::Path Path;
|
||||
typedef mozilla::gfx::Point Point;
|
||||
|
|
Загрузка…
Ссылка в новой задаче