bug 1015603 part 3 - add a smallCaps field to gfxFontStyle, and pass it through from layout when creating gfxFontStyle records. r=roc

This commit is contained in:
Jonathan Kew 2014-05-26 14:23:31 +01:00
parent 3721023208
commit 1be74705a6
5 changed files with 15 additions and 4 deletions

View File

@ -2313,6 +2313,7 @@ CanvasRenderingContext2D::SetFont(const nsAString& font,
fontStyle->mFont.sizeAdjust,
fontStyle->mFont.systemFont,
printerFont,
fontStyle->mFont.variant == NS_STYLE_FONT_VARIANT_SMALL_CAPS,
fontStyle->mFont.languageOverride);
fontStyle->mFont.AddFontFeaturesToStyle(&style);

View File

@ -115,6 +115,7 @@ bool nsFont::BaseEquals(const nsFont& aOther) const
(synthesis == aOther.synthesis) &&
(fontFeatureSettings == aOther.fontFeatureSettings) &&
(languageOverride == aOther.languageOverride) &&
(variant == aOther.variant) &&
(variantAlternates == aOther.variantAlternates) &&
(variantCaps == aOther.variantCaps) &&
(variantEastAsian == aOther.variantEastAsian) &&
@ -132,7 +133,6 @@ bool nsFont::BaseEquals(const nsFont& aOther) const
bool nsFont::Equals(const nsFont& aOther) const
{
if (BaseEquals(aOther) &&
(variant == aOther.variant) &&
(decorations == aOther.decorations)) {
return true;
}

View File

@ -122,6 +122,7 @@ nsFontMetrics::Init(const nsFont& aFont, nsIAtom* aLanguage,
aFont.sizeAdjust,
aFont.systemFont,
mDeviceContext->IsPrinterSurface(),
aFont.variant == NS_STYLE_FONT_VARIANT_SMALL_CAPS,
aFont.languageOverride);
aFont.AddFontFeaturesToStyle(&style);

View File

@ -5981,6 +5981,7 @@ gfxFontStyle::gfxFontStyle() :
languageOverride(NO_FONT_LANGUAGE_OVERRIDE),
weight(NS_FONT_WEIGHT_NORMAL), stretch(NS_FONT_STRETCH_NORMAL),
systemFont(true), printerFont(false), useGrayscaleAntialiasing(false),
smallCaps(false),
style(NS_FONT_STYLE_NORMAL)
{
}
@ -5988,14 +5989,16 @@ gfxFontStyle::gfxFontStyle() :
gfxFontStyle::gfxFontStyle(uint8_t aStyle, uint16_t aWeight, int16_t aStretch,
gfxFloat aSize, nsIAtom *aLanguage,
float aSizeAdjust, bool aSystemFont,
bool aPrinterFont,
bool aPrinterFont, bool aSmallCaps,
const nsString& aLanguageOverride):
language(aLanguage),
size(aSize), sizeAdjust(aSizeAdjust),
languageOverride(ParseFontLanguageOverride(aLanguageOverride)),
weight(aWeight), stretch(aStretch),
systemFont(aSystemFont), printerFont(aPrinterFont),
useGrayscaleAntialiasing(false), style(aStyle)
useGrayscaleAntialiasing(false),
smallCaps(aSmallCaps),
style(aStyle)
{
MOZ_ASSERT(!mozilla::IsNaN(size));
MOZ_ASSERT(!mozilla::IsNaN(sizeAdjust));
@ -6027,6 +6030,7 @@ gfxFontStyle::gfxFontStyle(const gfxFontStyle& aStyle) :
weight(aStyle.weight), stretch(aStyle.stretch),
systemFont(aStyle.systemFont), printerFont(aStyle.printerFont),
useGrayscaleAntialiasing(aStyle.useGrayscaleAntialiasing),
smallCaps(aStyle.smallCaps),
style(aStyle.style)
{
featureSettings.AppendElements(aStyle.featureSettings);

View File

@ -74,7 +74,7 @@ struct gfxFontStyle {
gfxFontStyle(uint8_t aStyle, uint16_t aWeight, int16_t aStretch,
gfxFloat aSize, nsIAtom *aLanguage,
float aSizeAdjust, bool aSystemFont,
bool aPrinterFont,
bool aPrinterFont, bool aSmallCaps,
const nsString& aLanguageOverride);
gfxFontStyle(const gfxFontStyle& aStyle);
@ -139,6 +139,10 @@ struct gfxFontStyle {
// Used to imitate -webkit-font-smoothing: antialiased
bool useGrayscaleAntialiasing : 1;
// Font should render as small-caps, using OT feature if available,
// otherwise using a synthetic small-caps implementation
bool smallCaps : 1;
// The style of font (normal, italic, oblique)
uint8_t style : 2;
@ -163,6 +167,7 @@ struct gfxFontStyle {
(*reinterpret_cast<const uint64_t*>(&size) ==
*reinterpret_cast<const uint64_t*>(&other.size)) &&
(style == other.style) &&
(smallCaps == other.smallCaps) &&
(systemFont == other.systemFont) &&
(printerFont == other.printerFont) &&
(useGrayscaleAntialiasing == other.useGrayscaleAntialiasing) &&