mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 993407 - Always show link tab as default in context menus. r=bnicholson
This commit is contained in:
parent
fff8083009
commit
f681294454
@ -2110,6 +2110,11 @@ var NativeWindow = {
|
||||
else this._targetRef = null;
|
||||
},
|
||||
|
||||
get defaultContext() {
|
||||
delete this.defaultContext;
|
||||
return this.defaultContext = Strings.browser.GetStringFromName("browser.menu.context.default");
|
||||
},
|
||||
|
||||
/* Gets menuitems for an arbitrary node
|
||||
* Parameters:
|
||||
* element - The element to look at. If this element has a contextmenu attribute, the
|
||||
@ -2191,7 +2196,7 @@ var NativeWindow = {
|
||||
} catch(ex) { }
|
||||
|
||||
// Fallback to the default
|
||||
return Strings.browser.GetStringFromName("browser.menu.context.default");
|
||||
return this.defaultContext;
|
||||
},
|
||||
|
||||
// Adds context menu items added through the add-on api
|
||||
@ -2299,7 +2304,7 @@ var NativeWindow = {
|
||||
let context = this._getContextType(element);
|
||||
|
||||
// First check for any html5 context menus that might exist...
|
||||
var items = this._getHTMLContextMenuItemsForElement(element);
|
||||
let items = this._getHTMLContextMenuItemsForElement(element);
|
||||
if (items.length > 0) {
|
||||
this._addMenuItems(items, context);
|
||||
}
|
||||
@ -2346,7 +2351,8 @@ var NativeWindow = {
|
||||
*/
|
||||
_reformatList: function(target) {
|
||||
let contexts = Object.keys(this.menus);
|
||||
if (contexts.length == 1) {
|
||||
|
||||
if (contexts.length === 1) {
|
||||
// If there's only one context, we'll only show a single flat single select list
|
||||
return this._reformatMenuItems(target, this.menus[contexts[0]]);
|
||||
}
|
||||
@ -2365,12 +2371,24 @@ var NativeWindow = {
|
||||
*/
|
||||
_reformatListAsTabs: function(target, menus) {
|
||||
let itemArray = [];
|
||||
for (let context in menus) {
|
||||
|
||||
// Sort the keys so that "link" is always first
|
||||
let contexts = Object.keys(this.menus);
|
||||
contexts.sort((context1, context2) => {
|
||||
if (context1 === this.defaultContext) {
|
||||
return -1;
|
||||
} else if (context2 === this.defaultContext) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
contexts.forEach(context => {
|
||||
itemArray.push({
|
||||
label: context,
|
||||
items: this._reformatMenuItems(target, menus[context])
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return itemArray;
|
||||
},
|
||||
@ -8394,8 +8412,11 @@ HTMLContextMenuItem.prototype = Object.create(ContextMenuItem.prototype, {
|
||||
}
|
||||
|
||||
var items = NativeWindow.contextmenus._getHTMLContextMenuItemsForMenu(elt, target);
|
||||
|
||||
// This menu will always only have one context, but we still make sure its the "right" one.
|
||||
var context = NativeWindow.contextmenus._getContextType(target);
|
||||
if (items.length > 0) {
|
||||
NativeWindow.contextmenus._addMenuItems(items, "link");
|
||||
NativeWindow.contextmenus._addMenuItems(items, context);
|
||||
}
|
||||
|
||||
} catch(ex) {
|
||||
|
Loading…
Reference in New Issue
Block a user