Last Comment Bug 595654 - MultiMessageSummary and ThreadSummary should ensure multimessageview.xhtml is loaded before proceeding
: MultiMessageSummary and ThreadSummary should ensure multimessageview.xhtml is...
Status: RESOLVED FIXED
:
Product: Thunderbird
Classification: Client Software
Component: Message Reader UI (show other bugs)
: 3.1
: All All
: -- normal (vote)
: Thunderbird 11.0
Assigned To: Jim Porter (:squib)
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-09-12 08:44 PDT by Jonathan Protzenko [:protz]
Modified: 2011-12-02 17:07 PST (History)
4 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Add the SummaryFrameManager (3.21 KB, patch)
2011-11-12 23:20 PST, Jim Porter (:squib)
no flags Details | Diff | Review
Add missing file (7.64 KB, patch)
2011-11-17 01:17 PST, Jim Porter (:squib)
jonathan.protzenko: review+
Details | Diff | Review
Updated patch (7.49 KB, patch)
2011-11-22 18:34 PST, Jim Porter (:squib)
jonathan.protzenko: review+
Details | Diff | Review

Description Jonathan Protzenko [:protz] 2010-09-12 08:44:33 PDT
So I was working on "Thunderbird Conversations" the other day, and it turned out I had broken the MultiMessageSummary. Actually, I just realized that MultiMessageSummary assumes that the right URL is loaded in the multimessage pane, and proceeds without even checking that multimessageview.xhtml is actually loaded.

What I did was make a monkey-patch on top of the summarizeMultipleSelection function that first restores the right url before handing control flow over the original summarizeMultipleSelection once multimessageview.xhtml is loaded.

I think the original implementations of summarizeThread and summarizeMultipleSelection should take care of this. I don't think this is just a case of "patch Thunderbird to suit my needs", because I'm pretty sure the extension that does account summary and folder summary has to workaround this too, and this might simplify its life if it could just assume that whenever someones actually needs to display something in the multimessage pane, then that someone takes care of having the right URL loaded.

davida, mixedpuppy, thoughts?

(I have a patch waiting somewhere so if you think that's a good idea, I'll just assign to me and submit a patch as soon as I have a decent development environment and work machine).
Comment 1 Blake Winton (:bwinton) (:☕️) (PTO 'til London. Find me there for quick answers!) 2010-09-12 09:00:43 PDT
As the nominal owner of the Message Reader sub-module, this proposal makes sense to me, and I would love to see the patch when you get a chance to post it.

Thanks,
Blake.
Comment 2 Shane Caraveo (:mixedpuppy) [on leave 5/16-7/16] 2010-09-12 10:39:14 PDT
Lets see a patch, I'll look at how it affects the addons and whether there is something that would help it work for them.
Comment 3 Jim Porter (:squib) 2011-07-18 22:30:12 PDT
Hm, I bet this is really the "SummaryFrameManager" from bug 492158. Protz and I have discussed this recently, and I'm guessing that's the sort of thing he means in comment 0. Assuming that's the case, then I definitely agree that this would be nice.

The first step would probably be to see if the SummaryFrameManager can be used to make both Mail Summaries and Conversations happy.
Comment 4 Jonathan Protzenko [:protz] 2011-07-19 01:14:17 PDT
My current stance on this is: as soon as you land the SummaryFrameManager (maybe give me a heads up a couple days before you do), I'll make sure Conversations is compatible with it, and submit patches if it doesn't expose the required functionality. I'm all for landing the SummaryFrameManager in Thunderbird :-).
Comment 5 Jim Porter (:squib) 2011-11-12 23:20:10 PST
Created attachment 574127 [details] [diff] [review]
Add the SummaryFrameManager

Here's a patch to do this. I also set the nsMsgDBView to trigger a selection change event when entering a folder so that the summary code gets called then. This is necessary for the folder summary to load properly (previously, I used an annoying hack to make it happen in the add-on).

I've verified that this works with and without (a modified version of) the Mail Summaries add-on.
Comment 6 Jim Porter (:squib) 2011-11-17 01:17:12 PST
Created attachment 575115 [details] [diff] [review]
Add missing file

Hmm, it would help if I added the necessary files to the patch...
Comment 7 Jonathan Protzenko [:protz] 2011-11-19 12:52:27 PST
Comment on attachment 575115 [details] [diff] [review]
Add missing file

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

So the patch looks fine. I just gave it a try, and it works for me with a few minor changes in my code (that's cool). However, there's a few minor details that I think are worth ironing out.
- I'd like to be notified if the SummaryFrameManager had to actually change the URL before calling me. That's minor, however, and I can easily detect that myself by checking what is the current URL before calling loadAndCallback so I'm not sure it should be part of the API. What do you think?
- Do you think we should cancel a request to load something in the multimessage if the message pane is hidden, or is that something that we expect the clients to check for themselves? If I call window.gSummaryFrameManager.loadAndCallback with the multimessage hidden, it will un-hide it and confuse the command (need to hit F8 twice).

Apart from that, the patch looks fine enough. I still do think we should have a couple tests for that, though, esp. the thing in nsMsgDBView.cpp which, I suppose, allows you to show the Folder Summary easily when a folder is selected. So, r=me with the nits above fixed, and a proper test (even if it's a very small one, I wouldn't want this to regress).

::: mail/base/modules/summaryFrameManager.js
@@ +49,5 @@
> + * @param aFrame the iframe that we're managing
> + */
> +function SummaryFrameManager(aFrame) {
> +  this.iframe = aFrame;
> +  this.iframe.addEventListener("DOMContentLoaded", this._onLoad.bind(this),

So I know there's a reason why we need DOMContentLoaded and not "loaded", but I was unable to find it off the top of my head. Can you add a comment?

@@ +70,5 @@
> +  loadAndCallback: function(aUrl, aCallback) {
> +    this.url = aUrl;
> +    if (this.iframe.contentDocument.location.href != aUrl) {
> +      // We're changing the document -- so we need to set the src attribute,
> +      // and stash the callback that we want to call when it's done loading

This comment is in complete contradiction with what's happening in the code. You're not changing the src attribute.

@@ +99,5 @@
> +    try {
> +      if (!event.originalTarget.location ||
> +          event.originalTarget.location.href != this.url)
> +        return;
> +

Is it to catch other (unrelated) DOMContentLoaded events bubbling up the tree? If so, a comment would be appropriate I think :).
Comment 8 Jim Porter (:squib) 2011-11-19 15:38:09 PST
(In reply to Jonathan Protzenko [:protz] from comment #7)
> Comment on attachment 575115 [details] [diff] [review] [diff] [details] [review]
> Add missing file
> 
> Review of attachment 575115 [details] [diff] [review] [diff] [details] [review]:
> -----------------------------------------------------------------
> 
> So the patch looks fine. I just gave it a try, and it works for me with a
> few minor changes in my code (that's cool). However, there's a few minor
> details that I think are worth ironing out.
> - I'd like to be notified if the SummaryFrameManager had to actually change
> the URL before calling me. That's minor, however, and I can easily detect
> that myself by checking what is the current URL before calling
> loadAndCallback so I'm not sure it should be part of the API. What do you
> think?

That seems reasonable. We could just pass it as a parameter to the callback.

> - Do you think we should cancel a request to load something in the
> multimessage if the message pane is hidden, or is that something that we
> expect the clients to check for themselves? If I call
> window.gSummaryFrameManager.loadAndCallback with the multimessage hidden, it
> will un-hide it and confuse the command (need to hit F8 twice).

I don't see this when I try it. Right now, we need to load the multimessage page even when it's hidden so that the right thing is loaded when you unhide it. We could probably come up with a way to load the right page when unhiding too, but that would be more complicated.

> Apart from that, the patch looks fine enough. I still do think we should
> have a couple tests for that, though, esp. the thing in nsMsgDBView.cpp
> which, I suppose, allows you to show the Folder Summary easily when a folder
> is selected. So, r=me with the nits above fixed, and a proper test (even if
> it's a very small one, I wouldn't want this to regress).

Do you have any idea of how to test this without actually having the Folder Summary in the Thunderbird tree?
Comment 9 Jim Porter (:squib) 2011-11-22 18:10:25 PST
Hm, it looks like the nsMsgDBView.cpp part breaks the folder summary for virtual folders. Since that's only needed for the folder summary, I'll probably wait on that bit and handle it in bug 492158. Then I can hopefully get help from some folder guru to figure out the best way of doing that. :)
Comment 10 Jim Porter (:squib) 2011-11-22 18:34:19 PST
Created attachment 576384 [details] [diff] [review]
Updated patch

Just asking for review again to make sure the "did the document change" argument to the callback will work for Conversations.
Comment 11 Jonathan Protzenko [:protz] 2011-11-27 12:34:42 PST
Comment on attachment 576384 [details] [diff] [review]
Updated patch

I just tried this and it works fine.

Sorry for the delay, I tend to be real busy these days, and I usually have to wait until the week-end for reviews.
Comment 12 Jim Porter (:squib) 2011-12-02 17:07:53 PST
Checked in: http://hg.mozilla.org/comm-central/rev/f1cec15376be

Existing tests should cover this, but be on the lookout if anything bad happens. I've run with this patch for a week or so now and things look good here.

Note You need to log in before you can comment on or make changes to this bug.