diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 21108b4e543e..c3784e112993 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -336,6 +336,7 @@ @RESPATH@/res/fonts/* @RESPATH@/res/dtd/* @RESPATH@/res/language.properties +@RESPATH@/res/locale/layout/HtmlForm.properties #ifdef XP_MACOSX @RESPATH@/res/MainMenu.nib/ #endif diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 462892d2cc41..f6420f432900 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -3560,7 +3560,7 @@ void nsContentUtils::GetEventArgNames(int32_t aNameSpaceID, nsAtom* aEventName, // Note: The list of content bundles in nsStringBundle.cpp should be updated // whenever entries are added or removed from this list. -static const char gPropertiesFiles[nsContentUtils::PropertiesFile_COUNT][56] = { +static const char* gPropertiesFiles[nsContentUtils::PropertiesFile_COUNT] = { // Must line up with the enum values in |PropertiesFile| enum. "chrome://global/locale/css.properties", "chrome://global/locale/xbl.properties", @@ -3575,7 +3575,9 @@ static const char gPropertiesFiles[nsContentUtils::PropertiesFile_COUNT][56] = { "chrome://global/locale/commonDialogs.properties", "chrome://global/locale/mathml/mathml.properties", "chrome://global/locale/security/security.properties", - "chrome://necko/locale/necko.properties"}; + "chrome://necko/locale/necko.properties", + "chrome://global/locale/layout/HtmlForm.properties", + "resource://gre/res/locale/layout/HtmlForm.properties"}; /* static */ nsresult nsContentUtils::EnsureStringBundle(PropertiesFile aFile) { @@ -3624,10 +3626,22 @@ void nsContentUtils::AsyncPrecreateStringBundles() { } } +static bool SpoofLocaleEnglish() { + // 0 - will prompt + // 1 - don't spoof + // 2 - spoof + return StaticPrefs::privacy_spoof_english() == 2; +} + /* static */ nsresult nsContentUtils::GetLocalizedString(PropertiesFile aFile, const char* aKey, nsAString& aResult) { + // When we spoof English, use en-US default strings in HTML forms. + if (aFile == eFORMS_PROPERTIES_MAYBESPOOF && SpoofLocaleEnglish()) { + aFile = eFORMS_PROPERTIES_en_US; + } + nsresult rv = EnsureStringBundle(aFile); NS_ENSURE_SUCCESS(rv, rv); nsIStringBundle* bundle = sStringBundles[aFile]; @@ -3638,6 +3652,11 @@ nsresult nsContentUtils::GetLocalizedString(PropertiesFile aFile, nsresult nsContentUtils::FormatLocalizedString( PropertiesFile aFile, const char* aKey, const nsTArray& aParams, nsAString& aResult) { + // When we spoof English, use en-US default strings in HTML forms. + if (aFile == eFORMS_PROPERTIES_MAYBESPOOF && SpoofLocaleEnglish()) { + aFile = eFORMS_PROPERTIES_en_US; + } + nsresult rv = EnsureStringBundle(aFile); NS_ENSURE_SUCCESS(rv, rv); nsIStringBundle* bundle = sStringBundles[aFile]; @@ -5124,11 +5143,13 @@ nsIWidget* nsContentUtils::GetTopLevelWidget(nsIWidget* aWidget) { const nsDependentString nsContentUtils::GetLocalizedEllipsis() { static char16_t sBuf[4] = {0, 0, 0, 0}; if (!sBuf[0]) { - nsAutoString tmp; - Preferences::GetLocalizedString("intl.ellipsis", tmp); - uint32_t len = - std::min(uint32_t(tmp.Length()), uint32_t(ArrayLength(sBuf) - 1)); - CopyUnicodeTo(tmp, 0, sBuf, len); + if (!SpoofLocaleEnglish()) { + nsAutoString tmp; + Preferences::GetLocalizedString("intl.ellipsis", tmp); + uint32_t len = + std::min(uint32_t(tmp.Length()), uint32_t(ArrayLength(sBuf) - 1)); + CopyUnicodeTo(tmp, 0, sBuf, len); + } if (!sBuf[0]) sBuf[0] = char16_t(0x2026); } return nsDependentString(sBuf); diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index d48e1a9350c7..aa5d53259726 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -1101,6 +1101,8 @@ class nsContentUtils { eMATHML_PROPERTIES, eSECURITY_PROPERTIES, eNECKO_PROPERTIES, + eFORMS_PROPERTIES_MAYBESPOOF, + eFORMS_PROPERTIES_en_US, PropertiesFile_COUNT }; static nsresult ReportToConsole( diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index e6802acc037b..ff543b391b8e 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -725,15 +725,15 @@ nsresult HTMLInputElement::InitFilePicker(FilePickerType aType) { nsAutoString title; nsAutoString okButtonLabel; if (aType == FILE_PICKER_DIRECTORY) { - nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - "DirectoryUpload", title); + nsContentUtils::GetLocalizedString( + nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "DirectoryUpload", title); - nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - "DirectoryPickerOkButtonLabel", - okButtonLabel); + nsContentUtils::GetLocalizedString( + nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, + "DirectoryPickerOkButtonLabel", okButtonLabel); } else { - nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - "FileUpload", title); + nsContentUtils::GetLocalizedString( + nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "FileUpload", title); } nsCOMPtr filePicker = @@ -2333,21 +2333,24 @@ void HTMLInputElement::GetDisplayFileName(nsAString& aValue) const { if ((StaticPrefs::dom_input_dirpicker() && Allowdirs()) || (StaticPrefs::dom_webkitBlink_dirPicker_enabled() && HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory))) { - nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - "NoDirSelected", value); + nsContentUtils::GetLocalizedString( + nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "NoDirSelected", value); } else if (HasAttr(kNameSpaceID_None, nsGkAtoms::multiple)) { - nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - "NoFilesSelected", value); + nsContentUtils::GetLocalizedString( + nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "NoFilesSelected", + value); } else { - nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - "NoFileSelected", value); + nsContentUtils::GetLocalizedString( + nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "NoFileSelected", + value); } } else { nsString count; count.AppendInt(int(mFileData->mFilesOrDirectories.Length())); nsContentUtils::FormatLocalizedString( - value, nsContentUtils::eFORMS_PROPERTIES, "XFilesSelected", count); + value, nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "XFilesSelected", + count); } aValue = value; @@ -5776,8 +5779,8 @@ HTMLInputElement::SubmitNamesValues(HTMLFormSubmission* aFormSubmission) { !HasAttr(kNameSpaceID_None, nsGkAtoms::value)) { // Get our default value, which is the same as our default label nsAutoString defaultValue; - nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - "Submit", defaultValue); + nsContentUtils::GetLocalizedString( + nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "Submit", defaultValue); value = defaultValue; } diff --git a/dom/locales/moz.build b/dom/locales/moz.build index 1734739c5426..b2bcd271de7c 100644 --- a/dom/locales/moz.build +++ b/dom/locales/moz.build @@ -59,3 +59,7 @@ with Files("en-US/chrome/plugins.properties"): BUG_COMPONENT = ("Core", "Plug-ins") JAR_MANIFESTS += ['jar.mn'] + +RESOURCE_FILES.locale.layout += [ + 'en-US/chrome/layout/HtmlForm.properties', +] diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 130288e889a6..5f041d5447f7 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -1649,8 +1649,8 @@ already_AddRefed nsCSSFrameConstructor::CreateGeneratedContent( } nsAutoString temp; - nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - "Submit", temp); + nsContentUtils::GetLocalizedString( + nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "Submit", temp); return CreateGenConTextNode(aState, temp, nullptr); } @@ -7956,8 +7956,8 @@ void nsCSSFrameConstructor::GetAlternateTextFor(Element* aElement, nsAtom* aTag, // If there's no "value" attribute either, then use the localized string for // "Submit" as the alternate text. - nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - "Submit", aAltText); + nsContentUtils::GetLocalizedString( + nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "Submit", aAltText); } } diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index 804822184028..6711904d380a 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -215,8 +215,8 @@ static already_AddRefed MakeAnonButton(Document* aDoc, // Set the file picking button text depending on the current locale. nsAutoString buttonTxt; - nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - labelKey, buttonTxt); + nsContentUtils::GetLocalizedString( + nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, labelKey, buttonTxt); // Set the browse button text. It's a bit of a pain to do because we want to // make sure we are not notifying. diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp index a35765a2cb5e..03186ef7bf54 100644 --- a/layout/forms/nsGfxButtonControlFrame.cpp +++ b/layout/forms/nsGfxButtonControlFrame.cpp @@ -88,8 +88,8 @@ nsresult nsGfxButtonControlFrame::GetDefaultLabel(nsAString& aString) const { return NS_OK; } - return nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - prop, aString); + return nsContentUtils::GetLocalizedString( + nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, prop, aString); } nsresult nsGfxButtonControlFrame::GetLabel(nsString& aLabel) { diff --git a/layout/generic/DetailsFrame.cpp b/layout/generic/DetailsFrame.cpp index 9f4e909f3952..e1a9f0c70b2b 100644 --- a/layout/generic/DetailsFrame.cpp +++ b/layout/generic/DetailsFrame.cpp @@ -98,8 +98,9 @@ nsresult DetailsFrame::CreateAnonymousContent( mDefaultSummary = new HTMLSummaryElement(nodeInfo.forget()); nsAutoString defaultSummaryText; - nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - "DefaultSummary", defaultSummaryText); + nsContentUtils::GetLocalizedString( + nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "DefaultSummary", + defaultSummaryText); RefPtr description = new nsTextNode(nodeInfoManager); description->SetText(defaultSummaryText, false); mDefaultSummary->AppendChildTo(description, false); diff --git a/mobile/android/installer/package-manifest.in b/mobile/android/installer/package-manifest.in index 241e17045633..0dc95d91ac76 100644 --- a/mobile/android/installer/package-manifest.in +++ b/mobile/android/installer/package-manifest.in @@ -204,6 +204,7 @@ @BINPATH@/res/grabber.gif @BINPATH@/res/dtd/* @BINPATH@/res/language.properties +@BINPATH@/res/locale/layout/HtmlForm.properties #ifndef MOZ_ANDROID_EXCLUDE_FONTS @BINPATH@/res/fonts/*