Bug 888484 - Save the default inspection node. r=paul
authorDave Camp <dcamp@mozilla.com>
Mon, 17 Jun 2013 06:52:54 -0700
changeset 151602 bf73e10f5e54f9c424a0899b3032e11a6a65d10a
parent 151601 89e4e5c1581957b38d50ba323562a22b33f31287
child 151603 eaabf1f668ff0f2e3a3030668bf5a4b254ebaf45
child 151605 bc59f7e483c5e3404b33a8b83b8506908e1edf40
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaul
bugs888484
milestone25.0a1
first release with
nightly linux32
bf73e10f5e54 / 25.0a1 / 20130720030214 / files
nightly linux64
bf73e10f5e54 / 25.0a1 / 20130720030214 / files
nightly mac
bf73e10f5e54 / 25.0a1 / 20130720030214 / files
nightly win32
bf73e10f5e54 / 25.0a1 / 20130720030214 / files
nightly win64
bf73e10f5e54 / 25.0a1 / 20130720030214 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 888484 - Save the default inspection node. r=paul
browser/devtools/inspector/inspector-panel.js
--- a/browser/devtools/inspector/inspector-panel.js
+++ b/browser/devtools/inspector/inspector-panel.js
@@ -152,24 +152,34 @@ InspectorPanel.prototype = {
 
     return deferred.promise;
   },
 
   /**
    * Return a promise that will resolve to the default node for selection.
    */
   _getDefaultNodeForSelection : function() {
+    if (this._defaultNode) {
+      return this._defaultNode;
+    }
+    let walker = this.walker;
     // if available set body node as default selected node
     // else set documentElement
-    return this.walker.querySelector(this.walker.rootNode, "body").then(front => {
+    return walker.querySelector(this.walker.rootNode, "body").then(front => {
       if (front) {
         return front;
       }
       return this.walker.documentElement(this.walker.rootNode);
-    });
+    }).then(node => {
+      if (walker !== this.walker) {
+        promise.reject(null);
+      }
+      this._defaultNode = node;
+      return node;
+    })
   },
 
   /**
    * Selection object (read only)
    */
   get selection() {
     return this._selection;
   },
@@ -271,16 +281,17 @@ InspectorPanel.prototype = {
 
   /**
    * Reset the inspector on navigate away.
    */
   onNavigatedAway: function InspectorPanel_onNavigatedAway(event, payload) {
     let newWindow = payload._navPayload || payload;
     this.walker.release().then(null, console.error);
     this.walker = null;
+    this._defaultNode = null;
     this.selection.setNodeFront(null);
     this.selection.setWalker(null);
     this._destroyMarkup();
     this.isDirty = false;
 
     this.target.inspector.getWalker().then(walker => {
       if (this._destroyPromise) {
         walker.release().then(null, console.error);
@@ -386,17 +397,17 @@ InspectorPanel.prototype = {
   },
 
   /**
    * When a node is deleted, select its parent node.
    */
   onDetached: function InspectorPanel_onDetached(event, parentNode) {
     this.cancelLayoutChange();
     this.breadcrumbs.cutAfter(this.breadcrumbs.indexOf(parentNode));
-    this.selection.setNodeFront(parentNode, "detached");
+    this.selection.setNodeFront(parentNode ? parentNode : this._defaultNode, "detached");
   },
 
   /**
    * Destroy the inspector.
    */
   destroy: function InspectorPanel__destroy() {
     if (this._destroyPromise) {
       return this._destroyPromise;