Reviewed by Tim Hatcher.
authorweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Oct 2007 18:11:16 +0000 (18:11 +0000)
committerweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Oct 2007 18:11:16 +0000 (18:11 +0000)
        Add resizing of the DOM view right sidebar.  This allows us to actually see the values now.

        * page/inspector/ResourcePanel.js:
        * page/inspector/inspector.css:
        * page/inspector/inspector.js:
        * page/inspector/utilities.js:

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

WebCore/ChangeLog
WebCore/page/inspector/ResourcePanel.js
WebCore/page/inspector/inspector.css
WebCore/page/inspector/inspector.js
WebCore/page/inspector/utilities.js

index 6cb2db6..5137a8f 100644 (file)
@@ -1,3 +1,14 @@
+2007-10-23  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Tim Hatcher.
+
+        Add resizing of the DOM view right sidebar.  This allows us to actually see the values now.
+
+        * page/inspector/ResourcePanel.js:
+        * page/inspector/inspector.css:
+        * page/inspector/inspector.js:
+        * page/inspector/utilities.js:
+
 2007-10-23  David Hyatt  <hyatt@apple.com>
 
         Get basic hit testing right for transforms.
 2007-10-23  David Hyatt  <hyatt@apple.com>
 
         Get basic hit testing right for transforms.
index 082c303..23a6277 100644 (file)
@@ -271,8 +271,13 @@ WebInspector.ResourcePanel.prototype = {
             this.views.dom.contentElement.sideContentElement.appendChild(this.views.dom.contentElement.crumbsElement);
             this.views.dom.contentElement.treeContentElement.appendChild(this.views.dom.contentElement.treeListElement);
 
             this.views.dom.contentElement.sideContentElement.appendChild(this.views.dom.contentElement.crumbsElement);
             this.views.dom.contentElement.treeContentElement.appendChild(this.views.dom.contentElement.treeListElement);
 
+            this.views.dom.contentElement.resizeArea = document.createElement("div");
+            this.views.dom.contentElement.resizeArea.className = "sidebarResizeArea";
+            this.views.dom.contentElement.resizeArea.addEventListener("mousedown", function(event) { panel.rightSidebarResizerDragStart(event) }, false);
+
             this.views.dom.contentElement.appendChild(this.views.dom.contentElement.sideContentElement);
             this.views.dom.contentElement.appendChild(this.views.dom.contentElement.sidebarElement);
             this.views.dom.contentElement.appendChild(this.views.dom.contentElement.sideContentElement);
             this.views.dom.contentElement.appendChild(this.views.dom.contentElement.sidebarElement);
+            this.views.dom.contentElement.appendChild(this.views.dom.contentElement.resizeArea);
 
             this.rootDOMNode = this.resource.documentNode;
         } else if (this.resource.category === WebInspector.resourceCategories.images) {
 
             this.rootDOMNode = this.resource.documentNode;
         } else if (this.resource.category === WebInspector.resourceCategories.images) {
@@ -997,6 +1002,37 @@ WebInspector.ResourcePanel.prototype = {
     {
         if (this.domTreeOutline && this.currentView && this.currentView === this.views.dom)
             this.domTreeOutline.handleKeyEvent(event);
     {
         if (this.domTreeOutline && this.currentView && this.currentView === this.views.dom)
             this.domTreeOutline.handleKeyEvent(event);
+    },
+
+    rightSidebarResizerDragStart: function(event)
+    {
+        var panel = this; 
+        WebInspector.dividerDragStart(this.views.dom.contentElement.sidebarElement, function(event) { panel.rightSidebarResizerDrag(event) }, function(event) { panel.rightSidebarResizerDragEnd(event) }, event, "col-resize");
+    },
+
+    rightSidebarResizerDragEnd: function(event)
+    {
+        var panel = this;
+        WebInspector.dividerDragEnd(this.views.dom.contentElement.sidebarElement, function(event) { panel.rightSidebarResizerDrag(event) }, function(event) { panel.rightSidebarResizerDragEnd(event) }, event);
+    },
+
+    rightSidebarResizerDrag: function(event)
+    {
+        var rightSidebar = this.views.dom.contentElement.sidebarElement;
+        if (rightSidebar.dragging == true) {
+            var x = event.clientX + window.scrollX;
+
+            var leftSidebarWidth = document.defaultView.getComputedStyle(document.getElementById("sidebar")).getPropertyCSSValue("width").getFloatValue(CSSPrimitiveValue.CSS_PX);
+            var newWidth = Number.constrain(window.innerWidth - x, 100, window.innerWidth - leftSidebarWidth - 100);
+
+            if (x == newWidth)
+                rightSidebar.dragLastX = x;
+
+            rightSidebar.style.width = newWidth + "px";
+            this.views.dom.contentElement.sideContentElement.style.right = newWidth + "px";
+            this.views.dom.contentElement.resizeArea.style.right = (newWidth - 3) + "px";
+            event.preventDefault();
+        }
     }
 }
 
     }
 }
 
index b89ef85..76b2fbe 100644 (file)
@@ -1924,3 +1924,13 @@ body.inactive #sidebar li.selected {
     margin-top: -10px;
     margin-bottom: -35px;
 }
     margin-top: -10px;
     margin-bottom: -35px;
 }
+
+.sidebarResizeArea {
+    position: absolute;
+    top: 0;
+    bottom: 0;
+    right: 222px;
+    width: 5px;
+    z-index: 100;
+    cursor: col-resize;
+}
index 24606a6..6bc1903 100644 (file)
@@ -453,7 +453,10 @@ WebInspector.sidebarResizerDrag = function(event)
         var buttonContainer = document.getElementById("viewbuttons");
 
         var x = event.clientX + window.scrollX;
         var buttonContainer = document.getElementById("viewbuttons");
 
         var x = event.clientX + window.scrollX;
-        var newWidth = WebInspector.constrainedWidthOfSidebar(x);
+
+        // FIXME: We can should come up with a better hueristic for constraining the size
+        // of the sidebar.
+        var newWidth = Number.constrain(x, 100, window.innerWidth - 100);
 
         if (x == newWidth)
             sidebar.dragLastX = x;
 
         if (x == newWidth)
             sidebar.dragLastX = x;
@@ -484,23 +487,6 @@ WebInspector.dividerDragEnd = function(element, dividerDrag, dividerDragEnd, eve
     document.body.style.removeProperty("cursor");
 }
 
     document.body.style.removeProperty("cursor");
 }
 
-WebInspector.constrainedWidthOfSidebar = function(width, minWidth, maxWidth) 
-{
-    // FIXME: We can should come up with a better hueristic for constraining the size
-    // of the sidebar.
-    if (typeof minWidth == "undefined")
-        minWidth = 100;
-    if (typeof maxWidth == "undefined")
-        maxWidth = window.innerWidth - 100;
-
-    if (width < minWidth)
-        width = minWidth;
-    else if (width > maxWidth)
-        width = maxWidth;
-
-    return width;
-}
-
 WebInspector.back = function()
 {
     if (this.currentBackForwardIndex <= 0) {
 WebInspector.back = function()
 {
     if (this.currentBackForwardIndex <= 0) {
index 2aab4f3..0bfd252 100644 (file)
@@ -592,6 +592,15 @@ Number.bytesToString = function(bytes)
     return (Math.round(megabytes * 1000) / 1000) + "MB";
 }
 
     return (Math.round(megabytes * 1000) / 1000) + "MB";
 }
 
+Number.constrain = function(num, min, max)
+{
+    if (num < min)
+        num = min;
+    else if (num > max)
+        num = max;
+    return num;
+}
+
 HTMLTextAreaElement.prototype.moveCursorToEnd = function()
 {
     var length = this.value.length;
 HTMLTextAreaElement.prototype.moveCursorToEnd = function()
 {
     var length = this.value.length;