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
--- 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