Closed Bug 459729 Opened 11 years ago Closed 11 years ago

CreateTruncatedCocoaLabel function in MenuHelpersX not available in 64-bit

Categories

(Core :: Widget: Cocoa, defect)

x86_64
macOS
defect
Not set

Tracking

()

RESOLVED FIXED

People

(Reporter: hiller.moz, Assigned: jaas)

References

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1.16) Gecko/20080716 Firefox/2.0.0.16
Build Identifier: 

MenuHelpersX::CreateTruncatedCocoaLabel (in widget/src/cocoa/nsMenuX.mm) will truncate the label text of menus and menuitems if they are above a certain length. They do this via the TruncateThemeText carbon call (deprecated as of OS X 10.5). Apart from being deprecated, it appears that this call is unnecessary.

In a xulrunner build I have locally -- the actual app has some menu items with fairly long names, especially in some locales -- I've commented out the call to ::TruncateThemeText and cranked the resolution down to see what happens. It seems that Cocoa is smart enough to shorten menuitem labels and menu labels automatically -- via an ellipsis at the end of the label or mid-label -- if working with a screen resolution too small to fit everything in appropriately. No explicit calls to ::TruncateThemeText are necessary, and in fact, for me, they're harmful.

So it seems like CreateTruncatedCocoaLabel could be eliminated and calls made to it replaced with a call that converts the nsString label to an NSString* directly. I don't know enough about upstream dev practices to suggest a patch myself, though.

Thanks!

Reproducible: Always

Steps to Reproduce:
Create an application menu or menuitem with an unusually long label (> 300 pixels required to render)
Actual Results:  
The label is abbreviated with an ellipsis mid-label or at the end of the label, invariably

Expected Results:  
The label should be abbreviated with an ellipsis only if necessary, per screen resolution and menu geometry

My build machine is running OS 10.4. Whoever looks at this bug should probably confirm the behavior is the same in OS 10.5.
We need to take care of this for 64-bit.
Blocks: 468509
Hardware: PowerPC → x86_64
Version: unspecified → Trunk
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
If I remove truncation of menu item labels I don't see them getting truncated for us. We get some really long menu items, try bookmarking a page with a long title.

We might be able to use "NSLineBreakByTruncatingMiddle" and NSMenuItem's "setAttributedTitle:" as a replacement for "TruncateThemeText".
Summary: CreateTruncatedCocoaLabel function in MenuHelpersX uses deprecated API, perhaps obsolete → CreateTruncatedCocoaLabel function in MenuHelpersX not available in 64-bit
Attached patch fix v1.0Splinter Review
Turn off truncation for now, will file a new bug on adding that to 64-bit in the future. There is no good API for it on 64-bit that I know of.

Also fix up some memory mgmt stuff related to that function.
Attachment #374923 - Flags: review?(mstange)
Attachment #374923 - Flags: review?(mstange) → review+
Attachment #374923 - Flags: superreview?(roc)
Attachment #374923 - Flags: superreview?(roc) → superreview+
pushed to mozilla-central

http://hg.mozilla.org/mozilla-central/rev/3c1c49cf3fde
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.