Bug 403484 The ellipsis for UI should be localizable r=roc+mconnor, sr=roc, blocking1.9=mtschrep

This commit is contained in:
masayuki%d-toybox.com 2007-11-15 10:43:18 +00:00
Родитель 224c2a2668
Коммит c2080ed834
9 изменённых файлов: 51 добавлений и 19 удалений

Просмотреть файл

@ -1115,6 +1115,8 @@ public:
*/
static PRBool IsNativeAnonymous(nsIContent* aContent);
static const nsAdoptingString& GetLocalizedEllipsis();
private:

Просмотреть файл

@ -3720,6 +3720,19 @@ nsContentUtils::IsNativeAnonymous(nsIContent* aContent)
return PR_FALSE;
}
/* static */
const nsAdoptingString&
nsContentUtils::GetLocalizedEllipsis()
{
static nsAdoptingString sEllipsis;
if (sEllipsis.IsEmpty()) {
sEllipsis = GetLocalizedStringPref("intl.ellipsis");
if (sEllipsis.IsEmpty())
sEllipsis.Assign(PRUnichar(0x2026));
}
return sEllipsis;
}
/* static */
void
nsAutoGCRoot::Shutdown()

Просмотреть файл

@ -77,9 +77,6 @@
#include "nsBidiPresUtils.h"
#endif // IBMBIDI
// horizontal ellipsis (U+2026)
#define ELLIPSIS PRUnichar(0x2026)
#define CROP_LEFT "left"
#define CROP_RIGHT "right"
#define CROP_CENTER "center"
@ -627,14 +624,15 @@ nsTextBoxFrame::CalculateTitleForWidth(nsPresContext* aPresContext,
return; // fits, done.
}
const nsAdoptingString& kEllipsis = nsContentUtils::GetLocalizedEllipsis();
// start with an ellipsis
mCroppedTitle.Assign(ELLIPSIS);
mCroppedTitle.Assign(kEllipsis);
// see if the width is even smaller than the ellipsis
// if so, clear the text (XXX set as many '.' as we can?).
nscoord ellipsisWidth;
aRenderingContext.SetTextRunRTL(PR_FALSE);
aRenderingContext.GetWidth(ELLIPSIS, ellipsisWidth);
aRenderingContext.GetWidth(kEllipsis, ellipsisWidth);
if (ellipsisWidth > aWidth) {
mCroppedTitle.SetLength(0);
@ -773,11 +771,7 @@ nsTextBoxFrame::CalculateTitleForWidth(nsPresContext* aPresContext,
rightPos--;
}
// form the new cropped string
nsAutoString ellipsisString;
ellipsisString.Assign(ELLIPSIS);
mCroppedTitle = leftString + ellipsisString + rightString;
mCroppedTitle = leftString + kEllipsis + rightString;
}
break;
}
@ -786,6 +780,8 @@ nsTextBoxFrame::CalculateTitleForWidth(nsPresContext* aPresContext,
mCroppedTitle.get(), mCroppedTitle.Length());
}
#define OLD_ELLIPSIS NS_LITERAL_STRING("...")
// the following block is to append the accesskey to mTitle if there is an accesskey
// but the mTitle doesn't have the character
void
@ -819,7 +815,19 @@ nsTextBoxFrame::UpdateAccessTitle()
return;
}
PRInt32 offset = mTitle.RFind("...");
const nsAdoptingString& kEllipsis = nsContentUtils::GetLocalizedEllipsis();
PRInt32 offset = mTitle.RFind(kEllipsis);
if (offset == kNotFound) {
// Try to check with our old ellipsis (for old addons)
if (!kEllipsis.Equals(OLD_ELLIPSIS))
offset = mTitle.RFind(OLD_ELLIPSIS);
if (offset == kNotFound) {
// Try to check with our default ellipsis (for non-localized addons)
nsAutoString defaultEllipsis(PRUnichar(0x2026));
if (!kEllipsis.Equals(defaultEllipsis))
offset = mTitle.RFind(defaultEllipsis);
}
}
if (offset == kNotFound) {
offset = (PRInt32)mTitle.Length();
if (mTitle.Last() == PRUnichar(':'))

Просмотреть файл

@ -106,9 +106,6 @@
#include "nsBidiPresUtils.h"
#endif
// horizontal ellipsis (U+2026)
#define ELLIPSIS PRUnichar(0x2026)
static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID);
// Enumeration function that cancels all the image requests in our cache
@ -1343,15 +1340,16 @@ nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
if (width > maxWidth) {
// See if the width is even smaller than the ellipsis
// If so, clear the text completely.
const nsAdoptingString& kEllipsis = nsContentUtils::GetLocalizedEllipsis();
nscoord ellipsisWidth;
aRenderingContext.SetTextRunRTL(PR_FALSE);
aRenderingContext.GetWidth(ELLIPSIS, ellipsisWidth);
aRenderingContext.GetWidth(kEllipsis, ellipsisWidth);
width = maxWidth;
if (ellipsisWidth > width)
aText.SetLength(0);
else if (ellipsisWidth == width)
aText.Assign(ELLIPSIS);
aText.Assign(kEllipsis);
else {
// We will be drawing an ellipsis, thank you very much.
// Subtract out the required width of the ellipsis.
@ -1376,7 +1374,7 @@ nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
twidth += cwidth;
}
aText.Truncate(i);
aText.Append(ELLIPSIS);
aText.Append(kEllipsis);
}
break;
@ -1396,7 +1394,7 @@ nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
nsAutoString copy;
aText.Right(copy, length-1-i);
aText.Assign(ELLIPSIS);
aText.Assign(kEllipsis);
aText += copy;
}
break;
@ -1425,7 +1423,7 @@ nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
--rightPos;
}
aText = leftStr;
aText.Append(ELLIPSIS);
aText.Append(kEllipsis);
aText += rightStr;
}
break;

Просмотреть файл

@ -420,6 +420,7 @@ pref("intl.charsetmenu.browser.more5", "chrome://global/locale/intl.properties"
pref("intl.charsetmenu.browser.unicode", "chrome://global/locale/intl.properties");
pref("intl.charset.detector", "chrome://global/locale/intl.properties");
pref("intl.charset.default", "chrome://global-platform/locale/intl.properties");
pref("intl.ellipsis", "chrome://global-platform/locale/intl.properties");
pref("font.language.group", "chrome://global/locale/intl.properties");
pref("intl.menuitems.alwaysappendaccesskeys","chrome://global/locale/intl.properties");
pref("intl.menuitems.insertseparatorbeforeaccesskeys","chrome://global/locale/intl.properties");

Просмотреть файл

@ -818,6 +818,7 @@ pref("intl.charsetmenu.browser.cache.size", 5);
pref("intl.charset.detector", "chrome://navigator/locale/navigator.properties");
pref("intl.charset.default", "chrome://navigator-platform/locale/navigator.properties");
pref("intl.content.langcode", "chrome://communicator-region/locale/region.properties");
pref("intl.ellipsis", "chrome://global-platform/locale/intl.properties");
pref("intl.locale.matchOS", false);
// fallback charset list for Unicode conversion (converting from Unicode)
// currently used for mail send only to handle symbol characters (e.g Euro, trademark, smartquotes)

Просмотреть файл

@ -1,2 +1,5 @@
# moved from navigator/locale/navigator.properties
intl.charset.default=ISO-8859-1
# LOCALIZATION NOTE (intl.ellipsis): Use the unicode ellipsis char, \u2026,
# or use "..." unless \u2026 doesn't suit traditions in your locale.
intl.ellipsis=

Просмотреть файл

@ -1,2 +1,5 @@
# moved from navigator/locale/navigator.properties
intl.charset.default=ISO-8859-1
# LOCALIZATION NOTE (intl.ellipsis): Use the unicode ellipsis char, \u2026,
# or use "..." unless \u2026 doesn't suit traditions in your locale.
intl.ellipsis=

Просмотреть файл

@ -1,2 +1,5 @@
# moved from navigator/locale/navigator.properties
intl.charset.default=ISO-8859-1
# LOCALIZATION NOTE (intl.ellipsis): Use the unicode ellipsis char, \u2026,
# or use "..." unless \u2026 doesn't suit traditions in your locale.
intl.ellipsis=