Bug 1277106 - Part 4: Remove MOZ_UTF16() macro. r=Waldo
authorChris Peterson <cpeterson@mozilla.com>
Tue, 19 Jul 2016 21:07:53 -0700
changeset 305979 dfd60b58fa6410b266fd7c87b25e50d1bb36fd8c
parent 305978 4e02a5ff49f20286544b1a721b6b37b9e678acb0
child 305980 eb0a5aab8c1338f9b02c1c91adb95f3436661960
push id79736
push usercpeterson@mozilla.com
push dateThu, 21 Jul 2016 07:32:59 +0000
treeherdermozilla-inbound@dfd60b58fa64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1277106
milestone50.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 1277106 - Part 4: Remove MOZ_UTF16() macro. r=Waldo
dom/base/nsGlobalWindow.cpp
dom/base/nsPlainTextSerializer.cpp
dom/events/TextComposition.cpp
gfx/thebes/gfxPlatform.cpp
mfbt/Char16.h
netwerk/base/nsIOService.cpp
parser/htmlparser/nsHTMLTags.cpp
widget/WidgetEventImpl.cpp
widget/windows/TSFTextStore.cpp
xpcom/ds/nsStaticAtom.h
xpcom/glue/nsStringAPI.h
xpcom/string/nsLiteralString.h
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -11114,17 +11114,17 @@ nsGlobalWindow::ShowSlowScriptDialog()
       if (NS_IS_LOW_SURROGATE(filenameUTF16[cutStart + cutLength])) {
         // Likewise, don't drop a trailing low surrogate here.  We want to
         // increase cutLength, since it might be 0 already so we can't very well
         // decrease it.
         ++cutLength;
       }
 
       // Insert U+2026 HORIZONTAL ELLIPSIS
-      filenameUTF16.Replace(cutStart, cutLength, NS_LITERAL_STRING("\x2026"));
+      filenameUTF16.Replace(cutStart, cutLength, NS_LITERAL_STRING(u"\x2026"));
     }
     const char16_t *formatParams[] = { filenameUTF16.get() };
     rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                                "KillScriptLocation",
                                                formatParams,
                                                scriptLocation);
 
     if (NS_SUCCEEDED(rv) && scriptLocation) {
--- a/dom/base/nsPlainTextSerializer.cpp
+++ b/dom/base/nsPlainTextSerializer.cpp
@@ -440,17 +440,17 @@ nsPlainTextSerializer::AppendDocumentSta
 nsresult
 nsPlainTextSerializer::DoOpenContainer(nsIAtom* aTag)
 {
   // Check if we need output current node as placeholder character and ignore
   // child nodes.
   if (ShouldReplaceContainerWithPlaceholder(mElement->NodeInfo()->NameAtom())) {
     if (mIgnoredChildNodeLevel == 0) {
       // Serialize current node as placeholder character
-      Write(NS_LITERAL_STRING("\xFFFC"));
+      Write(NS_LITERAL_STRING(u"\xFFFC"));
     }
     // Ignore child nodes.
     mIgnoredChildNodeLevel++;
     return NS_OK;
   }
   if (IsIgnorableRubyAnnotation(aTag)) {
     // Ignorable ruby annotation shouldn't be replaced by a placeholder
     // character, neither any of its descendants.
@@ -1113,17 +1113,17 @@ nsPlainTextSerializer::DoAddLeaf(nsIAtom
     while (line.Length() < width) {
       line.Append(char16_t('-'));
     }
     Write(line);
 
     EnsureVerticalSpace(0);
   }
   else if (mFlags & nsIDocumentEncoder::OutputNonTextContentAsPlaceholder) {
-    Write(NS_LITERAL_STRING("\xFFFC"));
+    Write(NS_LITERAL_STRING(u"\xFFFC"));
   }
   else if (aTag == nsGkAtoms::img) {
     /* Output (in decreasing order of preference)
        alt, title or nothing */
     // See <http://www.w3.org/TR/REC-html40/struct/objects.html#edef-IMG>
     nsAutoString imageDescription;
     if (NS_SUCCEEDED(GetAttributeValue(nsGkAtoms::alt,
                                        imageDescription))) {
@@ -2026,9 +2026,8 @@ int32_t GetUnicharStringWidth(const char
   for (;*pwcs && n-- > 0; pwcs++)
     if ((w = GetUnicharWidth(*pwcs)) < 0)
       ++width; // Taking 1 as the width of non-printable character, for bug# 94475.
     else
       width += w;
 
   return width;
 }
-
--- a/dom/events/TextComposition.cpp
+++ b/dom/events/TextComposition.cpp
@@ -36,17 +36,17 @@
 #undef TextRangeArray
 #undef Comment
 #endif
 
 using namespace mozilla::widget;
 
 namespace mozilla {
 
-#define IDEOGRAPHIC_SPACE (NS_LITERAL_STRING("\x3000"))
+#define IDEOGRAPHIC_SPACE (NS_LITERAL_STRING(u"\x3000"))
 
 /******************************************************************************
  * TextComposition
  ******************************************************************************/
 
 bool TextComposition::sHandlingSelectionEvent = false;
 
 TextComposition::TextComposition(nsPresContext* aPresContext,
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -410,17 +410,17 @@ NS_IMPL_ISUPPORTS(SRGBOverrideObserver, 
 #define GFX_PREF_CMS_FORCE_SRGB "gfx.color_management.force_srgb"
 
 NS_IMETHODIMP
 SRGBOverrideObserver::Observe(nsISupports *aSubject,
                               const char *aTopic,
                               const char16_t* someData)
 {
     NS_ASSERTION(NS_strcmp(someData,
-                           MOZ_UTF16(GFX_PREF_CMS_FORCE_SRGB)) == 0,
+                           (u"" GFX_PREF_CMS_FORCE_SRGB)) == 0,
                  "Restarting CMS on wrong pref!");
     ShutdownCMS();
     // Update current cms profile.
     gfxPlatform::CreateCMSOutputProfile();
     return NS_OK;
 }
 
 static const char* kObservedPrefs[] = {
--- a/mfbt/Char16.h
+++ b/mfbt/Char16.h
@@ -179,29 +179,16 @@ operator-(const char16_t* aX, const char
 }
 
 #else
 
 typedef const char16_t* char16ptr_t;
 
 #endif
 
-/*
- * Macro arguments used in concatenation or stringification won't be expanded.
- * Therefore, in order for |MOZ_UTF16(FOO)| to work as expected (which is to
- * expand |FOO| before doing whatever |MOZ_UTF16| needs to do to it) a helper
- * macro, |MOZ_UTF16_HELPER| needs to be inserted in between to allow the macro
- * argument to expand. See "3.10.6 Separate Expansion of Macro Arguments" of the
- * CPP manual for a more accurate and precise explanation.
- */
-#define MOZ_UTF16_HELPER(s) u##s
-#define MOZ_UTF16(s) MOZ_UTF16_HELPER(s)
-
 static_assert(sizeof(char16_t) == 2, "Is char16_t type 16 bits?");
 static_assert(char16_t(-1) > char16_t(0), "Is char16_t type unsigned?");
-static_assert(sizeof(MOZ_UTF16('A')) == 2, "Is char literal 16 bits?");
-static_assert(sizeof(MOZ_UTF16("")[0]) == 2, "Is string char 16 bits?");
 static_assert(sizeof(u'A') == 2, "Is unicode char literal 16 bits?");
 static_assert(sizeof(u""[0]) == 2, "Is unicode string char 16 bits?");
 
 #endif
 
 #endif /* mozilla_Char16_h */
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -1076,17 +1076,17 @@ nsIOService::SetOffline(bool offline)
                 mProxyService->ReloadPAC();
 
             mLastOfflineStateChange = PR_IntervalNow();
             // don't care if notification fails
             // Only send the ONLINE notification if there is connectivity
             if (observerService && mConnectivity) {
                 observerService->NotifyObservers(subject,
                                                  NS_IOSERVICE_OFFLINE_STATUS_TOPIC,
-                                                 MOZ_UTF16(NS_IOSERVICE_ONLINE));
+                                                 (u"" NS_IOSERVICE_ONLINE));
             }
         }
     }
 
     // Don't notify here, as the above notifications (if used) suffice.
     if ((mShutdown || mOfflineForProfileChange) && mOffline) {
         // be sure to try and shutdown both (even if the first fails)...
         // shutdown dns service first, because it has callbacks for socket transport
@@ -1156,21 +1156,21 @@ nsIOService::SetConnectivityInternal(boo
     }
 
     if (aConnectivity) {
         // If we were previously offline due to connectivity=false,
         // send the ONLINE notification
         observerService->NotifyObservers(
             static_cast<nsIIOService *>(this),
             NS_IOSERVICE_OFFLINE_STATUS_TOPIC,
-            MOZ_UTF16(NS_IOSERVICE_ONLINE));
+            (u"" NS_IOSERVICE_ONLINE));
     } else {
         // If we were previously online and lost connectivity
         // send the OFFLINE notification
-        const nsLiteralString offlineString(MOZ_UTF16(NS_IOSERVICE_OFFLINE));
+        const nsLiteralString offlineString(u"" NS_IOSERVICE_OFFLINE);
         observerService->NotifyObservers(static_cast<nsIIOService *>(this),
                                          NS_IOSERVICE_GOING_OFFLINE_TOPIC,
                                          offlineString.get());
         observerService->NotifyObservers(static_cast<nsIIOService *>(this),
                                          NS_IOSERVICE_OFFLINE_STATUS_TOPIC,
                                          offlineString.get());
     }
     return NS_OK;
@@ -1395,17 +1395,17 @@ nsIOService::NotifyWakeup()
     nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
 
     NS_ASSERTION(observerService, "The observer service should not be null");
 
     if (observerService && mNetworkNotifyChanged) {
         (void)observerService->
             NotifyObservers(nullptr,
                             NS_NETWORK_LINK_TOPIC,
-                            MOZ_UTF16(NS_NETWORK_LINK_DATA_CHANGED));
+                            (u"" NS_NETWORK_LINK_DATA_CHANGED));
     }
 
     RecheckCaptivePortal();
 
     return NS_OK;
 }
 
 void
--- a/parser/htmlparser/nsHTMLTags.cpp
+++ b/parser/htmlparser/nsHTMLTags.cpp
@@ -10,18 +10,18 @@
 #include "nsStaticAtom.h"
 #include "nsUnicharUtils.h"
 #include "mozilla/HashFunctions.h"
 #include <algorithm>
 
 using namespace mozilla;
 
 // static array of unicode tag names
-#define HTML_TAG(_tag, _classname) MOZ_UTF16(#_tag),
-#define HTML_HTMLELEMENT_TAG(_tag) MOZ_UTF16(#_tag),
+#define HTML_TAG(_tag, _classname) (u"" #_tag),
+#define HTML_HTMLELEMENT_TAG(_tag) (u"" #_tag),
 #define HTML_OTHER(_tag)
 const char16_t* const nsHTMLTags::sTagUnicodeTable[] = {
 #include "nsHTMLTagList.h"
 };
 #undef HTML_TAG
 #undef HTML_HTMLELEMENT_TAG
 #undef HTML_OTHER
 
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -467,24 +467,24 @@ WidgetWheelEvent::OverriddenDeltaY() con
   }
   return ComputeOverriddenDelta(mDeltaY, true);
 }
 
 /******************************************************************************
  * mozilla::WidgetKeyboardEvent (TextEvents.h)
  ******************************************************************************/
 
-#define NS_DEFINE_KEYNAME(aCPPName, aDOMKeyName) MOZ_UTF16(aDOMKeyName),
+#define NS_DEFINE_KEYNAME(aCPPName, aDOMKeyName) (u"" aDOMKeyName),
 const char16_t* const WidgetKeyboardEvent::kKeyNames[] = {
 #include "mozilla/KeyNameList.h"
 };
 #undef NS_DEFINE_KEYNAME
 
 #define NS_DEFINE_PHYSICAL_KEY_CODE_NAME(aCPPName, aDOMCodeName) \
-    MOZ_UTF16(aDOMCodeName),
+    (u"" aDOMCodeName),
 const char16_t* const WidgetKeyboardEvent::kCodeNames[] = {
 #include "mozilla/PhysicalKeyCodeNameList.h"
 };
 #undef NS_DEFINE_PHYSICAL_KEY_CODE_NAME
 
 WidgetKeyboardEvent::KeyNameIndexHashtable*
   WidgetKeyboardEvent::sKeyNameIndexHashtable = nullptr;
 WidgetKeyboardEvent::CodeNameIndexHashtable*
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -830,21 +830,21 @@ public:
 
   bool IsMSJapaneseIMEActive() const
   {
     // FYI: Name of MS-IME for Japanese is same as MS-IME for Korean.
     //      Therefore, we need to check the langid too.
     return mLangID == 0x411 &&
       (mActiveTIPKeyboardDescription.EqualsLiteral("Microsoft IME") ||
        mActiveTIPKeyboardDescription.Equals(
-         NS_LITERAL_STRING("Microsoft \xC785\xB825\xAE30")) ||
+         NS_LITERAL_STRING(u"Microsoft \xC785\xB825\xAE30")) ||
        mActiveTIPKeyboardDescription.Equals(
-         NS_LITERAL_STRING("\x5FAE\x8F6F\x8F93\x5165\x6CD5")) ||
+         NS_LITERAL_STRING(u"\x5FAE\x8F6F\x8F93\x5165\x6CD5")) ||
        mActiveTIPKeyboardDescription.Equals(
-         NS_LITERAL_STRING("\x5FAE\x8EDF\x8F38\x5165\x6CD5")));
+         NS_LITERAL_STRING(u"\x5FAE\x8EDF\x8F38\x5165\x6CD5")));
   }
 
   bool IsMSOfficeJapaneseIME2010Active() const
   {
     // {54EDCC94-1524-4BB1-9FB7-7BABE4F4CA64}
     static const GUID kGUID = {
       0x54EDCC94, 0x1524, 0x4BB1,
         { 0x9F, 0xB7, 0x7B, 0xAB, 0xE4, 0xF4, 0xCA, 0x64 }
@@ -862,64 +862,64 @@ public:
   /****************************************************************************
    * Traditional Chinese TIP
    ****************************************************************************/
 
   bool IsMSChangJieActive() const
   {
     return mActiveTIPKeyboardDescription.EqualsLiteral("Microsoft ChangJie") ||
       mActiveTIPKeyboardDescription.Equals(
-        NS_LITERAL_STRING("\x5FAE\x8F6F\x4ED3\x9889")) ||
+        NS_LITERAL_STRING(u"\x5FAE\x8F6F\x4ED3\x9889")) ||
       mActiveTIPKeyboardDescription.Equals(
-        NS_LITERAL_STRING("\x5FAE\x8EDF\x5009\x9821"));
+        NS_LITERAL_STRING(u"\x5FAE\x8EDF\x5009\x9821"));
   }
 
   bool IsMSQuickQuickActive() const
   {
     return mActiveTIPKeyboardDescription.EqualsLiteral("Microsoft Quick") ||
       mActiveTIPKeyboardDescription.Equals(
-        NS_LITERAL_STRING("\x5FAE\x8F6F\x901F\x6210")) ||
+        NS_LITERAL_STRING(u"\x5FAE\x8F6F\x901F\x6210")) ||
       mActiveTIPKeyboardDescription.Equals(
-        NS_LITERAL_STRING("\x5FAE\x8EDF\x901F\x6210"));
+        NS_LITERAL_STRING(u"\x5FAE\x8EDF\x901F\x6210"));
   }
 
   bool IsFreeChangJieActive() const
   {
     // FYI: The TIP name is misspelled...
     return mActiveTIPKeyboardDescription.EqualsLiteral("Free CangJie IME 10");
   }
 
   bool IsEasyChangjeiActive() const
   {
     return
       mActiveTIPKeyboardDescription.Equals(
         NS_LITERAL_STRING(
-          "\x4E2D\x6587 (\x7E41\x9AD4) - \x6613\x9821\x8F38\x5165\x6CD5"));
+          u"\x4E2D\x6587 (\x7E41\x9AD4) - \x6613\x9821\x8F38\x5165\x6CD5"));
   }
 
   /****************************************************************************
    * Simplified Chinese TIP
    ****************************************************************************/
 
   bool IsMSPinyinActive() const
   {
     return mActiveTIPKeyboardDescription.EqualsLiteral("Microsoft Pinyin") ||
       mActiveTIPKeyboardDescription.Equals(
-        NS_LITERAL_STRING("\x5FAE\x8F6F\x62FC\x97F3")) ||
+        NS_LITERAL_STRING(u"\x5FAE\x8F6F\x62FC\x97F3")) ||
       mActiveTIPKeyboardDescription.Equals(
-        NS_LITERAL_STRING("\x5FAE\x8EDF\x62FC\x97F3"));
+        NS_LITERAL_STRING(u"\x5FAE\x8EDF\x62FC\x97F3"));
   }
 
   bool IsMSWubiActive() const
   {
     return mActiveTIPKeyboardDescription.EqualsLiteral("Microsoft Wubi") ||
       mActiveTIPKeyboardDescription.Equals(
-        NS_LITERAL_STRING("\x5FAE\x8F6F\x4E94\x7B14")) ||
+        NS_LITERAL_STRING(u"\x5FAE\x8F6F\x4E94\x7B14")) ||
       mActiveTIPKeyboardDescription.Equals(
-        NS_LITERAL_STRING("\x5FAE\x8EDF\x4E94\x7B46"));
+        NS_LITERAL_STRING(u"\x5FAE\x8EDF\x4E94\x7B46"));
   }
 
 public: // ITfInputProcessorProfileActivationSink
   STDMETHODIMP OnActivated(DWORD, LANGID, REFCLSID, REFGUID, REFGUID,
                            HKL, DWORD);
 
 private:
   TSFStaticSink();
@@ -6095,9 +6095,8 @@ TSFTextStore::CurrentKeyboardLayoutHasIM
     return false;
   }
   return (profile.dwProfileType == TF_PROFILETYPE_INPUTPROCESSOR);
 }
 #endif // #ifdef DEBUG
 
 } // name widget
 } // name mozilla
-
--- a/xpcom/ds/nsStaticAtom.h
+++ b/xpcom/ds/nsStaticAtom.h
@@ -10,17 +10,17 @@
 #include "nsIAtom.h"
 #include "nsStringBuffer.h"
 
 #define NS_STATIC_ATOM(buffer_name, atom_ptr) \
   { (nsStringBuffer*) &buffer_name, atom_ptr }
 
 #define NS_STATIC_ATOM_BUFFER(buffer_name, str_data) \
   static nsFakeStringBuffer<sizeof(str_data)> buffer_name = \
-    { 1, sizeof(str_data) * sizeof(char16_t), MOZ_UTF16(str_data) };
+    { 1, sizeof(str_data) * sizeof(char16_t), (u"" str_data) };
 
 /**
  * Holds data used to initialize large number of atoms during startup. Use
  * the above macros to initialize these structs. They should never be accessed
  * directly other than from AtomTable.cpp
  */
 struct nsStaticAtom
 {
--- a/xpcom/glue/nsStringAPI.h
+++ b/xpcom/glue/nsStringAPI.h
@@ -1272,21 +1272,21 @@ static_assert(char16_t(-1) > char16_t(0)
   n(reinterpret_cast<const nsAString::char_type*>(s), \
     uint32_t((sizeof(s) / 2) - 1))
 #define NS_NAMED_MULTILINE_LITERAL_STRING(n,s) \
   const nsDependentString n(reinterpret_cast<const nsAString::char_type*>(s), \
                             uint32_t((sizeof(s) / 2) - 1))
 typedef nsDependentString nsLiteralString;
 
 #define NS_LITERAL_STRING(s) \
-  static_cast<const nsString&>(NS_MULTILINE_LITERAL_STRING(MOZ_UTF16(s)))
+  static_cast<const nsString&>(NS_MULTILINE_LITERAL_STRING(u"" s))
 #define NS_LITERAL_STRING_INIT(n, s) \
-  NS_MULTILINE_LITERAL_STRING_INIT(n, MOZ_UTF16(s))
+  NS_MULTILINE_LITERAL_STRING_INIT(n, (u"" s))
 #define NS_NAMED_LITERAL_STRING(n, s) \
-  NS_NAMED_MULTILINE_LITERAL_STRING(n, MOZ_UTF16(s))
+  NS_NAMED_MULTILINE_LITERAL_STRING(n, (u"" s))
 
 #define NS_LITERAL_CSTRING(s) \
   static_cast<const nsDependentCString&>(nsDependentCString(s, uint32_t(sizeof(s) - 1)))
 #define NS_LITERAL_CSTRING_INIT(n, s) \
   n(s, uint32_t(sizeof(s)-1))
 #define NS_NAMED_LITERAL_CSTRING(n, s) \
   const nsDependentCString n(s, uint32_t(sizeof(s)-1))
 
--- a/xpcom/string/nsLiteralString.h
+++ b/xpcom/string/nsLiteralString.h
@@ -21,17 +21,17 @@
 #include "string-template-undef.h"
 
 #include "mozilla/Char16.h"
 
 #define NS_MULTILINE_LITERAL_STRING(s)            static_cast<const nsLiteralString&>(nsLiteralString(s))
 #define NS_MULTILINE_LITERAL_STRING_INIT(n,s)     n(s)
 #define NS_NAMED_MULTILINE_LITERAL_STRING(n,s)    const nsLiteralString n(s)
 
-#define NS_LITERAL_STRING(s)                      static_cast<const nsLiteralString&>(nsLiteralString(MOZ_UTF16(s)))
-#define NS_LITERAL_STRING_INIT(n,s)               n(MOZ_UTF16(s))
-#define NS_NAMED_LITERAL_STRING(n,s)              const nsLiteralString n(MOZ_UTF16(s))
+#define NS_LITERAL_STRING(s)                      static_cast<const nsLiteralString&>(nsLiteralString(u"" s))
+#define NS_LITERAL_STRING_INIT(n,s)               n(u"" s)
+#define NS_NAMED_LITERAL_STRING(n,s)              const nsLiteralString n(u"" s)
 
 #define NS_LITERAL_CSTRING(s)                     static_cast<const nsLiteralCString&>(nsLiteralCString("" s))
 #define NS_LITERAL_CSTRING_INIT(n,s)              n("" s)
 #define NS_NAMED_LITERAL_CSTRING(n,s)             const nsLiteralCString n("" s)
 
 #endif /* !defined(nsLiteralString_h___) */