Bug 1497950 - Ensure CSSRuleView has immediate access to PageStyleFront from inspector; r=gl
authorRazvan Caliman <rcaliman@mozilla.com>
Wed, 17 Oct 2018 18:10:01 +0000
changeset 490236 32670a4721d4dac1a14315b16db5847a20749027
parent 490235 b82c3a7696f945a86d775911d22854481ef4a305
child 490237 d3dc7831efa89c4a464ba2aeb4252ce984185cfb
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
Bug 1497950 - Ensure CSSRuleView has immediate access to PageStyleFront from inspector; r=gl The current iteration of the Fonts panel requires an instance of the Rules view in order to get access to the element's rules. In 2-pane mode, when the Fonts panel is the default (last used panel), the Rules view is not yet instantiated. To guard against this, the Fonts panel makes a call to ensure an instance of the Rules view is created (and with it a CSSRuleView object). For some reason, the pageStyle wasn't immediately assigned to the CSSRuleView in the constructor. The constructor signature shows that pageStyle can be passed in as a param, but this never happens. There's only one usage of `new CSSRuleView()`. The pageStyle exist on the inspector instance passed in to the CSSRuleView. This patch ensures that the CSSRuleView makes use of the PageStyleFront instance from the inspector and removes the unused param from the constructor. Perhaps it's better for the Fonts panel to manage its own ElementStyle instance to get access to the element's selected rules. But in the interest of time, since the merge date is soon, I'd rather have this fix in quikcly now and keep the dependency to a Rules view instance with the promise to revisit the Fonts panel architecture and remove this dependency during the Firefox 65 Nightly cycle. Differential Revision: https://phabricator.services.mozilla.com/D9002
--- a/devtools/client/inspector/rules/rules.js
+++ b/devtools/client/inspector/rules/rules.js
@@ -92,31 +92,29 @@ const INSET_POINT_TYPES = ["top", "right
  * @param {Inspector} inspector
  *        Inspector toolbox panel
  * @param {Document} document
  *        The document that will contain the rule view.
  * @param {Object} store
  *        The CSS rule view can use this object to store metadata
  *        that might outlast the rule view, particularly the current
  *        set of disabled properties.
- * @param {PageStyleFront} pageStyle
- *        The PageStyleFront for communicating with the remote server.
-function CssRuleView(inspector, document, store, pageStyle) {
+function CssRuleView(inspector, document, store) {
   this.inspector = inspector;
   this.cssProperties = inspector.cssProperties;
   this.styleDocument = document;
   this.styleWindow = this.styleDocument.defaultView;
   this.store = store || {};
   // References to rules marked by various editors where they intend to write changes.
   // @see selectRule(), unselectRule()
   this.selectedRules = new Map();
-  this.pageStyle = pageStyle;
+  this.pageStyle = inspector.pageStyle;
   // Allow tests to override debouncing behavior, as this can cause intermittents.
   this.debounce = debounce;
   this._outputParser = new OutputParser(document, this.cssProperties);
   this._onAddRule = this._onAddRule.bind(this);
   this._onContextMenu = this._onContextMenu.bind(this);