mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Bug 722100 - Use dblclick instead of hard-coded logic/constants in Tab View; r=ttaubert
This commit is contained in:
parent
d70fc7999a
commit
67b7ab64bb
@ -792,6 +792,7 @@ let events = [
|
||||
'mouseout',
|
||||
'mousemove',
|
||||
'click',
|
||||
'dblclick',
|
||||
'resize',
|
||||
'change',
|
||||
'blur',
|
||||
|
@ -30,16 +30,12 @@ function test1() {
|
||||
closeGroupItem(groupItems[1], finish);
|
||||
});
|
||||
|
||||
// first click
|
||||
mouseClick(contentElement, 0);
|
||||
// second click
|
||||
mouseClick(contentElement, 0);
|
||||
// double click
|
||||
doubleClick(contentElement, 0);
|
||||
}
|
||||
|
||||
function mouseClick(targetElement, buttonCode) {
|
||||
function doubleClick(targetElement, buttonCode) {
|
||||
EventUtils.sendMouseEvent(
|
||||
{ type: "mousedown", button: buttonCode }, targetElement, contentWindow);
|
||||
EventUtils.sendMouseEvent(
|
||||
{ type: "mouseup", button: buttonCode }, targetElement, contentWindow);
|
||||
{ type: "dblclick", button: buttonCode }, targetElement, contentWindow);
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,7 @@ function test() {
|
||||
let height = cw.innerHeight;
|
||||
|
||||
let body = cw.document.body;
|
||||
EventUtils.synthesizeMouse(body, width - 10, height - 10, {}, cw);
|
||||
EventUtils.synthesizeMouse(body, width - 10, height - 10, {}, cw);
|
||||
EventUtils.synthesizeMouse(body, width - 10, height - 10, { clickCount: 2 }, cw);
|
||||
|
||||
whenTabViewIsHidden(function () {
|
||||
assertNumberOfTabs(2);
|
||||
|
@ -34,14 +34,7 @@ function onTabViewWindowLoaded(win) {
|
||||
is(secondGroup.getBounds().top - firstGroup.getBounds().bottom, 40,
|
||||
"There's currently 40 px between the first group and second group");
|
||||
|
||||
// set double click interval to negative so quick drag and drop doesn't
|
||||
// trigger the double click code.
|
||||
let origDBlClickInterval = contentWindow.UI.DBLCLICK_INTERVAL;
|
||||
contentWindow.UI.DBLCLICK_INTERVAL = -1;
|
||||
|
||||
let endGame = function() {
|
||||
contentWindow.UI.DBLCLICK_INTERVAL = origDBlClickInterval;
|
||||
|
||||
firstGroup.container.parentNode.removeChild(firstGroup.container);
|
||||
firstGroup.close();
|
||||
thirdGroup.container.parentNode.removeChild(thirdGroup.container);
|
||||
|
@ -51,16 +51,6 @@ let Keys = { meta: false };
|
||||
// Class: UI
|
||||
// Singleton top-level UI manager.
|
||||
let UI = {
|
||||
// Constant: DBLCLICK_INTERVAL
|
||||
// Defines the maximum time (in ms) between two clicks for it to count as
|
||||
// a double click.
|
||||
DBLCLICK_INTERVAL: 500,
|
||||
|
||||
// Constant: DBLCLICK_OFFSET
|
||||
// Defines the maximum offset (in pixels) between two clicks for it to count as
|
||||
// a double click.
|
||||
DBLCLICK_OFFSET: 5,
|
||||
|
||||
// Variable: _frameInitialized
|
||||
// True if the Tab View UI frame has been initialized.
|
||||
_frameInitialized: false,
|
||||
@ -100,11 +90,6 @@ let UI = {
|
||||
// Used to facilitate zooming down from a previous tab.
|
||||
_currentTab: null,
|
||||
|
||||
// Variable: _lastClick
|
||||
// Keeps track of the time of last click event to detect double click.
|
||||
// Used to create tabs on double-click since we cannot attach 'dblclick'
|
||||
_lastClick: 0,
|
||||
|
||||
// Variable: _eventListeners
|
||||
// Keeps track of event listeners added to the AllTabs object.
|
||||
_eventListeners: {},
|
||||
@ -212,40 +197,28 @@ let UI = {
|
||||
element.blur();
|
||||
});
|
||||
}
|
||||
if (e.originalTarget.id == "content") {
|
||||
if (!Utils.isLeftClick(e)) {
|
||||
self._lastClick = 0;
|
||||
self._lastClickPositions = null;
|
||||
} else {
|
||||
// Create a group with one tab on double click
|
||||
if (Date.now() - self._lastClick <= self.DBLCLICK_INTERVAL &&
|
||||
(self._lastClickPositions.x - self.DBLCLICK_OFFSET) <= e.clientX &&
|
||||
(self._lastClickPositions.x + self.DBLCLICK_OFFSET) >= e.clientX &&
|
||||
(self._lastClickPositions.y - self.DBLCLICK_OFFSET) <= e.clientY &&
|
||||
(self._lastClickPositions.y + self.DBLCLICK_OFFSET) >= e.clientY) {
|
||||
|
||||
let box =
|
||||
new Rect(e.clientX - Math.floor(TabItems.tabWidth/2),
|
||||
e.clientY - Math.floor(TabItems.tabHeight/2),
|
||||
TabItems.tabWidth, TabItems.tabHeight);
|
||||
box.inset(-30, -30);
|
||||
|
||||
let opts = {immediately: true, bounds: box};
|
||||
let groupItem = new GroupItem([], opts);
|
||||
groupItem.newTab();
|
||||
|
||||
self._lastClick = 0;
|
||||
self._lastClickPositions = null;
|
||||
gTabView.firstUseExperienced = true;
|
||||
} else {
|
||||
self._lastClick = Date.now();
|
||||
self._lastClickPositions = new Point(e.clientX, e.clientY);
|
||||
self._createGroupItemOnDrag(e);
|
||||
}
|
||||
}
|
||||
if (e.originalTarget.id == "content" &&
|
||||
Utils.isLeftClick(e) &&
|
||||
e.detail == 1) {
|
||||
self._createGroupItemOnDrag(e);
|
||||
}
|
||||
});
|
||||
|
||||
iQ(gTabViewFrame.contentDocument).dblclick(function(e) {
|
||||
// Create a group with one tab on double click
|
||||
let box =
|
||||
new Rect(e.clientX - Math.floor(TabItems.tabWidth/2),
|
||||
e.clientY - Math.floor(TabItems.tabHeight/2),
|
||||
TabItems.tabWidth, TabItems.tabHeight);
|
||||
box.inset(-30, -30);
|
||||
|
||||
let opts = {immediately: true, bounds: box};
|
||||
let groupItem = new GroupItem([], opts);
|
||||
groupItem.newTab();
|
||||
|
||||
gTabView.firstUseExperienced = true;
|
||||
});
|
||||
|
||||
iQ(window).bind("unload", function() {
|
||||
self.uninit();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user