Bug 985517 - Keep pseudo class locked when selecting another node in the markup view. r=pbro draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 02 Nov 2016 04:48:05 -0700
changeset 435041 68d13aa818492c0594e956d30812b83bd1da5307
parent 434636 908557c762f798605a2f96e4c943791cbada1b50
child 435042 45cede998137263fbcba72e34d28c1f84057b1ef
push id34913
push userbmo:poirot.alex@gmail.com
push dateMon, 07 Nov 2016 22:46:48 +0000
reviewerspbro
bugs985517
milestone52.0a1
Bug 985517 - Keep pseudo class locked when selecting another node in the markup view. r=pbro MozReview-Commit-ID: 4davyHgBtUh
devtools/client/framework/selection.js
devtools/client/inspector/inspector.js
devtools/client/inspector/test/browser_inspector_pseudoclass-lock.js
--- a/devtools/client/framework/selection.js
+++ b/devtools/client/framework/selection.js
@@ -37,17 +37,16 @@ var EventEmitter = require("devtools/sha
  *   isCommentNode()
  *   isDocumentNode()
  *   isDocumentTypeNode()
  *   isDocumentFragmentNode()
  *   isNotationNode()
  *
  * Events:
  *   "new-node-front" when the inner node changed
- *   "before-new-node-front" when the inner node is set to change
  *   "attribute-changed" when an attribute is changed
  *   "detached-front" when the node (or one of its parents) is removed from
  *   the document
  *   "reparented" when the node (or one of its parents) is moved under
  *   a different node
  */
 
 /**
@@ -119,17 +118,16 @@ Selection.prototype = {
     this.reason = reason;
 
     // If an inlineTextChild text node is being set, then set it's parent instead.
     let parentNode = value && value.parentNode();
     if (value && parentNode && parentNode.inlineTextChild === value) {
       value = parentNode;
     }
 
-    this.emit("before-new-node-front", value, reason);
     this._nodeFront = value;
     this.emit("new-node-front", value, this.reason);
   },
 
   get documentFront() {
     return this._walker.document(this._nodeFront);
   },
 
--- a/devtools/client/inspector/inspector.js
+++ b/devtools/client/inspector/inspector.js
@@ -98,17 +98,16 @@ function Inspector(toolbox) {
 
   this._handleRejectionIfNotDestroyed = this._handleRejectionIfNotDestroyed.bind(this);
   this._onBeforeNavigate = this._onBeforeNavigate.bind(this);
   this.onNewRoot = this.onNewRoot.bind(this);
   this._onContextMenu = this._onContextMenu.bind(this);
   this.onTextBoxContextMenu = this.onTextBoxContextMenu.bind(this);
   this._updateSearchResultsLabel = this._updateSearchResultsLabel.bind(this);
   this.onNewSelection = this.onNewSelection.bind(this);
-  this.onBeforeNewSelection = this.onBeforeNewSelection.bind(this);
   this.onDetached = this.onDetached.bind(this);
   this.onPaneToggleButtonClicked = this.onPaneToggleButtonClicked.bind(this);
   this._onMarkupFrameLoad = this._onMarkupFrameLoad.bind(this);
   this.onPanelWindowResize = this.onPanelWindowResize.bind(this);
   this.onSidebarShown = this.onSidebarShown.bind(this);
   this.onSidebarHidden = this.onSidebarHidden.bind(this);
 
   this._target.on("will-navigate", this._onBeforeNavigate);
@@ -218,17 +217,16 @@ Inspector.prototype = {
   _deferredOpen: function (defaultSelection) {
     let deferred = defer();
 
     this.breadcrumbs = new HTMLBreadcrumbs(this);
 
     this.walker.on("new-root", this.onNewRoot);
 
     this.selection.on("new-node-front", this.onNewSelection);
-    this.selection.on("before-new-node-front", this.onBeforeNewSelection);
     this.selection.on("detached-front", this.onDetached);
 
     if (this.target.isLocalTab) {
       // Show a warning when the debugger is paused.
       // We show the warning only when the inspector
       // is selected.
       this.updateDebuggerPausedWarning = () => {
         let notificationBox = this._toolbox.getNotificationBox();
@@ -851,26 +849,16 @@ Inspector.prototype = {
   /**
    * Cancel notification of inspector updates.
    */
   cancelUpdate: function () {
     this._updateProgress = null;
   },
 
   /**
-   * When a new node is selected, before the selection has changed.
-   */
-  onBeforeNewSelection: function (event, node) {
-    if (this.breadcrumbs.indexOf(node) == -1) {
-      // only clear locks if we'd have to update breadcrumbs
-      this.clearPseudoClasses();
-    }
-  },
-
-  /**
    * When a node is deleted, select its parent node or the defaultNode if no
    * parent is found (may happen when deleting an iframe inside which the
    * node was selected).
    */
   onDetached: function (event, parentNode) {
     this.breadcrumbs.cutAfter(this.breadcrumbs.indexOf(parentNode));
     this.selection.setNodeFront(parentNode ? parentNode : this._defaultNode, "detached");
   },
@@ -923,17 +911,16 @@ Inspector.prototype = {
 
     this.teardownSplitter();
 
     this.sidebar = null;
 
     this.teardownToolbar();
     this.breadcrumbs.destroy();
     this.selection.off("new-node-front", this.onNewSelection);
-    this.selection.off("before-new-node-front", this.onBeforeNewSelection);
     this.selection.off("detached-front", this.onDetached);
     let markupDestroyer = this._destroyMarkup();
     this.panelWin.inspector = null;
     this.target = null;
     this.panelDoc = null;
     this.panelWin = null;
     this.breadcrumbs = null;
     this._toolbox = null;
@@ -1553,26 +1540,16 @@ Inspector.prototype = {
       jsterm.requestEvaluation(evalString, options).then((res) => {
         jsterm.setInputValue(res.result);
         this.emit("console-var-ready");
       });
     });
   },
 
   /**
-   * Clear any pseudo-class locks applied to the current hierarchy.
-   */
-  clearPseudoClasses: function () {
-    if (!this.walker) {
-      return promise.resolve();
-    }
-    return this.walker.clearPseudoClassLocks().catch(this._handleRejectionIfNotDestroyed);
-  },
-
-  /**
    * Edit the outerHTML of the selected Node.
    */
   editHTML: function () {
     if (!this.selection.isNode()) {
       return;
     }
     if (this.markup) {
       this.markup.beginEditingOuterHTML(this.selection.nodeFront);
--- a/devtools/client/inspector/test/browser_inspector_pseudoclass-lock.js
+++ b/devtools/client/inspector/test/browser_inspector_pseudoclass-lock.js
@@ -70,27 +70,24 @@ function* togglePseudoClass(inspector) {
 function* testNavigate(inspector, testActor, ruleview) {
   yield selectNode("#parent-div", inspector);
 
   info("Make sure the pseudoclass is still on after navigating to a parent");
 
   ok((yield testActor.hasPseudoClassLock("#div-1", PSEUDO)),
      "pseudo-class lock is still applied after inspecting ancestor");
 
-  let onPseudo = inspector.selection.once("pseudoclass");
   yield selectNode("#div-2", inspector);
-  yield onPseudo;
 
-  info("Make sure the pseudoclass is removed after navigating to a " +
+  info("Make sure the pseudoclass is still set after navigating to a " +
        "non-hierarchy node");
-  ok(!(yield testActor.hasPseudoClassLock("#div-1", PSEUDO)),
-     "pseudo-class lock is removed after inspecting sibling node");
+  ok(yield testActor.hasPseudoClassLock("#div-1", PSEUDO),
+     "pseudo-class lock is still on after inspecting sibling node");
 
   yield selectNode("#div-1", inspector);
-  yield togglePseudoClass(inspector);
 }
 
 function* showPickerOn(selector, inspector) {
   let nodeFront = yield getNodeFront(selector, inspector);
   yield inspector.highlighter.showBoxModel(nodeFront);
 }
 
 function* assertPseudoAddedToNode(inspector, testActor, ruleview) {