Bug 924019 - Do not assume that PRUnichar and UniChar/unichar are the same type; r=smichaud
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 10 Oct 2013 12:59:40 -0400
changeset 165145 ffbc9ebb069990f2f49535f7f14ee0c45ad62f5a
parent 165144 d87155d486f064f26d46f76fa250041594160f76
child 165146 0194c6474d7ad1ec14cc8a1b1f70f06afb111f7e
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmichaud
bugs924019
milestone27.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 924019 - Do not assume that PRUnichar and UniChar/unichar are the same type; r=smichaud
accessible/src/mac/mozAccessible.mm
gfx/thebes/gfxCoreTextShaper.cpp
gfx/thebes/gfxMacPlatformFontList.mm
intl/locale/src/mac/nsDateTimeFormatMac.cpp
intl/locale/src/nsLocaleService.cpp
intl/lwbrk/src/nsCarbonBreaker.cpp
toolkit/crashreporter/mac_utils.mm
uriloader/exthandler/mac/nsOSHelperAppService.mm
widget/cocoa/TextInputHandler.mm
widget/cocoa/nsChildView.mm
widget/cocoa/nsClipboard.mm
widget/cocoa/nsCocoaUtils.mm
widget/cocoa/nsCocoaWindow.mm
widget/cocoa/nsDeviceContextSpecX.mm
widget/cocoa/nsDragService.mm
widget/cocoa/nsFilePicker.mm
widget/cocoa/nsLookAndFeel.mm
widget/cocoa/nsMacDockSupport.mm
widget/cocoa/nsMacWebAppUtils.mm
widget/cocoa/nsMenuBarX.mm
widget/cocoa/nsMenuUtilsX.mm
widget/cocoa/nsPrintDialogX.mm
widget/cocoa/nsSound.mm
widget/cocoa/nsStandaloneNativeMenu.mm
--- a/accessible/src/mac/mozAccessible.mm
+++ b/accessible/src/mac/mozAccessible.mm
@@ -535,17 +535,18 @@ GetClosestInterestingAccessible(id anObj
 }
 
 - (id)value
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   nsAutoString value;
   mGeckoAccessible->GetValue (value);
-  return value.IsEmpty() ? nil : [NSString stringWithCharacters:value.BeginReading() length:value.Length()];
+  return value.IsEmpty() ? nil : [NSString stringWithCharacters:reinterpret_cast<const unichar*>(value.BeginReading())
+                                                         length:value.Length()];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (void)valueDidChange
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
@@ -579,17 +580,18 @@ GetClosestInterestingAccessible(id anObj
 }
 
 - (NSString*)help
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   nsAutoString helpText;
   mGeckoAccessible->GetHelp (helpText);
-  return helpText.IsEmpty() ? nil : [NSString stringWithCharacters:helpText.BeginReading() length:helpText.Length()];
+  return helpText.IsEmpty() ? nil : [NSString stringWithCharacters:reinterpret_cast<const unichar*>(helpText.BeginReading())
+                                                            length:helpText.Length()];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 // objc-style description (from NSObject); not to be confused with the accessible description above.
 - (NSString*)description
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
--- a/gfx/thebes/gfxCoreTextShaper.cpp
+++ b/gfx/thebes/gfxCoreTextShaper.cpp
@@ -83,25 +83,25 @@ gfxCoreTextShaper::ShapeText(gfxContext 
         startOffset = isRightToLeft ?
             mozilla::ArrayLength(beginRTL) : mozilla::ArrayLength(beginLTR);
         CFMutableStringRef mutableString =
             ::CFStringCreateMutable(kCFAllocatorDefault,
                                     length + startOffset + mozilla::ArrayLength(endBidiWrap));
         ::CFStringAppendCharacters(mutableString,
                                    isRightToLeft ? beginRTL : beginLTR,
                                    startOffset);
-        ::CFStringAppendCharacters(mutableString, aText, length);
+        ::CFStringAppendCharacters(mutableString, reinterpret_cast<const UniChar*>(aText), length);
         ::CFStringAppendCharacters(mutableString,
                                    endBidiWrap, mozilla::ArrayLength(endBidiWrap));
         stringObj = mutableString;
     } else {
         startOffset = 0;
         stringObj = ::CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault,
-                                                         aText, length,
-                                                         kCFAllocatorNull);
+                                                         reinterpret_cast<const UniChar*>(aText),
+                                                         length, kCFAllocatorNull);
     }
 
     CFDictionaryRef attrObj;
     if (aShapedText->DisableLigatures()) {
         // For letterspacing (or maybe other situations) we need to make a copy of the CTFont
         // with the ligature feature disabled
         CTFontRef ctFont =
             CreateCTFontWithDisabledLigatures(::CTFontGetSize(mCTFont));
--- a/gfx/thebes/gfxMacPlatformFontList.mm
+++ b/gfx/thebes/gfxMacPlatformFontList.mm
@@ -118,23 +118,23 @@ static const int gAppleWeightToCSSWeight
 };
 
 // cache Cocoa's "shared font manager" for performance
 static NSFontManager *sFontManager;
 
 static void GetStringForNSString(const NSString *aSrc, nsAString& aDist)
 {
     aDist.SetLength([aSrc length]);
-    [aSrc getCharacters:aDist.BeginWriting()];
+    [aSrc getCharacters:reinterpret_cast<unichar*>(aDist.BeginWriting())];
 }
 
 static NSString* GetNSStringForString(const nsAString& aSrc)
 {
-    return [NSString stringWithCharacters:aSrc.BeginReading()
-                     length:aSrc.Length()];
+    return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(aSrc.BeginReading())
+                                   length:aSrc.Length()];
 }
 
 #ifdef PR_LOGGING
 
 #define LOG_FONTLIST(args) PR_LOG(gfxPlatform::GetLog(eGfxLog_fontlist), \
                                PR_LOG_DEBUG, args)
 #define LOG_FONTLIST_ENABLED() PR_LOG_TEST( \
                                    gfxPlatform::GetLog(eGfxLog_fontlist), \
@@ -882,17 +882,17 @@ gfxMacPlatformFontList::GlobalFontFallba
                               kCFCompareCaseInsensitive) != kCFCompareEqualTo)
         {
             nsAutoTArray<UniChar, 1024> buffer;
             CFIndex len = ::CFStringGetLength(familyName);
             buffer.SetLength(len+1);
             ::CFStringGetCharacters(familyName, ::CFRangeMake(0, len),
                                     buffer.Elements());
             buffer[len] = 0;
-            nsDependentString familyName(buffer.Elements(), len);
+            nsDependentString familyName(reinterpret_cast<PRUnichar*>(buffer.Elements()), len);
 
             bool needsBold;  // ignored in the system fallback case
 
             gfxFontFamily *family = FindFamily(familyName);
             if (family) {
                 fontEntry = family->FindFontForStyle(*aMatchStyle, needsBold);
                 if (fontEntry) {
                     if (fontEntry->TestCharacterMap(aCh)) {
--- a/intl/locale/src/mac/nsDateTimeFormatMac.cpp
+++ b/intl/locale/src/mac/nsDateTimeFormatMac.cpp
@@ -109,17 +109,17 @@ nsresult nsDateTimeFormatMac::FormatTMTi
   NS_ASSERTION(tmTime->tm_wday >= 0, "tm is not set correctly");
 
   // Got the locale for the formatter:
   CFLocaleRef formatterLocale;
   if (!locale) {
     formatterLocale = CFLocaleCopyCurrent();
   } else {
     CFStringRef localeStr = CFStringCreateWithCharacters(nullptr,
-                                                         mLocale.get(),
+                                                         reinterpret_cast<const UniChar*>(mLocale.get()),
                                                          mLocale.Length());
     formatterLocale = CFLocaleCreate(nullptr, localeStr);
     CFRelease(localeStr);
   }
 
   // Get the date style for the formatter:  
   CFDateFormatterStyle dateStyle;
   switch (dateFormatSelector) {
@@ -216,17 +216,17 @@ nsresult nsDateTimeFormatMac::FormatTMTi
                                                                           formatter,
                                                                           absTime);
   
   CFIndex stringLen = CFStringGetLength(formattedDate);
   
   nsAutoTArray<UniChar, 256> stringBuffer;
   if (stringBuffer.SetLength(stringLen + 1)) {
     CFStringGetCharacters(formattedDate, CFRangeMake(0, stringLen), stringBuffer.Elements());
-    stringOut.Assign(stringBuffer.Elements(), stringLen);
+    stringOut.Assign(reinterpret_cast<PRUnichar*>(stringBuffer.Elements()), stringLen);
   }
   
   CFRelease(formattedDate);
   CFRelease(formatter);
   
   return res;
 }
 
--- a/intl/locale/src/nsLocaleService.cpp
+++ b/intl/locale/src/nsLocaleService.cpp
@@ -225,17 +225,17 @@ nsLocaleService::nsLocaleService(void)
     int size = ::CFStringGetLength(userLocaleStr);
     if (buffer.SetLength(size + 1))
     {
         CFRange range = ::CFRangeMake(0, size);
         ::CFStringGetCharacters(userLocaleStr, range, buffer.Elements());
         buffer[size] = 0;
 
         // Convert the locale string to the format that Mozilla expects
-        nsAutoString xpLocale(buffer.Elements());
+        nsAutoString xpLocale(reinterpret_cast<PRUnichar*>(buffer.Elements()));
         xpLocale.ReplaceChar('_', '-');
 
         nsresult rv = NewLocale(xpLocale, getter_AddRefs(mSystemLocale));
         if (NS_SUCCEEDED(rv)) {
             mApplicationLocale = mSystemLocale;
         }
     }
 
--- a/intl/lwbrk/src/nsCarbonBreaker.cpp
+++ b/intl/lwbrk/src/nsCarbonBreaker.cpp
@@ -27,17 +27,17 @@ NS_GetComplexLineBreaks(const PRUnichar*
      
   for (UniCharArrayOffset position = 0; position < aLength;) {
     UniCharArrayOffset offset;
     status = UCFindTextBreak(breakLocator, 
                   kUCTextBreakLineMask, 
                   position == 0 ? kUCTextBreakLeadingEdgeMask : 
                                   (kUCTextBreakLeadingEdgeMask | 
                                    kUCTextBreakIterateMask),
-                  aText, 
+                  reinterpret_cast<const UniChar*>(aText),
                   aLength, 
                   position, 
                   &offset);
     if (status != noErr || offset >= aLength)
       break;        
     aBreakBefore[offset] = true;
     position = offset;
   }
--- a/toolkit/crashreporter/mac_utils.mm
+++ b/toolkit/crashreporter/mac_utils.mm
@@ -27,15 +27,15 @@ void GetObjCExceptionInfo(void* inExcept
   }
 
   [name getCharacters:nameBuffer];
   [reason getCharacters:reasonBuffer];
   nameBuffer[nameLength] = '\0';
   reasonBuffer[reasonLength] = '\0';
 
   outString.AssignLiteral("\nObj-C Exception data:\n");
-  AppendUTF16toUTF8(nameBuffer, outString);
+  AppendUTF16toUTF8(reinterpret_cast<const PRUnichar*>(nameBuffer), outString);
   outString.AppendLiteral(": ");
-  AppendUTF16toUTF8(reasonBuffer, outString);
+  AppendUTF16toUTF8(reinterpret_cast<const PRUnichar*>(reasonBuffer), outString);
 
   NS_Free(nameBuffer);
   NS_Free(reasonBuffer);
 }
--- a/uriloader/exthandler/mac/nsOSHelperAppService.mm
+++ b/uriloader/exthandler/mac/nsOSHelperAppService.mm
@@ -127,17 +127,17 @@ NS_IMETHODIMP nsOSHelperAppService::GetA
                                                                 kCFBundleNameKey);
 
             if (bundleName) {
               nsAutoTArray<UniChar, 255> buffer;
               CFIndex bundleNameLength = ::CFStringGetLength(bundleName);
               buffer.SetLength(bundleNameLength);
               ::CFStringGetCharacters(bundleName, CFRangeMake(0, bundleNameLength),
                                       buffer.Elements());
-              _retval.Assign(buffer.Elements(), bundleNameLength);
+              _retval.Assign(reinterpret_cast<PRUnichar*>(buffer.Elements()), bundleNameLength);
               rv = NS_OK;
             }
 
             ::CFRelease(handlerBundle);
           }
 
           ::CFRelease(appCFURL);
         }
@@ -161,17 +161,17 @@ nsresult nsOSHelperAppService::GetFileTo
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   nsresult rv;
   nsCOMPtr<nsILocalFileMac> localFile (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv,rv);
 
   CFURLRef pathAsCFURL;
   CFStringRef pathAsCFString = ::CFStringCreateWithCharacters(NULL,
-                                                              aPlatformAppPath,
+                                                              reinterpret_cast<const UniChar*>(aPlatformAppPath),
                                                               NS_strlen(aPlatformAppPath));
   if (!pathAsCFString)
     return NS_ERROR_OUT_OF_MEMORY;
 
   if (::CFStringGetCharacterAtIndex(pathAsCFString, 0) == '/') {
     // we have a Posix path
     pathAsCFURL = ::CFURLCreateWithFileSystemPath(nullptr, pathAsCFString,
                                                   kCFURLPOSIXPathStyle, false);
@@ -476,17 +476,17 @@ nsOSHelperAppService::GetMIMEInfoFromOS(
     }
     if (cfAppName) {
       nsAutoTArray<UniChar, 255> buffer;
       CFIndex appNameLength = ::CFStringGetLength(cfAppName);
       buffer.SetLength(appNameLength);
       ::CFStringGetCharacters(cfAppName, CFRangeMake(0, appNameLength),
                               buffer.Elements());
       nsAutoString appName;
-      appName.Assign(buffer.Elements(), appNameLength);
+      appName.Assign(reinterpret_cast<PRUnichar*>(buffer.Elements()), appNameLength);
       mimeInfoMac->SetDefaultDescription(appName);
       ::CFRelease(cfAppName);
     }
 
     mimeInfoMac->SetDefaultApplication(app);
     mimeInfoMac->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
   } else {
     mimeInfoMac->SetPreferredAction(nsIMIMEInfo::saveToDisk);
@@ -511,17 +511,17 @@ nsOSHelperAppService::GetMIMEInfoFromOS(
       CFStringRef cfTypeDesc = NULL;
       if (::LSCopyKindStringForMIMEType(cfType, &cfTypeDesc) == noErr) {
         nsAutoTArray<UniChar, 255> buffer;
         CFIndex typeDescLength = ::CFStringGetLength(cfTypeDesc);
         buffer.SetLength(typeDescLength);
         ::CFStringGetCharacters(cfTypeDesc, CFRangeMake(0, typeDescLength),
                                 buffer.Elements());
         nsAutoString typeDesc;
-        typeDesc.Assign(buffer.Elements(), typeDescLength);
+        typeDesc.Assign(reinterpret_cast<PRUnichar*>(buffer.Elements()), typeDescLength);
         mimeInfoMac->SetDescription(typeDesc);
       }
       if (cfTypeDesc) {
         ::CFRelease(cfTypeDesc);
       }
       ::CFRelease(cfType);
     }
   }
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -463,17 +463,18 @@ TISInputSourceWrapper::InitByInputSource
 
 void
 TISInputSourceWrapper::InitByInputSourceID(const nsAFlatString &aID)
 {
   Clear();
   if (aID.IsEmpty())
     return;
   CFStringRef idstr = ::CFStringCreateWithCharacters(kCFAllocatorDefault,
-                                                     aID.get(), aID.Length());
+                                                     reinterpret_cast<const UniChar*>(aID.get()),
+                                                     aID.Length());
   InitByInputSourceID(idstr);
   ::CFRelease(idstr);
 }
 
 void
 TISInputSourceWrapper::InitByInputSourceID(const CFStringRef aID)
 {
   Clear();
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1412,17 +1412,18 @@ static NSMenuItem* NativeMenuItemWithLoc
   return nil;
 }
 
 // Used for testing native menu system structure and event handling.
 NS_IMETHODIMP nsChildView::ActivateNativeMenuItemAt(const nsAString& indexString)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
-  NSString* locationString = [NSString stringWithCharacters:indexString.BeginReading() length:indexString.Length()];
+  NSString* locationString = [NSString stringWithCharacters:reinterpret_cast<const unichar*>(indexString.BeginReading())
+                                                     length:indexString.Length()];
   NSMenuItem* item = NativeMenuItemWithLocation([NSApp mainMenu], locationString);
   // We can't perform an action on an item with a submenu, that will raise
   // an obj-c exception.
   if (item && ![item hasSubmenu]) {
     NSMenu* parent = [item menu];
     if (parent) {
       // NSLog(@"Performing action for native menu item titled: %@\n",
       //       [[currentSubmenu itemAtIndex:targetIndex] title]);
--- a/widget/cocoa/nsClipboard.mm
+++ b/widget/cocoa/nsClipboard.mm
@@ -519,17 +519,18 @@ nsClipboard::PasteboardDictFromTransfera
       int32_t newlinePos = url.FindChar(PRUnichar('\n'));
       if (newlinePos >= 0) {
         url.Truncate(newlinePos);
 
         nsAutoString urlTitle;
         urlObject->GetData(urlTitle);
         urlTitle.Mid(urlTitle, newlinePos + 1, len - (newlinePos + 1));
 
-        NSString *nativeTitle = [[NSString alloc] initWithCharacters:urlTitle.get() length:urlTitle.Length()];
+        NSString *nativeTitle = [[NSString alloc] initWithCharacters:reinterpret_cast<const unichar*>(urlTitle.get())
+                                                              length:urlTitle.Length()];
         // be nice to Carbon apps, normalize the receiver's contents using Form C.
         [pasteboardOutputDict setObject:[nativeTitle precomposedStringWithCanonicalMapping] forKey:kCorePboardType_urln];
         // Also put the title out as 'urld', since some recipients will look for that.
         [pasteboardOutputDict setObject:[nativeTitle precomposedStringWithCanonicalMapping] forKey:kCorePboardType_urld];
         [nativeTitle release];
       }
 
       // The Finder doesn't like getting random binary data aka
--- a/widget/cocoa/nsCocoaUtils.mm
+++ b/widget/cocoa/nsCocoaUtils.mm
@@ -347,29 +347,29 @@ nsCocoaUtils::GetStringForNSString(const
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (!aSrc) {
     aDist.Truncate();
     return;
   }
 
   aDist.SetLength([aSrc length]);
-  [aSrc getCharacters: aDist.BeginWriting()];
+  [aSrc getCharacters: reinterpret_cast<unichar*>(aDist.BeginWriting())];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 // static
 NSString*
 nsCocoaUtils::ToNSString(const nsAString& aString)
 {
   if (aString.IsEmpty()) {
     return [NSString string];
   }
-  return [NSString stringWithCharacters:aString.BeginReading()
+  return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(aString.BeginReading())
                                  length:aString.Length()];
 }
 
 // static
 void
 nsCocoaUtils::GeckoRectToNSRect(const nsIntRect& aGeckoRect,
                                 NSRect& aOutCocoaRect)
 {
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -1589,17 +1589,18 @@ NS_IMETHODIMP nsCocoaWindow::SetCursor(i
 NS_IMETHODIMP nsCocoaWindow::SetTitle(const nsAString& aTitle)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   if (!mWindow)
     return NS_OK;
 
   const nsString& strTitle = PromiseFlatString(aTitle);
-  NSString* title = [NSString stringWithCharacters:strTitle.get() length:strTitle.Length()];
+  NSString* title = [NSString stringWithCharacters:reinterpret_cast<const unichar*>(strTitle.get())
+                                            length:strTitle.Length()];
   [mWindow setTitle:title];
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsCocoaWindow::Invalidate(const nsIntRect & aRect)
--- a/widget/cocoa/nsDeviceContextSpecX.mm
+++ b/widget/cocoa/nsDeviceContextSpecX.mm
@@ -60,17 +60,19 @@ NS_IMETHODIMP nsDeviceContextSpecX::Init
 NS_IMETHODIMP nsDeviceContextSpecX::BeginDocument(const nsAString& aTitle, 
                                                   PRUnichar*       aPrintToFileName,
                                                   int32_t          aStartPage, 
                                                   int32_t          aEndPage)
 {
     NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
     if (!aTitle.IsEmpty()) {
-      CFStringRef cfString = ::CFStringCreateWithCharacters(NULL, aTitle.BeginReading(), aTitle.Length());
+      CFStringRef cfString =
+        ::CFStringCreateWithCharacters(NULL, reinterpret_cast<const UniChar*>(aTitle.BeginReading()),
+                                             aTitle.Length());
       if (cfString) {
         ::PMPrintSettingsSetJobName(mPrintSettings, cfString);
         ::CFRelease(cfString);
       }
     }
 
     OSStatus status;
     status = ::PMSetFirstPage(mPrintSettings, aStartPage, false);
--- a/widget/cocoa/nsDragService.mm
+++ b/widget/cocoa/nsDragService.mm
@@ -369,17 +369,17 @@ nsDragService::GetData(nsITransferable* 
       if (!filePath)
         continue;
 
       unsigned int stringLength = [filePath length];
       unsigned int dataLength = (stringLength + 1) * sizeof(PRUnichar); // in bytes
       PRUnichar* clipboardDataPtr = (PRUnichar*)malloc(dataLength);
       if (!clipboardDataPtr)
         return NS_ERROR_OUT_OF_MEMORY;
-      [filePath getCharacters:clipboardDataPtr];
+      [filePath getCharacters:reinterpret_cast<unichar*>(clipboardDataPtr)];
       clipboardDataPtr[stringLength] = 0; // null terminate
 
       nsCOMPtr<nsIFile> file;
       nsresult rv = NS_NewLocalFile(nsDependentString(clipboardDataPtr), true, getter_AddRefs(file));
       free(clipboardDataPtr);
       if (NS_FAILED(rv))
         continue;
 
--- a/widget/cocoa/nsFilePicker.mm
+++ b/widget/cocoa/nsFilePicker.mm
@@ -119,17 +119,18 @@ NSView* nsFilePicker::GetAccessoryView()
   nsCOMPtr<nsIStringBundleService> sbs = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
   nsCOMPtr<nsIStringBundle> bundle;
   nsresult rv = sbs->CreateBundle("chrome://global/locale/filepicker.properties", getter_AddRefs(bundle));
   if (NS_SUCCEEDED(rv)) {
     nsXPIDLString locaLabel;
     bundle->GetStringFromName(NS_LITERAL_STRING("formatLabel").get(),
 			      getter_Copies(locaLabel));
     if (locaLabel) {
-      label = [NSString stringWithCharacters:locaLabel.get() length:locaLabel.Length()];
+      label = [NSString stringWithCharacters:reinterpret_cast<const unichar*>(locaLabel.get())
+                                      length:locaLabel.Length()];
     }
   }
 
   // set up label text field
   NSTextField* textField = [[[NSTextField alloc] init] autorelease];
   [textField setEditable:NO];
   [textField setSelectable:NO];
   [textField setDrawsBackground:NO];
@@ -143,21 +144,21 @@ NSView* nsFilePicker::GetAccessoryView()
   // set up popup button
   NSPopUpButton* popupButton = [[[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 0, 0) pullsDown:NO] autorelease];
   uint32_t numMenuItems = mTitles.Length();
   for (uint32_t i = 0; i < numMenuItems; i++) {
     const nsString& currentTitle = mTitles[i];
     NSString *titleString;
     if (currentTitle.IsEmpty()) {
       const nsString& currentFilter = mFilters[i];
-      titleString = [[NSString alloc] initWithCharacters:currentFilter.get()
+      titleString = [[NSString alloc] initWithCharacters:reinterpret_cast<const unichar*>(currentFilter.get())
                                                   length:currentFilter.Length()];
     }
     else {
-      titleString = [[NSString alloc] initWithCharacters:currentTitle.get()
+      titleString = [[NSString alloc] initWithCharacters:reinterpret_cast<const unichar*>(currentTitle.get())
                                                   length:currentTitle.Length()];
     }
     [popupButton addItemWithTitle:titleString];
     [titleString release];
   }
   if (mSelectedTypeIndex >= 0 && (uint32_t)mSelectedTypeIndex < numMenuItems)
     [popupButton selectItemAtIndex:mSelectedTypeIndex];
   [popupButton setTag:kSaveTypeControlTag];
@@ -522,18 +523,18 @@ nsFilePicker::GetFilterList()
 
   if (filterWide.Equals(NS_LITERAL_STRING("*"))) {
     return nil;
   }
 
   // The extensions in filterWide are in the format "*.ext" but are expected
   // in the format "ext" by NSOpenPanel. So we need to filter some characters.
   NSMutableString* filterString = [[[NSMutableString alloc] initWithString:
-                                    [NSString stringWithCharacters:filterWide.get()
-				              length:filterWide.Length()]] autorelease];
+                                    [NSString stringWithCharacters:reinterpret_cast<const unichar*>(filterWide.get())
+                                                            length:filterWide.Length()]] autorelease];
   NSCharacterSet *set = [NSCharacterSet characterSetWithCharactersInString:@". *"];
   NSRange range = [filterString rangeOfCharacterFromSet:set];
   while (range.length) {
     [filterString replaceCharactersInRange:range withString:@""];
     range = [filterString rangeOfCharacterFromSet:set];
   }
 
   return [[[NSArray alloc] initWithArray:
@@ -560,17 +561,18 @@ NSString *
 nsFilePicker::PanelDefaultDirectory()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   NSString *directory = nil;
   if (mDisplayDirectory) {
     nsAutoString pathStr;
     mDisplayDirectory->GetPath(pathStr);
-    directory = [[[NSString alloc] initWithCharacters:pathStr.get() length:pathStr.Length()] autorelease];
+    directory = [[[NSString alloc] initWithCharacters:reinterpret_cast<const unichar*>(pathStr.get())
+                                               length:pathStr.Length()] autorelease];
   }
   return directory;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 NS_IMETHODIMP nsFilePicker::GetFile(nsIFile **aFile)
 {
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -494,17 +494,17 @@ bool nsLookAndFeel::AllowOverlayScrollba
   return (UseOverlayScrollbars() && nsCocoaFeatures::OnMountainLionOrLater());
 }
 
 // copied from gfxQuartzFontCache.mm, maybe should go in a Cocoa utils
 // file somewhere
 static void GetStringForNSString(const NSString *aSrc, nsAString& aDest)
 {
     aDest.SetLength([aSrc length]);
-    [aSrc getCharacters:aDest.BeginWriting()];
+    [aSrc getCharacters:reinterpret_cast<unichar*>(aDest.BeginWriting())];
 }
 
 bool
 nsLookAndFeel::GetFontImpl(FontID aID, nsString &aFontName,
                            gfxFontStyle &aFontStyle,
                            float aDevPixPerCSSPixel)
 {
     NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
--- a/widget/cocoa/nsMacDockSupport.mm
+++ b/widget/cocoa/nsMacDockSupport.mm
@@ -71,17 +71,18 @@ nsMacDockSupport::SetBadgeText(const nsA
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   NSDockTile *tile = [[NSApplication sharedApplication] dockTile];
   mBadgeText = aBadgeText;
   if (aBadgeText.IsEmpty())
     [tile setBadgeLabel: nil];
   else
-    [tile setBadgeLabel:[NSString stringWithCharacters:mBadgeText.get() length:mBadgeText.Length()]];
+    [tile setBadgeLabel:[NSString stringWithCharacters:reinterpret_cast<const unichar*>(mBadgeText.get())
+                                                length:mBadgeText.Length()]];
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP
 nsMacDockSupport::GetBadgeText(nsAString& aBadgeText)
 {
--- a/widget/cocoa/nsMacWebAppUtils.mm
+++ b/widget/cocoa/nsMacWebAppUtils.mm
@@ -22,17 +22,18 @@ NS_IMETHODIMP nsMacWebAppUtils::PathForA
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   outPath.Truncate();
 
   nsAutoreleasePool localPool;
 
   //note that the result of this expression might be nil, meaning no matching app was found. 
   NSString* temp = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:
-                        [NSString stringWithCharacters:((nsString)bundleIdentifier).get() length:((nsString)bundleIdentifier).Length()]];
+                        [NSString stringWithCharacters:reinterpret_cast<const unichar*>(((nsString)bundleIdentifier).get())
+                                                length:((nsString)bundleIdentifier).Length()]];
 
   if (temp) {
     // Copy out the resultant absolute path into outPath if non-nil.
     nsCocoaUtils::GetStringForNSString(temp, outPath);
   }
 
   return NS_OK;
 
@@ -41,17 +42,18 @@ NS_IMETHODIMP nsMacWebAppUtils::PathForA
 
 NS_IMETHODIMP nsMacWebAppUtils::LaunchAppWithIdentifier(const nsAString& bundleIdentifier) {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   nsAutoreleasePool localPool;
 
   // Note this might return false, meaning the app wasnt launched for some reason. 
   BOOL success = [[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:
-                        [NSString stringWithCharacters:((nsString)bundleIdentifier).get() length:((nsString)bundleIdentifier).Length()]
+                        [NSString stringWithCharacters:reinterpret_cast<const unichar*>(((nsString)bundleIdentifier).get())
+                                                length:((nsString)bundleIdentifier).Length()]
                         options: (NSWorkspaceLaunchOptions)0
                         additionalEventParamDescriptor: nil
                         launchIdentifier: NULL];
 
   return success ? NS_OK : NS_ERROR_FAILURE;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
--- a/widget/cocoa/nsMenuBarX.mm
+++ b/widget/cocoa/nsMenuBarX.mm
@@ -232,17 +232,18 @@ void nsMenuBarX::ObserveContentInserted(
       InsertMenuAtIndex(newMenu, aContainer->IndexOf(aChild));
     else
       delete newMenu;
   }
 }
 
 void nsMenuBarX::ForceUpdateNativeMenuAt(const nsAString& indexString)
 {
-  NSString* locationString = [NSString stringWithCharacters:indexString.BeginReading() length:indexString.Length()];
+  NSString* locationString = [NSString stringWithCharacters:reinterpret_cast<const unichar*>(indexString.BeginReading())
+                                                     length:indexString.Length()];
   NSArray* indexes = [locationString componentsSeparatedByString:@"|"];
   unsigned int indexCount = [indexes count];
   if (indexCount == 0)
     return;
 
   nsMenuX* currentMenu = NULL;
   int targetIndex = [[indexes objectAtIndex:0] intValue];
   int visible = 0;
@@ -500,28 +501,30 @@ NSMenuItem* nsMenuBarX::CreateNativeAppM
     nsCOMPtr<nsIDOMElement> keyElement;
     domdoc->GetElementById(key, getter_AddRefs(keyElement));
     if (keyElement) {
       nsCOMPtr<nsIContent> keyContent (do_QueryInterface(keyElement));
       // first grab the key equivalent character
       nsAutoString keyChar(NS_LITERAL_STRING(" "));
       keyContent->GetAttr(kNameSpaceID_None, nsGkAtoms::key, keyChar);
       if (!keyChar.EqualsLiteral(" ")) {
-        keyEquiv = [[NSString stringWithCharacters:keyChar.get() length:keyChar.Length()] lowercaseString];
+        keyEquiv = [[NSString stringWithCharacters:reinterpret_cast<const unichar*>(keyChar.get())
+                                            length:keyChar.Length()] lowercaseString];
       }
       // now grab the key equivalent modifiers
       nsAutoString modifiersStr;
       keyContent->GetAttr(kNameSpaceID_None, nsGkAtoms::modifiers, modifiersStr);
       uint8_t geckoModifiers = nsMenuUtilsX::GeckoModifiersForNodeAttribute(modifiersStr);
       macKeyModifiers = nsMenuUtilsX::MacModifiersForGeckoModifiers(geckoModifiers);
     }
   }
   // get the label into NSString-form
-  NSString* labelString = [NSString stringWithCharacters:label.get() length:label.Length()];
-  
+  NSString* labelString = [NSString stringWithCharacters:reinterpret_cast<const unichar*>(label.get())
+                                                  length:label.Length()];
+
   if (!labelString)
     labelString = @"";
   if (!keyEquiv)
     keyEquiv = @"";
 
   // put together the actual NSMenuItem
   NSMenuItem* newMenuItem = [[NSMenuItem alloc] initWithTitle:labelString action:action keyEquivalent:keyEquiv];
   
--- a/widget/cocoa/nsMenuUtilsX.mm
+++ b/widget/cocoa/nsMenuUtilsX.mm
@@ -49,17 +49,18 @@ void nsMenuUtilsX::DispatchCommandTo(nsI
 NSString* nsMenuUtilsX::GetTruncatedCocoaLabel(const nsString& itemLabel)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   // We want to truncate long strings to some reasonable pixel length but there is no
   // good API for doing that which works for all OS versions and architectures. For now
   // we'll do nothing for consistency and depend on good user interface design to limit
   // string lengths.
-  return [NSString stringWithCharacters:itemLabel.get() length:itemLabel.Length()];
+  return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(itemLabel.get())
+                                 length:itemLabel.Length()];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 uint8_t nsMenuUtilsX::GeckoModifiersForNodeAttribute(const nsString& modifiersAttribute)
 {
   uint8_t modifiers = knsMenuItemNoModifier;
   char* str = ToNewCString(modifiersAttribute);
--- a/widget/cocoa/nsPrintDialogX.mm
+++ b/widget/cocoa/nsPrintDialogX.mm
@@ -48,17 +48,18 @@ nsPrintDialogServiceX::Show(nsIDOMWindow
   if (!settingsX)
     return NS_ERROR_FAILURE;
 
   // Set the print job title
   PRUnichar** docTitles;
   uint32_t titleCount;
   nsresult rv = aWebBrowserPrint->EnumerateDocumentNames(&titleCount, &docTitles);
   if (NS_SUCCEEDED(rv) && titleCount > 0) {
-    CFStringRef cfTitleString = CFStringCreateWithCharacters(NULL, docTitles[0], NS_strlen(docTitles[0]));
+    CFStringRef cfTitleString = CFStringCreateWithCharacters(NULL, reinterpret_cast<const UniChar*>(docTitles[0]),
+                                                             NS_strlen(docTitles[0]));
     if (cfTitleString) {
       ::PMPrintSettingsSetJobName(settingsX->GetPMPrintSettings(), cfTitleString);
       CFRelease(cfTitleString);
     }
     for (int32_t i = titleCount - 1; i >= 0; i--) {
       NS_Free(docTitles[i]);
     }
     NS_Free(docTitles);
--- a/widget/cocoa/nsSound.mm
+++ b/widget/cocoa/nsSound.mm
@@ -76,17 +76,17 @@ nsSound::PlaySystemSound(const nsAString
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   if (NS_IsMozAliasSound(aSoundAlias)) {
     NS_WARNING("nsISound::playSystemSound is called with \"_moz_\" events, they are obsolete, use nsISound::playEventSound instead");
     // Mac doesn't have system sound settings for each user actions.
     return NS_OK;
   }
 
-  NSString *name = [NSString stringWithCharacters:aSoundAlias.BeginReading()
+  NSString *name = [NSString stringWithCharacters:reinterpret_cast<const unichar*>(aSoundAlias.BeginReading())
                                            length:aSoundAlias.Length()];
   NSSound *sound = [NSSound soundNamed:name];
   if (sound) {
     [sound stop];
     [sound play];
   }
 
   return NS_OK;
--- a/widget/cocoa/nsStandaloneNativeMenu.mm
+++ b/widget/cocoa/nsStandaloneNativeMenu.mm
@@ -128,17 +128,18 @@ NativeMenuItemWithLocation(NSMenu * curr
 NS_IMETHODIMP
 nsStandaloneNativeMenu::ActivateNativeMenuItemAt(const nsAString& indexString)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
   
   if (!mMenu)
     return NS_ERROR_NOT_INITIALIZED;
 
-  NSString * locationString = [NSString stringWithCharacters:indexString.BeginReading() length:indexString.Length()];
+  NSString * locationString = [NSString stringWithCharacters:reinterpret_cast<const unichar*>(indexString.BeginReading())
+                                                      length:indexString.Length()];
   NSMenu * menu = static_cast<NSMenu *> (mMenu->NativeData());
   NSMenuItem * item = NativeMenuItemWithLocation(menu, locationString);
 
   // We can't perform an action on an item with a submenu, that will raise
   // an obj-c exception.
   if (item && ![item hasSubmenu]) {
     NSMenu * parent = [item menu];
     if (parent) {
@@ -155,17 +156,18 @@ nsStandaloneNativeMenu::ActivateNativeMe
 }
 
 NS_IMETHODIMP
 nsStandaloneNativeMenu::ForceUpdateNativeMenuAt(const nsAString& indexString)
 {
   if (!mMenu)
     return NS_ERROR_NOT_INITIALIZED;
 
-  NSString* locationString = [NSString stringWithCharacters:indexString.BeginReading() length:indexString.Length()];
+  NSString* locationString = [NSString stringWithCharacters:reinterpret_cast<const unichar*>(indexString.BeginReading())
+                                                     length:indexString.Length()];
   NSArray* indexes = [locationString componentsSeparatedByString:@"|"];
   unsigned int indexCount = [indexes count];
   if (indexCount == 0)
     return NS_OK;
 
   nsMenuX* currentMenu = mMenu;
 
   // now find the correct submenu