Comment 13 for bug 301054

Revision history for this message
In , Will Martin (public-atuan) wrote :

Created an attachment (id=244634)
Checks length of string value and sets multiline attib if needed

Okay, I've spent some time wading through the JavaScript in metaData.js. Here's a new patch, invalidating the old. Instead of setting the multiline attribute manually in metaData.xul, this one sets the attribute conditionally. If the value to be inserted is longer than 55 characters, then the JS sets the appropriate node in the XUL to multiline="true".

Advantages:
- Long text in alt/description/etc wraps.
- Long URLs with no good break-point get a horizontal scroll bar.
- No ugly white-space issue with shorter URLs.

However, it's not perfect. 55 characters is an estimate. I just found a long string and counted how many characters before it wrapped (58) and then tweaked it down a little bit to be on the conservative side. But the font is proportional - not all the characters are the same width. So in some rare cases right on the border, there may be elements that get a multiline setting but don't need it, and vice versa. In order to be perfect, I would need to figure out some way of determining whether a particular string is long enough to need wrapping, and I don't know any good way to do that.

I think that's a really minor issue, though. For the vast majority of cases, this should do it.