Port bug 617528 from Firefox and make html5 context menus work in Thunderbird (important for Conversations)

RESOLVED FIXED in Thunderbird 11.0

Status

Thunderbird
Mail Window Front End
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: protz, Assigned: squib)

Tracking

Trunk
Thunderbird 11.0
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

6 years ago
If we are to move towards richer UIs (I'm thinking Conversations here) designed using HTML, a very easy way to handle context menus is the HTML5 contextmenu attribute. Firefox just implemented this, and I'd love to see this work in Thunderbird too: this would allow me to have a better context menu for conversations, possibly one with actions that operate on the whole conversation, one specific to each message, one specific for attachments.

This would also allow me to implement all the annoying options that users scream for, and bury them deep in a context menu, so that regular users, me included, don't have to see them. And that would make the users happy.
(Assignee)

Comment 1

6 years ago
I know that in content, HTML5 context menus add themselves as a submenu of the main context menu; is this any different in chrome? (I really really hope the answer is "yes".)
(Assignee)

Comment 2

6 years ago
Let me amend that to say "I think that in content...". Bug 617528 is far too long for me to read through all of it. :)
(Reporter)

Comment 3

6 years ago
In a chrome:// html page, the menu items also added themselves into the main context menu, as far as my testing could tell.

Comment 4

6 years ago
The implementation of HTML5 context menu is flexible in this case. A menu builder creates XUL menu items and keeps them in a document fragment, this fragment can be attached to any place in native XUL context menu.
(Assignee)

Comment 5

6 years ago
Taking this. I've got a patch for it, and I want it for Mail Summaries.
Assignee: nobody → squibblyflabbetydoo
Status: NEW → ASSIGNED
I think Jan will be more appropriate than me to comment on this bug: he wrote the HTML5 context menu patches.
For what I can judge, your patch seems ok. I think you can test it with a mochitest-chrome test. You should find some doc about that in MDN if you never wrote one.
(In reply to Mounir Lamouri (:volkmar) (:mounir) from comment #6)
> I think Jan will be more appropriate than me to comment on this bug: he
> wrote the HTML5 context menu patches.
> For what I can judge, your patch seems ok. I think you can test it with a
> mochitest-chrome test. You should find some doc about that in MDN if you
> never wrote one.

Ignore this comment, it was for bug 704428 :(
(Assignee)

Comment 8

6 years ago
Created attachment 576673 [details] [diff] [review]
Add the appropriate hooks

Here's a patch for this; note that we immediately close the context menu if no items were added to it. Otherwise, right clicking on something with no HTML5 context menu would cause (under Linux, anyway) an invisible context menu that gobbles up the next click event. No tests for this here, since I'll end up testing this in bug 489999 and bug 492158.

If you want to try it out, install the tip version of Mail Summaries[1]. This link should work if you rename it to something.xpi: https://bitbucket.org/squib/mail-summaries/get/dd85e57a399f.zip

[1] https://bitbucket.org/squib/mail-summaries
Attachment #576673 - Flags: review?(jonathan.protzenko)
(Reporter)

Comment 9

6 years ago
Ok, so this works. However, I don't think your patch does the right thing.

In Firefox, whenever an html5 element has a contextmenu attribute on it, the elements from the user-provided contextmenu are added to the already existing contextmenu, they're not replacing it as a whole. Your approach basically says: if there's a contextmenu on the element that's being right-clicked, discard the original context menu, just show the entries from the user-provided one.

Think about a page that has a contextmenu attribute on some <div>, and just adds a couple specific actions. I'm pretty sure the author doesn't want to see copy, select all, and the like (copy image url, copy image, save image as, copy email address, add to address book, compose message to, open link in browser, etc. etc.) disabled...

I think the "right" thing to do here is: if the user provides a specific html context menu, disable all selected-msgHdrs-related actions, and append the user-provided actions to the main context menu, so as not to lose all other potentially useful actions.

I'm speaking very much with Conversations in mind here, so my point of view may be biased. David, Mark, do you have any specific opinion on this?
(Reporter)

Updated

6 years ago
Attachment #576673 - Flags: feedback-
(Assignee)

Comment 10

6 years ago
Without this patch, there is no context menu on the multi-message or account central frames, period. I'm assuming this is something we want to continue, though maybe it's not so good for Conversations. I don't think the global context menu is particularly useful for the account summary or folder summary, and it's only slightly useful for the multi-message summary. For the account/folder summary in particular, I would prefer not to have "Select All", "Copy", etc, since I don't think they're very useful. I suppose I could be persuaded otherwise, though.

If just Conversations needs the extra items, we could probably do something to allow the SummaryFrameManager to change the XUL context menu for the entire frame.

One other thing I'd be worried about is what the global context menu would do on the old account central page. This won't be a problem when the account summary is finished, but I still haven't made an account summary page for NNTP or RSS.
(Reporter)

Comment 11

6 years ago
I'm asking because we'll have to consider as well what we're doing for content tabs that also provide html5 context menus.
(Assignee)

Comment 12

6 years ago
(In reply to Jonathan Protzenko [:protz] from comment #11)
> I'm asking because we'll have to consider as well what we're doing for
> content tabs that also provide html5 context menus.

That's a good point. This patch should probably support content tabs too. Luckily, this is easy, and we can keep it separate from the context menu for the accountCentralPane and the multimessage.
(Assignee)

Comment 13

6 years ago
Created attachment 578783 [details] [diff] [review]
Add pagemenu to the global context menu too.

Ok, this patch also supports the HTML5 context menu in content tabs. The easiest way to test this is to set mailnews.start_page.override_url to "https://bug617528.bugzilla.mozilla.org/attachment.cgi?id=554309".

If you think this needs tests, I can probably write some.
Attachment #576673 - Attachment is obsolete: true
Attachment #576673 - Flags: review?(jonathan.protzenko)
Attachment #578783 - Flags: review?(jonathan.protzenko)
(Reporter)

Comment 14

6 years ago
Comment on attachment 578783 [details] [diff] [review]
Add pagemenu to the global context menu too.

Review of attachment 578783 [details] [diff] [review]:
-----------------------------------------------------------------

The patch is correct and works fine (as far as I could tell). Is the shift key something you added, or was it designed like this in Firefox?

I'm ok with the patch but I do think it needs a test. There's everything ready in test-content-tab.js:100, including the right-click, and the assertions, so it should be real easy to test. Sorry if I'm insisting a little bit, but I think it can be easily regressed, if the Firefox guys decide to update their code without us noticing.

r=me assuming you add a couple tests

Thanks,

jonathan
Attachment #578783 - Flags: review?(jonathan.protzenko) → review+
(Assignee)

Comment 15

6 years ago
Try build for tests in progress (I'm not taking any chances this time, since I always seem to cause Mac failures when testing menus): http://build.mozillamessaging.com/tinderboxpushlog/?tree=ThunderbirdTry&rev=b3d4b90a5847
(Assignee)

Comment 16

6 years ago
Well, it's a good thing I pushed to try, since I missed an important part of the build config for this. The latest try build passes though, so checked in: http://hg.mozilla.org/comm-central/rev/6e7c802ef298
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 11.0
(Assignee)

Updated

6 years ago
Depends on: 720420
You need to log in before you can comment on or make changes to this bug.