Bug 1436997 - When variation-font support is enabled, accept new CSS Fonts 4 format-hint strings for variation fonts. r=jwatt
authorJonathan Kew <jkew@mozilla.com>
Thu, 15 Feb 2018 10:56:42 +0000
changeset 403966 12b89457c62313feacba9ed2f0cd55af8dd58a36
parent 403965 99495614cba7396c358b78b3e50aea1b38937c59
child 403967 4697cdd9969f81a4da170f6b89ecbe549b06f6ca
push id33447
push usernerli@mozilla.com
push dateThu, 15 Feb 2018 19:29:41 +0000
treeherdermozilla-central@ee717948a600 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1436997
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1436997 - When variation-font support is enabled, accept new CSS Fonts 4 format-hint strings for variation fonts. r=jwatt
gfx/thebes/gfxUserFontSet.h
layout/inspector/InspectorFontFace.cpp
layout/style/FontFaceSet.cpp
--- a/gfx/thebes/gfxUserFontSet.h
+++ b/gfx/thebes/gfxUserFontSet.h
@@ -192,24 +192,33 @@ public:
         FLAG_FORMAT_OPENTYPE       = 1 << 1,
         FLAG_FORMAT_TRUETYPE       = 1 << 2,
         FLAG_FORMAT_TRUETYPE_AAT   = 1 << 3,
         FLAG_FORMAT_EOT            = 1 << 4,
         FLAG_FORMAT_SVG            = 1 << 5,
         FLAG_FORMAT_WOFF           = 1 << 6,
         FLAG_FORMAT_WOFF2          = 1 << 7,
 
+        FLAG_FORMAT_OPENTYPE_VARIATIONS = 1 << 8,
+        FLAG_FORMAT_TRUETYPE_VARIATIONS = 1 << 9,
+        FLAG_FORMAT_WOFF_VARIATIONS     = 1 << 10,
+        FLAG_FORMAT_WOFF2_VARIATIONS    = 1 << 11,
+
         // the common formats that we support everywhere
         FLAG_FORMATS_COMMON        = FLAG_FORMAT_OPENTYPE |
                                      FLAG_FORMAT_TRUETYPE |
                                      FLAG_FORMAT_WOFF     |
-                                     FLAG_FORMAT_WOFF2,
+                                     FLAG_FORMAT_WOFF2    |
+                                     FLAG_FORMAT_OPENTYPE_VARIATIONS |
+                                     FLAG_FORMAT_TRUETYPE_VARIATIONS |
+                                     FLAG_FORMAT_WOFF_VARIATIONS     |
+                                     FLAG_FORMAT_WOFF2_VARIATIONS,
 
         // mask of all unused bits, update when adding new formats
-        FLAG_FORMAT_NOT_USED       = ~((1 << 8)-1)
+        FLAG_FORMAT_NOT_USED       = ~((1 << 12)-1)
     };
 
 
     // creates a font face without adding it to a particular family
     // weight - [100, 900] (multiples of 100)
     // stretch = [NS_FONT_STRETCH_ULTRA_CONDENSED, NS_FONT_STRETCH_ULTRA_EXPANDED]
     // italic style = constants in gfxFontConstants.h, e.g. NS_FONT_STYLE_NORMAL
     // language override = result of calling nsRuleNode::ParseFontLanguageOverride
--- a/layout/inspector/InspectorFontFace.cpp
+++ b/layout/inspector/InspectorFontFace.cpp
@@ -143,16 +143,28 @@ InspectorFontFace::GetFormat(nsAString& 
       AppendToFormat(aFormat, "svg");
     }
     if (formatFlags & gfxUserFontSet::FLAG_FORMAT_WOFF) {
       AppendToFormat(aFormat, "woff");
     }
     if (formatFlags & gfxUserFontSet::FLAG_FORMAT_WOFF2) {
       AppendToFormat(aFormat, "woff2");
     }
+    if (formatFlags & gfxUserFontSet::FLAG_FORMAT_OPENTYPE_VARIATIONS) {
+      AppendToFormat(aFormat, "opentype-variations");
+    }
+    if (formatFlags & gfxUserFontSet::FLAG_FORMAT_TRUETYPE_VARIATIONS) {
+      AppendToFormat(aFormat, "truetype-variations");
+    }
+    if (formatFlags & gfxUserFontSet::FLAG_FORMAT_WOFF_VARIATIONS) {
+      AppendToFormat(aFormat, "woff-variations");
+    }
+    if (formatFlags & gfxUserFontSet::FLAG_FORMAT_WOFF2_VARIATIONS) {
+      AppendToFormat(aFormat, "woff2-variations");
+    }
   }
 }
 
 void
 InspectorFontFace::GetMetadata(nsAString& aMetadata)
 {
   aMetadata.Truncate();
   if (mFontEntry->IsUserFont() && !mFontEntry->IsLocalUserFont()) {
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -50,16 +50,17 @@
 #include "nsLayoutUtils.h"
 #include "nsPresContext.h"
 #include "nsPrintfCString.h"
 #ifdef MOZ_OLD_STYLE
 #include "nsStyleSet.h"
 #endif
 #include "nsUTF8Utils.h"
 #include "nsDOMNavigationTiming.h"
+#include "StylePrefs.h"
 
 using namespace mozilla;
 using namespace mozilla::css;
 using namespace mozilla::dom;
 
 #define LOG(args) MOZ_LOG(gfxUserFontSet::GetUserFontsLog(), mozilla::LogLevel::Debug, args)
 #define LOG_ENABLED() MOZ_LOG_TEST(gfxUserFontSet::GetUserFontsLog(), \
                                   LogLevel::Debug)
@@ -1203,16 +1204,29 @@ FontFaceSet::FindOrCreateUserFontEntryFr
             } else if (valueString.LowerCaseEqualsASCII("truetype")) {
               face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_TRUETYPE;
             } else if (valueString.LowerCaseEqualsASCII("truetype-aat")) {
               face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_TRUETYPE_AAT;
             } else if (valueString.LowerCaseEqualsASCII("embedded-opentype")) {
               face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_EOT;
             } else if (valueString.LowerCaseEqualsASCII("svg")) {
               face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_SVG;
+            } else if (StylePrefs::sFontVariationsEnabled &&
+                       valueString.LowerCaseEqualsASCII("woff-variations")) {
+              face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_WOFF_VARIATIONS;
+            } else if (StylePrefs::sFontVariationsEnabled &&
+                       Preferences::GetBool(GFX_PREF_WOFF2_ENABLED) &&
+                       valueString.LowerCaseEqualsASCII("woff2-variations")) {
+              face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_WOFF2_VARIATIONS;
+            } else if (StylePrefs::sFontVariationsEnabled &&
+                       valueString.LowerCaseEqualsASCII("opentype-variations")) {
+              face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_OPENTYPE_VARIATIONS;
+            } else if (StylePrefs::sFontVariationsEnabled &&
+                       valueString.LowerCaseEqualsASCII("truetype-variations")) {
+              face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_TRUETYPE_VARIATIONS;
             } else {
               // unknown format specified, mark to distinguish from the
               // case where no format hints are specified
               face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_UNKNOWN;
             }
             i++;
           }
           if (!face->mURI) {