Closed Bug 892463 Opened 11 years ago Closed 11 years ago

Australis menu panel right click overriding addon context menus

Categories

(Firefox :: Toolbars and Customization, defect)

25 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 28

People

(Reporter: uy2251+bugzilla, Assigned: Gijs)

References

Details

(Whiteboard: [Australis:M8][Australis:P2])

Attachments

(3 files, 2 obsolete files)

Steps To Reproduce 1. Place addon in australis menu panel 2. Right click on addon for context menu Expected Result 3. Addon context menu should appear with customization menuitems appended to list Actual Result 3. Menu panel customization menu appears
Blocks: 870471
Whiteboard: [Australis:M?]
Can you give an example add-on with which we can test this? Thank you! :-)
Flags: needinfo?(uy2251+bugzilla)
Whiteboard: [Australis:M?] → [Australis:M?][Australis:P2]
I noticed this with the x-notifier addon.
Flags: needinfo?(uy2251+bugzilla)
Attached image Screenshot of addon outside menupanel (deleted) —
Attached image Scrrenshot of addon inside menupanel (deleted) —
This was my first shot. It... looks like it works? Somewhat surprisingly? Jared, what do you think?
Attachment #777067 - Flags: review?(jaws)
Assignee: nobody → gijskruitbosch+bugs
Comment on attachment 777067 [details] [diff] [review] should modify add-on context menu, not replace it How will this behave when add-ons populate their menus on the fly when opening them?
(In reply to Dão Gottwald [:dao] from comment #6) > Comment on attachment 777067 [details] [diff] [review] > should modify add-on context menu, not replace it > > How will this behave when add-ons populate their menus on the fly when > opening them? That would depend on how they populate the menus. If the menu doesn't exist at all, we will replace the context property. If it does exist but it's empty and/or they append items, our items might end up on (or closer to) the top. I mean, as far as I'm concerned we can't really fix this perfectly, considering add-ons can pretty much do anything. Do you think I should follow a different approach? If so, what do you have in mind?
If we can't do it reliably, the best option might be to just leave external menus alone. Maybe provide some hook for add-ons to add the items themselves.
(In reply to Dão Gottwald [:dao] from comment #8) > If we can't do it reliably, the best option might be to just leave external > menus alone. Maybe provide some hook for add-ons to add the items themselves. I'm not sure we should let the perfect be the enemy of the good here. It will work well for 90% of cases, less well for the rest, but I don't see how this would completely break add-ons' context menus - and the 10% is totally fixable by the add-ons themselves, even if they add items dynamically. I think I would prefer offering our menu for the majority of such add-on icons rather than having it be an opt-in thing for *all* add-ons to have to put work into in order to "play nice" in Australis. If we can make this transition easier for most add-ons, we should take that opportunity.
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #777067 - Flags: review?(jaws) → review?(mconley)
Comment on attachment 777067 [details] [diff] [review] should modify add-on context menu, not replace it Review of attachment 777067 [details] [diff] [review]: ----------------------------------------------------------------- Stealing this back as I see mconley's review queue is quite worrisome. ::: browser/components/customizableui/src/CustomizableUI.jsm @@ +407,5 @@ > } > }, > > ensureButtonContextMenu: function(aNode, ourContextMenu) { > + let currentCtxt = aNode.getAttribute("context") || s/currentCtxt/currentContextMenu/ because characters are cheap and it makes reading the code a bit easier. @@ +440,5 @@ > + } > + > + let ourMenu = doc.getElementById(kCustomizationContextMenu); > + let ourSeparator = doc.createElement("menuseparator"); > + ourSeparator.id = aMenu + kCustomizeMenuSeparator; Do we need to add some randomness to this? I imagine that many add-on context menus may just use some default ID (or none at all) and thus this will give us collisions on the ID. Maybe store a random string on menuToModify that can also be used in removeCustomizeMenuitems?
Attachment #777067 - Flags: review?(mconley) → review+
(In reply to Jared Wein [:jaws] from comment #10) > @@ +440,5 @@ > > + } > > + > > + let ourMenu = doc.getElementById(kCustomizationContextMenu); > > + let ourSeparator = doc.createElement("menuseparator"); > > + ourSeparator.id = aMenu + kCustomizeMenuSeparator; > > Do we need to add some randomness to this? I imagine that many add-on > context menus may just use some default ID (or none at all) and thus this > will give us collisions on the ID. Maybe store a random string on > menuToModify that can also be used in removeCustomizeMenuitems? Funny you should suggest that, because I initially did this, but then I removed it again. The thing is, context menu attributes work by IDs of the menus that they ought to be showing. If there were multiple identical IDs, things would already be broken for such add-ons (one would have the other's context menu). Does that make sense and can I push this with just the other nit fixed? :-)
Comment on attachment 777067 [details] [diff] [review] should modify add-on context menu, not replace it (In reply to :Gijs Kruitbosch from comment #9) > (In reply to Dão Gottwald [:dao] from comment #8) > > If we can't do it reliably, the best option might be to just leave external > > menus alone. Maybe provide some hook for add-ons to add the items themselves. > > I'm not sure we should let the perfect be the enemy of the good here. It > will work well for 90% of cases, less well for the rest, but I don't see how > this would completely break add-ons' context menus It can quite easily break add-ons' context menus. For instance, a common pattern that we use ourselves is to add a command event listener to a menupopup that would do the right thing for our own items but not for items others would inject unaskedly without special care for how our menu works.
Attachment #777067 - Flags: review-
OK, so here's an alternative. Let's not override the menu at all, and add-ons will have to add the contextmenu themselves, because even when my original approach worked, it'd still easily cause issues with conflicting access keys; it's probably better to have add-ons add these menuitems themselves.
Attachment #778377 - Flags: review?(dao)
Attachment #777067 - Attachment is obsolete: true
(In reply to :Gijs Kruitbosch from comment #13) > Created attachment 778377 [details] [diff] [review] > Australis menupanel contextmenu shouldn't override add-on contextmenu > > OK, so here's an alternative. Let's not override the menu at all, and > add-ons will have to add the contextmenu themselves, because even when my > original approach worked, it'd still easily cause issues with conflicting > access keys; it's probably better to have add-ons add these menuitems > themselves. I think this is a reasonable compromise because users will have a readily available method to customize and remove items using the customize button and overriding addon menu seems to complicate the code unnecessarily.
Comment on attachment 778377 [details] [diff] [review] Australis menupanel contextmenu shouldn't override add-on contextmenu > ensureButtonContextMenu: function(aNode, ourContextMenu) { >+ let currentContextMenu = aNode.getAttribute("context") || >+ aNode.getAttribute("contextmenu"); >+ if (ourContextMenu && !currentContextMenu) { > aNode.setAttribute("context", kCustomizationContextMenu); >+ } else if (currentContextMenu == kCustomizationContextMenu) { >+ aNode.removeAttribute("context"); > } > }, "ourContextMenu" is confusing. Can you rename it such that it's clearly a boolean value meant to determine whether the context menu should be added or removed? Also add the "a" prefix while you're at it. It looks like you might enter the else branch when you shouldn't. How about: if (ourContextMenu) { if (!currentContextMenu) aNode.setAttribute("context", kCustomizationContextMenu); } else ...
Characters were cheap, I was told... :-)
Attachment #778398 - Flags: review?(dao)
Attachment #778377 - Attachment is obsolete: true
Attachment #778377 - Flags: review?(dao)
Comment on attachment 778398 [details] [diff] [review] Australis menupanel contextmenu shouldn't override add-on contextmenu >+ ensureButtonContextMenu: function(aNode, aShouldHaveCustomizationMenu) { >+ let currentContextMenu = aNode.getAttribute("context") || >+ aNode.getAttribute("contextmenu"); >+ if (aShouldHaveCustomizationMenu) { >+ if (!currentContextMenu) >+ aNode.setAttribute("context", kCustomizationContextMenu); >+ } else if (currentContextMenu == kCustomizationContextMenu) { >+ aNode.removeAttribute("context"); > } might be even easier to follow if you write it like this: ... } else { if (currentContextMenu == kCustomizationContextMenu) aNode.removeAttribute("context"); }
Attachment #778398 - Flags: review?(dao) → review+
(In reply to Dão Gottwald [:dao] from comment #17) > might be even easier to follow if you write it like this: > > ... > } else { > if (currentContextMenu == kCustomizationContextMenu) > aNode.removeAttribute("context"); > } Pushed with that change made. https://hg.mozilla.org/projects/ux/rev/47d9faf1a4be
Whiteboard: [Australis:M?][Australis:P2] → [Australis:M8][Australis:P2][fixed-in-ux]
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [Australis:M8][Australis:P2][fixed-in-ux] → [Australis:M8][Australis:P2]
Target Milestone: --- → Firefox 28
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: