Bug 1468754 Part 2: Make the ChangesActor be managed by the InspectorActor. draft
authorBrad Werth <bwerth@mozilla.com>
Tue, 19 Jun 2018 16:21:35 -0700
changeset 826138 20df5c7ae981254f1a424d5953db29c521e28927
parent 826137 5f698b0fc78d58db1cbff446b0b2a718cbf4188a
child 826139 5623c0182a5e5142d51dede4ee1b1e27d9881d91
push id118245
push userbwerth@mozilla.com
push dateFri, 03 Aug 2018 00:03:09 +0000
bugs1468754
milestone63.0a1
Bug 1468754 Part 2: Make the ChangesActor be managed by the InspectorActor. MozReview-Commit-ID: D71oBN8MSgU
devtools/client/inspector/inspector.js
devtools/server/actors/inspector/inspector.js
devtools/shared/fronts/inspector.js
devtools/shared/specs/inspector.js
--- a/devtools/client/inspector/inspector.js
+++ b/devtools/client/inspector/inspector.js
@@ -354,16 +354,22 @@ Inspector.prototype = {
   },
 
   _getPageStyle: function() {
     return this.inspector.getPageStyle().then(pageStyle => {
       this.pageStyle = pageStyle;
     }, this._handleRejectionIfNotDestroyed);
   },
 
+  _getChanges: function() {
+    return this.inspector.getChanges().then(changes => {
+      this.changes = changes;
+    }, this._handleRejectionIfNotDestroyed);
+  },
+
   /**
    * Return a promise that will resolve to the default node for selection.
    */
   _getDefaultNodeForSelection: function() {
     if (this._defaultNode) {
       return this._defaultNode;
     }
     const walker = this.walker;
@@ -1427,16 +1433,18 @@ Inspector.prototype = {
       return this._panelDestroyer;
     }
 
     if (this.walker) {
       this.walker.off("new-root", this.onNewRoot);
       this.pageStyle = null;
     }
 
+    this.changes = null;
+
     this.cancelUpdate();
 
     this.selection.off("new-node-front", this.onNewSelection);
     this.selection.off("detached-front", this.onDetached);
     this.sidebar.off("select", this.onSidebarSelect);
     this.target.off("will-navigate", this._onBeforeNavigate);
     this.target.off("thread-paused", this._updateDebuggerPausedWarning);
     this.target.off("thread-resumed", this._updateDebuggerPausedWarning);
--- a/devtools/server/actors/inspector/inspector.js
+++ b/devtools/server/actors/inspector/inspector.js
@@ -56,16 +56,17 @@ const {LongStringActor} = require("devto
 const defer = require("devtools/shared/defer");
 
 const {inspectorSpec} = require("devtools/shared/specs/inspector");
 
 loader.lazyRequireGetter(this, "InspectorActorUtils", "devtools/server/actors/inspector/utils");
 loader.lazyRequireGetter(this, "WalkerActor", "devtools/server/actors/inspector/walker", true);
 loader.lazyRequireGetter(this, "EyeDropper", "devtools/server/actors/highlighters/eye-dropper", true);
 loader.lazyRequireGetter(this, "PageStyleActor", "devtools/server/actors/styles", true);
+loader.lazyRequireGetter(this, "ChangesActor", "devtools/server/actors/changes", true);
 loader.lazyRequireGetter(this, "HighlighterActor", "devtools/server/actors/highlighters", true);
 loader.lazyRequireGetter(this, "CustomHighlighterActor", "devtools/server/actors/highlighters", true);
 loader.lazyRequireGetter(this, "isTypeRegistered", "devtools/server/actors/highlighters", true);
 loader.lazyRequireGetter(this, "HighlighterEnvironment", "devtools/server/actors/highlighters", true);
 
 const SVG_NS = "http://www.w3.org/2000/svg";
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
@@ -85,16 +86,17 @@ exports.InspectorActor = protocol.ActorC
 
   destroy: function() {
     protocol.Actor.prototype.destroy.call(this);
 
     this.destroyEyeDropper();
 
     this._highlighterPromise = null;
     this._pageStylePromise = null;
+    this._changesPromise = null;
     this._walkerPromise = null;
     this.walker = null;
     this.targetActor = null;
   },
 
   get window() {
     return this.targetActor.window;
   },
@@ -111,16 +113,17 @@ exports.InspectorActor = protocol.ActorC
     const domReady = () => {
       const targetActor = this.targetActor;
       window.removeEventListener("DOMContentLoaded", domReady, true);
       this.walker = WalkerActor(this.conn, targetActor, options);
       this.manage(this.walker);
       this.walker.once("destroyed", () => {
         this._walkerPromise = null;
         this._pageStylePromise = null;
+        this._changesPromise = null;
       });
       deferred.resolve(this.walker);
     };
 
     if (window.document.readyState === "loading") {
       window.addEventListener("DOMContentLoaded", domReady, true);
     } else {
       domReady();
@@ -137,16 +140,28 @@ exports.InspectorActor = protocol.ActorC
     this._pageStylePromise = this.getWalker().then(walker => {
       const pageStyle = PageStyleActor(this);
       this.manage(pageStyle);
       return pageStyle;
     });
     return this._pageStylePromise;
   },
 
+  getChanges: function() {
+    if (this._changesPromise) {
+      return this._changesPromise;
+    }
+
+    const changes = new ChangesActor(this);
+    this.manage(changes);
+
+    this._changesPromise = Promise.resolve(changes);
+    return this._changesPromise;
+  },
+
   /**
    * The most used highlighter actor is the HighlighterActor which can be
    * conveniently retrieved by this method.
    * The same instance will always be returned by this method when called
    * several times.
    * The highlighter actor returned here is used to highlighter elements's
    * box-models from the markup-view, box model, console, debugger, ... as
    * well as select elements with the pointer (pick).
--- a/devtools/shared/fronts/inspector.js
+++ b/devtools/shared/fronts/inspector.js
@@ -493,16 +493,24 @@ var InspectorFront = FrontClassWithSpec(
       return this.getWalker().then(() => {
         return pageStyle;
       });
     });
   }, {
     impl: "_getPageStyle"
   }),
 
+  getChanges: custom(function() {
+    return this._getChanges().then(changes => {
+      return changes;
+    });
+  }, {
+    impl: "_getChanges"
+  }),
+
   pickColorFromPage: custom(async function(toolbox, options) {
     if (toolbox) {
       // If the eyedropper was already started using the gcli command, hide it so we don't
       // end up with 2 instances of the eyedropper on the page.
       CommandUtils.executeOnTarget(toolbox.target, "eyedropper --hide");
     }
 
     await this._pickColorFromPage(options);
--- a/devtools/shared/specs/inspector.js
+++ b/devtools/shared/specs/inspector.js
@@ -366,16 +366,22 @@ const inspectorSpec = generateActorSpec(
       }
     },
     getPageStyle: {
       request: {},
       response: {
         pageStyle: RetVal("pagestyle")
       }
     },
+    getChanges: {
+      request: {},
+      response: {
+        changes: RetVal("changes")
+      }
+    },
     getHighlighter: {
       request: {
         autohide: Arg(0, "boolean")
       },
       response: {
         highligter: RetVal("highlighter")
       }
     },