Bug 1390036 (part 1) - Remove most remaining uses of nsXPIDLString. r=erahm.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 11 Aug 2017 18:31:22 +1000
changeset 375047 bd7a1aa5db733489256e531e4e6c8bac9b4aae98
parent 375046 66ef047d44aa6b155f28f9d64286342a0a1e7f1a
child 375048 5e6de75921f1a41b02fbd2358edf3b23457105c9
push id32344
push usercbook@mozilla.com
push dateWed, 16 Aug 2017 09:23:42 +0000
treeherdermozilla-central@6ebc251bd288 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1390036
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1390036 (part 1) - Remove most remaining uses of nsXPIDLString. r=erahm. CompareCacheHashEntry::mCrit[] is the only case where the nsXPIDLString-ness was important. The patch adds an explicit SetIsVoid() call to that class's constructor and changes some null checks to IsVoid() checks.
docshell/base/nsDocShell.cpp
dom/security/nsCSPContext.cpp
dom/security/test/gtest/TestCSPParser.cpp
layout/forms/nsGfxButtonControlFrame.cpp
layout/forms/nsGfxButtonControlFrame.h
netwerk/dns/nsIDNService.h
netwerk/streamconv/converters/nsIndexedToHTML.cpp
security/manager/ssl/nsCertTree.cpp
security/manager/ssl/nsCertTree.h
widget/nsPrintSettingsImpl.h
widget/tests/TestChromeMargin.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -9725,17 +9725,16 @@ public:
                                    NullString(), mPostData, mHeadersData,
                                    mLoadType, mSHEntry, mFirstParty,
                                    mSrcdoc, mSourceDocShell, mBaseURI,
                                    mCheckForPrerender, nullptr, nullptr);
   }
 
 private:
   // Use IDL strings so .get() returns null by default
-  nsXPIDLString mWindowTarget;
   nsXPIDLCString mTypeHint;
   nsString mSrcdoc;
 
   RefPtr<nsDocShell> mDocShell;
   nsCOMPtr<nsIURI> mURI;
   nsCOMPtr<nsIURI> mOriginalURI;
   Maybe<nsCOMPtr<nsIURI>> mResultPrincipalURI;
   bool mLoadReplace;
--- a/dom/security/nsCSPContext.cpp
+++ b/dom/security/nsCSPContext.cpp
@@ -735,17 +735,17 @@ nsCSPContext::EnsureEventTarget(nsIEvent
     return NS_OK;
   }
 
   mEventTarget = aEventTarget;
   return NS_OK;
 }
 
 struct ConsoleMsgQueueElem {
-  nsXPIDLString mMsg;
+  nsString      mMsg;
   nsString      mSourceName;
   nsString      mSourceLine;
   uint32_t      mLineNumber;
   uint32_t      mColumnNumber;
   uint32_t      mSeverityFlag;
 };
 
 void
--- a/dom/security/test/gtest/TestCSPParser.cpp
+++ b/dom/security/test/gtest/TestCSPParser.cpp
@@ -14,17 +14,16 @@
 #define nsAString_h___
 #define nsString_h___
 #define nsStringFwd_h___
 #define nsReadableUtils_h___
 class nsACString;
 class nsAString;
 class nsString;
 class nsCString;
-class nsXPIDLString;
 template<class T> class nsReadingIterator;
 #endif
 
 #include "nsIContentSecurityPolicy.h"
 #include "nsNetUtil.h"
 #include "mozilla/dom/nsCSPContext.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
--- a/layout/forms/nsGfxButtonControlFrame.cpp
+++ b/layout/forms/nsGfxButtonControlFrame.cpp
@@ -45,18 +45,19 @@ nsGfxButtonControlFrame::GetFrameName(ns
 }
 #endif
 
 // Create the text content used as label for the button.
 // The frame will be generated by the frame constructor.
 nsresult
 nsGfxButtonControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
 {
-  nsXPIDLString label;
-  GetLabel(label);
+  nsAutoString label;
+  nsresult rv = GetLabel(label);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   // Add a child text content node for the label
   mTextContent = new nsTextNode(mContent->NodeInfo()->NodeInfoManager());
 
   // set the value of the text node and add it to the child list
   mTextContent->SetText(label, false);
   aElements.AppendElement(mTextContent);
 
@@ -78,17 +79,17 @@ NS_QUERYFRAME_TAIL_INHERITING(nsHTMLButt
 
 // Initially we hardcoded the default strings here.
 // Next, we used html.css to store the default label for various types
 // of buttons. (nsGfxButtonControlFrame::DoNavQuirksReflow rev 1.20)
 // However, since html.css is not internationalized, we now grab the default
 // label from a string bundle as is done for all other UI strings.
 // See bug 16999 for further details.
 nsresult
-nsGfxButtonControlFrame::GetDefaultLabel(nsXPIDLString& aString) const
+nsGfxButtonControlFrame::GetDefaultLabel(nsAString& aString) const
 {
   nsCOMPtr<nsIFormControl> form = do_QueryInterface(mContent);
   NS_ENSURE_TRUE(form, NS_ERROR_UNEXPECTED);
 
   int32_t type = form->ControlType();
   const char *prop;
   if (type == NS_FORM_INPUT_RESET) {
     prop = "Reset";
@@ -101,17 +102,17 @@ nsGfxButtonControlFrame::GetDefaultLabel
     return NS_OK;
   }
 
   return nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
                                             prop, aString);
 }
 
 nsresult
-nsGfxButtonControlFrame::GetLabel(nsXPIDLString& aLabel)
+nsGfxButtonControlFrame::GetLabel(nsString& aLabel)
 {
   // Get the text from the "value" property on our content if there is
   // one; otherwise set it to a default value (localized).
   dom::HTMLInputElement* elt = dom::HTMLInputElement::FromContent(mContent);
   if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::value) && elt) {
     elt->GetValue(aLabel, dom::CallerType::System);
   } else {
     // Generate localized label.
@@ -155,17 +156,17 @@ nsGfxButtonControlFrame::AttributeChange
                                           nsIAtom*        aAttribute,
                                           int32_t         aModType)
 {
   nsresult rv = NS_OK;
 
   // If the value attribute is set, update the text of the label
   if (nsGkAtoms::value == aAttribute) {
     if (mTextContent && mContent) {
-      nsXPIDLString label;
+      nsAutoString label;
       rv = GetLabel(label);
       NS_ENSURE_SUCCESS(rv, rv);
 
       mTextContent->SetText(label, true);
     } else {
       rv = NS_ERROR_UNEXPECTED;
     }
 
--- a/layout/forms/nsGfxButtonControlFrame.h
+++ b/layout/forms/nsGfxButtonControlFrame.h
@@ -44,19 +44,19 @@ public:
 
   virtual nsresult AttributeChanged(int32_t         aNameSpaceID,
                                     nsIAtom*        aAttribute,
                                     int32_t         aModType) override;
 
   virtual nsContainerFrame* GetContentInsertionFrame() override;
 
 protected:
-  nsresult GetDefaultLabel(nsXPIDLString& aLabel) const;
+  nsresult GetDefaultLabel(nsAString& aLabel) const;
 
-  nsresult GetLabel(nsXPIDLString& aLabel);
+  nsresult GetLabel(nsString& aLabel);
 
   virtual bool IsInput() override { return true; }
 private:
   nsCOMPtr<nsIContent> mTextContent;
 };
 
 
 #endif
--- a/netwerk/dns/nsIDNService.h
+++ b/netwerk/dns/nsIDNService.h
@@ -174,17 +174,17 @@ private:
   // |mIDNUseWhitelist|.
   //
   // These members can only be updated on the main thread and
   // read on any thread. Therefore, acquiring the mutex is required
   // only for threads other than the main thread.
   mozilla::Mutex mLock;
 
   // guarded by mLock
-  nsXPIDLString mIDNBlacklist;
+  nsString mIDNBlacklist;
 
   /**
    * Flag set by the pref network.IDN_show_punycode. When it is true,
    * IDNs containing non-ASCII characters are always displayed to the
    * user in punycode
    *
    * guarded by mLock
    */
--- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp
+++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp
@@ -506,17 +506,17 @@ nsIndexedToHTML::DoOnStartRequest(nsIReq
         nsAutoCString charset;
         rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, charset);
         NS_ENSURE_SUCCESS(rv, rv);
 
         rv = mTextToSubURI->UnEscapeAndConvert(charset, titleUri, unEscapeSpec);
     }
     if (NS_FAILED(rv)) return rv;
 
-    nsXPIDLString htmlEscSpec;
+    nsString htmlEscSpec;
     htmlEscSpec.Adopt(nsEscapeHTML2(unEscapeSpec.get(),
                                     unEscapeSpec.Length()));
 
     nsAutoString title;
     const char16_t* formatTitle[] = {
         htmlEscSpec.get()
     };
 
--- a/security/manager/ssl/nsCertTree.cpp
+++ b/security/manager/ssl/nsCertTree.cpp
@@ -54,16 +54,17 @@ CompareCacheHashEntryPtr::~CompareCacheH
   delete entry;
 }
 
 CompareCacheHashEntry::CompareCacheHashEntry()
 :key(nullptr)
 {
   for (int i = 0; i < max_criterions; ++i) {
     mCritInit[i] = false;
+    mCrit[i].SetIsVoid(true);
   }
 }
 
 static bool
 CompareCacheMatchEntry(const PLDHashEntryHdr *hdr, const void *key)
 {
   const CompareCacheHashEntryPtr *entryPtr = static_cast<const CompareCacheHashEntryPtr*>(hdr);
   return entryPtr->entry->key == key;
@@ -1276,17 +1277,17 @@ NS_IMETHODIMP nsCertTree::IsSorted(bool 
 
 void
 nsCertTree::CmpInitCriterion(nsIX509Cert *cert, CompareCacheHashEntry *entry,
                              sortCriterion crit, int32_t level)
 {
   NS_ENSURE_TRUE(cert && entry, RETURN_NOTHING);
 
   entry->mCritInit[level] = true;
-  nsXPIDLString &str = entry->mCrit[level];
+  nsString& str = entry->mCrit[level];
 
   switch (crit) {
     case sort_IssuerOrg:
       cert->GetIssuerOrganization(str);
       if (str.IsEmpty())
         cert->GetCommonName(str);
       break;
     case sort_Org:
@@ -1338,24 +1339,24 @@ nsCertTree::CmpByCrit(nsIX509Cert *a, Co
   if (!ace->mCritInit[level]) {
     CmpInitCriterion(a, ace, crit, level);
   }
 
   if (!bce->mCritInit[level]) {
     CmpInitCriterion(b, bce, crit, level);
   }
 
-  nsXPIDLString &str_a = ace->mCrit[level];
-  nsXPIDLString &str_b = bce->mCrit[level];
+  nsString& str_a = ace->mCrit[level];
+  nsString& str_b = bce->mCrit[level];
 
   int32_t result;
-  if (str_a && str_b)
+  if (!str_a.IsVoid() && !str_b.IsVoid())
     result = Compare(str_a, str_b, nsCaseInsensitiveStringComparator());
   else
-    result = !str_a ? (!str_b ? 0 : -1) : 1;
+    result = str_a.IsVoid() ? (str_b.IsVoid() ? 0 : -1) : 1;
 
   if (sort_IssuedDateDescending == crit)
     result *= -1; // reverse compare order
 
   return result;
 }
 
 int32_t
--- a/security/manager/ssl/nsCertTree.h
+++ b/security/manager/ssl/nsCertTree.h
@@ -22,17 +22,17 @@
 typedef struct treeArrayElStr treeArrayEl;
 
 struct CompareCacheHashEntry {
   enum { max_criterions = 3 };
   CompareCacheHashEntry();
 
   void *key; // no ownership
   bool mCritInit[max_criterions];
-  nsXPIDLString mCrit[max_criterions];
+  nsString mCrit[max_criterions];
 };
 
 struct CompareCacheHashEntryPtr : PLDHashEntryHdr {
   CompareCacheHashEntryPtr();
   ~CompareCacheHashEntryPtr();
   CompareCacheHashEntry *entry;
 };
 
--- a/widget/nsPrintSettingsImpl.h
+++ b/widget/nsPrintSettingsImpl.h
@@ -86,17 +86,17 @@ protected:
   int16_t       mPaperSizeUnit;
 
   bool          mPrintReversed;
   bool          mPrintInColor; // a false means grayscale
   int32_t       mOrientation;  // see orientation consts
   int32_t       mResolution;
   int32_t       mDuplex;
   int32_t       mNumCopies;
-  nsXPIDLString mPrinter;
+  nsString      mPrinter;
   bool          mPrintToFile;
   nsString      mToFileName;
   int16_t       mOutputFormat;
   bool          mIsInitedFromPrinter;
   bool          mIsInitedFromPrefs;
 };
 
 #endif /* nsPrintSettings_h__ */
--- a/widget/tests/TestChromeMargin.cpp
+++ b/widget/tests/TestChromeMargin.cpp
@@ -21,17 +21,16 @@
 #define nsAString_h___
 #define nsString_h___
 #define nsStringFwd_h___
 #define nsReadableUtils_h___
 class nsACString;
 class nsAString;
 class nsString;
 class nsCString;
-class nsXPIDLString;
 template<class T> class nsReadingIterator;
 #endif
 
 #include "nscore.h"
 #include "nsContentUtils.h"
 
 #ifndef MOZILLA_INTERNAL_API
 #undef nsString_h___