Bug 1464801 - Assign writer methods to each axis defined in font-variation-settings during editor setup. r=pbro draft
authorRazvan Caliman <rcaliman@mozilla.com>
Wed, 30 May 2018 00:13:00 +0200
changeset 801217 658263e639f4bc6336b932ddd907b6fa7c8c65f6
parent 801216 4ede6a26a548909b8c51fe21e05fae48af488c68
push id111604
push userbmo:rcaliman@mozilla.com
push dateTue, 29 May 2018 22:15:00 +0000
reviewerspbro
bugs1464801
milestone62.0a1
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));
     }
   }
 
   /**