Web Inspector: Make collapsed sidebars undraggable
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Feb 2015 23:27:27 +0000 (23:27 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Feb 2015 23:27:27 +0000 (23:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140664

Patch by Nikita Vasilyev <nvasilyev@apple.com> on 2015-02-10
Reviewed by Timothy Hatcher.

* UserInterface/Views/Sidebar.css:
(.sidebar.collapsed):
(.sidebar.collapsed.right > .resizer): Deleted.
(.sidebar.collapsed.left > .resizer): Deleted.
* UserInterface/Views/Sidebar.js:
(WebInspector.Sidebar):
(WebInspector.Sidebar.prototype._resizerMouseDown):
(WebInspector.Sidebar.prototype._resizerMouseMoved):
(WebInspector.Sidebar.prototype._resizerDoubleClicked): Deleted.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/Sidebar.css
Source/WebInspectorUI/UserInterface/Views/Sidebar.js

index 321d960..a06883a 100644 (file)
@@ -1,3 +1,20 @@
+2015-02-10  Nikita Vasilyev  <nvasilyev@apple.com>
+
+        Web Inspector: Make collapsed sidebars undraggable
+        https://bugs.webkit.org/show_bug.cgi?id=140664
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/Sidebar.css:
+        (.sidebar.collapsed):
+        (.sidebar.collapsed.right > .resizer): Deleted.
+        (.sidebar.collapsed.left > .resizer): Deleted.
+        * UserInterface/Views/Sidebar.js:
+        (WebInspector.Sidebar):
+        (WebInspector.Sidebar.prototype._resizerMouseDown):
+        (WebInspector.Sidebar.prototype._resizerMouseMoved):
+        (WebInspector.Sidebar.prototype._resizerDoubleClicked): Deleted.
+
 2015-02-10  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: CSS Pretty Printing: still fails fails to put space between rgb(...) and numbers in minified gradients
index e5b0361..dccb566 100644 (file)
@@ -79,12 +79,8 @@ body.mac-platform.legacy.window-inactive .sidebar {
     right: -3px;
 }
 
-.sidebar.collapsed.right > .resizer {
-    left: -5px;
-}
-
-.sidebar.collapsed.left > .resizer {
-    right: -5px;
+.sidebar.collapsed {
+    display: none;
 }
 
 .sidebar.left {
index daeaa42..e07be64 100644 (file)
@@ -41,7 +41,6 @@ WebInspector.Sidebar = function(element, side, sidebarPanels, role, label) {
     this._resizeElement = document.createElement("div");
     this._resizeElement.classList.add(WebInspector.Sidebar.ResizeElementStyleClassName);
     this._resizeElement.addEventListener("mousedown", this._resizerMouseDown.bind(this), false);
-    this._resizeElement.addEventListener("dblclick", this._resizerDoubleClicked.bind(this), false);
     this._element.insertBefore(this._resizeElement, this._element.firstChild);
 
     this._sidebarPanels = [];
@@ -258,14 +257,6 @@ WebInspector.Sidebar.prototype = {
         this.selectedSidebarPanel = event.target.selectedNavigationItem ? event.target.selectedNavigationItem.identifier : null;
     },
 
-    _resizerDoubleClicked: function(event)
-    {
-        this.collapsed = !this.collapsed;
-
-        event.preventDefault();
-        event.stopPropagation();
-    },
-
     _resizerMouseDown: function(event)
     {
         if (event.button !== 0 || event.ctrlKey)
@@ -276,6 +267,9 @@ WebInspector.Sidebar.prototype = {
         this._resizerMouseMovedEventListener = this._resizerMouseMoved.bind(this);
         this._resizerMouseUpEventListener = this._resizerMouseUp.bind(this);
 
+        this._widthBeforeResize = this.width;
+        this._resizerMouseDownX = event.pageX;
+
         // Register these listeners on the document so we can track the mouse if it leaves the resizer.
         document.addEventListener("mousemove", this._resizerMouseMovedEventListener, false);
         document.addEventListener("mouseup", this._resizerMouseUpEventListener, false);
@@ -286,11 +280,12 @@ WebInspector.Sidebar.prototype = {
 
     _resizerMouseMoved: function(event)
     {
+        var deltaX = this._resizerMouseDownX - event.pageX;
+
         if (this._side === WebInspector.Sidebar.Sides.Left)
-            var newWidth = event.pageX - this._element.totalOffsetLeft;
-        else
-            var newWidth = this._element.totalOffsetLeft + this._element.offsetWidth - event.pageX;
+            deltaX *= -1;
 
+        var newWidth = deltaX + this._widthBeforeResize;
         this.width = newWidth;
         this.collapsed = (newWidth < (this.minimumWidth / 2));