From 72b6bcd6d689be2b3ee04105fc394ae99597873e Mon Sep 17 00:00:00 2001 From: John Daggett Date: Sun, 18 Oct 2015 22:17:46 +0900 Subject: [PATCH 01/25] Bug 543715 p1 - distinguish between italic and oblique. r=jfkthame --- gfx/thebes/gfxAndroidPlatform.cpp | 8 +- gfx/thebes/gfxAndroidPlatform.h | 4 +- gfx/thebes/gfxDWriteFontList.cpp | 16 ++-- gfx/thebes/gfxDWriteFontList.h | 23 +++--- gfx/thebes/gfxDWriteFonts.cpp | 5 +- gfx/thebes/gfxFT2FontList.cpp | 25 +++--- gfx/thebes/gfxFT2FontList.h | 6 +- gfx/thebes/gfxFcPlatformFontList.cpp | 33 ++++---- gfx/thebes/gfxFcPlatformFontList.h | 9 ++- gfx/thebes/gfxFont.cpp | 4 +- gfx/thebes/gfxFontEntry.cpp | 117 +++++++++++++++++---------- gfx/thebes/gfxFontEntry.h | 7 +- gfx/thebes/gfxFontconfigFonts.cpp | 20 ++--- gfx/thebes/gfxFontconfigFonts.h | 4 +- gfx/thebes/gfxGDIFont.cpp | 5 +- gfx/thebes/gfxGDIFontList.cpp | 43 +++++----- gfx/thebes/gfxGDIFontList.h | 10 +-- gfx/thebes/gfxMacFont.cpp | 9 +-- gfx/thebes/gfxMacPlatformFontList.h | 8 +- gfx/thebes/gfxMacPlatformFontList.mm | 21 ++--- gfx/thebes/gfxPlatform.cpp | 2 +- gfx/thebes/gfxPlatform.h | 4 +- gfx/thebes/gfxPlatformFontList.h | 4 +- gfx/thebes/gfxPlatformGtk.cpp | 15 ++-- gfx/thebes/gfxPlatformGtk.h | 4 +- gfx/thebes/gfxPlatformMac.cpp | 8 +- gfx/thebes/gfxPlatformMac.h | 4 +- gfx/thebes/gfxQtPlatform.cpp | 8 +- gfx/thebes/gfxQtPlatform.h | 4 +- gfx/thebes/gfxUserFontSet.cpp | 38 ++++----- gfx/thebes/gfxUserFontSet.h | 17 ++-- gfx/thebes/gfxWindowsPlatform.cpp | 8 +- gfx/thebes/gfxWindowsPlatform.h | 4 +- layout/style/FontFace.h | 4 +- layout/style/FontFaceSet.cpp | 12 +-- layout/style/FontFaceSet.h | 4 +- 36 files changed, 276 insertions(+), 241 deletions(-) diff --git a/gfx/thebes/gfxAndroidPlatform.cpp b/gfx/thebes/gfxAndroidPlatform.cpp index 32986c6d0f03..1e0703dedc04 100644 --- a/gfx/thebes/gfxAndroidPlatform.cpp +++ b/gfx/thebes/gfxAndroidPlatform.cpp @@ -328,26 +328,26 @@ gfxFontEntry* gfxAndroidPlatform::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(aFontName, aWeight, aStretch, - aItalic); + aStyle); } gfxFontEntry* gfxAndroidPlatform::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(aFontName, aWeight, aStretch, - aItalic, + aStyle, aFontData, aLength); } diff --git a/gfx/thebes/gfxAndroidPlatform.h b/gfx/thebes/gfxAndroidPlatform.h index 3b93b0cd7d39..c5fae095122d 100644 --- a/gfx/thebes/gfxAndroidPlatform.h +++ b/gfx/thebes/gfxAndroidPlatform.h @@ -48,11 +48,11 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxDWriteFontList.cpp b/gfx/thebes/gfxDWriteFontList.cpp index ed3091c079a9..50c3d6d2f08c 100644 --- a/gfx/thebes/gfxDWriteFontList.cpp +++ b/gfx/thebes/gfxDWriteFontList.cpp @@ -217,7 +217,8 @@ gfxDWriteFontFamily::FindStyleVariations(FontInfoData *aFontInfoData) " with style: %s weight: %d stretch: %d psname: %s fullname: %s", NS_ConvertUTF16toUTF8(fe->Name()).get(), NS_ConvertUTF16toUTF8(Name()).get(), - (fe->IsItalic()) ? "italic" : "normal", + (fe->IsItalic()) ? + "italic" : (fe->IsOblique() ? "oblique" : "normal"), fe->Weight(), fe->Stretch(), NS_ConvertUTF16toUTF8(psname).get(), NS_ConvertUTF16toUTF8(fullname).get())); @@ -388,7 +389,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag, // potential cmap discrepancies, see bug 629386. // Ditto for Hebrew, bug 837498. if (mFont && pFontList->UseGDIFontTableAccess() && - !(mItalic && UsingArabicOrHebrewScriptSystemLocale()) && + !(mStyle && UsingArabicOrHebrewScriptSystemLocale()) && !mFont->IsSymbolFont()) { LOGFONTW logfont = { 0 }; @@ -743,7 +744,7 @@ gfxFontEntry * gfxDWriteFontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { gfxFontEntry *lookup; @@ -758,7 +759,7 @@ gfxDWriteFontList::LookupLocalFont(const nsAString& aFontName, dwriteLookup->mFont, aWeight, aStretch, - aItalic); + aStyle); fe->SetForceGDIClassic(dwriteLookup->GetForceGDIClassic()); return fe; } @@ -767,7 +768,7 @@ gfxFontEntry * gfxDWriteFontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -832,7 +833,7 @@ gfxDWriteFontList::MakePlatformFont(const nsAString& aFontName, fontFile, aWeight, aStretch, - aItalic); + aStyle); fontFile->Analyze(&isSupported, &fileType, &entry->mFaceType, &numFaces); if (!isSupported || numFaces > 1) { @@ -974,7 +975,8 @@ gfxDWriteFontList::InitFontList() " with style: %s weight: %d stretch: %d", NS_ConvertUTF16toUTF8(fe->Name()).get(), NS_ConvertUTF16toUTF8(gillSansMTFamily->Name()).get(), - (fe->IsItalic()) ? "italic" : "normal", + (fe->IsItalic()) ? + "italic" : (fe->IsOblique() ? "oblique" : "normal"), fe->Weight(), fe->Stretch())); } } diff --git a/gfx/thebes/gfxDWriteFontList.h b/gfx/thebes/gfxDWriteFontList.h index 370dc7c1018e..9ce336136471 100644 --- a/gfx/thebes/gfxDWriteFontList.h +++ b/gfx/thebes/gfxDWriteFontList.h @@ -80,8 +80,11 @@ public: : gfxFontEntry(aFaceName), mFont(aFont), mFontFile(nullptr), mForceGDIClassic(false) { - mItalic = (aFont->GetStyle() == DWRITE_FONT_STYLE_ITALIC || - aFont->GetStyle() == DWRITE_FONT_STYLE_OBLIQUE); + DWRITE_FONT_STYLE dwriteStyle = aFont->GetStyle(); + mStyle = (dwriteStyle == DWRITE_FONT_STYLE_ITALIC ? + NS_FONT_STYLE_ITALIC : + (dwriteStyle == DWRITE_FONT_STYLE_OBLIQUE ? + NS_FONT_STYLE_OBLIQUE : NS_FONT_STYLE_NORMAL)); mStretch = FontStretchFromDWriteStretch(aFont->GetStretch()); uint16_t weight = NS_ROUNDUP(aFont->GetWeight() - 50, 100); @@ -101,19 +104,19 @@ public: * \param aFont DirectWrite font object * \param aWeight Weight of the font * \param aStretch Stretch of the font - * \param aItalic True if italic + * \param aStyle italic or oblique of font */ gfxDWriteFontEntry(const nsAString& aFaceName, IDWriteFont *aFont, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) : gfxFontEntry(aFaceName), mFont(aFont), mFontFile(nullptr), mForceGDIClassic(false) { mWeight = aWeight; mStretch = aStretch; - mItalic = aItalic; + mStyle = aStyle; mIsLocalUserFont = true; mIsCJK = UNINITIALIZED_VALUE; } @@ -125,19 +128,19 @@ public: * \param aFontFile DirectWrite fontfile object * \param aWeight Weight of the font * \param aStretch Stretch of the font - * \param aItalic True if italic + * \param aStyle italic or oblique of font */ gfxDWriteFontEntry(const nsAString& aFaceName, IDWriteFontFile *aFontFile, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) : gfxFontEntry(aFaceName), mFont(nullptr), mFontFile(aFontFile), mForceGDIClassic(false) { mWeight = aWeight; mStretch = aStretch; - mItalic = aItalic; + mStyle = aStyle; mIsDataUserFont = true; mIsCJK = UNINITIALIZED_VALUE; } @@ -349,12 +352,12 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxDWriteFonts.cpp b/gfx/thebes/gfxDWriteFonts.cpp index 3f387615a732..72a5c1f45bb9 100644 --- a/gfx/thebes/gfxDWriteFonts.cpp +++ b/gfx/thebes/gfxDWriteFonts.cpp @@ -85,8 +85,9 @@ gfxDWriteFont::gfxDWriteFont(gfxFontEntry *aFontEntry, static_cast(aFontEntry); nsresult rv; DWRITE_FONT_SIMULATIONS sims = DWRITE_FONT_SIMULATIONS_NONE; - if ((GetStyle()->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) && - !fe->IsItalic() && GetStyle()->allowSyntheticStyle) { + if ((GetStyle()->style != NS_FONT_STYLE_NORMAL) && + fe->IsUpright() && + GetStyle()->allowSyntheticStyle) { // For this we always use the font_matrix for uniformity. Not the // DWrite simulation. mNeedsOblique = true; diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 7a019646fbda..148110fdb7c9 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -188,9 +188,9 @@ FT2FontEntry::CreateScaledFont(const gfxFontStyle *aStyle) cairo_matrix_init_identity(&identityMatrix); // synthetic oblique by skewing via the font matrix - bool needsOblique = !IsItalic() && - (aStyle->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) && - aStyle->allowSyntheticStyle; + bool needsOblique = IsUpright() && + aStyle->style != NS_FONT_STYLE_NORMAL && + aStyle->allowSyntheticStyle; if (needsOblique) { cairo_matrix_t style; @@ -251,7 +251,7 @@ FT2FontEntry* FT2FontEntry::CreateFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -277,7 +277,7 @@ FT2FontEntry::CreateFontEntry(const nsAString& aFontName, FT2FontEntry::CreateFontEntry(face, nullptr, 0, aFontName, aFontData); if (fe) { - fe->mItalic = aItalic; + fe->mStyle = aStyle; fe->mWeight = aWeight; fe->mStretch = aStretch; fe->mIsDataUserFont = true; @@ -323,7 +323,7 @@ FT2FontEntry::CreateFontEntry(const FontListEntry& aFLE) fe->mFTFontIndex = aFLE.index(); fe->mWeight = aFLE.weight(); fe->mStretch = aFLE.stretch(); - fe->mItalic = aFLE.italic(); + fe->mStyle = (aFLE.italic() ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL); return fe; } @@ -380,7 +380,8 @@ FT2FontEntry::CreateFontEntry(FT_Face aFace, const uint8_t* aFontData) { FT2FontEntry *fe = new FT2FontEntry(aName); - fe->mItalic = FTFaceIsItalic(aFace); + fe->mStyle = (FTFaceIsItalic(aFace) ? + NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL); fe->mWeight = FTFaceGetWeight(aFace); fe->mFilename = aFilename; fe->mFTFontIndex = aIndex; @@ -596,7 +597,7 @@ FT2FontFamily::AddFacesToFontList(InfallibleTArray* aFontList, aFontList->AppendElement(FontListEntry(Name(), fe->Name(), fe->mFilename, fe->Weight(), fe->Stretch(), - fe->IsItalic(), + fe->mStyle, fe->mFTFontIndex, aVisibility == kHidden)); } @@ -1452,7 +1453,7 @@ gfxFontEntry* gfxFT2FontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { // walk over list of names FT2FontEntry* fontEntry = nullptr; @@ -1509,7 +1510,7 @@ searchDone: fontEntry->mFTFontIndex, fontEntry->Name(), nullptr); if (fe) { - fe->mItalic = aItalic; + fe->mStyle = aStyle; fe->mWeight = aWeight; fe->mStretch = aStretch; fe->mIsLocalUserFont = true; @@ -1538,7 +1539,7 @@ gfxFontEntry* gfxFT2FontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -1546,7 +1547,7 @@ gfxFT2FontList::MakePlatformFont(const nsAString& aFontName, // but instead pass ownership to the font entry. // Deallocation will happen later, when the font face is destroyed. return FT2FontEntry::CreateFontEntry(aFontName, aWeight, aStretch, - aItalic, aFontData, aLength); + aStyle, aFontData, aLength); } void diff --git a/gfx/thebes/gfxFT2FontList.h b/gfx/thebes/gfxFT2FontList.h index ecccf2b12e2f..c5748a704bc4 100644 --- a/gfx/thebes/gfxFT2FontList.h +++ b/gfx/thebes/gfxFT2FontList.h @@ -42,7 +42,7 @@ public: CreateFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); @@ -125,12 +125,12 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxFcPlatformFontList.cpp b/gfx/thebes/gfxFcPlatformFontList.cpp index cf4fd11cc44a..784ff5accb5f 100644 --- a/gfx/thebes/gfxFcPlatformFontList.cpp +++ b/gfx/thebes/gfxFcPlatformFontList.cpp @@ -256,8 +256,10 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, if (FcPatternGetInteger(aFontPattern, FC_SLANT, 0, &slant) != FcResultMatch) { slant = FC_SLANT_ROMAN; } - if (slant > 0) { - mItalic = true; + if (slant == FC_SLANT_OBLIQUE) { + mStyle = NS_FONT_STYLE_OBLIQUE; + } else if (slant > 0) { + mStyle = NS_FONT_STYLE_ITALIC; } // weight @@ -278,7 +280,7 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t *aData, FT_Face aFace) : gfxFontEntry(aFaceName), @@ -286,7 +288,7 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, mAspect(0.0), mFontData(aData) { mWeight = aWeight; - mItalic = aItalic; + mStyle = aStyle; mStretch = aStretch; mIsDataUserFont = true; @@ -319,13 +321,13 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, FcPattern* aFontPattern, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) : gfxFontEntry(aFaceName), mFontPattern(aFontPattern), mFTFace(nullptr), mFTFaceInitialized(false), mAspect(0.0), mFontData(nullptr) { mWeight = aWeight; - mItalic = aItalic; + mStyle = aStyle; mStretch = aStretch; mIsLocalUserFont = true; } @@ -670,9 +672,9 @@ gfxFontconfigFontEntry::CreateScaledFont(FcPattern* aRenderPattern, } // synthetic oblique by skewing via the font matrix - bool needsOblique = !IsItalic() && - (aStyle->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) && - aStyle->allowSyntheticStyle; + bool needsOblique = IsUpright() && + aStyle->style != NS_FONT_STYLE_NORMAL && + aStyle->allowSyntheticStyle; if (needsOblique) { // disable embedded bitmaps (mimics behavior in 90-synthetic.conf) @@ -863,7 +865,8 @@ gfxFontconfigFontFamily::FindStyleVariations(FontInfoData *aFontInfoData) " psname: %s fullname: %s", NS_ConvertUTF16toUTF8(fontEntry->Name()).get(), NS_ConvertUTF16toUTF8(Name()).get(), - fontEntry->IsItalic() ? "italic" : "normal", + (fontEntry->IsItalic()) ? + "italic" : (fontEntry->IsOblique() ? "oblique" : "normal"), fontEntry->Weight(), fontEntry->Stretch(), NS_ConvertUTF16toUTF8(psname).get(), NS_ConvertUTF16toUTF8(fullname).get())); @@ -1172,7 +1175,7 @@ gfxFontEntry* gfxFcPlatformFontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { nsAutoString keyName(aFontName); ToLowerCase(keyName); @@ -1185,14 +1188,14 @@ gfxFcPlatformFontList::LookupLocalFont(const nsAString& aFontName, return new gfxFontconfigFontEntry(aFontName, fontPattern, - aWeight, aStretch, aItalic); + aWeight, aStretch, aStyle); } gfxFontEntry* gfxFcPlatformFontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -1210,8 +1213,8 @@ gfxFcPlatformFontList::MakePlatformFont(const nsAString& aFontName, return nullptr; } - return new gfxFontconfigFontEntry(aFontName, aWeight, aStretch, aItalic, - aFontData, face); + return new gfxFontconfigFontEntry(aFontName, aWeight, aStretch, + aStyle, aFontData, face); } gfxFontFamily* diff --git a/gfx/thebes/gfxFcPlatformFontList.h b/gfx/thebes/gfxFcPlatformFontList.h index 32f743971cfd..4f5ec324a091 100644 --- a/gfx/thebes/gfxFcPlatformFontList.h +++ b/gfx/thebes/gfxFcPlatformFontList.h @@ -99,7 +99,7 @@ public: explicit gfxFontconfigFontEntry(const nsAString& aFaceName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t *aData, FT_Face aFace); @@ -108,7 +108,7 @@ public: FcPattern* aFontPattern, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); FcPattern* GetPattern() { return mFontPattern; } @@ -209,11 +209,12 @@ public: gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, - int16_t aStretch, bool aItalic) override; + int16_t aStretch, uint8_t aStyle) override; gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, - int16_t aStretch, bool aItalic, + int16_t aStretch, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index c409af6666cc..5db1dc67ebda 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -2290,7 +2290,9 @@ gfxFont::Measure(gfxTextRun *aTextRun, // If the font may be rendered with a fake-italic effect, we need to allow // for the top-right of the glyphs being skewed to the right, and the // bottom-left being skewed further left. - if (mStyle.style != NS_FONT_STYLE_NORMAL && !mFontEntry->IsItalic()) { + if (mStyle.style != NS_FONT_STYLE_NORMAL && + mFontEntry->IsUpright() && + mStyle.allowSyntheticStyle) { gfxFloat extendLeftEdge = ceil(OBLIQUE_SKEW_FACTOR * metrics.mBoundingBox.YMost()); gfxFloat extendRightEdge = diff --git a/gfx/thebes/gfxFontEntry.cpp b/gfx/thebes/gfxFontEntry.cpp index 53d53566705e..50a3e887ac42 100644 --- a/gfx/thebes/gfxFontEntry.cpp +++ b/gfx/thebes/gfxFontEntry.cpp @@ -68,7 +68,7 @@ gfxCharacterMap::NotifyReleased() } gfxFontEntry::gfxFontEntry() : - mItalic(false), mFixedPitch(false), + mStyle(NS_FONT_STYLE_NORMAL), mFixedPitch(false), mIsValid(true), mIsBadUnderlineFont(false), mIsUserFontContainer(false), @@ -108,7 +108,7 @@ gfxFontEntry::gfxFontEntry() : } gfxFontEntry::gfxFontEntry(const nsAString& aName, bool aIsStandardFace) : - mName(aName), mItalic(false), mFixedPitch(false), + mName(aName), mStyle(NS_FONT_STYLE_NORMAL), mFixedPitch(false), mIsValid(true), mIsBadUnderlineFont(false), mIsUserFontContainer(false), @@ -1155,57 +1155,69 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle, return nullptr; } -static inline uint32_t -StyleStretchDistance(gfxFontEntry *aFontEntry, bool aTargetItalic, - int16_t aTargetStretch) -{ - // Compute a measure of the "distance" between the requested style - // and the given fontEntry, - // considering italicness and font-stretch but not weight. +#define STYLE_SHIFT 2 // number of bits to contain style distance +// style distance ==> [0,2] +static inline uint32_t +StyleDistance(uint32_t aFontStyle, uint32_t aTargetStyle) +{ + if (aFontStyle == aTargetStyle) { + return 0; // styles match exactly ==> 0 + } + if (aFontStyle == NS_FONT_STYLE_NORMAL || + aTargetStyle == NS_FONT_STYLE_NORMAL) { + return 2; // one is normal (but not the other) ==> 2 + } + return 1; // neither is normal; must be italic vs oblique ==> 1 +} + +#define REVERSE_STRETCH_DISTANCE 5 + +// stretch distance ==> [0,13] +static inline uint32_t +StretchDistance(int16_t aFontStretch, int16_t aTargetStretch) +{ int32_t distance = 0; - if (aTargetStretch != aFontEntry->mStretch) { + if (aTargetStretch != aFontStretch) { // stretch values are in the range -4 .. +4 // if aTargetStretch is positive, we prefer more-positive values; // if zero or negative, prefer more-negative if (aTargetStretch > 0) { - distance = (aFontEntry->mStretch - aTargetStretch) * 2; + distance = (aFontStretch - aTargetStretch); } else { - distance = (aTargetStretch - aFontEntry->mStretch) * 2; + distance = (aTargetStretch - aFontStretch); } // if the computed "distance" here is negative, it means that // aFontEntry lies in the "non-preferred" direction from aTargetStretch, // so we treat that as larger than any preferred-direction distance - // (max possible is 8) by adding an extra 10 to the absolute value + // (max possible is 4) by adding an extra 5 to the absolute value if (distance < 0) { - distance = -distance + 10; + distance = -distance + REVERSE_STRETCH_DISTANCE; } } - if (aFontEntry->IsItalic() != aTargetItalic) { - distance += 1; - } return uint32_t(distance); } -#define NON_DESIRED_DIRECTION_DISTANCE 1000 -#define MAX_WEIGHT_DISTANCE 2000 - // CSS currently limits font weights to multiples of 100 but the weight // matching code below does not assume this. // -// Calculate weight values with range (0..1000). In general, heavier weights -// match towards even heavier weights while lighter weights match towards even -// lighter weights. Target weight values in the range [400..500] are special, -// since they will first match up to 500, then down to 0, then up again -// towards 999. +// Calculate weight distance with values in the range (0..1000). In general, +// heavier weights match towards even heavier weights while lighter weights +// match towards even lighter weights. Target weight values in the range +// [400..500] are special, since they will first match up to 500, then down +// towards 0, then up again towards 999. // // Example: with target 600 and font weight 800, distance will be 200. With -// target 300 and font weight 600, distance will be 1300, since heavier weights -// are farther away than lighter weights. If the target is 5 and the font weight -// 995, the distance would be 1990 for the same reason. +// target 300 and font weight 600, distance will be 900, since heavier +// weights are farther away than lighter weights. If the target is 5 and the +// font weight 995, the distance would be 1590 for the same reason. +#define REVERSE_WEIGHT_DISTANCE 600 +#define WEIGHT_SHIFT 11 // number of bits to contain weight distance + +// weight distance ==> [0,1598] static inline uint32_t -WeightDistance(uint32_t aTargetWeight, uint32_t aFontWeight) +WeightDistance(uint32_t aFontWeight, uint32_t aTargetWeight) { // Compute a measure of the "distance" between the requested // weight and the given fontEntry @@ -1235,13 +1247,34 @@ WeightDistance(uint32_t aTargetWeight, uint32_t aFontWeight) } } if (distance < 0) { - distance = -distance + NON_DESIRED_DIRECTION_DISTANCE; + distance = -distance + REVERSE_WEIGHT_DISTANCE; } distance += addedDistance; } return uint32_t(distance); } +#define MAX_DISTANCE 0xffffffff + +static inline uint32_t +WeightStyleStretchDistance(gfxFontEntry* aFontEntry, + const gfxFontStyle& aTargetStyle) +{ + // weight/style/stretch priority: stretch >> style >> weight + uint32_t stretchDist = + StretchDistance(aFontEntry->mStretch, aTargetStyle.stretch); + uint32_t styleDist = StyleDistance(aFontEntry->mStyle, aTargetStyle.style); + uint32_t weightDist = + WeightDistance(aFontEntry->Weight(), aTargetStyle.weight); + + NS_ASSERTION(weightDist < (1 << WEIGHT_SHIFT), "weight value out of bounds"); + NS_ASSERTION(styleDist < (1 << STYLE_SHIFT), "slope value out of bounds"); + + return (stretchDist << (STYLE_SHIFT + WEIGHT_SHIFT)) | + (styleDist << WEIGHT_SHIFT) | + weightDist; +} + void gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle, nsTArray& aFontEntryList, @@ -1271,9 +1304,6 @@ gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle, return; } - bool wantItalic = (aFontStyle.style & - (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; - // Most families are "simple", having just Regular/Bold/Italic/BoldItalic, // or some subset of these. In this case, we have exactly 4 entries in mAvailableFonts, // stored in the above order; note that some of the entries may be nullptr. @@ -1285,6 +1315,7 @@ gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle, // Family has no more than the "standard" 4 faces, at fixed indexes; // calculate which one we want. // Note that we cannot simply return it as not all 4 faces are necessarily present. + bool wantItalic = (aFontStyle.style != NS_FONT_STYLE_NORMAL); uint8_t faceIndex = (wantItalic ? kItalicMask : 0) | (wantBold ? kBoldMask : 0); @@ -1332,16 +1363,14 @@ gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle, // weight/style/stretch combination, only the last matched font entry will // be added. - uint32_t minDistance = 0xffffffff; + uint32_t minDistance = MAX_DISTANCE; gfxFontEntry* matched = nullptr; // iterate in forward order so that faces like 'Bold' are matched before // matching style distance faces such as 'Bold Outline' (see bug 1185812) for (uint32_t i = 0; i < count; i++) { fe = mAvailableFonts[i]; - uint32_t distance = - WeightDistance(aFontStyle.weight, fe->Weight()) + - (StyleStretchDistance(fe, wantItalic, aFontStyle.stretch) * - MAX_WEIGHT_DISTANCE); + // weight/style/stretch priority: stretch >> style >> weight + uint32_t distance = WeightStyleStretchDistance(fe, aFontStyle); if (distance < minDistance) { matched = fe; if (!aFontEntryList.IsEmpty()) { @@ -1391,8 +1420,9 @@ gfxFontFamily::CheckForSimpleFamily() gfxFontEntry *faces[4] = { 0 }; for (uint8_t i = 0; i < count; ++i) { gfxFontEntry *fe = mAvailableFonts[i]; - if (fe->Stretch() != firstStretch) { - return; // font-stretch doesn't match, don't treat as simple family + if (fe->Stretch() != firstStretch || fe->IsOblique()) { + // simple families don't have varying font-stretch or oblique + return; } uint8_t faceIndex = (fe->IsItalic() ? kItalicMask : 0) | (fe->Weight() >= 600 ? kBoldMask : 0); @@ -1448,9 +1478,8 @@ CalcStyleMatch(gfxFontEntry *aFontEntry, const gfxFontStyle *aStyle) int32_t rank = 0; if (aStyle) { // italics - bool wantItalic = - (aStyle->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; - if (aFontEntry->IsItalic() == wantItalic) { + bool wantUpright = (aStyle->style == NS_FONT_STYLE_NORMAL); + if (aFontEntry->IsUpright() == wantUpright) { rank += 10; } @@ -1458,7 +1487,7 @@ CalcStyleMatch(gfxFontEntry *aFontEntry, const gfxFontStyle *aStyle) rank += 9 - DeprecatedAbs(aFontEntry->Weight() / 100 - aStyle->ComputeWeight()); } else { // if no font to match, prefer non-bold, non-italic fonts - if (!aFontEntry->IsItalic()) { + if (aFontEntry->IsUpright()) { rank += 3; } if (!aFontEntry->IsBold()) { diff --git a/gfx/thebes/gfxFontEntry.h b/gfx/thebes/gfxFontEntry.h index c1e1a365d57a..d11f117b14c3 100644 --- a/gfx/thebes/gfxFontEntry.h +++ b/gfx/thebes/gfxFontEntry.h @@ -8,6 +8,7 @@ #include "gfxTypes.h" #include "nsString.h" +#include "gfxFontConstants.h" #include "gfxFontFeatures.h" #include "gfxFontUtils.h" #include "nsTArray.h" @@ -121,7 +122,9 @@ public: bool IsUserFont() const { return mIsDataUserFont || mIsLocalUserFont; } bool IsLocalUserFont() const { return mIsLocalUserFont; } bool IsFixedPitch() const { return mFixedPitch; } - bool IsItalic() const { return mItalic; } + bool IsItalic() const { return mStyle == NS_FONT_STYLE_ITALIC; } + bool IsOblique() const { return mStyle == NS_FONT_STYLE_OBLIQUE; } + bool IsUpright() const { return mStyle == NS_FONT_STYLE_NORMAL; } bool IsBold() const { return mWeight >= 600; } // bold == weights 600 and above bool IgnoreGDEF() const { return mIgnoreGDEF; } bool IgnoreGSUB() const { return mIgnoreGSUB; } @@ -388,7 +391,7 @@ public: nsString mName; nsString mFamilyName; - bool mItalic : 1; + uint8_t mStyle : 2; // italic/oblique bool mFixedPitch : 1; bool mIsValid : 1; bool mIsBadUnderlineFont : 1; diff --git a/gfx/thebes/gfxFontconfigFonts.cpp b/gfx/thebes/gfxFontconfigFonts.cpp index 6bf0576687a9..a23d52e9c2e0 100644 --- a/gfx/thebes/gfxFontconfigFonts.cpp +++ b/gfx/thebes/gfxFontconfigFonts.cpp @@ -335,10 +335,10 @@ protected: explicit gfxUserFcFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) : gfxFcFontEntry(aFontName) { - mItalic = aItalic; + mStyle = aStyle; mWeight = aWeight; mStretch = aStretch; } @@ -421,9 +421,9 @@ public: gfxLocalFcFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const nsTArray< nsCountedRef >& aPatterns) - : gfxUserFcFontEntry(aFontName, aWeight, aStretch, aItalic) + : gfxUserFcFontEntry(aFontName, aWeight, aStretch, aStyle) { if (!mPatterns.SetCapacity(aPatterns.Length(), fallible)) return; // OOM @@ -458,9 +458,9 @@ public: gfxDownloadedFcFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t *aData, FT_Face aFace) - : gfxUserFcFontEntry(aFontName, aWeight, aStretch, aItalic), + : gfxUserFcFontEntry(aFontName, aWeight, aStretch, aStyle), mFontData(aData), mFace(aFace) { NS_PRECONDITION(aFace != nullptr, "aFace is NULL!"); @@ -1748,7 +1748,7 @@ gfxPangoFontGroup::Shutdown() gfxPangoFontGroup::NewFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { gfxFontconfigUtils *utils = gfxFontconfigUtils::GetFontconfigUtils(); if (!utils) @@ -1791,7 +1791,7 @@ gfxPangoFontGroup::NewFontEntry(const nsAString& aFontName, return new gfxLocalFcFontEntry(aFontName, aWeight, aStretch, - aItalic, + aStyle, fonts); } @@ -1833,7 +1833,7 @@ gfxPangoFontGroup::GetFTLibrary() gfxPangoFontGroup::NewFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -1851,7 +1851,7 @@ gfxPangoFontGroup::NewFontEntry(const nsAString& aFontName, } return new gfxDownloadedFcFontEntry(aFontName, aWeight, - aStretch, aItalic, + aStretch, aStyle, aFontData, face); } diff --git a/gfx/thebes/gfxFontconfigFonts.h b/gfx/thebes/gfxFontconfigFonts.h index fe77332e8981..0d91a2a24a91 100644 --- a/gfx/thebes/gfxFontconfigFonts.h +++ b/gfx/thebes/gfxFontconfigFonts.h @@ -45,12 +45,12 @@ public: static gfxFontEntry *NewFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); // Used for @font-face { src: url(); } static gfxFontEntry *NewFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxGDIFont.cpp b/gfx/thebes/gfxGDIFont.cpp index 6c212a1f083e..9d01c49ea535 100644 --- a/gfx/thebes/gfxGDIFont.cpp +++ b/gfx/thebes/gfxGDIFont.cpp @@ -177,9 +177,8 @@ gfxGDIFont::Initialize() // Figure out if we want to do synthetic oblique styling. GDIFontEntry* fe = static_cast(GetFontEntry()); - bool wantFakeItalic = - (mStyle.style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) && - !fe->IsItalic() && mStyle.allowSyntheticStyle; + bool wantFakeItalic = mStyle.style != NS_FONT_STYLE_NORMAL && + fe->IsUpright() && mStyle.allowSyntheticStyle; // If the font's family has an actual italic face (but font matching // didn't choose it), we have to use a cairo transform instead of asking diff --git a/gfx/thebes/gfxGDIFontList.cpp b/gfx/thebes/gfxGDIFontList.cpp index 504f9fdd6791..8d4ff569d3e1 100644 --- a/gfx/thebes/gfxGDIFontList.cpp +++ b/gfx/thebes/gfxGDIFontList.cpp @@ -118,7 +118,8 @@ FontTypeToOutPrecision(uint8_t fontType) GDIFontEntry::GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType, - bool aItalic, uint16_t aWeight, int16_t aStretch, + uint8_t aStyle, uint16_t aWeight, + int16_t aStretch, gfxUserFontData *aUserFontData, bool aFamilyHasItalicFace) : gfxFontEntry(aFaceName), @@ -129,7 +130,7 @@ GDIFontEntry::GDIFontEntry(const nsAString& aFaceName, mCharset(), mUnicodeRanges() { mUserFontData = aUserFontData; - mItalic = aItalic; + mStyle = aStyle; mWeight = aWeight; mStretch = aStretch; if (IsType1()) @@ -306,9 +307,10 @@ GDIFontEntry::TestCharacterMap(uint32_t aCh) return false; // previous code was using the group style - gfxFontStyle fakeStyle; - if (mItalic) + gfxFontStyle fakeStyle; + if (!IsUpright()) { fakeStyle.style = NS_FONT_STYLE_ITALIC; + } fakeStyle.weight = mWeight * 100; RefPtr tempFont = FindOrMakeFont(&fakeStyle, false); @@ -387,7 +389,7 @@ GDIFontEntry::InitLogFont(const nsAString& aName, // do its best to give us an italic font entry, but if no face exists // it may give us a regular one based on weight. Windows should // do fake italic for us in that case. - mLogFont.lfItalic = mItalic; + mLogFont.lfItalic = !IsUpright(); mLogFont.lfWeight = mWeight; int len = std::min(aName.Length(), LF_FACESIZE - 1); @@ -397,14 +399,15 @@ GDIFontEntry::InitLogFont(const nsAString& aName, GDIFontEntry* GDIFontEntry::CreateFontEntry(const nsAString& aName, - gfxWindowsFontType aFontType, bool aItalic, + gfxWindowsFontType aFontType, + uint8_t aStyle, uint16_t aWeight, int16_t aStretch, gfxUserFontData* aUserFontData, bool aFamilyHasItalicFace) { // jtdfix - need to set charset, unicode ranges, pitch/family - GDIFontEntry *fe = new GDIFontEntry(aName, aFontType, aItalic, + GDIFontEntry *fe = new GDIFontEntry(aName, aFontType, aStyle, aWeight, aStretch, aUserFontData, aFamilyHasItalicFace); @@ -456,7 +459,7 @@ GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe, fe = static_cast(ff->mAvailableFonts[i].get()); // check if we already know about this face if (fe->mWeight == logFont.lfWeight && - fe->mItalic == (logFont.lfItalic == 0xFF)) { + fe->IsItalic() == (logFont.lfItalic == 0xFF)) { // update the charset bit here since this could be different fe->mCharset.set(metrics.tmCharSet); return 1; @@ -466,8 +469,10 @@ GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe, // We can't set the hasItalicFace flag correctly here, // because we might not have seen the family's italic face(s) yet. // So we'll set that flag for all members after loading all the faces. + uint8_t italicStyle = (logFont.lfItalic == 0xFF ? + NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL); fe = GDIFontEntry::CreateFontEntry(nsDependentString(lpelfe->elfFullName), - feType, (logFont.lfItalic == 0xFF), + feType, italicStyle, (uint16_t) (logFont.lfWeight), 0, nullptr, false); if (!fe) @@ -712,7 +717,7 @@ gfxFontEntry* gfxGDIFontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { gfxFontEntry *lookup; @@ -729,10 +734,9 @@ gfxGDIFontList::LookupLocalFont(const nsAString& aFontName, // 'Arial Vet' which can be used as a key in GDI font lookups). GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(lookup->Name(), gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/, - lookup->mItalic ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL, - lookup->mWeight, aStretch, nullptr, + lookup->mStyle, lookup->mWeight, aStretch, nullptr, static_cast(lookup)->mFamilyHasItalicFace); - + if (!fe) return nullptr; @@ -740,7 +744,7 @@ gfxGDIFontList::LookupLocalFont(const nsAString& aFontName, // make the new font entry match the userfont entry style characteristics fe->mWeight = (aWeight == 0 ? 400 : aWeight); - fe->mItalic = aItalic; + fe->mStyle = aStyle; return fe; } @@ -749,7 +753,7 @@ gfxFontEntry* gfxGDIFontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -808,17 +812,16 @@ gfxGDIFontList::MakePlatformFont(const nsAString& aFontName, WinUserFontData *winUserFontData = new WinUserFontData(fontRef); uint16_t w = (aWeight == 0 ? 400 : aWeight); - GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(uniqueName, - gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/, - uint32_t(aItalic ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL), - w, aStretch, winUserFontData, false); + GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(uniqueName, + gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/, + aStyle, w, aStretch, winUserFontData, false); if (!fe) return fe; fe->mIsDataUserFont = true; - // Uniscribe doesn't place CFF fonts loaded privately + // Uniscribe doesn't place CFF fonts loaded privately // via AddFontMemResourceEx on XP/Vista if (isCFF && !IsWin7OrLater()) { fe->mForceGDI = true; diff --git a/gfx/thebes/gfxGDIFontList.h b/gfx/thebes/gfxGDIFontList.h index 81ad45aa7601..4fca9324e22a 100644 --- a/gfx/thebes/gfxGDIFontList.h +++ b/gfx/thebes/gfxGDIFontList.h @@ -236,7 +236,7 @@ public: // create a font entry for a font with a given name static GDIFontEntry* CreateFontEntry(const nsAString& aName, gfxWindowsFontType aFontType, - bool aItalic, + uint8_t aStyle, uint16_t aWeight, int16_t aStretch, gfxUserFontData* aUserFontData, bool aFamilyHasItalicFace); @@ -245,7 +245,7 @@ public: static GDIFontEntry* LoadLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); uint8_t mWindowsFamily; uint8_t mWindowsPitch; @@ -266,7 +266,7 @@ protected: friend class gfxWindowsFont; GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType, - bool aItalic, uint16_t aWeight, int16_t aStretch, + uint8_t aStyle, uint16_t aWeight, int16_t aStretch, gfxUserFontData *aUserFontData, bool aFamilyHasItalicFace); void InitLogFont(const nsAString& aName, gfxWindowsFontType aFontType); @@ -311,12 +311,12 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp index 1e0600c891c3..239899b010ec 100644 --- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -61,11 +61,10 @@ gfxMacFont::gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyl cairo_matrix_init_scale(&sizeMatrix, mAdjustedSize, mAdjustedSize); // synthetic oblique by skewing via the font matrix - bool needsOblique = - (mFontEntry != nullptr) && - (!mFontEntry->IsItalic() && - (mStyle.style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE))) && - mStyle.allowSyntheticStyle; + bool needsOblique = mFontEntry != nullptr && + mFontEntry->IsUpright() && + mStyle.style != NS_FONT_STYLE_NORMAL && + mStyle.allowSyntheticStyle; if (needsOblique) { cairo_matrix_t style; diff --git a/gfx/thebes/gfxMacPlatformFontList.h b/gfx/thebes/gfxMacPlatformFontList.h index 232d5bb05171..7804cde41374 100644 --- a/gfx/thebes/gfxMacPlatformFontList.h +++ b/gfx/thebes/gfxMacPlatformFontList.h @@ -33,7 +33,7 @@ public: // for use with data fonts MacOSFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef, - uint16_t aWeight, uint16_t aStretch, uint32_t aItalicStyle, + uint16_t aWeight, uint16_t aStretch, uint8_t aStyle, bool aIsDataUserFont, bool aIsLocal); virtual ~MacOSFontEntry() { @@ -86,12 +86,12 @@ public: gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) override; - + uint8_t aStyle) override; + gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index 801af8c51d1c..d1c8817cb06c 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -268,7 +268,7 @@ MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName, MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef, uint16_t aWeight, uint16_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, bool aIsDataUserFont, bool aIsLocalUserFont) : gfxFontEntry(aPostscriptName, false), @@ -285,7 +285,7 @@ MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName, mWeight = aWeight; mStretch = aStretch; mFixedPitch = false; // xxx - do we need this for downloaded fonts? - mItalic = (aItalicStyle & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; + mStyle = aStyle; NS_ASSERTION(!(aIsDataUserFont && aIsLocalUserFont), "userfont is either a data font or a local font"); @@ -523,7 +523,7 @@ gfxMacFontFamily::FindStyleVariations(FontInfoData *aFontInfoData) [facename hasSuffix:@"Italic"] || [facename hasSuffix:@"Oblique"]) { - fontEntry->mItalic = true; + fontEntry->mStyle = NS_FONT_STYLE_ITALIC; } if (macTraits & NSFixedPitchFontMask) { fontEntry->mFixedPitch = true; @@ -1009,7 +1009,7 @@ gfxFontEntry* gfxMacPlatformFontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { nsAutoreleasePool localPool; @@ -1026,10 +1026,7 @@ gfxMacPlatformFontList::LookupLocalFont(const nsAString& aFontName, "bogus font weight value!"); newFontEntry = - new MacOSFontEntry(aFontName, fontRef, - aWeight, aStretch, - aItalic ? - NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL, + new MacOSFontEntry(aFontName, fontRef, aWeight, aStretch, aStyle, false, true); ::CFRelease(fontRef); @@ -1045,7 +1042,7 @@ gfxFontEntry* gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -1073,11 +1070,7 @@ gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName, nsAutoPtr newFontEntry(new MacOSFontEntry(uniqueName, fontRef, aWeight, - aStretch, - aItalic ? - NS_FONT_STYLE_ITALIC : - NS_FONT_STYLE_NORMAL, - true, false)); + aStretch, aStyle, true, false)); ::CFRelease(fontRef); // if succeeded and font cmap is good, return the new font diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 69bac9d2faa4..a072dcc080c5 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -1376,7 +1376,7 @@ gfxFontEntry* gfxPlatform::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 2b23ce625df2..3ab789f10f04 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -348,7 +348,7 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { return nullptr; } /** @@ -362,7 +362,7 @@ public: virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxPlatformFontList.h b/gfx/thebes/gfxPlatformFontList.h index d36b32d7c673..fccb6e08b3b6 100644 --- a/gfx/thebes/gfxPlatformFontList.h +++ b/gfx/thebes/gfxPlatformFontList.h @@ -153,14 +153,14 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) = 0; + uint8_t aStyle) = 0; // create a new platform font from downloaded data (@font-face) // this method is responsible to ensure aFontData is free()'d virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) = 0; diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index a77ec2395018..74ac7af7d63e 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -256,34 +256,35 @@ gfxFontEntry* gfxPlatformGtk::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { if (sUseFcFontList) { gfxPlatformFontList* pfl = gfxPlatformFontList::PlatformFontList(); - return pfl->LookupLocalFont(aFontName, aWeight, aStretch, aItalic); + return pfl->LookupLocalFont(aFontName, aWeight, aStretch, + aStyle); } return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight, - aStretch, aItalic); + aStretch, aStyle); } gfxFontEntry* gfxPlatformGtk::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { if (sUseFcFontList) { gfxPlatformFontList* pfl = gfxPlatformFontList::PlatformFontList(); - return pfl->MakePlatformFont(aFontName, aWeight, aStretch, aItalic, - aFontData, aLength); + return pfl->MakePlatformFont(aFontName, aWeight, aStretch, + aStyle, aFontData, aLength); } // passing ownership of the font data to the new font entry return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight, - aStretch, aItalic, + aStretch, aStyle, aFontData, aLength); } diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h index 548d7b704d73..b32ac6b99fb2 100644 --- a/gfx/thebes/gfxPlatformGtk.h +++ b/gfx/thebes/gfxPlatformGtk.h @@ -63,7 +63,7 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) override; + uint8_t aStyle) override; /** * Activate a platform font (needed to support @font-face src url() ) @@ -72,7 +72,7 @@ public: virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp index ca589a0f5305..b320febbb8ac 100644 --- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -152,19 +152,19 @@ gfxFontEntry* gfxPlatformMac::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(aFontName, aWeight, aStretch, - aItalic); + aStyle); } gfxFontEntry* gfxPlatformMac::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -174,7 +174,7 @@ gfxPlatformMac::MakePlatformFont(const nsAString& aFontName, return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(aFontName, aWeight, aStretch, - aItalic, + aStyle, aFontData, aLength); } diff --git a/gfx/thebes/gfxPlatformMac.h b/gfx/thebes/gfxPlatformMac.h index a4046e6933a4..e0edb9cdeb19 100644 --- a/gfx/thebes/gfxPlatformMac.h +++ b/gfx/thebes/gfxPlatformMac.h @@ -44,14 +44,14 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) override; + uint8_t aStyle) override; virtual gfxPlatformFontList* CreatePlatformFontList() override; virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxQtPlatform.cpp b/gfx/thebes/gfxQtPlatform.cpp index 371d847618d9..1aed17ccaa32 100644 --- a/gfx/thebes/gfxQtPlatform.cpp +++ b/gfx/thebes/gfxQtPlatform.cpp @@ -132,23 +132,23 @@ gfxFontEntry* gfxQtPlatform::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight, - aStretch, aItalic); + aStretch, aStyle); } gfxFontEntry* gfxQtPlatform::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { // passing ownership of the font data to the new font entry return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight, - aStretch, aItalic, + aStretch, aStyle, aFontData, aLength); } diff --git a/gfx/thebes/gfxQtPlatform.h b/gfx/thebes/gfxQtPlatform.h index fad09180df53..ed5c26e942e5 100644 --- a/gfx/thebes/gfxQtPlatform.h +++ b/gfx/thebes/gfxQtPlatform.h @@ -54,7 +54,7 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) override; + uint8_t aStyle) override; /** * Activate a platform font (needed to support @font-face src url() ) @@ -63,7 +63,7 @@ public: virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxUserFontSet.cpp b/gfx/thebes/gfxUserFontSet.cpp index c1c726afd95a..a210956dc297 100644 --- a/gfx/thebes/gfxUserFontSet.cpp +++ b/gfx/thebes/gfxUserFontSet.cpp @@ -109,7 +109,7 @@ gfxUserFontEntry::gfxUserFontEntry(gfxUserFontSet* aFontSet, const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) @@ -127,9 +127,7 @@ gfxUserFontEntry::gfxUserFontEntry(gfxUserFontSet* aFontSet, mSrcIndex = 0; mWeight = aWeight; mStretch = aStretch; - // XXX Currently, we don't distinguish 'italic' and 'oblique' styles; - // we need to fix this. (Bug 543715) - mItalic = (aItalicStyle & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; + mStyle = aStyle; mFeatureSettings.AppendElements(aFeatureSettings); mLanguageOverride = aLanguageOverride; @@ -147,18 +145,14 @@ bool gfxUserFontEntry::Matches(const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) { - // XXX font entries don't distinguish italic from oblique (bug 543715) - bool isItalic = - (aItalicStyle & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; - return mWeight == aWeight && mStretch == aStretch && - mItalic == isItalic && + mStyle == aStyle && mFeatureSettings == aFeatureSettings && mLanguageOverride == aLanguageOverride && mSrcList == aFontFaceSrcList && @@ -412,7 +406,7 @@ gfxUserFontEntry::LoadNextSrc() gfxPlatform::GetPlatform()->LookupLocalFont(currSrc.mLocalName, mWeight, mStretch, - mItalic); + mStyle); nsTArray fontSets; GetUserFontSets(fontSets); for (gfxUserFontSet* fontSet : fontSets) { @@ -612,11 +606,10 @@ gfxUserFontEntry::LoadPlatformFont(const uint8_t* aFontData, uint32_t& aLength) originalFullName); // Here ownership of saneData is passed to the platform, // which will delete it when no longer required - fe = gfxPlatform::GetPlatform()->MakePlatformFont(mName, mWeight, mStretch, - mItalic, + mStyle, saneData, saneLen); if (!fe) { @@ -771,7 +764,7 @@ gfxUserFontSet::FindOrCreateUserFontEntry( const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) @@ -787,14 +780,14 @@ gfxUserFontSet::FindOrCreateUserFontEntry( gfxUserFontFamily* family = LookupFamily(aFamilyName); if (family) { entry = FindExistingUserFontEntry(family, aFontFaceSrcList, aWeight, - aStretch, aItalicStyle, + aStretch, aStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); } if (!entry) { entry = CreateUserFontEntry(aFontFaceSrcList, aWeight, aStretch, - aItalicStyle, aFeatureSettings, + aStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); entry->mFamilyName = aFamilyName; } @@ -807,7 +800,7 @@ gfxUserFontSet::CreateUserFontEntry( const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) @@ -815,7 +808,7 @@ gfxUserFontSet::CreateUserFontEntry( RefPtr userFontEntry = new gfxUserFontEntry(this, aFontFaceSrcList, aWeight, - aStretch, aItalicStyle, aFeatureSettings, + aStretch, aStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); return userFontEntry.forget(); } @@ -826,7 +819,7 @@ gfxUserFontSet::FindExistingUserFontEntry( const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) @@ -844,7 +837,7 @@ gfxUserFontSet::FindExistingUserFontEntry( gfxUserFontEntry* existingUserFontEntry = static_cast(fontList[i].get()); if (!existingUserFontEntry->Matches(aFontFaceSrcList, - aWeight, aStretch, aItalicStyle, + aWeight, aStretch, aStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges)) { continue; @@ -867,7 +860,8 @@ gfxUserFontSet::AddUserFontEntry(const nsAString& aFamilyName, LOG(("userfonts (%p) added to \"%s\" (%p) style: %s weight: %d " "stretch: %d", this, NS_ConvertUTF16toUTF8(aFamilyName).get(), aUserFontEntry, - (aUserFontEntry->IsItalic() ? "italic" : "normal"), + (aUserFontEntry->IsItalic() ? "italic" : + (aUserFontEntry->IsOblique() ? "oblique" : "normal")), aUserFontEntry->Weight(), aUserFontEntry->Stretch())); } } @@ -1050,7 +1044,7 @@ gfxUserFontSet::UserFontCache::Entry::KeyEquals(const KeyTypePointer aKey) const } } - if (mFontEntry->mItalic != fe->mItalic || + if (mFontEntry->mStyle != fe->mStyle || mFontEntry->mWeight != fe->mWeight || mFontEntry->mStretch != fe->mStretch || mFontEntry->mFeatureSettings != fe->mFeatureSettings || diff --git a/gfx/thebes/gfxUserFontSet.h b/gfx/thebes/gfxUserFontSet.h index 320c9c088370..567227ed939c 100644 --- a/gfx/thebes/gfxUserFontSet.h +++ b/gfx/thebes/gfxUserFontSet.h @@ -16,6 +16,7 @@ #include "nsIScriptError.h" #include "nsURIHashKey.h" #include "mozilla/net/ReferrerPolicy.h" +#include "gfxFontConstants.h" class nsFontFaceLoader; @@ -210,7 +211,7 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) = 0; @@ -222,7 +223,7 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges); @@ -416,9 +417,9 @@ public: nsURIHashKey::HashKey(aKey->mURI), HashFeatures(aKey->mFontEntry->mFeatureSettings), mozilla::HashString(aKey->mFontEntry->mFamilyName), - ((uint32_t)aKey->mFontEntry->mItalic | - (aKey->mFontEntry->mWeight << 1) | - (aKey->mFontEntry->mStretch << 10) ) ^ + (aKey->mFontEntry->mStyle | + (aKey->mFontEntry->mWeight << 2) | + (aKey->mFontEntry->mStretch << 11) ) ^ aKey->mFontEntry->mLanguageOverride); } @@ -495,7 +496,7 @@ protected: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges); @@ -534,7 +535,7 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges); @@ -545,7 +546,7 @@ public: bool Matches(const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges); diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 556507b8f6d3..7ff3561ea300 100755 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -1056,26 +1056,26 @@ gfxFontEntry* gfxWindowsPlatform::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(aFontName, aWeight, aStretch, - aItalic); + aStyle); } gfxFontEntry* gfxWindowsPlatform::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(aFontName, aWeight, aStretch, - aItalic, + aStyle, aFontData, aLength); } diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 7e3bfd15947e..0d6005ba5e5a 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -193,7 +193,7 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); /** * Activate a platform font (needed to support @font-face src url() ) @@ -201,7 +201,7 @@ public: virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/layout/style/FontFace.h b/layout/style/FontFace.h index 1d6cfe0f78d1..58072b6e507d 100644 --- a/layout/style/FontFace.h +++ b/layout/style/FontFace.h @@ -44,12 +44,12 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) : gfxUserFontEntry(aFontSet, aFontFaceSrcList, aWeight, aStretch, - aItalicStyle, aFeatureSettings, aLanguageOverride, + aStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges) {} virtual void SetLoadState(UserFontLoadState aLoadState) override; diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 2eda306d1252..7362eb87f7e1 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -169,7 +169,7 @@ FontFaceSet::ParseFontShorthandForMatching( RefPtr& aFamilyList, uint32_t& aWeight, int32_t& aStretch, - uint32_t& aItalicStyle, + uint8_t& aStyle, ErrorResult& aRv) { // Parse aFont as a 'font' property value. @@ -224,7 +224,7 @@ FontFaceSet::ParseFontShorthandForMatching( aWeight = weight; aStretch = data->ValueFor(eCSSProperty_font_stretch)->GetIntValue(); - aItalicStyle = data->ValueFor(eCSSProperty_font_style)->GetIntValue(); + aStyle = data->ValueFor(eCSSProperty_font_style)->GetIntValue(); } static bool @@ -252,7 +252,7 @@ FontFaceSet::FindMatchingFontFaces(const nsAString& aFont, RefPtr familyList; uint32_t weight; int32_t stretch; - uint32_t italicStyle; + uint8_t italicStyle; ParseFontShorthandForMatching(aFont, familyList, weight, stretch, italicStyle, aRv); if (aRv.Failed()) { @@ -964,7 +964,7 @@ FontFaceSet::FindOrCreateUserFontEntryFromFontFace(const nsAString& aFamilyName, uint32_t weight = NS_STYLE_FONT_WEIGHT_NORMAL; int32_t stretch = NS_STYLE_FONT_STRETCH_NORMAL; - uint32_t italicStyle = NS_STYLE_FONT_STYLE_NORMAL; + uint8_t italicStyle = NS_STYLE_FONT_STYLE_NORMAL; uint32_t languageOverride = NO_FONT_LANGUAGE_OVERRIDE; // set up weight @@ -1772,13 +1772,13 @@ FontFaceSet::UserFontSet::CreateUserFontEntry( const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) { RefPtr entry = - new FontFace::Entry(this, aFontFaceSrcList, aWeight, aStretch, aItalicStyle, + new FontFace::Entry(this, aFontFaceSrcList, aWeight, aStretch, aStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); return entry.forget(); } diff --git a/layout/style/FontFaceSet.h b/layout/style/FontFaceSet.h index 782f36de097e..e2e435a301bf 100644 --- a/layout/style/FontFaceSet.h +++ b/layout/style/FontFaceSet.h @@ -83,7 +83,7 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) override; @@ -286,7 +286,7 @@ private: RefPtr& aFamilyList, uint32_t& aWeight, int32_t& aStretch, - uint32_t& aItalicStyle, + uint8_t& aStyle, ErrorResult& aRv); void FindMatchingFontFaces(const nsAString& aFont, const nsAString& aText, From fe5101b5b8ab9130f2101efeabd734dc853e7555 Mon Sep 17 00:00:00 2001 From: John Daggett Date: Sun, 18 Oct 2015 22:17:59 +0900 Subject: [PATCH 02/25] Bug 543715 p2 - italic/oblique reftests. r=jfkthame --- .../font-matching/italic-oblique-1.html | 31 +++++++++++++ .../font-matching/italic-oblique-2.html | 31 +++++++++++++ .../font-matching/italic-oblique-3.html | 37 +++++++++++++++ .../font-matching/italic-oblique-4.html | 37 +++++++++++++++ .../font-matching/italic-oblique-5.html | 37 +++++++++++++++ .../font-matching/italic-oblique-6.html | 37 +++++++++++++++ .../font-matching/italic-oblique-7.html | 37 +++++++++++++++ .../font-matching/italic-oblique-8.html | 43 ++++++++++++++++++ .../font-matching/italic-oblique-9.html | 43 ++++++++++++++++++ .../italic-oblique-kinnari-ref.html | 37 +++++++++++++++ .../font-matching/italic-oblique-kinnari.html | 37 +++++++++++++++ .../font-matching/italic-oblique-ref.html | 24 ++++++++++ layout/reftests/font-matching/reftest.list | 13 ++++++ .../font-matching/simple-oblique-ref.html | 33 ++++++++++++++ .../font-matching/simple-oblique.html | 33 ++++++++++++++ layout/reftests/fonts/mark2A.woff | Bin 0 -> 1084 bytes layout/reftests/fonts/mark2B.woff | Bin 0 -> 1084 bytes layout/reftests/fonts/mark2C.woff | Bin 0 -> 1084 bytes layout/reftests/fonts/mark2D.woff | Bin 0 -> 1084 bytes 19 files changed, 510 insertions(+) create mode 100644 layout/reftests/font-matching/italic-oblique-1.html create mode 100644 layout/reftests/font-matching/italic-oblique-2.html create mode 100644 layout/reftests/font-matching/italic-oblique-3.html create mode 100644 layout/reftests/font-matching/italic-oblique-4.html create mode 100644 layout/reftests/font-matching/italic-oblique-5.html create mode 100644 layout/reftests/font-matching/italic-oblique-6.html create mode 100644 layout/reftests/font-matching/italic-oblique-7.html create mode 100644 layout/reftests/font-matching/italic-oblique-8.html create mode 100644 layout/reftests/font-matching/italic-oblique-9.html create mode 100644 layout/reftests/font-matching/italic-oblique-kinnari-ref.html create mode 100644 layout/reftests/font-matching/italic-oblique-kinnari.html create mode 100644 layout/reftests/font-matching/italic-oblique-ref.html create mode 100644 layout/reftests/font-matching/simple-oblique-ref.html create mode 100644 layout/reftests/font-matching/simple-oblique.html create mode 100644 layout/reftests/fonts/mark2A.woff create mode 100644 layout/reftests/fonts/mark2B.woff create mode 100644 layout/reftests/fonts/mark2C.woff create mode 100644 layout/reftests/fonts/mark2D.woff diff --git a/layout/reftests/font-matching/italic-oblique-1.html b/layout/reftests/font-matching/italic-oblique-1.html new file mode 100644 index 000000000000..7df94b51dc49 --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-1.html @@ -0,0 +1,31 @@ + + +style matching - italic/oblique + + + + + + + + + +

BBB

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-2.html b/layout/reftests/font-matching/italic-oblique-2.html new file mode 100644 index 000000000000..b3264120d56f --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-2.html @@ -0,0 +1,31 @@ + + +style matching - italic/oblique + + + + + + + + + +

CCC

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-3.html b/layout/reftests/font-matching/italic-oblique-3.html new file mode 100644 index 000000000000..cf897ae44dcd --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-3.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

BBB

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-4.html b/layout/reftests/font-matching/italic-oblique-4.html new file mode 100644 index 000000000000..2313462c340c --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-4.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

BBB

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-5.html b/layout/reftests/font-matching/italic-oblique-5.html new file mode 100644 index 000000000000..de1281b0a2eb --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-5.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

BBB

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-6.html b/layout/reftests/font-matching/italic-oblique-6.html new file mode 100644 index 000000000000..de23a2de9e21 --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-6.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

CCC

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-7.html b/layout/reftests/font-matching/italic-oblique-7.html new file mode 100644 index 000000000000..05cc3c45f44f --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-7.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

AAA

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-8.html b/layout/reftests/font-matching/italic-oblique-8.html new file mode 100644 index 000000000000..ee4ec956ffe4 --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-8.html @@ -0,0 +1,43 @@ + + +style matching - italic/oblique + + + + + + + + + +

CCC

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-9.html b/layout/reftests/font-matching/italic-oblique-9.html new file mode 100644 index 000000000000..dfc4012fa9c9 --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-9.html @@ -0,0 +1,43 @@ + + +style matching - italic/oblique + + + + + + + + + +

CCC

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-kinnari-ref.html b/layout/reftests/font-matching/italic-oblique-kinnari-ref.html new file mode 100644 index 000000000000..4499ebc0b434 --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-kinnari-ref.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

AAA

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-kinnari.html b/layout/reftests/font-matching/italic-oblique-kinnari.html new file mode 100644 index 000000000000..f465d247e4fb --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-kinnari.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

AAA

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-ref.html b/layout/reftests/font-matching/italic-oblique-ref.html new file mode 100644 index 000000000000..8ae9bbc19b94 --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-ref.html @@ -0,0 +1,24 @@ + + +style matching - italic/oblique + + + + + + + + + +

AAA

+ + + + diff --git a/layout/reftests/font-matching/reftest.list b/layout/reftests/font-matching/reftest.list index 884840336985..22d26734ef04 100644 --- a/layout/reftests/font-matching/reftest.list +++ b/layout/reftests/font-matching/reftest.list @@ -98,3 +98,16 @@ skip-if(Mulet) HTTP(..) == font-synthesis-2.html font-synthesis-2-ref.html # MUL # Bug 1060791 - support for format 10 cmap in Apple Symbols; # relevant fonts not present on other platforms. skip-if(!cocoaWidget) HTTP(..) != apple-symbols-1.html apple-symbols-1-notref.html + +# distinguish between italic and oblique +== simple-oblique.html simple-oblique-ref.html +== italic-oblique-1.html italic-oblique-ref.html +== italic-oblique-2.html italic-oblique-ref.html +== italic-oblique-3.html italic-oblique-ref.html +== italic-oblique-4.html italic-oblique-ref.html +== italic-oblique-5.html italic-oblique-ref.html +== italic-oblique-6.html italic-oblique-ref.html +== italic-oblique-7.html italic-oblique-ref.html +== italic-oblique-8.html italic-oblique-ref.html +== italic-oblique-9.html italic-oblique-ref.html +!= italic-oblique-kinnari.html italic-oblique-kinnari-ref.html diff --git a/layout/reftests/font-matching/simple-oblique-ref.html b/layout/reftests/font-matching/simple-oblique-ref.html new file mode 100644 index 000000000000..d021f51d02b6 --- /dev/null +++ b/layout/reftests/font-matching/simple-oblique-ref.html @@ -0,0 +1,33 @@ + + + +oblique italic equivalence + + + + + + + +

UNICORN asteroid

+

UNICORN asteroid

+

UNICORN asteroid

+ + + \ No newline at end of file diff --git a/layout/reftests/font-matching/simple-oblique.html b/layout/reftests/font-matching/simple-oblique.html new file mode 100644 index 000000000000..cb4671f4d85e --- /dev/null +++ b/layout/reftests/font-matching/simple-oblique.html @@ -0,0 +1,33 @@ + + + +oblique italic equivalence + + + + + + + +

UNICORN asteroid

+

UNICORN asteroid

+

UNICORN asteroid

+ + + \ No newline at end of file diff --git a/layout/reftests/fonts/mark2A.woff b/layout/reftests/fonts/mark2A.woff new file mode 100644 index 0000000000000000000000000000000000000000..58869bec71a78714fdb0ce0ee79a8486be55debc GIT binary patch literal 1084 zcmXT-cXMN4WB>vd8wOqw&H4pIVgqh&A-+I$3P3q2AeQl4_u`~~u)Yxk1LG1P-w}wz zLjR_kCFdp<0L6Yl#2B3z_?h1)mz5|mFfiEw#aO^tk*P90u^6b1MFPm@0O9}t8JN>^ zD${`Ke1QBaAg(EoT9}`anwSDK&j83b1Y)xf!3(N0fPz3Vpg4mZ5UX(RX6MbwEvW#C zy#VqBKv-0Qp*1Hz8K{oQ0m$b9;|zw7+{6ly`&xi}c_3C`@L;gaOUz9LsyhJ`Hv!VZ zYhO#U7UUO~FfcIx0jiM(Vy*w{7)&c}B`2gLBrrT`zjfX3_~+X-sSncX7)25-vKCI~ zUM?yrabudnTgD;dKefkU~*$S)G#yA zgPEb7iR~ZAFkl=4Ni8t6gZLvU02n$~l4cz}aOS|d1=}Z1biAJ?Y|VW*dU0>gn(`bo zLu1C7Jkm2A53Nyn==&z8ryeNObflM6l=W&a>r_!m%Xk_4b0)9zXDJ1pVPo5- z>QmjIX2j7f!dQ5Ua~iLDom|4L&;9KmPsfY1v9U2+)s{aEvb(hZyw_m|fn)pM&R-C4 zWU_hU2ZgtaiNYFF;#{-?+c#D-*&)3M!U6s}< zr*&TU)9&YHavxsqY@TQJ`A+MK?DLGj&(AoJ(9Wz=v}S`Fr=vVK&kW&=V;v@suS^tX zRZfjvtyB8deyN&zZe!<7*_?e*(=WyIs9da4F)lvStu(cBqjmCSBl9`415-9WY^)Yr zc~_;>txeTDv?6t)?&q$`S7OukqNUEvS=+IVB{}^~dGKXPC6_ZC^>321wmrRaBUH_E zNvh6S*Fy$9k2h@l*}v5CedL?JpO3ulzFYcMCSl%9+jy0z;}fq%{kvDp)FtOz4N3z^ z49)+~^0+y4O=Oha(BL{#B80(mC*xyK>@ouLBNHT@q%brom)(8u@FkFYZ;S*lgL5tG HS_TFHZ25Y1 literal 0 HcmV?d00001 diff --git a/layout/reftests/fonts/mark2B.woff b/layout/reftests/fonts/mark2B.woff new file mode 100644 index 0000000000000000000000000000000000000000..d1319a74c83e5b921a0d02a425b06f4c960ee762 GIT binary patch literal 1084 zcmXT-cXMN4WB>vd8wOqw&H4pIVgqh&A-+I$3P3q2AeQl4_u`~~u)Yxk1LG1P-w}wz zLjR?jC+8*>0L6Yl#2B5J`I+A)mz5|mFfiEw#aO^tk*P90u^6b1MFPm@0O9}t8JN>^ zD${`Ke1QBaAg(EoT9}`anwSDK&j83b1Y)xf!3(N0fPz3Vpg4mZ5UX(RX6MbwEvW#C zy#VqBKv-0Qp*1Hz8K{oQ0m$b9;|zw7+{6ly`&xi}c_3C`@L;gaOUz9LsyhJ`Hv!VZ z>)%VW7UUO~FfcIx0jiM(Vy*w{8B8l~B`2gLBrrUB{b~BSW1nx=q&`TiV-!iW$XYm^ zd%38j#EoeNZyAd$C1yA*Vz5x=`~cJl)pP6cfdc|Z&oQb<0@WB8EnpI3&}U%00hdom ze2|ck#K0(U@&toWal!>=PGI0PGBiQ-KTr5`=)kE12d*65(%#s(klo4HF2Nurg{jME zL!r?D24!X;4v%8r#Dau^q=KZdANdCbSg-MhGBcctgn(`bo zLu1C7Jkm2A53Nyn==&z8ryeNObflM6l=W&a>r_!m%Xk_4b0)9zXDJ1pVPo5- z>QmjIX2j7f!dQ5Ua~iLDom|4L&;9KmPsfY1v9U2+)s{aEvb(hZyw_m|fn)pM&R-C4 zWU_hU2ZgtaiNYFF;#jn8BR^hQEO6^W+p)ZxYVF@%omKzvO!`OIKKK1OVtX^#jP^@D zoBdPl0PDU57izXwd|D&$;B0aCpNBhprE99+DFlSi+r1;Cd>-?+c#D-*&)3M!U6s}< zr*&TU)9&YHavxsqY@TQJ`A+MK?DLGj&(AoJ(9Wz=v}S`Fr=vVK&kW&=V;v@suS^tX zRZfjvtyB8deyN&zZe!<7*_?e*(=WyIs9da4F)lvStu(cBqjmCSBl9`415-9WY^)Yr zc~_;>txeTDv?6t)?&q$`S7OukqNUEvS=+IVB{}^~dGKXPC6_ZC^>321wmrRaBUH_E zNvh6S*Fy$9k2h@l*}v5CedL?JpO3ulzFYcMCSl%9+jy0z;}fq%{kvDp)Z6FV3`zq@ z49)+~^0+y4O=Oha(BL{#B81U$7vmF9>@ouLBNHT@q%brom)(8u@FkFYZ;S*lgL5tG HS_TFH%+GsM literal 0 HcmV?d00001 diff --git a/layout/reftests/fonts/mark2C.woff b/layout/reftests/fonts/mark2C.woff new file mode 100644 index 0000000000000000000000000000000000000000..d21fd0722c3d69df711808a2576b12a1860f6ac0 GIT binary patch literal 1084 zcmXT-cXMN4WB>vd8wOqw&H4pIVgqh&A-+I$3P3q2AeQl4_u`~~u)Yxk1LG1P-w}wz zLjR{)B^ zD${`Ke1QBaAg(EoT9}`anwSDK&j83b1Y)xf!3(N0fPz3Vpg4mZ5UX(RX6MbwEvW#C zy#VqBKv-0Qp*1Hz8K{oQ0m$b9;|zw7+{6ly`&xi}c_3C`@L;gaOUz9LsyhJ`HwMze z8$Zjk7UUO~FfcIx0jiM(Vy*uh7)&c}B`2gLBrrUhz2~{#vCp?_QXiz%F^VKwWG$S| zyI+Cw~R%W5;GhYF&O{kyaCh*)pP6cfdc|Z&oQb<0@WB8EnpI3&}U!-DuBu- zBtA$;NMc|VIC+9Ws5s#QGbb=`8X1}(^3N0g96E67z=11Ax3o7lE@XEywo5QbNnz?T z+E8e8fI*pAh{L1UH?bh0Agv%R>_`4V0oH50q09`YS~*_<-N4Slpa`TuGzh1F>`X{V zYeA&}GpLpz8+k^+FCb0ulk(F11=oLjJc;zY;$X~Ndrhocww=Bz2t zF*7t~oXI0S)A7(6g@?Xxa(e24LQO|{Sw&f|_OebDm9&hPu|H?>I)9c@Fv|stHW4a{5H&b>_fTO_?A?0ThvkX<2&ao;? zI({O;T+2K5^Z6B;9@PqlPcMqS_EkOn)FWx_@=3FTH{MR2BoQq&JGAv-jMv1Y)7XW? zX5KyK>((b~ezhWT;`**xmG8vD^`fQD%w21k%b9lW#`|U4j2$~V1pnPQe&@~Vof}`r zJlZ&I<`!|z$p&4Ajynv~1#zIXT%$h|j4f|tR$ JmUS%y0{~kbd#L~b literal 0 HcmV?d00001 diff --git a/layout/reftests/fonts/mark2D.woff b/layout/reftests/fonts/mark2D.woff new file mode 100644 index 0000000000000000000000000000000000000000..3d42d6f40c845c3f6303456173f8eef0d6199318 GIT binary patch literal 1084 zcmXT-cXMN4WB>vd8wOqw&H4pIVgqh&A-+I$3P3q2AeQl4_u`~~u)Yxk1LG1P-w}wz z!WdF5lXDXbfMP!&VvJ4<{A}-&%Ssd&7?^B;Vk}^+$W)o0SPWFhA_3%cfbjqS49w{{ zm1#hAK0tmI5Z9DPEzHkIO-uorX8`0I0e&gPE?DOrK)CXyGj3S8^SqrCg zFBg@RxG~M(En|_T#0-Z;4EpCe4*)en_1rpq;DEr`WOp*QOE5@DVd^s4 zP-t|3L77>I!=u%nYa2a=rn&ft`av5lDe(5KaNPDIp=P zAwiPOjZI(!<0pxOHDYY63TK&G6!x9||6kzK|GE`kY;I<35|bMza(WmTE?{zFTf|^| z_yQ|Kmlr!D$S`0W0!b|}w1fB~DF7HcSCVEOJ#gm0xdq!NPISDVCTz`pIC^n!&YJQZ zGecv>nLN@n9S^Nhc7n$)O4hmRh0E=FY8oMNy~T{`*S9*^Jggqvs|!f6JcZ9 zrs`AOpk~C;EW%iLigOyTdYxRtteo}ru_s+x9#q5o{KHfRHwd#Y+hW}?gukK7SEnd|o zTD8J<`-%K{w`V*$T+D7;`fw+A;P!dU-{wy^u;7TG80)ng3z`=6tFoOjG)eZERs8Bm zr>t`F-4!~eXYCg+Q+V5WWQu$A8uO`NrZabLl{Kp4 z&xQE6`aG$bXu!2tBPZuya^}HmG4}s9g};@`W3AaEo_sqX-g)g}K(=oE`=4x6@_Z+Q z(m)bJ^Z&CvZVp`&8D%##xXzTg!f3gN@fj#~8G-qc36f4y7@CyJ?!I^U63D$bMuL~Y Kxt4V;0|Nj@EPt2) literal 0 HcmV?d00001 From adfbc1f710ad79accbf5c70857ff5661e415ce7f Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Sun, 18 Oct 2015 11:22:22 -0700 Subject: [PATCH 03/25] Back out 2 changesets (bug 543715) because Mulet is why we can't have nice things Backed out changeset 2d1d8e9b095c (bug 543715) Backed out changeset bc90276ec090 (bug 543715) --- gfx/thebes/gfxAndroidPlatform.cpp | 8 +- gfx/thebes/gfxAndroidPlatform.h | 4 +- gfx/thebes/gfxDWriteFontList.cpp | 16 ++- gfx/thebes/gfxDWriteFontList.h | 23 ++-- gfx/thebes/gfxDWriteFonts.cpp | 5 +- gfx/thebes/gfxFT2FontList.cpp | 25 ++-- gfx/thebes/gfxFT2FontList.h | 6 +- gfx/thebes/gfxFcPlatformFontList.cpp | 33 +++-- gfx/thebes/gfxFcPlatformFontList.h | 9 +- gfx/thebes/gfxFont.cpp | 4 +- gfx/thebes/gfxFontEntry.cpp | 113 +++++++----------- gfx/thebes/gfxFontEntry.h | 7 +- gfx/thebes/gfxFontconfigFonts.cpp | 20 ++-- gfx/thebes/gfxFontconfigFonts.h | 4 +- gfx/thebes/gfxGDIFont.cpp | 5 +- gfx/thebes/gfxGDIFontList.cpp | 43 ++++--- gfx/thebes/gfxGDIFontList.h | 10 +- gfx/thebes/gfxMacFont.cpp | 9 +- gfx/thebes/gfxMacPlatformFontList.h | 8 +- gfx/thebes/gfxMacPlatformFontList.mm | 21 ++-- gfx/thebes/gfxPlatform.cpp | 2 +- gfx/thebes/gfxPlatform.h | 4 +- gfx/thebes/gfxPlatformFontList.h | 4 +- gfx/thebes/gfxPlatformGtk.cpp | 15 ++- gfx/thebes/gfxPlatformGtk.h | 4 +- gfx/thebes/gfxPlatformMac.cpp | 8 +- gfx/thebes/gfxPlatformMac.h | 4 +- gfx/thebes/gfxQtPlatform.cpp | 8 +- gfx/thebes/gfxQtPlatform.h | 4 +- gfx/thebes/gfxUserFontSet.cpp | 38 +++--- gfx/thebes/gfxUserFontSet.h | 17 ++- gfx/thebes/gfxWindowsPlatform.cpp | 8 +- gfx/thebes/gfxWindowsPlatform.h | 4 +- .../font-matching/italic-oblique-1.html | 31 ----- .../font-matching/italic-oblique-2.html | 31 ----- .../font-matching/italic-oblique-3.html | 37 ------ .../font-matching/italic-oblique-4.html | 37 ------ .../font-matching/italic-oblique-5.html | 37 ------ .../font-matching/italic-oblique-6.html | 37 ------ .../font-matching/italic-oblique-7.html | 37 ------ .../font-matching/italic-oblique-8.html | 43 ------- .../font-matching/italic-oblique-9.html | 43 ------- .../italic-oblique-kinnari-ref.html | 37 ------ .../font-matching/italic-oblique-kinnari.html | 37 ------ .../font-matching/italic-oblique-ref.html | 24 ---- layout/reftests/font-matching/reftest.list | 13 -- .../font-matching/simple-oblique-ref.html | 33 ----- .../font-matching/simple-oblique.html | 33 ----- layout/reftests/fonts/mark2A.woff | Bin 1084 -> 0 bytes layout/reftests/fonts/mark2B.woff | Bin 1084 -> 0 bytes layout/reftests/fonts/mark2C.woff | Bin 1084 -> 0 bytes layout/reftests/fonts/mark2D.woff | Bin 1084 -> 0 bytes layout/style/FontFace.h | 4 +- layout/style/FontFaceSet.cpp | 12 +- layout/style/FontFaceSet.h | 4 +- 55 files changed, 239 insertions(+), 784 deletions(-) delete mode 100644 layout/reftests/font-matching/italic-oblique-1.html delete mode 100644 layout/reftests/font-matching/italic-oblique-2.html delete mode 100644 layout/reftests/font-matching/italic-oblique-3.html delete mode 100644 layout/reftests/font-matching/italic-oblique-4.html delete mode 100644 layout/reftests/font-matching/italic-oblique-5.html delete mode 100644 layout/reftests/font-matching/italic-oblique-6.html delete mode 100644 layout/reftests/font-matching/italic-oblique-7.html delete mode 100644 layout/reftests/font-matching/italic-oblique-8.html delete mode 100644 layout/reftests/font-matching/italic-oblique-9.html delete mode 100644 layout/reftests/font-matching/italic-oblique-kinnari-ref.html delete mode 100644 layout/reftests/font-matching/italic-oblique-kinnari.html delete mode 100644 layout/reftests/font-matching/italic-oblique-ref.html delete mode 100644 layout/reftests/font-matching/simple-oblique-ref.html delete mode 100644 layout/reftests/font-matching/simple-oblique.html delete mode 100644 layout/reftests/fonts/mark2A.woff delete mode 100644 layout/reftests/fonts/mark2B.woff delete mode 100644 layout/reftests/fonts/mark2C.woff delete mode 100644 layout/reftests/fonts/mark2D.woff diff --git a/gfx/thebes/gfxAndroidPlatform.cpp b/gfx/thebes/gfxAndroidPlatform.cpp index 1e0703dedc04..32986c6d0f03 100644 --- a/gfx/thebes/gfxAndroidPlatform.cpp +++ b/gfx/thebes/gfxAndroidPlatform.cpp @@ -328,26 +328,26 @@ gfxFontEntry* gfxAndroidPlatform::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) { return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(aFontName, aWeight, aStretch, - aStyle); + aItalic); } gfxFontEntry* gfxAndroidPlatform::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) { return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(aFontName, aWeight, aStretch, - aStyle, + aItalic, aFontData, aLength); } diff --git a/gfx/thebes/gfxAndroidPlatform.h b/gfx/thebes/gfxAndroidPlatform.h index c5fae095122d..3b93b0cd7d39 100644 --- a/gfx/thebes/gfxAndroidPlatform.h +++ b/gfx/thebes/gfxAndroidPlatform.h @@ -48,11 +48,11 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle); + bool aItalic); virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxDWriteFontList.cpp b/gfx/thebes/gfxDWriteFontList.cpp index 50c3d6d2f08c..ed3091c079a9 100644 --- a/gfx/thebes/gfxDWriteFontList.cpp +++ b/gfx/thebes/gfxDWriteFontList.cpp @@ -217,8 +217,7 @@ gfxDWriteFontFamily::FindStyleVariations(FontInfoData *aFontInfoData) " with style: %s weight: %d stretch: %d psname: %s fullname: %s", NS_ConvertUTF16toUTF8(fe->Name()).get(), NS_ConvertUTF16toUTF8(Name()).get(), - (fe->IsItalic()) ? - "italic" : (fe->IsOblique() ? "oblique" : "normal"), + (fe->IsItalic()) ? "italic" : "normal", fe->Weight(), fe->Stretch(), NS_ConvertUTF16toUTF8(psname).get(), NS_ConvertUTF16toUTF8(fullname).get())); @@ -389,7 +388,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag, // potential cmap discrepancies, see bug 629386. // Ditto for Hebrew, bug 837498. if (mFont && pFontList->UseGDIFontTableAccess() && - !(mStyle && UsingArabicOrHebrewScriptSystemLocale()) && + !(mItalic && UsingArabicOrHebrewScriptSystemLocale()) && !mFont->IsSymbolFont()) { LOGFONTW logfont = { 0 }; @@ -744,7 +743,7 @@ gfxFontEntry * gfxDWriteFontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) { gfxFontEntry *lookup; @@ -759,7 +758,7 @@ gfxDWriteFontList::LookupLocalFont(const nsAString& aFontName, dwriteLookup->mFont, aWeight, aStretch, - aStyle); + aItalic); fe->SetForceGDIClassic(dwriteLookup->GetForceGDIClassic()); return fe; } @@ -768,7 +767,7 @@ gfxFontEntry * gfxDWriteFontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) { @@ -833,7 +832,7 @@ gfxDWriteFontList::MakePlatformFont(const nsAString& aFontName, fontFile, aWeight, aStretch, - aStyle); + aItalic); fontFile->Analyze(&isSupported, &fileType, &entry->mFaceType, &numFaces); if (!isSupported || numFaces > 1) { @@ -975,8 +974,7 @@ gfxDWriteFontList::InitFontList() " with style: %s weight: %d stretch: %d", NS_ConvertUTF16toUTF8(fe->Name()).get(), NS_ConvertUTF16toUTF8(gillSansMTFamily->Name()).get(), - (fe->IsItalic()) ? - "italic" : (fe->IsOblique() ? "oblique" : "normal"), + (fe->IsItalic()) ? "italic" : "normal", fe->Weight(), fe->Stretch())); } } diff --git a/gfx/thebes/gfxDWriteFontList.h b/gfx/thebes/gfxDWriteFontList.h index 9ce336136471..370dc7c1018e 100644 --- a/gfx/thebes/gfxDWriteFontList.h +++ b/gfx/thebes/gfxDWriteFontList.h @@ -80,11 +80,8 @@ public: : gfxFontEntry(aFaceName), mFont(aFont), mFontFile(nullptr), mForceGDIClassic(false) { - DWRITE_FONT_STYLE dwriteStyle = aFont->GetStyle(); - mStyle = (dwriteStyle == DWRITE_FONT_STYLE_ITALIC ? - NS_FONT_STYLE_ITALIC : - (dwriteStyle == DWRITE_FONT_STYLE_OBLIQUE ? - NS_FONT_STYLE_OBLIQUE : NS_FONT_STYLE_NORMAL)); + mItalic = (aFont->GetStyle() == DWRITE_FONT_STYLE_ITALIC || + aFont->GetStyle() == DWRITE_FONT_STYLE_OBLIQUE); mStretch = FontStretchFromDWriteStretch(aFont->GetStretch()); uint16_t weight = NS_ROUNDUP(aFont->GetWeight() - 50, 100); @@ -104,19 +101,19 @@ public: * \param aFont DirectWrite font object * \param aWeight Weight of the font * \param aStretch Stretch of the font - * \param aStyle italic or oblique of font + * \param aItalic True if italic */ gfxDWriteFontEntry(const nsAString& aFaceName, IDWriteFont *aFont, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) : gfxFontEntry(aFaceName), mFont(aFont), mFontFile(nullptr), mForceGDIClassic(false) { mWeight = aWeight; mStretch = aStretch; - mStyle = aStyle; + mItalic = aItalic; mIsLocalUserFont = true; mIsCJK = UNINITIALIZED_VALUE; } @@ -128,19 +125,19 @@ public: * \param aFontFile DirectWrite fontfile object * \param aWeight Weight of the font * \param aStretch Stretch of the font - * \param aStyle italic or oblique of font + * \param aItalic True if italic */ gfxDWriteFontEntry(const nsAString& aFaceName, IDWriteFontFile *aFontFile, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) : gfxFontEntry(aFaceName), mFont(nullptr), mFontFile(aFontFile), mForceGDIClassic(false) { mWeight = aWeight; mStretch = aStretch; - mStyle = aStyle; + mItalic = aItalic; mIsDataUserFont = true; mIsCJK = UNINITIALIZED_VALUE; } @@ -352,12 +349,12 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle); + bool aItalic); virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxDWriteFonts.cpp b/gfx/thebes/gfxDWriteFonts.cpp index 72a5c1f45bb9..3f387615a732 100644 --- a/gfx/thebes/gfxDWriteFonts.cpp +++ b/gfx/thebes/gfxDWriteFonts.cpp @@ -85,9 +85,8 @@ gfxDWriteFont::gfxDWriteFont(gfxFontEntry *aFontEntry, static_cast(aFontEntry); nsresult rv; DWRITE_FONT_SIMULATIONS sims = DWRITE_FONT_SIMULATIONS_NONE; - if ((GetStyle()->style != NS_FONT_STYLE_NORMAL) && - fe->IsUpright() && - GetStyle()->allowSyntheticStyle) { + if ((GetStyle()->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) && + !fe->IsItalic() && GetStyle()->allowSyntheticStyle) { // For this we always use the font_matrix for uniformity. Not the // DWrite simulation. mNeedsOblique = true; diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 148110fdb7c9..7a019646fbda 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -188,9 +188,9 @@ FT2FontEntry::CreateScaledFont(const gfxFontStyle *aStyle) cairo_matrix_init_identity(&identityMatrix); // synthetic oblique by skewing via the font matrix - bool needsOblique = IsUpright() && - aStyle->style != NS_FONT_STYLE_NORMAL && - aStyle->allowSyntheticStyle; + bool needsOblique = !IsItalic() && + (aStyle->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) && + aStyle->allowSyntheticStyle; if (needsOblique) { cairo_matrix_t style; @@ -251,7 +251,7 @@ FT2FontEntry* FT2FontEntry::CreateFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) { @@ -277,7 +277,7 @@ FT2FontEntry::CreateFontEntry(const nsAString& aFontName, FT2FontEntry::CreateFontEntry(face, nullptr, 0, aFontName, aFontData); if (fe) { - fe->mStyle = aStyle; + fe->mItalic = aItalic; fe->mWeight = aWeight; fe->mStretch = aStretch; fe->mIsDataUserFont = true; @@ -323,7 +323,7 @@ FT2FontEntry::CreateFontEntry(const FontListEntry& aFLE) fe->mFTFontIndex = aFLE.index(); fe->mWeight = aFLE.weight(); fe->mStretch = aFLE.stretch(); - fe->mStyle = (aFLE.italic() ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL); + fe->mItalic = aFLE.italic(); return fe; } @@ -380,8 +380,7 @@ FT2FontEntry::CreateFontEntry(FT_Face aFace, const uint8_t* aFontData) { FT2FontEntry *fe = new FT2FontEntry(aName); - fe->mStyle = (FTFaceIsItalic(aFace) ? - NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL); + fe->mItalic = FTFaceIsItalic(aFace); fe->mWeight = FTFaceGetWeight(aFace); fe->mFilename = aFilename; fe->mFTFontIndex = aIndex; @@ -597,7 +596,7 @@ FT2FontFamily::AddFacesToFontList(InfallibleTArray* aFontList, aFontList->AppendElement(FontListEntry(Name(), fe->Name(), fe->mFilename, fe->Weight(), fe->Stretch(), - fe->mStyle, + fe->IsItalic(), fe->mFTFontIndex, aVisibility == kHidden)); } @@ -1453,7 +1452,7 @@ gfxFontEntry* gfxFT2FontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) { // walk over list of names FT2FontEntry* fontEntry = nullptr; @@ -1510,7 +1509,7 @@ searchDone: fontEntry->mFTFontIndex, fontEntry->Name(), nullptr); if (fe) { - fe->mStyle = aStyle; + fe->mItalic = aItalic; fe->mWeight = aWeight; fe->mStretch = aStretch; fe->mIsLocalUserFont = true; @@ -1539,7 +1538,7 @@ gfxFontEntry* gfxFT2FontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) { @@ -1547,7 +1546,7 @@ gfxFT2FontList::MakePlatformFont(const nsAString& aFontName, // but instead pass ownership to the font entry. // Deallocation will happen later, when the font face is destroyed. return FT2FontEntry::CreateFontEntry(aFontName, aWeight, aStretch, - aStyle, aFontData, aLength); + aItalic, aFontData, aLength); } void diff --git a/gfx/thebes/gfxFT2FontList.h b/gfx/thebes/gfxFT2FontList.h index c5748a704bc4..ecccf2b12e2f 100644 --- a/gfx/thebes/gfxFT2FontList.h +++ b/gfx/thebes/gfxFT2FontList.h @@ -42,7 +42,7 @@ public: CreateFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength); @@ -125,12 +125,12 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle); + bool aItalic); virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxFcPlatformFontList.cpp b/gfx/thebes/gfxFcPlatformFontList.cpp index 784ff5accb5f..cf4fd11cc44a 100644 --- a/gfx/thebes/gfxFcPlatformFontList.cpp +++ b/gfx/thebes/gfxFcPlatformFontList.cpp @@ -256,10 +256,8 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, if (FcPatternGetInteger(aFontPattern, FC_SLANT, 0, &slant) != FcResultMatch) { slant = FC_SLANT_ROMAN; } - if (slant == FC_SLANT_OBLIQUE) { - mStyle = NS_FONT_STYLE_OBLIQUE; - } else if (slant > 0) { - mStyle = NS_FONT_STYLE_ITALIC; + if (slant > 0) { + mItalic = true; } // weight @@ -280,7 +278,7 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t *aData, FT_Face aFace) : gfxFontEntry(aFaceName), @@ -288,7 +286,7 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, mAspect(0.0), mFontData(aData) { mWeight = aWeight; - mStyle = aStyle; + mItalic = aItalic; mStretch = aStretch; mIsDataUserFont = true; @@ -321,13 +319,13 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, FcPattern* aFontPattern, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) : gfxFontEntry(aFaceName), mFontPattern(aFontPattern), mFTFace(nullptr), mFTFaceInitialized(false), mAspect(0.0), mFontData(nullptr) { mWeight = aWeight; - mStyle = aStyle; + mItalic = aItalic; mStretch = aStretch; mIsLocalUserFont = true; } @@ -672,9 +670,9 @@ gfxFontconfigFontEntry::CreateScaledFont(FcPattern* aRenderPattern, } // synthetic oblique by skewing via the font matrix - bool needsOblique = IsUpright() && - aStyle->style != NS_FONT_STYLE_NORMAL && - aStyle->allowSyntheticStyle; + bool needsOblique = !IsItalic() && + (aStyle->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) && + aStyle->allowSyntheticStyle; if (needsOblique) { // disable embedded bitmaps (mimics behavior in 90-synthetic.conf) @@ -865,8 +863,7 @@ gfxFontconfigFontFamily::FindStyleVariations(FontInfoData *aFontInfoData) " psname: %s fullname: %s", NS_ConvertUTF16toUTF8(fontEntry->Name()).get(), NS_ConvertUTF16toUTF8(Name()).get(), - (fontEntry->IsItalic()) ? - "italic" : (fontEntry->IsOblique() ? "oblique" : "normal"), + fontEntry->IsItalic() ? "italic" : "normal", fontEntry->Weight(), fontEntry->Stretch(), NS_ConvertUTF16toUTF8(psname).get(), NS_ConvertUTF16toUTF8(fullname).get())); @@ -1175,7 +1172,7 @@ gfxFontEntry* gfxFcPlatformFontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) { nsAutoString keyName(aFontName); ToLowerCase(keyName); @@ -1188,14 +1185,14 @@ gfxFcPlatformFontList::LookupLocalFont(const nsAString& aFontName, return new gfxFontconfigFontEntry(aFontName, fontPattern, - aWeight, aStretch, aStyle); + aWeight, aStretch, aItalic); } gfxFontEntry* gfxFcPlatformFontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) { @@ -1213,8 +1210,8 @@ gfxFcPlatformFontList::MakePlatformFont(const nsAString& aFontName, return nullptr; } - return new gfxFontconfigFontEntry(aFontName, aWeight, aStretch, - aStyle, aFontData, face); + return new gfxFontconfigFontEntry(aFontName, aWeight, aStretch, aItalic, + aFontData, face); } gfxFontFamily* diff --git a/gfx/thebes/gfxFcPlatformFontList.h b/gfx/thebes/gfxFcPlatformFontList.h index 4f5ec324a091..32f743971cfd 100644 --- a/gfx/thebes/gfxFcPlatformFontList.h +++ b/gfx/thebes/gfxFcPlatformFontList.h @@ -99,7 +99,7 @@ public: explicit gfxFontconfigFontEntry(const nsAString& aFaceName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t *aData, FT_Face aFace); @@ -108,7 +108,7 @@ public: FcPattern* aFontPattern, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle); + bool aItalic); FcPattern* GetPattern() { return mFontPattern; } @@ -209,12 +209,11 @@ public: gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, - int16_t aStretch, uint8_t aStyle) override; + int16_t aStretch, bool aItalic) override; gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, - int16_t aStretch, - uint8_t aStyle, + int16_t aStretch, bool aItalic, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index 5db1dc67ebda..c409af6666cc 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -2290,9 +2290,7 @@ gfxFont::Measure(gfxTextRun *aTextRun, // If the font may be rendered with a fake-italic effect, we need to allow // for the top-right of the glyphs being skewed to the right, and the // bottom-left being skewed further left. - if (mStyle.style != NS_FONT_STYLE_NORMAL && - mFontEntry->IsUpright() && - mStyle.allowSyntheticStyle) { + if (mStyle.style != NS_FONT_STYLE_NORMAL && !mFontEntry->IsItalic()) { gfxFloat extendLeftEdge = ceil(OBLIQUE_SKEW_FACTOR * metrics.mBoundingBox.YMost()); gfxFloat extendRightEdge = diff --git a/gfx/thebes/gfxFontEntry.cpp b/gfx/thebes/gfxFontEntry.cpp index 50a3e887ac42..53d53566705e 100644 --- a/gfx/thebes/gfxFontEntry.cpp +++ b/gfx/thebes/gfxFontEntry.cpp @@ -68,7 +68,7 @@ gfxCharacterMap::NotifyReleased() } gfxFontEntry::gfxFontEntry() : - mStyle(NS_FONT_STYLE_NORMAL), mFixedPitch(false), + mItalic(false), mFixedPitch(false), mIsValid(true), mIsBadUnderlineFont(false), mIsUserFontContainer(false), @@ -108,7 +108,7 @@ gfxFontEntry::gfxFontEntry() : } gfxFontEntry::gfxFontEntry(const nsAString& aName, bool aIsStandardFace) : - mName(aName), mStyle(NS_FONT_STYLE_NORMAL), mFixedPitch(false), + mName(aName), mItalic(false), mFixedPitch(false), mIsValid(true), mIsBadUnderlineFont(false), mIsUserFontContainer(false), @@ -1155,69 +1155,57 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle, return nullptr; } -#define STYLE_SHIFT 2 // number of bits to contain style distance - -// style distance ==> [0,2] static inline uint32_t -StyleDistance(uint32_t aFontStyle, uint32_t aTargetStyle) +StyleStretchDistance(gfxFontEntry *aFontEntry, bool aTargetItalic, + int16_t aTargetStretch) { - if (aFontStyle == aTargetStyle) { - return 0; // styles match exactly ==> 0 - } - if (aFontStyle == NS_FONT_STYLE_NORMAL || - aTargetStyle == NS_FONT_STYLE_NORMAL) { - return 2; // one is normal (but not the other) ==> 2 - } - return 1; // neither is normal; must be italic vs oblique ==> 1 -} + // Compute a measure of the "distance" between the requested style + // and the given fontEntry, + // considering italicness and font-stretch but not weight. -#define REVERSE_STRETCH_DISTANCE 5 - -// stretch distance ==> [0,13] -static inline uint32_t -StretchDistance(int16_t aFontStretch, int16_t aTargetStretch) -{ int32_t distance = 0; - if (aTargetStretch != aFontStretch) { + if (aTargetStretch != aFontEntry->mStretch) { // stretch values are in the range -4 .. +4 // if aTargetStretch is positive, we prefer more-positive values; // if zero or negative, prefer more-negative if (aTargetStretch > 0) { - distance = (aFontStretch - aTargetStretch); + distance = (aFontEntry->mStretch - aTargetStretch) * 2; } else { - distance = (aTargetStretch - aFontStretch); + distance = (aTargetStretch - aFontEntry->mStretch) * 2; } // if the computed "distance" here is negative, it means that // aFontEntry lies in the "non-preferred" direction from aTargetStretch, // so we treat that as larger than any preferred-direction distance - // (max possible is 4) by adding an extra 5 to the absolute value + // (max possible is 8) by adding an extra 10 to the absolute value if (distance < 0) { - distance = -distance + REVERSE_STRETCH_DISTANCE; + distance = -distance + 10; } } + if (aFontEntry->IsItalic() != aTargetItalic) { + distance += 1; + } return uint32_t(distance); } +#define NON_DESIRED_DIRECTION_DISTANCE 1000 +#define MAX_WEIGHT_DISTANCE 2000 + // CSS currently limits font weights to multiples of 100 but the weight // matching code below does not assume this. // -// Calculate weight distance with values in the range (0..1000). In general, -// heavier weights match towards even heavier weights while lighter weights -// match towards even lighter weights. Target weight values in the range -// [400..500] are special, since they will first match up to 500, then down -// towards 0, then up again towards 999. +// Calculate weight values with range (0..1000). In general, heavier weights +// match towards even heavier weights while lighter weights match towards even +// lighter weights. Target weight values in the range [400..500] are special, +// since they will first match up to 500, then down to 0, then up again +// towards 999. // // Example: with target 600 and font weight 800, distance will be 200. With -// target 300 and font weight 600, distance will be 900, since heavier -// weights are farther away than lighter weights. If the target is 5 and the -// font weight 995, the distance would be 1590 for the same reason. +// target 300 and font weight 600, distance will be 1300, since heavier weights +// are farther away than lighter weights. If the target is 5 and the font weight +// 995, the distance would be 1990 for the same reason. -#define REVERSE_WEIGHT_DISTANCE 600 -#define WEIGHT_SHIFT 11 // number of bits to contain weight distance - -// weight distance ==> [0,1598] static inline uint32_t -WeightDistance(uint32_t aFontWeight, uint32_t aTargetWeight) +WeightDistance(uint32_t aTargetWeight, uint32_t aFontWeight) { // Compute a measure of the "distance" between the requested // weight and the given fontEntry @@ -1247,34 +1235,13 @@ WeightDistance(uint32_t aFontWeight, uint32_t aTargetWeight) } } if (distance < 0) { - distance = -distance + REVERSE_WEIGHT_DISTANCE; + distance = -distance + NON_DESIRED_DIRECTION_DISTANCE; } distance += addedDistance; } return uint32_t(distance); } -#define MAX_DISTANCE 0xffffffff - -static inline uint32_t -WeightStyleStretchDistance(gfxFontEntry* aFontEntry, - const gfxFontStyle& aTargetStyle) -{ - // weight/style/stretch priority: stretch >> style >> weight - uint32_t stretchDist = - StretchDistance(aFontEntry->mStretch, aTargetStyle.stretch); - uint32_t styleDist = StyleDistance(aFontEntry->mStyle, aTargetStyle.style); - uint32_t weightDist = - WeightDistance(aFontEntry->Weight(), aTargetStyle.weight); - - NS_ASSERTION(weightDist < (1 << WEIGHT_SHIFT), "weight value out of bounds"); - NS_ASSERTION(styleDist < (1 << STYLE_SHIFT), "slope value out of bounds"); - - return (stretchDist << (STYLE_SHIFT + WEIGHT_SHIFT)) | - (styleDist << WEIGHT_SHIFT) | - weightDist; -} - void gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle, nsTArray& aFontEntryList, @@ -1304,6 +1271,9 @@ gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle, return; } + bool wantItalic = (aFontStyle.style & + (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; + // Most families are "simple", having just Regular/Bold/Italic/BoldItalic, // or some subset of these. In this case, we have exactly 4 entries in mAvailableFonts, // stored in the above order; note that some of the entries may be nullptr. @@ -1315,7 +1285,6 @@ gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle, // Family has no more than the "standard" 4 faces, at fixed indexes; // calculate which one we want. // Note that we cannot simply return it as not all 4 faces are necessarily present. - bool wantItalic = (aFontStyle.style != NS_FONT_STYLE_NORMAL); uint8_t faceIndex = (wantItalic ? kItalicMask : 0) | (wantBold ? kBoldMask : 0); @@ -1363,14 +1332,16 @@ gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle, // weight/style/stretch combination, only the last matched font entry will // be added. - uint32_t minDistance = MAX_DISTANCE; + uint32_t minDistance = 0xffffffff; gfxFontEntry* matched = nullptr; // iterate in forward order so that faces like 'Bold' are matched before // matching style distance faces such as 'Bold Outline' (see bug 1185812) for (uint32_t i = 0; i < count; i++) { fe = mAvailableFonts[i]; - // weight/style/stretch priority: stretch >> style >> weight - uint32_t distance = WeightStyleStretchDistance(fe, aFontStyle); + uint32_t distance = + WeightDistance(aFontStyle.weight, fe->Weight()) + + (StyleStretchDistance(fe, wantItalic, aFontStyle.stretch) * + MAX_WEIGHT_DISTANCE); if (distance < minDistance) { matched = fe; if (!aFontEntryList.IsEmpty()) { @@ -1420,9 +1391,8 @@ gfxFontFamily::CheckForSimpleFamily() gfxFontEntry *faces[4] = { 0 }; for (uint8_t i = 0; i < count; ++i) { gfxFontEntry *fe = mAvailableFonts[i]; - if (fe->Stretch() != firstStretch || fe->IsOblique()) { - // simple families don't have varying font-stretch or oblique - return; + if (fe->Stretch() != firstStretch) { + return; // font-stretch doesn't match, don't treat as simple family } uint8_t faceIndex = (fe->IsItalic() ? kItalicMask : 0) | (fe->Weight() >= 600 ? kBoldMask : 0); @@ -1478,8 +1448,9 @@ CalcStyleMatch(gfxFontEntry *aFontEntry, const gfxFontStyle *aStyle) int32_t rank = 0; if (aStyle) { // italics - bool wantUpright = (aStyle->style == NS_FONT_STYLE_NORMAL); - if (aFontEntry->IsUpright() == wantUpright) { + bool wantItalic = + (aStyle->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; + if (aFontEntry->IsItalic() == wantItalic) { rank += 10; } @@ -1487,7 +1458,7 @@ CalcStyleMatch(gfxFontEntry *aFontEntry, const gfxFontStyle *aStyle) rank += 9 - DeprecatedAbs(aFontEntry->Weight() / 100 - aStyle->ComputeWeight()); } else { // if no font to match, prefer non-bold, non-italic fonts - if (aFontEntry->IsUpright()) { + if (!aFontEntry->IsItalic()) { rank += 3; } if (!aFontEntry->IsBold()) { diff --git a/gfx/thebes/gfxFontEntry.h b/gfx/thebes/gfxFontEntry.h index d11f117b14c3..c1e1a365d57a 100644 --- a/gfx/thebes/gfxFontEntry.h +++ b/gfx/thebes/gfxFontEntry.h @@ -8,7 +8,6 @@ #include "gfxTypes.h" #include "nsString.h" -#include "gfxFontConstants.h" #include "gfxFontFeatures.h" #include "gfxFontUtils.h" #include "nsTArray.h" @@ -122,9 +121,7 @@ public: bool IsUserFont() const { return mIsDataUserFont || mIsLocalUserFont; } bool IsLocalUserFont() const { return mIsLocalUserFont; } bool IsFixedPitch() const { return mFixedPitch; } - bool IsItalic() const { return mStyle == NS_FONT_STYLE_ITALIC; } - bool IsOblique() const { return mStyle == NS_FONT_STYLE_OBLIQUE; } - bool IsUpright() const { return mStyle == NS_FONT_STYLE_NORMAL; } + bool IsItalic() const { return mItalic; } bool IsBold() const { return mWeight >= 600; } // bold == weights 600 and above bool IgnoreGDEF() const { return mIgnoreGDEF; } bool IgnoreGSUB() const { return mIgnoreGSUB; } @@ -391,7 +388,7 @@ public: nsString mName; nsString mFamilyName; - uint8_t mStyle : 2; // italic/oblique + bool mItalic : 1; bool mFixedPitch : 1; bool mIsValid : 1; bool mIsBadUnderlineFont : 1; diff --git a/gfx/thebes/gfxFontconfigFonts.cpp b/gfx/thebes/gfxFontconfigFonts.cpp index a23d52e9c2e0..6bf0576687a9 100644 --- a/gfx/thebes/gfxFontconfigFonts.cpp +++ b/gfx/thebes/gfxFontconfigFonts.cpp @@ -335,10 +335,10 @@ protected: explicit gfxUserFcFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) : gfxFcFontEntry(aFontName) { - mStyle = aStyle; + mItalic = aItalic; mWeight = aWeight; mStretch = aStretch; } @@ -421,9 +421,9 @@ public: gfxLocalFcFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const nsTArray< nsCountedRef >& aPatterns) - : gfxUserFcFontEntry(aFontName, aWeight, aStretch, aStyle) + : gfxUserFcFontEntry(aFontName, aWeight, aStretch, aItalic) { if (!mPatterns.SetCapacity(aPatterns.Length(), fallible)) return; // OOM @@ -458,9 +458,9 @@ public: gfxDownloadedFcFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t *aData, FT_Face aFace) - : gfxUserFcFontEntry(aFontName, aWeight, aStretch, aStyle), + : gfxUserFcFontEntry(aFontName, aWeight, aStretch, aItalic), mFontData(aData), mFace(aFace) { NS_PRECONDITION(aFace != nullptr, "aFace is NULL!"); @@ -1748,7 +1748,7 @@ gfxPangoFontGroup::Shutdown() gfxPangoFontGroup::NewFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) { gfxFontconfigUtils *utils = gfxFontconfigUtils::GetFontconfigUtils(); if (!utils) @@ -1791,7 +1791,7 @@ gfxPangoFontGroup::NewFontEntry(const nsAString& aFontName, return new gfxLocalFcFontEntry(aFontName, aWeight, aStretch, - aStyle, + aItalic, fonts); } @@ -1833,7 +1833,7 @@ gfxPangoFontGroup::GetFTLibrary() gfxPangoFontGroup::NewFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) { @@ -1851,7 +1851,7 @@ gfxPangoFontGroup::NewFontEntry(const nsAString& aFontName, } return new gfxDownloadedFcFontEntry(aFontName, aWeight, - aStretch, aStyle, + aStretch, aItalic, aFontData, face); } diff --git a/gfx/thebes/gfxFontconfigFonts.h b/gfx/thebes/gfxFontconfigFonts.h index 0d91a2a24a91..fe77332e8981 100644 --- a/gfx/thebes/gfxFontconfigFonts.h +++ b/gfx/thebes/gfxFontconfigFonts.h @@ -45,12 +45,12 @@ public: static gfxFontEntry *NewFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle); + bool aItalic); // Used for @font-face { src: url(); } static gfxFontEntry *NewFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxGDIFont.cpp b/gfx/thebes/gfxGDIFont.cpp index 9d01c49ea535..6c212a1f083e 100644 --- a/gfx/thebes/gfxGDIFont.cpp +++ b/gfx/thebes/gfxGDIFont.cpp @@ -177,8 +177,9 @@ gfxGDIFont::Initialize() // Figure out if we want to do synthetic oblique styling. GDIFontEntry* fe = static_cast(GetFontEntry()); - bool wantFakeItalic = mStyle.style != NS_FONT_STYLE_NORMAL && - fe->IsUpright() && mStyle.allowSyntheticStyle; + bool wantFakeItalic = + (mStyle.style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) && + !fe->IsItalic() && mStyle.allowSyntheticStyle; // If the font's family has an actual italic face (but font matching // didn't choose it), we have to use a cairo transform instead of asking diff --git a/gfx/thebes/gfxGDIFontList.cpp b/gfx/thebes/gfxGDIFontList.cpp index 8d4ff569d3e1..504f9fdd6791 100644 --- a/gfx/thebes/gfxGDIFontList.cpp +++ b/gfx/thebes/gfxGDIFontList.cpp @@ -118,8 +118,7 @@ FontTypeToOutPrecision(uint8_t fontType) GDIFontEntry::GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType, - uint8_t aStyle, uint16_t aWeight, - int16_t aStretch, + bool aItalic, uint16_t aWeight, int16_t aStretch, gfxUserFontData *aUserFontData, bool aFamilyHasItalicFace) : gfxFontEntry(aFaceName), @@ -130,7 +129,7 @@ GDIFontEntry::GDIFontEntry(const nsAString& aFaceName, mCharset(), mUnicodeRanges() { mUserFontData = aUserFontData; - mStyle = aStyle; + mItalic = aItalic; mWeight = aWeight; mStretch = aStretch; if (IsType1()) @@ -307,10 +306,9 @@ GDIFontEntry::TestCharacterMap(uint32_t aCh) return false; // previous code was using the group style - gfxFontStyle fakeStyle; - if (!IsUpright()) { + gfxFontStyle fakeStyle; + if (mItalic) fakeStyle.style = NS_FONT_STYLE_ITALIC; - } fakeStyle.weight = mWeight * 100; RefPtr tempFont = FindOrMakeFont(&fakeStyle, false); @@ -389,7 +387,7 @@ GDIFontEntry::InitLogFont(const nsAString& aName, // do its best to give us an italic font entry, but if no face exists // it may give us a regular one based on weight. Windows should // do fake italic for us in that case. - mLogFont.lfItalic = !IsUpright(); + mLogFont.lfItalic = mItalic; mLogFont.lfWeight = mWeight; int len = std::min(aName.Length(), LF_FACESIZE - 1); @@ -399,15 +397,14 @@ GDIFontEntry::InitLogFont(const nsAString& aName, GDIFontEntry* GDIFontEntry::CreateFontEntry(const nsAString& aName, - gfxWindowsFontType aFontType, - uint8_t aStyle, + gfxWindowsFontType aFontType, bool aItalic, uint16_t aWeight, int16_t aStretch, gfxUserFontData* aUserFontData, bool aFamilyHasItalicFace) { // jtdfix - need to set charset, unicode ranges, pitch/family - GDIFontEntry *fe = new GDIFontEntry(aName, aFontType, aStyle, + GDIFontEntry *fe = new GDIFontEntry(aName, aFontType, aItalic, aWeight, aStretch, aUserFontData, aFamilyHasItalicFace); @@ -459,7 +456,7 @@ GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe, fe = static_cast(ff->mAvailableFonts[i].get()); // check if we already know about this face if (fe->mWeight == logFont.lfWeight && - fe->IsItalic() == (logFont.lfItalic == 0xFF)) { + fe->mItalic == (logFont.lfItalic == 0xFF)) { // update the charset bit here since this could be different fe->mCharset.set(metrics.tmCharSet); return 1; @@ -469,10 +466,8 @@ GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe, // We can't set the hasItalicFace flag correctly here, // because we might not have seen the family's italic face(s) yet. // So we'll set that flag for all members after loading all the faces. - uint8_t italicStyle = (logFont.lfItalic == 0xFF ? - NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL); fe = GDIFontEntry::CreateFontEntry(nsDependentString(lpelfe->elfFullName), - feType, italicStyle, + feType, (logFont.lfItalic == 0xFF), (uint16_t) (logFont.lfWeight), 0, nullptr, false); if (!fe) @@ -717,7 +712,7 @@ gfxFontEntry* gfxGDIFontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) { gfxFontEntry *lookup; @@ -734,9 +729,10 @@ gfxGDIFontList::LookupLocalFont(const nsAString& aFontName, // 'Arial Vet' which can be used as a key in GDI font lookups). GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(lookup->Name(), gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/, - lookup->mStyle, lookup->mWeight, aStretch, nullptr, + lookup->mItalic ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL, + lookup->mWeight, aStretch, nullptr, static_cast(lookup)->mFamilyHasItalicFace); - + if (!fe) return nullptr; @@ -744,7 +740,7 @@ gfxGDIFontList::LookupLocalFont(const nsAString& aFontName, // make the new font entry match the userfont entry style characteristics fe->mWeight = (aWeight == 0 ? 400 : aWeight); - fe->mStyle = aStyle; + fe->mItalic = aItalic; return fe; } @@ -753,7 +749,7 @@ gfxFontEntry* gfxGDIFontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) { @@ -812,16 +808,17 @@ gfxGDIFontList::MakePlatformFont(const nsAString& aFontName, WinUserFontData *winUserFontData = new WinUserFontData(fontRef); uint16_t w = (aWeight == 0 ? 400 : aWeight); - GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(uniqueName, - gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/, - aStyle, w, aStretch, winUserFontData, false); + GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(uniqueName, + gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/, + uint32_t(aItalic ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL), + w, aStretch, winUserFontData, false); if (!fe) return fe; fe->mIsDataUserFont = true; - // Uniscribe doesn't place CFF fonts loaded privately + // Uniscribe doesn't place CFF fonts loaded privately // via AddFontMemResourceEx on XP/Vista if (isCFF && !IsWin7OrLater()) { fe->mForceGDI = true; diff --git a/gfx/thebes/gfxGDIFontList.h b/gfx/thebes/gfxGDIFontList.h index 4fca9324e22a..81ad45aa7601 100644 --- a/gfx/thebes/gfxGDIFontList.h +++ b/gfx/thebes/gfxGDIFontList.h @@ -236,7 +236,7 @@ public: // create a font entry for a font with a given name static GDIFontEntry* CreateFontEntry(const nsAString& aName, gfxWindowsFontType aFontType, - uint8_t aStyle, + bool aItalic, uint16_t aWeight, int16_t aStretch, gfxUserFontData* aUserFontData, bool aFamilyHasItalicFace); @@ -245,7 +245,7 @@ public: static GDIFontEntry* LoadLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle); + bool aItalic); uint8_t mWindowsFamily; uint8_t mWindowsPitch; @@ -266,7 +266,7 @@ protected: friend class gfxWindowsFont; GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType, - uint8_t aStyle, uint16_t aWeight, int16_t aStretch, + bool aItalic, uint16_t aWeight, int16_t aStretch, gfxUserFontData *aUserFontData, bool aFamilyHasItalicFace); void InitLogFont(const nsAString& aName, gfxWindowsFontType aFontType); @@ -311,12 +311,12 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle); + bool aItalic); virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp index 239899b010ec..1e0600c891c3 100644 --- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -61,10 +61,11 @@ gfxMacFont::gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyl cairo_matrix_init_scale(&sizeMatrix, mAdjustedSize, mAdjustedSize); // synthetic oblique by skewing via the font matrix - bool needsOblique = mFontEntry != nullptr && - mFontEntry->IsUpright() && - mStyle.style != NS_FONT_STYLE_NORMAL && - mStyle.allowSyntheticStyle; + bool needsOblique = + (mFontEntry != nullptr) && + (!mFontEntry->IsItalic() && + (mStyle.style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE))) && + mStyle.allowSyntheticStyle; if (needsOblique) { cairo_matrix_t style; diff --git a/gfx/thebes/gfxMacPlatformFontList.h b/gfx/thebes/gfxMacPlatformFontList.h index 7804cde41374..232d5bb05171 100644 --- a/gfx/thebes/gfxMacPlatformFontList.h +++ b/gfx/thebes/gfxMacPlatformFontList.h @@ -33,7 +33,7 @@ public: // for use with data fonts MacOSFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef, - uint16_t aWeight, uint16_t aStretch, uint8_t aStyle, + uint16_t aWeight, uint16_t aStretch, uint32_t aItalicStyle, bool aIsDataUserFont, bool aIsLocal); virtual ~MacOSFontEntry() { @@ -86,12 +86,12 @@ public: gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) override; - + bool aItalic) override; + gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index d1c8817cb06c..801af8c51d1c 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -268,7 +268,7 @@ MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName, MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef, uint16_t aWeight, uint16_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, bool aIsDataUserFont, bool aIsLocalUserFont) : gfxFontEntry(aPostscriptName, false), @@ -285,7 +285,7 @@ MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName, mWeight = aWeight; mStretch = aStretch; mFixedPitch = false; // xxx - do we need this for downloaded fonts? - mStyle = aStyle; + mItalic = (aItalicStyle & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; NS_ASSERTION(!(aIsDataUserFont && aIsLocalUserFont), "userfont is either a data font or a local font"); @@ -523,7 +523,7 @@ gfxMacFontFamily::FindStyleVariations(FontInfoData *aFontInfoData) [facename hasSuffix:@"Italic"] || [facename hasSuffix:@"Oblique"]) { - fontEntry->mStyle = NS_FONT_STYLE_ITALIC; + fontEntry->mItalic = true; } if (macTraits & NSFixedPitchFontMask) { fontEntry->mFixedPitch = true; @@ -1009,7 +1009,7 @@ gfxFontEntry* gfxMacPlatformFontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) { nsAutoreleasePool localPool; @@ -1026,7 +1026,10 @@ gfxMacPlatformFontList::LookupLocalFont(const nsAString& aFontName, "bogus font weight value!"); newFontEntry = - new MacOSFontEntry(aFontName, fontRef, aWeight, aStretch, aStyle, + new MacOSFontEntry(aFontName, fontRef, + aWeight, aStretch, + aItalic ? + NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL, false, true); ::CFRelease(fontRef); @@ -1042,7 +1045,7 @@ gfxFontEntry* gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) { @@ -1070,7 +1073,11 @@ gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName, nsAutoPtr newFontEntry(new MacOSFontEntry(uniqueName, fontRef, aWeight, - aStretch, aStyle, true, false)); + aStretch, + aItalic ? + NS_FONT_STYLE_ITALIC : + NS_FONT_STYLE_NORMAL, + true, false)); ::CFRelease(fontRef); // if succeeded and font cmap is good, return the new font diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index a072dcc080c5..69bac9d2faa4 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -1376,7 +1376,7 @@ gfxFontEntry* gfxPlatform::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) { diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 3ab789f10f04..2b23ce625df2 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -348,7 +348,7 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) { return nullptr; } /** @@ -362,7 +362,7 @@ public: virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxPlatformFontList.h b/gfx/thebes/gfxPlatformFontList.h index fccb6e08b3b6..d36b32d7c673 100644 --- a/gfx/thebes/gfxPlatformFontList.h +++ b/gfx/thebes/gfxPlatformFontList.h @@ -153,14 +153,14 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) = 0; + bool aItalic) = 0; // create a new platform font from downloaded data (@font-face) // this method is responsible to ensure aFontData is free()'d virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) = 0; diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index 74ac7af7d63e..a77ec2395018 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -256,35 +256,34 @@ gfxFontEntry* gfxPlatformGtk::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) { if (sUseFcFontList) { gfxPlatformFontList* pfl = gfxPlatformFontList::PlatformFontList(); - return pfl->LookupLocalFont(aFontName, aWeight, aStretch, - aStyle); + return pfl->LookupLocalFont(aFontName, aWeight, aStretch, aItalic); } return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight, - aStretch, aStyle); + aStretch, aItalic); } gfxFontEntry* gfxPlatformGtk::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) { if (sUseFcFontList) { gfxPlatformFontList* pfl = gfxPlatformFontList::PlatformFontList(); - return pfl->MakePlatformFont(aFontName, aWeight, aStretch, - aStyle, aFontData, aLength); + return pfl->MakePlatformFont(aFontName, aWeight, aStretch, aItalic, + aFontData, aLength); } // passing ownership of the font data to the new font entry return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight, - aStretch, aStyle, + aStretch, aItalic, aFontData, aLength); } diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h index b32ac6b99fb2..548d7b704d73 100644 --- a/gfx/thebes/gfxPlatformGtk.h +++ b/gfx/thebes/gfxPlatformGtk.h @@ -63,7 +63,7 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) override; + bool aItalic) override; /** * Activate a platform font (needed to support @font-face src url() ) @@ -72,7 +72,7 @@ public: virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp index b320febbb8ac..ca589a0f5305 100644 --- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -152,19 +152,19 @@ gfxFontEntry* gfxPlatformMac::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) { return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(aFontName, aWeight, aStretch, - aStyle); + aItalic); } gfxFontEntry* gfxPlatformMac::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) { @@ -174,7 +174,7 @@ gfxPlatformMac::MakePlatformFont(const nsAString& aFontName, return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(aFontName, aWeight, aStretch, - aStyle, + aItalic, aFontData, aLength); } diff --git a/gfx/thebes/gfxPlatformMac.h b/gfx/thebes/gfxPlatformMac.h index e0edb9cdeb19..a4046e6933a4 100644 --- a/gfx/thebes/gfxPlatformMac.h +++ b/gfx/thebes/gfxPlatformMac.h @@ -44,14 +44,14 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) override; + bool aItalic) override; virtual gfxPlatformFontList* CreatePlatformFontList() override; virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxQtPlatform.cpp b/gfx/thebes/gfxQtPlatform.cpp index 1aed17ccaa32..371d847618d9 100644 --- a/gfx/thebes/gfxQtPlatform.cpp +++ b/gfx/thebes/gfxQtPlatform.cpp @@ -132,23 +132,23 @@ gfxFontEntry* gfxQtPlatform::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) { return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight, - aStretch, aStyle); + aStretch, aItalic); } gfxFontEntry* gfxQtPlatform::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) { // passing ownership of the font data to the new font entry return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight, - aStretch, aStyle, + aStretch, aItalic, aFontData, aLength); } diff --git a/gfx/thebes/gfxQtPlatform.h b/gfx/thebes/gfxQtPlatform.h index ed5c26e942e5..fad09180df53 100644 --- a/gfx/thebes/gfxQtPlatform.h +++ b/gfx/thebes/gfxQtPlatform.h @@ -54,7 +54,7 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) override; + bool aItalic) override; /** * Activate a platform font (needed to support @font-face src url() ) @@ -63,7 +63,7 @@ public: virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxUserFontSet.cpp b/gfx/thebes/gfxUserFontSet.cpp index a210956dc297..c1c726afd95a 100644 --- a/gfx/thebes/gfxUserFontSet.cpp +++ b/gfx/thebes/gfxUserFontSet.cpp @@ -109,7 +109,7 @@ gfxUserFontEntry::gfxUserFontEntry(gfxUserFontSet* aFontSet, const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) @@ -127,7 +127,9 @@ gfxUserFontEntry::gfxUserFontEntry(gfxUserFontSet* aFontSet, mSrcIndex = 0; mWeight = aWeight; mStretch = aStretch; - mStyle = aStyle; + // XXX Currently, we don't distinguish 'italic' and 'oblique' styles; + // we need to fix this. (Bug 543715) + mItalic = (aItalicStyle & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; mFeatureSettings.AppendElements(aFeatureSettings); mLanguageOverride = aLanguageOverride; @@ -145,14 +147,18 @@ bool gfxUserFontEntry::Matches(const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) { + // XXX font entries don't distinguish italic from oblique (bug 543715) + bool isItalic = + (aItalicStyle & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; + return mWeight == aWeight && mStretch == aStretch && - mStyle == aStyle && + mItalic == isItalic && mFeatureSettings == aFeatureSettings && mLanguageOverride == aLanguageOverride && mSrcList == aFontFaceSrcList && @@ -406,7 +412,7 @@ gfxUserFontEntry::LoadNextSrc() gfxPlatform::GetPlatform()->LookupLocalFont(currSrc.mLocalName, mWeight, mStretch, - mStyle); + mItalic); nsTArray fontSets; GetUserFontSets(fontSets); for (gfxUserFontSet* fontSet : fontSets) { @@ -606,10 +612,11 @@ gfxUserFontEntry::LoadPlatformFont(const uint8_t* aFontData, uint32_t& aLength) originalFullName); // Here ownership of saneData is passed to the platform, // which will delete it when no longer required + fe = gfxPlatform::GetPlatform()->MakePlatformFont(mName, mWeight, mStretch, - mStyle, + mItalic, saneData, saneLen); if (!fe) { @@ -764,7 +771,7 @@ gfxUserFontSet::FindOrCreateUserFontEntry( const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) @@ -780,14 +787,14 @@ gfxUserFontSet::FindOrCreateUserFontEntry( gfxUserFontFamily* family = LookupFamily(aFamilyName); if (family) { entry = FindExistingUserFontEntry(family, aFontFaceSrcList, aWeight, - aStretch, aStyle, + aStretch, aItalicStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); } if (!entry) { entry = CreateUserFontEntry(aFontFaceSrcList, aWeight, aStretch, - aStyle, aFeatureSettings, + aItalicStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); entry->mFamilyName = aFamilyName; } @@ -800,7 +807,7 @@ gfxUserFontSet::CreateUserFontEntry( const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) @@ -808,7 +815,7 @@ gfxUserFontSet::CreateUserFontEntry( RefPtr userFontEntry = new gfxUserFontEntry(this, aFontFaceSrcList, aWeight, - aStretch, aStyle, aFeatureSettings, + aStretch, aItalicStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); return userFontEntry.forget(); } @@ -819,7 +826,7 @@ gfxUserFontSet::FindExistingUserFontEntry( const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) @@ -837,7 +844,7 @@ gfxUserFontSet::FindExistingUserFontEntry( gfxUserFontEntry* existingUserFontEntry = static_cast(fontList[i].get()); if (!existingUserFontEntry->Matches(aFontFaceSrcList, - aWeight, aStretch, aStyle, + aWeight, aStretch, aItalicStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges)) { continue; @@ -860,8 +867,7 @@ gfxUserFontSet::AddUserFontEntry(const nsAString& aFamilyName, LOG(("userfonts (%p) added to \"%s\" (%p) style: %s weight: %d " "stretch: %d", this, NS_ConvertUTF16toUTF8(aFamilyName).get(), aUserFontEntry, - (aUserFontEntry->IsItalic() ? "italic" : - (aUserFontEntry->IsOblique() ? "oblique" : "normal")), + (aUserFontEntry->IsItalic() ? "italic" : "normal"), aUserFontEntry->Weight(), aUserFontEntry->Stretch())); } } @@ -1044,7 +1050,7 @@ gfxUserFontSet::UserFontCache::Entry::KeyEquals(const KeyTypePointer aKey) const } } - if (mFontEntry->mStyle != fe->mStyle || + if (mFontEntry->mItalic != fe->mItalic || mFontEntry->mWeight != fe->mWeight || mFontEntry->mStretch != fe->mStretch || mFontEntry->mFeatureSettings != fe->mFeatureSettings || diff --git a/gfx/thebes/gfxUserFontSet.h b/gfx/thebes/gfxUserFontSet.h index 567227ed939c..320c9c088370 100644 --- a/gfx/thebes/gfxUserFontSet.h +++ b/gfx/thebes/gfxUserFontSet.h @@ -16,7 +16,6 @@ #include "nsIScriptError.h" #include "nsURIHashKey.h" #include "mozilla/net/ReferrerPolicy.h" -#include "gfxFontConstants.h" class nsFontFaceLoader; @@ -211,7 +210,7 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) = 0; @@ -223,7 +222,7 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges); @@ -417,9 +416,9 @@ public: nsURIHashKey::HashKey(aKey->mURI), HashFeatures(aKey->mFontEntry->mFeatureSettings), mozilla::HashString(aKey->mFontEntry->mFamilyName), - (aKey->mFontEntry->mStyle | - (aKey->mFontEntry->mWeight << 2) | - (aKey->mFontEntry->mStretch << 11) ) ^ + ((uint32_t)aKey->mFontEntry->mItalic | + (aKey->mFontEntry->mWeight << 1) | + (aKey->mFontEntry->mStretch << 10) ) ^ aKey->mFontEntry->mLanguageOverride); } @@ -496,7 +495,7 @@ protected: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges); @@ -535,7 +534,7 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges); @@ -546,7 +545,7 @@ public: bool Matches(const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges); diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 7ff3561ea300..556507b8f6d3 100755 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -1056,26 +1056,26 @@ gfxFontEntry* gfxWindowsPlatform::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle) + bool aItalic) { return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(aFontName, aWeight, aStretch, - aStyle); + aItalic); } gfxFontEntry* gfxWindowsPlatform::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength) { return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(aFontName, aWeight, aStretch, - aStyle, + aItalic, aFontData, aLength); } diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 0d6005ba5e5a..7e3bfd15947e 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -193,7 +193,7 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle); + bool aItalic); /** * Activate a platform font (needed to support @font-face src url() ) @@ -201,7 +201,7 @@ public: virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle, + bool aItalic, const uint8_t* aFontData, uint32_t aLength); diff --git a/layout/reftests/font-matching/italic-oblique-1.html b/layout/reftests/font-matching/italic-oblique-1.html deleted file mode 100644 index 7df94b51dc49..000000000000 --- a/layout/reftests/font-matching/italic-oblique-1.html +++ /dev/null @@ -1,31 +0,0 @@ - - -style matching - italic/oblique - - - - - - - - - -

BBB

- - - - diff --git a/layout/reftests/font-matching/italic-oblique-2.html b/layout/reftests/font-matching/italic-oblique-2.html deleted file mode 100644 index b3264120d56f..000000000000 --- a/layout/reftests/font-matching/italic-oblique-2.html +++ /dev/null @@ -1,31 +0,0 @@ - - -style matching - italic/oblique - - - - - - - - - -

CCC

- - - - diff --git a/layout/reftests/font-matching/italic-oblique-3.html b/layout/reftests/font-matching/italic-oblique-3.html deleted file mode 100644 index cf897ae44dcd..000000000000 --- a/layout/reftests/font-matching/italic-oblique-3.html +++ /dev/null @@ -1,37 +0,0 @@ - - -style matching - italic/oblique - - - - - - - - - -

BBB

- - - - diff --git a/layout/reftests/font-matching/italic-oblique-4.html b/layout/reftests/font-matching/italic-oblique-4.html deleted file mode 100644 index 2313462c340c..000000000000 --- a/layout/reftests/font-matching/italic-oblique-4.html +++ /dev/null @@ -1,37 +0,0 @@ - - -style matching - italic/oblique - - - - - - - - - -

BBB

- - - - diff --git a/layout/reftests/font-matching/italic-oblique-5.html b/layout/reftests/font-matching/italic-oblique-5.html deleted file mode 100644 index de1281b0a2eb..000000000000 --- a/layout/reftests/font-matching/italic-oblique-5.html +++ /dev/null @@ -1,37 +0,0 @@ - - -style matching - italic/oblique - - - - - - - - - -

BBB

- - - - diff --git a/layout/reftests/font-matching/italic-oblique-6.html b/layout/reftests/font-matching/italic-oblique-6.html deleted file mode 100644 index de23a2de9e21..000000000000 --- a/layout/reftests/font-matching/italic-oblique-6.html +++ /dev/null @@ -1,37 +0,0 @@ - - -style matching - italic/oblique - - - - - - - - - -

CCC

- - - - diff --git a/layout/reftests/font-matching/italic-oblique-7.html b/layout/reftests/font-matching/italic-oblique-7.html deleted file mode 100644 index 05cc3c45f44f..000000000000 --- a/layout/reftests/font-matching/italic-oblique-7.html +++ /dev/null @@ -1,37 +0,0 @@ - - -style matching - italic/oblique - - - - - - - - - -

AAA

- - - - diff --git a/layout/reftests/font-matching/italic-oblique-8.html b/layout/reftests/font-matching/italic-oblique-8.html deleted file mode 100644 index ee4ec956ffe4..000000000000 --- a/layout/reftests/font-matching/italic-oblique-8.html +++ /dev/null @@ -1,43 +0,0 @@ - - -style matching - italic/oblique - - - - - - - - - -

CCC

- - - - diff --git a/layout/reftests/font-matching/italic-oblique-9.html b/layout/reftests/font-matching/italic-oblique-9.html deleted file mode 100644 index dfc4012fa9c9..000000000000 --- a/layout/reftests/font-matching/italic-oblique-9.html +++ /dev/null @@ -1,43 +0,0 @@ - - -style matching - italic/oblique - - - - - - - - - -

CCC

- - - - diff --git a/layout/reftests/font-matching/italic-oblique-kinnari-ref.html b/layout/reftests/font-matching/italic-oblique-kinnari-ref.html deleted file mode 100644 index 4499ebc0b434..000000000000 --- a/layout/reftests/font-matching/italic-oblique-kinnari-ref.html +++ /dev/null @@ -1,37 +0,0 @@ - - -style matching - italic/oblique - - - - - - - - - -

AAA

- - - - diff --git a/layout/reftests/font-matching/italic-oblique-kinnari.html b/layout/reftests/font-matching/italic-oblique-kinnari.html deleted file mode 100644 index f465d247e4fb..000000000000 --- a/layout/reftests/font-matching/italic-oblique-kinnari.html +++ /dev/null @@ -1,37 +0,0 @@ - - -style matching - italic/oblique - - - - - - - - - -

AAA

- - - - diff --git a/layout/reftests/font-matching/italic-oblique-ref.html b/layout/reftests/font-matching/italic-oblique-ref.html deleted file mode 100644 index 8ae9bbc19b94..000000000000 --- a/layout/reftests/font-matching/italic-oblique-ref.html +++ /dev/null @@ -1,24 +0,0 @@ - - -style matching - italic/oblique - - - - - - - - - -

AAA

- - - - diff --git a/layout/reftests/font-matching/reftest.list b/layout/reftests/font-matching/reftest.list index 22d26734ef04..884840336985 100644 --- a/layout/reftests/font-matching/reftest.list +++ b/layout/reftests/font-matching/reftest.list @@ -98,16 +98,3 @@ skip-if(Mulet) HTTP(..) == font-synthesis-2.html font-synthesis-2-ref.html # MUL # Bug 1060791 - support for format 10 cmap in Apple Symbols; # relevant fonts not present on other platforms. skip-if(!cocoaWidget) HTTP(..) != apple-symbols-1.html apple-symbols-1-notref.html - -# distinguish between italic and oblique -== simple-oblique.html simple-oblique-ref.html -== italic-oblique-1.html italic-oblique-ref.html -== italic-oblique-2.html italic-oblique-ref.html -== italic-oblique-3.html italic-oblique-ref.html -== italic-oblique-4.html italic-oblique-ref.html -== italic-oblique-5.html italic-oblique-ref.html -== italic-oblique-6.html italic-oblique-ref.html -== italic-oblique-7.html italic-oblique-ref.html -== italic-oblique-8.html italic-oblique-ref.html -== italic-oblique-9.html italic-oblique-ref.html -!= italic-oblique-kinnari.html italic-oblique-kinnari-ref.html diff --git a/layout/reftests/font-matching/simple-oblique-ref.html b/layout/reftests/font-matching/simple-oblique-ref.html deleted file mode 100644 index d021f51d02b6..000000000000 --- a/layout/reftests/font-matching/simple-oblique-ref.html +++ /dev/null @@ -1,33 +0,0 @@ - - - -oblique italic equivalence - - - - - - - -

UNICORN asteroid

-

UNICORN asteroid

-

UNICORN asteroid

- - - \ No newline at end of file diff --git a/layout/reftests/font-matching/simple-oblique.html b/layout/reftests/font-matching/simple-oblique.html deleted file mode 100644 index cb4671f4d85e..000000000000 --- a/layout/reftests/font-matching/simple-oblique.html +++ /dev/null @@ -1,33 +0,0 @@ - - - -oblique italic equivalence - - - - - - - -

UNICORN asteroid

-

UNICORN asteroid

-

UNICORN asteroid

- - - \ No newline at end of file diff --git a/layout/reftests/fonts/mark2A.woff b/layout/reftests/fonts/mark2A.woff deleted file mode 100644 index 58869bec71a78714fdb0ce0ee79a8486be55debc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1084 zcmXT-cXMN4WB>vd8wOqw&H4pIVgqh&A-+I$3P3q2AeQl4_u`~~u)Yxk1LG1P-w}wz zLjR_kCFdp<0L6Yl#2B3z_?h1)mz5|mFfiEw#aO^tk*P90u^6b1MFPm@0O9}t8JN>^ zD${`Ke1QBaAg(EoT9}`anwSDK&j83b1Y)xf!3(N0fPz3Vpg4mZ5UX(RX6MbwEvW#C zy#VqBKv-0Qp*1Hz8K{oQ0m$b9;|zw7+{6ly`&xi}c_3C`@L;gaOUz9LsyhJ`Hv!VZ zYhO#U7UUO~FfcIx0jiM(Vy*w{7)&c}B`2gLBrrT`zjfX3_~+X-sSncX7)25-vKCI~ zUM?yrabudnTgD;dKefkU~*$S)G#yA zgPEb7iR~ZAFkl=4Ni8t6gZLvU02n$~l4cz}aOS|d1=}Z1biAJ?Y|VW*dU0>gn(`bo zLu1C7Jkm2A53Nyn==&z8ryeNObflM6l=W&a>r_!m%Xk_4b0)9zXDJ1pVPo5- z>QmjIX2j7f!dQ5Ua~iLDom|4L&;9KmPsfY1v9U2+)s{aEvb(hZyw_m|fn)pM&R-C4 zWU_hU2ZgtaiNYFF;#{-?+c#D-*&)3M!U6s}< zr*&TU)9&YHavxsqY@TQJ`A+MK?DLGj&(AoJ(9Wz=v}S`Fr=vVK&kW&=V;v@suS^tX zRZfjvtyB8deyN&zZe!<7*_?e*(=WyIs9da4F)lvStu(cBqjmCSBl9`415-9WY^)Yr zc~_;>txeTDv?6t)?&q$`S7OukqNUEvS=+IVB{}^~dGKXPC6_ZC^>321wmrRaBUH_E zNvh6S*Fy$9k2h@l*}v5CedL?JpO3ulzFYcMCSl%9+jy0z;}fq%{kvDp)FtOz4N3z^ z49)+~^0+y4O=Oha(BL{#B80(mC*xyK>@ouLBNHT@q%brom)(8u@FkFYZ;S*lgL5tG HS_TFHZ25Y1 diff --git a/layout/reftests/fonts/mark2B.woff b/layout/reftests/fonts/mark2B.woff deleted file mode 100644 index d1319a74c83e5b921a0d02a425b06f4c960ee762..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1084 zcmXT-cXMN4WB>vd8wOqw&H4pIVgqh&A-+I$3P3q2AeQl4_u`~~u)Yxk1LG1P-w}wz zLjR?jC+8*>0L6Yl#2B5J`I+A)mz5|mFfiEw#aO^tk*P90u^6b1MFPm@0O9}t8JN>^ zD${`Ke1QBaAg(EoT9}`anwSDK&j83b1Y)xf!3(N0fPz3Vpg4mZ5UX(RX6MbwEvW#C zy#VqBKv-0Qp*1Hz8K{oQ0m$b9;|zw7+{6ly`&xi}c_3C`@L;gaOUz9LsyhJ`Hv!VZ z>)%VW7UUO~FfcIx0jiM(Vy*w{8B8l~B`2gLBrrUB{b~BSW1nx=q&`TiV-!iW$XYm^ zd%38j#EoeNZyAd$C1yA*Vz5x=`~cJl)pP6cfdc|Z&oQb<0@WB8EnpI3&}U%00hdom ze2|ck#K0(U@&toWal!>=PGI0PGBiQ-KTr5`=)kE12d*65(%#s(klo4HF2Nurg{jME zL!r?D24!X;4v%8r#Dau^q=KZdANdCbSg-MhGBcctgn(`bo zLu1C7Jkm2A53Nyn==&z8ryeNObflM6l=W&a>r_!m%Xk_4b0)9zXDJ1pVPo5- z>QmjIX2j7f!dQ5Ua~iLDom|4L&;9KmPsfY1v9U2+)s{aEvb(hZyw_m|fn)pM&R-C4 zWU_hU2ZgtaiNYFF;#jn8BR^hQEO6^W+p)ZxYVF@%omKzvO!`OIKKK1OVtX^#jP^@D zoBdPl0PDU57izXwd|D&$;B0aCpNBhprE99+DFlSi+r1;Cd>-?+c#D-*&)3M!U6s}< zr*&TU)9&YHavxsqY@TQJ`A+MK?DLGj&(AoJ(9Wz=v}S`Fr=vVK&kW&=V;v@suS^tX zRZfjvtyB8deyN&zZe!<7*_?e*(=WyIs9da4F)lvStu(cBqjmCSBl9`415-9WY^)Yr zc~_;>txeTDv?6t)?&q$`S7OukqNUEvS=+IVB{}^~dGKXPC6_ZC^>321wmrRaBUH_E zNvh6S*Fy$9k2h@l*}v5CedL?JpO3ulzFYcMCSl%9+jy0z;}fq%{kvDp)Z6FV3`zq@ z49)+~^0+y4O=Oha(BL{#B81U$7vmF9>@ouLBNHT@q%brom)(8u@FkFYZ;S*lgL5tG HS_TFH%+GsM diff --git a/layout/reftests/fonts/mark2C.woff b/layout/reftests/fonts/mark2C.woff deleted file mode 100644 index d21fd0722c3d69df711808a2576b12a1860f6ac0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1084 zcmXT-cXMN4WB>vd8wOqw&H4pIVgqh&A-+I$3P3q2AeQl4_u`~~u)Yxk1LG1P-w}wz zLjR{)B^ zD${`Ke1QBaAg(EoT9}`anwSDK&j83b1Y)xf!3(N0fPz3Vpg4mZ5UX(RX6MbwEvW#C zy#VqBKv-0Qp*1Hz8K{oQ0m$b9;|zw7+{6ly`&xi}c_3C`@L;gaOUz9LsyhJ`HwMze z8$Zjk7UUO~FfcIx0jiM(Vy*uh7)&c}B`2gLBrrUhz2~{#vCp?_QXiz%F^VKwWG$S| zyI+Cw~R%W5;GhYF&O{kyaCh*)pP6cfdc|Z&oQb<0@WB8EnpI3&}U!-DuBu- zBtA$;NMc|VIC+9Ws5s#QGbb=`8X1}(^3N0g96E67z=11Ax3o7lE@XEywo5QbNnz?T z+E8e8fI*pAh{L1UH?bh0Agv%R>_`4V0oH50q09`YS~*_<-N4Slpa`TuGzh1F>`X{V zYeA&}GpLpz8+k^+FCb0ulk(F11=oLjJc;zY;$X~Ndrhocww=Bz2t zF*7t~oXI0S)A7(6g@?Xxa(e24LQO|{Sw&f|_OebDm9&hPu|H?>I)9c@Fv|stHW4a{5H&b>_fTO_?A?0ThvkX<2&ao;? zI({O;T+2K5^Z6B;9@PqlPcMqS_EkOn)FWx_@=3FTH{MR2BoQq&JGAv-jMv1Y)7XW? zX5KyK>((b~ezhWT;`**xmG8vD^`fQD%w21k%b9lW#`|U4j2$~V1pnPQe&@~Vof}`r zJlZ&I<`!|z$p&4Ajynv~1#zIXT%$h|j4f|tR$ JmUS%y0{~kbd#L~b diff --git a/layout/reftests/fonts/mark2D.woff b/layout/reftests/fonts/mark2D.woff deleted file mode 100644 index 3d42d6f40c845c3f6303456173f8eef0d6199318..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1084 zcmXT-cXMN4WB>vd8wOqw&H4pIVgqh&A-+I$3P3q2AeQl4_u`~~u)Yxk1LG1P-w}wz z!WdF5lXDXbfMP!&VvJ4<{A}-&%Ssd&7?^B;Vk}^+$W)o0SPWFhA_3%cfbjqS49w{{ zm1#hAK0tmI5Z9DPEzHkIO-uorX8`0I0e&gPE?DOrK)CXyGj3S8^SqrCg zFBg@RxG~M(En|_T#0-Z;4EpCe4*)en_1rpq;DEr`WOp*QOE5@DVd^s4 zP-t|3L77>I!=u%nYa2a=rn&ft`av5lDe(5KaNPDIp=P zAwiPOjZI(!<0pxOHDYY63TK&G6!x9||6kzK|GE`kY;I<35|bMza(WmTE?{zFTf|^| z_yQ|Kmlr!D$S`0W0!b|}w1fB~DF7HcSCVEOJ#gm0xdq!NPISDVCTz`pIC^n!&YJQZ zGecv>nLN@n9S^Nhc7n$)O4hmRh0E=FY8oMNy~T{`*S9*^Jggqvs|!f6JcZ9 zrs`AOpk~C;EW%iLigOyTdYxRtteo}ru_s+x9#q5o{KHfRHwd#Y+hW}?gukK7SEnd|o zTD8J<`-%K{w`V*$T+D7;`fw+A;P!dU-{wy^u;7TG80)ng3z`=6tFoOjG)eZERs8Bm zr>t`F-4!~eXYCg+Q+V5WWQu$A8uO`NrZabLl{Kp4 z&xQE6`aG$bXu!2tBPZuya^}HmG4}s9g};@`W3AaEo_sqX-g)g}K(=oE`=4x6@_Z+Q z(m)bJ^Z&CvZVp`&8D%##xXzTg!f3gN@fj#~8G-qc36f4y7@CyJ?!I^U63D$bMuL~Y Kxt4V;0|Nj@EPt2) diff --git a/layout/style/FontFace.h b/layout/style/FontFace.h index 58072b6e507d..1d6cfe0f78d1 100644 --- a/layout/style/FontFace.h +++ b/layout/style/FontFace.h @@ -44,12 +44,12 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) : gfxUserFontEntry(aFontSet, aFontFaceSrcList, aWeight, aStretch, - aStyle, aFeatureSettings, aLanguageOverride, + aItalicStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges) {} virtual void SetLoadState(UserFontLoadState aLoadState) override; diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 7362eb87f7e1..2eda306d1252 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -169,7 +169,7 @@ FontFaceSet::ParseFontShorthandForMatching( RefPtr& aFamilyList, uint32_t& aWeight, int32_t& aStretch, - uint8_t& aStyle, + uint32_t& aItalicStyle, ErrorResult& aRv) { // Parse aFont as a 'font' property value. @@ -224,7 +224,7 @@ FontFaceSet::ParseFontShorthandForMatching( aWeight = weight; aStretch = data->ValueFor(eCSSProperty_font_stretch)->GetIntValue(); - aStyle = data->ValueFor(eCSSProperty_font_style)->GetIntValue(); + aItalicStyle = data->ValueFor(eCSSProperty_font_style)->GetIntValue(); } static bool @@ -252,7 +252,7 @@ FontFaceSet::FindMatchingFontFaces(const nsAString& aFont, RefPtr familyList; uint32_t weight; int32_t stretch; - uint8_t italicStyle; + uint32_t italicStyle; ParseFontShorthandForMatching(aFont, familyList, weight, stretch, italicStyle, aRv); if (aRv.Failed()) { @@ -964,7 +964,7 @@ FontFaceSet::FindOrCreateUserFontEntryFromFontFace(const nsAString& aFamilyName, uint32_t weight = NS_STYLE_FONT_WEIGHT_NORMAL; int32_t stretch = NS_STYLE_FONT_STRETCH_NORMAL; - uint8_t italicStyle = NS_STYLE_FONT_STYLE_NORMAL; + uint32_t italicStyle = NS_STYLE_FONT_STYLE_NORMAL; uint32_t languageOverride = NO_FONT_LANGUAGE_OVERRIDE; // set up weight @@ -1772,13 +1772,13 @@ FontFaceSet::UserFontSet::CreateUserFontEntry( const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) { RefPtr entry = - new FontFace::Entry(this, aFontFaceSrcList, aWeight, aStretch, aStyle, + new FontFace::Entry(this, aFontFaceSrcList, aWeight, aStretch, aItalicStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); return entry.forget(); } diff --git a/layout/style/FontFaceSet.h b/layout/style/FontFaceSet.h index e2e435a301bf..782f36de097e 100644 --- a/layout/style/FontFaceSet.h +++ b/layout/style/FontFaceSet.h @@ -83,7 +83,7 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint8_t aStyle, + uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) override; @@ -286,7 +286,7 @@ private: RefPtr& aFamilyList, uint32_t& aWeight, int32_t& aStretch, - uint8_t& aStyle, + uint32_t& aItalicStyle, ErrorResult& aRv); void FindMatchingFontFaces(const nsAString& aFont, const nsAString& aText, From 406d1e9fbe6518a42a593dd6992cfed3b1a956fe Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Mon, 19 Oct 2015 00:01:58 +0900 Subject: [PATCH 04/25] Bug 1215937 - Remove use of expression closure from js/xpconnect/. r=bholley --HG-- extra : commitid : Ktu9nsb2ozN extra : rebase_source : bd5757a6ed71461e92dec4a72f6bfa441a06bfb7 --- js/xpconnect/loader/XPCOMUtils.jsm | 4 +++- js/xpconnect/tests/chrome/test_sandboxImport.xul | 4 ++-- js/xpconnect/tests/mochitest/file_bug802557.html | 10 ++++++---- js/xpconnect/tests/mochitest/test_bug478438.html | 10 +++++----- js/xpconnect/tests/unit/test_bug809652.js | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/js/xpconnect/loader/XPCOMUtils.jsm b/js/xpconnect/loader/XPCOMUtils.jsm index 8818c9c96838..d339ffa29215 100644 --- a/js/xpconnect/loader/XPCOMUtils.jsm +++ b/js/xpconnect/loader/XPCOMUtils.jsm @@ -144,7 +144,9 @@ this.XPCOMUtils = { countRef.value = _interfaces.length; return _interfaces; }, - getScriptableHelper: function XPCU_getScriptableHelper() null, + getScriptableHelper: function XPCU_getScriptableHelper() { + return null; + }, contractID: classInfo.contractID, classDescription: classInfo.classDescription, classID: classInfo.classID, diff --git a/js/xpconnect/tests/chrome/test_sandboxImport.xul b/js/xpconnect/tests/chrome/test_sandboxImport.xul index 8020c5bc3b67..eb2f76e8465a 100644 --- a/js/xpconnect/tests/chrome/test_sandboxImport.xul +++ b/js/xpconnect/tests/chrome/test_sandboxImport.xul @@ -24,8 +24,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=533596 } var sandbox = new Components.utils.Sandbox("about:blank"); - sandbox.importFunction(function() "PASS", "foo"); - sandbox.importFunction(function bar() "PASS"); + sandbox.importFunction(function() { return "PASS"; }, "foo"); + sandbox.importFunction(function bar() { return "PASS"; }); sandbox.importFunction(checkWrapped); is(Components.utils.evalInSandbox("foo()", sandbox), "PASS", "importFunction works"); is(Components.utils.evalInSandbox("bar()", sandbox), "PASS", "importFunction works"); diff --git a/js/xpconnect/tests/mochitest/file_bug802557.html b/js/xpconnect/tests/mochitest/file_bug802557.html index 02b4aedce735..39f952bc5b42 100644 --- a/js/xpconnect/tests/mochitest/file_bug802557.html +++ b/js/xpconnect/tests/mochitest/file_bug802557.html @@ -6,7 +6,9 @@ var gTS = window.location.toString; var gGHR = Object.getOwnPropertyDescriptor(window.location, 'href').get; function getTests(fromOuter) { - function loc() fromOuter ? window.location : location; + function loc() { + return fromOuter ? window.location : location; + } return { getLocationImplicit: function() { return loc() + ""; @@ -35,14 +37,14 @@ function getTests(fromOuter) { function mungeNames(obj, suffix) { var rv = {}; Object.getOwnPropertyNames(obj) - .forEach(function (name) rv[name + suffix] = obj[name]); + .forEach(name => rv[name + suffix] = obj[name]); return rv; } function mergeObjects(a, b) { var rv = {}; - Object.getOwnPropertyNames(a).forEach(function(name) rv[name] = a[name]); - Object.getOwnPropertyNames(b).forEach(function(name) rv[name] = b[name]); + Object.getOwnPropertyNames(a).forEach(name => rv[name] = a[name]); + Object.getOwnPropertyNames(b).forEach(name => rv[name] = b[name]); return rv; } diff --git a/js/xpconnect/tests/mochitest/test_bug478438.html b/js/xpconnect/tests/mochitest/test_bug478438.html index 2fd01ba4fe06..76faa706c65d 100644 --- a/js/xpconnect/tests/mochitest/test_bug478438.html +++ b/js/xpconnect/tests/mochitest/test_bug478438.html @@ -24,19 +24,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478438 catch (e) { onAllow.opposite("unable " + infinitive, ": " + e) } } - testOne(function() iwin.focus, pass, + testOne(() => iwin.focus, pass, "to resolve/get allAccess property iwin.focus"); - testOne(function() iwin.focus(), pass, + testOne(() => iwin.focus(), pass, "to call allAccess method iwin.focus"); - testOne(function() iwin.alert, fail, + testOne(() => iwin.alert, fail, "to resolve/get restricted property iwin.alert"); - testOne(function() iwin.alert(), fail, + testOne(() => iwin.alert(), fail, "to call restricted method iwin.alert"); - testOne(function() iwin.location.toString(), fail, + testOne(() => iwin.location.toString(), fail, "to call restricted method iwin.location.toString"); testOne(function() { iwin.location = "http://example.org" }, pass, diff --git a/js/xpconnect/tests/unit/test_bug809652.js b/js/xpconnect/tests/unit/test_bug809652.js index 30e985f203d0..66dd6d550400 100644 --- a/js/xpconnect/tests/unit/test_bug809652.js +++ b/js/xpconnect/tests/unit/test_bug809652.js @@ -21,7 +21,7 @@ function run_test() { for (var i = 0; i < 8; ++i) new Uint8Array(sb.ab)[i] = i * 10; sb.ta = []; - TypedArrays.forEach(function(f) sb.ta.push(new f(sb.ab))); + TypedArrays.forEach(f => sb.ta.push(new f(sb.ab))); sb.dv = new DataView(sb.ab); /* Things that should throw. */ From 4cf6fc17b571313ee24e7de3de29fd1d43a57a7f Mon Sep 17 00:00:00 2001 From: Rail Aliiev Date: Sun, 18 Oct 2015 17:51:04 -0400 Subject: [PATCH 05/25] Bug 1184089 - L10N nightly repacks should not manipulate mozconfigs. r=Callek DONTBUILD --- testing/mozharness/scripts/desktop_l10n.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/testing/mozharness/scripts/desktop_l10n.py b/testing/mozharness/scripts/desktop_l10n.py index b5a3ec045cab..f5fb74335559 100755 --- a/testing/mozharness/scripts/desktop_l10n.py +++ b/testing/mozharness/scripts/desktop_l10n.py @@ -206,7 +206,6 @@ class DesktopSingleLocale(LocalesMixin, ReleaseMixin, MockMixin, BuildbotMixin, self.version = None self.upload_urls = {} self.locales_property = {} - self.l10n_dir = None self.package_urls = {} self.pushdate = None # upload_files is a dictionary of files to upload, keyed by locale. @@ -730,7 +729,6 @@ class DesktopSingleLocale(LocalesMixin, ReleaseMixin, MockMixin, BuildbotMixin, """wrapper for make installers-(locale)""" env = self.query_l10n_env() self._copy_mozconfig() - env['L10NBASEDIR'] = self.l10n_dir dirs = self.query_abs_dirs() cwd = os.path.join(dirs['abs_locales_dir']) target = ["installers-%s" % locale, From 145e3645210d664d659e30a6632935cf0c12bb91 Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Thu, 15 Oct 2015 18:56:56 +1300 Subject: [PATCH 06/25] bug 1214493 restore fractional start time accidentally rounded in 13e85dc6b41b r=padenot --HG-- extra : rebase_source : 524269e54597bffcdeafc96940cbe14b8850c6a7 --- dom/media/webaudio/AudioBufferSourceNode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom/media/webaudio/AudioBufferSourceNode.cpp b/dom/media/webaudio/AudioBufferSourceNode.cpp index 033c68850132..3e2df060cef1 100644 --- a/dom/media/webaudio/AudioBufferSourceNode.cpp +++ b/dom/media/webaudio/AudioBufferSourceNode.cpp @@ -97,7 +97,7 @@ public: switch (aIndex) { case AudioBufferSourceNode::START: MOZ_ASSERT(!mStart, "Another START?"); - mStart = mDestination->SecondsToNearestStreamTime(aParam); + mStart = aParam * mDestination->SampleRate(); // Round to nearest mBeginProcessing = mStart + 0.5; break; From fef64ad5d0b7aca4eff0725eb91fb456367de2cf Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Fri, 16 Oct 2015 01:40:07 +1300 Subject: [PATCH 07/25] bug 1215096 correct off-by-one error in playback position of resampled buffers r=padenot "The behavior of an expression of the form E1 op = E2 is equivalent to E1 = E1 op E2 except that E1 is evaluated only once", which means that the subtraction of -= was happening before conversion from double to unsigned int. The "+ 0.5" was subtracted before the truncation toward zero, causing rounding to nearest minus one, except when nearest was zero. --HG-- extra : rebase_source : 3b2335da7a244245ea2fcf5c80760dc1645e6dae --- dom/media/webaudio/AudioBufferSourceNode.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dom/media/webaudio/AudioBufferSourceNode.cpp b/dom/media/webaudio/AudioBufferSourceNode.cpp index 3e2df060cef1..ed38f9d5fb64 100644 --- a/dom/media/webaudio/AudioBufferSourceNode.cpp +++ b/dom/media/webaudio/AudioBufferSourceNode.cpp @@ -270,7 +270,8 @@ public: if (leadTicks > 0.0) { // Round to nearest output subsample supported by the resampler at // these rates. - skipFracNum -= leadTicks * ratioNum + 0.5; + uint32_t leadSubsamples = leadTicks * ratioNum + 0.5; + skipFracNum -= leadSubsamples; MOZ_ASSERT(skipFracNum < INT32_MAX, "mBeginProcessing is wrong?"); } speex_resampler_set_skip_frac_num(resampler, skipFracNum); From 28235c90c63bcf5fa5912698280d7842861a163c Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Fri, 16 Oct 2015 01:52:37 +1300 Subject: [PATCH 08/25] mochitest for bug 913854 r=padenot --HG-- extra : rebase_source : 8b8e282f34cda23ba924ef4f7201d59b94a7c7af --- dom/media/webaudio/test/mochitest.ini | 1 + ..._sequentialBufferSourceWithResampling.html | 72 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 dom/media/webaudio/test/test_sequentialBufferSourceWithResampling.html diff --git a/dom/media/webaudio/test/mochitest.ini b/dom/media/webaudio/test/mochitest.ini index 40b9da2bc9cc..8f121db5b3b3 100644 --- a/dom/media/webaudio/test/mochitest.ini +++ b/dom/media/webaudio/test/mochitest.ini @@ -169,6 +169,7 @@ skip-if = (toolkit == 'gonk' && !debug) || android_version == '10' || android_ve [test_scriptProcessorNode_playbackTime1.html] [test_scriptProcessorNodeZeroInputOutput.html] [test_scriptProcessorNodeNotConnected.html] +[test_sequentialBufferSourceWithResampling.html] [test_singleSourceDest.html] [test_stereoPanningWithGain.html] [test_waveDecoder.html] diff --git a/dom/media/webaudio/test/test_sequentialBufferSourceWithResampling.html b/dom/media/webaudio/test/test_sequentialBufferSourceWithResampling.html new file mode 100644 index 000000000000..5c03a8a91135 --- /dev/null +++ b/dom/media/webaudio/test/test_sequentialBufferSourceWithResampling.html @@ -0,0 +1,72 @@ + +Test seamless playback of a series of resampled buffers + + + From c31207d4a3ef13c97e9b4f614646b1239ea8a53f Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Fri, 16 Oct 2015 11:31:45 +1300 Subject: [PATCH 09/25] bug 1020370 adjust assert to tolerate large skipFracNum r=padenot --HG-- extra : rebase_source : 35b6077976ccdc4c2b9d9fd4c778c6362fdd1daa extra : histedit_source : 7adb8e3296924a1c8ffcb4665122c40ee48f42a4 --- dom/media/webaudio/AudioBufferSourceNode.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dom/media/webaudio/AudioBufferSourceNode.cpp b/dom/media/webaudio/AudioBufferSourceNode.cpp index ed38f9d5fb64..f280afda25d7 100644 --- a/dom/media/webaudio/AudioBufferSourceNode.cpp +++ b/dom/media/webaudio/AudioBufferSourceNode.cpp @@ -271,8 +271,9 @@ public: // Round to nearest output subsample supported by the resampler at // these rates. uint32_t leadSubsamples = leadTicks * ratioNum + 0.5; + MOZ_ASSERT(leadSubsamples <= skipFracNum, + "mBeginProcessing is wrong?"); skipFracNum -= leadSubsamples; - MOZ_ASSERT(skipFracNum < INT32_MAX, "mBeginProcessing is wrong?"); } speex_resampler_set_skip_frac_num(resampler, skipFracNum); From 5db355303c98e3a8c1c421815ea377d618054188 Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Fri, 16 Oct 2015 11:56:24 +1300 Subject: [PATCH 10/25] bug 1020370 use int64_t to avoid overflow in subsample calcs r=padenot ratioDen can be large when playbackRate is low. Subsample skipping is limited to uint32_t values supported by speex resampler. --HG-- extra : rebase_source : 26a14f212b5fd3fdd62820f458db3a7cf3673e93 extra : histedit_source : 733829a4b2ba6aab7c651f362dbc47553f9dfc59 --- dom/media/webaudio/AudioBufferSourceNode.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dom/media/webaudio/AudioBufferSourceNode.cpp b/dom/media/webaudio/AudioBufferSourceNode.cpp index f280afda25d7..3cd887bceb4e 100644 --- a/dom/media/webaudio/AudioBufferSourceNode.cpp +++ b/dom/media/webaudio/AudioBufferSourceNode.cpp @@ -265,17 +265,18 @@ public: // buffer, but correct for input latency. If starting before mStart, // then align the resampler so that the time corresponding to the // first input sample is mStart. - uint32_t skipFracNum = inputLatency * ratioDen; + int64_t skipFracNum = static_cast(inputLatency) * ratioDen; double leadTicks = mStart - *aCurrentPosition; if (leadTicks > 0.0) { // Round to nearest output subsample supported by the resampler at // these rates. - uint32_t leadSubsamples = leadTicks * ratioNum + 0.5; + int64_t leadSubsamples = leadTicks * ratioNum + 0.5; MOZ_ASSERT(leadSubsamples <= skipFracNum, "mBeginProcessing is wrong?"); skipFracNum -= leadSubsamples; } - speex_resampler_set_skip_frac_num(resampler, skipFracNum); + speex_resampler_set_skip_frac_num(resampler, + std::min(skipFracNum, UINT32_MAX)); mBeginProcessing = -STREAM_TIME_MAX; } From 70eb9690cb0fd1656dd5f941ab71e9e6d0b8d658 Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Fri, 16 Oct 2015 09:59:48 +1300 Subject: [PATCH 11/25] crashtest for bug 1020370 r=padenot --HG-- extra : rebase_source : f72a12e2d7d6d7cfeab7f4f0bf0975a06a2ef533 extra : histedit_source : e9193166e88501fd522b9ed6c8c8a806684649ac --- .../buffer-source-resampling-start-1.html | 16 ++++++++++++++++ dom/media/test/crashtests/crashtests.list | 1 + 2 files changed, 17 insertions(+) create mode 100644 dom/media/test/crashtests/buffer-source-resampling-start-1.html diff --git a/dom/media/test/crashtests/buffer-source-resampling-start-1.html b/dom/media/test/crashtests/buffer-source-resampling-start-1.html new file mode 100644 index 000000000000..55db8591ed00 --- /dev/null +++ b/dom/media/test/crashtests/buffer-source-resampling-start-1.html @@ -0,0 +1,16 @@ + + + diff --git a/dom/media/test/crashtests/crashtests.list b/dom/media/test/crashtests/crashtests.list index bd8cbf199da5..6fc93dfd728d 100644 --- a/dom/media/test/crashtests/crashtests.list +++ b/dom/media/test/crashtests/crashtests.list @@ -84,6 +84,7 @@ load 1185192.html load analyser-channels-1.html load audiocontext-double-suspend.html load buffer-source-ended-1.html +load buffer-source-resampling-start-1.html load doppler-1.html HTTP load media-element-source-seek-1.html load offline-buffer-source-ended-1.html From eba61c1793a790a54d1f7fcab1f91c8475df4a3e Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Mon, 21 Sep 2015 15:36:28 +1200 Subject: [PATCH 12/25] crashtest for bug 1206362 r=padenot --HG-- extra : rebase_source : 9c2af42fcdb168ced50e0e8f72b1054116af3180 extra : histedit_source : c6737b330ee494c254388b6b54a53a09c6ec1ae6 --- .../test/crashtests/buffer-source-duration-1.html | 14 ++++++++++++++ dom/media/test/crashtests/crashtests.list | 1 + 2 files changed, 15 insertions(+) create mode 100644 dom/media/test/crashtests/buffer-source-duration-1.html diff --git a/dom/media/test/crashtests/buffer-source-duration-1.html b/dom/media/test/crashtests/buffer-source-duration-1.html new file mode 100644 index 000000000000..df8d7a37d54e --- /dev/null +++ b/dom/media/test/crashtests/buffer-source-duration-1.html @@ -0,0 +1,14 @@ + + + diff --git a/dom/media/test/crashtests/crashtests.list b/dom/media/test/crashtests/crashtests.list index 6fc93dfd728d..3076c690fb83 100644 --- a/dom/media/test/crashtests/crashtests.list +++ b/dom/media/test/crashtests/crashtests.list @@ -83,6 +83,7 @@ load 1185176.html load 1185192.html load analyser-channels-1.html load audiocontext-double-suspend.html +load buffer-source-duration-1.html load buffer-source-ended-1.html load buffer-source-resampling-start-1.html load doppler-1.html From 9a3278a62698e119aa5661f86662a99e2a21938a Mon Sep 17 00:00:00 2001 From: Dan Glastonbury Date: Tue, 29 Sep 2015 17:08:54 +1300 Subject: [PATCH 13/25] Bug 1209384 - Check active query has same type as target. r=jgilbert --- dom/canvas/WebGL2ContextQueries.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dom/canvas/WebGL2ContextQueries.cpp b/dom/canvas/WebGL2ContextQueries.cpp index c446cf570622..b3ffe264e6e6 100644 --- a/dom/canvas/WebGL2ContextQueries.cpp +++ b/dom/canvas/WebGL2ContextQueries.cpp @@ -275,8 +275,12 @@ WebGL2Context::GetQuery(GLenum target, GLenum pname) } WebGLRefPtr& targetSlot = GetQuerySlotByTarget(target); - RefPtr tmp = targetSlot.get(); + if (tmp && tmp->mType != target) { + // Query in slot doesn't match target + return nullptr; + } + return tmp.forget(); } From af8cf1df882ed2951c1fbaf9ed85b546988ca276 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 19 Oct 2015 11:56:13 +1100 Subject: [PATCH 14/25] Bug 1215360 - Render canvas anonymous content on top of the top layer. r=roc --HG-- extra : source : 231e0e545afaf3bf4993b0f6d20cd60ee734c899 --- layout/generic/nsViewportFrame.cpp | 33 ++++++++++++++++++++++-------- layout/style/ua.css | 4 +--- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/layout/generic/nsViewportFrame.cpp b/layout/generic/nsViewportFrame.cpp index e51066c04386..de0a5c3f0169 100644 --- a/layout/generic/nsViewportFrame.cpp +++ b/layout/generic/nsViewportFrame.cpp @@ -12,6 +12,7 @@ #include "nsGkAtoms.h" #include "nsIScrollableFrame.h" #include "nsSubDocumentFrame.h" +#include "nsCanvasFrame.h" #include "nsAbsoluteContainingBlock.h" #include "GeckoProfiler.h" #include "nsIMozBrowserFrame.h" @@ -91,6 +92,22 @@ ShouldInTopLayerForFullscreen(Element* aElement) } #endif // DEBUG +static void +BuildDisplayListForTopLayerFrame(nsDisplayListBuilder* aBuilder, + nsIFrame* aFrame, + nsDisplayList* aList) +{ + nsRect dirty; + nsDisplayListBuilder::OutOfFlowDisplayData* + savedOutOfFlowData = nsDisplayListBuilder::GetOutOfFlowData(aFrame); + if (savedOutOfFlowData) { + dirty = savedOutOfFlowData->mDirtyRect; + } + nsDisplayList list; + aFrame->BuildDisplayListForStackingContext(aBuilder, dirty, &list); + aList->AppendToTop(&list); +} + void ViewportFrame::BuildDisplayListForTopLayer(nsDisplayListBuilder* aBuilder, nsDisplayList* aList) @@ -123,16 +140,16 @@ ViewportFrame::BuildDisplayListForTopLayer(nsDisplayListBuilder* aBuilder, continue; } MOZ_ASSERT(frame->GetParent() == this); + BuildDisplayListForTopLayerFrame(aBuilder, frame, aList); + } + } - nsRect dirty; - nsDisplayListBuilder::OutOfFlowDisplayData* - savedOutOfFlowData = nsDisplayListBuilder::GetOutOfFlowData(frame); - if (savedOutOfFlowData) { - dirty = savedOutOfFlowData->mDirtyRect; + nsIPresShell* shell = PresContext()->PresShell(); + if (nsCanvasFrame* canvasFrame = shell->GetCanvasFrame()) { + if (Element* container = canvasFrame->GetCustomContentContainer()) { + if (nsIFrame* frame = container->GetPrimaryFrame()) { + BuildDisplayListForTopLayerFrame(aBuilder, frame, aList); } - nsDisplayList list; - frame->BuildDisplayListForStackingContext(aBuilder, dirty, &list); - aList->AppendToTop(&list); } } } diff --git a/layout/style/ua.css b/layout/style/ua.css index 6af848e72725..f2af3f2f08bc 100644 --- a/layout/style/ua.css +++ b/layout/style/ua.css @@ -514,12 +514,10 @@ div:-moz-native-anonymous.moz-selectioncaret-right.hidden > div { everything else, not reacting to pointer events. */ div:-moz-native-anonymous.moz-custom-content-container { pointer-events: none; - + -moz-top-layer: top; position: fixed; top: 0; left: 0; width: 100%; height: 100%; - - z-index: 2147483648; } From c5f685501207c537f19f4d38bbe70fc6b8db2476 Mon Sep 17 00:00:00 2001 From: Dan Glastonbury Date: Wed, 30 Sep 2015 14:04:17 +1300 Subject: [PATCH 15/25] Bug 1207205 - Remove fGetActiveUniformName. r=jrmuizel --- gfx/gl/GLContext.cpp | 3 ++- gfx/gl/GLContext.h | 9 --------- gfx/gl/GLContextSymbols.h | 2 -- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp index dce2d4abcf2f..6caf6623137c 100644 --- a/gfx/gl/GLContext.cpp +++ b/gfx/gl/GLContext.cpp @@ -1431,10 +1431,11 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl) } if (IsSupported(GLFeature::uniform_buffer_object)) { + // Note: Don't query for glGetActiveUniformName because it is not + // supported by GL ES 3. SymLoadStruct uboSymbols[] = { { (PRFuncPtr*) &mSymbols.fGetUniformIndices, { "GetUniformIndices", nullptr } }, { (PRFuncPtr*) &mSymbols.fGetActiveUniformsiv, { "GetActiveUniformsiv", nullptr } }, - { (PRFuncPtr*) &mSymbols.fGetActiveUniformName, { "GetActiveUniformName", nullptr } }, { (PRFuncPtr*) &mSymbols.fGetUniformBlockIndex, { "GetUniformBlockIndex", nullptr } }, { (PRFuncPtr*) &mSymbols.fGetActiveUniformBlockiv, { "GetActiveUniformBlockiv", nullptr } }, { (PRFuncPtr*) &mSymbols.fGetActiveUniformBlockName, { "GetActiveUniformBlockName", nullptr } }, diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index 58501d63c04d..e86d7551a969 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -3011,15 +3011,6 @@ public: AFTER_GL_CALL; } - void fGetActiveUniformName(GLuint program, GLuint uniformIndex, GLsizei bufSize, - GLsizei* length, GLchar* uniformName) - { - ASSERT_SYMBOL_PRESENT(fGetActiveUniformName); - BEFORE_GL_CALL; - mSymbols.fGetActiveUniformName(program, uniformIndex, bufSize, length, uniformName); - AFTER_GL_CALL; - } - GLuint fGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) { ASSERT_SYMBOL_PRESENT(fGetUniformBlockIndex); BEFORE_GL_CALL; diff --git a/gfx/gl/GLContextSymbols.h b/gfx/gl/GLContextSymbols.h index a3469e09242f..b78a021b1b16 100644 --- a/gfx/gl/GLContextSymbols.h +++ b/gfx/gl/GLContextSymbols.h @@ -614,8 +614,6 @@ struct GLContextSymbols typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params); PFNGLGETACTIVEUNIFORMSIVPROC fGetActiveUniformsiv; - typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIdex, GLsizei bufSize, GLsizei* length, GLchar* uniformName); - PFNGLGETACTIVEUNIFORMNAMEPROC fGetActiveUniformName; typedef GLuint (GLAPIENTRY * PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar* uniformBlockName); PFNGLGETUNIFORMBLOCKINDEXPROC fGetUniformBlockIndex; typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params); From 04af36237581fd88db51c23079798935c7e84a56 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Sun, 18 Oct 2015 18:39:07 -0700 Subject: [PATCH 16/25] Bug 1207012 - Disable browser_bug666317.js for a permaorange uncaught exception that becomes visibly orange on beta --HG-- extra : rebase_source : ec59909e71db0bb48919e5c810d018520257817d --- image/test/browser/browser.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image/test/browser/browser.ini b/image/test/browser/browser.ini index 9cea73060d82..6f37dde71fb4 100644 --- a/image/test/browser/browser.ini +++ b/image/test/browser/browser.ini @@ -8,6 +8,6 @@ support-files = imageX2.html [browser_bug666317.js] -skip-if = e10s # Bug 948194 - Decoded Images seem to not be discarded on memory-pressure notification with e10s enabled +skip-if = true || e10s # Bug 1207012 - Permaorange from an uncaught exception that isn't actually turning the suite orange until it hits beta, Bug 948194 - Decoded Images seem to not be discarded on memory-pressure notification with e10s enabled [browser_image.js] skip-if = true # Bug 987616 From 9aeb5db9a1db4b69b6060b0a7e8fde92d62fd0a7 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Mon, 21 Sep 2015 19:43:47 -0700 Subject: [PATCH 17/25] Bug 1206995 - disable test_window_define_nonconfigurable.html for release_build, since the feature it tests is disabled there, which makes the test fail --HG-- extra : rebase_source : c1d39ea0d6a7709de4411085030d8cdbd2a137f9 --- dom/base/test/mochitest.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini index 005fa347d2b2..1e06815c3b50 100644 --- a/dom/base/test/mochitest.ini +++ b/dom/base/test/mochitest.ini @@ -830,6 +830,7 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' [test_bug1081686.html] skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s [test_window_define_nonconfigurable.html] +skip-if = release_build [test_root_iframe.html] [test_performance_observer.html] [test_performance_user_timing.html] From f4458274bd5a5e6528846a5842becf362d4a855f Mon Sep 17 00:00:00 2001 From: John Daggett Date: Mon, 19 Oct 2015 11:16:43 +0900 Subject: [PATCH 18/25] Bug 543715 p1 - distinguish between italic and oblique. r=jfkthame --- gfx/thebes/gfxAndroidPlatform.cpp | 8 +- gfx/thebes/gfxAndroidPlatform.h | 4 +- gfx/thebes/gfxDWriteFontList.cpp | 16 ++-- gfx/thebes/gfxDWriteFontList.h | 23 +++--- gfx/thebes/gfxDWriteFonts.cpp | 5 +- gfx/thebes/gfxFT2FontList.cpp | 25 +++--- gfx/thebes/gfxFT2FontList.h | 6 +- gfx/thebes/gfxFcPlatformFontList.cpp | 33 ++++---- gfx/thebes/gfxFcPlatformFontList.h | 9 ++- gfx/thebes/gfxFont.cpp | 4 +- gfx/thebes/gfxFontEntry.cpp | 117 +++++++++++++++++---------- gfx/thebes/gfxFontEntry.h | 7 +- gfx/thebes/gfxFontconfigFonts.cpp | 20 ++--- gfx/thebes/gfxFontconfigFonts.h | 4 +- gfx/thebes/gfxGDIFont.cpp | 5 +- gfx/thebes/gfxGDIFontList.cpp | 43 +++++----- gfx/thebes/gfxGDIFontList.h | 10 +-- gfx/thebes/gfxMacFont.cpp | 9 +-- gfx/thebes/gfxMacPlatformFontList.h | 8 +- gfx/thebes/gfxMacPlatformFontList.mm | 21 ++--- gfx/thebes/gfxPlatform.cpp | 2 +- gfx/thebes/gfxPlatform.h | 4 +- gfx/thebes/gfxPlatformFontList.h | 4 +- gfx/thebes/gfxPlatformGtk.cpp | 15 ++-- gfx/thebes/gfxPlatformGtk.h | 4 +- gfx/thebes/gfxPlatformMac.cpp | 8 +- gfx/thebes/gfxPlatformMac.h | 4 +- gfx/thebes/gfxQtPlatform.cpp | 8 +- gfx/thebes/gfxQtPlatform.h | 4 +- gfx/thebes/gfxUserFontSet.cpp | 38 ++++----- gfx/thebes/gfxUserFontSet.h | 17 ++-- gfx/thebes/gfxWindowsPlatform.cpp | 8 +- gfx/thebes/gfxWindowsPlatform.h | 4 +- layout/style/FontFace.h | 4 +- layout/style/FontFaceSet.cpp | 12 +-- layout/style/FontFaceSet.h | 4 +- 36 files changed, 276 insertions(+), 241 deletions(-) diff --git a/gfx/thebes/gfxAndroidPlatform.cpp b/gfx/thebes/gfxAndroidPlatform.cpp index 32986c6d0f03..1e0703dedc04 100644 --- a/gfx/thebes/gfxAndroidPlatform.cpp +++ b/gfx/thebes/gfxAndroidPlatform.cpp @@ -328,26 +328,26 @@ gfxFontEntry* gfxAndroidPlatform::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(aFontName, aWeight, aStretch, - aItalic); + aStyle); } gfxFontEntry* gfxAndroidPlatform::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(aFontName, aWeight, aStretch, - aItalic, + aStyle, aFontData, aLength); } diff --git a/gfx/thebes/gfxAndroidPlatform.h b/gfx/thebes/gfxAndroidPlatform.h index 3b93b0cd7d39..c5fae095122d 100644 --- a/gfx/thebes/gfxAndroidPlatform.h +++ b/gfx/thebes/gfxAndroidPlatform.h @@ -48,11 +48,11 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxDWriteFontList.cpp b/gfx/thebes/gfxDWriteFontList.cpp index ed3091c079a9..50c3d6d2f08c 100644 --- a/gfx/thebes/gfxDWriteFontList.cpp +++ b/gfx/thebes/gfxDWriteFontList.cpp @@ -217,7 +217,8 @@ gfxDWriteFontFamily::FindStyleVariations(FontInfoData *aFontInfoData) " with style: %s weight: %d stretch: %d psname: %s fullname: %s", NS_ConvertUTF16toUTF8(fe->Name()).get(), NS_ConvertUTF16toUTF8(Name()).get(), - (fe->IsItalic()) ? "italic" : "normal", + (fe->IsItalic()) ? + "italic" : (fe->IsOblique() ? "oblique" : "normal"), fe->Weight(), fe->Stretch(), NS_ConvertUTF16toUTF8(psname).get(), NS_ConvertUTF16toUTF8(fullname).get())); @@ -388,7 +389,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag, // potential cmap discrepancies, see bug 629386. // Ditto for Hebrew, bug 837498. if (mFont && pFontList->UseGDIFontTableAccess() && - !(mItalic && UsingArabicOrHebrewScriptSystemLocale()) && + !(mStyle && UsingArabicOrHebrewScriptSystemLocale()) && !mFont->IsSymbolFont()) { LOGFONTW logfont = { 0 }; @@ -743,7 +744,7 @@ gfxFontEntry * gfxDWriteFontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { gfxFontEntry *lookup; @@ -758,7 +759,7 @@ gfxDWriteFontList::LookupLocalFont(const nsAString& aFontName, dwriteLookup->mFont, aWeight, aStretch, - aItalic); + aStyle); fe->SetForceGDIClassic(dwriteLookup->GetForceGDIClassic()); return fe; } @@ -767,7 +768,7 @@ gfxFontEntry * gfxDWriteFontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -832,7 +833,7 @@ gfxDWriteFontList::MakePlatformFont(const nsAString& aFontName, fontFile, aWeight, aStretch, - aItalic); + aStyle); fontFile->Analyze(&isSupported, &fileType, &entry->mFaceType, &numFaces); if (!isSupported || numFaces > 1) { @@ -974,7 +975,8 @@ gfxDWriteFontList::InitFontList() " with style: %s weight: %d stretch: %d", NS_ConvertUTF16toUTF8(fe->Name()).get(), NS_ConvertUTF16toUTF8(gillSansMTFamily->Name()).get(), - (fe->IsItalic()) ? "italic" : "normal", + (fe->IsItalic()) ? + "italic" : (fe->IsOblique() ? "oblique" : "normal"), fe->Weight(), fe->Stretch())); } } diff --git a/gfx/thebes/gfxDWriteFontList.h b/gfx/thebes/gfxDWriteFontList.h index 370dc7c1018e..9ce336136471 100644 --- a/gfx/thebes/gfxDWriteFontList.h +++ b/gfx/thebes/gfxDWriteFontList.h @@ -80,8 +80,11 @@ public: : gfxFontEntry(aFaceName), mFont(aFont), mFontFile(nullptr), mForceGDIClassic(false) { - mItalic = (aFont->GetStyle() == DWRITE_FONT_STYLE_ITALIC || - aFont->GetStyle() == DWRITE_FONT_STYLE_OBLIQUE); + DWRITE_FONT_STYLE dwriteStyle = aFont->GetStyle(); + mStyle = (dwriteStyle == DWRITE_FONT_STYLE_ITALIC ? + NS_FONT_STYLE_ITALIC : + (dwriteStyle == DWRITE_FONT_STYLE_OBLIQUE ? + NS_FONT_STYLE_OBLIQUE : NS_FONT_STYLE_NORMAL)); mStretch = FontStretchFromDWriteStretch(aFont->GetStretch()); uint16_t weight = NS_ROUNDUP(aFont->GetWeight() - 50, 100); @@ -101,19 +104,19 @@ public: * \param aFont DirectWrite font object * \param aWeight Weight of the font * \param aStretch Stretch of the font - * \param aItalic True if italic + * \param aStyle italic or oblique of font */ gfxDWriteFontEntry(const nsAString& aFaceName, IDWriteFont *aFont, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) : gfxFontEntry(aFaceName), mFont(aFont), mFontFile(nullptr), mForceGDIClassic(false) { mWeight = aWeight; mStretch = aStretch; - mItalic = aItalic; + mStyle = aStyle; mIsLocalUserFont = true; mIsCJK = UNINITIALIZED_VALUE; } @@ -125,19 +128,19 @@ public: * \param aFontFile DirectWrite fontfile object * \param aWeight Weight of the font * \param aStretch Stretch of the font - * \param aItalic True if italic + * \param aStyle italic or oblique of font */ gfxDWriteFontEntry(const nsAString& aFaceName, IDWriteFontFile *aFontFile, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) : gfxFontEntry(aFaceName), mFont(nullptr), mFontFile(aFontFile), mForceGDIClassic(false) { mWeight = aWeight; mStretch = aStretch; - mItalic = aItalic; + mStyle = aStyle; mIsDataUserFont = true; mIsCJK = UNINITIALIZED_VALUE; } @@ -349,12 +352,12 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxDWriteFonts.cpp b/gfx/thebes/gfxDWriteFonts.cpp index 3f387615a732..72a5c1f45bb9 100644 --- a/gfx/thebes/gfxDWriteFonts.cpp +++ b/gfx/thebes/gfxDWriteFonts.cpp @@ -85,8 +85,9 @@ gfxDWriteFont::gfxDWriteFont(gfxFontEntry *aFontEntry, static_cast(aFontEntry); nsresult rv; DWRITE_FONT_SIMULATIONS sims = DWRITE_FONT_SIMULATIONS_NONE; - if ((GetStyle()->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) && - !fe->IsItalic() && GetStyle()->allowSyntheticStyle) { + if ((GetStyle()->style != NS_FONT_STYLE_NORMAL) && + fe->IsUpright() && + GetStyle()->allowSyntheticStyle) { // For this we always use the font_matrix for uniformity. Not the // DWrite simulation. mNeedsOblique = true; diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 7a019646fbda..148110fdb7c9 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -188,9 +188,9 @@ FT2FontEntry::CreateScaledFont(const gfxFontStyle *aStyle) cairo_matrix_init_identity(&identityMatrix); // synthetic oblique by skewing via the font matrix - bool needsOblique = !IsItalic() && - (aStyle->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) && - aStyle->allowSyntheticStyle; + bool needsOblique = IsUpright() && + aStyle->style != NS_FONT_STYLE_NORMAL && + aStyle->allowSyntheticStyle; if (needsOblique) { cairo_matrix_t style; @@ -251,7 +251,7 @@ FT2FontEntry* FT2FontEntry::CreateFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -277,7 +277,7 @@ FT2FontEntry::CreateFontEntry(const nsAString& aFontName, FT2FontEntry::CreateFontEntry(face, nullptr, 0, aFontName, aFontData); if (fe) { - fe->mItalic = aItalic; + fe->mStyle = aStyle; fe->mWeight = aWeight; fe->mStretch = aStretch; fe->mIsDataUserFont = true; @@ -323,7 +323,7 @@ FT2FontEntry::CreateFontEntry(const FontListEntry& aFLE) fe->mFTFontIndex = aFLE.index(); fe->mWeight = aFLE.weight(); fe->mStretch = aFLE.stretch(); - fe->mItalic = aFLE.italic(); + fe->mStyle = (aFLE.italic() ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL); return fe; } @@ -380,7 +380,8 @@ FT2FontEntry::CreateFontEntry(FT_Face aFace, const uint8_t* aFontData) { FT2FontEntry *fe = new FT2FontEntry(aName); - fe->mItalic = FTFaceIsItalic(aFace); + fe->mStyle = (FTFaceIsItalic(aFace) ? + NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL); fe->mWeight = FTFaceGetWeight(aFace); fe->mFilename = aFilename; fe->mFTFontIndex = aIndex; @@ -596,7 +597,7 @@ FT2FontFamily::AddFacesToFontList(InfallibleTArray* aFontList, aFontList->AppendElement(FontListEntry(Name(), fe->Name(), fe->mFilename, fe->Weight(), fe->Stretch(), - fe->IsItalic(), + fe->mStyle, fe->mFTFontIndex, aVisibility == kHidden)); } @@ -1452,7 +1453,7 @@ gfxFontEntry* gfxFT2FontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { // walk over list of names FT2FontEntry* fontEntry = nullptr; @@ -1509,7 +1510,7 @@ searchDone: fontEntry->mFTFontIndex, fontEntry->Name(), nullptr); if (fe) { - fe->mItalic = aItalic; + fe->mStyle = aStyle; fe->mWeight = aWeight; fe->mStretch = aStretch; fe->mIsLocalUserFont = true; @@ -1538,7 +1539,7 @@ gfxFontEntry* gfxFT2FontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -1546,7 +1547,7 @@ gfxFT2FontList::MakePlatformFont(const nsAString& aFontName, // but instead pass ownership to the font entry. // Deallocation will happen later, when the font face is destroyed. return FT2FontEntry::CreateFontEntry(aFontName, aWeight, aStretch, - aItalic, aFontData, aLength); + aStyle, aFontData, aLength); } void diff --git a/gfx/thebes/gfxFT2FontList.h b/gfx/thebes/gfxFT2FontList.h index ecccf2b12e2f..c5748a704bc4 100644 --- a/gfx/thebes/gfxFT2FontList.h +++ b/gfx/thebes/gfxFT2FontList.h @@ -42,7 +42,7 @@ public: CreateFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); @@ -125,12 +125,12 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxFcPlatformFontList.cpp b/gfx/thebes/gfxFcPlatformFontList.cpp index cf4fd11cc44a..784ff5accb5f 100644 --- a/gfx/thebes/gfxFcPlatformFontList.cpp +++ b/gfx/thebes/gfxFcPlatformFontList.cpp @@ -256,8 +256,10 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, if (FcPatternGetInteger(aFontPattern, FC_SLANT, 0, &slant) != FcResultMatch) { slant = FC_SLANT_ROMAN; } - if (slant > 0) { - mItalic = true; + if (slant == FC_SLANT_OBLIQUE) { + mStyle = NS_FONT_STYLE_OBLIQUE; + } else if (slant > 0) { + mStyle = NS_FONT_STYLE_ITALIC; } // weight @@ -278,7 +280,7 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t *aData, FT_Face aFace) : gfxFontEntry(aFaceName), @@ -286,7 +288,7 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, mAspect(0.0), mFontData(aData) { mWeight = aWeight; - mItalic = aItalic; + mStyle = aStyle; mStretch = aStretch; mIsDataUserFont = true; @@ -319,13 +321,13 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName, FcPattern* aFontPattern, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) : gfxFontEntry(aFaceName), mFontPattern(aFontPattern), mFTFace(nullptr), mFTFaceInitialized(false), mAspect(0.0), mFontData(nullptr) { mWeight = aWeight; - mItalic = aItalic; + mStyle = aStyle; mStretch = aStretch; mIsLocalUserFont = true; } @@ -670,9 +672,9 @@ gfxFontconfigFontEntry::CreateScaledFont(FcPattern* aRenderPattern, } // synthetic oblique by skewing via the font matrix - bool needsOblique = !IsItalic() && - (aStyle->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) && - aStyle->allowSyntheticStyle; + bool needsOblique = IsUpright() && + aStyle->style != NS_FONT_STYLE_NORMAL && + aStyle->allowSyntheticStyle; if (needsOblique) { // disable embedded bitmaps (mimics behavior in 90-synthetic.conf) @@ -863,7 +865,8 @@ gfxFontconfigFontFamily::FindStyleVariations(FontInfoData *aFontInfoData) " psname: %s fullname: %s", NS_ConvertUTF16toUTF8(fontEntry->Name()).get(), NS_ConvertUTF16toUTF8(Name()).get(), - fontEntry->IsItalic() ? "italic" : "normal", + (fontEntry->IsItalic()) ? + "italic" : (fontEntry->IsOblique() ? "oblique" : "normal"), fontEntry->Weight(), fontEntry->Stretch(), NS_ConvertUTF16toUTF8(psname).get(), NS_ConvertUTF16toUTF8(fullname).get())); @@ -1172,7 +1175,7 @@ gfxFontEntry* gfxFcPlatformFontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { nsAutoString keyName(aFontName); ToLowerCase(keyName); @@ -1185,14 +1188,14 @@ gfxFcPlatformFontList::LookupLocalFont(const nsAString& aFontName, return new gfxFontconfigFontEntry(aFontName, fontPattern, - aWeight, aStretch, aItalic); + aWeight, aStretch, aStyle); } gfxFontEntry* gfxFcPlatformFontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -1210,8 +1213,8 @@ gfxFcPlatformFontList::MakePlatformFont(const nsAString& aFontName, return nullptr; } - return new gfxFontconfigFontEntry(aFontName, aWeight, aStretch, aItalic, - aFontData, face); + return new gfxFontconfigFontEntry(aFontName, aWeight, aStretch, + aStyle, aFontData, face); } gfxFontFamily* diff --git a/gfx/thebes/gfxFcPlatformFontList.h b/gfx/thebes/gfxFcPlatformFontList.h index 32f743971cfd..4f5ec324a091 100644 --- a/gfx/thebes/gfxFcPlatformFontList.h +++ b/gfx/thebes/gfxFcPlatformFontList.h @@ -99,7 +99,7 @@ public: explicit gfxFontconfigFontEntry(const nsAString& aFaceName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t *aData, FT_Face aFace); @@ -108,7 +108,7 @@ public: FcPattern* aFontPattern, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); FcPattern* GetPattern() { return mFontPattern; } @@ -209,11 +209,12 @@ public: gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, - int16_t aStretch, bool aItalic) override; + int16_t aStretch, uint8_t aStyle) override; gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, - int16_t aStretch, bool aItalic, + int16_t aStretch, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index c409af6666cc..5db1dc67ebda 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -2290,7 +2290,9 @@ gfxFont::Measure(gfxTextRun *aTextRun, // If the font may be rendered with a fake-italic effect, we need to allow // for the top-right of the glyphs being skewed to the right, and the // bottom-left being skewed further left. - if (mStyle.style != NS_FONT_STYLE_NORMAL && !mFontEntry->IsItalic()) { + if (mStyle.style != NS_FONT_STYLE_NORMAL && + mFontEntry->IsUpright() && + mStyle.allowSyntheticStyle) { gfxFloat extendLeftEdge = ceil(OBLIQUE_SKEW_FACTOR * metrics.mBoundingBox.YMost()); gfxFloat extendRightEdge = diff --git a/gfx/thebes/gfxFontEntry.cpp b/gfx/thebes/gfxFontEntry.cpp index 53d53566705e..50a3e887ac42 100644 --- a/gfx/thebes/gfxFontEntry.cpp +++ b/gfx/thebes/gfxFontEntry.cpp @@ -68,7 +68,7 @@ gfxCharacterMap::NotifyReleased() } gfxFontEntry::gfxFontEntry() : - mItalic(false), mFixedPitch(false), + mStyle(NS_FONT_STYLE_NORMAL), mFixedPitch(false), mIsValid(true), mIsBadUnderlineFont(false), mIsUserFontContainer(false), @@ -108,7 +108,7 @@ gfxFontEntry::gfxFontEntry() : } gfxFontEntry::gfxFontEntry(const nsAString& aName, bool aIsStandardFace) : - mName(aName), mItalic(false), mFixedPitch(false), + mName(aName), mStyle(NS_FONT_STYLE_NORMAL), mFixedPitch(false), mIsValid(true), mIsBadUnderlineFont(false), mIsUserFontContainer(false), @@ -1155,57 +1155,69 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle, return nullptr; } -static inline uint32_t -StyleStretchDistance(gfxFontEntry *aFontEntry, bool aTargetItalic, - int16_t aTargetStretch) -{ - // Compute a measure of the "distance" between the requested style - // and the given fontEntry, - // considering italicness and font-stretch but not weight. +#define STYLE_SHIFT 2 // number of bits to contain style distance +// style distance ==> [0,2] +static inline uint32_t +StyleDistance(uint32_t aFontStyle, uint32_t aTargetStyle) +{ + if (aFontStyle == aTargetStyle) { + return 0; // styles match exactly ==> 0 + } + if (aFontStyle == NS_FONT_STYLE_NORMAL || + aTargetStyle == NS_FONT_STYLE_NORMAL) { + return 2; // one is normal (but not the other) ==> 2 + } + return 1; // neither is normal; must be italic vs oblique ==> 1 +} + +#define REVERSE_STRETCH_DISTANCE 5 + +// stretch distance ==> [0,13] +static inline uint32_t +StretchDistance(int16_t aFontStretch, int16_t aTargetStretch) +{ int32_t distance = 0; - if (aTargetStretch != aFontEntry->mStretch) { + if (aTargetStretch != aFontStretch) { // stretch values are in the range -4 .. +4 // if aTargetStretch is positive, we prefer more-positive values; // if zero or negative, prefer more-negative if (aTargetStretch > 0) { - distance = (aFontEntry->mStretch - aTargetStretch) * 2; + distance = (aFontStretch - aTargetStretch); } else { - distance = (aTargetStretch - aFontEntry->mStretch) * 2; + distance = (aTargetStretch - aFontStretch); } // if the computed "distance" here is negative, it means that // aFontEntry lies in the "non-preferred" direction from aTargetStretch, // so we treat that as larger than any preferred-direction distance - // (max possible is 8) by adding an extra 10 to the absolute value + // (max possible is 4) by adding an extra 5 to the absolute value if (distance < 0) { - distance = -distance + 10; + distance = -distance + REVERSE_STRETCH_DISTANCE; } } - if (aFontEntry->IsItalic() != aTargetItalic) { - distance += 1; - } return uint32_t(distance); } -#define NON_DESIRED_DIRECTION_DISTANCE 1000 -#define MAX_WEIGHT_DISTANCE 2000 - // CSS currently limits font weights to multiples of 100 but the weight // matching code below does not assume this. // -// Calculate weight values with range (0..1000). In general, heavier weights -// match towards even heavier weights while lighter weights match towards even -// lighter weights. Target weight values in the range [400..500] are special, -// since they will first match up to 500, then down to 0, then up again -// towards 999. +// Calculate weight distance with values in the range (0..1000). In general, +// heavier weights match towards even heavier weights while lighter weights +// match towards even lighter weights. Target weight values in the range +// [400..500] are special, since they will first match up to 500, then down +// towards 0, then up again towards 999. // // Example: with target 600 and font weight 800, distance will be 200. With -// target 300 and font weight 600, distance will be 1300, since heavier weights -// are farther away than lighter weights. If the target is 5 and the font weight -// 995, the distance would be 1990 for the same reason. +// target 300 and font weight 600, distance will be 900, since heavier +// weights are farther away than lighter weights. If the target is 5 and the +// font weight 995, the distance would be 1590 for the same reason. +#define REVERSE_WEIGHT_DISTANCE 600 +#define WEIGHT_SHIFT 11 // number of bits to contain weight distance + +// weight distance ==> [0,1598] static inline uint32_t -WeightDistance(uint32_t aTargetWeight, uint32_t aFontWeight) +WeightDistance(uint32_t aFontWeight, uint32_t aTargetWeight) { // Compute a measure of the "distance" between the requested // weight and the given fontEntry @@ -1235,13 +1247,34 @@ WeightDistance(uint32_t aTargetWeight, uint32_t aFontWeight) } } if (distance < 0) { - distance = -distance + NON_DESIRED_DIRECTION_DISTANCE; + distance = -distance + REVERSE_WEIGHT_DISTANCE; } distance += addedDistance; } return uint32_t(distance); } +#define MAX_DISTANCE 0xffffffff + +static inline uint32_t +WeightStyleStretchDistance(gfxFontEntry* aFontEntry, + const gfxFontStyle& aTargetStyle) +{ + // weight/style/stretch priority: stretch >> style >> weight + uint32_t stretchDist = + StretchDistance(aFontEntry->mStretch, aTargetStyle.stretch); + uint32_t styleDist = StyleDistance(aFontEntry->mStyle, aTargetStyle.style); + uint32_t weightDist = + WeightDistance(aFontEntry->Weight(), aTargetStyle.weight); + + NS_ASSERTION(weightDist < (1 << WEIGHT_SHIFT), "weight value out of bounds"); + NS_ASSERTION(styleDist < (1 << STYLE_SHIFT), "slope value out of bounds"); + + return (stretchDist << (STYLE_SHIFT + WEIGHT_SHIFT)) | + (styleDist << WEIGHT_SHIFT) | + weightDist; +} + void gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle, nsTArray& aFontEntryList, @@ -1271,9 +1304,6 @@ gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle, return; } - bool wantItalic = (aFontStyle.style & - (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; - // Most families are "simple", having just Regular/Bold/Italic/BoldItalic, // or some subset of these. In this case, we have exactly 4 entries in mAvailableFonts, // stored in the above order; note that some of the entries may be nullptr. @@ -1285,6 +1315,7 @@ gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle, // Family has no more than the "standard" 4 faces, at fixed indexes; // calculate which one we want. // Note that we cannot simply return it as not all 4 faces are necessarily present. + bool wantItalic = (aFontStyle.style != NS_FONT_STYLE_NORMAL); uint8_t faceIndex = (wantItalic ? kItalicMask : 0) | (wantBold ? kBoldMask : 0); @@ -1332,16 +1363,14 @@ gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle, // weight/style/stretch combination, only the last matched font entry will // be added. - uint32_t minDistance = 0xffffffff; + uint32_t minDistance = MAX_DISTANCE; gfxFontEntry* matched = nullptr; // iterate in forward order so that faces like 'Bold' are matched before // matching style distance faces such as 'Bold Outline' (see bug 1185812) for (uint32_t i = 0; i < count; i++) { fe = mAvailableFonts[i]; - uint32_t distance = - WeightDistance(aFontStyle.weight, fe->Weight()) + - (StyleStretchDistance(fe, wantItalic, aFontStyle.stretch) * - MAX_WEIGHT_DISTANCE); + // weight/style/stretch priority: stretch >> style >> weight + uint32_t distance = WeightStyleStretchDistance(fe, aFontStyle); if (distance < minDistance) { matched = fe; if (!aFontEntryList.IsEmpty()) { @@ -1391,8 +1420,9 @@ gfxFontFamily::CheckForSimpleFamily() gfxFontEntry *faces[4] = { 0 }; for (uint8_t i = 0; i < count; ++i) { gfxFontEntry *fe = mAvailableFonts[i]; - if (fe->Stretch() != firstStretch) { - return; // font-stretch doesn't match, don't treat as simple family + if (fe->Stretch() != firstStretch || fe->IsOblique()) { + // simple families don't have varying font-stretch or oblique + return; } uint8_t faceIndex = (fe->IsItalic() ? kItalicMask : 0) | (fe->Weight() >= 600 ? kBoldMask : 0); @@ -1448,9 +1478,8 @@ CalcStyleMatch(gfxFontEntry *aFontEntry, const gfxFontStyle *aStyle) int32_t rank = 0; if (aStyle) { // italics - bool wantItalic = - (aStyle->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; - if (aFontEntry->IsItalic() == wantItalic) { + bool wantUpright = (aStyle->style == NS_FONT_STYLE_NORMAL); + if (aFontEntry->IsUpright() == wantUpright) { rank += 10; } @@ -1458,7 +1487,7 @@ CalcStyleMatch(gfxFontEntry *aFontEntry, const gfxFontStyle *aStyle) rank += 9 - DeprecatedAbs(aFontEntry->Weight() / 100 - aStyle->ComputeWeight()); } else { // if no font to match, prefer non-bold, non-italic fonts - if (!aFontEntry->IsItalic()) { + if (aFontEntry->IsUpright()) { rank += 3; } if (!aFontEntry->IsBold()) { diff --git a/gfx/thebes/gfxFontEntry.h b/gfx/thebes/gfxFontEntry.h index c1e1a365d57a..d11f117b14c3 100644 --- a/gfx/thebes/gfxFontEntry.h +++ b/gfx/thebes/gfxFontEntry.h @@ -8,6 +8,7 @@ #include "gfxTypes.h" #include "nsString.h" +#include "gfxFontConstants.h" #include "gfxFontFeatures.h" #include "gfxFontUtils.h" #include "nsTArray.h" @@ -121,7 +122,9 @@ public: bool IsUserFont() const { return mIsDataUserFont || mIsLocalUserFont; } bool IsLocalUserFont() const { return mIsLocalUserFont; } bool IsFixedPitch() const { return mFixedPitch; } - bool IsItalic() const { return mItalic; } + bool IsItalic() const { return mStyle == NS_FONT_STYLE_ITALIC; } + bool IsOblique() const { return mStyle == NS_FONT_STYLE_OBLIQUE; } + bool IsUpright() const { return mStyle == NS_FONT_STYLE_NORMAL; } bool IsBold() const { return mWeight >= 600; } // bold == weights 600 and above bool IgnoreGDEF() const { return mIgnoreGDEF; } bool IgnoreGSUB() const { return mIgnoreGSUB; } @@ -388,7 +391,7 @@ public: nsString mName; nsString mFamilyName; - bool mItalic : 1; + uint8_t mStyle : 2; // italic/oblique bool mFixedPitch : 1; bool mIsValid : 1; bool mIsBadUnderlineFont : 1; diff --git a/gfx/thebes/gfxFontconfigFonts.cpp b/gfx/thebes/gfxFontconfigFonts.cpp index 6bf0576687a9..a23d52e9c2e0 100644 --- a/gfx/thebes/gfxFontconfigFonts.cpp +++ b/gfx/thebes/gfxFontconfigFonts.cpp @@ -335,10 +335,10 @@ protected: explicit gfxUserFcFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) : gfxFcFontEntry(aFontName) { - mItalic = aItalic; + mStyle = aStyle; mWeight = aWeight; mStretch = aStretch; } @@ -421,9 +421,9 @@ public: gfxLocalFcFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const nsTArray< nsCountedRef >& aPatterns) - : gfxUserFcFontEntry(aFontName, aWeight, aStretch, aItalic) + : gfxUserFcFontEntry(aFontName, aWeight, aStretch, aStyle) { if (!mPatterns.SetCapacity(aPatterns.Length(), fallible)) return; // OOM @@ -458,9 +458,9 @@ public: gfxDownloadedFcFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t *aData, FT_Face aFace) - : gfxUserFcFontEntry(aFontName, aWeight, aStretch, aItalic), + : gfxUserFcFontEntry(aFontName, aWeight, aStretch, aStyle), mFontData(aData), mFace(aFace) { NS_PRECONDITION(aFace != nullptr, "aFace is NULL!"); @@ -1748,7 +1748,7 @@ gfxPangoFontGroup::Shutdown() gfxPangoFontGroup::NewFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { gfxFontconfigUtils *utils = gfxFontconfigUtils::GetFontconfigUtils(); if (!utils) @@ -1791,7 +1791,7 @@ gfxPangoFontGroup::NewFontEntry(const nsAString& aFontName, return new gfxLocalFcFontEntry(aFontName, aWeight, aStretch, - aItalic, + aStyle, fonts); } @@ -1833,7 +1833,7 @@ gfxPangoFontGroup::GetFTLibrary() gfxPangoFontGroup::NewFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -1851,7 +1851,7 @@ gfxPangoFontGroup::NewFontEntry(const nsAString& aFontName, } return new gfxDownloadedFcFontEntry(aFontName, aWeight, - aStretch, aItalic, + aStretch, aStyle, aFontData, face); } diff --git a/gfx/thebes/gfxFontconfigFonts.h b/gfx/thebes/gfxFontconfigFonts.h index fe77332e8981..0d91a2a24a91 100644 --- a/gfx/thebes/gfxFontconfigFonts.h +++ b/gfx/thebes/gfxFontconfigFonts.h @@ -45,12 +45,12 @@ public: static gfxFontEntry *NewFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); // Used for @font-face { src: url(); } static gfxFontEntry *NewFontEntry(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxGDIFont.cpp b/gfx/thebes/gfxGDIFont.cpp index 6c212a1f083e..9d01c49ea535 100644 --- a/gfx/thebes/gfxGDIFont.cpp +++ b/gfx/thebes/gfxGDIFont.cpp @@ -177,9 +177,8 @@ gfxGDIFont::Initialize() // Figure out if we want to do synthetic oblique styling. GDIFontEntry* fe = static_cast(GetFontEntry()); - bool wantFakeItalic = - (mStyle.style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) && - !fe->IsItalic() && mStyle.allowSyntheticStyle; + bool wantFakeItalic = mStyle.style != NS_FONT_STYLE_NORMAL && + fe->IsUpright() && mStyle.allowSyntheticStyle; // If the font's family has an actual italic face (but font matching // didn't choose it), we have to use a cairo transform instead of asking diff --git a/gfx/thebes/gfxGDIFontList.cpp b/gfx/thebes/gfxGDIFontList.cpp index 504f9fdd6791..8d4ff569d3e1 100644 --- a/gfx/thebes/gfxGDIFontList.cpp +++ b/gfx/thebes/gfxGDIFontList.cpp @@ -118,7 +118,8 @@ FontTypeToOutPrecision(uint8_t fontType) GDIFontEntry::GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType, - bool aItalic, uint16_t aWeight, int16_t aStretch, + uint8_t aStyle, uint16_t aWeight, + int16_t aStretch, gfxUserFontData *aUserFontData, bool aFamilyHasItalicFace) : gfxFontEntry(aFaceName), @@ -129,7 +130,7 @@ GDIFontEntry::GDIFontEntry(const nsAString& aFaceName, mCharset(), mUnicodeRanges() { mUserFontData = aUserFontData; - mItalic = aItalic; + mStyle = aStyle; mWeight = aWeight; mStretch = aStretch; if (IsType1()) @@ -306,9 +307,10 @@ GDIFontEntry::TestCharacterMap(uint32_t aCh) return false; // previous code was using the group style - gfxFontStyle fakeStyle; - if (mItalic) + gfxFontStyle fakeStyle; + if (!IsUpright()) { fakeStyle.style = NS_FONT_STYLE_ITALIC; + } fakeStyle.weight = mWeight * 100; RefPtr tempFont = FindOrMakeFont(&fakeStyle, false); @@ -387,7 +389,7 @@ GDIFontEntry::InitLogFont(const nsAString& aName, // do its best to give us an italic font entry, but if no face exists // it may give us a regular one based on weight. Windows should // do fake italic for us in that case. - mLogFont.lfItalic = mItalic; + mLogFont.lfItalic = !IsUpright(); mLogFont.lfWeight = mWeight; int len = std::min(aName.Length(), LF_FACESIZE - 1); @@ -397,14 +399,15 @@ GDIFontEntry::InitLogFont(const nsAString& aName, GDIFontEntry* GDIFontEntry::CreateFontEntry(const nsAString& aName, - gfxWindowsFontType aFontType, bool aItalic, + gfxWindowsFontType aFontType, + uint8_t aStyle, uint16_t aWeight, int16_t aStretch, gfxUserFontData* aUserFontData, bool aFamilyHasItalicFace) { // jtdfix - need to set charset, unicode ranges, pitch/family - GDIFontEntry *fe = new GDIFontEntry(aName, aFontType, aItalic, + GDIFontEntry *fe = new GDIFontEntry(aName, aFontType, aStyle, aWeight, aStretch, aUserFontData, aFamilyHasItalicFace); @@ -456,7 +459,7 @@ GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe, fe = static_cast(ff->mAvailableFonts[i].get()); // check if we already know about this face if (fe->mWeight == logFont.lfWeight && - fe->mItalic == (logFont.lfItalic == 0xFF)) { + fe->IsItalic() == (logFont.lfItalic == 0xFF)) { // update the charset bit here since this could be different fe->mCharset.set(metrics.tmCharSet); return 1; @@ -466,8 +469,10 @@ GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe, // We can't set the hasItalicFace flag correctly here, // because we might not have seen the family's italic face(s) yet. // So we'll set that flag for all members after loading all the faces. + uint8_t italicStyle = (logFont.lfItalic == 0xFF ? + NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL); fe = GDIFontEntry::CreateFontEntry(nsDependentString(lpelfe->elfFullName), - feType, (logFont.lfItalic == 0xFF), + feType, italicStyle, (uint16_t) (logFont.lfWeight), 0, nullptr, false); if (!fe) @@ -712,7 +717,7 @@ gfxFontEntry* gfxGDIFontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { gfxFontEntry *lookup; @@ -729,10 +734,9 @@ gfxGDIFontList::LookupLocalFont(const nsAString& aFontName, // 'Arial Vet' which can be used as a key in GDI font lookups). GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(lookup->Name(), gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/, - lookup->mItalic ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL, - lookup->mWeight, aStretch, nullptr, + lookup->mStyle, lookup->mWeight, aStretch, nullptr, static_cast(lookup)->mFamilyHasItalicFace); - + if (!fe) return nullptr; @@ -740,7 +744,7 @@ gfxGDIFontList::LookupLocalFont(const nsAString& aFontName, // make the new font entry match the userfont entry style characteristics fe->mWeight = (aWeight == 0 ? 400 : aWeight); - fe->mItalic = aItalic; + fe->mStyle = aStyle; return fe; } @@ -749,7 +753,7 @@ gfxFontEntry* gfxGDIFontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -808,17 +812,16 @@ gfxGDIFontList::MakePlatformFont(const nsAString& aFontName, WinUserFontData *winUserFontData = new WinUserFontData(fontRef); uint16_t w = (aWeight == 0 ? 400 : aWeight); - GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(uniqueName, - gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/, - uint32_t(aItalic ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL), - w, aStretch, winUserFontData, false); + GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(uniqueName, + gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/, + aStyle, w, aStretch, winUserFontData, false); if (!fe) return fe; fe->mIsDataUserFont = true; - // Uniscribe doesn't place CFF fonts loaded privately + // Uniscribe doesn't place CFF fonts loaded privately // via AddFontMemResourceEx on XP/Vista if (isCFF && !IsWin7OrLater()) { fe->mForceGDI = true; diff --git a/gfx/thebes/gfxGDIFontList.h b/gfx/thebes/gfxGDIFontList.h index 81ad45aa7601..4fca9324e22a 100644 --- a/gfx/thebes/gfxGDIFontList.h +++ b/gfx/thebes/gfxGDIFontList.h @@ -236,7 +236,7 @@ public: // create a font entry for a font with a given name static GDIFontEntry* CreateFontEntry(const nsAString& aName, gfxWindowsFontType aFontType, - bool aItalic, + uint8_t aStyle, uint16_t aWeight, int16_t aStretch, gfxUserFontData* aUserFontData, bool aFamilyHasItalicFace); @@ -245,7 +245,7 @@ public: static GDIFontEntry* LoadLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); uint8_t mWindowsFamily; uint8_t mWindowsPitch; @@ -266,7 +266,7 @@ protected: friend class gfxWindowsFont; GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType, - bool aItalic, uint16_t aWeight, int16_t aStretch, + uint8_t aStyle, uint16_t aWeight, int16_t aStretch, gfxUserFontData *aUserFontData, bool aFamilyHasItalicFace); void InitLogFont(const nsAString& aName, gfxWindowsFontType aFontType); @@ -311,12 +311,12 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp index 1e0600c891c3..239899b010ec 100644 --- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -61,11 +61,10 @@ gfxMacFont::gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyl cairo_matrix_init_scale(&sizeMatrix, mAdjustedSize, mAdjustedSize); // synthetic oblique by skewing via the font matrix - bool needsOblique = - (mFontEntry != nullptr) && - (!mFontEntry->IsItalic() && - (mStyle.style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE))) && - mStyle.allowSyntheticStyle; + bool needsOblique = mFontEntry != nullptr && + mFontEntry->IsUpright() && + mStyle.style != NS_FONT_STYLE_NORMAL && + mStyle.allowSyntheticStyle; if (needsOblique) { cairo_matrix_t style; diff --git a/gfx/thebes/gfxMacPlatformFontList.h b/gfx/thebes/gfxMacPlatformFontList.h index 232d5bb05171..7804cde41374 100644 --- a/gfx/thebes/gfxMacPlatformFontList.h +++ b/gfx/thebes/gfxMacPlatformFontList.h @@ -33,7 +33,7 @@ public: // for use with data fonts MacOSFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef, - uint16_t aWeight, uint16_t aStretch, uint32_t aItalicStyle, + uint16_t aWeight, uint16_t aStretch, uint8_t aStyle, bool aIsDataUserFont, bool aIsLocal); virtual ~MacOSFontEntry() { @@ -86,12 +86,12 @@ public: gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) override; - + uint8_t aStyle) override; + gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index 801af8c51d1c..d1c8817cb06c 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -268,7 +268,7 @@ MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName, MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef, uint16_t aWeight, uint16_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, bool aIsDataUserFont, bool aIsLocalUserFont) : gfxFontEntry(aPostscriptName, false), @@ -285,7 +285,7 @@ MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName, mWeight = aWeight; mStretch = aStretch; mFixedPitch = false; // xxx - do we need this for downloaded fonts? - mItalic = (aItalicStyle & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; + mStyle = aStyle; NS_ASSERTION(!(aIsDataUserFont && aIsLocalUserFont), "userfont is either a data font or a local font"); @@ -523,7 +523,7 @@ gfxMacFontFamily::FindStyleVariations(FontInfoData *aFontInfoData) [facename hasSuffix:@"Italic"] || [facename hasSuffix:@"Oblique"]) { - fontEntry->mItalic = true; + fontEntry->mStyle = NS_FONT_STYLE_ITALIC; } if (macTraits & NSFixedPitchFontMask) { fontEntry->mFixedPitch = true; @@ -1009,7 +1009,7 @@ gfxFontEntry* gfxMacPlatformFontList::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { nsAutoreleasePool localPool; @@ -1026,10 +1026,7 @@ gfxMacPlatformFontList::LookupLocalFont(const nsAString& aFontName, "bogus font weight value!"); newFontEntry = - new MacOSFontEntry(aFontName, fontRef, - aWeight, aStretch, - aItalic ? - NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL, + new MacOSFontEntry(aFontName, fontRef, aWeight, aStretch, aStyle, false, true); ::CFRelease(fontRef); @@ -1045,7 +1042,7 @@ gfxFontEntry* gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -1073,11 +1070,7 @@ gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName, nsAutoPtr newFontEntry(new MacOSFontEntry(uniqueName, fontRef, aWeight, - aStretch, - aItalic ? - NS_FONT_STYLE_ITALIC : - NS_FONT_STYLE_NORMAL, - true, false)); + aStretch, aStyle, true, false)); ::CFRelease(fontRef); // if succeeded and font cmap is good, return the new font diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 69bac9d2faa4..a072dcc080c5 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -1376,7 +1376,7 @@ gfxFontEntry* gfxPlatform::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 2b23ce625df2..3ab789f10f04 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -348,7 +348,7 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { return nullptr; } /** @@ -362,7 +362,7 @@ public: virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/gfx/thebes/gfxPlatformFontList.h b/gfx/thebes/gfxPlatformFontList.h index d36b32d7c673..fccb6e08b3b6 100644 --- a/gfx/thebes/gfxPlatformFontList.h +++ b/gfx/thebes/gfxPlatformFontList.h @@ -153,14 +153,14 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) = 0; + uint8_t aStyle) = 0; // create a new platform font from downloaded data (@font-face) // this method is responsible to ensure aFontData is free()'d virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) = 0; diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index a77ec2395018..74ac7af7d63e 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -256,34 +256,35 @@ gfxFontEntry* gfxPlatformGtk::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { if (sUseFcFontList) { gfxPlatformFontList* pfl = gfxPlatformFontList::PlatformFontList(); - return pfl->LookupLocalFont(aFontName, aWeight, aStretch, aItalic); + return pfl->LookupLocalFont(aFontName, aWeight, aStretch, + aStyle); } return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight, - aStretch, aItalic); + aStretch, aStyle); } gfxFontEntry* gfxPlatformGtk::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { if (sUseFcFontList) { gfxPlatformFontList* pfl = gfxPlatformFontList::PlatformFontList(); - return pfl->MakePlatformFont(aFontName, aWeight, aStretch, aItalic, - aFontData, aLength); + return pfl->MakePlatformFont(aFontName, aWeight, aStretch, + aStyle, aFontData, aLength); } // passing ownership of the font data to the new font entry return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight, - aStretch, aItalic, + aStretch, aStyle, aFontData, aLength); } diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h index 548d7b704d73..b32ac6b99fb2 100644 --- a/gfx/thebes/gfxPlatformGtk.h +++ b/gfx/thebes/gfxPlatformGtk.h @@ -63,7 +63,7 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) override; + uint8_t aStyle) override; /** * Activate a platform font (needed to support @font-face src url() ) @@ -72,7 +72,7 @@ public: virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp index ca589a0f5305..b320febbb8ac 100644 --- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -152,19 +152,19 @@ gfxFontEntry* gfxPlatformMac::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(aFontName, aWeight, aStretch, - aItalic); + aStyle); } gfxFontEntry* gfxPlatformMac::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { @@ -174,7 +174,7 @@ gfxPlatformMac::MakePlatformFont(const nsAString& aFontName, return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(aFontName, aWeight, aStretch, - aItalic, + aStyle, aFontData, aLength); } diff --git a/gfx/thebes/gfxPlatformMac.h b/gfx/thebes/gfxPlatformMac.h index a4046e6933a4..e0edb9cdeb19 100644 --- a/gfx/thebes/gfxPlatformMac.h +++ b/gfx/thebes/gfxPlatformMac.h @@ -44,14 +44,14 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) override; + uint8_t aStyle) override; virtual gfxPlatformFontList* CreatePlatformFontList() override; virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxQtPlatform.cpp b/gfx/thebes/gfxQtPlatform.cpp index 371d847618d9..1aed17ccaa32 100644 --- a/gfx/thebes/gfxQtPlatform.cpp +++ b/gfx/thebes/gfxQtPlatform.cpp @@ -132,23 +132,23 @@ gfxFontEntry* gfxQtPlatform::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight, - aStretch, aItalic); + aStretch, aStyle); } gfxFontEntry* gfxQtPlatform::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { // passing ownership of the font data to the new font entry return gfxPangoFontGroup::NewFontEntry(aFontName, aWeight, - aStretch, aItalic, + aStretch, aStyle, aFontData, aLength); } diff --git a/gfx/thebes/gfxQtPlatform.h b/gfx/thebes/gfxQtPlatform.h index fad09180df53..ed5c26e942e5 100644 --- a/gfx/thebes/gfxQtPlatform.h +++ b/gfx/thebes/gfxQtPlatform.h @@ -54,7 +54,7 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) override; + uint8_t aStyle) override; /** * Activate a platform font (needed to support @font-face src url() ) @@ -63,7 +63,7 @@ public: virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) override; diff --git a/gfx/thebes/gfxUserFontSet.cpp b/gfx/thebes/gfxUserFontSet.cpp index c1c726afd95a..a210956dc297 100644 --- a/gfx/thebes/gfxUserFontSet.cpp +++ b/gfx/thebes/gfxUserFontSet.cpp @@ -109,7 +109,7 @@ gfxUserFontEntry::gfxUserFontEntry(gfxUserFontSet* aFontSet, const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) @@ -127,9 +127,7 @@ gfxUserFontEntry::gfxUserFontEntry(gfxUserFontSet* aFontSet, mSrcIndex = 0; mWeight = aWeight; mStretch = aStretch; - // XXX Currently, we don't distinguish 'italic' and 'oblique' styles; - // we need to fix this. (Bug 543715) - mItalic = (aItalicStyle & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; + mStyle = aStyle; mFeatureSettings.AppendElements(aFeatureSettings); mLanguageOverride = aLanguageOverride; @@ -147,18 +145,14 @@ bool gfxUserFontEntry::Matches(const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) { - // XXX font entries don't distinguish italic from oblique (bug 543715) - bool isItalic = - (aItalicStyle & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0; - return mWeight == aWeight && mStretch == aStretch && - mItalic == isItalic && + mStyle == aStyle && mFeatureSettings == aFeatureSettings && mLanguageOverride == aLanguageOverride && mSrcList == aFontFaceSrcList && @@ -412,7 +406,7 @@ gfxUserFontEntry::LoadNextSrc() gfxPlatform::GetPlatform()->LookupLocalFont(currSrc.mLocalName, mWeight, mStretch, - mItalic); + mStyle); nsTArray fontSets; GetUserFontSets(fontSets); for (gfxUserFontSet* fontSet : fontSets) { @@ -612,11 +606,10 @@ gfxUserFontEntry::LoadPlatformFont(const uint8_t* aFontData, uint32_t& aLength) originalFullName); // Here ownership of saneData is passed to the platform, // which will delete it when no longer required - fe = gfxPlatform::GetPlatform()->MakePlatformFont(mName, mWeight, mStretch, - mItalic, + mStyle, saneData, saneLen); if (!fe) { @@ -771,7 +764,7 @@ gfxUserFontSet::FindOrCreateUserFontEntry( const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) @@ -787,14 +780,14 @@ gfxUserFontSet::FindOrCreateUserFontEntry( gfxUserFontFamily* family = LookupFamily(aFamilyName); if (family) { entry = FindExistingUserFontEntry(family, aFontFaceSrcList, aWeight, - aStretch, aItalicStyle, + aStretch, aStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); } if (!entry) { entry = CreateUserFontEntry(aFontFaceSrcList, aWeight, aStretch, - aItalicStyle, aFeatureSettings, + aStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); entry->mFamilyName = aFamilyName; } @@ -807,7 +800,7 @@ gfxUserFontSet::CreateUserFontEntry( const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) @@ -815,7 +808,7 @@ gfxUserFontSet::CreateUserFontEntry( RefPtr userFontEntry = new gfxUserFontEntry(this, aFontFaceSrcList, aWeight, - aStretch, aItalicStyle, aFeatureSettings, + aStretch, aStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); return userFontEntry.forget(); } @@ -826,7 +819,7 @@ gfxUserFontSet::FindExistingUserFontEntry( const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) @@ -844,7 +837,7 @@ gfxUserFontSet::FindExistingUserFontEntry( gfxUserFontEntry* existingUserFontEntry = static_cast(fontList[i].get()); if (!existingUserFontEntry->Matches(aFontFaceSrcList, - aWeight, aStretch, aItalicStyle, + aWeight, aStretch, aStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges)) { continue; @@ -867,7 +860,8 @@ gfxUserFontSet::AddUserFontEntry(const nsAString& aFamilyName, LOG(("userfonts (%p) added to \"%s\" (%p) style: %s weight: %d " "stretch: %d", this, NS_ConvertUTF16toUTF8(aFamilyName).get(), aUserFontEntry, - (aUserFontEntry->IsItalic() ? "italic" : "normal"), + (aUserFontEntry->IsItalic() ? "italic" : + (aUserFontEntry->IsOblique() ? "oblique" : "normal")), aUserFontEntry->Weight(), aUserFontEntry->Stretch())); } } @@ -1050,7 +1044,7 @@ gfxUserFontSet::UserFontCache::Entry::KeyEquals(const KeyTypePointer aKey) const } } - if (mFontEntry->mItalic != fe->mItalic || + if (mFontEntry->mStyle != fe->mStyle || mFontEntry->mWeight != fe->mWeight || mFontEntry->mStretch != fe->mStretch || mFontEntry->mFeatureSettings != fe->mFeatureSettings || diff --git a/gfx/thebes/gfxUserFontSet.h b/gfx/thebes/gfxUserFontSet.h index 320c9c088370..567227ed939c 100644 --- a/gfx/thebes/gfxUserFontSet.h +++ b/gfx/thebes/gfxUserFontSet.h @@ -16,6 +16,7 @@ #include "nsIScriptError.h" #include "nsURIHashKey.h" #include "mozilla/net/ReferrerPolicy.h" +#include "gfxFontConstants.h" class nsFontFaceLoader; @@ -210,7 +211,7 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) = 0; @@ -222,7 +223,7 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges); @@ -416,9 +417,9 @@ public: nsURIHashKey::HashKey(aKey->mURI), HashFeatures(aKey->mFontEntry->mFeatureSettings), mozilla::HashString(aKey->mFontEntry->mFamilyName), - ((uint32_t)aKey->mFontEntry->mItalic | - (aKey->mFontEntry->mWeight << 1) | - (aKey->mFontEntry->mStretch << 10) ) ^ + (aKey->mFontEntry->mStyle | + (aKey->mFontEntry->mWeight << 2) | + (aKey->mFontEntry->mStretch << 11) ) ^ aKey->mFontEntry->mLanguageOverride); } @@ -495,7 +496,7 @@ protected: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges); @@ -534,7 +535,7 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges); @@ -545,7 +546,7 @@ public: bool Matches(const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges); diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 556507b8f6d3..7ff3561ea300 100755 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -1056,26 +1056,26 @@ gfxFontEntry* gfxWindowsPlatform::LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic) + uint8_t aStyle) { return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(aFontName, aWeight, aStretch, - aItalic); + aStyle); } gfxFontEntry* gfxWindowsPlatform::MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength) { return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(aFontName, aWeight, aStretch, - aItalic, + aStyle, aFontData, aLength); } diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 7e3bfd15947e..0d6005ba5e5a 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -193,7 +193,7 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic); + uint8_t aStyle); /** * Activate a platform font (needed to support @font-face src url() ) @@ -201,7 +201,7 @@ public: virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - bool aItalic, + uint8_t aStyle, const uint8_t* aFontData, uint32_t aLength); diff --git a/layout/style/FontFace.h b/layout/style/FontFace.h index 1d6cfe0f78d1..58072b6e507d 100644 --- a/layout/style/FontFace.h +++ b/layout/style/FontFace.h @@ -44,12 +44,12 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) : gfxUserFontEntry(aFontSet, aFontFaceSrcList, aWeight, aStretch, - aItalicStyle, aFeatureSettings, aLanguageOverride, + aStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges) {} virtual void SetLoadState(UserFontLoadState aLoadState) override; diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 2eda306d1252..7362eb87f7e1 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -169,7 +169,7 @@ FontFaceSet::ParseFontShorthandForMatching( RefPtr& aFamilyList, uint32_t& aWeight, int32_t& aStretch, - uint32_t& aItalicStyle, + uint8_t& aStyle, ErrorResult& aRv) { // Parse aFont as a 'font' property value. @@ -224,7 +224,7 @@ FontFaceSet::ParseFontShorthandForMatching( aWeight = weight; aStretch = data->ValueFor(eCSSProperty_font_stretch)->GetIntValue(); - aItalicStyle = data->ValueFor(eCSSProperty_font_style)->GetIntValue(); + aStyle = data->ValueFor(eCSSProperty_font_style)->GetIntValue(); } static bool @@ -252,7 +252,7 @@ FontFaceSet::FindMatchingFontFaces(const nsAString& aFont, RefPtr familyList; uint32_t weight; int32_t stretch; - uint32_t italicStyle; + uint8_t italicStyle; ParseFontShorthandForMatching(aFont, familyList, weight, stretch, italicStyle, aRv); if (aRv.Failed()) { @@ -964,7 +964,7 @@ FontFaceSet::FindOrCreateUserFontEntryFromFontFace(const nsAString& aFamilyName, uint32_t weight = NS_STYLE_FONT_WEIGHT_NORMAL; int32_t stretch = NS_STYLE_FONT_STRETCH_NORMAL; - uint32_t italicStyle = NS_STYLE_FONT_STYLE_NORMAL; + uint8_t italicStyle = NS_STYLE_FONT_STYLE_NORMAL; uint32_t languageOverride = NO_FONT_LANGUAGE_OVERRIDE; // set up weight @@ -1772,13 +1772,13 @@ FontFaceSet::UserFontSet::CreateUserFontEntry( const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) { RefPtr entry = - new FontFace::Entry(this, aFontFaceSrcList, aWeight, aStretch, aItalicStyle, + new FontFace::Entry(this, aFontFaceSrcList, aWeight, aStretch, aStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); return entry.forget(); } diff --git a/layout/style/FontFaceSet.h b/layout/style/FontFaceSet.h index 782f36de097e..e2e435a301bf 100644 --- a/layout/style/FontFaceSet.h +++ b/layout/style/FontFaceSet.h @@ -83,7 +83,7 @@ public: const nsTArray& aFontFaceSrcList, uint32_t aWeight, int32_t aStretch, - uint32_t aItalicStyle, + uint8_t aStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) override; @@ -286,7 +286,7 @@ private: RefPtr& aFamilyList, uint32_t& aWeight, int32_t& aStretch, - uint32_t& aItalicStyle, + uint8_t& aStyle, ErrorResult& aRv); void FindMatchingFontFaces(const nsAString& aFont, const nsAString& aText, From 1c88c2730e8ea736310dd23123c6bedc167285a7 Mon Sep 17 00:00:00 2001 From: John Daggett Date: Mon, 19 Oct 2015 11:17:00 +0900 Subject: [PATCH 19/25] Bug 543715 p2 - italic/oblique reftests. r=jfkthame --- .../font-matching/italic-oblique-1.html | 31 +++++++++++++ .../font-matching/italic-oblique-2.html | 31 +++++++++++++ .../font-matching/italic-oblique-3.html | 37 +++++++++++++++ .../font-matching/italic-oblique-4.html | 37 +++++++++++++++ .../font-matching/italic-oblique-5.html | 37 +++++++++++++++ .../font-matching/italic-oblique-6.html | 37 +++++++++++++++ .../font-matching/italic-oblique-7.html | 37 +++++++++++++++ .../font-matching/italic-oblique-8.html | 43 ++++++++++++++++++ .../font-matching/italic-oblique-9.html | 43 ++++++++++++++++++ .../italic-oblique-kinnari-ref.html | 37 +++++++++++++++ .../font-matching/italic-oblique-kinnari.html | 37 +++++++++++++++ .../font-matching/italic-oblique-ref.html | 24 ++++++++++ layout/reftests/font-matching/reftest.list | 13 ++++++ .../font-matching/simple-oblique-ref.html | 33 ++++++++++++++ .../font-matching/simple-oblique.html | 33 ++++++++++++++ layout/reftests/fonts/mark2A.woff | Bin 0 -> 1084 bytes layout/reftests/fonts/mark2B.woff | Bin 0 -> 1084 bytes layout/reftests/fonts/mark2C.woff | Bin 0 -> 1084 bytes layout/reftests/fonts/mark2D.woff | Bin 0 -> 1084 bytes 19 files changed, 510 insertions(+) create mode 100644 layout/reftests/font-matching/italic-oblique-1.html create mode 100644 layout/reftests/font-matching/italic-oblique-2.html create mode 100644 layout/reftests/font-matching/italic-oblique-3.html create mode 100644 layout/reftests/font-matching/italic-oblique-4.html create mode 100644 layout/reftests/font-matching/italic-oblique-5.html create mode 100644 layout/reftests/font-matching/italic-oblique-6.html create mode 100644 layout/reftests/font-matching/italic-oblique-7.html create mode 100644 layout/reftests/font-matching/italic-oblique-8.html create mode 100644 layout/reftests/font-matching/italic-oblique-9.html create mode 100644 layout/reftests/font-matching/italic-oblique-kinnari-ref.html create mode 100644 layout/reftests/font-matching/italic-oblique-kinnari.html create mode 100644 layout/reftests/font-matching/italic-oblique-ref.html create mode 100644 layout/reftests/font-matching/simple-oblique-ref.html create mode 100644 layout/reftests/font-matching/simple-oblique.html create mode 100644 layout/reftests/fonts/mark2A.woff create mode 100644 layout/reftests/fonts/mark2B.woff create mode 100644 layout/reftests/fonts/mark2C.woff create mode 100644 layout/reftests/fonts/mark2D.woff diff --git a/layout/reftests/font-matching/italic-oblique-1.html b/layout/reftests/font-matching/italic-oblique-1.html new file mode 100644 index 000000000000..7df94b51dc49 --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-1.html @@ -0,0 +1,31 @@ + + +style matching - italic/oblique + + + + + + + + + +

BBB

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-2.html b/layout/reftests/font-matching/italic-oblique-2.html new file mode 100644 index 000000000000..b3264120d56f --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-2.html @@ -0,0 +1,31 @@ + + +style matching - italic/oblique + + + + + + + + + +

CCC

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-3.html b/layout/reftests/font-matching/italic-oblique-3.html new file mode 100644 index 000000000000..cf897ae44dcd --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-3.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

BBB

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-4.html b/layout/reftests/font-matching/italic-oblique-4.html new file mode 100644 index 000000000000..2313462c340c --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-4.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

BBB

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-5.html b/layout/reftests/font-matching/italic-oblique-5.html new file mode 100644 index 000000000000..de1281b0a2eb --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-5.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

BBB

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-6.html b/layout/reftests/font-matching/italic-oblique-6.html new file mode 100644 index 000000000000..de23a2de9e21 --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-6.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

CCC

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-7.html b/layout/reftests/font-matching/italic-oblique-7.html new file mode 100644 index 000000000000..05cc3c45f44f --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-7.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

AAA

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-8.html b/layout/reftests/font-matching/italic-oblique-8.html new file mode 100644 index 000000000000..ee4ec956ffe4 --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-8.html @@ -0,0 +1,43 @@ + + +style matching - italic/oblique + + + + + + + + + +

CCC

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-9.html b/layout/reftests/font-matching/italic-oblique-9.html new file mode 100644 index 000000000000..dfc4012fa9c9 --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-9.html @@ -0,0 +1,43 @@ + + +style matching - italic/oblique + + + + + + + + + +

CCC

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-kinnari-ref.html b/layout/reftests/font-matching/italic-oblique-kinnari-ref.html new file mode 100644 index 000000000000..4499ebc0b434 --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-kinnari-ref.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

AAA

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-kinnari.html b/layout/reftests/font-matching/italic-oblique-kinnari.html new file mode 100644 index 000000000000..f465d247e4fb --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-kinnari.html @@ -0,0 +1,37 @@ + + +style matching - italic/oblique + + + + + + + + + +

AAA

+ + + + diff --git a/layout/reftests/font-matching/italic-oblique-ref.html b/layout/reftests/font-matching/italic-oblique-ref.html new file mode 100644 index 000000000000..8ae9bbc19b94 --- /dev/null +++ b/layout/reftests/font-matching/italic-oblique-ref.html @@ -0,0 +1,24 @@ + + +style matching - italic/oblique + + + + + + + + + +

AAA

+ + + + diff --git a/layout/reftests/font-matching/reftest.list b/layout/reftests/font-matching/reftest.list index 884840336985..cf7a2f4e66f1 100644 --- a/layout/reftests/font-matching/reftest.list +++ b/layout/reftests/font-matching/reftest.list @@ -98,3 +98,16 @@ skip-if(Mulet) HTTP(..) == font-synthesis-2.html font-synthesis-2-ref.html # MUL # Bug 1060791 - support for format 10 cmap in Apple Symbols; # relevant fonts not present on other platforms. skip-if(!cocoaWidget) HTTP(..) != apple-symbols-1.html apple-symbols-1-notref.html + +# distinguish between italic and oblique +== simple-oblique.html simple-oblique-ref.html +== italic-oblique-1.html italic-oblique-ref.html +fuzzy-if(Mulet,103,144) == italic-oblique-2.html italic-oblique-ref.html +== italic-oblique-3.html italic-oblique-ref.html +== italic-oblique-4.html italic-oblique-ref.html +== italic-oblique-5.html italic-oblique-ref.html +fuzzy-if(Mulet,103,144) == italic-oblique-6.html italic-oblique-ref.html +== italic-oblique-7.html italic-oblique-ref.html +fuzzy-if(Mulet,103,144) == italic-oblique-8.html italic-oblique-ref.html +fuzzy-if(Mulet,103,144) == italic-oblique-9.html italic-oblique-ref.html +!= italic-oblique-kinnari.html italic-oblique-kinnari-ref.html diff --git a/layout/reftests/font-matching/simple-oblique-ref.html b/layout/reftests/font-matching/simple-oblique-ref.html new file mode 100644 index 000000000000..d021f51d02b6 --- /dev/null +++ b/layout/reftests/font-matching/simple-oblique-ref.html @@ -0,0 +1,33 @@ + + + +oblique italic equivalence + + + + + + + +

UNICORN asteroid

+

UNICORN asteroid

+

UNICORN asteroid

+ + + \ No newline at end of file diff --git a/layout/reftests/font-matching/simple-oblique.html b/layout/reftests/font-matching/simple-oblique.html new file mode 100644 index 000000000000..cb4671f4d85e --- /dev/null +++ b/layout/reftests/font-matching/simple-oblique.html @@ -0,0 +1,33 @@ + + + +oblique italic equivalence + + + + + + + +

UNICORN asteroid

+

UNICORN asteroid

+

UNICORN asteroid

+ + + \ No newline at end of file diff --git a/layout/reftests/fonts/mark2A.woff b/layout/reftests/fonts/mark2A.woff new file mode 100644 index 0000000000000000000000000000000000000000..58869bec71a78714fdb0ce0ee79a8486be55debc GIT binary patch literal 1084 zcmXT-cXMN4WB>vd8wOqw&H4pIVgqh&A-+I$3P3q2AeQl4_u`~~u)Yxk1LG1P-w}wz zLjR_kCFdp<0L6Yl#2B3z_?h1)mz5|mFfiEw#aO^tk*P90u^6b1MFPm@0O9}t8JN>^ zD${`Ke1QBaAg(EoT9}`anwSDK&j83b1Y)xf!3(N0fPz3Vpg4mZ5UX(RX6MbwEvW#C zy#VqBKv-0Qp*1Hz8K{oQ0m$b9;|zw7+{6ly`&xi}c_3C`@L;gaOUz9LsyhJ`Hv!VZ zYhO#U7UUO~FfcIx0jiM(Vy*w{7)&c}B`2gLBrrT`zjfX3_~+X-sSncX7)25-vKCI~ zUM?yrabudnTgD;dKefkU~*$S)G#yA zgPEb7iR~ZAFkl=4Ni8t6gZLvU02n$~l4cz}aOS|d1=}Z1biAJ?Y|VW*dU0>gn(`bo zLu1C7Jkm2A53Nyn==&z8ryeNObflM6l=W&a>r_!m%Xk_4b0)9zXDJ1pVPo5- z>QmjIX2j7f!dQ5Ua~iLDom|4L&;9KmPsfY1v9U2+)s{aEvb(hZyw_m|fn)pM&R-C4 zWU_hU2ZgtaiNYFF;#{-?+c#D-*&)3M!U6s}< zr*&TU)9&YHavxsqY@TQJ`A+MK?DLGj&(AoJ(9Wz=v}S`Fr=vVK&kW&=V;v@suS^tX zRZfjvtyB8deyN&zZe!<7*_?e*(=WyIs9da4F)lvStu(cBqjmCSBl9`415-9WY^)Yr zc~_;>txeTDv?6t)?&q$`S7OukqNUEvS=+IVB{}^~dGKXPC6_ZC^>321wmrRaBUH_E zNvh6S*Fy$9k2h@l*}v5CedL?JpO3ulzFYcMCSl%9+jy0z;}fq%{kvDp)FtOz4N3z^ z49)+~^0+y4O=Oha(BL{#B80(mC*xyK>@ouLBNHT@q%brom)(8u@FkFYZ;S*lgL5tG HS_TFHZ25Y1 literal 0 HcmV?d00001 diff --git a/layout/reftests/fonts/mark2B.woff b/layout/reftests/fonts/mark2B.woff new file mode 100644 index 0000000000000000000000000000000000000000..d1319a74c83e5b921a0d02a425b06f4c960ee762 GIT binary patch literal 1084 zcmXT-cXMN4WB>vd8wOqw&H4pIVgqh&A-+I$3P3q2AeQl4_u`~~u)Yxk1LG1P-w}wz zLjR?jC+8*>0L6Yl#2B5J`I+A)mz5|mFfiEw#aO^tk*P90u^6b1MFPm@0O9}t8JN>^ zD${`Ke1QBaAg(EoT9}`anwSDK&j83b1Y)xf!3(N0fPz3Vpg4mZ5UX(RX6MbwEvW#C zy#VqBKv-0Qp*1Hz8K{oQ0m$b9;|zw7+{6ly`&xi}c_3C`@L;gaOUz9LsyhJ`Hv!VZ z>)%VW7UUO~FfcIx0jiM(Vy*w{8B8l~B`2gLBrrUB{b~BSW1nx=q&`TiV-!iW$XYm^ zd%38j#EoeNZyAd$C1yA*Vz5x=`~cJl)pP6cfdc|Z&oQb<0@WB8EnpI3&}U%00hdom ze2|ck#K0(U@&toWal!>=PGI0PGBiQ-KTr5`=)kE12d*65(%#s(klo4HF2Nurg{jME zL!r?D24!X;4v%8r#Dau^q=KZdANdCbSg-MhGBcctgn(`bo zLu1C7Jkm2A53Nyn==&z8ryeNObflM6l=W&a>r_!m%Xk_4b0)9zXDJ1pVPo5- z>QmjIX2j7f!dQ5Ua~iLDom|4L&;9KmPsfY1v9U2+)s{aEvb(hZyw_m|fn)pM&R-C4 zWU_hU2ZgtaiNYFF;#jn8BR^hQEO6^W+p)ZxYVF@%omKzvO!`OIKKK1OVtX^#jP^@D zoBdPl0PDU57izXwd|D&$;B0aCpNBhprE99+DFlSi+r1;Cd>-?+c#D-*&)3M!U6s}< zr*&TU)9&YHavxsqY@TQJ`A+MK?DLGj&(AoJ(9Wz=v}S`Fr=vVK&kW&=V;v@suS^tX zRZfjvtyB8deyN&zZe!<7*_?e*(=WyIs9da4F)lvStu(cBqjmCSBl9`415-9WY^)Yr zc~_;>txeTDv?6t)?&q$`S7OukqNUEvS=+IVB{}^~dGKXPC6_ZC^>321wmrRaBUH_E zNvh6S*Fy$9k2h@l*}v5CedL?JpO3ulzFYcMCSl%9+jy0z;}fq%{kvDp)Z6FV3`zq@ z49)+~^0+y4O=Oha(BL{#B81U$7vmF9>@ouLBNHT@q%brom)(8u@FkFYZ;S*lgL5tG HS_TFH%+GsM literal 0 HcmV?d00001 diff --git a/layout/reftests/fonts/mark2C.woff b/layout/reftests/fonts/mark2C.woff new file mode 100644 index 0000000000000000000000000000000000000000..d21fd0722c3d69df711808a2576b12a1860f6ac0 GIT binary patch literal 1084 zcmXT-cXMN4WB>vd8wOqw&H4pIVgqh&A-+I$3P3q2AeQl4_u`~~u)Yxk1LG1P-w}wz zLjR{)B^ zD${`Ke1QBaAg(EoT9}`anwSDK&j83b1Y)xf!3(N0fPz3Vpg4mZ5UX(RX6MbwEvW#C zy#VqBKv-0Qp*1Hz8K{oQ0m$b9;|zw7+{6ly`&xi}c_3C`@L;gaOUz9LsyhJ`HwMze z8$Zjk7UUO~FfcIx0jiM(Vy*uh7)&c}B`2gLBrrUhz2~{#vCp?_QXiz%F^VKwWG$S| zyI+Cw~R%W5;GhYF&O{kyaCh*)pP6cfdc|Z&oQb<0@WB8EnpI3&}U!-DuBu- zBtA$;NMc|VIC+9Ws5s#QGbb=`8X1}(^3N0g96E67z=11Ax3o7lE@XEywo5QbNnz?T z+E8e8fI*pAh{L1UH?bh0Agv%R>_`4V0oH50q09`YS~*_<-N4Slpa`TuGzh1F>`X{V zYeA&}GpLpz8+k^+FCb0ulk(F11=oLjJc;zY;$X~Ndrhocww=Bz2t zF*7t~oXI0S)A7(6g@?Xxa(e24LQO|{Sw&f|_OebDm9&hPu|H?>I)9c@Fv|stHW4a{5H&b>_fTO_?A?0ThvkX<2&ao;? zI({O;T+2K5^Z6B;9@PqlPcMqS_EkOn)FWx_@=3FTH{MR2BoQq&JGAv-jMv1Y)7XW? zX5KyK>((b~ezhWT;`**xmG8vD^`fQD%w21k%b9lW#`|U4j2$~V1pnPQe&@~Vof}`r zJlZ&I<`!|z$p&4Ajynv~1#zIXT%$h|j4f|tR$ JmUS%y0{~kbd#L~b literal 0 HcmV?d00001 diff --git a/layout/reftests/fonts/mark2D.woff b/layout/reftests/fonts/mark2D.woff new file mode 100644 index 0000000000000000000000000000000000000000..3d42d6f40c845c3f6303456173f8eef0d6199318 GIT binary patch literal 1084 zcmXT-cXMN4WB>vd8wOqw&H4pIVgqh&A-+I$3P3q2AeQl4_u`~~u)Yxk1LG1P-w}wz z!WdF5lXDXbfMP!&VvJ4<{A}-&%Ssd&7?^B;Vk}^+$W)o0SPWFhA_3%cfbjqS49w{{ zm1#hAK0tmI5Z9DPEzHkIO-uorX8`0I0e&gPE?DOrK)CXyGj3S8^SqrCg zFBg@RxG~M(En|_T#0-Z;4EpCe4*)en_1rpq;DEr`WOp*QOE5@DVd^s4 zP-t|3L77>I!=u%nYa2a=rn&ft`av5lDe(5KaNPDIp=P zAwiPOjZI(!<0pxOHDYY63TK&G6!x9||6kzK|GE`kY;I<35|bMza(WmTE?{zFTf|^| z_yQ|Kmlr!D$S`0W0!b|}w1fB~DF7HcSCVEOJ#gm0xdq!NPISDVCTz`pIC^n!&YJQZ zGecv>nLN@n9S^Nhc7n$)O4hmRh0E=FY8oMNy~T{`*S9*^Jggqvs|!f6JcZ9 zrs`AOpk~C;EW%iLigOyTdYxRtteo}ru_s+x9#q5o{KHfRHwd#Y+hW}?gukK7SEnd|o zTD8J<`-%K{w`V*$T+D7;`fw+A;P!dU-{wy^u;7TG80)ng3z`=6tFoOjG)eZERs8Bm zr>t`F-4!~eXYCg+Q+V5WWQu$A8uO`NrZabLl{Kp4 z&xQE6`aG$bXu!2tBPZuya^}HmG4}s9g};@`W3AaEo_sqX-g)g}K(=oE`=4x6@_Z+Q z(m)bJ^Z&CvZVp`&8D%##xXzTg!f3gN@fj#~8G-qc36f4y7@CyJ?!I^U63D$bMuL~Y Kxt4V;0|Nj@EPt2) literal 0 HcmV?d00001 From 6a3c5ff8549d5904ee6f8a99e7a9b5ba953b3484 Mon Sep 17 00:00:00 2001 From: Jonathan Hao Date: Wed, 14 Oct 2015 15:25:00 +0800 Subject: [PATCH 20/25] Bug 1207964 - Remove workaround from bug 1080461. r=jwwang --HG-- extra : rebase_source : b7955be8bce9aebb82707cbf42d405a3c308fb7e --- dom/media/MediaDecoderStateMachine.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 45cc233d9252..7f1c442a6de8 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -1783,12 +1783,6 @@ int64_t MediaDecoderStateMachine::AudioDecodedUsecs() // already decoded and pushed to the hardware, plus the amount of audio // data waiting to be pushed to the hardware. int64_t pushed = mMediaSink->IsStarted() ? (AudioEndTime() - GetMediaTime()) : 0; - - // Currently for real time streams, AudioQueue().Duration() produce - // wrong values (Bug 1114434), so we use frame counts to calculate duration. - if (IsRealTime()) { - return pushed + FramesToUsecs(AudioQueue().FrameCount(), mInfo.mAudio.mRate).value(); - } return pushed + AudioQueue().Duration(); } From 66c7ddec13275ffd9724575305afcf7de73194ec Mon Sep 17 00:00:00 2001 From: JerryShih Date: Thu, 15 Oct 2015 06:03:00 -0400 Subject: [PATCH 21/25] Bug 1215050 - Make layerscope support TiledPaintedLayer when using HWC. r=mattwoodrow, r=cjku --HG-- extra : rebase_source : 3a606457d9c7cd630b6c9ab38941e2619b03943e --- gfx/layers/LayerScope.cpp | 14 ++++++++++++-- gfx/layers/composite/TiledContentHost.cpp | 21 +++++++++++++++++++++ gfx/layers/composite/TiledContentHost.h | 2 ++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/gfx/layers/LayerScope.cpp b/gfx/layers/LayerScope.cpp index c13385212e61..d0899ceb8bd8 100644 --- a/gfx/layers/LayerScope.cpp +++ b/gfx/layers/LayerScope.cpp @@ -979,7 +979,9 @@ SenderHelper::SendLayer(LayerComposite* aLayer, case Layer::TYPE_COLOR: { EffectChain effect; aLayer->GenEffectChain(effect); - SenderHelper::SendEffectChain(nullptr, effect, aWidth, aHeight); + + LayerScope::DrawBegin(); + LayerScope::DrawEnd(nullptr, effect, aWidth, aHeight); break; } case Layer::TYPE_IMAGE: @@ -995,7 +997,9 @@ SenderHelper::SendLayer(LayerComposite* aLayer, // Generate primary effect (lock and gen) AutoLockCompositableHost lock(compHost); aLayer->GenEffectChain(effect); - SenderHelper::SendEffectChain(compOGL->gl(), effect); + + LayerScope::DrawBegin(); + LayerScope::DrawEnd(compOGL->gl(), effect, aWidth, aHeight); } break; } @@ -1172,6 +1176,12 @@ SenderHelper::SendEffectChain(GLContext* aGLContext, if (!sLayersBufferSendable) return; const Effect* primaryEffect = aEffectChain.mPrimaryEffect; + MOZ_ASSERT(primaryEffect); + + if (!primaryEffect) { + return; + } + switch (primaryEffect->mType) { case EffectTypes::RGB: { const TexturedEffect* texturedEffect = diff --git a/gfx/layers/composite/TiledContentHost.cpp b/gfx/layers/composite/TiledContentHost.cpp index 58a5e1e07016..6b8a54a3eea5 100644 --- a/gfx/layers/composite/TiledContentHost.cpp +++ b/gfx/layers/composite/TiledContentHost.cpp @@ -69,6 +69,27 @@ TiledContentHost::~TiledContentHost() MOZ_COUNT_DTOR(TiledContentHost); } +already_AddRefed +TiledContentHost::GenEffect(const gfx::Filter& aFilter) +{ + // If we can use hwc for this TiledContentHost, it implies that we have exactly + // one high precision tile. Please check TiledContentHost::GetRenderState() for + // all condition. + MOZ_ASSERT(mTiledBuffer.GetTileCount() == 1 && mLowPrecisionTiledBuffer.GetTileCount() == 0); + MOZ_ASSERT(mTiledBuffer.GetTile(0).mTextureHost); + + TileHost& tile = mTiledBuffer.GetTile(0); + if (!tile.mTextureHost->BindTextureSource(tile.mTextureSource)) { + return nullptr; + } + + return CreateTexturedEffect(tile.mTextureSource, + nullptr, + aFilter, + true, + tile.mTextureHost->GetRenderState()); +} + void TiledContentHost::Attach(Layer* aLayer, Compositor* aCompositor, diff --git a/gfx/layers/composite/TiledContentHost.h b/gfx/layers/composite/TiledContentHost.h index f15df1ffdc80..d2080d28c984 100644 --- a/gfx/layers/composite/TiledContentHost.h +++ b/gfx/layers/composite/TiledContentHost.h @@ -211,6 +211,8 @@ public: return LayerRenderState(); } + // Generate effect for layerscope when using hwc. + virtual already_AddRefed GenEffect(const gfx::Filter& aFilter) override; virtual bool UpdateThebes(const ThebesBufferData& aData, const nsIntRegion& aUpdated, From 0eb273bf78dc199769f43ae1b506ee8be545c915 Mon Sep 17 00:00:00 2001 From: Alfredo Yang Date: Fri, 16 Oct 2015 01:02:00 -0400 Subject: [PATCH 22/25] Bug 1215441 - Skip flush before Init() is completed. r=sotaro --HG-- extra : rebase_source : 6eb1535c88637c72ce1945ff773f7de359fb9688 --- dom/media/platforms/gonk/GonkMediaDataDecoder.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dom/media/platforms/gonk/GonkMediaDataDecoder.cpp b/dom/media/platforms/gonk/GonkMediaDataDecoder.cpp index b67dca62fe90..5b59e3292e19 100644 --- a/dom/media/platforms/gonk/GonkMediaDataDecoder.cpp +++ b/dom/media/platforms/gonk/GonkMediaDataDecoder.cpp @@ -103,6 +103,11 @@ GonkDecoderManager::Flush() GMDD_LOG("Decoder is not initialized"); return NS_ERROR_UNEXPECTED; } + + if (!mInitPromise.IsEmpty()) { + return NS_OK; + } + { MutexAutoLock lock(mMutex); mQueuedSamples.Clear(); From 030874110221cff6e8de9fe573b1569174023b82 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Sun, 4 Oct 2015 21:03:26 -0700 Subject: [PATCH 23/25] Bug 1215411 - Define MOZ_FALLTHROUGH annotation to suppress clang's -Wimplicit-fallthrough warnings. r=botond --- mfbt/Attributes.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mfbt/Attributes.h b/mfbt/Attributes.h index 9c17e1ede20a..cb4bef94c61d 100644 --- a/mfbt/Attributes.h +++ b/mfbt/Attributes.h @@ -336,6 +336,35 @@ # define MOZ_WARN_UNUSED_RESULT #endif +/** + * MOZ_FALLTHROUGH is an annotation to suppress compiler warnings about switch + * cases that fall through without a break or return statement. MOZ_FALLTHROUGH + * is only needed on cases that have code: + * + * switch (foo) { + * case 1: // These cases have no code. No fallthrough annotations are needed. + * case 2: + * case 3: + * foo = 4; // This case has code, so a fallthrough annotation is needed: + * MOZ_FALLTHROUGH; + * default: + * return foo; + * } + */ +#if defined(__clang__) && __cplusplus >= 201103L + /* clang's fallthrough annotations are only available starting in C++11. */ +# define MOZ_FALLTHROUGH [[clang::fallthrough]] +#elif defined(_MSC_VER) + /* + * MSVC's __fallthrough annotations are checked by /analyze (Code Analysis): + * https://msdn.microsoft.com/en-us/library/ms235402%28VS.80%29.aspx + */ +# include +# define MOZ_FALLTHROUGH __fallthrough +#else +# define MOZ_FALLTHROUGH /* FALLTHROUGH */ +#endif + #ifdef __cplusplus /* From 9169f6d9ef2aee9ebe1b8d0b2537d61676d37303 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Sat, 17 Oct 2015 22:12:38 -0700 Subject: [PATCH 24/25] Bug 1215902 - Fix clang's -Wimplicit-fallthrough warnings in extensions/cookie. r=jdm extensions/cookie/nsCookiePermission.cpp:207:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels extensions/cookie/nsPermissionManager.cpp:933:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels extensions/cookie/nsPermissionManager.cpp:952:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels extensions/cookie/nsPermissionManager.cpp:979:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels extensions/cookie/nsPermissionManager.cpp:1061:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels extensions/cookie/nsPermissionManager.cpp:1255:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels extensions/cookie/nsPermissionManager.cpp:1353:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels extensions/cookie/nsPermissionManager.cpp:1377:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels --- extensions/cookie/nsCookiePermission.cpp | 1 + extensions/cookie/nsPermissionManager.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/extensions/cookie/nsCookiePermission.cpp b/extensions/cookie/nsCookiePermission.cpp index 86e84b7f2dbb..5b50c58e2143 100644 --- a/extensions/cookie/nsCookiePermission.cpp +++ b/extensions/cookie/nsCookiePermission.cpp @@ -198,6 +198,7 @@ nsCookiePermission::CanSetCookie(nsIURI *aURI, switch (perm) { case nsICookiePermission::ACCESS_SESSION: *aIsSession = true; + MOZ_FALLTHROUGH; case nsICookiePermission::ACCESS_ALLOW: *aResult = true; diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index 1c49f557470f..a8170852e129 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -910,6 +910,7 @@ nsPermissionManager::InitDB(bool aRemoveFile) } // fall through to the next upgrade + MOZ_FALLTHROUGH; // TODO: we want to make default version as version 2 in order to fix bug 784875. case 0: @@ -929,6 +930,7 @@ nsPermissionManager::InitDB(bool aRemoveFile) } // fall through to the next upgrade + MOZ_FALLTHROUGH; // Version 3->4 is the creation of the modificationTime field. case 3: @@ -946,6 +948,7 @@ nsPermissionManager::InitDB(bool aRemoveFile) } // fall through to the next upgrade + MOZ_FALLTHROUGH; // In version 5, host appId, and isInBrowserElement were merged into a // single origin entry @@ -1031,6 +1034,7 @@ nsPermissionManager::InitDB(bool aRemoveFile) } // fall through to the next upgrade + MOZ_FALLTHROUGH; // At this point, the version 5 table has been migrated to a version 6 table // We are guaranteed to have at least one of moz_hosts and moz_perms. If @@ -1228,6 +1232,7 @@ nsPermissionManager::InitDB(bool aRemoveFile) } // fall through to the next upgrade + MOZ_FALLTHROUGH; // The version 7-8 migration is the re-migration of localhost and ip-address // entries due to errors in the previous version 7 migration which caused @@ -1329,6 +1334,7 @@ nsPermissionManager::InitDB(bool aRemoveFile) } // fall through to the next upgrade + MOZ_FALLTHROUGH; // The version 8-9 migration removes the unnecessary backup moz-hosts database contents. // as the data no longer needs to be migrated @@ -1355,6 +1361,9 @@ nsPermissionManager::InitDB(bool aRemoveFile) NS_ENSURE_SUCCESS(rv, rv); } + // fall through to the next upgrade + MOZ_FALLTHROUGH; + // current version. case HOSTS_SCHEMA_VERSION: break; From 7aaa6c74c3c704951d97b12a1561a8f7327f8d1f Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Sat, 17 Oct 2015 22:57:38 -0700 Subject: [PATCH 25/25] Bug 1215892 - Fix clang's -Wimplicit-fallthrough warnings in gfx. r=BenWa gfx/gl/GLBlitHelper.cpp:395:13 [-Wimplicit-fallthrough] unannotated fall-through between switch labels gfx/layers/apz/src/AsyncPanZoomController.cpp:1087:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels gfx/layers/apz/src/AsyncPanZoomController.cpp:1196:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels gfx/layers/apz/src/GestureEventListener.cpp:411:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels gfx/layers/apz/util/APZEventState.cpp:292:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels gfx/layers/apz/util/APZEventState.cpp:295:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels widget/GfxInfoBase.cpp:1015:9 [-Wimplicit-fallthrough] unannotated fall-through between switch labels --- gfx/gl/GLBlitHelper.cpp | 4 +++- gfx/layers/apz/src/AsyncPanZoomController.cpp | 4 ++-- gfx/layers/apz/src/GestureEventListener.cpp | 1 + gfx/layers/apz/util/APZEventState.cpp | 5 ++--- widget/GfxInfoBase.cpp | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gfx/gl/GLBlitHelper.cpp b/gfx/gl/GLBlitHelper.cpp index 1931f2989e2d..350266477789 100644 --- a/gfx/gl/GLBlitHelper.cpp +++ b/gfx/gl/GLBlitHelper.cpp @@ -389,8 +389,10 @@ GLBlitHelper::InitTexQuadProgram(BlitType target) GLint texUnitLoc = mGL->fGetUniformLocation(program, "uTexUnit"); MOZ_ASSERT(texUnitLoc != -1, "uniform uTexUnit not found"); mGL->fUniform1i(texUnitLoc, 0); - break; +#else + MOZ_ASSERT_UNREACHABLE("gralloc not support on non-android"); #endif + break; } case ConvertPlanarYCbCr: { GLint texY = mGL->fGetUniformLocation(program, "uYTexture"); diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index e725cf4bfebf..f7d765c56dbd 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -1183,7 +1183,7 @@ nsEventStatus AsyncPanZoomController::OnTouchStart(const MultiTouchInput& aEvent case WHEEL_SCROLL: case PAN_MOMENTUM: CurrentTouchBlock()->GetOverscrollHandoffChain()->CancelAnimations(ExcludeOverscroll); - // Fall through. + MOZ_FALLTHROUGH; case NOTHING: { mX.StartTouch(point.x, aEvent.mTime); mY.StartTouch(point.y, aEvent.mTime); @@ -1292,7 +1292,7 @@ nsEventStatus AsyncPanZoomController::OnTouchEnd(const MultiTouchInput& aEvent) case FLING: // Should never happen. NS_WARNING("Received impossible touch end in OnTouchEnd."); - // Fall through. + MOZ_FALLTHROUGH; case ANIMATING_ZOOM: case SMOOTH_SCROLL: case NOTHING: diff --git a/gfx/layers/apz/src/GestureEventListener.cpp b/gfx/layers/apz/src/GestureEventListener.cpp index 1088d8cb2241..ede6d75d7b48 100644 --- a/gfx/layers/apz/src/GestureEventListener.cpp +++ b/gfx/layers/apz/src/GestureEventListener.cpp @@ -408,6 +408,7 @@ void GestureEventListener::HandleInputTimeoutLongTap() // just in case MAX_TAP_TIME > ContextMenuDelay cancel MAX_TAP timer // and fall through CancelMaxTapTimeoutTask(); + MOZ_FALLTHROUGH; case GESTURE_FIRST_SINGLE_TOUCH_MAX_TAP_DOWN: { SetState(GESTURE_LONG_TOUCH_DOWN); mAsyncPanZoomController->HandleGestureEvent( diff --git a/gfx/layers/apz/util/APZEventState.cpp b/gfx/layers/apz/util/APZEventState.cpp index d60c8957ce17..dfd939010204 100644 --- a/gfx/layers/apz/util/APZEventState.cpp +++ b/gfx/layers/apz/util/APZEventState.cpp @@ -289,10 +289,10 @@ APZEventState::ProcessTouchEvent(const WidgetTouchEvent& aEvent, mTouchEndCancelled = true; mEndTouchIsClick = false; } - // fall through + MOZ_FALLTHROUGH; case eTouchCancel: mActiveElementManager->HandleTouchEndEvent(mEndTouchIsClick); - // fall through + MOZ_FALLTHROUGH; case eTouchMove: { if (mPendingTouchPreventedResponse) { MOZ_ASSERT(aGuid == mPendingTouchPreventedGuid); @@ -427,4 +427,3 @@ APZEventState::GetWidget() const } // namespace layers } // namespace mozilla - diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index 3c5b0f6fb739..438e6cceaa1c 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -1010,7 +1010,7 @@ GfxInfoBase::EvaluateDownloadedBlacklist(nsTArray& aDriverInfo) } else { RemovePrefForDriverVersion(); } - // FALLTHROUGH + MOZ_FALLTHROUGH; case nsIGfxInfo::FEATURE_BLOCKED_MISMATCHED_VERSION: case nsIGfxInfo::FEATURE_BLOCKED_DEVICE: