Bug 1842197 - [devtools] Limit reads of devtools.inspector.ruleview.inline-compatibility-warning.enabled. r=devtools-reviewers,ochameau, a=pascalc

We already have a pref observer for the pref,
so we can store the pref value on the RuleView
instance and check this property instead of
using Services.prefs.

Differential Revision: https://phabricator.services.mozilla.com/D183001
This commit is contained in:
Nicolas Chevobbe 2023-07-10 13:27:55 +00:00
parent 8add6a89b0
commit b34f339376
2 changed files with 7 additions and 6 deletions

View File

@ -243,6 +243,8 @@ function CssRuleView(inspector, document, store) {
this._handleDefaultColorUnitPrefChange
);
this._prefObserver.on(PREF_DRAGGABLE, this._handleDraggablePrefChange);
// Initialize value of this.draggablePropertiesEnabled
this._handleDraggablePrefChange();
this.pseudoClassCheckboxes = this._createPseudoClassCheckboxes();
this.showUserAgentStyles = Services.prefs.getBoolPref(PREF_UA_STYLES);
@ -725,6 +727,10 @@ CssRuleView.prototype = {
},
_handleDraggablePrefChange() {
this.draggablePropertiesEnabled = Services.prefs.getBoolPref(
PREF_DRAGGABLE,
false
);
// This event is consumed by text-property-editor instances in order to
// update their draggable behavior. Preferences observer are costly, so
// we are forwarding the preference update via the EventEmitter.

View File

@ -1387,12 +1387,7 @@ TextPropertyEditor.prototype = {
*/
_isDraggableProperty(textProperty) {
// Check if the feature is explicitly disabled.
if (
!Services.prefs.getBoolPref(
"devtools.inspector.draggable_properties",
false
)
) {
if (!this.ruleView.draggablePropertiesEnabled) {
return false;
}
// temporary way of fixing the bug when editing inline styles