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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Razvan Caliman 2018-10-17 18:10:01 +00:00
Родитель 3e017e39de
Коммит 4d87a7742b
1 изменённых файлов: 2 добавлений и 4 удалений

Просмотреть файл

@ -97,10 +97,8 @@ const INSET_POINT_TYPES = ["top", "right", "bottom", "left"];
* 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) {
EventEmitter.decorate(this);
this.inspector = inspector;
@ -111,7 +109,7 @@ function CssRuleView(inspector, document, store, pageStyle) {
// 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;