mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 628887 - When in an expanded stack, arrow keys should only move between those r=tim
This commit is contained in:
parent
4626384c45
commit
0283e446f8
@ -1130,18 +1130,26 @@ let UI = {
|
||||
function getClosestTabBy(norm) {
|
||||
if (!self.getActiveTab())
|
||||
return null;
|
||||
let centers =
|
||||
[[item.bounds.center(), item]
|
||||
for each(item in TabItems.getItems()) if (!item.parent || !item.parent.hidden)];
|
||||
let myCenter = self.getActiveTab().bounds.center();
|
||||
let matches = centers
|
||||
.filter(function(item){return norm(item[0], myCenter)})
|
||||
.sort(function(a,b){
|
||||
return myCenter.distance(a[0]) - myCenter.distance(b[0]);
|
||||
});
|
||||
if (matches.length > 0)
|
||||
return matches[0][1];
|
||||
return null;
|
||||
|
||||
let activeTab = self.getActiveTab();
|
||||
let activeTabGroup = activeTab.parent;
|
||||
let myCenter = activeTab.bounds.center();
|
||||
let match;
|
||||
|
||||
TabItems.getItems().forEach(function (item) {
|
||||
if (!item.parent.hidden &&
|
||||
(!activeTabGroup.expanded || activeTabGroup.id == item.parent.id)) {
|
||||
let itemCenter = item.bounds.center();
|
||||
|
||||
if (norm(itemCenter, myCenter)) {
|
||||
let itemDist = myCenter.distance(itemCenter);
|
||||
if (!match || match[0] > itemDist)
|
||||
match = [itemDist, item];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return match && match[1];
|
||||
}
|
||||
|
||||
let preventDefault = true;
|
||||
|
@ -120,6 +120,7 @@ _BROWSER_FILES = \
|
||||
browser_tabview_bug628061.js \
|
||||
browser_tabview_bug628165.js \
|
||||
browser_tabview_bug628270.js \
|
||||
browser_tabview_bug628887.js \
|
||||
browser_tabview_bug629189.js \
|
||||
browser_tabview_bug629195.js \
|
||||
browser_tabview_bug630102.js \
|
||||
|
@ -0,0 +1,50 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
newWindowWithTabView(function(win) {
|
||||
registerCleanupFunction(function() win.close());
|
||||
|
||||
let cw = win.TabView.getContentWindow();
|
||||
let groupItemOne = cw.GroupItems.groupItems[0];
|
||||
|
||||
let groupItemTwo = createGroupItemWithBlankTabs(win, 100, 100, 40, 2);
|
||||
ok(groupItemTwo.isStacked(), "groupItem is now stacked");
|
||||
|
||||
is(win.gBrowser.tabs.length, 3, "There are three tabs");
|
||||
|
||||
// the focus should remain within the group after it's expanded
|
||||
groupItemTwo.addSubscriber("expanded", function onExpanded() {
|
||||
groupItemTwo.removeSubscriber("expanded", onExpanded);
|
||||
|
||||
ok(groupItemTwo.expanded, "groupItemTwo is expanded");
|
||||
is(cw.UI.getActiveTab(), groupItemTwo.getChild(0),
|
||||
"The first tab item in group item two is active in expanded mode");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {}, cw);
|
||||
is(cw.UI.getActiveTab(), groupItemTwo.getChild(0),
|
||||
"The first tab item is still active after pressing down key");
|
||||
|
||||
// the focus should goes to other group if the down arrow is pressed
|
||||
groupItemTwo.addSubscriber("collapsed", function onExpanded() {
|
||||
groupItemTwo.removeSubscriber("collapsed", onExpanded);
|
||||
|
||||
ok(!groupItemTwo.expanded, "groupItemTwo is not expanded");
|
||||
is(cw.UI.getActiveTab(), groupItemTwo.getChild(0),
|
||||
"The first tab item is active in group item two in collapsed mode");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {}, cw);
|
||||
is(cw.UI.getActiveTab(), groupItemOne.getChild(0),
|
||||
"The first tab item in group item one is active after pressing down key");
|
||||
|
||||
finish();
|
||||
});
|
||||
|
||||
groupItemTwo.collapse();
|
||||
});
|
||||
|
||||
groupItemTwo.expand();
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user