Bug 1478448 - (Part 5) Add ChangeManager skeleton to pass tracked style changes to store. r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D3330

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Razvan Caliman 2018-09-17 09:17:15 +00:00
Родитель d5d2274e18
Коммит 4986634d30
4 изменённых файлов: 47 добавлений и 0 удалений

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

@ -0,0 +1,27 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const {
trackChange,
} = require("./actions/changes");
class ChangesManager {
constructor(inspector) {
this.store = inspector.store;
}
track(change) {
this.store.dispatch(trackChange(change));
}
destroy() {
this.store = null;
}
}
module.exports = ChangesManager;

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

@ -11,5 +11,6 @@ DIRS += [
]
DevToolsModules(
'ChangesManager.js',
'ChangesView.js',
)

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

@ -96,6 +96,16 @@ function updateDiff(diff = {}, change = {}) {
const reducers = {
[TRACK_CHANGE](state, { data }) {
const defaults = {
href: "",
selector: "",
tag: null,
add: null,
remove: null
};
data = { ...defaults, ...data };
// Update the state in-place with data about a style change (no deep clone of state).
// TODO: redefine state as a shallow object structure after figuring how to track
// both CSS Declarations and CSS Rules and At-Rules (@media, @keyframes, etc).

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

@ -37,6 +37,8 @@ loader.lazyRequireGetter(this, "clipboardHelper", "devtools/shared/platform/clip
loader.lazyRequireGetter(this, "openContentLink", "devtools/client/shared/link", true);
loader.lazyRequireGetter(this, "getScreenshotFront", "devtools/shared/fronts/screenshot", true);
loader.lazyRequireGetter(this, "saveScreenshot", "devtools/shared/screenshot/save");
loader.lazyRequireGetter(this, "ChangesManager",
"devtools/client/inspector/changes/ChangesManager");
loader.lazyImporter(this, "DeferredTask", "resource://gre/modules/DeferredTask.jsm");
@ -123,6 +125,9 @@ function Inspector(toolbox) {
this.reflowTracker = new ReflowTracker(this._target);
this.styleChangeTracker = new InspectorStyleChangeTracker(this);
if (Services.prefs.getBoolPref(TRACK_CHANGES_ENABLED)) {
this.changesManager = new ChangesManager(this);
}
// Store the URL of the target page prior to navigation in order to ensure
// telemetry counts in the Grid Inspector are not double counted on reload.
@ -1483,6 +1488,10 @@ Inspector.prototype = {
this.reflowTracker.destroy();
this.styleChangeTracker.destroy();
if (this.changesManager) {
this.changesManager.destroy();
}
this._is3PaneModeChromeEnabled = null;
this._is3PaneModeEnabled = null;
this._notificationBox = null;