Title: [116954] trunk/Source/WebCore
Revision
116954
Author
[email protected]
Date
2012-05-14 08:53:05 -0700 (Mon, 14 May 2012)

Log Message

Web Inspector: preserve tab index while widening / shrinking tabbed pane area.
https://bugs.webkit.org/show_bug.cgi?id=86359

Reviewed by Vsevolod Vlasov.

After the drag'n'drop reorder, we should preserve tab index while widening /
shrinking the tabbed pane area.

* inspector/front-end/TabbedPane.js:
(WebInspector.TabbedPane.prototype._innerCloseTab):
(WebInspector.TabbedPane.prototype._showTabElement):
(WebInspector.TabbedPane.prototype._hideTabElement):
(WebInspector.TabbedPane.prototype._updateTabsDropDown):
(WebInspector.TabbedPane.prototype.elementsToRestoreScrollPositionsFor):
(WebInspector.TabbedPane.prototype._insertBefore):
(WebInspector.TabbedPaneTab):
(WebInspector.TabbedPaneTab.prototype._createTabElement):
(WebInspector.TabbedPaneTab.prototype._tabDragging):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (116953 => 116954)


--- trunk/Source/WebCore/ChangeLog	2012-05-14 15:48:17 UTC (rev 116953)
+++ trunk/Source/WebCore/ChangeLog	2012-05-14 15:53:05 UTC (rev 116954)
@@ -1,3 +1,24 @@
+2012-05-14  Pavel Feldman  <[email protected]>
+
+        Web Inspector: preserve tab index while widening / shrinking tabbed pane area.
+        https://bugs.webkit.org/show_bug.cgi?id=86359
+
+        Reviewed by Vsevolod Vlasov.
+
+        After the drag'n'drop reorder, we should preserve tab index while widening /
+        shrinking the tabbed pane area.
+
+        * inspector/front-end/TabbedPane.js:
+        (WebInspector.TabbedPane.prototype._innerCloseTab):
+        (WebInspector.TabbedPane.prototype._showTabElement):
+        (WebInspector.TabbedPane.prototype._hideTabElement):
+        (WebInspector.TabbedPane.prototype._updateTabsDropDown):
+        (WebInspector.TabbedPane.prototype.elementsToRestoreScrollPositionsFor):
+        (WebInspector.TabbedPane.prototype._insertBefore):
+        (WebInspector.TabbedPaneTab):
+        (WebInspector.TabbedPaneTab.prototype._createTabElement):
+        (WebInspector.TabbedPaneTab.prototype._tabDragging):
+
 2012-05-14  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: Request / response headers should be stored in name-value pairs array, not a map on front-end.

Modified: trunk/Source/WebCore/inspector/front-end/TabbedPane.js (116953 => 116954)


--- trunk/Source/WebCore/inspector/front-end/TabbedPane.js	2012-05-14 15:48:17 UTC (rev 116953)
+++ trunk/Source/WebCore/inspector/front-end/TabbedPane.js	2012-05-14 15:53:05 UTC (rev 116954)
@@ -139,7 +139,7 @@
 
         this._tabsHistory.splice(this._tabsHistory.indexOf(tab), 1);
         this._tabs.splice(this._tabs.indexOf(tab), 1);
-        if (tab.shown)
+        if (tab._shown)
             this._hideTabElement(tab);
 
         var eventData = { tabId: id, view: tab.view, isUserGesture: userGesture };
@@ -281,7 +281,7 @@
             this._tabsElement.appendChild(tab.tabElement);
         else
             this._tabsElement.insertBefore(tab.tabElement, this._tabsElement.children[index]);
-        tab.shown = true;
+        tab._shown = true;
     },
 
     /**
@@ -290,7 +290,7 @@
     _hideTabElement: function(tab)
     {
         this._tabsElement.removeChild(tab.tabElement);
-        tab.shown = false;
+        tab._shown = false;
     },
 
     _createDropDownButton: function()
@@ -309,12 +309,12 @@
         var tabsToShowIndexes = this._tabsToShowIndexes(this._tabs, this._tabsHistory, this._headerContentsElement.offsetWidth, this._measuredDropDownButtonWidth);
 
         for (var i = 0; i < this._tabs.length; ++i) {
-            if (this._tabs[i].shown && tabsToShowIndexes.indexOf(i) === -1)
+            if (this._tabs[i]._shown && tabsToShowIndexes.indexOf(i) === -1)
                 this._hideTabElement(this._tabs[i]);
         }
         for (var i = 0; i < tabsToShowIndexes.length; ++i) {
             var tab = this._tabs[tabsToShowIndexes[i]];
-            if (!tab.shown)
+            if (!tab._shown)
                 this._showTabElement(i, tab);
         }
         
@@ -329,7 +329,7 @@
         this._tabsSelect.removeChildren();
         var tabsToShow = [];
         for (var i = 0; i < this._tabs.length; ++i) {
-            if (!this._tabs[i].shown)
+            if (!this._tabs[i]._shown)
                 tabsToShow.push(this._tabs[i]);
                 continue;
         }
@@ -482,6 +482,20 @@
     elementsToRestoreScrollPositionsFor: function()
     {
         return [ this._contentElement ];
+    },
+
+    /**
+     * @param {WebInspector.TabbedPaneTab} tab
+     * @param {number} index
+     */
+    _insertBefore: function(tab, index)
+    {
+        this._tabsElement.insertBefore(tab._tabElement, this._tabsElement.childNodes[index]);
+        var oldIndex = this._tabs.indexOf(tab);
+        this._tabs.splice(oldIndex, 1);
+        if (oldIndex < index)
+            --index;
+        this._tabs.splice(index, 0, tab);
     }
 }
 
@@ -507,7 +521,7 @@
     this._title = title;
     this._tooltip = tooltip;
     this._view = view;
-    this.shown = false;
+    this._shown = false;
     /** @type {number} */ this._measuredWidth;
     /** @type {Element} */ this._tabElement;
 }
@@ -628,9 +642,9 @@
         else {
             this._tabElement = tabElement;
             tabElement.addEventListener("click", this._tabClicked.bind(this), false);
+            tabElement.addEventListener("mousedown", this._tabMouseDown.bind(this), false);
             if (this._closeable) {
                 tabElement.addEventListener("contextmenu", this._tabContextMenu.bind(this), false);
-                tabElement.addEventListener("mousedown", this._tabMouseDown.bind(this), false);
                 tabElement.addEventListener("mousemove", this._tabMouseMove.bind(this), false);
             }
         }
@@ -663,6 +677,7 @@
         if (event.target.hasStyleClass("tabbed-pane-header-tab-close-button") || event.button === 1)
             return;
         this._tabbedPane.selectTab(this.id, true);
+        this._dragStartX = event.pageX;
     },
 
     _tabContextMenu: function(event)
@@ -691,11 +706,12 @@
 
     _tabMouseMove: function(event)
     {
+        if (isNaN(this._dragStartX))
+            return;
         if (event.which !== 1)
             return;
         this._tabbedPane.selectTab(this.id, true);
         WebInspector.elementDragStart(this._tabElement, this._tabDragging.bind(this), this._endTabDragging.bind(this), event, "pointer");
-        this._dragStartX = event.pageX;
     },
 
     /**
@@ -708,15 +724,24 @@
             var tabElement = tabElements[i];
             if (tabElement === this._tabElement)
                 continue;
-            var offset = tabElement.totalOffsetLeft();
-            if (event.offsetX < offset || event.offsetX > offset + tabElement.clientWidth)
+
+            var intersects = tabElement.offsetLeft + tabElement.clientWidth > this._tabElement.offsetLeft &&
+                this._tabElement.offsetLeft + this._tabElement.clientWidth > tabElement.offsetLeft;
+            if (!intersects)
                 continue;
-  
-            if (tabElement.offsetLeft > this._tabElement.offsetLeft)
+
+            if (Math.abs(event.pageX - this._dragStartX) < tabElement.clientWidth / 2 + 5)
+                break;
+
+            if (event.pageX - this._dragStartX > 0) {
                 tabElement = tabElement.nextSibling;
+                ++i;
+            }
+
             var oldOffsetLeft = this._tabElement.offsetLeft;
-            this._tabElement.parentElement.insertBefore(this._tabElement, tabElement);
+            this._tabbedPane._insertBefore(this, i);
             this._dragStartX += this._tabElement.offsetLeft - oldOffsetLeft;
+            break;
         }
 
         if (!this._tabElement.previousSibling && event.pageX - this._dragStartX < 0) {
@@ -739,6 +764,7 @@
     {
         this._tabElement.style.removeProperty("position");
         this._tabElement.style.removeProperty("left");
+        delete this._dragStartX;
         WebInspector.elementDragEnd(event);
     }
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to