Bug 1464801 - Assign writer methods to each axis defined in font-variation-settings during editor setup. r=pbro
authorRazvan Caliman <rcaliman@mozilla.com>
Wed, 30 May 2018 00:13:00 +0200
changeset 474655 42cb57f4d43a886640980df5d7476d4f222be02b
parent 474654 a8d1c965c25ece82ae277592d5cfb9d2a9c45341
child 474656 032953979332b61c8fe2507aea9cae2fda417371
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1464801
milestone62.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 1464801 - Assign writer methods to each axis defined in font-variation-settings during editor setup. r=pbro MozReview-Commit-ID: 2L3etSyDBPR
devtools/client/inspector/fonts/fonts.js
--- a/devtools/client/inspector/fonts/fonts.js
+++ b/devtools/client/inspector/fonts/fonts.js
@@ -17,16 +17,17 @@ const { ELEMENT_STYLE } = require("devto
 
 const FontsApp = createFactory(require("./components/FontsApp"));
 
 const { LocalizationHelper } = require("devtools/shared/l10n");
 const INSPECTOR_L10N =
   new LocalizationHelper("devtools/client/locales/inspector.properties");
 
 const { getStr } = require("./utils/l10n");
+const { parseFontVariationAxes } = require("./utils/font-utils");
 const { updateFonts } = require("./actions/fonts");
 const {
   applyInstance,
   resetFontEditor,
   updateAxis,
   updateCustomInstance,
   updateFontEditor,
   updateFontProperty,
@@ -575,16 +576,22 @@ class FontInspector {
       properties["font-family"].split(",").map(font => font.replace(/\"+/g, "").trim());
 
     // Mark available fonts as used if their names appears in the font-family declaration.
     // TODO: sort used fonts in order of font-family declaration.
     for (let font of fonts) {
       font.used = declaredFontNames.includes(font.CSSFamilyName);
     }
 
+    // Assign writer methods to each axis defined in font-variation-settings.
+    const axes = parseFontVariationAxes(properties["font-variation-settings"]);
+    Object.keys(axes).map(axis => {
+      this.writers.set(axis, this.getWriterForAxis(axis));
+    });
+
     // Update the font editor state only if property values differ from the ones in store.
     // This can happen when a user makes manual changes in the Rule view.
     if (JSON.stringify(properties) !== JSON.stringify(fontEditor.properties)) {
       this.store.dispatch(updateFontEditor(fonts, properties));
     }
   }
 
   /**