Bug 785903 - Markup panel selection should scroll to the center when highlighting, r=dcamp
authorJan Skrasek <hrach.cz@gmail.com>
Mon, 01 Oct 2012 18:15:23 +0300
changeset 108913 1ef6d7852465abc53a35d30c25e5072653423dec
parent 108912 a2214e8900c0820dbc66ff0bc7903a415e2101f8
child 108914 0f91d1acd09b5674716a642dcccd4c3cc179b4d8
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersdcamp
bugs785903
milestone18.0a1
Bug 785903 - Markup panel selection should scroll to the center when highlighting, r=dcamp
browser/devtools/markupview/MarkupView.jsm
--- a/browser/devtools/markupview/MarkupView.jsm
+++ b/browser/devtools/markupview/MarkupView.jsm
@@ -94,17 +94,17 @@ MarkupView.prototype = {
   },
 
   /**
    * Highlight the given element in the markup panel.
    */
   _onSelect: function MT__onSelect()
   {
     if (this._inspector.selection) {
-      this.showNode(this._inspector.selection);
+      this.showNode(this._inspector.selection, true);
     }
     this.selectNode(this._inspector.selection);
   },
 
   /**
    * Create a TreeWalker to find the next/previous
    * node for selection.
    */
@@ -249,17 +249,17 @@ MarkupView.prototype = {
    */
   navigate: function MT__navigate(aContainer, aIgnoreFocus)
   {
     if (!aContainer) {
       return;
     }
 
     let node = aContainer.node;
-    this.showNode(node);
+    this.showNode(node, false);
     this.selectNode(node);
 
     if (this._inspector._IUI.highlighter.isNodeHighlightable(node)) {
       this._inspector._IUI.select(node, true, false, "treepanel");
       this._inspector._IUI.highlighter.highlight(node);
     }
 
     if (!aIgnoreFocus) {
@@ -338,25 +338,25 @@ MarkupView.prototype = {
     }
     this._inspector.emit("markupmutation");
   },
 
   /**
    * Make sure the given node's parents are expanded and the
    * node is scrolled on to screen.
    */
-  showNode: function MT_showNode(aNode)
+  showNode: function MT_showNode(aNode, centered)
   {
     this.importNode(aNode);
     let walker = documentWalker(aNode);
     let parent;
     while (parent = walker.parentNode()) {
       this.expandNode(parent);
     }
-    LayoutHelpers.scrollIntoViewIfNeeded(this._containers.get(aNode).editor.elt, false);
+    LayoutHelpers.scrollIntoViewIfNeeded(this._containers.get(aNode).editor.elt, centered);
   },
 
   /**
    * Expand the container's children.
    */
   _expandContainer: function MT__expandContainer(aContainer)
   {
     if (aContainer.hasChildren && !aContainer.expanded) {