Bug 1533428 - patch 2 - Move the Orientation enum from gfxFont to nsFontMetrics to enable some #include-elimination, in particular to avoid including gfxTextRun.h in nsFontMetrics.h. r=jwatt

Differential Revision: https://phabricator.services.mozilla.com/D22913

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jonathan Kew 2019-04-01 14:32:19 +00:00
Родитель 243b72de64
Коммит a978a2a32d
14 изменённых файлов: 105 добавлений и 83 удалений

Просмотреть файл

@ -10,7 +10,7 @@
#include "nsCoreUtils.h"
#include "StyleInfo.h"
#include "gfxFont.h"
#include "gfxTextRun.h"
#include "nsFontMetrics.h"
#include "nsLayoutUtils.h"
#include "nsContainerFrame.h"

Просмотреть файл

@ -16,7 +16,7 @@
#include "nsPresContext.h"
#include "nsLayoutUtils.h"
#include "nsRange.h"
#include "gfxFont.h"
#include "gfxTextRun.h"
#include "nsIAccessibleTypes.h"
#include "mozilla/gfx/2D.h"

Просмотреть файл

@ -3744,7 +3744,8 @@ nsresult CanvasRenderingContext2D::DrawOrMeasureText(
processor.mFontgrp
->UpdateUserFonts(); // ensure user font generation is current
const gfxFont::Metrics& fontMetrics =
processor.mFontgrp->GetFirstValidFont()->GetMetrics(gfxFont::eHorizontal);
processor.mFontgrp->GetFirstValidFont()->GetMetrics(
nsFontMetrics::eHorizontal);
gfxFloat baselineAnchor;

Просмотреть файл

@ -8,9 +8,9 @@
#include <algorithm> // for max
#include "gfxASurface.h" // for gfxASurface, etc
#include "gfxContext.h"
#include "gfxFont.h" // for gfxFontGroup
#include "gfxImageSurface.h" // for gfxImageSurface
#include "gfxPoint.h" // for gfxSize
#include "gfxTextRun.h" // for gfxFontGroup
#include "mozilla/Attributes.h" // for final
#include "mozilla/gfx/PathHelpers.h"
#include "mozilla/gfx/PrintTarget.h"

Просмотреть файл

@ -11,6 +11,7 @@
#include "gfxPlatform.h" // for gfxPlatform
#include "gfxPoint.h" // for gfxPoint
#include "gfxRect.h" // for gfxRect
#include "gfxTextRun.h" // for gfxFontGroup
#include "gfxTypes.h" // for gfxFloat
#include "nsBoundingMetrics.h" // for nsBoundingMetrics
#include "nsDebug.h" // for NS_ERROR
@ -123,7 +124,7 @@ nsFontMetrics::nsFontMetrics(const nsFont& aFont, const Params& aParams,
aFont.synthesis & NS_FONT_SYNTHESIS_WEIGHT,
aFont.synthesis & NS_FONT_SYNTHESIS_STYLE, aFont.languageOverride);
aFont.AddFontFeaturesToStyle(&style, mOrientation == gfxFont::eVertical);
aFont.AddFontFeaturesToStyle(&style, mOrientation == eVertical);
style.featureValueLookup = aParams.featureValueLookup;
aFont.AddFontVariationsToStyle(&style);
@ -148,36 +149,42 @@ void nsFontMetrics::Destroy() { mDeviceContext = nullptr; }
#define ROUND_TO_TWIPS(x) (nscoord) floor(((x)*mP2A) + 0.5)
#define CEIL_TO_TWIPS(x) (nscoord) ceil((x)*mP2A)
const gfxFont::Metrics& nsFontMetrics::GetMetrics(
gfxFont::Orientation aOrientation) const {
return mFontGroup->GetFirstValidFont()->GetMetrics(aOrientation);
static const gfxFont::Metrics& GetMetrics(
nsFontMetrics* aFontMetrics, nsFontMetrics::FontOrientation aOrientation) {
return aFontMetrics->GetThebesFontGroup()->GetFirstValidFont()->GetMetrics(
aOrientation);
}
static const gfxFont::Metrics& GetMetrics(nsFontMetrics* aFontMetrics) {
return GetMetrics(aFontMetrics, aFontMetrics->Orientation());
}
nscoord nsFontMetrics::XHeight() {
return ROUND_TO_TWIPS(GetMetrics().xHeight);
return ROUND_TO_TWIPS(GetMetrics(this).xHeight);
}
nscoord nsFontMetrics::CapHeight() {
return ROUND_TO_TWIPS(GetMetrics().capHeight);
return ROUND_TO_TWIPS(GetMetrics(this).capHeight);
}
nscoord nsFontMetrics::SuperscriptOffset() {
return ROUND_TO_TWIPS(GetMetrics().emHeight *
return ROUND_TO_TWIPS(GetMetrics(this).emHeight *
NS_FONT_SUPERSCRIPT_OFFSET_RATIO);
}
nscoord nsFontMetrics::SubscriptOffset() {
return ROUND_TO_TWIPS(GetMetrics().emHeight * NS_FONT_SUBSCRIPT_OFFSET_RATIO);
return ROUND_TO_TWIPS(GetMetrics(this).emHeight *
NS_FONT_SUBSCRIPT_OFFSET_RATIO);
}
void nsFontMetrics::GetStrikeout(nscoord& aOffset, nscoord& aSize) {
aOffset = ROUND_TO_TWIPS(GetMetrics().strikeoutOffset);
aSize = ROUND_TO_TWIPS(GetMetrics().strikeoutSize);
aOffset = ROUND_TO_TWIPS(GetMetrics(this).strikeoutOffset);
aSize = ROUND_TO_TWIPS(GetMetrics(this).strikeoutSize);
}
void nsFontMetrics::GetUnderline(nscoord& aOffset, nscoord& aSize) {
aOffset = ROUND_TO_TWIPS(mFontGroup->GetUnderlineOffset());
aSize = ROUND_TO_TWIPS(GetMetrics().underlineSize);
aSize = ROUND_TO_TWIPS(GetMetrics(this).underlineSize);
}
// GetMaxAscent/GetMaxDescent/GetMaxHeight must contain the
@ -198,45 +205,45 @@ static gfxFloat ComputeMaxAscent(const gfxFont::Metrics& aMetrics) {
}
nscoord nsFontMetrics::InternalLeading() {
return ROUND_TO_TWIPS(GetMetrics().internalLeading);
return ROUND_TO_TWIPS(GetMetrics(this).internalLeading);
}
nscoord nsFontMetrics::ExternalLeading() {
return ROUND_TO_TWIPS(GetMetrics().externalLeading);
return ROUND_TO_TWIPS(GetMetrics(this).externalLeading);
}
nscoord nsFontMetrics::EmHeight() {
return ROUND_TO_TWIPS(GetMetrics().emHeight);
return ROUND_TO_TWIPS(GetMetrics(this).emHeight);
}
nscoord nsFontMetrics::EmAscent() {
return ROUND_TO_TWIPS(GetMetrics().emAscent);
return ROUND_TO_TWIPS(GetMetrics(this).emAscent);
}
nscoord nsFontMetrics::EmDescent() {
return ROUND_TO_TWIPS(GetMetrics().emDescent);
return ROUND_TO_TWIPS(GetMetrics(this).emDescent);
}
nscoord nsFontMetrics::MaxHeight() {
return CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics())) +
CEIL_TO_TWIPS(ComputeMaxDescent(GetMetrics(), mFontGroup));
return CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics(this))) +
CEIL_TO_TWIPS(ComputeMaxDescent(GetMetrics(this), mFontGroup));
}
nscoord nsFontMetrics::MaxAscent() {
return CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics()));
return CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics(this)));
}
nscoord nsFontMetrics::MaxDescent() {
return CEIL_TO_TWIPS(ComputeMaxDescent(GetMetrics(), mFontGroup));
return CEIL_TO_TWIPS(ComputeMaxDescent(GetMetrics(this), mFontGroup));
}
nscoord nsFontMetrics::MaxAdvance() {
return CEIL_TO_TWIPS(GetMetrics().maxAdvance);
return CEIL_TO_TWIPS(GetMetrics(this).maxAdvance);
}
nscoord nsFontMetrics::AveCharWidth() {
// Use CEIL instead of ROUND for consistency with GetMaxAdvance
return CEIL_TO_TWIPS(GetMetrics().aveCharWidth);
return CEIL_TO_TWIPS(GetMetrics(this).aveCharWidth);
}
nscoord nsFontMetrics::SpaceWidth() {
@ -244,15 +251,15 @@ nscoord nsFontMetrics::SpaceWidth() {
// width of a horizontal space (even if we're using vertical line-spacing
// metrics, as with "writing-mode:vertical-*;text-orientation:mixed").
return CEIL_TO_TWIPS(
GetMetrics(mVertical &&
mTextOrientation == NS_STYLE_TEXT_ORIENTATION_UPRIGHT
? gfxFont::eVertical
: gfxFont::eHorizontal)
GetMetrics(this, mVertical && mTextOrientation ==
NS_STYLE_TEXT_ORIENTATION_UPRIGHT
? eVertical
: eHorizontal)
.spaceWidth);
}
int32_t nsFontMetrics::GetMaxStringLength() {
const gfxFont::Metrics& m = GetMetrics();
const gfxFont::Metrics& m = GetMetrics(this);
const double x = 32767.0 / std::max(1.0, m.maxAdvance);
int32_t len = (int32_t)floor(x);
return std::max(1, len);
@ -268,7 +275,7 @@ nscoord nsFontMetrics::GetWidth(const char* aString, uint32_t aLength,
AutoTextRun textRun(this, aDrawTarget, aString, aLength);
if (textRun.get()) {
return NSToCoordRound(
textRun->GetAdvanceWidth(Range(0, aLength), &provider));
textRun->GetAdvanceWidth(gfxTextRun::Range(0, aLength), &provider));
}
return 0;
}
@ -283,7 +290,7 @@ nscoord nsFontMetrics::GetWidth(const char16_t* aString, uint32_t aLength,
AutoTextRun textRun(this, aDrawTarget, aString, aLength);
if (textRun.get()) {
return NSToCoordRound(
textRun->GetAdvanceWidth(Range(0, aLength), &provider));
textRun->GetAdvanceWidth(gfxTextRun::Range(0, aLength), &provider));
}
return 0;
}
@ -299,7 +306,7 @@ void nsFontMetrics::DrawString(const char* aString, uint32_t aLength,
return;
}
gfx::Point pt(aX, aY);
Range range(0, aLength);
gfxTextRun::Range range(0, aLength);
if (mTextRunRTL) {
if (mVertical) {
pt.y += textRun->GetAdvanceWidth(range, &provider);
@ -323,7 +330,7 @@ void nsFontMetrics::DrawString(const char16_t* aString, uint32_t aLength,
return;
}
gfx::Point pt(aX, aY);
Range range(0, aLength);
gfxTextRun::Range range(0, aLength);
if (mTextRunRTL) {
if (mVertical) {
pt.y += textRun->GetAdvanceWidth(range, &provider);
@ -369,3 +376,7 @@ nsBoundingMetrics nsFontMetrics::GetInkBoundsForVisualOverflow(
return GetTextBoundingMetrics(this, aString, aLength, aDrawTarget,
gfxFont::LOOSE_INK_EXTENTS);
}
gfxUserFontSet* nsFontMetrics::GetUserFontSet() const {
return mFontGroup->GetUserFontSet();
}

Просмотреть файл

@ -8,7 +8,6 @@
#include <stdint.h> // for uint32_t
#include <sys/types.h> // for int32_t
#include "gfxTextRun.h" // for gfxFont, gfxFontGroup
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
#include "mozilla/RefPtr.h" // for RefPtr
#include "nsCOMPtr.h" // for nsCOMPtr
@ -19,12 +18,19 @@
#include "nscore.h" // for char16_t
class gfxContext;
class gfxFontGroup;
class gfxUserFontSet;
class gfxTextPerfMetrics;
class nsDeviceContext;
class nsAtom;
struct nsBoundingMetrics;
namespace mozilla {
namespace gfx {
class DrawTarget;
} // namespace gfx
} // namespace mozilla
/**
* Font metrics
*
@ -45,13 +51,14 @@ struct nsBoundingMetrics;
*/
class nsFontMetrics final {
public:
typedef gfxTextRun::Range Range;
typedef mozilla::gfx::DrawTarget DrawTarget;
enum FontOrientation { eHorizontal, eVertical };
struct MOZ_STACK_CLASS Params {
nsAtom* language = nullptr;
bool explicitLanguage = false;
gfxFont::Orientation orientation = gfxFont::eHorizontal;
FontOrientation orientation = eHorizontal;
gfxUserFontSet* userFontSet = nullptr;
gfxTextPerfMetrics* textPerf = nullptr;
gfxFontFeatureValueSet* featureValueLookup = nullptr;
@ -184,7 +191,7 @@ class nsFontMetrics final {
/**
* Returns the orientation (horizontal/vertical) of these metrics.
*/
gfxFont::Orientation Orientation() const { return mOrientation; }
FontOrientation Orientation() const { return mOrientation; }
int32_t GetMaxStringLength();
@ -225,9 +232,7 @@ class nsFontMetrics final {
uint8_t GetTextOrientation() const { return mTextOrientation; }
gfxFontGroup* GetThebesFontGroup() const { return mFontGroup; }
gfxUserFontSet* GetUserFontSet() const {
return mFontGroup->GetUserFontSet();
}
gfxUserFontSet* GetUserFontSet() const;
int32_t AppUnitsPerDevPixel() const { return mP2A; }
@ -235,13 +240,6 @@ class nsFontMetrics final {
// Private destructor, to discourage deletion outside of Release():
~nsFontMetrics();
const gfxFont::Metrics& GetMetrics() const {
return GetMetrics(mOrientation);
}
const gfxFont::Metrics& GetMetrics(
const gfxFont::Orientation aFontOrientation) const;
nsFont mFont;
RefPtr<gfxFontGroup> mFontGroup;
RefPtr<nsAtom> mLanguage;
@ -253,7 +251,7 @@ class nsFontMetrics final {
// The font orientation (horizontal or vertical) for which these metrics
// have been initialized. This determines which line metrics (ascent and
// descent) they will return.
gfxFont::Orientation mOrientation;
FontOrientation mOrientation;
// These fields may be set by clients to control the behavior of methods
// like GetWidth and DrawString according to the writing mode, direction

Просмотреть файл

@ -536,7 +536,8 @@ double gfxFontconfigFontEntry::GetAspect() {
s.size = 100.0; // pick large size to avoid possible hinting artifacts
RefPtr<gfxFont> font = FindOrMakeFont(&s);
if (font) {
const gfxFont::Metrics& metrics = font->GetMetrics(gfxFont::eHorizontal);
const gfxFont::Metrics& metrics =
font->GetMetrics(nsFontMetrics::eHorizontal);
// The factor of 0.1 ensures that xHeight is sane so fonts don't
// become huge. Strictly ">" ensures that xHeight and emHeight are

Просмотреть файл

@ -635,7 +635,7 @@ void gfxShapedText::SetMissingGlyph(uint32_t aIndex, uint32_t aChar,
details->mAdvance = 0;
} else {
gfxFloat width =
std::max(aFont->GetMetrics(gfxFont::eHorizontal).aveCharWidth,
std::max(aFont->GetMetrics(nsFontMetrics::eHorizontal).aveCharWidth,
gfxFloat(gfxFontMissingGlyphs::GetDesiredMinWidth(
aChar, mAppUnitsPerDevUnit)));
details->mAdvance = uint32_t(width * mAppUnitsPerDevUnit);
@ -889,7 +889,7 @@ gfxFloat gfxFont::GetGlyphHAdvance(DrawTarget* aDrawTarget, uint16_t aGID) {
return GetGlyphWidth(aGID) / 65536.0;
}
if (mFUnitsConvFactor < 0.0f) {
GetMetrics(eHorizontal);
GetMetrics(nsFontMetrics::eHorizontal);
}
NS_ASSERTION(mFUnitsConvFactor >= 0.0f,
"missing font unit conversion factor");
@ -1970,7 +1970,7 @@ bool gfxFont::DrawMissingGlyph(const TextRunDrawParams& aRunParams,
Point pt(Float(ToDeviceUnits(aPt.x, aRunParams.devPerApp)),
Float(ToDeviceUnits(aPt.y, aRunParams.devPerApp)));
Float advanceDevUnits = Float(ToDeviceUnits(advance, aRunParams.devPerApp));
Float height = GetMetrics(eHorizontal).maxAscent;
Float height = GetMetrics(nsFontMetrics::eHorizontal).maxAscent;
// Horizontally center if drawing vertically upright with no sideways
// transform.
Rect glyphRect =
@ -2170,7 +2170,7 @@ void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd,
// those if available.
// [1] See http://www.microsoft.com/typography/otspec/base.htm
if (aTextRun->UseCenterBaseline()) {
const Metrics& metrics = GetMetrics(eHorizontal);
const Metrics& metrics = GetMetrics(nsFontMetrics::eHorizontal);
float baseAdj = (metrics.emAscent - metrics.emDescent) / 2;
baseline += baseAdj * aTextRun->GetAppUnitsPerDevUnit() * baselineDir;
}
@ -2411,14 +2411,15 @@ gfxFont::RunMetrics gfxFont::Measure(const gfxTextRun* aTextRun,
const int32_t appUnitsPerDevUnit = aTextRun->GetAppUnitsPerDevUnit();
// Current position in appunits
gfxFont::Orientation orientation =
Orientation orientation =
aOrientation == gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_UPRIGHT
? eVertical
: eHorizontal;
? nsFontMetrics::eVertical
: nsFontMetrics::eHorizontal;
const gfxFont::Metrics& fontMetrics = GetMetrics(orientation);
gfxFloat baselineOffset = 0;
if (aTextRun->UseCenterBaseline() && orientation == eHorizontal) {
if (aTextRun->UseCenterBaseline() &&
orientation == nsFontMetrics::eHorizontal) {
// For a horizontal font being used in vertical writing mode with
// text-orientation:mixed, the overall metrics we're accumulating
// will be aimed at a center baseline. But this font's metrics were
@ -2775,7 +2776,8 @@ void gfxFont::PostShapingFixup(DrawTarget* aDrawTarget, const char16_t* aText,
uint32_t aOffset, uint32_t aLength,
bool aVertical, gfxShapedText* aShapedText) {
if (IsSyntheticBold()) {
const Metrics& metrics = GetMetrics(aVertical ? eVertical : eHorizontal);
const Metrics& metrics = GetMetrics(aVertical ? nsFontMetrics::eVertical
: nsFontMetrics::eHorizontal);
if (metrics.maxAdvance > metrics.aveCharWidth) {
float synBoldOffset = GetSyntheticBoldOffset() * CalcXScale(aDrawTarget);
aShapedText->AdjustAdvancesForSyntheticBold(synBoldOffset, aOffset,
@ -3373,7 +3375,7 @@ void gfxFont::SetupGlyphExtents(DrawTarget* aDrawTarget, uint32_t aGlyphID,
aDrawTarget->GetGlyphRasterizationMetrics(sf, &glyphIndex, 1, &metrics);
}
const Metrics& fontMetrics = GetMetrics(eHorizontal);
const Metrics& fontMetrics = GetMetrics(nsFontMetrics::eHorizontal);
int32_t appUnitsPerDevUnit = aExtents->GetAppUnitsPerDevUnit();
if (!aNeedTight && metrics.mXBearing >= 0.0 &&
metrics.mYBearing >= -fontMetrics.maxAscent &&
@ -3818,9 +3820,11 @@ gfxFloat gfxFont::SynthesizeSpaceWidth(uint32_t aCh) {
case 0x2006:
return GetAdjustedSize() / 6; // six-per-em space
case 0x2007:
return GetMetrics(eHorizontal).ZeroOrAveCharWidth(); // figure space
return GetMetrics(nsFontMetrics::eHorizontal)
.ZeroOrAveCharWidth(); // figure space
case 0x2008:
return GetMetrics(eHorizontal).spaceWidth; // punctuation space
return GetMetrics(nsFontMetrics::eHorizontal)
.spaceWidth; // punctuation space
case 0x2009:
return GetAdjustedSize() / 5; // thin space
case 0x200a:

Просмотреть файл

@ -34,11 +34,11 @@
#include "harfbuzz/hb.h"
#include "mozilla/gfx/2D.h"
#include "nsColor.h"
#include "nsFontMetrics.h"
#include "mozilla/ServoUtils.h"
typedef struct _cairo cairo_t;
typedef struct _cairo_scaled_font cairo_scaled_font_t;
// typedef struct gr_face gr_face;
#ifdef DEBUG
# include <stdio.h>
@ -1548,10 +1548,10 @@ class gfxFont {
}
};
enum Orientation { eHorizontal, eVertical };
typedef nsFontMetrics::FontOrientation Orientation;
const Metrics& GetMetrics(Orientation aOrientation) {
if (aOrientation == eHorizontal) {
if (aOrientation == nsFontMetrics::eHorizontal) {
return GetHorizontalMetrics();
}
if (!mVerticalMetrics) {

Просмотреть файл

@ -310,7 +310,8 @@ hb_position_t gfxHarfBuzzShaper::GetGlyphVAdvance(hb_codepoint_t glyph) const {
if (!mVmtxTable) {
// Must be a "vertical" font that doesn't actually have vertical metrics;
// use a fixed advance.
return FloatToFixed(mFont->GetMetrics(gfxFont::eVertical).aveCharWidth);
return FloatToFixed(
mFont->GetMetrics(nsFontMetrics::eVertical).aveCharWidth);
}
NS_ASSERTION(mNumLongVMetrics > 0,
@ -473,7 +474,8 @@ void gfxHarfBuzzShaper::GetGlyphVOrigin(hb_codepoint_t aGlyph,
// Last resort, for non-sfnt fonts: get the horizontal metrics and
// compute a default VOrg from their ascent and descent.
const gfxFont::Metrics &mtx = mFont->GetHorizontalMetrics();
gfxFloat advance = mFont->GetMetrics(gfxFont::eVertical).aveCharWidth;
gfxFloat advance =
mFont->GetMetrics(nsFontMetrics::eVertical).aveCharWidth;
gfxFloat ascent = mtx.emAscent;
gfxFloat height = ascent + mtx.emDescent;
// vOrigin that will place the glyph so that its origin is shifted

Просмотреть файл

@ -1552,8 +1552,8 @@ bool gfxTextRun::SetSpaceGlyphIfSimple(gfxFont* aFont, uint32_t aCharIndex,
gfxFont::Orientation fontOrientation =
(aOrientation & gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_UPRIGHT)
? gfxFont::eVertical
: gfxFont::eHorizontal;
? nsFontMetrics::eVertical
: nsFontMetrics::eHorizontal;
uint32_t spaceWidthAppUnits = NS_lroundf(
aFont->GetMetrics(fontOrientation).spaceWidth * mAppUnitsPerDevUnit);
if (!CompressedGlyph::IsSimpleAdvance(spaceWidthAppUnits)) {
@ -2644,9 +2644,10 @@ gfxFloat gfxFontGroup::GetUnderlineOffset() {
if (!font) {
continue;
}
gfxFloat bad = font->GetMetrics(gfxFont::eHorizontal).underlineOffset;
gfxFloat bad =
font->GetMetrics(nsFontMetrics::eHorizontal).underlineOffset;
gfxFloat first = GetFirstValidFont()
->GetMetrics(gfxFont::eHorizontal)
->GetMetrics(nsFontMetrics::eHorizontal)
.underlineOffset;
mUnderlineOffset = std::min(first, bad);
return mUnderlineOffset;
@ -2654,8 +2655,9 @@ gfxFloat gfxFontGroup::GetUnderlineOffset() {
}
// no bad underline fonts, use the first valid font's metric
mUnderlineOffset =
GetFirstValidFont()->GetMetrics(gfxFont::eHorizontal).underlineOffset;
mUnderlineOffset = GetFirstValidFont()
->GetMetrics(nsFontMetrics::eHorizontal)
.underlineOffset;
}
return mUnderlineOffset;

Просмотреть файл

@ -4564,8 +4564,8 @@ already_AddRefed<nsFontMetrics> nsLayoutUtils::GetFontMetricsForComputedStyle(
params.language = styleFont->mLanguage;
params.explicitLanguage = styleFont->mExplicitLanguage;
params.orientation = wm.IsVertical() && !wm.IsSideways()
? gfxFont::eVertical
: gfxFont::eHorizontal;
? nsFontMetrics::eVertical
: nsFontMetrics::eHorizontal;
// pass the user font set object into the device context to
// pass along to CreateFontGroup
params.userFontSet = aPresContext->GetUserFontSet();
@ -9728,7 +9728,7 @@ already_AddRefed<nsFontMetrics> nsLayoutUtils::GetMetricsFor(
nsFont font = aStyleFont->mFont;
font.size = aFontSize;
gfxFont::Orientation orientation =
aIsVertical ? gfxFont::eVertical : gfxFont::eHorizontal;
aIsVertical ? nsFontMetrics::eVertical : nsFontMetrics::eHorizontal;
nsFontMetrics::Params params;
params.language = aStyleFont->mLanguage;
params.explicitLanguage = aStyleFont->mExplicitLanguage;

Просмотреть файл

@ -1725,8 +1725,8 @@ static gfxFont::Metrics GetFirstFontMetrics(gfxFontGroup* aFontGroup,
bool aVerticalMetrics) {
if (!aFontGroup) return gfxFont::Metrics();
gfxFont* font = aFontGroup->GetFirstValidFont();
return font->GetMetrics(aVerticalMetrics ? gfxFont::eVertical
: gfxFont::eHorizontal);
return font->GetMetrics(aVerticalMetrics ? nsFontMetrics::eVertical
: nsFontMetrics::eHorizontal);
}
static nscoord GetSpaceWidthAppUnits(const gfxTextRun* aTextRun) {
@ -6416,8 +6416,9 @@ void nsTextFrame::PaintTextSelectionDecorations(
const auto kDecoration = rightUnderline ? StyleTextDecorationLine_OVERLINE
: StyleTextDecorationLine_UNDERLINE;
bool useVerticalMetrics = verticalRun && mTextRun->UseCenterBaseline();
gfxFont::Metrics decorationMetrics(firstFont->GetMetrics(
useVerticalMetrics ? gfxFont::eVertical : gfxFont::eHorizontal));
gfxFont::Metrics decorationMetrics(
firstFont->GetMetrics(useVerticalMetrics ? nsFontMetrics::eVertical
: nsFontMetrics::eHorizontal));
if (!useVerticalMetrics) {
// The potential adjustment from using gfxFontGroup::GetUnderlineOffset
// is only valid for horizontal font metrics.
@ -7351,8 +7352,9 @@ bool nsTextFrame::CombineSelectionUnderlineRect(nsPresContext* aPresContext,
WritingMode wm = GetWritingMode();
bool verticalRun = wm.IsVertical();
bool useVerticalMetrics = verticalRun && !wm.IsSideways();
const gfxFont::Metrics& metrics = firstFont->GetMetrics(
useVerticalMetrics ? gfxFont::eVertical : gfxFont::eHorizontal);
const gfxFont::Metrics& metrics =
firstFont->GetMetrics(useVerticalMetrics ? nsFontMetrics::eVertical
: nsFontMetrics::eHorizontal);
nsCSSRendering::DecorationRectParams params;
params.ascent = aPresContext->AppUnitsToGfxUnits(mAscent);

Просмотреть файл

@ -11,6 +11,7 @@
#include <algorithm>
#include "gfxContext.h"
#include "gfxMathTable.h"
#include "gfxTextRun.h"
using namespace mozilla;