Bug 626368 - Empty space left between tabs when closing multiple pages in Panorama view [r=ian, a=beltzner]

--HG--
extra : rebase_source : 4f10915c108923889536ef159c223c6091f3bf49
This commit is contained in:
Tim Taubert 2011-01-25 22:13:21 +01:00
Родитель cd34c7cb6d
Коммит a1d9275d7f
6 изменённых файлов: 105 добавлений и 5 удалений

Просмотреть файл

@ -207,7 +207,7 @@ function GroupItem(listOfEls, options) {
else {
this.$titleShield
.mousedown(function(e) {
self.lastMouseDownTarget = (Utils.isRightClick(e) ? null : e.target);
self.lastMouseDownTarget = (Utils.isLeftClick(e) ? e.target : null);
})
.mouseup(function(e) {
var same = (e.target == self.lastMouseDownTarget);
@ -1019,7 +1019,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
.data("xulTab", xulTab)
.appendTo(this.$appTabTray)
.click(function(event) {
if (Utils.isRightClick(event))
if (!Utils.isLeftClick(event))
return;
GroupItems.setActiveGroupItem(self);

Просмотреть файл

@ -703,7 +703,7 @@ Item.prototype = {
// ___ mousedown
$container.mousedown(function(e) {
if (Utils.isRightClick(e))
if (!Utils.isLeftClick(e))
return;
var cancel = false;
@ -835,7 +835,7 @@ Item.prototype = {
.addClass('iq-resizable-handle iq-resizable-se')
.appendTo($container)
.mousedown(function(e) {
if (Utils.isRightClick(e))
if (!Utils.isLeftClick(e))
return;
startMouse = new Point(e.pageX, e.pageY);

Просмотреть файл

@ -580,6 +580,20 @@ let Utils = {
// ___ Misc
// ----------
// Function: isLeftClick
// Given a DOM mouse event, returns true if it was for the left mouse button.
isLeftClick: function Utils_isLeftClick(event) {
return event.button == 0;
},
// ----------
// Function: isMiddleClick
// Given a DOM mouse event, returns true if it was for the middle mouse button.
isMiddleClick: function Utils_isMiddleClick(event) {
return event.button == 1;
},
// ----------
// Function: isRightClick
// Given a DOM mouse event, returns true if it was for the right mouse button.

Просмотреть файл

@ -200,7 +200,7 @@ function TabItem(tab, options) {
return;
// press close button or middle mouse click
if (iQ(e.target).hasClass("close") || e.button == 1) {
if (iQ(e.target).hasClass("close") || Utils.isMiddleClick(e)) {
self.close();
} else {
if (!Items.item(this).isDragging)

Просмотреть файл

@ -90,6 +90,7 @@ _BROWSER_FILES = \
browser_tabview_bug624265.js \
browser_tabview_bug624953.js \
browser_tabview_bug625269.js \
browser_tabview_bug626368.js \
browser_tabview_bug627736.js \
browser_tabview_dragdrop.js \
browser_tabview_exit_button.js \

Просмотреть файл

@ -0,0 +1,85 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is a test for bug 626368.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tim Taubert <tim.taubert@gmx.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function test() {
let cw;
let createGroupItem = function () {
let bounds = new cw.Rect(20, 20, 150, 150);
let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true});
cw.GroupItems.setActiveGroupItem(groupItem);
gBrowser.loadOneTab('about:blank', {inBackground: true});
return groupItem;
}
let synthesizeMiddleMouseDrag = function (tabContainer, width) {
EventUtils.synthesizeMouseAtCenter(tabContainer,
{type: 'mousedown', button: 1}, cw);
let rect = tabContainer.getBoundingClientRect();
EventUtils.synthesizeMouse(tabContainer, rect.width / 2 + width,
rect.height / 2, {type: 'mousemove', button: 1}, cw);
EventUtils.synthesizeMouse(tabContainer, rect.width / 2 + width,
rect.height / 2, {type: 'mouseup', button: 1}, cw);
}
let testDragAndDropWithMiddleMouseButton = function () {
let groupItem = createGroupItem();
let tabItem = groupItem.getChild(0);
let tabContainer = tabItem.container;
let bounds = tabItem.getBounds();
// try to drag and move the mouse out of the tab
synthesizeMiddleMouseDrag(tabContainer, 200);
is(groupItem.getChild(0), tabItem, 'tabItem was not closed');
ok(bounds.equals(tabItem.getBounds()), 'bounds did not change');
// try to drag and let the mouse stay within tab bounds
synthesizeMiddleMouseDrag(tabContainer, 10);
ok(!groupItem.getChild(0), 'tabItem was closed');
hideTabView(finish);
}
waitForExplicitFinish();
showTabView(function () {
cw = TabView.getContentWindow();
afterAllTabsLoaded(testDragAndDropWithMiddleMouseButton);
});
}