Changeset 116930 in webkit


Ignore:
Timestamp:
May 14, 2012 2:46:33 AM (12 years ago)
Author:
pfeldman@chromium.org
Message:

Web Inspector: implement tabs reordering via drag'n'drop.
https://bugs.webkit.org/show_bug.cgi?id=86294

Reviewed by Yury Semikhatsky.

  • inspector/front-end/TabbedPane.js:

(WebInspector.TabbedPaneTab.prototype._createTabElement):
(WebInspector.TabbedPaneTab.prototype._tabClicked):
(WebInspector.TabbedPaneTab.prototype._tabMouseDown):
(WebInspector.TabbedPaneTab.prototype._tabContextMenu):
(WebInspector.TabbedPaneTab.prototype._tabMouseMove):
(WebInspector.TabbedPaneTab.prototype._tabDragging):
(WebInspector.TabbedPaneTab.prototype._endTabDragging):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r116927 r116930  
     12012-05-12  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Web Inspector: implement tabs reordering via drag'n'drop.
     4        https://bugs.webkit.org/show_bug.cgi?id=86294
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        * inspector/front-end/TabbedPane.js:
     9        (WebInspector.TabbedPaneTab.prototype._createTabElement):
     10        (WebInspector.TabbedPaneTab.prototype._tabClicked):
     11        (WebInspector.TabbedPaneTab.prototype._tabMouseDown):
     12        (WebInspector.TabbedPaneTab.prototype._tabContextMenu):
     13        (WebInspector.TabbedPaneTab.prototype._tabMouseMove):
     14        (WebInspector.TabbedPaneTab.prototype._tabDragging):
     15        (WebInspector.TabbedPaneTab.prototype._endTabDragging):
     16
    1172012-05-14  MORITA Hajime  <morrita@google.com>
    218
  • trunk/Source/WebCore/inspector/front-end/SettingsScreen.js

    r116854 r116930  
    614614{
    615615    this._statusBarButton = new WebInspector.StatusBarButton(WebInspector.UIString("Settings"), "settings-status-bar-item");;
    616     this._statusBarButton.addEventListener("click", this._buttonClicked.bind(this), false);
     616    this._statusBarButton.addEventListener("click", this._buttonClicked, this);
    617617
    618618    /** @type {?WebInspector.SettingsScreen} */
  • trunk/Source/WebCore/inspector/front-end/TabbedPane.js

    r116853 r116930  
    629629            this._tabElement = tabElement;
    630630            tabElement.addEventListener("click", this._tabClicked.bind(this), false);
    631             if (this._closeable)
     631            if (this._closeable) {
    632632                tabElement.addEventListener("contextmenu", this._tabContextMenu.bind(this), false);
     633                tabElement.addEventListener("mousedown", this._tabMouseDown.bind(this), false);
     634                tabElement.addEventListener("mousemove", this._tabMouseMove.bind(this), false);
     635            }
    633636        }
    634637       
     
    651654        if (this._closeable && (event.button === 1 || event.target.hasStyleClass("tabbed-pane-header-tab-close-button")))
    652655            this._tabbedPane.closeTab(this.id, true);
    653         else
    654             this._tabbedPane.selectTab(this.id, true);
    655         this._tabbedPane.focus();
     656    },
     657
     658    /**
     659     * @param {Event} event
     660     */
     661    _tabMouseDown: function(event)
     662    {
     663        if (event.target.hasStyleClass("tabbed-pane-header-tab-close-button") || event.button === 1)
     664            return;
     665        this._tabbedPane.selectTab(this.id, true);
    656666    },
    657667
     
    678688        contextMenu.appendItem(WebInspector.UIString("Close All"), closeAll.bind(this));
    679689        contextMenu.show(event);
     690    },
     691
     692    _tabMouseMove: function(event)
     693    {
     694        if (event.which !== 1)
     695            return;
     696        this._tabbedPane.selectTab(this.id, true);
     697        WebInspector.elementDragStart(this._tabElement, this._tabDragging.bind(this), this._endTabDragging.bind(this), event, "pointer");
     698        this._dragStartX = event.pageX;
     699    },
     700
     701    /**
     702     * @param {Event} event
     703     */
     704    _tabDragging: function(event)
     705    {
     706        var tabElements = this._tabbedPane._tabsElement.childNodes;
     707        for (var i = 0; i < tabElements.length; ++i) {
     708            var tabElement = tabElements[i];
     709            if (tabElement === this._tabElement)
     710                continue;
     711            var offset = tabElement.totalOffsetLeft();
     712            if (event.offsetX < offset || event.offsetX > offset + tabElement.clientWidth)
     713                continue;
     714 
     715            if (tabElement.offsetLeft > this._tabElement.offsetLeft)
     716                tabElement = tabElement.nextSibling;
     717            var oldOffsetLeft = this._tabElement.offsetLeft;
     718            this._tabElement.parentElement.insertBefore(this._tabElement, tabElement);
     719            this._dragStartX += this._tabElement.offsetLeft - oldOffsetLeft;
     720        }
     721
     722        if (!this._tabElement.previousSibling && event.pageX - this._dragStartX < 0) {
     723            this._tabElement.style.setProperty("left", "0px");
     724            return;
     725        }
     726        if (!this._tabElement.nextSibling && event.pageX - this._dragStartX > 0) {
     727            this._tabElement.style.setProperty("left", "0px");
     728            return;
     729        }
     730
     731        this._tabElement.style.setProperty("position", "relative");
     732        this._tabElement.style.setProperty("left", (event.pageX - this._dragStartX) + "px");
     733    },
     734
     735    /**
     736     * @param {Event} event
     737     */
     738    _endTabDragging: function(event)
     739    {
     740        this._tabElement.style.removeProperty("position");
     741        this._tabElement.style.removeProperty("left");
     742        WebInspector.elementDragEnd(event);
    680743    }
    681744}
Note: See TracChangeset for help on using the changeset viewer.