From 649f28dd884671b6d9cd8654107a32b144bb6802 Mon Sep 17 00:00:00 2001 From: Gabriel Luong Date: Sat, 11 Feb 2017 00:05:50 -0500 Subject: [PATCH] Bug 1336198 - Part 1: Redux store should be initialized at the Inspector level. r=jdescottes --HG-- rename : devtools/client/inspector/layout/store.js => devtools/client/inspector/store.js --- devtools/client/inspector/inspector.js | 18 ++++++++++-------- devtools/client/inspector/layout/layout.js | 6 ++---- devtools/client/inspector/layout/moz.build | 1 - .../client/inspector/layout/reducers/index.js | 9 --------- .../client/inspector/layout/reducers/moz.build | 1 - devtools/client/inspector/moz.build | 6 ++++-- devtools/client/inspector/reducers.js | 12 ++++++++++++ .../client/inspector/{layout => }/store.js | 2 +- 8 files changed, 29 insertions(+), 26 deletions(-) delete mode 100644 devtools/client/inspector/layout/reducers/index.js create mode 100644 devtools/client/inspector/reducers.js rename devtools/client/inspector/{layout => }/store.js (92%) diff --git a/devtools/client/inspector/inspector.js b/devtools/client/inspector/inspector.js index 44a8190f78c5..068eeb526990 100644 --- a/devtools/client/inspector/inspector.js +++ b/devtools/client/inspector/inspector.js @@ -34,6 +34,8 @@ const {CommandUtils} = require("devtools/client/shared/developer-toolbar"); const {ViewHelpers} = require("devtools/client/shared/widgets/view-helpers"); const clipboardHelper = require("devtools/shared/platform/clipboard"); +const Store = require("devtools/client/inspector/store"); + const {LocalizationHelper, localizeMarkup} = require("devtools/shared/l10n"); const INSPECTOR_L10N = new LocalizationHelper("devtools/client/locales/inspector.properties"); @@ -92,6 +94,7 @@ function Inspector(toolbox) { this.panelWin.inspector = this; this.highlighters = new HighlightersOverlay(this); + this.store = Store(); this.telemetry = new Telemetry(); this.nodeMenuTriggerInfo = null; @@ -910,7 +913,6 @@ Inspector.prototype = { this.cancelUpdate(); this.target.off("will-navigate", this._onBeforeNavigate); - this.target.off("thread-paused", this.updateDebuggerPausedWarning); this.target.off("thread-resumed", this.updateDebuggerPausedWarning); this._toolbox.off("select", this.updateDebuggerPausedWarning); @@ -942,8 +944,6 @@ Inspector.prototype = { this.teardownSplitter(); - this.sidebar = null; - this.teardownToolbar(); this.breadcrumbs.destroy(); this.selection.off("new-node-front", this.onNewSelection); @@ -951,12 +951,14 @@ Inspector.prototype = { let markupDestroyer = this._destroyMarkup(); - this.panelWin.inspector = null; - this.target = null; - this.panelDoc = null; - this.panelWin = null; - this.breadcrumbs = null; this._toolbox = null; + this.breadcrumbs = null; + this.panelDoc = null; + this.panelWin.inspector = null; + this.panelWin = null; + this.sidebar = null; + this.store = null; + this.target = null; this.highlighters.destroy(); this.highlighters = null; diff --git a/devtools/client/inspector/layout/layout.js b/devtools/client/inspector/layout/layout.js index 768b3d89dad5..fa2e96087c24 100644 --- a/devtools/client/inspector/layout/layout.js +++ b/devtools/client/inspector/layout/layout.js @@ -26,7 +26,6 @@ const { } = require("./actions/highlighter-settings"); const App = createFactory(require("./components/App")); -const Store = require("./store"); const EditingSession = require("./utils/editing-session"); @@ -42,7 +41,7 @@ function LayoutView(inspector, window) { this.document = window.document; this.highlighters = inspector.highlighters; this.inspector = inspector; - this.store = null; + this.store = inspector.store; this.walker = this.inspector.walker; this.updateBoxModel = this.updateBoxModel.bind(this); @@ -72,7 +71,6 @@ LayoutView.prototype = { } this.layoutInspector = yield this.inspector.walker.getLayoutInspector(); - let store = this.store = Store(); this.loadHighlighterSettings(); @@ -232,7 +230,7 @@ LayoutView.prototype = { }); let provider = createElement(Provider, { - store, + store: this.store, id: "layoutview", title: INSPECTOR_L10N.getStr("inspector.sidebar.layoutViewTitle2"), key: "layoutview", diff --git a/devtools/client/inspector/layout/moz.build b/devtools/client/inspector/layout/moz.build index 8575deedfb74..4d425f932182 100644 --- a/devtools/client/inspector/layout/moz.build +++ b/devtools/client/inspector/layout/moz.build @@ -13,6 +13,5 @@ DIRS += [ DevToolsModules( 'layout.js', - 'store.js', 'types.js', ) diff --git a/devtools/client/inspector/layout/reducers/index.js b/devtools/client/inspector/layout/reducers/index.js deleted file mode 100644 index 4ab7d2eb949d..000000000000 --- a/devtools/client/inspector/layout/reducers/index.js +++ /dev/null @@ -1,9 +0,0 @@ -/* 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"; - -exports.boxModel = require("./box-model"); -exports.grids = require("./grids"); -exports.highlighterSettings = require("./highlighter-settings"); diff --git a/devtools/client/inspector/layout/reducers/moz.build b/devtools/client/inspector/layout/reducers/moz.build index 5e157a4bd728..50e631af17b1 100644 --- a/devtools/client/inspector/layout/reducers/moz.build +++ b/devtools/client/inspector/layout/reducers/moz.build @@ -8,5 +8,4 @@ DevToolsModules( 'box-model.js', 'grids.js', 'highlighter-settings.js', - 'index.js', ) diff --git a/devtools/client/inspector/moz.build b/devtools/client/inspector/moz.build index 9b35cf590f22..1c5f3e58dd4c 100644 --- a/devtools/client/inspector/moz.build +++ b/devtools/client/inspector/moz.build @@ -17,10 +17,12 @@ DevToolsModules( 'inspector-commands.js', 'inspector-search.js', 'panel.js', + 'reducers.js', + 'store.js', 'toolsidebar.js', ) BROWSER_CHROME_MANIFESTS += ['test/browser.ini'] -with Files('**'): - BUG_COMPONENT = ('Firefox', 'Developer Tools: Inspector') +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Developer Tools: Inspector') diff --git a/devtools/client/inspector/reducers.js b/devtools/client/inspector/reducers.js new file mode 100644 index 000000000000..6c09e49c49e4 --- /dev/null +++ b/devtools/client/inspector/reducers.js @@ -0,0 +1,12 @@ +/* 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"; + +// This file exposes the Redux reducers of the box model, grid and grid highlighter +// settings. + +exports.boxModel = require("devtools/client/inspector/layout/reducers/box-model"); +exports.grids = require("devtools/client/inspector/layout/reducers/grids"); +exports.highlighterSettings = require("devtools/client/inspector/layout/reducers/highlighter-settings"); diff --git a/devtools/client/inspector/layout/store.js b/devtools/client/inspector/store.js similarity index 92% rename from devtools/client/inspector/layout/store.js rename to devtools/client/inspector/store.js index 5069dda2649e..2b406e5781aa 100644 --- a/devtools/client/inspector/layout/store.js +++ b/devtools/client/inspector/store.js @@ -6,7 +6,7 @@ const { combineReducers } = require("devtools/client/shared/vendor/redux"); const createStore = require("devtools/client/shared/redux/create-store"); -const reducers = require("./reducers/index"); +const reducers = require("devtools/client/inspector/reducers"); const flags = require("devtools/shared/flags"); module.exports = function () {