Change WebInspector.elementDragStart and WebInspector.elementDragEnd to have more
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Apr 2008 20:36:24 +0000 (20:36 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Apr 2008 20:36:24 +0000 (20:36 +0000)
state, so calling elementDragEnd does not need the listener functions. Also makes
calling elementDragStart again without elementDragEnd work correctly.

Reviewed by Adam Roben.

* page/inspector/ElementsPanel.js:
(DocumentPanel.prototype.rightSidebarResizerDragStart): Just call WebInspector.elementDragStart.
Removed code that stored away the listeners now that elementDragStart does it.
(DocumentPanel.prototype.rightSidebarResizerDragEnd): Just call WebInspector.elementDragEnd.
Removed code that deleted listeners properties now that elementDragEnd does it.
* page/inspector/inspector.js:
(WebInspector.sidebarResizerDragEnd): Pass less arguments to elementDragEnd.
(WebInspector.searchResultsResizerDragEnd): Ditto.
(WebInspector.elementDragStart): Store the listeners as private properties on WebInspector.
If the properties are already defined, call elementDragEnd first.
(WebInspector.elementDragEnd): Remove the event listeners using the stored properties.
Delete the private listener properties.

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

WebCore/ChangeLog
WebCore/page/inspector/ElementsPanel.js
WebCore/page/inspector/inspector.js

index 42b6ff4..246aa17 100644 (file)
@@ -1,3 +1,24 @@
+2008-04-08  Timothy Hatcher  <timothy@apple.com>
+
+        Change WebInspector.elementDragStart and WebInspector.elementDragEnd to have more
+        state, so calling elementDragEnd does not need the listener functions. Also makes
+        calling elementDragStart again without elementDragEnd work correctly.
+
+        Reviewed by Adam Roben.
+
+        * page/inspector/ElementsPanel.js:
+        (DocumentPanel.prototype.rightSidebarResizerDragStart): Just call WebInspector.elementDragStart.
+        Removed code that stored away the listeners now that elementDragStart does it.
+        (DocumentPanel.prototype.rightSidebarResizerDragEnd): Just call WebInspector.elementDragEnd.
+        Removed code that deleted listeners properties now that elementDragEnd does it.
+        * page/inspector/inspector.js:
+        (WebInspector.sidebarResizerDragEnd): Pass less arguments to elementDragEnd.
+        (WebInspector.searchResultsResizerDragEnd): Ditto.
+        (WebInspector.elementDragStart): Store the listeners as private properties on WebInspector.
+        If the properties are already defined, call elementDragEnd first.
+        (WebInspector.elementDragEnd): Remove the event listeners using the stored properties.
+        Delete the private listener properties.
+
 2008-04-08  Adam Roben  <aroben@apple.com>
 
         Build fix
index db7efb1..f8b0b24 100644 (file)
@@ -718,19 +718,12 @@ WebInspector.DocumentPanel.prototype = {
 
     rightSidebarResizerDragStart: function(event)
     {
-        if (this.sidebarDragEventListener || this.sidebarDragEndEventListener)
-            return this.rightSidebarResizerDragEnd(event);
-
-        this.sidebarDragEventListener = this.rightSidebarResizerDrag.bind(this);
-        this.sidebarDragEndEventListener = this.rightSidebarResizerDragEnd.bind(this);
-        WebInspector.elementDragStart(this.views.dom.sidebarElement, this.sidebarDragEventListener, this.sidebarDragEndEventListener, event, "col-resize");
+        WebInspector.elementDragStart(this.views.dom.sidebarElement, this.rightSidebarResizerDrag.bind(this), this.rightSidebarResizerDragEnd.bind(this), event, "col-resize");
     },
 
     rightSidebarResizerDragEnd: function(event)
     {
-        WebInspector.elementDragEnd(this.views.dom.sidebarElement, this.sidebarDragEventListener, this.sidebarDragEndEventListener, event);
-        delete this.sidebarDragEventListener;
-        delete this.sidebarDragEndEventListener;
+        WebInspector.elementDragEnd(event);
     },
 
     rightSidebarResizerDrag: function(event)
index 5c86180..504f6e5 100644 (file)
@@ -588,7 +588,7 @@ WebInspector.sidebarResizerDragStart = function(event)
 
 WebInspector.sidebarResizerDragEnd = function(event)
 {
-    WebInspector.elementDragEnd(document.getElementById("sidebar"), WebInspector.sidebarResizerDrag, WebInspector.sidebarResizerDragEnd, event);
+    WebInspector.elementDragEnd(event);
 }
 
 WebInspector.sidebarResizerDrag = function(event)
@@ -616,7 +616,7 @@ WebInspector.searchResultsResizerDragStart = function(event)
 
 WebInspector.searchResultsResizerDragEnd = function(event)
 {
-    WebInspector.elementDragEnd(document.getElementById("searchResults"), WebInspector.searchResultsResizerDrag, WebInspector.searchResultsResizerDragEnd, event);
+    WebInspector.elementDragEnd(event);
 }
 
 WebInspector.searchResultsResizerDrag = function(event)
@@ -635,25 +635,29 @@ WebInspector.searchResultsResizerDrag = function(event)
 
 WebInspector.elementDragStart = function(element, dividerDrag, elementDragEnd, event, cursor) 
 {
-    if (WebInspector.draggingElement)
-        return elementDragEnd(event);
+    if (this._elementDraggingEventListener || this._elementEndDraggingEventListener)
+        this.elementDragEnd(event);
 
-    WebInspector.draggingElement = true;
+    this._elementDraggingEventListener = dividerDrag;
+    this._elementEndDraggingEventListener = elementDragEnd;
 
     document.addEventListener("mousemove", dividerDrag, true);
     document.addEventListener("mouseup", elementDragEnd, true);
+
     document.body.style.cursor = cursor;
 
     event.preventDefault();
 }
 
-WebInspector.elementDragEnd = function(element, dividerDrag, elementDragEnd, event) 
+WebInspector.elementDragEnd = function(event)
 {
-    document.removeEventListener("mousemove", dividerDrag, true);
-    document.removeEventListener("mouseup", elementDragEnd, true);
+    document.removeEventListener("mousemove", this._elementDraggingEventListener, true);
+    document.removeEventListener("mouseup", this._elementEndDraggingEventListener, true);
+
     document.body.style.removeProperty("cursor");
 
-    delete WebInspector.draggingElement;
+    delete this._elementDraggingEventListener;
+    delete this._elementEndDraggingEventListener;
 
     event.preventDefault();
 }