Bug 1488419 - Re-attach listener for Rule view change after writing new value. r=gl a=pascalc
authorRazvan Caliman <rcaliman@mozilla.com>
Tue, 04 Sep 2018 16:21:20 +0000
changeset 492381 b359fee9b67a943524b8a52b3b1dd253d2bb572a
parent 492380 a14dab7cea37796574693819b27e4f7936388dfd
child 492382 8ff3d813035140ecf3ff45269183b3242d69ea1d
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl, pascalc
bugs1488419
milestone63.0
Bug 1488419 - Re-attach listener for Rule view change after writing new value. r=gl a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D4931
devtools/client/inspector/fonts/fonts.js
--- a/devtools/client/inspector/fonts/fonts.js
+++ b/devtools/client/inspector/fonts/fonts.js
@@ -80,17 +80,17 @@ class FontInspector {
     this.writers = new Map();
 
     this.snapshotChanges = debounce(this.snapshotChanges, 100, this);
     this.syncChanges = debounce(this.syncChanges, 100, this);
     this.onInstanceChange = this.onInstanceChange.bind(this);
     this.onNewNode = this.onNewNode.bind(this);
     this.onPreviewTextChange = debounce(this.onPreviewTextChange, 100, this);
     this.onPropertyChange = this.onPropertyChange.bind(this);
-    this.onRulePropertyUpdated = debounce(this.onRulePropertyUpdated, 100, this);
+    this.onRulePropertyUpdated = debounce(this.onRulePropertyUpdated, 300, this);
     this.onToggleFontHighlight = this.onToggleFontHighlight.bind(this);
     this.onThemeChanged = this.onThemeChanged.bind(this);
     this.update = this.update.bind(this);
     this.updateFontVariationSettings = this.updateFontVariationSettings.bind(this);
 
     this.init();
   }
 
@@ -593,32 +593,33 @@ class FontInspector {
    * on the page circumventing direct TextProperty.setValue() which triggers expensive DOM
    * operations in TextPropertyEditor.update().
    *
    * @param  {String} name
    *         CSS property name
    * @param  {String} value
    *         CSS property value
    */
-  syncChanges(name, value) {
+  async syncChanges(name, value) {
     const textProperty = this.getTextProperty(name, value);
     if (textProperty) {
-      // This method may be called after the connection to the page style actor is closed.
-      // For example, during teardown of automated tests. Here, we catch any failure that
-      // may occur because of that. We're not interested in handling the error.
-      textProperty.setValue(value).catch(error => {
+      try {
+        await textProperty.setValue(value, "", true);
+        this.ruleView.on("property-value-updated", this.onRulePropertyUpdated);
+      } catch (error) {
+        // Because setValue() does an asynchronous call to the server, there is a chance
+        // the font editor was destroyed while we were waiting. If that happened, just
+        // bail out silently.
         if (!this.document) {
           return;
         }
 
         throw error;
-      });
+      }
     }
-
-    this.ruleView.on("property-value-updated", this.onRulePropertyUpdated);
   }
 
   /**
    * Handler for changes of a font axis value coming from the FontEditor.
    *
    * @param  {String} tag
    *         Tag name of the font axis.
    * @param  {String} value