Bug 1231550 - Use DrawTarget instead of gfxContext and/or nsRenderingContext in many places in font/text code. r=jfkthame.

AutoTextRun now only needs a DrawTarget instead of an nsRenderingContext, and
similar nsRenderingContext/gfxContext-to-DrawTarget replacements can be
propagated a long way up the call graph. This patch replaces 93 occurrences of
nsRenderingContext and 135 occurrences of gfxContext with DrawTarget; that's
13% of them.

The patch is mostly plumbing changes. A couple of not-entirely-plumbing
changes:

- It adds a comment about the null check in
  gfxGlyphExtents::GetTightGlyphExtentsAppUnits().

- A couple of functions simply had an unused gfxContext or nsRenderingContext
  parameter removed, e.g. SetLineBreaks().
This commit is contained in:
Nicholas Nethercote 2015-12-15 13:56:41 -08:00
parent 412ed76584
commit 8c877dc5ab
82 changed files with 661 additions and 643 deletions

View File

@ -3458,7 +3458,7 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcess
}
mTextRun = mFontgrp->MakeTextRun(text,
length,
mThebes,
mThebes->GetDrawTarget(),
mAppUnitsPerDevPixel,
flags,
mMissingFonts);
@ -3471,7 +3471,7 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcess
mDoMeasureBoundingBox ?
gfxFont::TIGHT_INK_EXTENTS :
gfxFont::LOOSE_INK_EXTENTS,
mThebes,
mThebes->GetDrawTarget(),
nullptr);
// this only measures the height; the total width is gotten from the
@ -3507,7 +3507,7 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcess
mDoMeasureBoundingBox ?
gfxFont::TIGHT_INK_EXTENTS :
gfxFont::LOOSE_INK_EXTENTS,
mThebes,
mThebes->GetDrawTarget(),
nullptr);
inlineCoord += textRunMetrics.mAdvanceWidth;
// old code was:

View File

@ -27,23 +27,25 @@ namespace {
class AutoTextRun {
public:
AutoTextRun(nsFontMetrics* aMetrics, nsRenderingContext* aRC,
typedef mozilla::gfx::DrawTarget DrawTarget;
AutoTextRun(nsFontMetrics* aMetrics, DrawTarget* aDrawTarget,
const char* aString, int32_t aLength)
{
mTextRun = aMetrics->GetThebesFontGroup()->MakeTextRun(
reinterpret_cast<const uint8_t*>(aString), aLength,
aRC->ThebesContext(),
aDrawTarget,
aMetrics->AppUnitsPerDevPixel(),
ComputeFlags(aMetrics),
nullptr);
}
AutoTextRun(nsFontMetrics* aMetrics, nsRenderingContext* aRC,
AutoTextRun(nsFontMetrics* aMetrics, DrawTarget* aDrawTarget,
const char16_t* aString, int32_t aLength)
{
mTextRun = aMetrics->GetThebesFontGroup()->MakeTextRun(
aString, aLength,
aRC->ThebesContext(),
aDrawTarget,
aMetrics->AppUnitsPerDevPixel(),
ComputeFlags(aMetrics),
nullptr);
@ -91,7 +93,7 @@ public:
NS_ERROR("This shouldn't be called because we never enable hyphens");
return 0;
}
virtual already_AddRefed<gfxContext> GetContext() {
virtual already_AddRefed<mozilla::gfx::DrawTarget> GetDrawTarget() {
NS_ERROR("This shouldn't be called because we never enable hyphens");
return nullptr;
}
@ -313,7 +315,7 @@ nsFontMetrics::GetMaxStringLength()
nscoord
nsFontMetrics::GetWidth(const char* aString, uint32_t aLength,
nsRenderingContext *aContext)
DrawTarget* aDrawTarget)
{
if (aLength == 0)
return 0;
@ -322,14 +324,14 @@ nsFontMetrics::GetWidth(const char* aString, uint32_t aLength,
return SpaceWidth();
StubPropertyProvider provider;
AutoTextRun textRun(this, aContext, aString, aLength);
AutoTextRun textRun(this, aDrawTarget, aString, aLength);
return textRun.get() ?
NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider)) : 0;
}
nscoord
nsFontMetrics::GetWidth(const char16_t* aString, uint32_t aLength,
nsRenderingContext *aContext)
DrawTarget* aDrawTarget)
{
if (aLength == 0)
return 0;
@ -338,7 +340,7 @@ nsFontMetrics::GetWidth(const char16_t* aString, uint32_t aLength,
return SpaceWidth();
StubPropertyProvider provider;
AutoTextRun textRun(this, aContext, aString, aLength);
AutoTextRun textRun(this, aDrawTarget, aString, aLength);
return textRun.get() ?
NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider)) : 0;
}
@ -353,7 +355,7 @@ nsFontMetrics::DrawString(const char *aString, uint32_t aLength,
return;
StubPropertyProvider provider;
AutoTextRun textRun(this, aContext, aString, aLength);
AutoTextRun textRun(this, aContext->GetDrawTarget(), aString, aLength);
if (!textRun.get()) {
return;
}
@ -373,13 +375,13 @@ void
nsFontMetrics::DrawString(const char16_t* aString, uint32_t aLength,
nscoord aX, nscoord aY,
nsRenderingContext *aContext,
nsRenderingContext *aTextRunConstructionContext)
DrawTarget* aTextRunConstructionDrawTarget)
{
if (aLength == 0)
return;
StubPropertyProvider provider;
AutoTextRun textRun(this, aTextRunConstructionContext, aString, aLength);
AutoTextRun textRun(this, aTextRunConstructionDrawTarget, aString, aLength);
if (!textRun.get()) {
return;
}
@ -396,20 +398,19 @@ nsFontMetrics::DrawString(const char16_t* aString, uint32_t aLength,
}
static nsBoundingMetrics
GetTextBoundingMetrics(nsFontMetrics* aMetrics, const char16_t *aString, uint32_t aLength,
nsRenderingContext *aContext, gfxFont::BoundingBoxType aType)
GetTextBoundingMetrics(nsFontMetrics* aMetrics, const char16_t* aString,
uint32_t aLength, mozilla::gfx::DrawTarget* aDrawTarget,
gfxFont::BoundingBoxType aType)
{
if (aLength == 0)
return nsBoundingMetrics();
StubPropertyProvider provider;
AutoTextRun textRun(aMetrics, aContext, aString, aLength);
AutoTextRun textRun(aMetrics, aDrawTarget, aString, aLength);
nsBoundingMetrics m;
if (textRun.get()) {
gfxTextRun::Metrics theMetrics =
textRun->MeasureText(0, aLength,
aType,
aContext->ThebesContext(), &provider);
textRun->MeasureText(0, aLength, aType, aDrawTarget, &provider);
m.leftBearing = NSToCoordFloor( theMetrics.mBoundingBox.X());
m.rightBearing = NSToCoordCeil( theMetrics.mBoundingBox.XMost());
@ -422,16 +423,17 @@ GetTextBoundingMetrics(nsFontMetrics* aMetrics, const char16_t *aString, uint32_
nsBoundingMetrics
nsFontMetrics::GetBoundingMetrics(const char16_t *aString, uint32_t aLength,
nsRenderingContext *aContext)
DrawTarget* aDrawTarget)
{
return GetTextBoundingMetrics(this, aString, aLength, aContext, gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS);
return GetTextBoundingMetrics(this, aString, aLength, aDrawTarget,
gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS);
}
nsBoundingMetrics
nsFontMetrics::GetInkBoundsForVisualOverflow(const char16_t *aString, uint32_t aLength,
nsRenderingContext *aContext)
DrawTarget* aDrawTarget)
{
return GetTextBoundingMetrics(this, aString, aLength, aContext, gfxFont::LOOSE_INK_EXTENTS);
return GetTextBoundingMetrics(this, aString, aLength, aDrawTarget,
gfxFont::LOOSE_INK_EXTENTS);
}

View File

@ -46,6 +46,8 @@ struct nsBoundingMetrics;
class nsFontMetrics final
{
public:
typedef mozilla::gfx::DrawTarget DrawTarget;
nsFontMetrics();
NS_INLINE_DECL_REFCOUNTING(nsFontMetrics)
@ -187,9 +189,9 @@ public:
// width in points, not twips. Callers must convert it if they
// want it in another format.
nscoord GetWidth(const char* aString, uint32_t aLength,
nsRenderingContext *aContext);
DrawTarget* aDrawTarget);
nscoord GetWidth(const char16_t* aString, uint32_t aLength,
nsRenderingContext *aContext);
DrawTarget* aDrawTarget);
// Draw a string using this font handle on the surface passed in.
void DrawString(const char *aString, uint32_t aLength,
@ -198,17 +200,17 @@ public:
void DrawString(const char16_t* aString, uint32_t aLength,
nscoord aX, nscoord aY,
nsRenderingContext *aContext,
nsRenderingContext *aTextRunConstructionContext);
DrawTarget* aTextRunConstructionDrawTarget);
nsBoundingMetrics GetBoundingMetrics(const char16_t *aString,
uint32_t aLength,
nsRenderingContext *aContext);
DrawTarget* aDrawTarget);
// Returns the LOOSE_INK_EXTENTS bounds of the text for determing the
// overflow area of the string.
nsBoundingMetrics GetInkBoundsForVisualOverflow(const char16_t *aString,
uint32_t aLength,
nsRenderingContext *aContext);
DrawTarget* aDrawTarget);
void SetTextRunRTL(bool aIsRTL) { mTextRunRTL = aIsRTL; }
bool GetTextRunRTL() const { return mTextRunRTL; }

View File

@ -81,23 +81,21 @@ MakeTextRun(const char16_t *aText, uint32_t aLength, gfxFontGroup *aFontGroup,
return textRun.forget();
}
static already_AddRefed<gfxContext>
MakeContext ()
static already_AddRefed<DrawTarget>
MakeDrawTarget()
{
const int size = 200;
RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
CreateOffscreenContentDrawTarget(IntSize(size, size),
SurfaceFormat::B8G8R8X8);
RefPtr<gfxContext> ctx = new gfxContext(drawTarget);
return ctx.forget();
return drawTarget.forget();
}
TEST(Gfx, WordCache) {
gTextRuns = new FrameTextRunCache();
RefPtr<gfxContext> ctx = MakeContext();
RefPtr<DrawTarget> dt = MakeDrawTarget();
{
gfxFontStyle style(mozilla::gfx::FontStyle::NORMAL,
139,
@ -114,7 +112,7 @@ TEST(Gfx, WordCache) {
nullptr, nullptr, 1.0);
gfxTextRunFactory::Parameters params = {
ctx, nullptr, nullptr, nullptr, 0, 60
dt, nullptr, nullptr, nullptr, 0, 60
};
uint32_t flags = gfxTextRunFactory::TEXT_IS_PERSISTENT;

View File

@ -115,7 +115,7 @@ IsBuggyIndicScript(int32_t aScript)
}
bool
gfxCoreTextShaper::ShapeText(gfxContext *aContext,
gfxCoreTextShaper::ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,

View File

@ -18,7 +18,7 @@ public:
virtual ~gfxCoreTextShaper();
virtual bool ShapeText(gfxContext *aContext,
virtual bool ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,

View File

@ -544,17 +544,16 @@ gfxDWriteFont::GetCairoScaledFont()
}
gfxFont::RunMetrics
gfxDWriteFont::Measure(gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType,
gfxContext *aRefContext,
Spacing *aSpacing,
uint16_t aOrientation)
gfxDWriteFont::Measure(gfxTextRun* aTextRun,
uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType,
DrawTarget* aRefDrawTarget,
Spacing* aSpacing,
uint16_t aOrientation)
{
gfxFont::RunMetrics metrics =
gfxFont::Measure(aTextRun, aStart, aEnd,
aBoundingBoxType, aRefContext, aSpacing,
aOrientation);
gfxFont::Measure(aTextRun, aStart, aEnd, aBoundingBoxType,
aRefDrawTarget, aSpacing, aOrientation);
// if aBoundingBoxType is LOOSE_INK_EXTENTS
// and the underlying cairo font may be antialiased,

View File

@ -50,7 +50,7 @@ public:
virtual RunMetrics Measure(gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType,
gfxContext *aContextForTightBoundingBox,
DrawTarget *aDrawTargetForTightBoundingBox,
Spacing *aSpacing,
uint16_t aOrientation) override;

View File

@ -43,7 +43,7 @@
*/
bool
gfxFT2Font::ShapeText(gfxContext *aContext,
gfxFT2Font::ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,
@ -51,11 +51,11 @@ gfxFT2Font::ShapeText(gfxContext *aContext,
bool aVertical,
gfxShapedText *aShapedText)
{
if (!gfxFont::ShapeText(aContext, aText, aOffset, aLength, aScript,
if (!gfxFont::ShapeText(aDrawTarget, aText, aOffset, aLength, aScript,
aVertical, aShapedText)) {
// harfbuzz must have failed(?!), just render raw glyphs
AddRange(aText, aOffset, aLength, aShapedText);
PostShapingFixup(aContext->GetDrawTarget(), aText, aOffset, aLength,
PostShapingFixup(aDrawTarget, aText, aOffset, aLength,
aVertical, aShapedText);
}

View File

@ -65,7 +65,7 @@ public: // new functions
#endif
protected:
virtual bool ShapeText(gfxContext *aContext,
virtual bool ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,

View File

@ -863,13 +863,13 @@ gfxFont::~gfxFont()
}
gfxFloat
gfxFont::GetGlyphHAdvance(gfxContext *aCtx, uint16_t aGID)
gfxFont::GetGlyphHAdvance(DrawTarget* aDrawTarget, uint16_t aGID)
{
if (!SetupCairoFont(aCtx->GetDrawTarget())) {
if (!SetupCairoFont(aDrawTarget)) {
return 0;
}
if (ProvidesGlyphWidths()) {
return GetGlyphWidth(*aCtx->GetDrawTarget(), aGID) / 65536.0;
return GetGlyphWidth(*aDrawTarget, aGID) / 65536.0;
}
if (mFUnitsConvFactor < 0.0f) {
GetMetrics(eHorizontal);
@ -2232,7 +2232,7 @@ NeedsGlyphExtents(gfxFont *aFont, gfxTextRun *aTextRun)
}
bool
gfxFont::IsSpaceGlyphInvisible(gfxContext *aRefContext, gfxTextRun *aTextRun)
gfxFont::IsSpaceGlyphInvisible(DrawTarget* aRefDrawTarget, gfxTextRun* aTextRun)
{
if (!mFontEntry->mSpaceGlyphIsInvisibleInitialized &&
GetAdjustedSize() >= 1.0) {
@ -2240,7 +2240,7 @@ gfxFont::IsSpaceGlyphInvisible(gfxContext *aRefContext, gfxTextRun *aTextRun)
GetOrCreateGlyphExtents(aTextRun->GetAppUnitsPerDevUnit());
gfxRect glyphExtents;
mFontEntry->mSpaceGlyphIsInvisible =
extents->GetTightGlyphExtentsAppUnits(this, aRefContext,
extents->GetTightGlyphExtentsAppUnits(this, aRefDrawTarget,
GetSpaceGlyph(), &glyphExtents) &&
glyphExtents.IsEmpty();
mFontEntry->mSpaceGlyphIsInvisibleInitialized = true;
@ -2252,7 +2252,7 @@ gfxFont::RunMetrics
gfxFont::Measure(gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType,
gfxContext *aRefContext,
DrawTarget* aRefDrawTarget,
Spacing *aSpacing,
uint16_t aOrientation)
{
@ -2270,7 +2270,7 @@ gfxFont::Measure(gfxTextRun *aTextRun,
if (mNonAAFont) {
return mNonAAFont->Measure(aTextRun, aStart, aEnd,
TIGHT_HINTED_OUTLINE_EXTENTS,
aRefContext, aSpacing, aOrientation);
aRefDrawTarget, aSpacing, aOrientation);
}
}
@ -2333,7 +2333,7 @@ gfxFont::Measure(gfxTextRun *aTextRun,
double advance = glyphData->GetSimpleAdvance();
uint32_t glyphIndex = glyphData->GetSimpleGlyph();
if (glyphIndex != spaceGlyph ||
!IsSpaceGlyphInvisible(aRefContext, aTextRun)) {
!IsSpaceGlyphInvisible(aRefDrawTarget, aTextRun)) {
allGlyphsInvisible = false;
}
// Only get the real glyph horizontal extent if we were asked
@ -2348,7 +2348,7 @@ gfxFont::Measure(gfxTextRun *aTextRun,
} else {
gfxRect glyphRect;
if (!extents->GetTightGlyphExtentsAppUnits(this,
aRefContext, glyphIndex, &glyphRect)) {
aRefDrawTarget, glyphIndex, &glyphRect)) {
glyphRect = gfxRect(0, metrics.mBoundingBox.Y(),
advance, metrics.mBoundingBox.Height());
}
@ -2380,7 +2380,7 @@ gfxFont::Measure(gfxTextRun *aTextRun,
gfxRect glyphRect;
if (glyphData->IsMissing() || !extents ||
!extents->GetTightGlyphExtentsAppUnits(this,
aRefContext, glyphIndex, &glyphRect)) {
aRefDrawTarget, glyphIndex, &glyphRect)) {
// We might have failed to get glyph extents due to
// OOM or something
glyphRect = gfxRect(0, -metrics.mAscent,
@ -2500,7 +2500,7 @@ IsBoundarySpace(char16_t aChar, char16_t aNextChar)
template<typename T>
gfxShapedWord*
gfxFont::GetShapedWord(gfxContext *aContext,
gfxFont::GetShapedWord(DrawTarget *aDrawTarget,
const T *aText,
uint32_t aLength,
uint32_t aHash,
@ -2565,7 +2565,7 @@ gfxFont::GetShapedWord(gfxContext *aContext,
}
DebugOnly<bool> ok =
ShapeText(aContext, aText, 0, aLength, aRunScript, aVertical, sw);
ShapeText(aDrawTarget, aText, 0, aLength, aRunScript, aVertical, sw);
NS_WARN_IF_FALSE(ok, "failed to shape word - expect garbled text");
@ -2610,7 +2610,7 @@ gfxFont::CacheHashEntry::KeyEquals(const KeyTypePointer aKey) const
}
bool
gfxFont::ShapeText(gfxContext *aContext,
gfxFont::ShapeText(DrawTarget *aDrawTarget,
const uint8_t *aText,
uint32_t aOffset,
uint32_t aLength,
@ -2624,12 +2624,12 @@ gfxFont::ShapeText(gfxContext *aContext,
if (utf16.Length() != aLength) {
return false;
}
return ShapeText(aContext, utf16.BeginReading(), aOffset, aLength,
return ShapeText(aDrawTarget, utf16.BeginReading(), aOffset, aLength,
aScript, aVertical, aShapedText);
}
bool
gfxFont::ShapeText(gfxContext *aContext,
gfxFont::ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,
@ -2646,7 +2646,7 @@ gfxFont::ShapeText(gfxContext *aContext,
if (!mGraphiteShaper) {
mGraphiteShaper = new gfxGraphiteShaper(this);
}
ok = mGraphiteShaper->ShapeText(aContext, aText, aOffset, aLength,
ok = mGraphiteShaper->ShapeText(aDrawTarget, aText, aOffset, aLength,
aScript, aVertical, aShapedText);
}
}
@ -2655,13 +2655,13 @@ gfxFont::ShapeText(gfxContext *aContext,
if (!mHarfBuzzShaper) {
mHarfBuzzShaper = new gfxHarfBuzzShaper(this);
}
ok = mHarfBuzzShaper->ShapeText(aContext, aText, aOffset, aLength,
ok = mHarfBuzzShaper->ShapeText(aDrawTarget, aText, aOffset, aLength,
aScript, aVertical, aShapedText);
}
NS_WARN_IF_FALSE(ok, "shaper failed, expect scrambled or missing text");
PostShapingFixup(aContext->GetDrawTarget(), aText, aOffset, aLength,
PostShapingFixup(aDrawTarget, aText, aOffset, aLength,
aVertical, aShapedText);
return ok;
@ -2694,7 +2694,7 @@ gfxFont::PostShapingFixup(DrawTarget* aDrawTarget,
template<typename T>
bool
gfxFont::ShapeFragmentWithoutWordCache(gfxContext *aContext,
gfxFont::ShapeFragmentWithoutWordCache(DrawTarget *aDrawTarget,
const T *aText,
uint32_t aOffset,
uint32_t aLength,
@ -2735,7 +2735,7 @@ gfxFont::ShapeFragmentWithoutWordCache(gfxContext *aContext,
}
}
ok = ShapeText(aContext, aText, aOffset, fragLen, aScript, aVertical,
ok = ShapeText(aDrawTarget, aText, aOffset, fragLen, aScript, aVertical,
aTextRun);
aText += fragLen;
@ -2759,7 +2759,7 @@ IsInvalidControlChar(uint32_t aCh)
template<typename T>
bool
gfxFont::ShapeTextWithoutWordCache(gfxContext *aContext,
gfxFont::ShapeTextWithoutWordCache(DrawTarget *aDrawTarget,
const T *aText,
uint32_t aOffset,
uint32_t aLength,
@ -2781,7 +2781,7 @@ gfxFont::ShapeTextWithoutWordCache(gfxContext *aContext,
}
if (length > 0) {
ok = ShapeFragmentWithoutWordCache(aContext, aText + fragStart,
ok = ShapeFragmentWithoutWordCache(aDrawTarget, aText + fragStart,
aOffset + fragStart, length,
aScript, aVertical, aTextRun);
}
@ -2800,7 +2800,7 @@ gfxFont::ShapeTextWithoutWordCache(gfxContext *aContext,
} else if (IsInvalidControlChar(ch) &&
!(aTextRun->GetFlags() & gfxTextRunFactory::TEXT_HIDE_CONTROL_CHARACTERS)) {
if (GetFontEntry()->IsUserFont() && HasCharacter(ch)) {
ShapeFragmentWithoutWordCache(aContext, aText + i,
ShapeFragmentWithoutWordCache(aDrawTarget, aText + i,
aOffset + i, 1,
aScript, aVertical, aTextRun);
} else {
@ -2840,7 +2840,7 @@ inline static bool HasSpaces(const char16_t *aString, uint32_t aLen)
template<typename T>
bool
gfxFont::SplitAndInitTextRun(gfxContext *aContext,
gfxFont::SplitAndInitTextRun(DrawTarget *aDrawTarget,
gfxTextRun *aTextRun,
const T *aString, // text for this font run
uint32_t aRunStart, // position in the textrun
@ -2880,7 +2880,7 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
if (aRunLength > wordCacheCharLimit ||
HasSpaces(aString, aRunLength)) {
TEXT_PERF_INCR(tp, wordCacheSpaceRules);
return ShapeTextWithoutWordCache(aContext, aString,
return ShapeTextWithoutWordCache(aDrawTarget, aString,
aRunStart, aRunLength,
aRunScript, aVertical,
aTextRun);
@ -2930,7 +2930,7 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
// font's word cache but just shape directly into the textrun.
if (length > wordCacheCharLimit) {
TEXT_PERF_INCR(tp, wordCacheLong);
bool ok = ShapeFragmentWithoutWordCache(aContext,
bool ok = ShapeFragmentWithoutWordCache(aDrawTarget,
aString + wordStart,
aRunStart + wordStart,
length,
@ -2950,7 +2950,7 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
wordFlags |= gfxTextRunFactory::TEXT_IS_8BIT;
}
}
gfxShapedWord *sw = GetShapedWord(aContext,
gfxShapedWord* sw = GetShapedWord(aDrawTarget,
aString + wordStart, length,
hash, aRunScript, aVertical,
appUnitsPerDevUnit,
@ -2981,7 +2981,7 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
DebugOnly<char16_t> boundary16 = boundary;
NS_ASSERTION(boundary16 < 256, "unexpected boundary!");
gfxShapedWord *sw =
GetShapedWord(aContext, &boundary, 1,
GetShapedWord(aDrawTarget, &boundary, 1,
gfxShapedWord::HashMix(0, boundary),
aRunScript, aVertical, appUnitsPerDevUnit,
flags | gfxTextRunFactory::TEXT_IS_8BIT, tp);
@ -3014,7 +3014,7 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
} else if (IsInvalidControlChar(ch) &&
!(aTextRun->GetFlags() & gfxTextRunFactory::TEXT_HIDE_CONTROL_CHARACTERS)) {
if (GetFontEntry()->IsUserFont() && HasCharacter(ch)) {
ShapeFragmentWithoutWordCache(aContext, aString + i,
ShapeFragmentWithoutWordCache(aDrawTarget, aString + i,
aRunStart + i, 1,
aRunScript, aVertical, aTextRun);
} else {
@ -3032,7 +3032,7 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
// Explicit instantiations of SplitAndInitTextRun, to avoid libxul link failure
template bool
gfxFont::SplitAndInitTextRun(gfxContext *aContext,
gfxFont::SplitAndInitTextRun(DrawTarget *aDrawTarget,
gfxTextRun *aTextRun,
const uint8_t *aString,
uint32_t aRunStart,
@ -3040,7 +3040,7 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
int32_t aRunScript,
bool aVertical);
template bool
gfxFont::SplitAndInitTextRun(gfxContext *aContext,
gfxFont::SplitAndInitTextRun(DrawTarget *aDrawTarget,
gfxTextRun *aTextRun,
const char16_t *aString,
uint32_t aRunStart,
@ -3050,7 +3050,7 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
template<>
bool
gfxFont::InitFakeSmallCapsRun(gfxContext *aContext,
gfxFont::InitFakeSmallCapsRun(DrawTarget *aDrawTarget,
gfxTextRun *aTextRun,
const char16_t *aText,
uint32_t aOffset,
@ -3131,7 +3131,7 @@ gfxFont::InitFakeSmallCapsRun(gfxContext *aContext,
// just use the current font and the existing string
aTextRun->AddGlyphRun(f, aMatchType, aOffset + runStart, true,
aOrientation);
if (!f->SplitAndInitTextRun(aContext, aTextRun,
if (!f->SplitAndInitTextRun(aDrawTarget, aTextRun,
aText + runStart,
aOffset + runStart, runLength,
aScript, vertical)) {
@ -3166,7 +3166,7 @@ gfxFont::InitFakeSmallCapsRun(gfxContext *aContext,
// into the destination textrun but have to handle the
// mismatch of character positions.
gfxTextRunFactory::Parameters params = {
aContext, nullptr, nullptr, nullptr, 0,
aDrawTarget, nullptr, nullptr, nullptr, 0,
aTextRun->GetAppUnitsPerDevUnit()
};
nsAutoPtr<gfxTextRun> tempRun;
@ -3174,7 +3174,7 @@ gfxFont::InitFakeSmallCapsRun(gfxContext *aContext,
gfxTextRun::Create(&params, convertedString.Length(),
aTextRun->GetFontGroup(), 0);
tempRun->AddGlyphRun(f, aMatchType, 0, true, aOrientation);
if (!f->SplitAndInitTextRun(aContext, tempRun,
if (!f->SplitAndInitTextRun(aDrawTarget, tempRun,
convertedString.BeginReading(),
0, convertedString.Length(),
aScript, vertical)) {
@ -3193,7 +3193,7 @@ gfxFont::InitFakeSmallCapsRun(gfxContext *aContext,
} else {
aTextRun->AddGlyphRun(f, aMatchType, aOffset + runStart,
true, aOrientation);
if (!f->SplitAndInitTextRun(aContext, aTextRun,
if (!f->SplitAndInitTextRun(aDrawTarget, aTextRun,
convertedString.BeginReading(),
aOffset + runStart, runLength,
aScript, vertical)) {
@ -3217,7 +3217,7 @@ gfxFont::InitFakeSmallCapsRun(gfxContext *aContext,
template<>
bool
gfxFont::InitFakeSmallCapsRun(gfxContext *aContext,
gfxFont::InitFakeSmallCapsRun(DrawTarget *aDrawTarget,
gfxTextRun *aTextRun,
const uint8_t *aText,
uint32_t aOffset,
@ -3230,7 +3230,7 @@ gfxFont::InitFakeSmallCapsRun(gfxContext *aContext,
{
NS_ConvertASCIItoUTF16 unicodeString(reinterpret_cast<const char*>(aText),
aLength);
return InitFakeSmallCapsRun(aContext, aTextRun, static_cast<const char16_t*>(unicodeString.get()),
return InitFakeSmallCapsRun(aDrawTarget, aTextRun, static_cast<const char16_t*>(unicodeString.get()),
aOffset, aLength, aMatchType, aOrientation,
aScript, aSyntheticLower, aSyntheticUpper);
}

View File

@ -454,6 +454,8 @@ class gfxTextRunFactory {
NS_INLINE_DECL_REFCOUNTING(gfxTextRunFactory)
public:
typedef mozilla::gfx::DrawTarget DrawTarget;
// Flags in the mask 0xFFFF0000 are reserved for textrun clients
// Flags in the mask 0x0000F000 are reserved for per-platform fonts
// Flags in the mask 0x00000FFF are set by the textrun creator.
@ -572,8 +574,8 @@ public:
* This record contains all the parameters needed to initialize a textrun.
*/
struct Parameters {
// A reference context suggesting where the textrun will be rendered
gfxContext *mContext;
// Shape text params suggesting where the textrun will be rendered
DrawTarget *mDrawTarget;
// Pointer to arbitrary user data (which should outlive the textrun)
void *mUserData;
// A description of which characters have been stripped from the original
@ -626,7 +628,7 @@ public:
// Shape a piece of text and store the resulting glyph data into
// aShapedText. Parameters aOffset/aLength indicate the range of
// aShapedText to be updated; aLength is also the length of aText.
virtual bool ShapeText(gfxContext *aContext,
virtual bool ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,
@ -1486,7 +1488,7 @@ public:
return 0;
}
// Return the horizontal advance of a glyph.
gfxFloat GetGlyphHAdvance(gfxContext *aCtx, uint16_t aGID);
gfxFloat GetGlyphHAdvance(DrawTarget* aDrawTarget, uint16_t aGID);
// Return Azure GlyphRenderingOptions for drawing this font.
virtual already_AddRefed<mozilla::gfx::GlyphRenderingOptions>
@ -1626,7 +1628,7 @@ public:
* the advance width for the character run,y=-(font ascent), and height=
* font ascent + font descent). Otherwise, we must return as tight as possible
* an approximation to the area actually painted by glyphs.
* @param aContextForTightBoundingBox when aTight is true, this must
* @param aDrawTargetForTightBoundingBox when aTight is true, this must
* be non-null.
* @param aSpacing spacing to insert before and after glyphs. The bounding box
* need not include the spacing itself, but the spacing affects the glyph
@ -1643,7 +1645,7 @@ public:
virtual RunMetrics Measure(gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType,
gfxContext *aContextForTightBoundingBox,
DrawTarget* aDrawTargetForTightBoundingBox,
Spacing *aSpacing, uint16_t aOrientation);
/**
* Line breaks have been changed at the beginning and/or end of a substring
@ -1709,7 +1711,7 @@ public:
}
template<typename T>
bool InitFakeSmallCapsRun(gfxContext *aContext,
bool InitFakeSmallCapsRun(DrawTarget *aDrawTarget,
gfxTextRun *aTextRun,
const T *aText,
uint32_t aOffset,
@ -1724,7 +1726,7 @@ public:
// limiting the length of text passed by processing the run in multiple
// segments if necessary
template<typename T>
bool SplitAndInitTextRun(gfxContext *aContext,
bool SplitAndInitTextRun(DrawTarget *aDrawTarget,
gfxTextRun *aTextRun,
const T *aString,
uint32_t aRunStart,
@ -1735,7 +1737,7 @@ public:
// Get a ShapedWord representing the given text (either 8- or 16-bit)
// for use in setting up a gfxTextRun.
template<typename T>
gfxShapedWord* GetShapedWord(gfxContext *aContext,
gfxShapedWord* GetShapedWord(DrawTarget *aDrawTarget,
const T *aText,
uint32_t aLength,
uint32_t aHash,
@ -1905,7 +1907,8 @@ protected:
return -1;
}
bool IsSpaceGlyphInvisible(gfxContext *aRefContext, gfxTextRun *aTextRun);
bool IsSpaceGlyphInvisible(DrawTarget* aRefDrawTarget,
gfxTextRun* aTextRun);
void AddGlyphChangeObserver(GlyphChangeObserver *aObserver);
void RemoveGlyphChangeObserver(GlyphChangeObserver *aObserver);
@ -1917,7 +1920,7 @@ protected:
bool SpaceMayParticipateInShaping(int32_t aRunScript);
// For 8-bit text, expand to 16-bit and then call the following method.
bool ShapeText(gfxContext *aContext,
bool ShapeText(DrawTarget *aContext,
const uint8_t *aText,
uint32_t aOffset, // dest offset in gfxShapedText
uint32_t aLength,
@ -1927,7 +1930,7 @@ protected:
// Call the appropriate shaper to generate glyphs for aText and store
// them into aShapedText.
virtual bool ShapeText(gfxContext *aContext,
virtual bool ShapeText(DrawTarget *aContext,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,
@ -1953,7 +1956,7 @@ protected:
// not handled via normal shaping, but does not otherwise divide up the
// text.
template<typename T>
bool ShapeTextWithoutWordCache(gfxContext *aContext,
bool ShapeTextWithoutWordCache(DrawTarget *aDrawTarget,
const T *aText,
uint32_t aOffset,
uint32_t aLength,
@ -1967,7 +1970,7 @@ protected:
// that will ensure we don't pass excessively long runs to the various
// platform shapers.
template<typename T>
bool ShapeFragmentWithoutWordCache(gfxContext *aContext,
bool ShapeFragmentWithoutWordCache(DrawTarget *aDrawTarget,
const T *aText,
uint32_t aOffset,
uint32_t aLength,

View File

@ -78,7 +78,7 @@ gfxGDIFont::CopyWithAntialiasOption(AntialiasOption anAAOption)
}
bool
gfxGDIFont::ShapeText(gfxContext *aContext,
gfxGDIFont::ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,
@ -98,11 +98,11 @@ gfxGDIFont::ShapeText(gfxContext *aContext,
// creating a "toy" font internally (see bug 544617).
// We must check that this succeeded, otherwise we risk cairo creating the
// wrong kind of font internally as a fallback (bug 744480).
if (!SetupCairoFont(aContext->GetDrawTarget())) {
if (!SetupCairoFont(aDrawTarget)) {
return false;
}
return gfxFont::ShapeText(aContext, aText, aOffset, aLength, aScript,
return gfxFont::ShapeText(aDrawTarget, aText, aOffset, aLength, aScript,
aVertical, aShapedText);
}
@ -144,14 +144,13 @@ gfxFont::RunMetrics
gfxGDIFont::Measure(gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType,
gfxContext *aRefContext,
DrawTarget *aRefDrawTarget,
Spacing *aSpacing,
uint16_t aOrientation)
{
gfxFont::RunMetrics metrics =
gfxFont::Measure(aTextRun, aStart, aEnd,
aBoundingBoxType, aRefContext, aSpacing,
aOrientation);
gfxFont::Measure(aTextRun, aStart, aEnd, aBoundingBoxType,
aRefDrawTarget, aSpacing, aOrientation);
// if aBoundingBoxType is LOOSE_INK_EXTENTS
// and the underlying cairo font may be antialiased,

View File

@ -48,7 +48,7 @@ public:
virtual RunMetrics Measure(gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType,
gfxContext *aContextForTightBoundingBox,
DrawTarget *aDrawTargetForTightBoundingBox,
Spacing *aSpacing,
uint16_t aOrientation) override;
@ -82,7 +82,7 @@ protected:
virtual const Metrics& GetHorizontalMetrics() override;
/* override to ensure the cairo font is set up properly */
virtual bool ShapeText(gfxContext *aContext,
virtual bool ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,

View File

@ -35,21 +35,24 @@ gfxGlyphExtents::~gfxGlyphExtents()
}
bool
gfxGlyphExtents::GetTightGlyphExtentsAppUnits(gfxFont *aFont,
gfxContext *aContext, uint32_t aGlyphID, gfxRect *aExtents)
gfxGlyphExtents::GetTightGlyphExtentsAppUnits(gfxFont* aFont,
DrawTarget* aDrawTarget, uint32_t aGlyphID, gfxRect* aExtents)
{
HashEntry *entry = mTightGlyphExtents.GetEntry(aGlyphID);
if (!entry) {
if (!aContext) {
NS_WARNING("Could not get glyph extents (no aContext)");
// Some functions higher up in the call chain deliberately pass in a
// nullptr DrawTarget, e.g. GetBaselinePosition() passes nullptr to
// gfxTextRun::MeasureText() and that nullptr reaches here.
if (!aDrawTarget) {
NS_WARNING("Could not get glyph extents (no aDrawTarget)");
return false;
}
if (aFont->SetupCairoFont(aContext->GetDrawTarget())) {
if (aFont->SetupCairoFont(aDrawTarget)) {
#ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
++gGlyphExtentsSetupLazyTight;
#endif
aFont->SetupGlyphExtents(aContext->GetDrawTarget(), aGlyphID, true, this);
aFont->SetupGlyphExtents(aDrawTarget, aGlyphID, true, this);
entry = mTightGlyphExtents.GetEntry(aGlyphID);
}
if (!entry) {

View File

@ -62,8 +62,8 @@ public:
// Get glyph extents; a rectangle relative to the left baseline origin
// Returns true on success. Can fail on OOM or when aContext is null
// and extents were not (successfully) prefetched.
bool GetTightGlyphExtentsAppUnits(gfxFont *aFont,
gfxContext *aContext, uint32_t aGlyphID, gfxRect *aExtents);
bool GetTightGlyphExtentsAppUnits(gfxFont* aFont,
DrawTarget* aDrawTarget, uint32_t aGlyphID, gfxRect* aExtents);
void SetContainedGlyphWidthAppUnits(uint32_t aGlyphID, uint16_t aWidth) {
mContainedGlyphWidths.Set(aGlyphID, aWidth);

View File

@ -82,7 +82,7 @@ AddFeature(const uint32_t& aTag, uint32_t& aValue, void *aUserArg)
}
bool
gfxGraphiteShaper::ShapeText(gfxContext *aContext,
gfxGraphiteShaper::ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,
@ -91,11 +91,11 @@ gfxGraphiteShaper::ShapeText(gfxContext *aContext,
gfxShapedText *aShapedText)
{
// some font back-ends require this in order to get proper hinted metrics
if (!mFont->SetupCairoFont(aContext->GetDrawTarget())) {
if (!mFont->SetupCairoFont(aDrawTarget)) {
return false;
}
mCallbackData.mDrawTarget = aContext->GetDrawTarget();
mCallbackData.mDrawTarget = aDrawTarget;
const gfxFontStyle *style = mFont->GetStyle();
@ -173,7 +173,7 @@ gfxGraphiteShaper::ShapeText(gfxContext *aContext,
return false;
}
nsresult rv = SetGlyphsFromSegment(aContext, aShapedText, aOffset, aLength,
nsresult rv = SetGlyphsFromSegment(aDrawTarget, aShapedText, aOffset, aLength,
aText, seg);
gr_seg_destroy(seg);
@ -193,7 +193,7 @@ struct Cluster {
};
nsresult
gfxGraphiteShaper::SetGlyphsFromSegment(gfxContext *aContext,
gfxGraphiteShaper::SetGlyphsFromSegment(DrawTarget *aDrawTarget,
gfxShapedText *aShapedText,
uint32_t aOffset,
uint32_t aLength,
@ -269,7 +269,7 @@ gfxGraphiteShaper::SetGlyphsFromSegment(gfxContext *aContext,
}
bool roundX, roundY;
GetRoundOffsetsToPixels(aContext->GetDrawTarget(), &roundX, &roundY);
GetRoundOffsetsToPixels(aDrawTarget, &roundX, &roundY);
gfxShapedText::CompressedGlyph *charGlyphs =
aShapedText->GetCharacterGlyphs() + aOffset;

View File

@ -19,7 +19,7 @@ public:
explicit gfxGraphiteShaper(gfxFont *aFont);
virtual ~gfxGraphiteShaper();
virtual bool ShapeText(gfxContext *aContext,
virtual bool ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,
@ -30,7 +30,7 @@ public:
static void Shutdown();
protected:
nsresult SetGlyphsFromSegment(gfxContext *aContext,
nsresult SetGlyphsFromSegment(DrawTarget *aDrawTarget,
gfxShapedText *aShapedText,
uint32_t aOffset,
uint32_t aLength,

View File

@ -1462,7 +1462,7 @@ gfxHarfBuzzShaper::InitializeVertical()
}
bool
gfxHarfBuzzShaper::ShapeText(gfxContext *aContext,
gfxHarfBuzzShaper::ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,
@ -1471,11 +1471,11 @@ gfxHarfBuzzShaper::ShapeText(gfxContext *aContext,
gfxShapedText *aShapedText)
{
// some font back-ends require this in order to get proper hinted metrics
if (!mFont->SetupCairoFont(aContext->GetDrawTarget())) {
if (!mFont->SetupCairoFont(aDrawTarget)) {
return false;
}
mCallbackData.mDrawTarget = aContext->GetDrawTarget();
mCallbackData.mDrawTarget = aDrawTarget;
mUseVerticalPresentationForms = false;
if (!Initialize()) {
@ -1565,7 +1565,7 @@ gfxHarfBuzzShaper::ShapeText(gfxContext *aContext,
hb_buffer_reverse(buffer);
}
nsresult rv = SetGlyphsFromRun(aContext, aShapedText, aOffset, aLength,
nsresult rv = SetGlyphsFromRun(aDrawTarget, aShapedText, aOffset, aLength,
aText, buffer, aVertical);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to store glyphs into gfxShapedWord");
@ -1579,7 +1579,7 @@ gfxHarfBuzzShaper::ShapeText(gfxContext *aContext,
// for charToGlyphArray
nsresult
gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
gfxHarfBuzzShaper::SetGlyphsFromRun(DrawTarget *aDrawTarget,
gfxShapedText *aShapedText,
uint32_t aOffset,
uint32_t aLength,
@ -1618,11 +1618,10 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
int32_t charStart = 0; // and this char index within the range of the run
bool roundI, roundB;
DrawTarget* drawTarget = aContext->GetDrawTarget();
if (aVertical) {
GetRoundOffsetsToPixels(drawTarget, &roundB, &roundI);
GetRoundOffsetsToPixels(aDrawTarget, &roundB, &roundI);
} else {
GetRoundOffsetsToPixels(drawTarget, &roundI, &roundB);
GetRoundOffsetsToPixels(aDrawTarget, &roundI, &roundB);
}
int32_t appUnitsPerDevUnit = aShapedText->GetAppUnitsPerDevUnit();

View File

@ -27,7 +27,7 @@ public:
};
bool Initialize();
virtual bool ShapeText(gfxContext *aContext,
virtual bool ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,
@ -98,7 +98,7 @@ public:
}
protected:
nsresult SetGlyphsFromRun(gfxContext *aContext,
nsresult SetGlyphsFromRun(DrawTarget *aDrawTarget,
gfxShapedText *aShapedText,
uint32_t aOffset,
uint32_t aLength,

View File

@ -120,7 +120,7 @@ gfxMacFont::~gfxMacFont()
}
bool
gfxMacFont::ShapeText(gfxContext *aContext,
gfxMacFont::ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,
@ -140,15 +140,15 @@ gfxMacFont::ShapeText(gfxContext *aContext,
if (!mCoreTextShaper) {
mCoreTextShaper = new gfxCoreTextShaper(this);
}
if (mCoreTextShaper->ShapeText(aContext, aText, aOffset, aLength,
if (mCoreTextShaper->ShapeText(aDrawTarget, aText, aOffset, aLength,
aScript, aVertical, aShapedText)) {
PostShapingFixup(aContext->GetDrawTarget(), aText, aOffset,
PostShapingFixup(aDrawTarget, aText, aOffset,
aLength, aVertical, aShapedText);
return true;
}
}
return gfxFont::ShapeText(aContext, aText, aOffset, aLength, aScript,
return gfxFont::ShapeText(aDrawTarget, aText, aOffset, aLength, aScript,
aVertical, aShapedText);
}
@ -168,13 +168,13 @@ gfxFont::RunMetrics
gfxMacFont::Measure(gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType,
gfxContext *aRefContext,
DrawTarget *aRefDrawTarget,
Spacing *aSpacing,
uint16_t aOrientation)
{
gfxFont::RunMetrics metrics =
gfxFont::Measure(aTextRun, aStart, aEnd,
aBoundingBoxType, aRefContext, aSpacing,
aBoundingBoxType, aRefDrawTarget, aSpacing,
aOrientation);
// if aBoundingBoxType is not TIGHT_HINTED_OUTLINE_EXTENTS then we need to add

View File

@ -34,7 +34,7 @@ public:
virtual RunMetrics Measure(gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType,
gfxContext *aContextForTightBoundingBox,
DrawTarget *aDrawTargetForTightBoundingBox,
Spacing *aSpacing,
uint16_t aOrientation) override;
@ -67,7 +67,7 @@ protected:
}
// override to prefer CoreText shaping with fonts that depend on AAT
virtual bool ShapeText(gfxContext *aContext,
virtual bool ShapeText(DrawTarget *aDrawTarget,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,

View File

@ -575,7 +575,8 @@ gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, DrawMode aDrawMode,
if (aAdvanceWidth) {
gfxTextRun::Metrics metrics = MeasureText(aStart, aLength,
gfxFont::LOOSE_INK_EXTENTS,
aContext, aProvider);
aContext->GetDrawTarget(),
aProvider);
*aAdvanceWidth = metrics.mAdvanceWidth * direction;
}
@ -596,7 +597,8 @@ gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, DrawMode aDrawMode,
// measure text, use the bounding box
gfxTextRun::Metrics metrics = MeasureText(aStart, aLength,
gfxFont::LOOSE_INK_EXTENTS,
aContext, aProvider);
aContext->GetDrawTarget(),
aProvider);
metrics.mBoundingBox.MoveBy(aPt);
syntheticBoldBuffer.PushSolidColor(metrics.mBoundingBox, currentColor,
GetAppUnitsPerDevUnit());
@ -713,7 +715,7 @@ void
gfxTextRun::AccumulateMetricsForRun(gfxFont *aFont,
uint32_t aStart, uint32_t aEnd,
gfxFont::BoundingBoxType aBoundingBoxType,
gfxContext *aRefContext,
DrawTarget* aRefDrawTarget,
PropertyProvider *aProvider,
uint32_t aSpacingStart, uint32_t aSpacingEnd,
uint16_t aOrientation,
@ -722,7 +724,8 @@ gfxTextRun::AccumulateMetricsForRun(gfxFont *aFont,
nsAutoTArray<PropertyProvider::Spacing,200> spacingBuffer;
bool haveSpacing = GetAdjustedSpacingArray(aStart, aEnd, aProvider,
aSpacingStart, aSpacingEnd, &spacingBuffer);
Metrics metrics = aFont->Measure(this, aStart, aEnd, aBoundingBoxType, aRefContext,
Metrics metrics = aFont->Measure(this, aStart, aEnd, aBoundingBoxType,
aRefDrawTarget,
haveSpacing ? spacingBuffer.Elements() : nullptr,
aOrientation);
aMetrics->CombineWith(metrics, IsRightToLeft());
@ -731,7 +734,7 @@ gfxTextRun::AccumulateMetricsForRun(gfxFont *aFont,
void
gfxTextRun::AccumulatePartialLigatureMetrics(gfxFont *aFont,
uint32_t aStart, uint32_t aEnd,
gfxFont::BoundingBoxType aBoundingBoxType, gfxContext *aRefContext,
gfxFont::BoundingBoxType aBoundingBoxType, DrawTarget* aRefDrawTarget,
PropertyProvider *aProvider, uint16_t aOrientation, Metrics *aMetrics)
{
if (aStart >= aEnd)
@ -744,7 +747,7 @@ gfxTextRun::AccumulatePartialLigatureMetrics(gfxFont *aFont,
// First measure the complete ligature
Metrics metrics;
AccumulateMetricsForRun(aFont, data.mLigatureStart, data.mLigatureEnd,
aBoundingBoxType, aRefContext,
aBoundingBoxType, aRefDrawTarget,
aProvider, aStart, aEnd, aOrientation, &metrics);
// Clip the bounding box to the ligature part
@ -769,7 +772,7 @@ gfxTextRun::AccumulatePartialLigatureMetrics(gfxFont *aFont,
gfxTextRun::Metrics
gfxTextRun::MeasureText(uint32_t aStart, uint32_t aLength,
gfxFont::BoundingBoxType aBoundingBoxType,
gfxContext *aRefContext,
DrawTarget* aRefDrawTarget,
PropertyProvider *aProvider)
{
NS_ASSERTION(aStart + aLength <= GetLength(), "Substring out of range");
@ -785,7 +788,7 @@ gfxTextRun::MeasureText(uint32_t aStart, uint32_t aLength,
ShrinkToLigatureBoundaries(&ligatureRunStart, &ligatureRunEnd);
AccumulatePartialLigatureMetrics(font, start, ligatureRunStart,
aBoundingBoxType, aRefContext, aProvider,
aBoundingBoxType, aRefDrawTarget, aProvider,
iter.GetGlyphRun()->mOrientation, &accumulatedMetrics);
// XXX This sucks. We have to get glyph extents just so we can detect
@ -795,11 +798,11 @@ gfxTextRun::MeasureText(uint32_t aStart, uint32_t aLength,
// advance widths.
AccumulateMetricsForRun(font,
ligatureRunStart, ligatureRunEnd, aBoundingBoxType,
aRefContext, aProvider, ligatureRunStart, ligatureRunEnd,
aRefDrawTarget, aProvider, ligatureRunStart, ligatureRunEnd,
iter.GetGlyphRun()->mOrientation, &accumulatedMetrics);
AccumulatePartialLigatureMetrics(font, ligatureRunEnd, end,
aBoundingBoxType, aRefContext, aProvider,
aBoundingBoxType, aRefDrawTarget, aProvider,
iter.GetGlyphRun()->mOrientation, &accumulatedMetrics);
}
@ -816,7 +819,7 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
gfxFloat *aTrimWhitespace,
Metrics *aMetrics,
gfxFont::BoundingBoxType aBoundingBoxType,
gfxContext *aRefContext,
DrawTarget* aRefDrawTarget,
bool *aUsedHyphenation,
uint32_t *aLastBreak,
bool aCanWordWrap,
@ -962,13 +965,13 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
}
if (aMetrics) {
*aMetrics = MeasureText(aStart, charsFit,
aBoundingBoxType, aRefContext, aProvider);
*aMetrics = MeasureText(aStart, charsFit, aBoundingBoxType,
aRefDrawTarget, aProvider);
if (trimmableChars) {
Metrics trimMetrics =
MeasureText(aStart + charsFit - trimmableChars,
trimmableChars, aBoundingBoxType,
aRefContext, aProvider);
aRefDrawTarget, aProvider);
aMetrics->mAdvanceWidth -= trimMetrics.mAdvanceWidth;
}
}
@ -1032,8 +1035,7 @@ gfxTextRun::GetAdvanceWidth(uint32_t aStart, uint32_t aLength,
bool
gfxTextRun::SetLineBreaks(uint32_t aStart, uint32_t aLength,
bool aLineBreakBefore, bool aLineBreakAfter,
gfxFloat *aAdvanceWidthDelta,
gfxContext *aRefContext)
gfxFloat *aAdvanceWidthDelta)
{
// Do nothing because our shaping does not currently take linebreaks into
// account. There is no change in advance width.
@ -1317,7 +1319,7 @@ gfxTextRun::ClearGlyphsAndCharacters()
}
void
gfxTextRun::SetSpaceGlyph(gfxFont *aFont, gfxContext *aContext,
gfxTextRun::SetSpaceGlyph(gfxFont* aFont, DrawTarget* aDrawTarget,
uint32_t aCharIndex, uint16_t aOrientation)
{
if (SetSpaceGlyphIfSimple(aFont, aCharIndex, ' ', aOrientation)) {
@ -1332,7 +1334,7 @@ gfxTextRun::SetSpaceGlyph(gfxFont *aFont, gfxContext *aContext,
aOrientation;
bool vertical =
(GetFlags() & gfxTextRunFactory::TEXT_ORIENT_VERTICAL_UPRIGHT) != 0;
gfxShapedWord *sw = aFont->GetShapedWord(aContext,
gfxShapedWord* sw = aFont->GetShapedWord(aDrawTarget,
&space, 1,
gfxShapedWord::HashMix(0, ' '),
MOZ_SCRIPT_LATIN,
@ -1378,7 +1380,7 @@ gfxTextRun::SetSpaceGlyphIfSimple(gfxFont* aFont, uint32_t aCharIndex,
}
void
gfxTextRun::FetchGlyphExtents(gfxContext *aRefContext)
gfxTextRun::FetchGlyphExtents(DrawTarget* aRefDrawTarget)
{
bool needsGlyphExtents = NeedsGlyphExtents(this);
if (!needsGlyphExtents && !mDetailedGlyphs)
@ -1410,7 +1412,7 @@ gfxTextRun::FetchGlyphExtents(gfxContext *aRefContext)
uint32_t glyphIndex = glyphData->GetSimpleGlyph();
if (!extents->IsGlyphKnown(glyphIndex)) {
if (!fontIsSetup) {
if (!font->SetupCairoFont(aRefContext->GetDrawTarget())) {
if (!font->SetupCairoFont(aRefDrawTarget)) {
NS_WARNING("failed to set up font for glyph extents");
break;
}
@ -1419,7 +1421,7 @@ gfxTextRun::FetchGlyphExtents(gfxContext *aRefContext)
#ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
++gGlyphExtentsSetupEagerSimple;
#endif
font->SetupGlyphExtents(aRefContext->GetDrawTarget(),
font->SetupGlyphExtents(aRefDrawTarget,
glyphIndex, false, extents);
}
}
@ -1436,7 +1438,7 @@ gfxTextRun::FetchGlyphExtents(gfxContext *aRefContext)
uint32_t glyphIndex = details->mGlyphID;
if (!extents->IsGlyphKnownWithTightExtents(glyphIndex)) {
if (!fontIsSetup) {
if (!font->SetupCairoFont(aRefContext->GetDrawTarget())) {
if (!font->SetupCairoFont(aRefDrawTarget)) {
NS_WARNING("failed to set up font for glyph extents");
break;
}
@ -1445,7 +1447,7 @@ gfxTextRun::FetchGlyphExtents(gfxContext *aRefContext)
#ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
++gGlyphExtentsSetupEagerTight;
#endif
font->SetupGlyphExtents(aRefContext->GetDrawTarget(),
font->SetupGlyphExtents(aRefDrawTarget,
glyphIndex, true, extents);
}
}
@ -1988,7 +1990,7 @@ gfxFontGroup::MakeSpaceTextRun(const Parameters *aParams, uint32_t aFlags)
if (font->GetSpaceGlyph()) {
// Normally, the font has a cached space glyph, so we can avoid
// the cost of calling FindFontForChar.
textRun->SetSpaceGlyph(font, aParams->mContext, 0, orientation);
textRun->SetSpaceGlyph(font, aParams->mDrawTarget, 0, orientation);
} else {
// In case the primary font doesn't have <space> (bug 970891),
// find one that does.
@ -1997,7 +1999,7 @@ gfxFontGroup::MakeSpaceTextRun(const Parameters *aParams, uint32_t aFlags)
FindFontForChar(' ', 0, 0, MOZ_SCRIPT_LATIN, nullptr,
&matchType);
if (spaceFont) {
textRun->SetSpaceGlyph(spaceFont, aParams->mContext, 0,
textRun->SetSpaceGlyph(spaceFont, aParams->mDrawTarget, 0,
orientation);
}
}
@ -2029,7 +2031,8 @@ gfxFontGroup::MakeBlankTextRun(uint32_t aLength,
}
gfxTextRun *
gfxFontGroup::MakeHyphenTextRun(gfxContext *aCtx, uint32_t aAppUnitsPerDevUnit)
gfxFontGroup::MakeHyphenTextRun(DrawTarget* aDrawTarget,
uint32_t aAppUnitsPerDevUnit)
{
// only use U+2010 if it is supported by the first font in the group;
// it's better to use ASCII '-' from the primary font than to fall back to
@ -2037,12 +2040,12 @@ gfxFontGroup::MakeHyphenTextRun(gfxContext *aCtx, uint32_t aAppUnitsPerDevUnit)
static const char16_t hyphen = 0x2010;
gfxFont *font = GetFirstValidFont(uint32_t(hyphen));
if (font->HasCharacter(hyphen)) {
return MakeTextRun(&hyphen, 1, aCtx, aAppUnitsPerDevUnit,
return MakeTextRun(&hyphen, 1, aDrawTarget, aAppUnitsPerDevUnit,
gfxFontGroup::TEXT_IS_PERSISTENT, nullptr);
}
static const uint8_t dash = '-';
return MakeTextRun(&dash, 1, aCtx, aAppUnitsPerDevUnit,
return MakeTextRun(&dash, 1, aDrawTarget, aAppUnitsPerDevUnit,
gfxFontGroup::TEXT_IS_PERSISTENT, nullptr);
}
@ -2050,10 +2053,10 @@ gfxFloat
gfxFontGroup::GetHyphenWidth(gfxTextRun::PropertyProvider *aProvider)
{
if (mHyphenWidth < 0) {
RefPtr<gfxContext> ctx(aProvider->GetContext());
if (ctx) {
RefPtr<DrawTarget> dt(aProvider->GetDrawTarget());
if (dt) {
nsAutoPtr<gfxTextRun>
hyphRun(MakeHyphenTextRun(ctx,
hyphRun(MakeHyphenTextRun(dt,
aProvider->GetAppUnitsPerDevUnit()));
mHyphenWidth = hyphRun.get() ?
hyphRun->GetAdvanceWidth(0, hyphRun->GetLength(), nullptr) : 0;
@ -2090,9 +2093,9 @@ gfxFontGroup::MakeTextRun(const uint8_t *aString, uint32_t aLength,
return nullptr;
}
InitTextRun(aParams->mContext, textRun, aString, aLength, aMFR);
InitTextRun(aParams->mDrawTarget, textRun, aString, aLength, aMFR);
textRun->FetchGlyphExtents(aParams->mContext);
textRun->FetchGlyphExtents(aParams->mDrawTarget);
return textRun;
}
@ -2119,16 +2122,16 @@ gfxFontGroup::MakeTextRun(const char16_t *aString, uint32_t aLength,
return nullptr;
}
InitTextRun(aParams->mContext, textRun, aString, aLength, aMFR);
InitTextRun(aParams->mDrawTarget, textRun, aString, aLength, aMFR);
textRun->FetchGlyphExtents(aParams->mContext);
textRun->FetchGlyphExtents(aParams->mDrawTarget);
return textRun;
}
template<typename T>
void
gfxFontGroup::InitTextRun(gfxContext *aContext,
gfxFontGroup::InitTextRun(DrawTarget* aDrawTarget,
gfxTextRun *aTextRun,
const T *aString,
uint32_t aLength,
@ -2207,7 +2210,7 @@ gfxFontGroup::InitTextRun(gfxContext *aContext,
// the text is still purely 8-bit; bypass the script-run itemizer
// and treat it as a single Latin run
InitScriptRun(aContext, aTextRun, aString,
InitScriptRun(aDrawTarget, aTextRun, aString,
0, aLength, MOZ_SCRIPT_LATIN, aMFR);
} else {
const char16_t *textPtr;
@ -2253,7 +2256,7 @@ gfxFontGroup::InitTextRun(gfxContext *aContext,
NS_ConvertUTF16toUTF8(textPtr + runStart, runLen).get()));
}
InitScriptRun(aContext, aTextRun, textPtr + runStart,
InitScriptRun(aDrawTarget, aTextRun, textPtr + runStart,
runStart, runLimit - runStart, runScript, aMFR);
}
}
@ -2300,7 +2303,7 @@ IsPUA(uint32_t aUSV)
template<typename T>
void
gfxFontGroup::InitScriptRun(gfxContext *aContext,
gfxFontGroup::InitScriptRun(DrawTarget* aDrawTarget,
gfxTextRun *aTextRun,
const T *aString, // text for this script run,
// not the entire textrun
@ -2342,7 +2345,7 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext,
aTextRun->AddGlyphRun(matchedFont, range.matchType,
aOffset + runStart, (matchedLength > 0),
range.orientation);
if (!matchedFont->SplitAndInitTextRun(aContext, aTextRun,
if (!matchedFont->SplitAndInitTextRun(aDrawTarget, aTextRun,
aString + runStart,
aOffset + runStart,
matchedLength,
@ -2382,7 +2385,7 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext,
aTextRun->AddGlyphRun(subSuperFont, range.matchType,
aOffset + runStart, (matchedLength > 0),
range.orientation);
if (!subSuperFont->SplitAndInitTextRun(aContext, aTextRun,
if (!subSuperFont->SplitAndInitTextRun(aDrawTarget, aTextRun,
aString + runStart,
aOffset + runStart,
matchedLength,
@ -2399,7 +2402,7 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext,
syntheticUpper))
{
// fallback for small-caps variant glyphs
if (!matchedFont->InitFakeSmallCapsRun(aContext, aTextRun,
if (!matchedFont->InitFakeSmallCapsRun(aDrawTarget, aTextRun,
aString + runStart,
aOffset + runStart,
matchedLength,
@ -2427,7 +2430,7 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext,
aTextRun->AddGlyphRun(matchedFont, range.matchType,
aOffset + runStart, (matchedLength > 0),
range.orientation);
if (!matchedFont->SplitAndInitTextRun(aContext, aTextRun,
if (!matchedFont->SplitAndInitTextRun(aDrawTarget, aTextRun,
aString + runStart,
aOffset + runStart,
matchedLength,
@ -2533,7 +2536,7 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext,
gfxTextRun *
gfxFontGroup::GetEllipsisTextRun(int32_t aAppUnitsPerDevPixel, uint32_t aFlags,
LazyReferenceContextGetter& aRefContextGetter)
LazyReferenceDrawTargetGetter& aRefDrawTargetGetter)
{
MOZ_ASSERT(!(aFlags & ~TEXT_ORIENT_MASK),
"flags here should only be used to specify orientation");
@ -2552,9 +2555,9 @@ gfxFontGroup::GetEllipsisTextRun(int32_t aAppUnitsPerDevPixel, uint32_t aFlags,
: nsDependentString(kASCIIPeriodsChar,
ArrayLength(kASCIIPeriodsChar) - 1);
RefPtr<gfxContext> refCtx = aRefContextGetter.GetRefContext();
RefPtr<DrawTarget> refDT = aRefDrawTargetGetter.GetRefDrawTarget();
Parameters params = {
refCtx, nullptr, nullptr, nullptr, 0, aAppUnitsPerDevPixel
refDT, nullptr, nullptr, nullptr, 0, aAppUnitsPerDevPixel
};
gfxTextRun* textRun =
MakeTextRun(ellipsis.get(), ellipsis.Length(), &params,

View File

@ -82,7 +82,6 @@ struct gfxTextRunDrawCallbacks {
*/
class gfxTextRun : public gfxShapedText {
public:
// Override operator delete to properly free the object that was
// allocated via malloc.
void operator delete(void* p) {
@ -92,6 +91,7 @@ public:
virtual ~gfxTextRun();
typedef gfxFont::RunMetrics Metrics;
typedef mozilla::gfx::DrawTarget DrawTarget;
// Public textrun API for general use
@ -194,7 +194,7 @@ public:
// Returns a gfxContext that can be used to measure the hyphen glyph.
// Only called if the hyphen width is requested.
virtual already_AddRefed<gfxContext> GetContext() = 0;
virtual already_AddRefed<DrawTarget> GetDrawTarget() = 0;
// Return the appUnitsPerDevUnit value to be used when measuring.
// Only called if the hyphen width is requested.
@ -267,8 +267,8 @@ public:
*/
Metrics MeasureText(uint32_t aStart, uint32_t aLength,
gfxFont::BoundingBoxType aBoundingBoxType,
gfxContext *aRefContextForTightBoundingBox,
PropertyProvider *aProvider);
DrawTarget* aDrawTargetForTightBoundingBox,
PropertyProvider* aProvider);
/**
* Computes just the advance width for a substring.
@ -310,8 +310,7 @@ public:
*/
virtual bool SetLineBreaks(uint32_t aStart, uint32_t aLength,
bool aLineBreakBefore, bool aLineBreakAfter,
gfxFloat *aAdvanceWidthDelta,
gfxContext *aRefContext);
gfxFloat* aAdvanceWidthDelta);
enum SuppressBreak {
eNoSuppressBreak,
@ -355,7 +354,7 @@ public:
* @param aMetrics if non-null, we fill this in for the returned substring.
* If a hyphenation break was used, the hyphen is NOT included in the returned metrics.
* @param aBoundingBoxType whether to make the bounding box in aMetrics tight
* @param aRefContextForTightBoundingBox a reference context to get the
* @param aDrawTargetForTightBoundingbox a reference DrawTarget to get the
* tight bounding box, if requested
* @param aUsedHyphenation if non-null, records if we selected a hyphenation break
* @param aLastBreak if non-null and result is aMaxLength, we set this to
@ -383,7 +382,7 @@ public:
gfxFloat *aTrimWhitespace,
Metrics *aMetrics,
gfxFont::BoundingBoxType aBoundingBoxType,
gfxContext *aRefContextForTightBoundingBox,
DrawTarget* aDrawTargetForTightBoundingBox,
bool *aUsedHyphenation,
uint32_t *aLastBreak,
bool aCanWordWrap,
@ -490,8 +489,8 @@ public:
// clean out results from shaping in progress, used for fallback scenarios
void ClearGlyphsAndCharacters();
void SetSpaceGlyph(gfxFont *aFont, gfxContext *aContext, uint32_t aCharIndex,
uint16_t aOrientation);
void SetSpaceGlyph(gfxFont* aFont, DrawTarget* aDrawTarget,
uint32_t aCharIndex, uint16_t aOrientation);
// Set the glyph data for the given character index to the font's
// space glyph, IF this can be done as a "simple" glyph record
@ -531,7 +530,7 @@ public:
* that some glyph extents might not be fetched due to OOM or other
* errors.
*/
void FetchGlyphExtents(gfxContext *aRefContext);
void FetchGlyphExtents(DrawTarget* aRefDrawTarget);
uint32_t CountMissingGlyphs();
const GlyphRun *GetGlyphRuns(uint32_t *aNumGlyphRuns) {
@ -696,7 +695,7 @@ private:
void AccumulatePartialLigatureMetrics(gfxFont *aFont,
uint32_t aStart, uint32_t aEnd,
gfxFont::BoundingBoxType aBoundingBoxType,
gfxContext *aRefContext,
DrawTarget* aRefDrawTarget,
PropertyProvider *aProvider,
uint16_t aOrientation,
Metrics *aMetrics);
@ -704,7 +703,7 @@ private:
// **** measurement helper ****
void AccumulateMetricsForRun(gfxFont *aFont, uint32_t aStart, uint32_t aEnd,
gfxFont::BoundingBoxType aBoundingBoxType,
gfxContext *aRefContext,
DrawTarget* aRefDrawTarget,
PropertyProvider *aProvider,
uint32_t aSpacingStart, uint32_t aSpacingEnd,
uint16_t aOrientation,
@ -793,14 +792,14 @@ public:
* a full Parameters record.
*/
template<typename T>
gfxTextRun *MakeTextRun(const T *aString, uint32_t aLength,
gfxContext *aRefContext,
gfxTextRun* MakeTextRun(const T* aString, uint32_t aLength,
DrawTarget* aRefDrawTarget,
int32_t aAppUnitsPerDevUnit,
uint32_t aFlags,
gfxMissingFontRecorder *aMFR)
{
gfxTextRunFactory::Parameters params = {
aRefContext, nullptr, nullptr, nullptr, 0, aAppUnitsPerDevUnit
aRefDrawTarget, nullptr, nullptr, nullptr, 0, aAppUnitsPerDevUnit
};
return MakeTextRun(aString, aLength, &params, aFlags, aMFR);
}
@ -820,7 +819,7 @@ public:
* The caller is responsible for deleting the returned text run
* when no longer required.
*/
gfxTextRun *MakeHyphenTextRun(gfxContext *aCtx,
gfxTextRun* MakeHyphenTextRun(DrawTarget* aDrawTarget,
uint32_t aAppUnitsPerDevUnit);
/**
@ -871,9 +870,9 @@ public:
return mSkipDrawing;
}
class LazyReferenceContextGetter {
class LazyReferenceDrawTargetGetter {
public:
virtual already_AddRefed<gfxContext> GetRefContext() = 0;
virtual already_AddRefed<DrawTarget> GetRefDrawTarget() = 0;
};
// The gfxFontGroup keeps ownership of this textrun.
// It is only guaranteed to exist until the next call to GetEllipsisTextRun
@ -881,7 +880,7 @@ public:
// group, or until UpdateUserFonts is called, or the fontgroup is destroyed.
// Get it/use it/forget it :) - don't keep a reference that might go stale.
gfxTextRun* GetEllipsisTextRun(int32_t aAppUnitsPerDevPixel, uint32_t aFlags,
LazyReferenceContextGetter& aRefContextGetter);
LazyReferenceDrawTargetGetter& aRefDrawTargetGetter);
protected:
// search through pref fonts for a character, return nullptr if no matching pref font
@ -1102,7 +1101,7 @@ protected:
// Set up the textrun glyphs for an entire text run:
// find script runs, and then call InitScriptRun for each
template<typename T>
void InitTextRun(gfxContext *aContext,
void InitTextRun(DrawTarget* aDrawTarget,
gfxTextRun *aTextRun,
const T *aString,
uint32_t aLength,
@ -1111,7 +1110,7 @@ protected:
// InitTextRun helper to handle a single script run, by finding font ranges
// and calling each font's InitTextRun() as appropriate
template<typename T>
void InitScriptRun(gfxContext *aContext,
void InitScriptRun(DrawTarget* aDrawTarget,
gfxTextRun *aTextRun,
const T *aString,
uint32_t aScriptRunStart,

View File

@ -2212,12 +2212,14 @@ class MOZ_STACK_CLASS nsIRenderingContextBidiProcessor final
: public nsBidiPresUtils::BidiProcessor
{
public:
typedef mozilla::gfx::DrawTarget DrawTarget;
nsIRenderingContextBidiProcessor(nsRenderingContext* aCtx,
nsRenderingContext* aTextRunConstructionContext,
DrawTarget* aTextRunConstructionDrawTarget,
nsFontMetrics* aFontMetrics,
const nsPoint& aPt)
: mCtx(aCtx)
, mTextRunConstructionContext(aTextRunConstructionContext)
, mTextRunConstructionDrawTarget(aTextRunConstructionDrawTarget)
, mFontMetrics(aFontMetrics)
, mPt(aPt)
{}
@ -2239,7 +2241,7 @@ public:
virtual nscoord GetWidth() override
{
return nsLayoutUtils::AppUnitWidthOfString(mText, mLength, *mFontMetrics,
*mTextRunConstructionContext);
mTextRunConstructionDrawTarget);
}
virtual void DrawText(nscoord aIOffset,
@ -2252,12 +2254,12 @@ public:
pt.x += aIOffset;
}
mFontMetrics->DrawString(mText, mLength, pt.x, pt.y,
mCtx, mTextRunConstructionContext);
mCtx, mTextRunConstructionDrawTarget);
}
private:
nsRenderingContext* mCtx;
nsRenderingContext* mTextRunConstructionContext;
DrawTarget* mTextRunConstructionDrawTarget;
nsFontMetrics* mFontMetrics;
nsPoint mPt;
const char16_t* mText;
@ -2269,7 +2271,7 @@ nsresult nsBidiPresUtils::ProcessTextForRenderingContext(const char16_t* a
nsBidiLevel aBaseLevel,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsRenderingContext& aTextRunConstructionContext,
DrawTarget* aTextRunConstructionDrawTarget,
nsFontMetrics& aFontMetrics,
Mode aMode,
nscoord aX,
@ -2279,7 +2281,7 @@ nsresult nsBidiPresUtils::ProcessTextForRenderingContext(const char16_t* a
nscoord* aWidth)
{
nsIRenderingContextBidiProcessor processor(&aRenderingContext,
&aTextRunConstructionContext,
aTextRunConstructionDrawTarget,
&aFontMetrics,
nsPoint(aX, aY));
nsBidi bidiEngine;

View File

@ -11,6 +11,7 @@
#include "nsBidiUtils.h"
#include "nsHashKeys.h"
#include "nsCoord.h"
#include "nsRenderingContext.h"
#ifdef DrawText
#undef DrawText
@ -93,6 +94,8 @@ struct nsBidiPositionResolve
class nsBidiPresUtils {
public:
typedef mozilla::gfx::DrawTarget DrawTarget;
nsBidiPresUtils();
~nsBidiPresUtils();
@ -212,7 +215,7 @@ public:
nsBidiLevel aBaseLevel,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsRenderingContext& aTextRunConstructionContext,
DrawTarget* aTextRunConstructionDrawTarget,
nsFontMetrics& aFontMetrics,
nscoord aX,
nscoord aY,
@ -220,7 +223,7 @@ public:
int32_t aPosResolveCount = 0)
{
return ProcessTextForRenderingContext(aText, aLength, aBaseLevel, aPresContext, aRenderingContext,
aTextRunConstructionContext,
aTextRunConstructionDrawTarget,
aFontMetrics,
MODE_DRAW, aX, aY, aPosResolve, aPosResolveCount, nullptr);
}
@ -234,7 +237,8 @@ public:
{
nscoord length;
nsresult rv = ProcessTextForRenderingContext(aText, aLength, aBaseLevel, aPresContext,
aRenderingContext, aRenderingContext,
aRenderingContext,
aRenderingContext.GetDrawTarget(),
aFontMetrics,
MODE_MEASURE, 0, 0, nullptr, 0, &length);
return NS_SUCCEEDED(rv) ? length : 0;
@ -377,7 +381,7 @@ private:
nsBidiLevel aBaseLevel,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsRenderingContext& aTextRunConstructionContext,
DrawTarget* aTextRunConstructionDrawTarget,
nsFontMetrics& aFontMetrics,
Mode aMode,
nscoord aX, // DRAW only

View File

@ -3465,7 +3465,7 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
* before the cursor aIndex contains the index of the text where the cursor falls
*/
bool
nsLayoutUtils::BinarySearchForPosition(nsRenderingContext* aRendContext,
nsLayoutUtils::BinarySearchForPosition(DrawTarget* aDrawTarget,
nsFontMetrics& aFontMetrics,
const char16_t* aText,
int32_t aBaseWidth,
@ -3480,8 +3480,7 @@ nsLayoutUtils::BinarySearchForPosition(nsRenderingContext* aRendContext,
if ((range == 1) || (range == 2 && NS_IS_HIGH_SURROGATE(aText[aStartInx]))) {
aIndex = aStartInx + aBaseInx;
aTextWidth = nsLayoutUtils::AppUnitWidthOfString(aText, aIndex,
aFontMetrics,
*aRendContext);
aFontMetrics, aDrawTarget);
return true;
}
@ -3493,7 +3492,7 @@ nsLayoutUtils::BinarySearchForPosition(nsRenderingContext* aRendContext,
int32_t textWidth = nsLayoutUtils::AppUnitWidthOfString(aText, inx,
aFontMetrics,
*aRendContext);
aDrawTarget);
int32_t fullWidth = aBaseWidth + textWidth;
if (fullWidth == aCursorPos) {
@ -3502,14 +3501,14 @@ nsLayoutUtils::BinarySearchForPosition(nsRenderingContext* aRendContext,
return true;
} else if (aCursorPos < fullWidth) {
aTextWidth = aBaseWidth;
if (BinarySearchForPosition(aRendContext, aFontMetrics, aText, aBaseWidth,
if (BinarySearchForPosition(aDrawTarget, aFontMetrics, aText, aBaseWidth,
aBaseInx, aStartInx, inx, aCursorPos, aIndex,
aTextWidth)) {
return true;
}
} else {
aTextWidth = fullWidth;
if (BinarySearchForPosition(aRendContext, aFontMetrics, aText, aBaseWidth,
if (BinarySearchForPosition(aDrawTarget, aFontMetrics, aText, aBaseWidth,
aBaseInx, inx, aEndInx, aCursorPos, aIndex,
aTextWidth)) {
return true;
@ -5507,13 +5506,13 @@ nscoord
nsLayoutUtils::AppUnitWidthOfString(const char16_t *aString,
uint32_t aLength,
nsFontMetrics& aFontMetrics,
nsRenderingContext& aContext)
DrawTarget* aDrawTarget)
{
uint32_t maxChunkLength = GetMaxChunkLength(aFontMetrics);
nscoord width = 0;
while (aLength > 0) {
int32_t len = FindSafeLength(aString, aLength, maxChunkLength);
width += aFontMetrics.GetWidth(aString, len, &aContext);
width += aFontMetrics.GetWidth(aString, len, aDrawTarget);
aLength -= len;
aString += len;
}
@ -5539,13 +5538,13 @@ nsLayoutUtils::AppUnitWidthOfStringBidi(const char16_t* aString,
aFontMetrics.SetVertical(aFrame->GetWritingMode().IsVertical());
aFontMetrics.SetTextOrientation(aFrame->StyleVisibility()->mTextOrientation);
return nsLayoutUtils::AppUnitWidthOfString(aString, aLength, aFontMetrics,
aContext);
aContext.GetDrawTarget());
}
bool
nsLayoutUtils::StringWidthIsGreaterThan(const nsString& aString,
nsFontMetrics& aFontMetrics,
nsRenderingContext& aContext,
DrawTarget* aDrawTarget,
nscoord aWidth)
{
const char16_t *string = aString.get();
@ -5554,7 +5553,7 @@ nsLayoutUtils::StringWidthIsGreaterThan(const nsString& aString,
nscoord width = 0;
while (length > 0) {
int32_t len = FindSafeLength(string, length, maxChunkLength);
width += aFontMetrics.GetWidth(string, len, &aContext);
width += aFontMetrics.GetWidth(string, len, aDrawTarget);
if (width > aWidth) {
return true;
}
@ -5568,7 +5567,7 @@ nsBoundingMetrics
nsLayoutUtils::AppUnitBoundsOfString(const char16_t* aString,
uint32_t aLength,
nsFontMetrics& aFontMetrics,
nsRenderingContext& aContext)
DrawTarget* aDrawTarget)
{
uint32_t maxChunkLength = GetMaxChunkLength(aFontMetrics);
int32_t len = FindSafeLength(aString, aLength, maxChunkLength);
@ -5576,14 +5575,14 @@ nsLayoutUtils::AppUnitBoundsOfString(const char16_t* aString,
// negative ascent/descent can be returned and the left bearing
// is properly initialized.
nsBoundingMetrics totalMetrics =
aFontMetrics.GetBoundingMetrics(aString, len, &aContext);
aFontMetrics.GetBoundingMetrics(aString, len, aDrawTarget);
aLength -= len;
aString += len;
while (aLength > 0) {
len = FindSafeLength(aString, aLength, maxChunkLength);
nsBoundingMetrics metrics =
aFontMetrics.GetBoundingMetrics(aString, len, &aContext);
aFontMetrics.GetBoundingMetrics(aString, len, aDrawTarget);
totalMetrics += metrics;
aLength -= len;
aString += len;
@ -5615,8 +5614,8 @@ nsLayoutUtils::DrawString(const nsIFrame* aFrame,
nsBidiLevel level =
nsBidiPresUtils::BidiLevelFromStyle(aStyleContext);
rv = nsBidiPresUtils::RenderText(aString, aLength, level,
presContext, *aContext, *aContext,
aFontMetrics,
presContext, *aContext,
aContext->GetDrawTarget(), aFontMetrics,
aPoint.x, aPoint.y);
}
if (NS_FAILED(rv))
@ -5638,7 +5637,8 @@ nsLayoutUtils::DrawUniDirString(const char16_t* aString,
uint32_t maxChunkLength = GetMaxChunkLength(aFontMetrics);
if (aLength <= maxChunkLength) {
aFontMetrics.DrawString(aString, aLength, x, y, &aContext, &aContext);
aFontMetrics.DrawString(aString, aLength, x, y, &aContext,
aContext.GetDrawTarget());
return;
}
@ -5647,16 +5647,17 @@ nsLayoutUtils::DrawUniDirString(const char16_t* aString,
// If we're drawing right to left, we must start at the end.
if (isRTL) {
x += nsLayoutUtils::AppUnitWidthOfString(aString, aLength, aFontMetrics,
aContext);
aContext.GetDrawTarget());
}
while (aLength > 0) {
int32_t len = FindSafeLength(aString, aLength, maxChunkLength);
nscoord width = aFontMetrics.GetWidth(aString, len, &aContext);
nscoord width = aFontMetrics.GetWidth(aString, len, aContext.GetDrawTarget());
if (isRTL) {
x -= width;
}
aFontMetrics.DrawString(aString, len, x, y, &aContext, &aContext);
aFontMetrics.DrawString(aString, len, x, y, &aContext,
aContext.GetDrawTarget());
if (!isRTL) {
x += width;
}

View File

@ -1050,7 +1050,7 @@ public:
* falls.
*/
static bool
BinarySearchForPosition(nsRenderingContext* acx,
BinarySearchForPosition(DrawTarget* aDrawTarget,
nsFontMetrics& aFontMetrics,
const char16_t* aText,
int32_t aBaseWidth,
@ -1562,19 +1562,19 @@ public:
static nscoord AppUnitWidthOfString(char16_t aC,
nsFontMetrics& aFontMetrics,
nsRenderingContext& aContext) {
return AppUnitWidthOfString(&aC, 1, aFontMetrics, aContext);
DrawTarget* aDrawTarget) {
return AppUnitWidthOfString(&aC, 1, aFontMetrics, aDrawTarget);
}
static nscoord AppUnitWidthOfString(const nsString& aString,
nsFontMetrics& aFontMetrics,
nsRenderingContext& aContext) {
DrawTarget* aDrawTarget) {
return nsLayoutUtils::AppUnitWidthOfString(aString.get(), aString.Length(),
aFontMetrics, aContext);
aFontMetrics, aDrawTarget);
}
static nscoord AppUnitWidthOfString(const char16_t *aString,
uint32_t aLength,
nsFontMetrics& aFontMetrics,
nsRenderingContext& aContext);
DrawTarget* aDrawTarget);
static nscoord AppUnitWidthOfStringBidi(const nsString& aString,
const nsIFrame* aFrame,
nsFontMetrics& aFontMetrics,
@ -1591,13 +1591,13 @@ public:
static bool StringWidthIsGreaterThan(const nsString& aString,
nsFontMetrics& aFontMetrics,
nsRenderingContext& aContext,
DrawTarget* aDrawTarget,
nscoord aWidth);
static nsBoundingMetrics AppUnitBoundsOfString(const char16_t* aString,
uint32_t aLength,
nsFontMetrics& aFontMetrics,
nsRenderingContext& aContext);
DrawTarget* aDrawTarget);
static void DrawString(const nsIFrame* aFrame,
nsFontMetrics& aFontMetrics,

View File

@ -10051,7 +10051,7 @@ void ReflowCountMgr::PaintCount(const char* aName,
nscoord x = 0, y = fm->MaxAscent();
nscoord width, height = fm->MaxHeight();
fm->SetTextRunRTL(false);
width = fm->GetWidth(buf, len, aRenderingContext);;
width = fm->GetWidth(buf, len, drawTarget);
Color color;
Color color2;

View File

@ -91,7 +91,7 @@ of the presence of white-space in the line as it told to reflow each inline
frame. This allows for the compression of leading whitespace and the compression
of adjacent whitespace that is in separate inline elements.
<p>As a post-processing step, the TrimTrailingWhiteSpace logic is used
to remove those pesky pices of white-space that end up being placed at
to remove those pesky pieces of white-space that end up being placed at
the end of a line, that shouldn't really be seen.
<p>To support pre-formatted text that contains tab characters, the line
layout class keeps track of the current column on behalf of the text frame

View File

@ -529,7 +529,7 @@ MathVariant(uint32_t aCh, uint8_t aMathVar)
void
MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
gfxContext* aRefContext,
mozilla::gfx::DrawTarget* aRefDrawTarget,
gfxMissingFontRecorder* aMFR)
{
gfxFontGroup* fontGroup = aTextRun->GetFontGroup();
@ -712,7 +712,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
uint32_t flags;
gfxTextRunFactory::Parameters innerParams =
GetParametersForInner(aTextRun, &flags, aRefContext);
GetParametersForInner(aTextRun, &flags, aRefDrawTarget);
nsAutoPtr<nsTransformedTextRun> transformedChild;
nsAutoPtr<gfxTextRun> cachedChild;
@ -780,7 +780,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(),
canBreakBeforeArray.Elements());
if (transformedChild) {
transformedChild->FinishSettingProperties(aRefContext, aMFR);
transformedChild->FinishSettingProperties(aRefDrawTarget, aMFR);
}
if (mergeNeeded) {

View File

@ -22,7 +22,7 @@ public:
mSSTYScriptLevel(aSSTYScriptLevel) {}
virtual void RebuildTextRun(nsTransformedTextRun* aTextRun,
gfxContext* aRefContext,
mozilla::gfx::DrawTarget* aRefDrawTarget,
gfxMissingFontRecorder* aMFR) override;
enum {
// Style effects which may override single character <mi> behaviour

View File

@ -28,14 +28,19 @@
namespace mozilla {
namespace css {
class LazyReferenceRenderingContextGetterFromFrame final :
public gfxFontGroup::LazyReferenceContextGetter {
class LazyReferenceRenderingDrawTargetGetterFromFrame final :
public gfxFontGroup::LazyReferenceDrawTargetGetter {
public:
explicit LazyReferenceRenderingContextGetterFromFrame(nsIFrame* aFrame)
typedef mozilla::gfx::DrawTarget DrawTarget;
explicit LazyReferenceRenderingDrawTargetGetterFromFrame(nsIFrame* aFrame)
: mFrame(aFrame) {}
virtual already_AddRefed<gfxContext> GetRefContext() override
virtual already_AddRefed<DrawTarget> GetRefDrawTarget() override
{
return mFrame->PresContext()->PresShell()->CreateReferenceRenderingContext();
RefPtr<gfxContext> ctx =
mFrame->PresContext()->PresShell()->CreateReferenceRenderingContext();
RefPtr<DrawTarget> dt = ctx->GetDrawTarget();
return dt.forget();
}
private:
nsIFrame* mFrame;
@ -47,11 +52,11 @@ GetEllipsisTextRun(nsIFrame* aFrame)
RefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(aFrame));
LazyReferenceRenderingContextGetterFromFrame lazyRefContextGetter(aFrame);
LazyReferenceRenderingDrawTargetGetterFromFrame lazyRefDrawTargetGetter(aFrame);
return fm->GetThebesFontGroup()->GetEllipsisTextRun(
aFrame->PresContext()->AppUnitsPerDevPixel(),
nsLayoutUtils::GetTextRunOrientFlagsForStyle(aFrame->StyleContext()),
lazyRefContextGetter);
lazyRefDrawTargetGetter);
}
static nsIFrame*

View File

@ -843,13 +843,13 @@ nsBlockFrame::GetPrefISize(nsRenderingContext *aRenderingContext)
}
nsRect
nsBlockFrame::ComputeTightBounds(gfxContext* aContext) const
nsBlockFrame::ComputeTightBounds(DrawTarget* aDrawTarget) const
{
// be conservative
if (StyleContext()->HasTextDecorationLines()) {
return GetVisualOverflowRect();
}
return ComputeSimpleTightBounds(aContext);
return ComputeSimpleTightBounds(aDrawTarget);
}
/* virtual */ nsresult

View File

@ -230,7 +230,7 @@ public:
virtual nscoord GetMinISize(nsRenderingContext *aRenderingContext) override;
virtual nscoord GetPrefISize(nsRenderingContext *aRenderingContext) override;
virtual nsRect ComputeTightBounds(gfxContext* aContext) const override;
virtual nsRect ComputeTightBounds(DrawTarget* aDrawTarget) const override;
virtual nsresult GetPrefWidthTightBounds(nsRenderingContext* aContext,
nscoord* aX,

View File

@ -608,8 +608,7 @@ nsBulletFrame::GetDesiredSize(nsPresContext* aCX,
GetListItemText(text);
finalSize.BSize(wm) = fm->MaxHeight();
finalSize.ISize(wm) =
nsLayoutUtils::AppUnitWidthOfStringBidi(text, this, *fm,
*aRenderingContext);
nsLayoutUtils::AppUnitWidthOfStringBidi(text, this, *fm, *aRenderingContext);
aMetrics.SetBlockStartAscent(wm.IsLineInverted()
? fm->MaxDescent() : fm->MaxAscent());
break;
@ -631,8 +630,8 @@ nsBulletFrame::Reflow(nsPresContext* aPresContext,
SetFontSizeInflation(inflation);
// Get the base size
GetDesiredSize(aPresContext, aReflowState.rendContext,
aMetrics, inflation, &mPadding);
GetDesiredSize(aPresContext, aReflowState.rendContext, aMetrics, inflation,
&mPadding);
// Add in the border and padding; split the top/bottom between the
// ascent and descent to make things look nice

View File

@ -4522,13 +4522,13 @@ nsFrame::ComputeSize(nsRenderingContext *aRenderingContext,
}
nsRect
nsIFrame::ComputeTightBounds(gfxContext* aContext) const
nsIFrame::ComputeTightBounds(DrawTarget* aDrawTarget) const
{
return GetVisualOverflowRect();
}
nsRect
nsFrame::ComputeSimpleTightBounds(gfxContext* aContext) const
nsFrame::ComputeSimpleTightBounds(DrawTarget* aDrawTarget) const
{
if (StyleOutline()->GetOutlineStyle() != NS_STYLE_BORDER_STYLE_NONE ||
StyleBorder()->HasBorder() || !StyleBackground()->IsTransparent() ||
@ -4544,7 +4544,7 @@ nsFrame::ComputeSimpleTightBounds(gfxContext* aContext) const
nsFrameList::Enumerator childFrames(lists.CurrentList());
for (; !childFrames.AtEnd(); childFrames.Next()) {
nsIFrame* child = childFrames.get();
r.UnionRect(r, child->ComputeTightBounds(aContext) + child->GetPosition());
r.UnionRect(r, child->ComputeTightBounds(aDrawTarget) + child->GetPosition());
}
}
return r;

View File

@ -273,7 +273,7 @@ public:
// Compute tight bounds assuming this frame honours its border, background
// and outline, its children's tight bounds, and nothing else.
nsRect ComputeSimpleTightBounds(gfxContext* aContext) const;
nsRect ComputeSimpleTightBounds(mozilla::gfx::DrawTarget* aDrawTarget) const;
/**
* A helper, used by |nsFrame::ComputeSize| (for frames that need to

View File

@ -423,6 +423,7 @@ public:
typedef mozilla::layout::FrameChildListIDs ChildListIDs;
typedef mozilla::layout::FrameChildListIterator ChildListIterator;
typedef mozilla::layout::FrameChildListArrayIterator ChildListArrayIterator;
typedef mozilla::gfx::DrawTarget DrawTarget;
typedef mozilla::gfx::Matrix Matrix;
typedef mozilla::gfx::Matrix4x4 Matrix4x4;
typedef mozilla::Sides Sides;
@ -894,8 +895,7 @@ public:
NS_DECLARE_FRAME_PROPERTY(LineBaselineOffset, nullptr)
NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImage, ReleaseValue<gfxASurface>)
NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImageDT,
ReleaseValue<mozilla::gfx::DrawTarget>)
NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImageDT, ReleaseValue<DrawTarget>)
NS_DECLARE_FRAME_PROPERTY(InvalidationRect, DeleteValue<nsRect>)
@ -1799,10 +1799,10 @@ public:
* text decorations, but today it sometimes includes other things that
* contribute to visual overflow.
*
* @param aContext a rendering context that can be used if we need
* @param aDrawTarget a draw target that can be used if we need
* to do measurement
*/
virtual nsRect ComputeTightBounds(gfxContext* aContext) const;
virtual nsRect ComputeTightBounds(DrawTarget* aDrawTarget) const;
/**
* This function is similar to GetPrefISize and ComputeTightBounds: it

View File

@ -1203,7 +1203,8 @@ nsImageFrame::DisplayAltText(nsPresContext* aPresContext,
rv = nsBidiPresUtils::RenderText(str, maxFit, dir,
aPresContext, aRenderingContext,
aRenderingContext, *fm, x, y);
aRenderingContext.GetDrawTarget(),
*fm, x, y);
}
if (NS_FAILED(rv)) {
nsLayoutUtils::DrawUniDirString(str, maxFit,

View File

@ -292,13 +292,13 @@ nsInlineFrame::ComputeSize(nsRenderingContext *aRenderingContext,
}
nsRect
nsInlineFrame::ComputeTightBounds(gfxContext* aContext) const
nsInlineFrame::ComputeTightBounds(DrawTarget* aDrawTarget) const
{
// be conservative
if (StyleContext()->HasTextDecorationLines()) {
return GetVisualOverflowRect();
}
return ComputeSimpleTightBounds(aContext);
return ComputeSimpleTightBounds(aDrawTarget);
}
void

View File

@ -80,7 +80,7 @@ public:
const mozilla::LogicalSize& aBorder,
const mozilla::LogicalSize& aPadding,
ComputeSizeFlags aFlags) override;
virtual nsRect ComputeTightBounds(gfxContext* aContext) const override;
virtual nsRect ComputeTightBounds(DrawTarget* aDrawTarget) const override;
virtual void Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,

View File

@ -943,7 +943,8 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
aFrame->Reflow(mPresContext, metrics, *reflowStateHolder, aReflowStatus);
} else {
static_cast<nsTextFrame*>(aFrame)->
ReflowText(*this, availableSpaceOnLine, psd->mReflowState->rendContext,
ReflowText(*this, availableSpaceOnLine,
psd->mReflowState->rendContext->GetDrawTarget(),
metrics, aReflowStatus);
}
@ -2592,7 +2593,7 @@ nsLineLayout::TrimTrailingWhiteSpaceIn(PerSpanData* psd,
// might have a soft hyphen which should now appear, changing the frame's
// width
nsTextFrame::TrimOutput trimOutput = static_cast<nsTextFrame*>(pfd->mFrame)->
TrimTrailingWhiteSpace(mBlockReflowState->rendContext);
TrimTrailingWhiteSpace(mBlockReflowState->rendContext->GetDrawTarget());
#ifdef NOISY_TRIM
nsFrame::ListTag(stdout, psd->mFrame->mFrame);
printf(": trim of ");

View File

@ -333,6 +333,9 @@ nsPageFrame::DrawHeaderFooter(nsRenderingContext& aRenderingContext,
nscoord contentWidth = aWidth - (mPD->mEdgePaperMargin.left + mPD->mEdgePaperMargin.right);
gfxContext* gfx = aRenderingContext.ThebesContext();
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
if ((aHeaderFooter == eHeader && aHeight < mPD->mReflowMargin.top) ||
(aHeaderFooter == eFooter && aHeight < mPD->mReflowMargin.bottom)) {
nsAutoString str;
@ -347,9 +350,10 @@ nsPageFrame::DrawHeaderFooter(nsRenderingContext& aRenderingContext,
return; // bail is empty string
}
// find how much text fits, the "position" is the size of the available area
if (nsLayoutUtils::BinarySearchForPosition(&aRenderingContext, aFontMetrics,
text, 0, 0, 0, len,
int32_t(contentWidth), indx, textWidth)) {
if (nsLayoutUtils::BinarySearchForPosition(drawTarget, aFontMetrics, text,
0, 0, 0, len,
int32_t(contentWidth), indx,
textWidth)) {
if (indx < len-1 ) {
// we can't fit in all the text
if (indx > 3) {
@ -383,14 +387,11 @@ nsPageFrame::DrawHeaderFooter(nsRenderingContext& aRenderingContext,
y = aRect.YMost() - aHeight - mPD->mEdgePaperMargin.bottom;
}
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
gfxContext* gfx = aRenderingContext.ThebesContext();
// set up new clip and draw the text
gfx->Save();
gfx->Clip(NSRectToSnappedRect(aRect, PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
aRenderingContext.ThebesContext()->SetColor(Color(0.f, 0.f, 0.f));
gfx->SetColor(Color(0.f, 0.f, 0.f));
nsLayoutUtils::DrawString(this, aFontMetrics, &aRenderingContext,
str.get(), str.Length(),
nsPoint(x, y + aAscent));

View File

@ -63,7 +63,7 @@ nsRubyBaseContainerFrame::GetFrameName(nsAString& aResult) const
static gfxBreakPriority
LineBreakBefore(nsIFrame* aFrame,
nsRenderingContext* aRenderingContext,
DrawTarget* aDrawTarget,
nsIFrame* aLineContainerFrame,
const nsLineList::iterator* aLine)
{
@ -79,8 +79,7 @@ LineBreakBefore(nsIFrame* aFrame,
auto textFrame = static_cast<nsTextFrame*>(child);
gfxSkipCharsIterator iter =
textFrame->EnsureTextRun(nsTextFrame::eInflated,
aRenderingContext->ThebesContext(),
textFrame->EnsureTextRun(nsTextFrame::eInflated, aDrawTarget,
aLineContainerFrame, aLine);
iter.SetOriginalOffset(textFrame->GetContentOffset());
uint32_t pos = iter.GetSkippedOffset();
@ -208,7 +207,8 @@ nsRubyBaseContainerFrame::AddInlineMinISize(
nsIFrame* baseFrame = enumerator.GetFrameAtLevel(0);
if (baseFrame) {
gfxBreakPriority breakPriority =
LineBreakBefore(baseFrame, aRenderingContext, nullptr, nullptr);
LineBreakBefore(baseFrame, aRenderingContext->GetDrawTarget(),
nullptr, nullptr);
if (breakPriority != gfxBreakPriority::eNoBreak) {
aData->OptionallyBreak();
}
@ -582,7 +582,7 @@ nsRubyBaseContainerFrame::ReflowOneColumn(const ReflowState& aReflowState,
aReflowState.mAllowLineBreak : aReflowState.mAllowInitialLineBreak;
if (allowBreakBefore) {
gfxBreakPriority breakPriority = LineBreakBefore(
aColumn.mBaseFrame, baseReflowState.rendContext,
aColumn.mBaseFrame, baseReflowState.rendContext->GetDrawTarget(),
baseReflowState.mLineLayout->LineContainerFrame(),
baseReflowState.mLineLayout->GetLine());
if (breakPriority != gfxBreakPriority::eNoBreak) {

View File

@ -864,10 +864,10 @@ CreateObserversForAnimatedGlyphs(gfxTextRun* aTextRun)
*/
class BuildTextRunsScanner {
public:
BuildTextRunsScanner(nsPresContext* aPresContext, gfxContext* aContext,
BuildTextRunsScanner(nsPresContext* aPresContext, DrawTarget* aDrawTarget,
nsIFrame* aLineContainer, nsTextFrame::TextRunType aWhichTextRun) :
mCurrentFramesAllSameTextRun(nullptr),
mContext(aContext),
mDrawTarget(aDrawTarget),
mLineContainer(aLineContainer),
mMissingFonts(aPresContext->MissingFontRecorder()),
mBidiEnabled(aPresContext->BidiEnabled()),
@ -967,10 +967,12 @@ public:
class BreakSink final : public nsILineBreakSink {
public:
BreakSink(gfxTextRun* aTextRun, gfxContext* aContext,
uint32_t aOffsetIntoTextRun) :
mTextRun(aTextRun), mContext(aContext),
mOffsetIntoTextRun(aOffsetIntoTextRun) {}
BreakSink(gfxTextRun* aTextRun, DrawTarget* aDrawTarget,
uint32_t aOffsetIntoTextRun)
: mTextRun(aTextRun)
, mDrawTarget(aDrawTarget)
, mOffsetIntoTextRun(aOffsetIntoTextRun)
{}
virtual void SetBreaks(uint32_t aOffset, uint32_t aLength,
uint8_t* aBreakBefore) override {
@ -1001,7 +1003,7 @@ public:
if (mTextRun->GetFlags() & nsTextFrameUtils::TEXT_IS_TRANSFORMED) {
nsTransformedTextRun* transformedTextRun =
static_cast<nsTransformedTextRun*>(mTextRun);
transformedTextRun->FinishSettingProperties(mContext, aMFR);
transformedTextRun->FinishSettingProperties(mDrawTarget, aMFR);
}
// The way nsTransformedTextRun is implemented, its glyph runs aren't
// available until after nsTransformedTextRun::FinishSettingProperties()
@ -1010,7 +1012,7 @@ public:
}
gfxTextRun* mTextRun;
gfxContext* mContext;
DrawTarget* mDrawTarget;
uint32_t mOffsetIntoTextRun;
};
@ -1021,7 +1023,7 @@ private:
nsAutoTArray<gfxTextRun*,5> mTextRunsToDelete;
nsLineBreaker mLineBreaker;
gfxTextRun* mCurrentFramesAllSameTextRun;
gfxContext* mContext;
DrawTarget* mDrawTarget;
nsIFrame* mLineContainer;
nsTextFrame* mLastFrame;
// The common ancestor of the current frame and the previous leaf frame
@ -1251,7 +1253,7 @@ BuildTextRunsScanner::FindBoundaries(nsIFrame* aFrame, FindBoundaryState* aState
* is enabled, this will be eInflated, otherwise it's eNotInflated.
*/
static void
BuildTextRuns(gfxContext* aContext, nsTextFrame* aForFrame,
BuildTextRuns(DrawTarget* aDrawTarget, nsTextFrame* aForFrame,
nsIFrame* aLineContainer,
const nsLineList::iterator* aForFrameLine,
nsTextFrame::TextRunType aWhichTextRun)
@ -1285,8 +1287,8 @@ BuildTextRuns(gfxContext* aContext, nsTextFrame* aForFrame,
}
nsPresContext* presContext = aLineContainer->PresContext();
BuildTextRunsScanner scanner(presContext, aContext, aLineContainer,
aWhichTextRun);
BuildTextRunsScanner scanner(presContext, aDrawTarget,
aLineContainer, aWhichTextRun);
nsBlockFrame* block = nsLayoutUtils::GetAsBlock(aLineContainer);
@ -1841,27 +1843,32 @@ GetFontGroupForFrame(nsIFrame* aFrame, float aFontSizeInflation,
return metrics->GetThebesFontGroup();
}
static already_AddRefed<gfxContext>
CreateReferenceThebesContext(nsTextFrame* aTextFrame)
static already_AddRefed<DrawTarget>
CreateReferenceDrawTarget(nsTextFrame* aTextFrame)
{
return aTextFrame->PresContext()->PresShell()->CreateReferenceRenderingContext();
RefPtr<gfxContext> ctx =
aTextFrame->PresContext()->PresShell()->CreateReferenceRenderingContext();
RefPtr<DrawTarget> dt = ctx->GetDrawTarget();
return dt.forget();
}
/**
* The returned textrun must be deleted when no longer needed.
*/
static gfxTextRun*
GetHyphenTextRun(gfxTextRun* aTextRun, gfxContext* aContext, nsTextFrame* aTextFrame)
GetHyphenTextRun(gfxTextRun* aTextRun, DrawTarget* aDrawTarget,
nsTextFrame* aTextFrame)
{
RefPtr<gfxContext> ctx = aContext;
if (!ctx) {
ctx = CreateReferenceThebesContext(aTextFrame);
RefPtr<DrawTarget> dt = aDrawTarget;
if (!dt) {
dt = CreateReferenceDrawTarget(aTextFrame);
if (!dt) {
return nullptr;
}
}
if (!ctx)
return nullptr;
return aTextRun->GetFontGroup()->
MakeHyphenTextRun(ctx, aTextRun->GetAppUnitsPerDevUnit());
MakeHyphenTextRun(dt, aTextRun->GetAppUnitsPerDevUnit());
}
PR_STATIC_ASSERT(NS_STYLE_WHITESPACE_NORMAL == 0);
@ -2217,7 +2224,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
gfxTextRun* textRun;
gfxTextRunFactory::Parameters params =
{ mContext, finalUserData, &skipChars,
{ mDrawTarget, finalUserData, &skipChars,
textBreakPointsAfterTransform.Elements(),
uint32_t(textBreakPointsAfterTransform.Length()),
int32_t(firstFrame->PresContext()->AppUnitsPerDevPixel())};
@ -2448,7 +2455,7 @@ BuildTextRunsScanner::SetupBreakSinksForTextRun(gfxTextRun* aTextRun,
mappedFlow->mStartFrame->GetContentOffset());
nsAutoPtr<BreakSink>* breakSink =
mBreakSinks.AppendElement(new BreakSink(aTextRun, mContext, offset));
mBreakSinks.AppendElement(new BreakSink(aTextRun, mDrawTarget, offset));
if (!breakSink || !*breakSink)
return;
@ -2694,7 +2701,7 @@ NS_QUERYFRAME_TAIL_INHERITING(nsTextFrameBase)
gfxSkipCharsIterator
nsTextFrame::EnsureTextRun(TextRunType aWhichTextRun,
gfxContext* aReferenceContext,
DrawTarget* aRefDrawTarget,
nsIFrame* aLineContainer,
const nsLineList::iterator* aLine,
uint32_t* aFlowEndInTextRun)
@ -2705,12 +2712,12 @@ nsTextFrame::EnsureTextRun(TextRunType aWhichTextRun,
gTextRuns->MarkUsed(textRun);
}
} else {
RefPtr<gfxContext> ctx = aReferenceContext;
if (!ctx) {
ctx = CreateReferenceThebesContext(this);
RefPtr<DrawTarget> refDT = aRefDrawTarget;
if (!refDT) {
refDT = CreateReferenceDrawTarget(this);
}
if (ctx) {
BuildTextRuns(ctx, this, aLineContainer, aLine, aWhichTextRun);
if (refDT) {
BuildTextRuns(refDT, this, aLineContainer, aLine, aWhichTextRun);
}
textRun = GetTextRun(aWhichTextRun);
if (!textRun) {
@ -3000,8 +3007,8 @@ public:
return mTextStyle->mHyphens;
}
virtual already_AddRefed<gfxContext> GetContext() {
return CreateReferenceThebesContext(GetFrame());
virtual already_AddRefed<DrawTarget> GetDrawTarget() {
return CreateReferenceDrawTarget(GetFrame());
}
virtual uint32_t GetAppUnitsPerDevUnit() {
@ -5122,7 +5129,7 @@ GenerateTextRunForEmphasisMarks(nsTextFrame* aFrame, nsFontMetrics* aFontMetrics
WritingMode aWM, const nsStyleText* aStyleText)
{
const nsString& emphasisString = aStyleText->mTextEmphasisStyleString;
RefPtr<gfxContext> ctx = CreateReferenceThebesContext(aFrame);
RefPtr<DrawTarget> dt = CreateReferenceDrawTarget(aFrame);
auto appUnitsPerDevUnit = aFrame->PresContext()->AppUnitsPerDevPixel();
uint32_t flags = nsLayoutUtils::
GetTextRunOrientFlagsForStyle(aFrame->StyleContext());
@ -5132,7 +5139,7 @@ GenerateTextRunForEmphasisMarks(nsTextFrame* aFrame, nsFontMetrics* aFontMetrics
}
return aFontMetrics->GetThebesFontGroup()->
MakeTextRun<char16_t>(emphasisString.get(), emphasisString.Length(),
ctx, appUnitsPerDevUnit, flags, nullptr);
dt, appUnitsPerDevUnit, flags, nullptr);
}
static nsRubyFrame*
@ -5809,17 +5816,17 @@ static void
AddHyphenToMetrics(nsTextFrame* aTextFrame, gfxTextRun* aBaseTextRun,
gfxTextRun::Metrics* aMetrics,
gfxFont::BoundingBoxType aBoundingBoxType,
gfxContext* aContext)
DrawTarget* aDrawTarget)
{
// Fix up metrics to include hyphen
nsAutoPtr<gfxTextRun> hyphenTextRun(
GetHyphenTextRun(aBaseTextRun, aContext, aTextFrame));
GetHyphenTextRun(aBaseTextRun, aDrawTarget, aTextFrame));
if (!hyphenTextRun.get())
return;
gfxTextRun::Metrics hyphenMetrics =
hyphenTextRun->MeasureText(0, hyphenTextRun->GetLength(),
aBoundingBoxType, aContext, nullptr);
hyphenTextRun->MeasureText(0, hyphenTextRun->GetLength(), aBoundingBoxType,
aDrawTarget, nullptr);
if (aTextFrame->GetWritingMode().IsLineInverted()) {
hyphenMetrics.mBoundingBox.y = -hyphenMetrics.mBoundingBox.YMost();
}
@ -6420,7 +6427,7 @@ nsTextFrame::PaintShadows(nsCSSShadowArray* aShadow,
}
if (GetStateBits() & TEXT_HYPHEN_BREAK) {
AddHyphenToMetrics(this, mTextRun, &shadowMetrics,
gfxFont::LOOSE_INK_EXTENTS, aCtx);
gfxFont::LOOSE_INK_EXTENTS, aCtx->GetDrawTarget());
}
// Add bounds of text decorations
gfxRect decorationRect(0, -shadowMetrics.mAscent,
@ -7805,10 +7812,9 @@ nsTextFrame::AddInlineMinISizeForFlow(nsRenderingContext *aRenderingContext,
TextRunType aTextRunType)
{
uint32_t flowEndInTextRun;
gfxContext* ctx = aRenderingContext->ThebesContext();
gfxSkipCharsIterator iter =
EnsureTextRun(aTextRunType, ctx, aData->LineContainer(),
aData->line, &flowEndInTextRun);
EnsureTextRun(aTextRunType, aRenderingContext->GetDrawTarget(),
aData->LineContainer(), aData->line, &flowEndInTextRun);
gfxTextRun *textRun = GetTextRun(aTextRunType);
if (!textRun)
return;
@ -7982,10 +7988,9 @@ nsTextFrame::AddInlinePrefISizeForFlow(nsRenderingContext *aRenderingContext,
TextRunType aTextRunType)
{
uint32_t flowEndInTextRun;
gfxContext* ctx = aRenderingContext->ThebesContext();
gfxSkipCharsIterator iter =
EnsureTextRun(aTextRunType, ctx, aData->LineContainer(),
aData->line, &flowEndInTextRun);
EnsureTextRun(aTextRunType, aRenderingContext->GetDrawTarget(),
aData->LineContainer(), aData->line, &flowEndInTextRun);
gfxTextRun *textRun = GetTextRun(aTextRunType);
if (!textRun)
return;
@ -8144,7 +8149,7 @@ RoundOut(const gfxRect& aRect)
}
nsRect
nsTextFrame::ComputeTightBounds(gfxContext* aContext) const
nsTextFrame::ComputeTightBounds(DrawTarget* aDrawTarget) const
{
if (StyleContext()->HasTextDecorationLines() ||
(GetStateBits() & TEXT_HYPHEN_BREAK)) {
@ -8166,7 +8171,7 @@ nsTextFrame::ComputeTightBounds(gfxContext* aContext) const
mTextRun->MeasureText(provider.GetStart().GetSkippedOffset(),
ComputeTransformedLength(provider),
gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS,
aContext, &provider);
aDrawTarget, &provider);
if (GetWritingMode().IsLineInverted()) {
metrics.mBoundingBox.y = -metrics.mBoundingBox.YMost();
}
@ -8200,7 +8205,7 @@ nsTextFrame::GetPrefWidthTightBounds(nsRenderingContext* aContext,
mTextRun->MeasureText(provider.GetStart().GetSkippedOffset(),
ComputeTransformedLength(provider),
gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS,
aContext->ThebesContext(), &provider);
aContext->GetDrawTarget(), &provider);
// Round it like nsTextFrame::ComputeTightBounds() to ensure consistency.
*aX = NSToCoordFloor(metrics.mBoundingBox.x);
*aXMost = NSToCoordCeil(metrics.mBoundingBox.XMost());
@ -8447,7 +8452,7 @@ nsTextFrame::Reflow(nsPresContext* aPresContext,
}
ReflowText(*aReflowState.mLineLayout, aReflowState.AvailableWidth(),
aReflowState.rendContext, aMetrics, aStatus);
aReflowState.rendContext->GetDrawTarget(), aMetrics, aStatus);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
}
@ -8482,7 +8487,7 @@ private:
void
nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
nsRenderingContext* aRenderingContext,
DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aMetrics,
nsReflowStatus& aStatus)
{
@ -8533,7 +8538,6 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
uint32_t flowEndInTextRun;
nsIFrame* lineContainer = aLineLayout.LineContainerFrame();
gfxContext* ctx = aRenderingContext->ThebesContext();
const nsTextFragment* frag = mContent->GetText();
// DOM offsets of the text range we need to measure, after trimming
@ -8603,7 +8607,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
// Find the length of the first-letter. We need a textrun for this.
// REVIEW: maybe-bogus inflation should be ok (fixed below)
gfxSkipCharsIterator iter =
EnsureTextRun(nsTextFrame::eInflated, ctx,
EnsureTextRun(nsTextFrame::eInflated, aDrawTarget,
lineContainer, aLineLayout.GetLine(),
&flowEndInTextRun);
@ -8655,7 +8659,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
}
gfxSkipCharsIterator iter =
EnsureTextRun(nsTextFrame::eInflated, ctx,
EnsureTextRun(nsTextFrame::eInflated, aDrawTarget,
lineContainer, aLineLayout.GetLine(), &flowEndInTextRun);
NS_ASSERTION(IsCurrentFontInflation(fontSizeInflation),
@ -8667,7 +8671,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
// preformatted newline was encountered, and prev-in-flow frames have
// consumed all the text of the textrun. We need a new textrun.
ClearTextRuns();
iter = EnsureTextRun(nsTextFrame::eInflated, ctx,
iter = EnsureTextRun(nsTextFrame::eInflated, aDrawTarget,
lineContainer, aLineLayout.GetLine(),
&flowEndInTextRun);
}
@ -8751,7 +8755,8 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
availWidth,
&provider, suppressBreak,
canTrimTrailingWhitespace ? &trimmedWidth : nullptr,
&textMetrics, boundingBoxType, ctx,
&textMetrics, boundingBoxType,
aDrawTarget,
&usedHyphenation, &transformedLastBreak,
textStyle->WordCanWrap(this), &breakPriority);
if (!length && !textMetrics.mAscent && !textMetrics.mDescent) {
@ -8801,7 +8806,8 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
}
if (usedHyphenation) {
// Fix up metrics to include hyphen
AddHyphenToMetrics(this, mTextRun, &textMetrics, boundingBoxType, ctx);
AddHyphenToMetrics(this, mTextRun, &textMetrics, boundingBoxType,
aDrawTarget);
AddStateBits(TEXT_HYPHEN_BREAK | TEXT_HAS_NONCOLLAPSED_CHARACTERS);
}
if (textMetrics.mBoundingBox.IsEmpty()) {
@ -9040,7 +9046,7 @@ nsTextFrame::CanContinueTextRun() const
}
nsTextFrame::TrimOutput
nsTextFrame::TrimTrailingWhiteSpace(nsRenderingContext* aRC)
nsTextFrame::TrimTrailingWhiteSpace(DrawTarget* aDrawTarget)
{
TrimOutput result;
result.mChanged = false;
@ -9052,9 +9058,8 @@ nsTextFrame::TrimTrailingWhiteSpace(nsRenderingContext* aRC)
if (!contentLength)
return result;
gfxContext* ctx = aRC->ThebesContext();
gfxSkipCharsIterator start =
EnsureTextRun(nsTextFrame::eInflated, ctx);
EnsureTextRun(nsTextFrame::eInflated, aDrawTarget);
NS_ENSURE_TRUE(mTextRun, result);
uint32_t trimmedStart = start.GetSkippedOffset();
@ -9083,7 +9088,7 @@ nsTextFrame::TrimTrailingWhiteSpace(nsRenderingContext* aRC)
gfxFloat advanceDelta;
mTextRun->SetLineBreaks(trimmedStart, trimmedEnd - trimmedStart,
(GetStateBits() & TEXT_START_OF_LINE) != 0, true,
&advanceDelta, ctx);
&advanceDelta);
if (advanceDelta != 0) {
result.mChanged = true;
}

View File

@ -243,7 +243,7 @@ public:
const mozilla::LogicalSize& aBorder,
const mozilla::LogicalSize& aPadding,
ComputeSizeFlags aFlags) override;
virtual nsRect ComputeTightBounds(gfxContext* aContext) const override;
virtual nsRect ComputeTightBounds(DrawTarget* aDrawTarget) const override;
virtual nsresult GetPrefWidthTightBounds(nsRenderingContext* aContext,
nscoord* aX,
nscoord* aXMost) override;
@ -262,7 +262,7 @@ public:
// an amount to *subtract* from the frame's width (zero if !mChanged)
nscoord mDeltaWidth;
};
TrimOutput TrimTrailingWhiteSpace(nsRenderingContext* aRC);
TrimOutput TrimTrailingWhiteSpace(DrawTarget* aDrawTarget);
virtual RenderedText GetRenderedText(uint32_t aStartOffset = 0,
uint32_t aEndOffset = UINT32_MAX,
TextOffsetType aOffsetType =
@ -475,9 +475,8 @@ public:
* Acquires the text run for this content, if necessary.
* @param aWhichTextRun indicates whether to get an inflated or non-inflated
* text run
* @param aReferenceContext the rendering context to use as a reference for
* creating the textrun, if available (if not, we'll create one which will
* just be slower)
* @param aRefDrawTarget the DrawTarget to use as a reference for creating the
* textrun, if available (if not, we'll create one which will just be slower)
* @param aLineContainer the block ancestor for this frame, or nullptr if
* unknown
* @param aFlowEndInTextRun if non-null, this returns the textrun offset of
@ -487,7 +486,7 @@ public:
* content offset
*/
gfxSkipCharsIterator EnsureTextRun(TextRunType aWhichTextRun,
gfxContext* aReferenceContext = nullptr,
DrawTarget* aRefDrawTarget = nullptr,
nsIFrame* aLineContainer = nullptr,
const nsLineList::iterator* aLine = nullptr,
uint32_t* aFlowEndInTextRun = nullptr);
@ -546,7 +545,7 @@ public:
// Similar to Reflow(), but for use from nsLineLayout
void ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
nsRenderingContext* aRenderingContext,
DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aMetrics, nsReflowStatus& aStatus);
bool IsFloatingFirstLetterChild() const;

View File

@ -213,10 +213,10 @@ MergeCharactersInTextRun(gfxTextRun* aDest, gfxTextRun* aSrc,
gfxTextRunFactory::Parameters
GetParametersForInner(nsTransformedTextRun* aTextRun, uint32_t* aFlags,
gfxContext* aRefContext)
DrawTarget* aRefDrawTarget)
{
gfxTextRunFactory::Parameters params =
{ aRefContext, nullptr, nullptr,
{ aRefDrawTarget, nullptr, nullptr,
nullptr, 0, aTextRun->GetAppUnitsPerDevUnit()
};
*aFlags = aTextRun->GetFlags() & ~gfxFontGroup::TEXT_IS_PERSISTENT;
@ -601,7 +601,8 @@ nsCaseTransformTextRunFactory::TransformString(
void
nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
gfxContext* aRefContext, gfxMissingFontRecorder *aMFR)
DrawTarget* aRefDrawTarget,
gfxMissingFontRecorder* aMFR)
{
nsAutoString convertedString;
nsAutoTArray<bool,50> charsToMergeArray;
@ -621,7 +622,7 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
uint32_t flags;
gfxTextRunFactory::Parameters innerParams =
GetParametersForInner(aTextRun, &flags, aRefContext);
GetParametersForInner(aTextRun, &flags, aRefDrawTarget);
gfxFontGroup* fontGroup = aTextRun->GetFontGroup();
nsAutoPtr<nsTransformedTextRun> transformedChild;
@ -648,7 +649,7 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(),
canBreakBeforeArray.Elements());
if (transformedChild) {
transformedChild->FinishSettingProperties(aRefContext, aMFR);
transformedChild->FinishSettingProperties(aRefDrawTarget, aMFR);
}
if (mergeNeeded) {

View File

@ -56,7 +56,7 @@ public:
bool aOwnsFactory);
virtual void RebuildTextRun(nsTransformedTextRun* aTextRun,
gfxContext* aRefContext,
mozilla::gfx::DrawTarget* aRefDrawTarget,
gfxMissingFontRecorder* aMFR) = 0;
};
@ -79,7 +79,7 @@ public:
mAllUppercase(aAllUppercase) {}
virtual void RebuildTextRun(nsTransformedTextRun* aTextRun,
gfxContext* aRefContext,
mozilla::gfx::DrawTarget* aRefDrawTarget,
gfxMissingFontRecorder* aMFR) override;
// Perform a transformation on the given string, writing the result into
@ -137,12 +137,12 @@ public:
* are done and before we request any data from the textrun. Also always
* called after a Create.
*/
void FinishSettingProperties(gfxContext* aRefContext,
void FinishSettingProperties(mozilla::gfx::DrawTarget* aRefDrawTarget,
gfxMissingFontRecorder* aMFR)
{
if (mNeedsRebuild) {
mNeedsRebuild = false;
mFactory->RebuildTextRun(this, aRefContext, aMFR);
mFactory->RebuildTextRun(this, aRefDrawTarget, aMFR);
}
}
@ -209,7 +209,7 @@ MergeCharactersInTextRun(gfxTextRun* aDest, gfxTextRun* aSrc,
gfxTextRunFactory::Parameters
GetParametersForInner(nsTransformedTextRun* aTextRun, uint32_t* aFlags,
gfxContext* aRefContext);
mozilla::gfx::DrawTarget* aRefDrawTarget);
#endif /*NSTEXTRUNTRANSFORMATIONS_H_*/

View File

@ -81,7 +81,7 @@ public:
* of the frame, on output the size after stretching.
*/
NS_IMETHOD
Stretch(nsRenderingContext& aRenderingContext,
Stretch(mozilla::gfx::DrawTarget* aDrawTarget,
nsStretchDirection aStretchDirection,
nsBoundingMetrics& aContainerSize,
nsHTMLReflowMetrics& aDesiredStretchSize) = 0;

View File

@ -87,13 +87,13 @@ public:
FontNameFor(const nsGlyphCode& aGlyphCode) const = 0;
// Getters for the parts
virtual nsGlyphCode ElementAt(gfxContext* aThebesContext,
virtual nsGlyphCode ElementAt(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar,
bool aVertical,
uint32_t aPosition) = 0;
virtual nsGlyphCode BigOf(gfxContext* aThebesContext,
virtual nsGlyphCode BigOf(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar,
@ -101,13 +101,13 @@ public:
uint32_t aSize) = 0;
// True if this table contains parts to render this char
virtual bool HasPartsOf(gfxContext* aThebesContext,
virtual bool HasPartsOf(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar,
bool aVertical) = 0;
virtual gfxTextRun* MakeTextRun(gfxContext* aThebesContext,
virtual gfxTextRun* MakeTextRun(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
const nsGlyphCode& aGlyph) = 0;
@ -194,41 +194,41 @@ public:
return mGlyphCodeFonts[aGlyphCode.font];
}
virtual nsGlyphCode ElementAt(gfxContext* aThebesContext,
virtual nsGlyphCode ElementAt(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar,
bool aVertical,
uint32_t aPosition) override;
virtual nsGlyphCode BigOf(gfxContext* aThebesContext,
virtual nsGlyphCode BigOf(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar,
bool aVertical,
uint32_t aSize) override
{
return ElementAt(aThebesContext, aAppUnitsPerDevPixel, aFontGroup,
return ElementAt(aDrawTarget, aAppUnitsPerDevPixel, aFontGroup,
aChar, aVertical, 4 + aSize);
}
virtual bool HasPartsOf(gfxContext* aThebesContext,
virtual bool HasPartsOf(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar,
bool aVertical) override
{
return (ElementAt(aThebesContext, aAppUnitsPerDevPixel, aFontGroup,
return (ElementAt(aDrawTarget, aAppUnitsPerDevPixel, aFontGroup,
aChar, aVertical, 0).Exists() ||
ElementAt(aThebesContext, aAppUnitsPerDevPixel, aFontGroup,
ElementAt(aDrawTarget, aAppUnitsPerDevPixel, aFontGroup,
aChar, aVertical, 1).Exists() ||
ElementAt(aThebesContext, aAppUnitsPerDevPixel, aFontGroup,
ElementAt(aDrawTarget, aAppUnitsPerDevPixel, aFontGroup,
aChar, aVertical, 2).Exists() ||
ElementAt(aThebesContext, aAppUnitsPerDevPixel, aFontGroup,
ElementAt(aDrawTarget, aAppUnitsPerDevPixel, aFontGroup,
aChar, aVertical, 3).Exists());
}
virtual gfxTextRun* MakeTextRun(gfxContext* aThebesContext,
virtual gfxTextRun* MakeTextRun(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
const nsGlyphCode& aGlyph) override;
@ -268,7 +268,7 @@ private:
/* virtual */
nsGlyphCode
nsPropertiesTable::ElementAt(gfxContext* /* aThebesContext */,
nsPropertiesTable::ElementAt(DrawTarget* /* aDrawTarget */,
int32_t /* aAppUnitsPerDevPixel */,
gfxFontGroup* /* aFontGroup */,
char16_t aChar,
@ -381,7 +381,7 @@ nsPropertiesTable::ElementAt(gfxContext* /* aThebesContext */,
/* virtual */
gfxTextRun*
nsPropertiesTable::MakeTextRun(gfxContext* aThebesContext,
nsPropertiesTable::MakeTextRun(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
const nsGlyphCode& aGlyph)
@ -389,7 +389,7 @@ nsPropertiesTable::MakeTextRun(gfxContext* aThebesContext,
NS_ASSERTION(!aGlyph.IsGlyphID(),
"nsPropertiesTable can only access glyphs by code point");
return aFontGroup->
MakeTextRun(aGlyph.code, aGlyph.Length(), aThebesContext,
MakeTextRun(aGlyph.code, aGlyph.Length(), aDrawTarget,
aAppUnitsPerDevPixel, 0, nullptr);
}
@ -404,19 +404,19 @@ public:
MOZ_COUNT_DTOR(nsOpenTypeTable);
}
virtual nsGlyphCode ElementAt(gfxContext* aThebesContext,
virtual nsGlyphCode ElementAt(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar,
bool aVertical,
uint32_t aPosition) override;
virtual nsGlyphCode BigOf(gfxContext* aThebesContext,
virtual nsGlyphCode BigOf(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar,
bool aVertical,
uint32_t aSize) override;
virtual bool HasPartsOf(gfxContext* aThebesContext,
virtual bool HasPartsOf(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar,
@ -429,7 +429,7 @@ public:
return mFontFamilyName;
}
virtual gfxTextRun* MakeTextRun(gfxContext* aThebesContext,
virtual gfxTextRun* MakeTextRun(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
const nsGlyphCode& aGlyph) override;
@ -456,14 +456,14 @@ private:
MOZ_COUNT_CTOR(nsOpenTypeTable);
}
void UpdateCache(gfxContext* aThebesContext,
void UpdateCache(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar);
};
void
nsOpenTypeTable::UpdateCache(gfxContext* aThebesContext,
nsOpenTypeTable::UpdateCache(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar)
@ -471,7 +471,7 @@ nsOpenTypeTable::UpdateCache(gfxContext* aThebesContext,
if (mCharCache != aChar) {
nsAutoPtr<gfxTextRun> textRun;
textRun = aFontGroup->
MakeTextRun(&aChar, 1, aThebesContext, aAppUnitsPerDevPixel, 0, nullptr);
MakeTextRun(&aChar, 1, aDrawTarget, aAppUnitsPerDevPixel, 0, nullptr);
const gfxTextRun::CompressedGlyph& data = textRun->GetCharacterGlyphs()[0];
if (data.IsSimpleGlyph()) {
mGlyphID = data.GetSimpleGlyph();
@ -486,14 +486,14 @@ nsOpenTypeTable::UpdateCache(gfxContext* aThebesContext,
/* virtual */
nsGlyphCode
nsOpenTypeTable::ElementAt(gfxContext* aThebesContext,
nsOpenTypeTable::ElementAt(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar,
bool aVertical,
uint32_t aPosition)
{
UpdateCache(aThebesContext, aAppUnitsPerDevPixel, aFontGroup, aChar);
UpdateCache(aDrawTarget, aAppUnitsPerDevPixel, aFontGroup, aChar);
uint32_t parts[4];
if (!mFontEntry->GetMathVariantsParts(mGlyphID, aVertical, parts)) {
@ -512,14 +512,14 @@ nsOpenTypeTable::ElementAt(gfxContext* aThebesContext,
/* virtual */
nsGlyphCode
nsOpenTypeTable::BigOf(gfxContext* aThebesContext,
nsOpenTypeTable::BigOf(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar,
bool aVertical,
uint32_t aSize)
{
UpdateCache(aThebesContext, aAppUnitsPerDevPixel, aFontGroup, aChar);
UpdateCache(aDrawTarget, aAppUnitsPerDevPixel, aFontGroup, aChar);
uint32_t glyphID =
mFontEntry->GetMathVariantsSize(mGlyphID, aVertical, aSize);
@ -535,13 +535,13 @@ nsOpenTypeTable::BigOf(gfxContext* aThebesContext,
/* virtual */
bool
nsOpenTypeTable::HasPartsOf(gfxContext* aThebesContext,
nsOpenTypeTable::HasPartsOf(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
char16_t aChar,
bool aVertical)
{
UpdateCache(aThebesContext, aAppUnitsPerDevPixel, aFontGroup, aChar);
UpdateCache(aDrawTarget, aAppUnitsPerDevPixel, aFontGroup, aChar);
uint32_t parts[4];
if (!mFontEntry->GetMathVariantsParts(mGlyphID, aVertical, parts)) {
@ -553,7 +553,7 @@ nsOpenTypeTable::HasPartsOf(gfxContext* aThebesContext,
/* virtual */
gfxTextRun*
nsOpenTypeTable::MakeTextRun(gfxContext* aThebesContext,
nsOpenTypeTable::MakeTextRun(DrawTarget* aDrawTarget,
int32_t aAppUnitsPerDevPixel,
gfxFontGroup* aFontGroup,
const nsGlyphCode& aGlyph)
@ -562,7 +562,7 @@ nsOpenTypeTable::MakeTextRun(gfxContext* aThebesContext,
"nsOpenTypeTable can only access glyphs by id");
gfxTextRunFactory::Parameters params = {
aThebesContext, nullptr, nullptr, nullptr, 0, aAppUnitsPerDevPixel
aDrawTarget, nullptr, nullptr, nullptr, 0, aAppUnitsPerDevPixel
};
gfxTextRun* textRun = gfxTextRun::Create(&params, 1, aFontGroup, 0);
textRun->AddGlyphRun(aFontGroup->GetFirstValidFont(),
@ -575,7 +575,7 @@ nsOpenTypeTable::MakeTextRun(gfxContext* aThebesContext,
detailedGlyph.mAdvance =
NSToCoordRound(aAppUnitsPerDevPixel *
aFontGroup->GetFirstValidFont()->
GetGlyphHAdvance(aThebesContext, aGlyph.glyphID));
GetGlyphHAdvance(aDrawTarget, aGlyph.glyphID));
detailedGlyph.mXOffset = detailedGlyph.mYOffset = 0;
gfxShapedText::CompressedGlyph g;
g.SetComplex(true, true, 1);
@ -1020,12 +1020,12 @@ nsMathMLChar::SetFontFamily(nsPresContext* aPresContext,
}
static nsBoundingMetrics
MeasureTextRun(gfxContext* aThebesContext, gfxTextRun* aTextRun)
MeasureTextRun(DrawTarget* aDrawTarget, gfxTextRun* aTextRun)
{
gfxTextRun::Metrics metrics =
aTextRun->MeasureText(0, aTextRun->GetLength(),
gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS,
aThebesContext, nullptr);
aDrawTarget, nullptr);
nsBoundingMetrics bm;
bm.leftBearing = NSToCoordFloor(metrics.mBoundingBox.X());
@ -1041,7 +1041,7 @@ class nsMathMLChar::StretchEnumContext {
public:
StretchEnumContext(nsMathMLChar* aChar,
nsPresContext* aPresContext,
gfxContext* aThebesContext,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
nsStretchDirection aStretchDirection,
nscoord aTargetSize,
@ -1051,7 +1051,7 @@ public:
bool& aGlyphFound)
: mChar(aChar),
mPresContext(aPresContext),
mThebesContext(aThebesContext),
mDrawTarget(aDrawTarget),
mFontSizeInflation(aFontSizeInflation),
mDirection(aStretchDirection),
mTargetSize(aTargetSize),
@ -1075,7 +1075,7 @@ private:
nsMathMLChar* mChar;
nsPresContext* mPresContext;
gfxContext* mThebesContext;
DrawTarget* mDrawTarget;
float mFontSizeInflation;
const nsStretchDirection mDirection;
const nscoord mTargetSize;
@ -1127,7 +1127,7 @@ StretchEnumContext::TryVariants(nsGlyphTable* aGlyphTable,
nscoord displayOperatorMinHeight = 0;
if (largeopOnly) {
NS_ASSERTION(isVertical, "Stretching should be in the vertical direction");
ch = aGlyphTable->BigOf(mThebesContext, oneDevPixel, *aFontGroup, uchar,
ch = aGlyphTable->BigOf(mDrawTarget, oneDevPixel, *aFontGroup, uchar,
isVertical, 0);
if (ch.IsGlyphID()) {
gfxFont* mathFont = aFontGroup->get()->GetFirstMathFont();
@ -1139,9 +1139,9 @@ StretchEnumContext::TryVariants(nsGlyphTable* aGlyphTable,
mathFont->GetMathConstant(gfxFontEntry::DisplayOperatorMinHeight,
oneDevPixel);
nsAutoPtr<gfxTextRun> textRun;
textRun = aGlyphTable->MakeTextRun(mThebesContext, oneDevPixel,
textRun = aGlyphTable->MakeTextRun(mDrawTarget, oneDevPixel,
*aFontGroup, ch);
nsBoundingMetrics bm = MeasureTextRun(mThebesContext, textRun);
nsBoundingMetrics bm = MeasureTextRun(mDrawTarget, textRun);
float largeopFactor = kLargeOpFactor;
if (NS_STRETCH_INTEGRAL & mStretchHint) {
// integrals are drawn taller
@ -1158,7 +1158,7 @@ StretchEnumContext::TryVariants(nsGlyphTable* aGlyphTable,
printf(" searching in %s ...\n",
NS_LossyConvertUTF16toASCII(aFamily).get());
#endif
while ((ch = aGlyphTable->BigOf(mThebesContext, oneDevPixel, *aFontGroup,
while ((ch = aGlyphTable->BigOf(mDrawTarget, oneDevPixel, *aFontGroup,
uchar, isVertical, size)).Exists()) {
if (!mChar->SetFontFamily(mPresContext, aGlyphTable, ch, aFamilyList, font,
@ -1170,9 +1170,9 @@ StretchEnumContext::TryVariants(nsGlyphTable* aGlyphTable,
}
nsAutoPtr<gfxTextRun> textRun;
textRun = aGlyphTable->MakeTextRun(mThebesContext, oneDevPixel,
textRun = aGlyphTable->MakeTextRun(mDrawTarget, oneDevPixel,
*aFontGroup, ch);
nsBoundingMetrics bm = MeasureTextRun(mThebesContext, textRun);
nsBoundingMetrics bm = MeasureTextRun(mDrawTarget, textRun);
if (ch.IsGlyphID()) {
gfxFont* mathFont = aFontGroup->get()->GetFirstMathFont();
if (mathFont) {
@ -1267,12 +1267,12 @@ nsMathMLChar::StretchEnumContext::TryParts(nsGlyphTable* aGlyphTable,
nscoord oneDevPixel = mPresContext->AppUnitsPerDevPixel();
char16_t uchar = mChar->mData[0];
bool maxWidth = (NS_STRETCH_MAXWIDTH & mStretchHint) != 0;
if (!aGlyphTable->HasPartsOf(mThebesContext, oneDevPixel, *aFontGroup,
if (!aGlyphTable->HasPartsOf(mDrawTarget, oneDevPixel, *aFontGroup,
uchar, isVertical))
return false; // to next table
for (int32_t i = 0; i < 4; i++) {
nsGlyphCode ch = aGlyphTable->ElementAt(mThebesContext, oneDevPixel,
nsGlyphCode ch = aGlyphTable->ElementAt(mDrawTarget, oneDevPixel,
*aFontGroup, uchar, isVertical, i);
chdata[i] = ch;
if (ch.Exists()) {
@ -1280,9 +1280,9 @@ nsMathMLChar::StretchEnumContext::TryParts(nsGlyphTable* aGlyphTable,
aFontGroup))
return false;
textRun[i] = aGlyphTable->MakeTextRun(mThebesContext, oneDevPixel,
textRun[i] = aGlyphTable->MakeTextRun(mDrawTarget, oneDevPixel,
*aFontGroup, ch);
nsBoundingMetrics bm = MeasureTextRun(mThebesContext, textRun[i]);
nsBoundingMetrics bm = MeasureTextRun(mDrawTarget, textRun[i]);
bmdata[i] = bm;
sizedata[i] = isVertical ? bm.ascent + bm.descent
: bm.rightBearing - bm.leftBearing;
@ -1514,7 +1514,7 @@ InsertMathFallbacks(FontFamilyList& aFamilyList,
nsresult
nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
gfxContext* aThebesContext,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
nsStretchDirection& aStretchDirection,
const nsBoundingMetrics& aContainerSize,
@ -1549,10 +1549,10 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
uint32_t len = uint32_t(mData.Length());
nsAutoPtr<gfxTextRun> textRun;
textRun = fm->GetThebesFontGroup()->
MakeTextRun(static_cast<const char16_t*>(mData.get()), len, aThebesContext,
MakeTextRun(static_cast<const char16_t*>(mData.get()), len, aDrawTarget,
aPresContext->AppUnitsPerDevPixel(), 0,
aPresContext->MissingFontRecorder());
aDesiredStretchSize = MeasureTextRun(aThebesContext, textRun);
aDesiredStretchSize = MeasureTextRun(aDrawTarget, textRun);
mGlyphs[0] = textRun;
bool maxWidth = (NS_STRETCH_MAXWIDTH & aStretchHint) != 0;
@ -1668,7 +1668,7 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
printf("Searching in "%s" for a glyph of appropriate size for: 0x%04X:%c\n",
NS_ConvertUTF16toUTF8(fontlistStr).get(), mData[0], mData[0]&0x00FF);
#endif
StretchEnumContext enumData(this, aPresContext, aThebesContext,
StretchEnumContext enumData(this, aPresContext, aDrawTarget,
aFontSizeInflation,
aStretchDirection, targetSize, aStretchHint,
aDesiredStretchSize, font.fontlist, glyphFound);
@ -1781,7 +1781,7 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
nsresult
nsMathMLChar::Stretch(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
nsStretchDirection aStretchDirection,
const nsBoundingMetrics& aContainerSize,
@ -1799,8 +1799,7 @@ nsMathMLChar::Stretch(nsPresContext* aPresContext,
mScaleY = mScaleX = 1.0;
mDirection = aStretchDirection;
nsresult rv =
StretchInternal(aPresContext, aRenderingContext.ThebesContext(),
aFontSizeInflation, mDirection,
StretchInternal(aPresContext, aDrawTarget, aFontSizeInflation, mDirection,
aContainerSize, aDesiredStretchSize, aStretchHint);
// Record the metrics
@ -1822,17 +1821,14 @@ nsMathMLChar::Stretch(nsPresContext* aPresContext,
// minimum size, so that only widths of smaller subsequent characters are
// considered.
nscoord
nsMathMLChar::GetMaxWidth(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
float aFontSizeInflation,
uint32_t aStretchHint)
nsMathMLChar::GetMaxWidth(nsPresContext* aPresContext, DrawTarget* aDrawTarget,
float aFontSizeInflation, uint32_t aStretchHint)
{
nsBoundingMetrics bm;
nsStretchDirection direction = NS_STRETCH_DIRECTION_VERTICAL;
const nsBoundingMetrics container; // zero target size
StretchInternal(aPresContext, aRenderingContext.ThebesContext(),
aFontSizeInflation, direction,
StretchInternal(aPresContext, aDrawTarget, aFontSizeInflation, direction,
container, bm, aStretchHint | NS_STRETCH_MAXWIDTH);
return std::max(bm.width, bm.rightBearing) - std::min(0, bm.leftBearing);

View File

@ -85,6 +85,8 @@ struct nsGlyphCode {
class nsMathMLChar
{
public:
typedef mozilla::gfx::DrawTarget DrawTarget;
// constructor and destructor
nsMathMLChar() {
MOZ_COUNT_CTOR(nsMathMLChar);
@ -114,7 +116,7 @@ public:
// @param aDesiredStretchSize - OUT - the size that the char wants
nsresult
Stretch(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
nsStretchDirection aStretchDirection,
const nsBoundingMetrics& aContainerSize,
@ -164,7 +166,7 @@ public:
// It is used to determine whether the operator is stretchy or a largeop.
nscoord
GetMaxWidth(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
uint32_t aStretchHint = NS_STRETCH_NORMAL);
@ -238,7 +240,7 @@ private:
nsresult
StretchInternal(nsPresContext* aPresContext,
gfxContext* aThebesContext,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
nsStretchDirection& aStretchDirection,
const nsBoundingMetrics& aContainerSize,

View File

@ -40,7 +40,7 @@ NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
// error handlers
// provide a feedback to the user when a frame with bad markup can not be rendered
nsresult
nsMathMLContainerFrame::ReflowError(nsRenderingContext& aRenderingContext,
nsMathMLContainerFrame::ReflowError(DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aDesiredSize)
{
// clear all other flags and record that there is an error with this frame
@ -58,7 +58,7 @@ nsMathMLContainerFrame::ReflowError(nsRenderingContext& aRenderingContext,
nsAutoString errorMsg; errorMsg.AssignLiteral("invalid-markup");
mBoundingMetrics =
nsLayoutUtils::AppUnitBoundsOfString(errorMsg.get(), errorMsg.Length(),
*fm, aRenderingContext);
*fm, aDrawTarget);
// reflow metrics
WritingMode wm = aDesiredSize.GetWritingMode();
@ -188,7 +188,7 @@ nsMathMLContainerFrame::ClearSavedChildMetrics()
// helper to get the preferred size that a container frame should use to fire
// the stretch on its stretchy child frames.
void
nsMathMLContainerFrame::GetPreferredStretchSize(nsRenderingContext& aRenderingContext,
nsMathMLContainerFrame::GetPreferredStretchSize(DrawTarget* aDrawTarget,
uint32_t aOptions,
nsStretchDirection aStretchDirection,
nsBoundingMetrics& aPreferredStretchSize)
@ -200,7 +200,7 @@ nsMathMLContainerFrame::GetPreferredStretchSize(nsRenderingContext& aRenderingCo
else if (aOptions & STRETCH_CONSIDER_EMBELLISHMENTS) {
// compute our up-to-date size using Place()
nsHTMLReflowMetrics metrics(GetWritingMode()); // ???
Place(aRenderingContext, false, metrics);
Place(aDrawTarget, false, metrics);
aPreferredStretchSize = metrics.mBoundingMetrics;
}
else {
@ -289,7 +289,7 @@ nsMathMLContainerFrame::GetPreferredStretchSize(nsRenderingContext& aRenderingCo
}
NS_IMETHODIMP
nsMathMLContainerFrame::Stretch(nsRenderingContext& aRenderingContext,
nsMathMLContainerFrame::Stretch(DrawTarget* aDrawTarget,
nsStretchDirection aStretchDirection,
nsBoundingMetrics& aContainerSize,
nsHTMLReflowMetrics& aDesiredStretchSize)
@ -339,7 +339,7 @@ nsMathMLContainerFrame::Stretch(nsRenderingContext& aRenderingContext,
if (mEmbellishData.direction == NS_STRETCH_DIRECTION_VERTICAL ?
NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY(mPresentationData.flags) :
NS_MATHML_WILL_STRETCH_ALL_CHILDREN_HORIZONTALLY(mPresentationData.flags)) {
GetPreferredStretchSize(aRenderingContext, 0,
GetPreferredStretchSize(aDrawTarget, 0,
mEmbellishData.direction, containerSize);
// Stop further recalculations
aStretchDirection = mEmbellishData.direction;
@ -350,7 +350,7 @@ nsMathMLContainerFrame::Stretch(nsRenderingContext& aRenderingContext,
}
// do the stretching...
mathMLFrame->Stretch(aRenderingContext,
mathMLFrame->Stretch(aDrawTarget,
aStretchDirection, containerSize, childSize);
// store the updated metrics
SaveReflowAndBoundingMetricsFor(baseFrame, childSize,
@ -367,7 +367,7 @@ nsMathMLContainerFrame::Stretch(nsRenderingContext& aRenderingContext,
NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY(mPresentationData.flags) ?
NS_STRETCH_DIRECTION_VERTICAL : NS_STRETCH_DIRECTION_HORIZONTAL;
GetPreferredStretchSize(aRenderingContext, STRETCH_CONSIDER_EMBELLISHMENTS,
GetPreferredStretchSize(aDrawTarget, STRETCH_CONSIDER_EMBELLISHMENTS,
stretchDir, containerSize);
nsIFrame* childFrame = mFrames.FirstChild();
@ -379,7 +379,7 @@ nsMathMLContainerFrame::Stretch(nsRenderingContext& aRenderingContext,
GetReflowAndBoundingMetricsFor(childFrame,
childSize, childSize.mBoundingMetrics);
// do the stretching...
mathMLFrame->Stretch(aRenderingContext, stretchDir,
mathMLFrame->Stretch(aDrawTarget, stretchDir,
containerSize, childSize);
// store the updated metrics
SaveReflowAndBoundingMetricsFor(childFrame, childSize,
@ -391,7 +391,7 @@ nsMathMLContainerFrame::Stretch(nsRenderingContext& aRenderingContext,
}
// re-position all our children
nsresult rv = Place(aRenderingContext, true, aDesiredStretchSize);
nsresult rv = Place(aDrawTarget, true, aDesiredStretchSize);
if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) {
// Make sure the child frames get their DidReflow() calls.
DidReflowChildren(mFrames.FirstChild());
@ -445,7 +445,7 @@ nsMathMLContainerFrame::Stretch(nsRenderingContext& aRenderingContext,
}
nsresult
nsMathMLContainerFrame::FinalizeReflow(nsRenderingContext& aRenderingContext,
nsMathMLContainerFrame::FinalizeReflow(DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aDesiredSize)
{
// During reflow, we use rect.x and rect.y as placeholders for the child's ascent
@ -472,7 +472,7 @@ nsMathMLContainerFrame::FinalizeReflow(nsRenderingContext& aRenderingContext,
bool placeOrigin = !NS_MATHML_IS_EMBELLISH_OPERATOR(mEmbellishData.flags) ||
(mEmbellishData.coreFrame != this && !mPresentationData.baseFrame &&
mEmbellishData.direction == NS_STRETCH_DIRECTION_UNSUPPORTED);
nsresult rv = Place(aRenderingContext, placeOrigin, aDesiredSize);
nsresult rv = Place(aDrawTarget, placeOrigin, aDesiredSize);
// Place() will call FinishReflowChild() when placeOrigin is true but if
// it returns before reaching FinishReflowChild() due to errors we need
@ -526,8 +526,7 @@ nsMathMLContainerFrame::FinalizeReflow(nsRenderingContext& aRenderingContext,
// The stretch call will detect if this is incorrect and recalculate the size.
nsBoundingMetrics defaultSize = aDesiredSize.mBoundingMetrics;
Stretch(aRenderingContext, stretchDir, defaultSize,
aDesiredSize);
Stretch(aDrawTarget, stretchDir, defaultSize, aDesiredSize);
#ifdef DEBUG
{
// The Place() call above didn't request FinishReflowChild(),
@ -874,7 +873,7 @@ nsMathMLContainerFrame::ReflowChild(nsIFrame* aChildFrame,
}
if (IsForeignChild(aChildFrame)) {
// use ComputeTightBounds API as aDesiredSize.mBoundingMetrics is not set.
nsRect r = aChildFrame->ComputeTightBounds(aReflowState.rendContext->ThebesContext());
nsRect r = aChildFrame->ComputeTightBounds(aReflowState.rendContext->GetDrawTarget());
aDesiredSize.mBoundingMetrics.leftBearing = r.x;
aDesiredSize.mBoundingMetrics.rightBearing = r.XMost();
aDesiredSize.mBoundingMetrics.ascent = aDesiredSize.BlockStartAscent() - r.y;
@ -924,6 +923,8 @@ nsMathMLContainerFrame::Reflow(nsPresContext* aPresContext,
// The stretching of siblings of an embellished child is _deferred_ until
// after finishing the stretching of the embellished child - bug 117652
DrawTarget* drawTarget = aReflowState.rendContext->GetDrawTarget();
if (!NS_MATHML_IS_EMBELLISH_OPERATOR(mEmbellishData.flags) &&
(NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY(mPresentationData.flags) ||
NS_MATHML_WILL_STRETCH_ALL_CHILDREN_HORIZONTALLY(mPresentationData.flags))) {
@ -939,8 +940,7 @@ nsMathMLContainerFrame::Reflow(nsPresContext* aPresContext,
// We don't use STRETCH_CONSIDER_EMBELLISHMENTS -- because we don't want to
// include them in the caculations of the size of stretchy elements
nsBoundingMetrics containerSize;
GetPreferredStretchSize(*aReflowState.rendContext, 0, stretchDir,
containerSize);
GetPreferredStretchSize(drawTarget, 0, stretchDir, containerSize);
// fire the stretch on each child
childFrame = mFrames.FirstChild();
@ -952,7 +952,7 @@ nsMathMLContainerFrame::Reflow(nsPresContext* aPresContext,
GetReflowAndBoundingMetricsFor(childFrame,
childDesiredSize, childDesiredSize.mBoundingMetrics);
mathMLFrame->Stretch(*aReflowState.rendContext, stretchDir,
mathMLFrame->Stretch(drawTarget, stretchDir,
containerSize, childDesiredSize);
// store the updated metrics
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
@ -964,7 +964,7 @@ nsMathMLContainerFrame::Reflow(nsPresContext* aPresContext,
/////////////
// Place children now by re-adjusting the origins to align the baselines
FinalizeReflow(*aReflowState.rendContext, aDesiredSize);
FinalizeReflow(drawTarget, aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
@ -1055,19 +1055,19 @@ nsMathMLContainerFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingC
}
// Measure
nsresult rv = MeasureForWidth(*aRenderingContext, aDesiredSize);
nsresult rv = MeasureForWidth(aRenderingContext->GetDrawTarget(), aDesiredSize);
if (NS_FAILED(rv)) {
ReflowError(*aRenderingContext, aDesiredSize);
ReflowError(aRenderingContext->GetDrawTarget(), aDesiredSize);
}
ClearSavedChildMetrics();
}
/* virtual */ nsresult
nsMathMLContainerFrame::MeasureForWidth(nsRenderingContext& aRenderingContext,
nsMathMLContainerFrame::MeasureForWidth(DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aDesiredSize)
{
return Place(aRenderingContext, false, aDesiredSize);
return Place(aDrawTarget, false, aDesiredSize);
}
@ -1278,7 +1278,7 @@ private:
};
/* virtual */ nsresult
nsMathMLContainerFrame::Place(nsRenderingContext& aRenderingContext,
nsMathMLContainerFrame::Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{

View File

@ -44,7 +44,7 @@ public:
// Overloaded nsMathMLFrame methods -- see documentation in nsIMathMLFrame.h
NS_IMETHOD
Stretch(nsRenderingContext& aRenderingContext,
Stretch(DrawTarget* aDrawTarget,
nsStretchDirection aStretchDirection,
nsBoundingMetrics& aContainerSize,
nsHTMLReflowMetrics& aDesiredStretchSize) override;
@ -196,7 +196,7 @@ protected:
* return.
*/
virtual nsresult
Place(nsRenderingContext& aRenderingContext,
Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize);
@ -209,7 +209,7 @@ protected:
// if in an <mrow>, and so their frames implement MeasureForWidth to use
// nsMathMLContainerFrame::Place.
virtual nsresult
MeasureForWidth(nsRenderingContext& aRenderingContext,
MeasureForWidth(DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aDesiredSize);
@ -221,7 +221,7 @@ protected:
// helper to get the preferred size that a container frame should use to fire
// the stretch on its stretchy child frames.
void
GetPreferredStretchSize(nsRenderingContext& aRenderingContext,
GetPreferredStretchSize(DrawTarget* aDrawTarget,
uint32_t aOptions,
nsStretchDirection aStretchDirection,
nsBoundingMetrics& aPreferredStretchSize);
@ -235,8 +235,7 @@ public:
// error handlers to provide a visual feedback to the user when an error
// (typically invalid markup) was encountered during reflow.
nsresult
ReflowError(nsRenderingContext& aRenderingContext,
nsHTMLReflowMetrics& aDesiredSize);
ReflowError(DrawTarget* aDrawTarget, nsHTMLReflowMetrics& aDesiredSize);
/*
* Helper to call ReportErrorToConsole for parse errors involving
* attribute/value pairs.
@ -295,8 +294,7 @@ protected:
// helper method to complete the post-reflow hook and ensure that embellished
// operators don't terminate their Reflow without receiving a Stretch command.
virtual nsresult
FinalizeReflow(nsRenderingContext& aRenderingContext,
nsHTMLReflowMetrics& aDesiredSize);
FinalizeReflow(DrawTarget* aDrawTarget, nsHTMLReflowMetrics& aDesiredSize);
// Record metrics of a child frame for recovery through the following method
static void

View File

@ -168,15 +168,15 @@ nsMathMLFrame::GetPresentationDataFrom(nsIFrame* aFrame,
}
/* static */ void
nsMathMLFrame::GetRuleThickness(nsRenderingContext& aRenderingContext,
nsFontMetrics* aFontMetrics,
nscoord& aRuleThickness)
nsMathMLFrame::GetRuleThickness(DrawTarget* aDrawTarget,
nsFontMetrics* aFontMetrics,
nscoord& aRuleThickness)
{
nscoord xHeight = aFontMetrics->XHeight();
char16_t overBar = 0x00AF;
nsBoundingMetrics bm =
nsLayoutUtils::AppUnitBoundsOfString(&overBar, 1, *aFontMetrics,
aRenderingContext);
aDrawTarget);
aRuleThickness = bm.ascent + bm.descent;
if (aRuleThickness <= 0 || aRuleThickness >= xHeight) {
// fall-back to the other version
@ -185,9 +185,9 @@ nsMathMLFrame::GetRuleThickness(nsRenderingContext& aRenderingContext,
}
/* static */ void
nsMathMLFrame::GetAxisHeight(nsRenderingContext& aRenderingContext,
nsFontMetrics* aFontMetrics,
nscoord& aAxisHeight)
nsMathMLFrame::GetAxisHeight(DrawTarget* aDrawTarget,
nsFontMetrics* aFontMetrics,
nscoord& aAxisHeight)
{
gfxFont* mathFont = aFontMetrics->GetThebesFontGroup()->GetFirstMathFont();
if (mathFont) {
@ -200,8 +200,7 @@ nsMathMLFrame::GetAxisHeight(nsRenderingContext& aRenderingContext,
nscoord xHeight = aFontMetrics->XHeight();
char16_t minus = 0x2212; // not '-', but official Unicode minus sign
nsBoundingMetrics bm =
nsLayoutUtils::AppUnitBoundsOfString(&minus, 1, *aFontMetrics,
aRenderingContext);
nsLayoutUtils::AppUnitBoundsOfString(&minus, 1, *aFontMetrics, aDrawTarget);
aAxisHeight = bm.ascent - (bm.ascent + bm.descent)/2;
if (aAxisHeight <= 0 || aAxisHeight >= xHeight) {
// fall-back to the other version

View File

@ -21,7 +21,6 @@ class nsDisplayListSet;
// Concrete base class with default methods that derived MathML frames can override
class nsMathMLFrame : public nsIMathMLFrame {
public:
// nsIMathMLFrame ---
virtual bool
@ -50,7 +49,7 @@ public:
virtual eMathMLFrameType GetMathMLFrameType() override;
NS_IMETHOD
Stretch(nsRenderingContext& aRenderingContext,
Stretch(mozilla::gfx::DrawTarget* aDrawTarget,
nsStretchDirection aStretchDirection,
nsBoundingMetrics& aContainerSize,
nsHTMLReflowMetrics& aDesiredStretchSize) override
@ -336,14 +335,14 @@ public:
// Here are some slower variants to obtain the desired metrics
// by actually measuring some characters
static void
GetRuleThickness(nsRenderingContext& aRenderingContext,
nsFontMetrics* aFontMetrics,
nscoord& aRuleThickness);
GetRuleThickness(mozilla::gfx::DrawTarget* aDrawTarget,
nsFontMetrics* aFontMetrics,
nscoord& aRuleThickness);
static void
GetAxisHeight(nsRenderingContext& aRenderingContext,
nsFontMetrics* aFontMetrics,
nscoord& aAxisHeight);
GetAxisHeight(mozilla::gfx::DrawTarget* aDrawTarget,
nsFontMetrics* aFontMetrics,
nscoord& aAxisHeight);
static void
GetRadicalParameters(nsFontMetrics* aFontMetrics,

View File

@ -157,20 +157,20 @@ nsMathMLSelectedFrame::Reflow(nsPresContext* aPresContext,
aDesiredSize.mBoundingMetrics);
mBoundingMetrics = aDesiredSize.mBoundingMetrics;
}
FinalizeReflow(*aReflowState.rendContext, aDesiredSize);
FinalizeReflow(aReflowState.rendContext->GetDrawTarget(), aDesiredSize);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
// Only place the selected child ...
/* virtual */ nsresult
nsMathMLSelectedFrame::Place(nsRenderingContext& aRenderingContext,
nsMathMLSelectedFrame::Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{
nsIFrame* childFrame = GetSelectedFrame();
if (mInvalidMarkup) {
return ReflowError(aRenderingContext, aDesiredSize);
return ReflowError(aDrawTarget, aDesiredSize);
}
aDesiredSize.ClearSize();

View File

@ -30,7 +30,7 @@ public:
const nsDisplayListSet& aLists) override;
virtual nsresult
Place(nsRenderingContext& aRenderingContext,
Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize) override;

View File

@ -153,7 +153,7 @@ nsMathMLTokenFrame::Reflow(nsPresContext* aPresContext,
}
// place and size children
FinalizeReflow(*aReflowState.rendContext, aDesiredSize);
FinalizeReflow(aReflowState.rendContext->GetDrawTarget(), aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
@ -163,7 +163,7 @@ nsMathMLTokenFrame::Reflow(nsPresContext* aPresContext,
// pass, it is not computed here because our children may be text frames
// that do not implement the GetBoundingMetrics() interface.
/* virtual */ nsresult
nsMathMLTokenFrame::Place(nsRenderingContext& aRenderingContext,
nsMathMLTokenFrame::Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{

View File

@ -54,7 +54,7 @@ public:
nsReflowStatus& aStatus) override;
virtual nsresult
Place(nsRenderingContext& aRenderingContext,
Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize) override;

View File

@ -299,22 +299,22 @@ nsMathMLmencloseFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
}
/* virtual */ nsresult
nsMathMLmencloseFrame::MeasureForWidth(nsRenderingContext& aRenderingContext,
nsMathMLmencloseFrame::MeasureForWidth(DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aDesiredSize)
{
return PlaceInternal(aRenderingContext, false, aDesiredSize, true);
return PlaceInternal(aDrawTarget, false, aDesiredSize, true);
}
/* virtual */ nsresult
nsMathMLmencloseFrame::Place(nsRenderingContext& aRenderingContext,
nsMathMLmencloseFrame::Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{
return PlaceInternal(aRenderingContext, aPlaceOrigin, aDesiredSize, false);
return PlaceInternal(aDrawTarget, aPlaceOrigin, aDesiredSize, false);
}
/* virtual */ nsresult
nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
nsMathMLmencloseFrame::PlaceInternal(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
bool aWidthOnly)
@ -324,7 +324,7 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
// inferred mrow.
nsHTMLReflowMetrics baseSize(aDesiredSize.GetWritingMode());
nsresult rv =
nsMathMLContainerFrame::Place(aRenderingContext, false, baseSize);
nsMathMLContainerFrame::Place(aDrawTarget, false, baseSize);
if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) {
DidReflowChildren(GetFirstPrincipalChild());
@ -347,14 +347,14 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
RefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
fontSizeInflation);
GetRuleThickness(aRenderingContext, fm, mRuleThickness);
GetRuleThickness(aDrawTarget, fm, mRuleThickness);
if (mRuleThickness < onePixel) {
mRuleThickness = onePixel;
}
char16_t one = '1';
nsBoundingMetrics bmOne =
nsLayoutUtils::AppUnitBoundsOfString(&one, 1, *fm, aRenderingContext);
nsLayoutUtils::AppUnitBoundsOfString(&one, 1, *fm, aDrawTarget);
///////////////
// General rules: the menclose element takes the size of the enclosed content.
@ -484,7 +484,7 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
if (IsToDraw(NOTATION_LONGDIV)) {
if (aWidthOnly) {
nscoord longdiv_width = mMathMLChar[mLongDivCharIndex].
GetMaxWidth(PresContext(), aRenderingContext, fontSizeInflation);
GetMaxWidth(PresContext(), aDrawTarget, fontSizeInflation);
// Update horizontal parameters
dx_left = std::max(dx_left, longdiv_width);
@ -496,7 +496,7 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
contSize.descent = bmBase.ascent + bmBase.descent + psi;
// height(longdiv) should be >= height(base) + psi + mRuleThickness
mMathMLChar[mLongDivCharIndex].Stretch(PresContext(), aRenderingContext,
mMathMLChar[mLongDivCharIndex].Stretch(PresContext(), aDrawTarget,
fontSizeInflation,
NS_STRETCH_DIRECTION_VERTICAL,
contSize, bmLongdivChar,
@ -526,7 +526,7 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
if (aWidthOnly) {
nscoord radical_width = mMathMLChar[mRadicalCharIndex].
GetMaxWidth(PresContext(), aRenderingContext, fontSizeInflation);
GetMaxWidth(PresContext(), aDrawTarget, fontSizeInflation);
// Update horizontal parameters
*dx_leading = std::max(*dx_leading, radical_width);
@ -538,7 +538,7 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
contSize.descent = bmBase.ascent + bmBase.descent + psi;
// height(radical) should be >= height(base) + psi + mRadicalRuleThickness
mMathMLChar[mRadicalCharIndex].Stretch(PresContext(), aRenderingContext,
mMathMLChar[mRadicalCharIndex].Stretch(PresContext(), aDrawTarget,
fontSizeInflation,
NS_STRETCH_DIRECTION_VERTICAL,
contSize, bmRadicalChar,

View File

@ -50,12 +50,12 @@ public:
nsStyleContext* aContext);
virtual nsresult
Place(nsRenderingContext& aRenderingContext,
Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize) override;
virtual nsresult
MeasureForWidth(nsRenderingContext& aRenderingContext,
MeasureForWidth(DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aDesiredSize) override;
virtual nsresult
@ -92,11 +92,11 @@ protected:
explicit nsMathMLmencloseFrame(nsStyleContext* aContext);
virtual ~nsMathMLmencloseFrame();
nsresult PlaceInternal(nsRenderingContext& aRenderingContext,
nsresult PlaceInternal(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
bool aWidthOnly);
// functions to parse the "notation" attribute.
nsresult AddNotation(const nsAString& aNotation);
void InitNotations();

View File

@ -192,7 +192,7 @@ direction, this has no impact on overall appearance.
*/
static void
ApplyUnstretchedMetrics(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
nsMathMLChar* aMathMLChar,
nsBoundingMetrics& aMetrics,
@ -200,8 +200,7 @@ ApplyUnstretchedMetrics(nsPresContext* aPresContext,
{
if (aMathMLChar && 0 < aMathMLChar->Length()) {
nsBoundingMetrics charSize;
aMathMLChar->Stretch(aPresContext, aRenderingContext,
aFontSizeInflation,
aMathMLChar->Stretch(aPresContext, aDrawTarget, aFontSizeInflation,
NS_STRETCH_DIRECTION_DEFAULT,
aMetrics, // size is unimportant as we aren't stretching
charSize, NS_STRETCH_NONE, aIsRTL);
@ -228,7 +227,7 @@ nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
fontSizeInflation);
nscoord axisHeight, em;
GetAxisHeight(*aReflowState.rendContext, fm, axisHeight);
GetAxisHeight(aReflowState.rendContext->GetDrawTarget(), fm, axisHeight);
GetEmHeight(fm, em);
// leading to be left at the top and the bottom of stretched chars
nscoord leading = NSToCoordRound(0.2f * em);
@ -288,7 +287,9 @@ nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
nsBoundingMetrics containerSize;
nsStretchDirection stretchDir = NS_STRETCH_DIRECTION_VERTICAL;
GetPreferredStretchSize(*aReflowState.rendContext,
DrawTarget* drawTarget = aReflowState.rendContext->GetDrawTarget();
GetPreferredStretchSize(drawTarget,
0, /* i.e., without embellishments */
stretchDir, containerSize);
childFrame = firstChild;
@ -299,13 +300,13 @@ nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
// retrieve the metrics that was stored at the previous pass
GetReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
mathmlChild->Stretch(*aReflowState.rendContext,
mathmlChild->Stretch(drawTarget,
stretchDir, containerSize, childDesiredSize);
// store the updated metrics
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
nscoord childDescent = childDesiredSize.Height() - childDesiredSize.BlockStartAscent();
if (descent < childDescent)
descent = childDescent;
@ -316,23 +317,22 @@ nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
}
// bug 121748: for surrounding fences & separators, use a size that covers everything
GetPreferredStretchSize(*aReflowState.rendContext,
STRETCH_CONSIDER_EMBELLISHMENTS,
GetPreferredStretchSize(drawTarget, STRETCH_CONSIDER_EMBELLISHMENTS,
stretchDir, containerSize);
bool isRTL = StyleVisibility()->mDirection;
// To achieve a minimum size of "1", the container should be enlarged by the
// unstretched metrics of the fences and separators.
ApplyUnstretchedMetrics(aPresContext, *aReflowState.rendContext,
ApplyUnstretchedMetrics(aPresContext, drawTarget,
fontSizeInflation, mOpenChar,
containerSize, isRTL);
for (i = 0; i < mSeparatorsCount; i++) {
ApplyUnstretchedMetrics(aPresContext, *aReflowState.rendContext,
ApplyUnstretchedMetrics(aPresContext, drawTarget,
fontSizeInflation, &mSeparatorsChar[i],
containerSize, isRTL);
}
ApplyUnstretchedMetrics(aPresContext, *aReflowState.rendContext,
ApplyUnstretchedMetrics(aPresContext, drawTarget,
fontSizeInflation, mCloseChar,
containerSize, isRTL);
@ -348,21 +348,21 @@ nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
/////////////////
// opening fence ...
ReflowChar(aPresContext, *aReflowState.rendContext, *fm,
ReflowChar(aPresContext, drawTarget, *fm,
fontSizeInflation, mOpenChar,
NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel,
axisHeight, leading, em, containerSize, ascent, descent, isRTL);
/////////////////
// separators ...
for (i = 0; i < mSeparatorsCount; i++) {
ReflowChar(aPresContext, *aReflowState.rendContext, *fm,
ReflowChar(aPresContext, drawTarget, *fm,
fontSizeInflation, &mSeparatorsChar[i],
NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel,
axisHeight, leading, em, containerSize, ascent, descent, isRTL);
}
/////////////////
// closing fence ...
ReflowChar(aPresContext, *aReflowState.rendContext, *fm,
ReflowChar(aPresContext, drawTarget, *fm,
fontSizeInflation, mCloseChar,
NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel,
axisHeight, leading, em, containerSize, ascent, descent, isRTL);
@ -479,8 +479,8 @@ GetCharSpacing(nsMathMLChar* aMathMLChar,
// helper functions to perform the common task of formatting our chars
/*static*/ nsresult
nsMathMLmfencedFrame::ReflowChar(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsMathMLmfencedFrame::ReflowChar(nsPresContext* aPresContext,
DrawTarget* aDrawTarget,
nsFontMetrics& aFontMetrics,
float aFontSizeInflation,
nsMathMLChar* aMathMLChar,
@ -501,7 +501,7 @@ nsMathMLmfencedFrame::ReflowChar(nsPresContext* aPresContext,
// stretch the char to the appropriate height if it is not big enough.
nsBoundingMetrics charSize;
nsresult res = aMathMLChar->Stretch(aPresContext, aRenderingContext,
nsresult res = aMathMLChar->Stretch(aPresContext, aDrawTarget,
aFontSizeInflation,
NS_STRETCH_DIRECTION_VERTICAL,
aContainerSize, charSize,
@ -522,7 +522,7 @@ nsMathMLmfencedFrame::ReflowChar(nsPresContext* aPresContext,
aMathMLChar->GetData(data);
nsBoundingMetrics metrics =
nsLayoutUtils::AppUnitBoundsOfString(data.get(), data.Length(),
aFontMetrics, aRenderingContext);
aFontMetrics, aDrawTarget);
charSize.ascent = metrics.ascent;
charSize.descent = metrics.descent;
charSize.width = metrics.width;
@ -583,14 +583,14 @@ nsMathMLmfencedFrame::PlaceChar(nsMathMLChar* aMathMLChar,
static nscoord
GetMaxCharWidth(nsPresContext* aPresContext,
nsRenderingContext* aRenderingContext,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
nsMathMLChar* aMathMLChar,
nsOperatorFlags aForm,
int32_t aScriptLevel,
nscoord em)
{
nscoord width = aMathMLChar->GetMaxWidth(aPresContext, *aRenderingContext,
nscoord width = aMathMLChar->GetMaxWidth(aPresContext, aDrawTarget,
aFontSizeInflation);
if (0 < aMathMLChar->Length()) {
@ -620,7 +620,7 @@ nsMathMLmfencedFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingCon
if (mOpenChar) {
width +=
GetMaxCharWidth(presContext, aRenderingContext,
GetMaxCharWidth(presContext, aRenderingContext->GetDrawTarget(),
fontSizeInflation, mOpenChar,
NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel, em);
}
@ -636,7 +636,7 @@ nsMathMLmfencedFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingCon
if (i < mSeparatorsCount) {
width +=
GetMaxCharWidth(presContext, aRenderingContext,
GetMaxCharWidth(presContext, aRenderingContext->GetDrawTarget(),
fontSizeInflation, &mSeparatorsChar[i],
NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel, em);
}
@ -647,7 +647,7 @@ nsMathMLmfencedFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingCon
if (mCloseChar) {
width +=
GetMaxCharWidth(presContext, aRenderingContext,
GetMaxCharWidth(presContext, aRenderingContext->GetDrawTarget(),
fontSizeInflation, mCloseChar,
NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel, em);
}

View File

@ -63,8 +63,8 @@ public:
// helper routines to format the MathMLChars involved here
static nsresult
ReflowChar(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
ReflowChar(nsPresContext* aPresContext,
DrawTarget* aDrawTarget,
nsFontMetrics& aFontMetrics,
float aFontSizeInflation,
nsMathMLChar* aMathMLChar,

View File

@ -165,13 +165,10 @@ nsMathMLmfracFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
}
/* virtual */ nsresult
nsMathMLmfracFrame::MeasureForWidth(nsRenderingContext& aRenderingContext,
nsMathMLmfracFrame::MeasureForWidth(DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aDesiredSize)
{
return PlaceInternal(aRenderingContext,
false,
aDesiredSize,
true);
return PlaceInternal(aDrawTarget, false, aDesiredSize, true);
}
nscoord
@ -185,18 +182,15 @@ nsMathMLmfracFrame::FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
}
/* virtual */ nsresult
nsMathMLmfracFrame::Place(nsRenderingContext& aRenderingContext,
nsMathMLmfracFrame::Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{
return PlaceInternal(aRenderingContext,
aPlaceOrigin,
aDesiredSize,
false);
return PlaceInternal(aDrawTarget, aPlaceOrigin, aDesiredSize, false);
}
nsresult
nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
nsMathMLmfracFrame::PlaceInternal(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
bool aWidthOnly)
@ -215,7 +209,7 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
if (aPlaceOrigin) {
ReportChildCountError();
}
return ReflowError(aRenderingContext, aDesiredSize);
return ReflowError(aDrawTarget, aDesiredSize);
}
GetReflowAndBoundingMetricsFor(frameNum, sizeNum, bmNum);
GetReflowAndBoundingMetricsFor(frameDen, sizeDen, bmDen);
@ -236,9 +230,9 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
mathFont->GetMathConstant(gfxFontEntry::FractionRuleThickness,
oneDevPixel);
} else {
GetRuleThickness(aRenderingContext, fm, defaultRuleThickness);
GetRuleThickness(aDrawTarget, fm, defaultRuleThickness);
}
GetAxisHeight(aRenderingContext, fm, axisHeight);
GetAxisHeight(aDrawTarget, fm, axisHeight);
bool outermostEmbellished = false;
if (mEmbellishData.coreFrame) {

View File

@ -58,11 +58,11 @@ public:
virtual eMathMLFrameType GetMathMLFrameType() override;
virtual nsresult
MeasureForWidth(nsRenderingContext& aRenderingContext,
MeasureForWidth(DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aDesiredSize) override;
virtual nsresult
Place(nsRenderingContext& aRenderingContext,
Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize) override;
@ -92,8 +92,8 @@ public:
protected:
explicit nsMathMLmfracFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {}
virtual ~nsMathMLmfracFrame();
nsresult PlaceInternal(nsRenderingContext& aRenderingContext,
nsresult PlaceInternal(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
bool aWidthOnly);

View File

@ -90,7 +90,7 @@ nsMathMLmmultiscriptsFrame::TransmitAutomaticData()
}
/* virtual */ nsresult
nsMathMLmmultiscriptsFrame::Place(nsRenderingContext& aRenderingContext,
nsMathMLmmultiscriptsFrame::Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{
@ -135,7 +135,7 @@ nsMathMLmmultiscriptsFrame::Place(nsRenderingContext& aRenderingContext,
mStyleContext, fontSizeInflation);
}
}
return PlaceMultiScript(PresContext(), aRenderingContext, aPlaceOrigin,
return PlaceMultiScript(PresContext(), aDrawTarget, aPlaceOrigin,
aDesiredSize, this, subScriptShift, supScriptShift,
fontSizeInflation);
}
@ -143,8 +143,8 @@ nsMathMLmmultiscriptsFrame::Place(nsRenderingContext& aRenderingContext,
// exported routine that both munderover and mmultiscripts share.
// munderover uses this when movablelimits is set.
nsresult
nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext,
DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
nsMathMLContainerFrame* aFrame,
@ -180,7 +180,7 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext,
aFrame->ReportErrorToConsole("NoBase");
else
aFrame->ReportChildCountError();
return aFrame->ReflowError(aRenderingContext, aDesiredSize);
return aFrame->ReflowError(aDrawTarget, aDesiredSize);
}
// get x-height (an ex)
@ -329,7 +329,7 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext,
if (aPlaceOrigin) {
aFrame->ReportInvalidChildError(nsGkAtoms::mprescripts_);
}
return aFrame->ReflowError(aRenderingContext, aDesiredSize);
return aFrame->ReflowError(aDrawTarget, aDesiredSize);
}
if (prescriptsFrame) {
// duplicate <mprescripts/> found
@ -337,13 +337,13 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext,
if (aPlaceOrigin) {
aFrame->ReportErrorToConsole("DuplicateMprescripts");
}
return aFrame->ReflowError(aRenderingContext, aDesiredSize);
return aFrame->ReflowError(aDrawTarget, aDesiredSize);
}
if (!isSubScript) {
if (aPlaceOrigin) {
aFrame->ReportErrorToConsole("SubSupMismatch");
}
return aFrame->ReflowError(aRenderingContext, aDesiredSize);
return aFrame->ReflowError(aDrawTarget, aDesiredSize);
}
prescriptsFrame = childFrame;
@ -356,7 +356,7 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext,
if (aPlaceOrigin) {
aFrame->ReportErrorToConsole("NoBase");
}
return aFrame->ReflowError(aRenderingContext, aDesiredSize);
return aFrame->ReflowError(aDrawTarget, aDesiredSize);
} else {
//A different error message is triggered later for the other tags
foundNoneTag = true;
@ -488,7 +488,7 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext,
oneDevPixel);
} else {
nscoord ruleSize;
GetRuleThickness(aRenderingContext, fm, ruleSize);
GetRuleThickness(aDrawTarget, fm, ruleSize);
subSuperscriptGapMin = 4 * ruleSize;
}
nscoord gap =
@ -550,7 +550,7 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext,
aFrame->ReportErrorToConsole("SubSupMismatch");
}
}
return aFrame->ReflowError(aRenderingContext, aDesiredSize);
return aFrame->ReflowError(aDrawTarget, aDesiredSize);
}
// we left out the width of prescripts, so ...

View File

@ -26,19 +26,19 @@ public:
TransmitAutomaticData() override;
virtual nsresult
Place(nsRenderingContext& aRenderingContext,
Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize) override;
static nsresult
PlaceMultiScript(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
nsMathMLContainerFrame* aForFrame,
nscoord aUserSubScriptShift,
nscoord aUserSupScriptShift,
float aFontSizeInflation);
PlaceMultiScript(nsPresContext* aPresContext,
DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
nsMathMLContainerFrame* aForFrame,
nscoord aUserSubScriptShift,
nscoord aUserSupScriptShift,
float aFontSizeInflation);
uint8_t
ScriptIncrement(nsIFrame* aFrame) override;

View File

@ -604,7 +604,7 @@ GetStretchHint(nsOperatorFlags aFlags, nsPresentationData aPresentationData,
// On input - it contains our current size
// On output - the same size or the new size that we want
NS_IMETHODIMP
nsMathMLmoFrame::Stretch(nsRenderingContext& aRenderingContext,
nsMathMLmoFrame::Stretch(DrawTarget* aDrawTarget,
nsStretchDirection aStretchDirection,
nsBoundingMetrics& aContainerSize,
nsHTMLReflowMetrics& aDesiredStretchSize)
@ -623,7 +623,7 @@ nsMathMLmoFrame::Stretch(nsRenderingContext& aRenderingContext,
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
fontSizeInflation);
nscoord axisHeight, height;
GetAxisHeight(aRenderingContext, fm, axisHeight);
GetAxisHeight(aDrawTarget, fm, axisHeight);
// get the leading to be left at the top and the bottom of the stretched char
// this seems more reliable than using fm->GetLeading() on suspicious fonts
@ -748,7 +748,7 @@ nsMathMLmoFrame::Stretch(nsRenderingContext& aRenderingContext,
}
// let the MathMLChar stretch itself...
nsresult res = mMathMLChar.Stretch(PresContext(), aRenderingContext,
nsresult res = mMathMLChar.Stretch(PresContext(), aDrawTarget,
fontSizeInflation,
aStretchDirection, container, charSize,
stretchHint,
@ -763,7 +763,7 @@ nsMathMLmoFrame::Stretch(nsRenderingContext& aRenderingContext,
// Place our children using the default method
// This will allow our child text frame to get its DidReflow()
nsresult rv = Place(aRenderingContext, true, aDesiredStretchSize);
nsresult rv = Place(aDrawTarget, true, aDesiredStretchSize);
if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) {
// Make sure the child frames get their DidReflow() calls.
DidReflowChildren(mFrames.FirstChild());
@ -959,12 +959,11 @@ nsMathMLmoFrame::Reflow(nsPresContext* aPresContext,
}
nsresult
nsMathMLmoFrame::Place(nsRenderingContext& aRenderingContext,
nsMathMLmoFrame::Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{
nsresult rv = nsMathMLTokenFrame::Place(aRenderingContext, aPlaceOrigin,
aDesiredSize);
nsresult rv = nsMathMLTokenFrame::Place(aDrawTarget, aPlaceOrigin, aDesiredSize);
if (NS_FAILED(rv)) {
return rv;
@ -985,11 +984,11 @@ nsMathMLmoFrame::Place(nsRenderingContext& aRenderingContext,
StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK &&
NS_MATHML_OPERATOR_IS_LARGEOP(mFlags) && UseMathMLChar()) {
nsBoundingMetrics newMetrics;
rv = mMathMLChar.Stretch(PresContext(), aRenderingContext,
nsLayoutUtils::FontSizeInflationFor(this),
NS_STRETCH_DIRECTION_VERTICAL,
aDesiredSize.mBoundingMetrics, newMetrics,
NS_STRETCH_LARGEOP, StyleVisibility()->mDirection);
rv = mMathMLChar.Stretch(PresContext(), aDrawTarget,
nsLayoutUtils::FontSizeInflationFor(this),
NS_STRETCH_DIRECTION_VERTICAL,
aDesiredSize.mBoundingMetrics, newMetrics,
NS_STRETCH_LARGEOP, StyleVisibility()->mDirection);
if (NS_FAILED(rv)) {
// Just use the initial size
@ -1046,7 +1045,7 @@ nsMathMLmoFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingContext,
uint32_t stretchHint = GetStretchHint(mFlags, mPresentationData, true,
StyleFont());
aDesiredSize.Width() = mMathMLChar.
GetMaxWidth(PresContext(), *aRenderingContext,
GetMaxWidth(PresContext(), aRenderingContext->GetDrawTarget(),
nsLayoutUtils::FontSizeInflationFor(this),
stretchHint);
}

View File

@ -49,7 +49,7 @@ public:
nsReflowStatus& aStatus) override;
virtual nsresult
Place(nsRenderingContext& aRenderingContext,
Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize) override;
@ -67,7 +67,7 @@ public:
// This method is called by the parent frame to ask <mo>
// to stretch itself.
NS_IMETHOD
Stretch(nsRenderingContext& aRenderingContext,
Stretch(DrawTarget* aDrawTarget,
nsStretchDirection aStretchDirection,
nsBoundingMetrics& aContainerSize,
nsHTMLReflowMetrics& aDesiredStretchSize) override;

View File

@ -319,12 +319,12 @@ nsMathMLmpaddedFrame::Reflow(nsPresContext* aPresContext,
}
/* virtual */ nsresult
nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext,
nsMathMLmpaddedFrame::Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{
nsresult rv =
nsMathMLContainerFrame::Place(aRenderingContext, false, aDesiredSize);
nsMathMLContainerFrame::Place(aDrawTarget, false, aDesiredSize);
if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) {
DidReflowChildren(GetFirstPrincipalChild());
return rv;
@ -441,9 +441,9 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext,
}
/* virtual */ nsresult
nsMathMLmpaddedFrame::MeasureForWidth(nsRenderingContext& aRenderingContext,
nsMathMLmpaddedFrame::MeasureForWidth(DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aDesiredSize)
{
ProcessAttributes();
return Place(aRenderingContext, false, aDesiredSize);
return Place(aDrawTarget, false, aDesiredSize);
}

View File

@ -34,7 +34,7 @@ public:
nsReflowStatus& aStatus) override;
virtual nsresult
Place(nsRenderingContext& aRenderingContext,
Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize) override;
@ -47,9 +47,9 @@ public:
protected:
explicit nsMathMLmpaddedFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {}
virtual ~nsMathMLmpaddedFrame();
virtual nsresult
MeasureForWidth(nsRenderingContext& aRenderingContext,
MeasureForWidth(DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aDesiredSize) override;
private:

View File

@ -172,7 +172,7 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
aDesiredSize.SetBlockStartAscent(0);
nsBoundingMetrics bmSqr, bmBase, bmIndex;
nsRenderingContext& renderingContext = *aReflowState.rendContext;
DrawTarget* drawTarget = aReflowState.rendContext->GetDrawTarget();
//////////////////
// Reflow Children
@ -214,7 +214,7 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
if (2 != count) {
// report an error, encourage people to get their markups in order
ReportChildCountError();
ReflowError(renderingContext, aDesiredSize);
ReflowError(drawTarget, aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
// Call DidReflow() for the child frames we successfully did reflow.
@ -238,7 +238,7 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
// built-in: adjust clearance psi to emulate \mathstrut using '1' (TexBook, p.131)
char16_t one = '1';
nsBoundingMetrics bmOne =
nsLayoutUtils::AppUnitBoundsOfString(&one, 1, *fm, renderingContext);
nsLayoutUtils::AppUnitBoundsOfString(&one, 1, *fm, drawTarget);
if (bmOne.ascent > bmBase.ascent)
psi += bmOne.ascent - bmBase.ascent;
@ -261,7 +261,7 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
// height(radical) should be >= height(base) + psi + ruleThickness
nsBoundingMetrics radicalSize;
mSqrChar.Stretch(aPresContext, renderingContext,
mSqrChar.Stretch(aPresContext, drawTarget,
fontSizeInflation,
NS_STRETCH_DIRECTION_VERTICAL,
contSize, radicalSize,
@ -366,7 +366,7 @@ nsMathMLmrootFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingConte
if (baseFrame)
indexFrame = baseFrame->GetNextSibling();
if (!indexFrame || indexFrame->GetNextSibling()) {
ReflowError(*aRenderingContext, aDesiredSize);
ReflowError(aRenderingContext->GetDrawTarget(), aDesiredSize);
return;
}
@ -377,7 +377,8 @@ nsMathMLmrootFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingConte
nscoord indexWidth =
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, indexFrame,
nsLayoutUtils::PREF_ISIZE);
nscoord sqrWidth = mSqrChar.GetMaxWidth(PresContext(), *aRenderingContext,
nscoord sqrWidth = mSqrChar.GetMaxWidth(PresContext(),
aRenderingContext->GetDrawTarget(),
fontSizeInflation);
nscoord dxSqr;

View File

@ -120,7 +120,7 @@ nsMathMLmspaceFrame::Reflow(nsPresContext* aPresContext,
}
/* virtual */ nsresult
nsMathMLmspaceFrame::MeasureForWidth(nsRenderingContext& aRenderingContext,
nsMathMLmspaceFrame::MeasureForWidth(DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aDesiredSize)
{
ProcessAttributes(PresContext());

View File

@ -40,7 +40,7 @@ protected:
virtual ~nsMathMLmspaceFrame();
virtual nsresult
MeasureForWidth(nsRenderingContext& aRenderingContext,
MeasureForWidth(DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aDesiredSize) override;
private:

View File

@ -888,7 +888,7 @@ nsMathMLmtableOuterFrame::Reflow(nsPresContext* aPresContext,
nsLayoutUtils::
FontSizeInflationFor(this));
nscoord axisHeight;
GetAxisHeight(*aReflowState.rendContext, fm, axisHeight);
GetAxisHeight(aReflowState.rendContext->GetDrawTarget(), fm, axisHeight);
if (rowFrame) {
// anchor the table on the axis of the row of reference
// XXX fallback to baseline because it is a hard problem

View File

@ -301,7 +301,7 @@ i.e.,:
*/
/* virtual */ nsresult
nsMathMLmunderoverFrame::Place(nsRenderingContext& aRenderingContext,
nsMathMLmunderoverFrame::Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{
@ -311,14 +311,14 @@ nsMathMLmunderoverFrame::Place(nsRenderingContext& aRenderingContext,
//place like sub sup or subsup
if (mContent->IsMathMLElement(nsGkAtoms::munderover_)) {
return nsMathMLmmultiscriptsFrame::PlaceMultiScript(PresContext(),
aRenderingContext,
aDrawTarget,
aPlaceOrigin,
aDesiredSize,
this, 0, 0,
fontSizeInflation);
} else if (mContent->IsMathMLElement( nsGkAtoms::munder_)) {
return nsMathMLmmultiscriptsFrame::PlaceMultiScript(PresContext(),
aRenderingContext,
aDrawTarget,
aPlaceOrigin,
aDesiredSize,
this, 0, 0,
@ -327,7 +327,7 @@ nsMathMLmunderoverFrame::Place(nsRenderingContext& aRenderingContext,
NS_ASSERTION(mContent->IsMathMLElement(nsGkAtoms::mover_),
"mContent->NodeInfo()->NameAtom() not recognized");
return nsMathMLmmultiscriptsFrame::PlaceMultiScript(PresContext(),
aRenderingContext,
aDrawTarget,
aPlaceOrigin,
aDesiredSize,
this, 0, 0,
@ -382,8 +382,8 @@ nsMathMLmunderoverFrame::Place(nsRenderingContext& aRenderingContext,
if (haveError) {
if (aPlaceOrigin) {
ReportChildCountError();
}
return ReflowError(aRenderingContext, aDesiredSize);
}
return ReflowError(aDrawTarget, aDesiredSize);
}
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
if (underFrame) {
@ -407,7 +407,7 @@ nsMathMLmunderoverFrame::Place(nsRenderingContext& aRenderingContext,
gfxFont* mathFont = fm->GetThebesFontGroup()->GetFirstMathFont();
nscoord ruleThickness;
GetRuleThickness (aRenderingContext, fm, ruleThickness);
GetRuleThickness (aDrawTarget, fm, ruleThickness);
nscoord correction = 0;
GetItalicCorrection (bmBase, correction);

View File

@ -20,7 +20,7 @@ public:
friend nsIFrame* NS_NewMathMLmunderoverFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
virtual nsresult
Place(nsRenderingContext& aRenderingContext,
Place(DrawTarget* aDrawTarget,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize) override;

View File

@ -518,8 +518,9 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
nsRenderingContext refContext(
PresContext()->PresShell()->CreateReferenceRenderingContext());
DrawTarget* refDrawTarget = refContext.GetDrawTarget();
CalculateUnderline(refContext, *fontMet);
CalculateUnderline(refDrawTarget, *fontMet);
nscolor c = aOverrideColor ? *aOverrideColor : StyleColor()->mColor;
ColorPattern color(ToDeviceColor(c));
@ -537,7 +538,7 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
posResolve.logicalIndex = mAccessKeyInfo->mAccesskeyIndex;
rv = nsBidiPresUtils::RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), level,
presContext, aRenderingContext,
refContext, *fontMet,
refDrawTarget, *fontMet,
baselinePt.x, baselinePt.y,
&posResolve,
1);
@ -548,7 +549,7 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
{
rv = nsBidiPresUtils::RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), level,
presContext, aRenderingContext,
refContext, *fontMet,
refDrawTarget, *fontMet,
baselinePt.x, baselinePt.y);
}
}
@ -563,14 +564,14 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
mAccessKeyInfo->mBeforeWidth = nsLayoutUtils::
AppUnitWidthOfString(mCroppedTitle.get(),
mAccessKeyInfo->mAccesskeyIndex,
*fontMet, refContext);
*fontMet, refDrawTarget);
else
mAccessKeyInfo->mBeforeWidth = 0;
}
fontMet->DrawString(mCroppedTitle.get(), mCroppedTitle.Length(),
baselinePt.x, baselinePt.y, &aRenderingContext,
&refContext);
refDrawTarget);
}
if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
@ -599,7 +600,7 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
}
void
nsTextBoxFrame::CalculateUnderline(nsRenderingContext& aRenderingContext,
nsTextBoxFrame::CalculateUnderline(DrawTarget* aDrawTarget,
nsFontMetrics& aFontMetrics)
{
if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
@ -609,7 +610,7 @@ nsTextBoxFrame::CalculateUnderline(nsRenderingContext& aRenderingContext,
aFontMetrics.SetTextRunRTL(false);
mAccessKeyInfo->mAccessWidth = nsLayoutUtils::
AppUnitWidthOfString(titleString[mAccessKeyInfo->mAccesskeyIndex],
aFontMetrics, aRenderingContext);
aFontMetrics, aDrawTarget);
nscoord offset, baseline;
aFontMetrics.GetUnderline(offset, mAccessKeyInfo->mAccessUnderlineSize);
@ -622,6 +623,8 @@ nscoord
nsTextBoxFrame::CalculateTitleForWidth(nsRenderingContext& aRenderingContext,
nscoord aWidth)
{
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
if (mTitle.IsEmpty()) {
mCroppedTitle.Truncate();
return 0;
@ -651,7 +654,7 @@ nsTextBoxFrame::CalculateTitleForWidth(nsRenderingContext& aRenderingContext,
// if so, clear the text (XXX set as many '.' as we can?).
fm->SetTextRunRTL(false);
titleWidth = nsLayoutUtils::AppUnitWidthOfString(kEllipsis, *fm,
aRenderingContext);
drawTarget);
if (titleWidth > aWidth) {
mCroppedTitle.SetLength(0);
@ -680,7 +683,7 @@ nsTextBoxFrame::CalculateTitleForWidth(nsRenderingContext& aRenderingContext,
char16_t ch = mTitle.CharAt(i);
// still in LTR mode
cwidth = nsLayoutUtils::AppUnitWidthOfString(ch, *fm,
aRenderingContext);
drawTarget);
if (twidth + cwidth > aWidth)
break;
@ -709,7 +712,7 @@ nsTextBoxFrame::CalculateTitleForWidth(nsRenderingContext& aRenderingContext,
for (i=length-1; i >= 0; --i) {
char16_t ch = mTitle.CharAt(i);
cwidth = nsLayoutUtils::AppUnitWidthOfString(ch, *fm,
aRenderingContext);
drawTarget);
if (twidth + cwidth > aWidth)
break;
@ -752,7 +755,7 @@ nsTextBoxFrame::CalculateTitleForWidth(nsRenderingContext& aRenderingContext,
// look at the next character on the left end
ch = mTitle.CharAt(leftPos);
charWidth = nsLayoutUtils::AppUnitWidthOfString(ch, *fm,
aRenderingContext);
drawTarget);
totalWidth += charWidth;
if (totalWidth > aWidth)
// greater than the allowable width
@ -768,7 +771,7 @@ nsTextBoxFrame::CalculateTitleForWidth(nsRenderingContext& aRenderingContext,
ch = mTitle.CharAt(rightPos);
charWidth =
nsLayoutUtils::AppUnitWidthOfString(ch, *fm,
aRenderingContext);
drawTarget);
totalWidth += charWidth;
if (totalWidth > aWidth)
// greater than the allowable width
@ -962,7 +965,7 @@ nsTextBoxFrame::DoLayout(nsBoxLayoutState& aBoxLayoutState)
nsBoundingMetrics metrics =
fontMet->GetInkBoundsForVisualOverflow(mCroppedTitle.get(),
mCroppedTitle.Length(),
aBoxLayoutState.GetRenderingContext());
aBoxLayoutState.GetRenderingContext()->GetDrawTarget());
WritingMode wm = GetWritingMode();
LogicalRect tr(wm, textRect, GetSize());

View File

@ -85,8 +85,7 @@ protected:
nsRenderingContext& aRenderingContext,
const nsRect& aRect);
void CalculateUnderline(nsRenderingContext& aRenderingContext,
nsFontMetrics& aFontMetrics);
void CalculateUnderline(DrawTarget* aDrawTarget, nsFontMetrics& aFontMetrics);
void CalcTextSize(nsBoxLayoutState& aBoxLayoutState);

View File

@ -1318,10 +1318,12 @@ nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
{
NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
nscoord maxWidth = aTextRect.width;
bool widthIsGreater = nsLayoutUtils::StringWidthIsGreaterThan(aText,
aFontMetrics,
aRenderingContext,
drawTarget,
maxWidth);
if (aColumn->Overflow()) {
@ -1353,7 +1355,7 @@ nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
maxWidth += width;
widthIsGreater = nsLayoutUtils::StringWidthIsGreaterThan(aText,
aFontMetrics,
aRenderingContext,
drawTarget,
maxWidth);
nextColumn = nextColumn->GetNext();
@ -1372,8 +1374,7 @@ nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
const nsDependentString& kEllipsis = nsContentUtils::GetLocalizedEllipsis();
aFontMetrics.SetTextRunRTL(false);
nscoord ellipsisWidth =
nsLayoutUtils::AppUnitWidthOfString(kEllipsis, aFontMetrics,
aRenderingContext);
nsLayoutUtils::AppUnitWidthOfString(kEllipsis, aFontMetrics, drawTarget);
width = maxWidth;
if (ellipsisWidth > width)
@ -1399,7 +1400,7 @@ nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
char16_t ch = aText[i];
// XXX this is horrible and doesn't handle clusters
cwidth = nsLayoutUtils::AppUnitWidthOfString(ch, aFontMetrics,
aRenderingContext);
drawTarget);
if (twidth + cwidth > width)
break;
twidth += cwidth;
@ -1418,7 +1419,7 @@ nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
for (i=length-1; i >= 0; --i) {
char16_t ch = aText[i];
cwidth = nsLayoutUtils::AppUnitWidthOfString(ch, aFontMetrics,
aRenderingContext);
drawTarget);
if (twidth + cwidth > width)
break;
twidth += cwidth;
@ -1441,7 +1442,7 @@ nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
for (int32_t leftPos = 0; leftPos < rightPos; ++leftPos) {
char16_t ch = aText[leftPos];
cwidth = nsLayoutUtils::AppUnitWidthOfString(ch, aFontMetrics,
aRenderingContext);
drawTarget);
twidth += cwidth;
if (twidth > width)
break;
@ -1449,7 +1450,7 @@ nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
ch = aText[rightPos];
cwidth = nsLayoutUtils::AppUnitWidthOfString(ch, aFontMetrics,
aRenderingContext);
drawTarget);
twidth += cwidth;
if (twidth > width)
break;

View File

@ -308,7 +308,8 @@ protected:
void CheckTextForBidi(nsAutoString& aText);
void AdjustForCellText(nsAutoString& aText,
int32_t aRowIndex, nsTreeColumn* aColumn,
int32_t aRowIndex,
nsTreeColumn* aColumn,
nsRenderingContext& aRenderingContext,
nsFontMetrics& aFontMetrics,
nsRect& aTextRect);