From e717d9b1f9220794a61fa020e86b5c03af975147 Mon Sep 17 00:00:00 2001 From: "neil%parkwaycc.co.uk" Date: Tue, 18 Jan 2005 23:46:59 +0000 Subject: [PATCH] Bug 276002 Change nsContenUtils::Get/FormatLocalizedString to use nsXPIDLString to save on nsAutoString copies r=dbaron sr=bryner git-svn-id: svn://10.0.0.236/trunk@167959 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/public/nsContentUtils.h | 4 ++-- mozilla/content/base/src/nsContentUtils.cpp | 24 +++++++------------ mozilla/layout/base/nsCSSFrameConstructor.cpp | 8 +++---- mozilla/layout/base/nsCSSFrameConstructor.h | 6 ++--- mozilla/layout/base/nsDocumentViewer.cpp | 2 +- mozilla/layout/forms/nsFileControlFrame.cpp | 2 +- .../layout/forms/nsGfxButtonControlFrame.cpp | 7 +++--- .../layout/forms/nsGfxButtonControlFrame.h | 2 +- mozilla/layout/forms/nsIsIndexFrame.cpp | 2 +- mozilla/layout/generic/nsImageFrame.cpp | 2 +- .../layout/generic/nsSimplePageSequence.cpp | 6 ++--- mozilla/layout/printing/nsPrintEngine.cpp | 2 +- 12 files changed, 30 insertions(+), 37 deletions(-) diff --git a/mozilla/content/base/public/nsContentUtils.h b/mozilla/content/base/public/nsContentUtils.h index 27cc99550bf..572e0e34483 100644 --- a/mozilla/content/base/public/nsContentUtils.h +++ b/mozilla/content/base/public/nsContentUtils.h @@ -499,7 +499,7 @@ public: */ static nsresult GetLocalizedString(PropertiesFile aFile, const char* aKey, - nsString& aResult); + nsXPIDLString& aResult); /** * Fill (with the parameters given) the localized string named |aKey| in @@ -509,7 +509,7 @@ public: const char* aKey, const PRUnichar **aParams, PRUint32 aParamsLength, - nsString& aResult); + nsXPIDLString& aResult); private: diff --git a/mozilla/content/base/src/nsContentUtils.cpp b/mozilla/content/base/src/nsContentUtils.cpp index 406a218a36f..084bfd15594 100644 --- a/mozilla/content/base/src/nsContentUtils.cpp +++ b/mozilla/content/base/src/nsContentUtils.cpp @@ -2238,18 +2238,14 @@ nsContentUtils::EnsureStringBundle(PropertiesFile aFile) /* static */ nsresult nsContentUtils::GetLocalizedString(PropertiesFile aFile, const char* aKey, - nsString& aResult) + nsXPIDLString& aResult) { nsresult rv = EnsureStringBundle(aFile); NS_ENSURE_SUCCESS(rv, rv); nsIStringBundle *bundle = sStringBundles[aFile]; - nsXPIDLString result; - rv = bundle->GetStringFromName(NS_ConvertASCIItoUCS2(aKey).get(), - getter_Copies(result)); - NS_ENSURE_SUCCESS(rv, rv); - aResult = result; - return NS_OK; + return bundle->GetStringFromName(NS_ConvertASCIItoUCS2(aKey).get(), + getter_Copies(aResult)); } /* static */ @@ -2257,19 +2253,15 @@ nsresult nsContentUtils::FormatLocalizedString(PropertiesFile aFile, const char* aKey, const PRUnichar **aParams, PRUint32 aParamsLength, - nsString& aResult) + nsXPIDLString& aResult) { nsresult rv = EnsureStringBundle(aFile); NS_ENSURE_SUCCESS(rv, rv); nsIStringBundle *bundle = sStringBundles[aFile]; - nsXPIDLString result; - rv = bundle->FormatStringFromName(NS_ConvertASCIItoUCS2(aKey).get(), - aParams, aParamsLength, - getter_Copies(result)); - NS_ENSURE_SUCCESS(rv, rv); - aResult = result; - return NS_OK; + return bundle->FormatStringFromName(NS_ConvertASCIItoUCS2(aKey).get(), + aParams, aParamsLength, + getter_Copies(aResult)); } /* static */ nsresult @@ -2290,7 +2282,7 @@ nsContentUtils::ReportToConsole(PropertiesFile aFile, NS_ENSURE_SUCCESS(rv, rv); } - nsString errorText; + nsXPIDLString errorText; rv = FormatLocalizedString(aFile, aMessageName, aParams, aParamsLength, errorText); NS_ENSURE_SUCCESS(rv, rv); diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 8af9b988be7..97624d1c0f1 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -10500,9 +10500,9 @@ nsCSSFrameConstructor::WillDestroyFrameTree() } //STATIC -void nsCSSFrameConstructor::GetAlternateTextFor(nsIContent* aContent, - nsIAtom* aTag, // content object's tag - nsString& aAltText) +void nsCSSFrameConstructor::GetAlternateTextFor(nsIContent* aContent, + nsIAtom* aTag, // content object's tag + nsXPIDLString& aAltText) { nsresult rv; @@ -10536,7 +10536,7 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell, nsIFrame*& aFrame) { nsresult rv; - nsAutoString altText; + nsXPIDLString altText; // Initialize OUT parameter aFrame = nsnull; diff --git a/mozilla/layout/base/nsCSSFrameConstructor.h b/mozilla/layout/base/nsCSSFrameConstructor.h index 4cfd6c22878..5e6376bc017 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.h +++ b/mozilla/layout/base/nsCSSFrameConstructor.h @@ -82,9 +82,9 @@ public: static void ReleaseGlobals() { NS_IF_RELEASE(gXBLService); } // get the alternate text for a content node - static void GetAlternateTextFor(nsIContent* aContent, - nsIAtom* aTag, // content object's tag - nsString& aAltText); + static void GetAlternateTextFor(nsIContent* aContent, + nsIAtom* aTag, // content object's tag + nsXPIDLString& aAltText); private: // These are not supported and are not implemented! nsCSSFrameConstructor(const nsCSSFrameConstructor& aCopy); diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index d8f1e05c681..dcc93cd7df6 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -984,7 +984,7 @@ DocumentViewerImpl::PermitUnload(PRBool *aPermitUnload) nsCOMPtr prompt(do_GetInterface(mContainer)); if (prompt) { - nsString preMsg, postMsg; + nsXPIDLString preMsg, postMsg; rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES, "OnBeforeUnloadPreMessage", preMsg); diff --git a/mozilla/layout/forms/nsFileControlFrame.cpp b/mozilla/layout/forms/nsFileControlFrame.cpp index 87e7a284fd3..d6a11970b28 100644 --- a/mozilla/layout/forms/nsFileControlFrame.cpp +++ b/mozilla/layout/forms/nsFileControlFrame.cpp @@ -308,7 +308,7 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent) do_QueryInterface(doc->GetScriptGlobalObject()); // Get Loc title - nsString title; + nsXPIDLString title; nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, "FileUpload", title); diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp index 3ce5becb761..6d6943bc91a 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp @@ -157,9 +157,10 @@ nsGfxButtonControlFrame::CreateAnonymousContent(nsPresContext* aPresContext, // Get the text from the "value" attribute. // If it is zero length, set it to a default value (localized) - nsAutoString initvalue, value; + nsAutoString initvalue; result = GetValue(&initvalue); - value = initvalue; + nsXPIDLString value; + value.Assign(initvalue); if (result != NS_CONTENT_ATTR_HAS_VALUE && value.IsEmpty()) { // Generate localized label. // We can't make any assumption as to what the default would be @@ -283,7 +284,7 @@ else { // label from a string bundle as is done for all other UI strings. // See bug 16999 for further details. nsresult -nsGfxButtonControlFrame::GetDefaultLabel(nsString& aString) +nsGfxButtonControlFrame::GetDefaultLabel(nsXPIDLString& aString) { nsresult rv = NS_OK; PRInt32 type = GetFormControlType(); diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.h b/mozilla/layout/forms/nsGfxButtonControlFrame.h index 742bd5c6e52..120ad8e435b 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.h +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.h @@ -103,7 +103,7 @@ public: protected: NS_IMETHOD AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aSuggestedReflowState); - nsresult GetDefaultLabel(nsString& aLabel); + nsresult GetDefaultLabel(nsXPIDLString& aLabel); PRBool IsFileBrowseButton(PRInt32 type); // Browse button of file input diff --git a/mozilla/layout/forms/nsIsIndexFrame.cpp b/mozilla/layout/forms/nsIsIndexFrame.cpp index a3be0323f35..b8943e22036 100644 --- a/mozilla/layout/forms/nsIsIndexFrame.cpp +++ b/mozilla/layout/forms/nsIsIndexFrame.cpp @@ -135,7 +135,7 @@ nsIsIndexFrame::UpdatePromptLabel() // Get the text from the "prompt" attribute. // If it is zero length, set it to a default value (localized) - nsAutoString prompt; + nsXPIDLString prompt; if (mContent) mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::prompt, prompt); diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index 975af24d8b5..76561b2dfb6 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -1260,7 +1260,7 @@ nsImageFrame::DisplayAltFeedback(nsPresContext* aPresContext, if (!inner.IsEmpty()) { nsIContent* content = GetContent(); if (content) { - nsAutoString altText; + nsXPIDLString altText; nsCSSFrameConstructor::GetAlternateTextFor(content, content->Tag(), altText); DisplayAltText(aPresContext, aRenderingContext, altText, inner); diff --git a/mozilla/layout/generic/nsSimplePageSequence.cpp b/mozilla/layout/generic/nsSimplePageSequence.cpp index 17f589345bc..78269e97b1d 100644 --- a/mozilla/layout/generic/nsSimplePageSequence.cpp +++ b/mozilla/layout/generic/nsSimplePageSequence.cpp @@ -565,7 +565,7 @@ void nsSimplePageSequenceFrame::SetPageNumberFormat(const char* aPropName, const char* aDefPropVal, PRBool aPageNumOnly) { // Doing this here so we only have to go get these formats once - nsAutoString pageNumberFormat; + nsXPIDLString pageNumberFormat; // Now go get the Localized Page Formating String nsresult rv = nsContentUtils::GetLocalizedString(nsContentUtils::ePRINTING_PROPERTIES, @@ -711,14 +711,14 @@ nsSimplePageSequenceFrame::StartPrint(nsPresContext* aPresContext, // to have UI for setting the header/footer font name and size // // Get default font name and size to be used for the headers and footers - nsAutoString fontName; + nsXPIDLString fontName; rv = nsContentUtils::GetLocalizedString(nsContentUtils::ePRINTING_PROPERTIES, "fontname", fontName); if (NS_FAILED(rv)) { fontName.AssignLiteral("serif"); } - nsAutoString fontSizeStr; + nsXPIDLString fontSizeStr; nscoord pointSize = 10;; rv = nsContentUtils::GetLocalizedString(nsContentUtils::ePRINTING_PROPERTIES, "fontsize", fontSizeStr); diff --git a/mozilla/layout/printing/nsPrintEngine.cpp b/mozilla/layout/printing/nsPrintEngine.cpp index ddf91b7992a..c466211cffc 100644 --- a/mozilla/layout/printing/nsPrintEngine.cpp +++ b/mozilla/layout/printing/nsPrintEngine.cpp @@ -2246,7 +2246,7 @@ nsPrintEngine::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrinting) PR_PL(("ShowPrintErrorDialog: stringName='%s'\n", stringName.get())); - nsString msg, title; + nsXPIDLString msg, title; nsresult rv = nsContentUtils::GetLocalizedString(nsContentUtils::ePRINTING_PROPERTIES, stringName.get(), msg);