зеркало из https://github.com/mozilla/gecko-dev.git
Implement CSS computation of font-stretch property and store it in the gfx font structures. (Bug 3512) r=vlad sr=bzbarsky
This commit is contained in:
Родитель
48f0a08ad3
Коммит
38d578f649
|
@ -1972,6 +1972,7 @@ nsCanvasRenderingContext2D::SetFont(const nsAString& font)
|
|||
|
||||
gfxFontStyle style(fontStyle->mFont.style,
|
||||
fontStyle->mFont.weight,
|
||||
fontStyle->mFont.stretch,
|
||||
NSAppUnitsToFloatPixels(fontSize, aupcp),
|
||||
langGroup,
|
||||
fontStyle->mFont.sizeAdjust,
|
||||
|
|
|
@ -68,7 +68,7 @@ struct NS_GFX nsFont {
|
|||
// The family name of the font
|
||||
nsString name;
|
||||
|
||||
// The style of font (normal, italic, oblique)
|
||||
// The style of font (normal, italic, oblique; see gfxFontConstants.h)
|
||||
PRUint8 style;
|
||||
|
||||
// Force this font to not be considered a 'generic' font, even if
|
||||
|
@ -82,9 +82,13 @@ struct NS_GFX nsFont {
|
|||
// "Wingdings", etc.) should be applied.
|
||||
PRUint8 familyNameQuirks;
|
||||
|
||||
// The weight of the font (0-999)
|
||||
// The weight of the font; see gfxFontConstants.h.
|
||||
PRUint16 weight;
|
||||
|
||||
// The stretch of the font (the sum of various NS_FONT_STRETCH_*
|
||||
// constants; see gfxFontConstants.h).
|
||||
PRInt16 stretch;
|
||||
|
||||
// The decorations on the font (underline, overline,
|
||||
// line-through). The decorations can be binary or'd together.
|
||||
PRUint8 decorations;
|
||||
|
@ -100,13 +104,13 @@ struct NS_GFX nsFont {
|
|||
|
||||
// Initialize the font struct with an ASCII name
|
||||
nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
|
||||
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
|
||||
float aSizeAdjust=0.0f);
|
||||
PRUint16 aWeight, PRInt16 aStretch, PRUint8 aDecoration,
|
||||
nscoord aSize, float aSizeAdjust=0.0f);
|
||||
|
||||
// Initialize the font struct with a (potentially) unicode name
|
||||
nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
|
||||
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
|
||||
float aSizeAdjust=0.0f);
|
||||
PRUint16 aWeight, PRInt16 aStretch, PRUint8 aDecoration,
|
||||
nscoord aSize, float aSizeAdjust=0.0f);
|
||||
|
||||
// Make a copy of the given font
|
||||
nsFont(const nsFont& aFont);
|
||||
|
|
|
@ -41,8 +41,8 @@
|
|||
#include "nsCRT.h"
|
||||
|
||||
nsFont::nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
|
||||
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
|
||||
float aSizeAdjust)
|
||||
PRUint16 aWeight, PRInt16 aStretch, PRUint8 aDecoration,
|
||||
nscoord aSize, float aSizeAdjust)
|
||||
{
|
||||
NS_ASSERTION(aName && IsASCII(nsDependentCString(aName)),
|
||||
"Must only pass ASCII names here");
|
||||
|
@ -52,14 +52,15 @@ nsFont::nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
|
|||
variant = aVariant;
|
||||
familyNameQuirks = PR_FALSE;
|
||||
weight = aWeight;
|
||||
stretch = aStretch;
|
||||
decorations = aDecoration;
|
||||
size = aSize;
|
||||
sizeAdjust = aSizeAdjust;
|
||||
}
|
||||
|
||||
nsFont::nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
|
||||
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
|
||||
float aSizeAdjust)
|
||||
PRUint16 aWeight, PRInt16 aStretch, PRUint8 aDecoration,
|
||||
nscoord aSize, float aSizeAdjust)
|
||||
: name(aName)
|
||||
{
|
||||
style = aStyle;
|
||||
|
@ -67,6 +68,7 @@ nsFont::nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
|
|||
variant = aVariant;
|
||||
familyNameQuirks = PR_FALSE;
|
||||
weight = aWeight;
|
||||
stretch = aStretch;
|
||||
decorations = aDecoration;
|
||||
size = aSize;
|
||||
sizeAdjust = aSizeAdjust;
|
||||
|
@ -80,6 +82,7 @@ nsFont::nsFont(const nsFont& aOther)
|
|||
variant = aOther.variant;
|
||||
familyNameQuirks = aOther.familyNameQuirks;
|
||||
weight = aOther.weight;
|
||||
stretch = aOther.stretch;
|
||||
decorations = aOther.decorations;
|
||||
size = aOther.size;
|
||||
sizeAdjust = aOther.sizeAdjust;
|
||||
|
@ -99,6 +102,7 @@ PRBool nsFont::BaseEquals(const nsFont& aOther) const
|
|||
(systemFont == aOther.systemFont) &&
|
||||
(familyNameQuirks == aOther.familyNameQuirks) &&
|
||||
(weight == aOther.weight) &&
|
||||
(stretch == aOther.stretch) &&
|
||||
(size == aOther.size) &&
|
||||
(sizeAdjust == aOther.sizeAdjust) &&
|
||||
name.Equals(aOther.name, nsCaseInsensitiveStringComparator())) {
|
||||
|
@ -125,6 +129,7 @@ nsFont& nsFont::operator=(const nsFont& aOther)
|
|||
variant = aOther.variant;
|
||||
familyNameQuirks = aOther.familyNameQuirks;
|
||||
weight = aOther.weight;
|
||||
stretch = aOther.stretch;
|
||||
decorations = aOther.decorations;
|
||||
size = aOther.size;
|
||||
sizeAdjust = aOther.sizeAdjust;
|
||||
|
|
|
@ -106,6 +106,7 @@ nsSystemFontsBeOS::GetSystemFontInfo(const BFont *theFont, nsString *aFontName,
|
|||
aFontStyle->style = FONT_STYLE_NORMAL;
|
||||
aFontStyle->weight = FONT_WEIGHT_NORMAL;
|
||||
aFontStyle->decorations = FONT_DECORATION_NONE;
|
||||
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
|
||||
|
||||
font_family family;
|
||||
theFont->GetFamilyAndStyle(&family, NULL);
|
||||
|
@ -120,6 +121,8 @@ nsSystemFontsBeOS::GetSystemFontInfo(const BFont *theFont, nsString *aFontName,
|
|||
if (face & B_BOLD_FACE)
|
||||
aFontStyle->weight = FONT_WEIGHT_BOLD;
|
||||
|
||||
// FIXME: Set aFontStyle->stretch correctly!
|
||||
|
||||
if (face & B_UNDERSCORE_FACE)
|
||||
aFontStyle->decorations |= FONT_DECORATION_UNDERLINE;
|
||||
|
||||
|
|
|
@ -213,6 +213,9 @@ nsSystemFontsGTK2::GetSystemFontInfo(GtkWidget *aWidget, nsString *aFontName,
|
|||
|
||||
aFontStyle->weight = pango_font_description_get_weight(desc);
|
||||
|
||||
// FIXME: Set aFontStyle->stretch correctly!
|
||||
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
|
||||
|
||||
float size = float(pango_font_description_get_size(desc) / PANGO_SCALE);
|
||||
|
||||
// |size| is now either pixels or pango-points (not Mozilla-points!)
|
||||
|
|
|
@ -116,6 +116,7 @@ nsSystemFontsMac::GetSystemFont(nsSystemFontID aID, nsString *aFontName,
|
|||
{
|
||||
aFontStyle->style = FONT_STYLE_NORMAL;
|
||||
aFontStyle->weight = FONT_WEIGHT_NORMAL;
|
||||
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
|
||||
|
||||
aFontName->AssignLiteral("sans-serif");
|
||||
aFontStyle->size = 14;
|
||||
|
@ -182,6 +183,7 @@ nsSystemFontsMac::GetSystemFont(nsSystemFontID aID, nsString *aFontName,
|
|||
aFontStyle->weight = FONT_WEIGHT_BOLD;
|
||||
if (fontStyle & italic)
|
||||
aFontStyle->style = FONT_STYLE_ITALIC;
|
||||
// FIXME: Set aFontStyle->stretch correctly!
|
||||
|
||||
aFontStyle->systemFont = PR_TRUE;
|
||||
|
||||
|
|
|
@ -221,6 +221,9 @@ nsresult nsSystemFontsOS2::GetSystemFont(nsSystemFontID aID, nsString* aFontName
|
|||
aFontStyle->weight = FONT_WEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
// FIXME: Set aFontStyle->stretch correctly!
|
||||
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
|
||||
|
||||
// similar hopes for italic and oblique fonts...
|
||||
NS_NAMED_LITERAL_CSTRING(spcItalic, " Italic");
|
||||
NS_NAMED_LITERAL_CSTRING(spcOblique, " Oblique");
|
||||
|
|
|
@ -77,6 +77,8 @@ nsSystemFontsQt::GetSystemFontInfo(const char *aClassName, nsString *aFontName,
|
|||
nsString family((PRUnichar*)qFont.family().data());
|
||||
*aFontName = quote + family + quote;
|
||||
aFontStyle->weight = qFont.weight();
|
||||
// FIXME: Set aFontStyle->stretch correctly!
|
||||
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
|
||||
aFontStyle->size = qFont.pointSizeF() * float(gfxQtPlatform::DPI()) / 72.0f;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -64,6 +64,9 @@ nsresult nsSystemFontsWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONTW* ptrLog
|
|||
aFontStyle->weight = (ptrLogFont->lfWeight == FW_BOLD ?
|
||||
FONT_WEIGHT_BOLD : FONT_WEIGHT_NORMAL);
|
||||
|
||||
// FIXME: Set aFontStyle->stretch correctly!
|
||||
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
|
||||
|
||||
// XXX mPixelScale is currently hardcoded to 1 in thebes gfx...
|
||||
float mPixelScale = 1.0f;
|
||||
// Do Point Size
|
||||
|
|
|
@ -428,6 +428,7 @@ nsThebesDeviceContext::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const
|
|||
aFont->variant = NS_FONT_VARIANT_NORMAL;
|
||||
aFont->familyNameQuirks = fontStyle.familyNameQuirks;
|
||||
aFont->weight = fontStyle.weight;
|
||||
aFont->stretch = fontStyle.stretch;
|
||||
aFont->decorations = NS_FONT_DECORATION_NONE;
|
||||
aFont->size = NSFloatPixelsToAppUnits(fontStyle.size, UnscaledAppUnitsPerDevPixel());
|
||||
//aFont->langGroup = fontStyle.langGroup;
|
||||
|
|
|
@ -84,7 +84,8 @@ nsThebesFontMetrics::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
|||
}
|
||||
|
||||
PRBool printerFont = mDeviceContext->IsPrinterSurface();
|
||||
mFontStyle = new gfxFontStyle(aFont.style, aFont.weight, size, langGroup,
|
||||
mFontStyle = new gfxFontStyle(aFont.style, aFont.weight, aFont.stretch,
|
||||
size, langGroup,
|
||||
aFont.sizeAdjust, aFont.systemFont,
|
||||
aFont.familyNameQuirks,
|
||||
printerFont);
|
||||
|
|
|
@ -78,8 +78,8 @@ class gfxUserFontData;
|
|||
|
||||
struct THEBES_API gfxFontStyle {
|
||||
gfxFontStyle();
|
||||
gfxFontStyle(PRUint8 aStyle, PRUint16 aWeight, gfxFloat aSize,
|
||||
const nsACString& aLangGroup,
|
||||
gfxFontStyle(PRUint8 aStyle, PRUint16 aWeight, PRInt16 aStretch,
|
||||
gfxFloat aSize, const nsACString& aLangGroup,
|
||||
float aSizeAdjust, PRPackedBool aSystemFont,
|
||||
PRPackedBool aFamilyNameQuirks,
|
||||
PRPackedBool aPrinterFont);
|
||||
|
@ -107,6 +107,10 @@ struct THEBES_API gfxFontStyle {
|
|||
// font being used, since it is two weights lighter than 900.
|
||||
PRUint16 weight;
|
||||
|
||||
// The stretch of the font (the sum of various NS_FONT_STRETCH_*
|
||||
// constants; see gfxFontConstants.h).
|
||||
PRInt16 stretch;
|
||||
|
||||
// The logical size of the font, in pixels
|
||||
gfxFloat size;
|
||||
|
||||
|
@ -143,6 +147,7 @@ struct THEBES_API gfxFontStyle {
|
|||
(printerFont == other.printerFont) &&
|
||||
(familyNameQuirks == other.familyNameQuirks) &&
|
||||
(weight == other.weight) &&
|
||||
(stretch == other.stretch) &&
|
||||
(langGroup.Equals(other.langGroup)) &&
|
||||
(sizeAdjust == other.sizeAdjust);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,20 @@
|
|||
#define NS_FONT_WEIGHT_NORMAL 400
|
||||
#define NS_FONT_WEIGHT_BOLD 700
|
||||
#define NS_FONT_WEIGHT_BOLDER 1
|
||||
#define NS_FONT_WEIGHT_LIGHTER -1
|
||||
#define NS_FONT_WEIGHT_LIGHTER (-1)
|
||||
|
||||
#define NS_FONT_STRETCH_ULTRA_CONDENSED (-4)
|
||||
#define NS_FONT_STRETCH_EXTRA_CONDENSED (-3)
|
||||
#define NS_FONT_STRETCH_CONDENSED (-2)
|
||||
#define NS_FONT_STRETCH_SEMI_CONDENSED (-1)
|
||||
#define NS_FONT_STRETCH_NORMAL 0
|
||||
#define NS_FONT_STRETCH_SEMI_EXPANDED 1
|
||||
#define NS_FONT_STRETCH_EXPANDED 2
|
||||
#define NS_FONT_STRETCH_EXTRA_EXPANDED 3
|
||||
#define NS_FONT_STRETCH_ULTRA_EXPANDED 4
|
||||
// These need to be more than double all of the values above so that we
|
||||
// can add any multiple of any of these values to the values above.
|
||||
#define NS_FONT_STRETCH_WIDER 10
|
||||
#define NS_FONT_STRETCH_NARROWER (-10)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1228,18 +1228,19 @@ gfxFontGroup::GetGeneration()
|
|||
|
||||
gfxFontStyle::gfxFontStyle() :
|
||||
style(FONT_STYLE_NORMAL), systemFont(PR_TRUE), printerFont(PR_FALSE),
|
||||
familyNameQuirks(PR_FALSE), weight(FONT_WEIGHT_NORMAL), size(DEFAULT_PIXEL_FONT_SIZE),
|
||||
familyNameQuirks(PR_FALSE), weight(FONT_WEIGHT_NORMAL),
|
||||
stretch(NS_FONT_STRETCH_NORMAL), size(DEFAULT_PIXEL_FONT_SIZE),
|
||||
langGroup(NS_LITERAL_CSTRING("x-western")), sizeAdjust(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
gfxFontStyle::gfxFontStyle(PRUint8 aStyle, PRUint16 aWeight, gfxFloat aSize,
|
||||
const nsACString& aLangGroup,
|
||||
gfxFontStyle::gfxFontStyle(PRUint8 aStyle, PRUint16 aWeight, PRInt16 aStretch,
|
||||
gfxFloat aSize, const nsACString& aLangGroup,
|
||||
float aSizeAdjust, PRPackedBool aSystemFont,
|
||||
PRPackedBool aFamilyNameQuirks,
|
||||
PRPackedBool aPrinterFont):
|
||||
style(aStyle), systemFont(aSystemFont), printerFont(aPrinterFont),
|
||||
familyNameQuirks(aFamilyNameQuirks), weight(aWeight),
|
||||
familyNameQuirks(aFamilyNameQuirks), weight(aWeight), stretch(aStretch),
|
||||
size(aSize), langGroup(aLangGroup), sizeAdjust(aSizeAdjust)
|
||||
{
|
||||
if (weight > 900)
|
||||
|
@ -1264,7 +1265,7 @@ gfxFontStyle::gfxFontStyle(PRUint8 aStyle, PRUint16 aWeight, gfxFloat aSize,
|
|||
gfxFontStyle::gfxFontStyle(const gfxFontStyle& aStyle) :
|
||||
style(aStyle.style), systemFont(aStyle.systemFont), printerFont(aStyle.printerFont),
|
||||
familyNameQuirks(aStyle.familyNameQuirks), weight(aStyle.weight),
|
||||
size(aStyle.size), langGroup(aStyle.langGroup),
|
||||
stretch(aStyle.stretch), size(aStyle.size), langGroup(aStyle.langGroup),
|
||||
sizeAdjust(aStyle.sizeAdjust)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -2245,7 +2245,9 @@ gfxFcFont::GetOrMakeFont(FcPattern *aPattern)
|
|||
// one particular language to choose and converting the set to a
|
||||
// string through FcNameUnparse() is more trouble than it's worth.
|
||||
NS_NAMED_LITERAL_CSTRING(langGroup, "x-unicode");
|
||||
gfxFontStyle fontStyle(style, weight, size, langGroup, 0.0,
|
||||
// FIXME: Pass a real stretch based on aPattern!
|
||||
gfxFontStyle fontStyle(style, weight, NS_FONT_STRETCH_NORMAL,
|
||||
size, langGroup, 0.0,
|
||||
PR_TRUE, PR_FALSE, PR_FALSE);
|
||||
|
||||
nsRefPtr<gfxFontEntry> fe;
|
||||
|
|
|
@ -106,6 +106,7 @@ SetupTests()
|
|||
|
||||
/* some common styles */
|
||||
gfxFontStyle style_western_normal_16 (FONT_STYLE_NORMAL,
|
||||
NS_FONT_STRETCH_NORMAL,
|
||||
400,
|
||||
16.0,
|
||||
nsDependentCString("x-western"),
|
||||
|
@ -113,6 +114,7 @@ SetupTests()
|
|||
PR_FALSE, PR_FALSE, PR_FALSE);
|
||||
|
||||
gfxFontStyle style_western_bold_16 (FONT_STYLE_NORMAL,
|
||||
NS_FONT_STRETCH_NORMAL,
|
||||
700,
|
||||
16.0,
|
||||
nsDependentCString("x-western"),
|
||||
|
|
|
@ -90,6 +90,7 @@ void
|
|||
RunTest (TestEntry *test, gfxContext *ctx) {
|
||||
if (!lastFamilies || strcmp(lastFamilies, test->mFamilies)) {
|
||||
gfxFontStyle style_western_normal_16 (FONT_STYLE_NORMAL,
|
||||
NS_FONT_STRETCH_NORMAL,
|
||||
400,
|
||||
16.0,
|
||||
nsDependentCString("x-western"),
|
||||
|
|
|
@ -156,6 +156,7 @@ main (int argc, char **argv) {
|
|||
nsRefPtr<gfxContext> ctx = MakeContext();
|
||||
{
|
||||
gfxFontStyle style (FONT_STYLE_NORMAL,
|
||||
NS_FONT_STRETCH_NORMAL,
|
||||
139,
|
||||
10.0,
|
||||
nsDependentCString("x-western"),
|
||||
|
|
|
@ -178,19 +178,24 @@ nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType)
|
|||
mImageAnimationModePref(imgIContainer::kNormalAnimMode),
|
||||
// Font sizes default to zero; they will be set in GetFontPreferences
|
||||
mDefaultVariableFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
||||
NS_FONT_WEIGHT_NORMAL, 0, 0),
|
||||
NS_FONT_WEIGHT_NORMAL, NS_FONT_STRETCH_NORMAL, 0, 0),
|
||||
mDefaultFixedFont("monospace", NS_FONT_STYLE_NORMAL,
|
||||
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, 0),
|
||||
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL,
|
||||
NS_FONT_STRETCH_NORMAL, 0, 0),
|
||||
mDefaultSerifFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
||||
NS_FONT_WEIGHT_NORMAL, 0, 0),
|
||||
NS_FONT_WEIGHT_NORMAL, NS_FONT_STRETCH_NORMAL, 0, 0),
|
||||
mDefaultSansSerifFont("sans-serif", NS_FONT_STYLE_NORMAL,
|
||||
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, 0),
|
||||
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL,
|
||||
NS_FONT_STRETCH_NORMAL, 0, 0),
|
||||
mDefaultMonospaceFont("monospace", NS_FONT_STYLE_NORMAL,
|
||||
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, 0),
|
||||
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL,
|
||||
NS_FONT_STRETCH_NORMAL, 0, 0),
|
||||
mDefaultCursiveFont("cursive", NS_FONT_STYLE_NORMAL,
|
||||
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, 0),
|
||||
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL,
|
||||
NS_FONT_STRETCH_NORMAL, 0, 0),
|
||||
mDefaultFantasyFont("fantasy", NS_FONT_STYLE_NORMAL,
|
||||
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, 0),
|
||||
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL,
|
||||
NS_FONT_STRETCH_NORMAL, 0, 0),
|
||||
mCanPaginatedScroll(PR_FALSE),
|
||||
mIsRootPaginatedDocument(PR_FALSE), mSupressResizeReflow(PR_FALSE)
|
||||
{
|
||||
|
|
|
@ -7693,7 +7693,7 @@ void ReflowCountMgr::PaintCount(const char * aName,
|
|||
if (counter != nsnull && counter->mName.EqualsASCII(aName)) {
|
||||
aRenderingContext->PushState();
|
||||
nsFont font("Times", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
||||
NS_FONT_WEIGHT_NORMAL, 0,
|
||||
NS_FONT_WEIGHT_NORMAL, NS_FONT_STRETCH_NORMAL, 0,
|
||||
nsPresContext::CSSPixelsToAppUnits(11));
|
||||
|
||||
nsCOMPtr<nsIFontMetrics> fm = aPresContext->GetMetricsFor(font);
|
||||
|
|
|
@ -438,17 +438,18 @@
|
|||
#define NS_STYLE_FONT_SIZE_SMALLER 9
|
||||
|
||||
// See nsStyleFont
|
||||
#define NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED -4
|
||||
#define NS_STYLE_FONT_STRETCH_EXTRA_CONDENSED -3
|
||||
#define NS_STYLE_FONT_STRETCH_CONDENSED -2
|
||||
#define NS_STYLE_FONT_STRETCH_SEMI_CONDENSED -1
|
||||
#define NS_STYLE_FONT_STRETCH_NORMAL 0
|
||||
#define NS_STYLE_FONT_STRETCH_SEMI_EXPANDED 1
|
||||
#define NS_STYLE_FONT_STRETCH_EXPANDED 2
|
||||
#define NS_STYLE_FONT_STRETCH_EXTRA_EXPANDED 3
|
||||
#define NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED 4
|
||||
#define NS_STYLE_FONT_STRETCH_WIDER 10
|
||||
#define NS_STYLE_FONT_STRETCH_NARROWER -10
|
||||
// We should eventually stop using the NS_STYLE_* variants here.
|
||||
#define NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED NS_FONT_STRETCH_ULTRA_CONDENSED
|
||||
#define NS_STYLE_FONT_STRETCH_EXTRA_CONDENSED NS_FONT_STRETCH_EXTRA_CONDENSED
|
||||
#define NS_STYLE_FONT_STRETCH_CONDENSED NS_FONT_STRETCH_CONDENSED
|
||||
#define NS_STYLE_FONT_STRETCH_SEMI_CONDENSED NS_FONT_STRETCH_SEMI_CONDENSED
|
||||
#define NS_STYLE_FONT_STRETCH_NORMAL NS_FONT_STRETCH_NORMAL
|
||||
#define NS_STYLE_FONT_STRETCH_SEMI_EXPANDED NS_FONT_STRETCH_SEMI_EXPANDED
|
||||
#define NS_STYLE_FONT_STRETCH_EXPANDED NS_FONT_STRETCH_EXPANDED
|
||||
#define NS_STYLE_FONT_STRETCH_EXTRA_EXPANDED NS_FONT_STRETCH_EXTRA_EXPANDED
|
||||
#define NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED NS_FONT_STRETCH_ULTRA_EXPANDED
|
||||
#define NS_STYLE_FONT_STRETCH_WIDER NS_FONT_STRETCH_WIDER
|
||||
#define NS_STYLE_FONT_STRETCH_NARROWER NS_FONT_STRETCH_NARROWER
|
||||
|
||||
// See nsStyleFont - system fonts
|
||||
#define NS_STYLE_FONT_CAPTION 1 // css2
|
||||
|
|
|
@ -806,7 +806,7 @@ InitGlobals(nsPresContext* aPresContext)
|
|||
// stretchy characters.
|
||||
// We just want to iterate over the font-family list using the
|
||||
// callback mechanism that nsFont has...
|
||||
nsFont font("", 0, 0, 0, 0, 0);
|
||||
nsFont font("", 0, 0, 0, 0, 0, 0);
|
||||
NS_NAMED_LITERAL_CSTRING(defaultKey, "font.mathfont-glyph-tables");
|
||||
rv = mathfontProp->GetStringProperty(defaultKey, font.name);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
|
|
@ -5742,7 +5742,7 @@ CSSParserImpl::ParseFontDescriptorValue(nsCSSFontDesc aDescID,
|
|||
// because it's only being used to call EnumerateFamilies
|
||||
nsAutoString valueStr;
|
||||
aValue.GetStringValue(valueStr);
|
||||
nsFont font(valueStr, 0, 0, 0, 0, 0);
|
||||
nsFont font(valueStr, 0, 0, 0, 0, 0, 0);
|
||||
ExtractFirstFamilyData dat;
|
||||
|
||||
font.EnumerateFamilies(ExtractFirstFamily, (void*) &dat);
|
||||
|
@ -7306,7 +7306,7 @@ CSSParserImpl::ParseFontSrc(nsCSSValue& aValue)
|
|||
|
||||
// the style parameters to the nsFont constructor are ignored,
|
||||
// because it's only being used to call EnumerateFamilies
|
||||
nsFont font(family, 0, 0, 0, 0, 0);
|
||||
nsFont font(family, 0, 0, 0, 0, 0, 0);
|
||||
ExtractFirstFamilyData dat;
|
||||
|
||||
font.EnumerateFamilies(ExtractFirstFamily, (void*) &dat);
|
||||
|
|
|
@ -420,7 +420,7 @@ CSS_PROP_SHORTHAND(font, font, Font, 0)
|
|||
CSS_PROP_FONT(font-family, font_family, FontFamily, CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE, Font, mFamily, eCSSType_Value, nsnull)
|
||||
CSS_PROP_FONT(font-size, font_size, FontSize, CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE, Font, mSize, eCSSType_Value, kFontSizeKTable)
|
||||
CSS_PROP_FONT(font-size-adjust, font_size_adjust, FontSizeAdjust, CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE, Font, mSizeAdjust, eCSSType_Value, nsnull)
|
||||
CSS_PROP_BACKENDONLY(font-stretch, font_stretch, FontStretch, CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE, Font, mStretch, eCSSType_Value, kFontStretchKTable)
|
||||
CSS_PROP_FONT(font-stretch, font_stretch, FontStretch, CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE, Font, mStretch, eCSSType_Value, kFontStretchKTable)
|
||||
CSS_PROP_FONT(font-style, font_style, FontStyle, CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE, Font, mStyle, eCSSType_Value, kFontStyleKTable)
|
||||
CSS_PROP_FONT(font-variant, font_variant, FontVariant, CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE, Font, mVariant, eCSSType_Value, kFontVariantKTable)
|
||||
CSS_PROP_FONT(font-weight, font_weight, FontWeight, CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE, Font, mWeight, eCSSType_Value, kFontWeightKTable)
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
#include "nsInspectorCSSUtils.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsFrameManager.h"
|
||||
#include "prlog.h"
|
||||
#include "nsCSSKeywords.h"
|
||||
#include "nsStyleCoord.h"
|
||||
#include "nsDisplayList.h"
|
||||
|
@ -1088,6 +1089,36 @@ nsComputedDOMStyle::GetFontSizeAdjust(nsIDOMCSSValue** aValue)
|
|||
return CallQueryInterface(val, aValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComputedDOMStyle::GetFontStretch(nsIDOMCSSValue** aValue)
|
||||
{
|
||||
nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
|
||||
NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
const nsStyleFont* font = GetStyleFont();
|
||||
|
||||
// The computed value space isn't actually representable in string
|
||||
// form, so just represent anything with widers or narrowers in it as
|
||||
// 'wider' or 'narrower'.
|
||||
PR_STATIC_ASSERT(NS_FONT_STRETCH_NARROWER % 2 == 0);
|
||||
PR_STATIC_ASSERT(NS_FONT_STRETCH_WIDER % 2 == 0);
|
||||
PR_STATIC_ASSERT(NS_FONT_STRETCH_NARROWER + NS_FONT_STRETCH_WIDER == 0);
|
||||
PR_STATIC_ASSERT(NS_FONT_STRETCH_NARROWER < 0);
|
||||
PRInt16 stretch = font->mFont.stretch;
|
||||
if (stretch == NS_FONT_STRETCH_NORMAL) {
|
||||
val->SetIdent(eCSSKeyword_normal);
|
||||
} else if (stretch <= NS_FONT_STRETCH_NARROWER / 2) {
|
||||
val->SetIdent(eCSSKeyword_narrower);
|
||||
} else if (stretch >= NS_FONT_STRETCH_WIDER / 2) {
|
||||
val->SetIdent(eCSSKeyword_wider);
|
||||
} else {
|
||||
val->SetIdent(
|
||||
nsCSSProps::ValueToKeywordEnum(stretch, nsCSSProps::kFontStretchKTable));
|
||||
}
|
||||
|
||||
return CallQueryInterface(val, aValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComputedDOMStyle::GetFontStyle(nsIDOMCSSValue** aValue)
|
||||
{
|
||||
|
@ -1114,6 +1145,7 @@ nsComputedDOMStyle::GetFontWeight(nsIDOMCSSValue** aValue)
|
|||
|
||||
const nsStyleFont* font = GetStyleFont();
|
||||
|
||||
// XXX This doesn't deal with bolder/lighter very well.
|
||||
const nsCSSKeyword enum_weight =
|
||||
nsCSSProps::ValueToKeywordEnum(font->mFont.weight,
|
||||
nsCSSProps::kFontWeightKTable);
|
||||
|
@ -4025,7 +4057,7 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength)
|
|||
COMPUTED_STYLE_MAP_ENTRY(font_family, FontFamily),
|
||||
COMPUTED_STYLE_MAP_ENTRY(font_size, FontSize),
|
||||
COMPUTED_STYLE_MAP_ENTRY(font_size_adjust, FontSizeAdjust),
|
||||
// COMPUTED_STYLE_MAP_ENTRY(font_stretch, FontStretch),
|
||||
COMPUTED_STYLE_MAP_ENTRY(font_stretch, FontStretch),
|
||||
COMPUTED_STYLE_MAP_ENTRY(font_style, FontStyle),
|
||||
COMPUTED_STYLE_MAP_ENTRY(font_variant, FontVariant),
|
||||
COMPUTED_STYLE_MAP_ENTRY(font_weight, FontWeight),
|
||||
|
|
|
@ -146,9 +146,10 @@ private:
|
|||
/* Font properties */
|
||||
nsresult GetColor(nsIDOMCSSValue** aValue);
|
||||
nsresult GetFontFamily(nsIDOMCSSValue** aValue);
|
||||
nsresult GetFontStyle(nsIDOMCSSValue** aValue);
|
||||
nsresult GetFontSize(nsIDOMCSSValue** aValue);
|
||||
nsresult GetFontSizeAdjust(nsIDOMCSSValue** aValue);
|
||||
nsresult GetFontStretch(nsIDOMCSSValue** aValue);
|
||||
nsresult GetFontStyle(nsIDOMCSSValue** aValue);
|
||||
nsresult GetFontWeight(nsIDOMCSSValue** aValue);
|
||||
nsresult GetFontVariant(nsIDOMCSSValue** aValue);
|
||||
|
||||
|
|
|
@ -913,10 +913,11 @@ CheckFontCallback(const nsRuleDataStruct& aData,
|
|||
|
||||
// em, ex, percent, 'larger', and 'smaller' values on font-size depend
|
||||
// on the parent context's font-size
|
||||
// Likewise, 'lighter' and 'bolder' values of 'font-weight' depend on
|
||||
// the parent.
|
||||
// Likewise, 'lighter' and 'bolder' values of 'font-weight', and 'wider'
|
||||
// and 'narrower' values of 'font-stretch' depend on the parent.
|
||||
const nsCSSValue& size = fontData.mSize;
|
||||
const nsCSSValue& weight = fontData.mWeight;
|
||||
const nsCSSValue& stretch = fontData.mStretch;
|
||||
if ((size.IsRelativeLengthUnit() && size.GetUnit() != eCSSUnit_Pixel) ||
|
||||
size.GetUnit() == eCSSUnit_Percent ||
|
||||
(size.GetUnit() == eCSSUnit_Enumerated &&
|
||||
|
@ -925,6 +926,9 @@ CheckFontCallback(const nsRuleDataStruct& aData,
|
|||
#ifdef MOZ_MATHML
|
||||
fontData.mScriptLevel.GetUnit() == eCSSUnit_Integer ||
|
||||
#endif
|
||||
(stretch.GetUnit() == eCSSUnit_Enumerated &&
|
||||
(stretch.GetIntValue() == NS_FONT_STRETCH_NARROWER ||
|
||||
stretch.GetIntValue() == NS_FONT_STRETCH_WIDER)) ||
|
||||
(weight.GetUnit() == eCSSUnit_Enumerated &&
|
||||
(weight.GetIntValue() == NS_STYLE_FONT_WEIGHT_BOLDER ||
|
||||
weight.GetIntValue() == NS_STYLE_FONT_WEIGHT_LIGHTER))) {
|
||||
|
@ -2609,6 +2613,26 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext,
|
|||
NS_STYLE_FONT_WEIGHT_NORMAL,
|
||||
systemFont.weight);
|
||||
|
||||
// font-stretch: enum, normal, inherit
|
||||
if (eCSSUnit_Enumerated == aFontData.mStretch.GetUnit()) {
|
||||
PRInt32 value = aFontData.mStretch.GetIntValue();
|
||||
switch (value) {
|
||||
case NS_FONT_STRETCH_WIDER:
|
||||
case NS_FONT_STRETCH_NARROWER:
|
||||
aInherited = PR_TRUE;
|
||||
aFont->mFont.stretch = aParentFont->mFont.stretch + value;
|
||||
break;
|
||||
default:
|
||||
aFont->mFont.stretch = value;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
SetDiscrete(aFontData.mStretch, aFont->mFont.stretch, aInherited,
|
||||
SETDSC_NORMAL | SETDSC_SYSTEM_FONT,
|
||||
aParentFont->mFont.stretch,
|
||||
defaultVariableFont->stretch,
|
||||
0, 0, NS_FONT_STRETCH_NORMAL, systemFont.stretch);
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
// Compute scriptlevel, scriptminsize and scriptsizemultiplier now so
|
||||
// they're available for font-size computation.
|
||||
|
|
|
@ -202,6 +202,7 @@ nsChangeHint nsStyleFont::CalcFontDifference(const nsFont& aFont1, const nsFont&
|
|||
(aFont1.variant == aFont2.variant) &&
|
||||
(aFont1.familyNameQuirks == aFont2.familyNameQuirks) &&
|
||||
(aFont1.weight == aFont2.weight) &&
|
||||
(aFont1.stretch == aFont2.stretch) &&
|
||||
(aFont1.name == aFont2.name)) {
|
||||
if ((aFont1.decorations == aFont2.decorations)) {
|
||||
return NS_STYLE_HINT_NONE;
|
||||
|
|
|
@ -1040,7 +1040,6 @@ var gCSSProperties = {
|
|||
"font-stretch": {
|
||||
domProp: "fontStretch",
|
||||
inherited: true,
|
||||
backend_only: true,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: [ "normal" ],
|
||||
other_values: [ "wider", "narrower", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded" ],
|
||||
|
|
|
@ -1277,8 +1277,8 @@ nsSVGGlyphFrame::EnsureTextRun(float *aDrawScale, float *aMetricsScale,
|
|||
const nsFont& font = fontData->mFont;
|
||||
PRBool printerFont = (presContext->Type() == nsPresContext::eContext_PrintPreview ||
|
||||
presContext->Type() == nsPresContext::eContext_Print);
|
||||
gfxFontStyle fontStyle(font.style, font.weight, textRunSize, langGroup,
|
||||
font.sizeAdjust, font.systemFont,
|
||||
gfxFontStyle fontStyle(font.style, font.weight, font.stretch, textRunSize,
|
||||
langGroup, font.sizeAdjust, font.systemFont,
|
||||
font.familyNameQuirks,
|
||||
printerFont);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче