From 2bccd4ab67c13f096801c52c2bfcb1e43d9034bb Mon Sep 17 00:00:00 2001 From: "bsmedberg%covad.net" Date: Fri, 18 Nov 2005 15:58:53 +0000 Subject: [PATCH] Bug 315563 - Convert the activex code to use the frozen string API, r=darin --- .../activex/src/common/IEHtmlElement.cpp | 1 - .../src/common/IEHtmlElementCollection.cpp | 2 -- .../activex/src/common/IWebBrowserImpl.h | 34 +++++++++++-------- .../browser/activex/src/common/Makefile.in | 1 - embedding/browser/activex/src/common/StdAfx.h | 6 ++-- .../browser/activex/src/control/Makefile.in | 1 - .../activex/src/control/MozillaBrowser.cpp | 25 +++++++++----- .../activex/src/control/PromptService.cpp | 1 - .../browser/activex/src/control/StdAfx.h | 5 +-- .../src/control/WebBrowserContainer.cpp | 4 +-- .../activex/src/plugin/LegacyPlugin.cpp | 2 +- .../browser/activex/src/plugin/Makefile.in | 2 +- .../activex/src/plugin/PrefObserver.cpp | 11 +++--- .../browser/activex/src/plugin/XPCBrowser.cpp | 3 +- .../activex/src/plugin/XPCDocument.cpp | 2 +- .../browser/activex/src/plugin/XPConnect.cpp | 13 +++---- 16 files changed, 58 insertions(+), 55 deletions(-) diff --git a/embedding/browser/activex/src/common/IEHtmlElement.cpp b/embedding/browser/activex/src/common/IEHtmlElement.cpp index 625e31a4d0b7..d7499e0051e7 100644 --- a/embedding/browser/activex/src/common/IEHtmlElement.cpp +++ b/embedding/browser/activex/src/common/IEHtmlElement.cpp @@ -40,7 +40,6 @@ #include "nsCOMPtr.h" #include "nsIDOMElement.h" -#include "nsString.h" #include "IEHtmlElement.h" #include "IEHtmlElementCollection.h" diff --git a/embedding/browser/activex/src/common/IEHtmlElementCollection.cpp b/embedding/browser/activex/src/common/IEHtmlElementCollection.cpp index dad2987ee62f..af30444eb6c0 100644 --- a/embedding/browser/activex/src/common/IEHtmlElementCollection.cpp +++ b/embedding/browser/activex/src/common/IEHtmlElementCollection.cpp @@ -43,8 +43,6 @@ #include "nsIDOMDocument.h" #include "nsIDOMHtmlElement.h" -#include "nsString.h" - #include "IEHtmlElement.h" #include "IEHtmlElementCollection.h" diff --git a/embedding/browser/activex/src/common/IWebBrowserImpl.h b/embedding/browser/activex/src/common/IWebBrowserImpl.h index 4d90f2a233b1..e3e5136b4c39 100644 --- a/embedding/browser/activex/src/common/IWebBrowserImpl.h +++ b/embedding/browser/activex/src/common/IWebBrowserImpl.h @@ -48,8 +48,10 @@ #include "nsIBaseWindow.h" #include "nsIWindowWatcher.h" #include "nsIInputStream.h" -#include "nsIByteArrayInputStream.h" +#include "nsIStringStream.h" #include "nsIURI.h" +#include "nsComponentManagerUtils.h" +#include "nsServiceManagerUtils.h" #include "PropertyList.h" @@ -184,7 +186,7 @@ public: if (homePage) { - nsXPIDLString homePageString; + nsString homePageString; nsresult rv = homePage->ToString(getter_Copies(homePageString)); if (NS_SUCCEEDED(rv)) { @@ -226,6 +228,8 @@ public: ATLTRACE(_T("IWebBrowserImpl::Navigate()\n")); ENSURE_BROWSER_IS_VALID(); + nsresult rv; + // Extract the URL parameter if (URL == NULL) { @@ -368,9 +372,9 @@ public: SafeArrayUnlock(PostData->parray); // Create a byte array input stream object. - nsCOMPtr stream; - nsresult rv = NS_NewByteArrayInputStream( - getter_AddRefs(stream), tmp, nSize); + nsCOMPtr stream + (do_CreateInstance("@mozilla.org/io/string-input-stream;1")); + rv = stream->AdoptData(tmp, nSize); if (NS_FAILED(rv) || !stream) { NS_ASSERTION(0, "cannot create byte stream"); @@ -384,7 +388,7 @@ public: } // Extract the headers parameter - nsCOMPtr headersStream; + nsCOMPtr headersStream; if (Headers && Headers->vt == VT_BSTR && Headers->bstrVal) @@ -403,15 +407,15 @@ public: tmp[nSize - 1] = '\0'; // Create a byte array input stream object which will own the buffer - nsCOMPtr stream; - nsresult rv = - NS_NewByteArrayInputStream(getter_AddRefs(stream), tmp, nSize); - if (NS_FAILED(rv) || !stream) + headersStream = do_CreateInstance("@mozilla.org/io/string-input-stream;1"); + if (headersStream) + rv = headersStream->AdoptData(tmp, nSize); + + if (NS_FAILED(rv) || !headersStream) { NS_ASSERTION(0, "cannot create byte stream"); nsMemory::Free(tmp); } - headersStream = do_QueryInterface(stream); } } } @@ -428,7 +432,7 @@ public: } // Load the URL - nsresult rv = NS_ERROR_FAILURE; + rv = NS_ERROR_FAILURE; if (webNavToUse) { rv = webNavToUse->LoadURI(URL, @@ -664,18 +668,18 @@ public: return SetErrorInfo(E_INVALIDARG); } // Get the url from the web shell - nsXPIDLString szLocationName; + nsString szLocationName; ENSURE_GET_WEBNAV(); nsCOMPtr baseWindow = do_QueryInterface(webNav); baseWindow->GetTitle(getter_Copies(szLocationName)); - if (nsnull == (const PRUnichar *) szLocationName) + if (!szLocationName.get()) { return SetErrorInfo(E_UNEXPECTED); } // Convert the string to a BSTR USES_CONVERSION; - LPCOLESTR pszConvertedLocationName = W2COLE((const PRUnichar *) szLocationName); + LPCOLESTR pszConvertedLocationName = W2COLE(szLocationName.get()); *LocationName = SysAllocString(pszConvertedLocationName); return S_OK; diff --git a/embedding/browser/activex/src/common/Makefile.in b/embedding/browser/activex/src/common/Makefile.in index 7aad7a1ea37e..62670338b7cd 100644 --- a/embedding/browser/activex/src/common/Makefile.in +++ b/embedding/browser/activex/src/common/Makefile.in @@ -46,7 +46,6 @@ include $(DEPTH)/config/autoconf.mk MODULE = ax_common LIBRARY_NAME = ax_common_s XPIDL_MODULE = ax_common -MOZILLA_INTERNAL_API = 1 REQUIRES = \ xpcom \ diff --git a/embedding/browser/activex/src/common/StdAfx.h b/embedding/browser/activex/src/common/StdAfx.h index 8267ede5b2c8..56d2396f17bb 100644 --- a/embedding/browser/activex/src/common/StdAfx.h +++ b/embedding/browser/activex/src/common/StdAfx.h @@ -65,14 +65,14 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIEventQueueService.h" -#include "nsString.h" +#include "nsStringAPI.h" #include "nsCOMPtr.h" -#include "nsXPIDLString.h" +#include "nsComponentManagerUtils.h" +#include "nsServiceManagerUtils.h" #include "nsIDocument.h" #include "nsIDocumentObserver.h" #include "nsVoidArray.h" -#include "nsCRT.h" #include "nsIDOMNode.h" #include "nsIDOMNodeList.h" diff --git a/embedding/browser/activex/src/control/Makefile.in b/embedding/browser/activex/src/control/Makefile.in index af404dbf576e..672d10f10591 100644 --- a/embedding/browser/activex/src/control/Makefile.in +++ b/embedding/browser/activex/src/control/Makefile.in @@ -49,7 +49,6 @@ DEFFILE = L_mozctl.def EXPORT_LIBRARY = 1 FORCE_SHARED_LIB= 1 GRE_MODULE = 1 -MOZILLA_INTERNAL_API = 1 REQUIRES = \ xpcom \ diff --git a/embedding/browser/activex/src/control/MozillaBrowser.cpp b/embedding/browser/activex/src/control/MozillaBrowser.cpp index 0aefb17ca984..38885600634c 100644 --- a/embedding/browser/activex/src/control/MozillaBrowser.cpp +++ b/embedding/browser/activex/src/control/MozillaBrowser.cpp @@ -186,7 +186,7 @@ CMozillaBrowser::CMozillaBrowser() mBrowserHelperListCount = 0; // Name of the default profile to use - mProfileName.AssignLiteral("MozillaControl"); + mProfileName.Assign(NS_LITERAL_STRING("MozillaControl")); // Initialise the web browser Initialize(); @@ -448,7 +448,7 @@ LRESULT CMozillaBrowser::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& ios->GetProtocolHandler(kDesignModeScheme, getter_AddRefs(ph)); if (ph && NS_SUCCEEDED(ph->GetScheme(phScheme)) && - phScheme.LowerCaseEqualsASCII(kDesignModeScheme)) + phScheme.Equals(NS_LITERAL_CSTRING(kDesignModeScheme))) { Navigate(const_cast(kDesignModeURL), NULL, NULL, NULL, NULL); } @@ -786,8 +786,8 @@ LRESULT CMozillaBrowser::OnViewSource(WORD wNotifyCode, WORD wID, HWND hWndCtl, nsCAutoString aURI; uri->GetSpec(aURI); - nsAutoString strURI(NS_LITERAL_STRING("view-source:")); - AppendUTF8toUTF16(aURI, strURI); + NS_ConvertUTF8toUTF16 strURI(aURI); + strURI.Insert(NS_LITERAL_STRING("view-source:"), 0); // Ask the client to create a window to view the source in CIPtr(IDispatch) spDispNew; @@ -932,18 +932,27 @@ LRESULT CMozillaBrowser::OnLinkCopyShortcut(WORD wNotifyCode, WORD wID, HWND hWn { EmptyClipboard(); + NS_ConvertUTF16toUTF8 curi(uri); + const char *stringText; + PRUint32 stringLen = NS_CStringGetData(curi, + &stringText); + // CF_TEXT - HGLOBAL hmemText = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, uri.Length() + 1); + HGLOBAL hmemText = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, + stringLen + 1); char *pszText = (char *) GlobalLock(hmemText); - uri.ToCString(pszText, uri.Length() + 1); + strncpy(pszText, stringText, stringLen); + pszText[stringLen] = '\0'; GlobalUnlock(hmemText); SetClipboardData(CF_TEXT, hmemText); // UniformResourceLocator - CFSTR_SHELLURL const UINT cfShellURL = RegisterClipboardFormat(CFSTR_SHELLURL); - HGLOBAL hmemURL = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, uri.Length() + 1); + HGLOBAL hmemURL = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, + stringLen + 1); char *pszURL = (char *) GlobalLock(hmemURL); - uri.ToCString(pszURL, uri.Length() + 1); + strncpy(pszText, stringText, stringLen); + pszText[stringLen] = '\0'; GlobalUnlock(hmemURL); SetClipboardData(cfShellURL, hmemURL); diff --git a/embedding/browser/activex/src/control/PromptService.cpp b/embedding/browser/activex/src/control/PromptService.cpp index 54b62507b7f6..e826eb679774 100644 --- a/embedding/browser/activex/src/control/PromptService.cpp +++ b/embedding/browser/activex/src/control/PromptService.cpp @@ -46,7 +46,6 @@ #include "nsIPromptService.h" #include "nsIFactory.h" #include "nsIDOMWindow.h" -#include "nsReadableUtils.h" class PromptDlg { diff --git a/embedding/browser/activex/src/control/StdAfx.h b/embedding/browser/activex/src/control/StdAfx.h index e76a97591c4c..506b4a7cb56e 100644 --- a/embedding/browser/activex/src/control/StdAfx.h +++ b/embedding/browser/activex/src/control/StdAfx.h @@ -67,9 +67,8 @@ #include "nsWidgetsCID.h" #include "nsGfxCIID.h" #include "nsViewsCID.h" -#include "nsString.h" +#include "nsStringAPI.h" #include "nsCOMPtr.h" -#include "nsXPIDLString.h" #include "nsIHTTPChannel.h" @@ -95,7 +94,6 @@ #include "nsIPresShell.h" #include "nsCOMPtr.h" #include "nsISelection.h" -#include "nsPresContext.h" #include "nsIPrompt.h" #include "nsIEditor.h" #include "nsIEditingSession.h" @@ -106,7 +104,6 @@ #include "nsIStreamListener.h" #include "nsUnitConversion.h" #include "nsVoidArray.h" -#include "nsCRT.h" #include "nsIDocumentViewer.h" #include "nsIDOMNode.h" diff --git a/embedding/browser/activex/src/control/WebBrowserContainer.cpp b/embedding/browser/activex/src/control/WebBrowserContainer.cpp index 06b6a9b3210b..53ecce6b78b2 100644 --- a/embedding/browser/activex/src/control/WebBrowserContainer.cpp +++ b/embedding/browser/activex/src/control/WebBrowserContainer.cpp @@ -43,8 +43,6 @@ #include "WebBrowserContainer.h" -#include "nsReadableUtils.h" - #include "nsServiceManagerUtils.h" #include "nsIWebNavigationInfo.h" @@ -284,7 +282,7 @@ NS_IMETHODIMP CWebBrowserContainer::OnLocationChange(nsIWebProgress* aWebProgres nsIRequest* aRequest, nsIURI *location) { -// nsXPIDLCString aPath; +// nsCString aPath; // location->GetPath(getter_Copies(aPath)); return NS_OK; } diff --git a/embedding/browser/activex/src/plugin/LegacyPlugin.cpp b/embedding/browser/activex/src/plugin/LegacyPlugin.cpp index 4e9c5b8bc84d..cdaac0beb19d 100644 --- a/embedding/browser/activex/src/plugin/LegacyPlugin.cpp +++ b/embedding/browser/activex/src/plugin/LegacyPlugin.cpp @@ -54,7 +54,7 @@ #ifdef XPC_IDISPATCH_SUPPORT #include "nsCOMPtr.h" -#include "nsString.h" +#include "nsStringAPI.h" #include "nsIDocument.h" #include "nsIDOMElement.h" #include "nsIDOMDocument.h" diff --git a/embedding/browser/activex/src/plugin/Makefile.in b/embedding/browser/activex/src/plugin/Makefile.in index 629afb1dab8a..bbd0cec5e197 100644 --- a/embedding/browser/activex/src/plugin/Makefile.in +++ b/embedding/browser/activex/src/plugin/Makefile.in @@ -50,7 +50,6 @@ LIBRARY_NAME = npmozax RESFILE = MozActiveX.res DEFFILE = npmozax.def GRE_MODULE = 1 -MOZILLA_INTERNAL_API = 1 REQUIRES = \ xpcom \ @@ -198,6 +197,7 @@ DEFINES += -DXPC_IDISPATCH_SUPPORT endif EXTRA_DSO_LDOPTS = \ + $(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \ $(MOZ_COMPONENT_LIBS) \ $(NSPR_LIBS) \ $(NULL) diff --git a/embedding/browser/activex/src/plugin/PrefObserver.cpp b/embedding/browser/activex/src/plugin/PrefObserver.cpp index a883372943dc..810d7a137749 100644 --- a/embedding/browser/activex/src/plugin/PrefObserver.cpp +++ b/embedding/browser/activex/src/plugin/PrefObserver.cpp @@ -46,8 +46,7 @@ #include "nsIPrefBranch2.h" #include "nsWeakReference.h" #include "nsIObserver.h" -#include "nsCRT.h" -#include "nsString.h" +#include "nsStringAPI.h" #include "XPConnect.h" @@ -116,7 +115,7 @@ NS_INTERFACE_MAP_END /* void observe (in nsISupports aSubject, in string aTopic, in wstring aData); */ NS_IMETHODIMP PrefObserver::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData) { - if (nsCRT::strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic) != 0) + if (strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic) != 0) { return S_OK; } @@ -127,9 +126,9 @@ NS_IMETHODIMP PrefObserver::Observe(nsISupports *aSubject, const char *aTopic, c return rv; NS_ConvertUTF16toUTF8 pref(aData); - if (nsCRT::strcmp(kActiveXHostingFlags, pref.get()) == 0 || - nsCRT::strcmp(kUserAgentPref, pref.get()) == 0 || - nsCRT::strcmp(kProxyPref, pref.get()) == 0) + if (strcmp(kActiveXHostingFlags, pref.get()) == 0 || + strcmp(kUserAgentPref, pref.get()) == 0 || + strcmp(kProxyPref, pref.get()) == 0) { Sync(prefBranch); } diff --git a/embedding/browser/activex/src/plugin/XPCBrowser.cpp b/embedding/browser/activex/src/plugin/XPCBrowser.cpp index 2cb461ebb199..6c15bccd6ab8 100644 --- a/embedding/browser/activex/src/plugin/XPCBrowser.cpp +++ b/embedding/browser/activex/src/plugin/XPCBrowser.cpp @@ -43,9 +43,10 @@ #include "nsCOMPtr.h" #include "nsIInterfaceRequestorUtils.h" #include "nsServiceManagerUtils.h" -#include "nsString.h" +#include "nsStringAPI.h" #include "nsIPrefBranch.h" #include "nsIPrefService.h" +#include "nsMemory.h" #include "XPCBrowser.h" diff --git a/embedding/browser/activex/src/plugin/XPCDocument.cpp b/embedding/browser/activex/src/plugin/XPCDocument.cpp index 05ff0553810f..c9326d1a13e5 100644 --- a/embedding/browser/activex/src/plugin/XPCDocument.cpp +++ b/embedding/browser/activex/src/plugin/XPCDocument.cpp @@ -109,7 +109,7 @@ public: #include "nsCOMPtr.h" #include "nsIInterfaceRequestorUtils.h" -#include "nsString.h" +#include "nsStringAPI.h" #include "nsNetUtil.h" #include "nsIContent.h" diff --git a/embedding/browser/activex/src/plugin/XPConnect.cpp b/embedding/browser/activex/src/plugin/XPConnect.cpp index d3abf9aa308f..e296adfbc40e 100644 --- a/embedding/browser/activex/src/plugin/XPConnect.cpp +++ b/embedding/browser/activex/src/plugin/XPConnect.cpp @@ -42,6 +42,7 @@ #endif #include "nsCOMPtr.h" +#include "nsIComponentManager.h" #include "nsComponentManagerUtils.h" #include "nsServiceManagerUtils.h" @@ -50,8 +51,6 @@ #include "nsIVariant.h" #include "nsMemory.h" -#include "nsIAtom.h" - #include "nsIDOMDocument.h" #include "nsIDOMNode.h" #include "nsIDOMNodeList.h" @@ -281,9 +280,10 @@ nsScriptablePeer::ConvertVariants(nsIVariant *aIn, VARIANT *aOut) case nsIDataType::VTYPE_STRING_SIZE_IS: case nsIDataType::VTYPE_CHAR_STR: { - nsXPIDLCString value; + nsCString value; aIn->GetAsString(getter_Copies(value)); - nsAutoString valueWide; valueWide.AssignWithConversion(value); + nsString valueWide; + NS_CStringToUTF16(value, NS_CSTRING_ENCODING_ASCII, valueWide); aOut->vt = VT_BSTR; aOut->bstrVal = SysAllocString(valueWide.get()); } @@ -291,7 +291,7 @@ nsScriptablePeer::ConvertVariants(nsIVariant *aIn, VARIANT *aOut) case nsIDataType::VTYPE_WSTRING_SIZE_IS: case nsIDataType::VTYPE_WCHAR_STR: { - nsXPIDLString value; + nsString value; aIn->GetAsWString(getter_Copies(value)); aOut->vt = VT_BSTR; aOut->bstrVal = SysAllocString(value.get()); @@ -320,7 +320,8 @@ nsScriptablePeer::ConvertVariants(nsIVariant *aIn, VARIANT *aOut) { nsCAutoString value; aIn->GetAsACString(value); - nsAutoString valueWide; valueWide.AssignWithConversion(value.get()); + nsAutoString valueWide; + NS_CStringToUTF16(value, NS_CSTRING_ENCODING_ASCII, valueWide); aOut->vt = VT_BSTR; aOut->bstrVal = SysAllocString(valueWide.get()); }