Last Comment Bug 767323 - Ampersands don't appear in the windows biff icon tooltip
: Ampersands don't appear in the windows biff icon tooltip
Status: RESOLVED FIXED
:
Product: MailNews Core
Classification: Components
Component: Backend (show other bugs)
: Trunk
: x86_64 Windows 7
: -- minor (vote)
: Thunderbird 16.0
Assigned To: neil@parkwaycc.co.uk
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-22 04:32 PDT by neil@parkwaycc.co.uk
Modified: 2012-09-26 03:54 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Proposed patch (2.99 KB, patch)
2012-06-22 05:21 PDT, neil@parkwaycc.co.uk
mozilla: review+
Details | Diff | Splinter Review

Description neil@parkwaycc.co.uk 2012-06-22 04:32:08 PDT
I happened to notice a feed in my biff icon tooltip. However the name of the account, "Blogs & News Feeds" had been corrupted - the ampersand was missing.

A search turned up the problem was a "feature" of tooltips - they delete ampersands because people writing for native Win32 use the same string for a control's label as for its tooltip, so they want the ampersand removed.

There is a way to disable this for a custom tooltip, but we're stuck with the default tooltip created by Windows Explorer.
Comment 1 neil@parkwaycc.co.uk 2012-06-22 04:39:44 PDT
OK, so the rule is a little more complicated than that.

The tooltip code removes one & from any run of &s.
However the underlining code also affects the display.
It allows you to quote an & with another &.
So in all you need 2n+1 &s for each run of &s.

Input	Display*
&	
&&	_
&&&	&
&&&&	&_
&&&&&	&&
&&&&&&	&&_
&&&&&&&	&&&

*Only the last "single" & actually underlines the next character.
Comment 2 neil@parkwaycc.co.uk 2012-06-22 05:12:50 PDT
To test biff, I open a folder (not an account) and evaluate (on one line):
top.opener.msgWindow.openFolder.server.performingBiff = true;
var Ci = Components.interfaces;
var mwi = Components.classes['@mozilla.org/messenger/osintegration;1']
                   .getService(Ci.nsIFolderListener);
mwi.OnItemIntPropertyChanged(top.opener.msgWindow.openFolder.parent,
                             "BiffState",
                             Ci.nsIMsgFolder.nsMsgBiffState_NewMail,
                             Ci.nsIMsgFolder.nsMsgBiffState_NoMail);
mwi.OnItemIntPropertyChanged(top.opener.msgWindow.openFolder.parent,
                             "BiffState",
                             Ci.nsIMsgFolder.nsMsgBiffState_NoMail,
                             Ci.nsIMsgFolder.nsMsgBiffState_NewMail);
Comment 3 neil@parkwaycc.co.uk 2012-06-22 05:21:15 PDT
Created attachment 635699 [details] [diff] [review]
Proposed patch

I decided to fix the hard case with multiple ampersands, just in case ;-)

After replacing single ampersands with three, I then search for six ampersands, which must come from (part of) a run of ampersands. I delete one, then skip two, so that I delete one in every three as long as there are at least six.

2 -> 6 -> 5 (less than 6, so stop)
3 -> 9 -> 2 + 6 -> 2 + 5 (less than 6, so stop) -> 7
4 -> 12 -> 2 + 9 -> 2 + 2 + 6 -> 2 + 2 + 5 -> 9 etc.

Of course, only when we have properly escaped the string can we actually check whether it will fit in the notification buffer.
Comment 4 David :Bienvenu 2012-06-25 15:49:37 PDT
Comment on attachment 635699 [details] [diff] [review]
Proposed patch

you could make the function static, since it's fairly specific to this file...
Comment 5 neil@parkwaycc.co.uk 2012-06-26 01:36:35 PDT
Pushed comm-central changeset 7198d5992627.
Comment 6 neil@parkwaycc.co.uk 2012-07-02 09:52:15 PDT
Oops, why did I forgot to mark this as FIXED?

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