Reviewed by Adam Roben.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Feb 2008 00:46:16 +0000 (00:46 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Feb 2008 00:46:16 +0000 (00:46 +0000)
        <rdar://problem/5712777> REGRESSION: Arrow up/down in inspector
        source list does not scroll when item at edge is reached (16572)

        Use scrollIntoViewIfNeeded() instead of the hand-rolled scrollToElement
        we were using in utilities.js.

        * page/inspector/DocumentPanel.js: Use scrollIntoViewIfNeeded instead of scrollToElement.
        * page/inspector/Resource.js: Ditto.
        * page/inspector/inspector.js: Ditto.
        * page/inspector/SourcePanel.js: Use scrollIntoViewIfNeeded instead
        of scrollIntoView, so the source line is centered in the view if needed.
        * page/inspector/utilities.js: Removed scrollToElement().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30607 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/page/inspector/DocumentPanel.js
WebCore/page/inspector/Resource.js
WebCore/page/inspector/SourcePanel.js
WebCore/page/inspector/inspector.js
WebCore/page/inspector/utilities.js

index e5fa128..1dc5d46 100644 (file)
@@ -1,3 +1,20 @@
+2008-02-26  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Adam Roben.
+
+        <rdar://problem/5712777> REGRESSION: Arrow up/down in inspector
+        source list does not scroll when item at edge is reached (16572)
+
+        Use scrollIntoViewIfNeeded() instead of the hand-rolled scrollToElement
+        we were using in utilities.js.
+
+        * page/inspector/DocumentPanel.js: Use scrollIntoViewIfNeeded instead of scrollToElement.
+        * page/inspector/Resource.js: Ditto.
+        * page/inspector/inspector.js: Ditto.
+        * page/inspector/SourcePanel.js: Use scrollIntoViewIfNeeded instead
+        of scrollIntoView, so the source line is centered in the view if needed.
+        * page/inspector/utilities.js: Removed scrollToElement().
+
 2008-02-26  David Hyatt  <hyatt@apple.com>
 
         Reviewed by Dan
index 770f9ba..8528196 100644 (file)
@@ -805,9 +805,8 @@ WebInspector.DOMNodeTreeElement.prototype = {
 
     onreveal: function()
     {
-        if (!this.listItemElement || !this.treeOutline)
-            return;
-        this.treeOutline.panel.views.dom.treeContentElement.scrollToElement(this.listItemElement);
+        if (this.listItemElement)
+            this.listItemElement.scrollIntoViewIfNeeded(false);
     },
 
     onselect: function()
index 2f87b13..ed35970 100644 (file)
@@ -681,9 +681,8 @@ WebInspector.ResourceTreeElement.prototype = {
 
     onreveal: function()
     {
-        if (!this.listItemElement || !this.treeOutline || !this.treeOutline.childrenListElement)
-            return;
-        this.treeOutline.childrenListElement.scrollToElement(this.listItemElement);
+        if (this.listItemElement)
+            this.listItemElement.scrollIntoViewIfNeeded(false);
     }
 }
 
index 9d4139c..32d7899 100644 (file)
@@ -90,7 +90,7 @@ WebInspector.SourcePanel.prototype = {
         if (!row)
             return;
         this.currentView = this.views.source;
-        row.scrollIntoView(true);
+        row.scrollIntoViewIfNeeded(true);
     },
 
     addMessageToSource: function(msg)
index 04e78e6..a9f5fcf 100644 (file)
@@ -927,15 +927,15 @@ WebInspector.performSearch = function(query)
         selection.addRange(element.representedObject.range);
 
         WebInspector.navigateToPanel(element.representedObject.panel, "source");
-        element.representedObject.line.scrollIntoView(true);
-        resultsContainer.scrollToElement(element.listItemElement);
+        element.representedObject.line.scrollIntoViewIfNeeded(true);
+        element.listItemElement.scrollIntoViewIfNeeded(false);
     }
 
     var domResultSelected = function(element)
     {
         WebInspector.navigateToPanel(element.representedObject.panel, "dom");
         element.representedObject.panel.focusedDOMNode = element.representedObject.node;
-        resultsContainer.scrollToElement(element.listItemElement);
+        element.listItemElement.scrollIntoViewIfNeeded(false);
     }
 
     for (var i = 0; i < files.length; ++i) {
index 812b613..47d721f 100644 (file)
@@ -123,24 +123,6 @@ Element.prototype.hasStyleClass = function(className)
     return regex.test(this.className);
 }
 
-Element.prototype.scrollToElement = function(element)
-{
-    if (!element || !this.isAncestor(element))
-        return;
-
-    var offsetTop = 0;
-    var current = element
-    while (current && current !== this) {
-        offsetTop += current.offsetTop;
-        current = current.offsetParent;
-    }
-
-    if (this.scrollTop > offsetTop)
-        this.scrollTop = offsetTop;
-    else if ((this.scrollTop + this.offsetHeight) < (offsetTop + element.offsetHeight))
-        this.scrollTop = offsetTop - this.offsetHeight + element.offsetHeight;
-}
-
 Node.prototype.firstParentOrSelfWithNodeName = function(nodeName)
 {
     for (var node = this; node && (node !== document); node = node.parentNode)