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

This commit is contained in:
masayuki@d-toybox.com 2007-11-19 02:17:17 -08:00
Родитель c724dec6e0
Коммит b66ba0396a
8 изменённых файлов: 55 добавлений и 19 удалений

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

@ -1121,6 +1121,11 @@ public:
*/
static nsIWidget* GetTopLevelWidget(nsIWidget* aWidget);
/**
* Return the localized ellipsis for UI.
*/
static const nsDependentString GetLocalizedEllipsis();
private:
static PRBool InitializeEventTable();

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

@ -3737,6 +3737,21 @@ nsContentUtils::GetTopLevelWidget(nsIWidget* aWidget)
return currWidget;
}
/* static */
const nsDependentString
nsContentUtils::GetLocalizedEllipsis()
{
static PRUnichar sBuf[4] = { 0, 0, 0, 0 };
if (!sBuf[0]) {
nsAutoString tmp(GetLocalizedStringPref("intl.ellipsis"));
PRUint32 len = PR_MIN(tmp.Length(), NS_ARRAY_LENGTH(sBuf) - 1);
CopyUnicodeTo(tmp, 0, sBuf, len);
if (!sBuf[0])
sBuf[0] = PRUnichar(0x2026);
}
return nsDependentString(sBuf);
}
/* 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 nsDependentString 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 nsDependentString 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 nsDependentString 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;

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

@ -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=