зеркало из https://github.com/mozilla/pjs.git
fix encoding of window titles in apple events. b=448087 r=smichaud sr=roc
This commit is contained in:
Родитель
bac21bef2f
Коммит
7be29ef19f
|
@ -36,7 +36,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <MacWindows.h>
|
||||
#include "nsWindowUtils.h"
|
||||
|
||||
#include "nsCommandLineServiceMac.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -61,7 +61,6 @@
|
|||
#include "nsIXULWindow.h"
|
||||
#include "nsString.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsWindowUtils.h"
|
||||
#include "nsMacUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIXULWindow.h"
|
||||
|
@ -407,6 +406,8 @@ TAEListIndex nsWindowUtils::GetWindowIndex(TWindowKind windowKind, WindowPtr the
|
|||
//---------------------------------------------------------
|
||||
void nsWindowUtils::GetCleanedWindowName(WindowPtr wind, char* outName, long maxLen)
|
||||
{
|
||||
outName[0] = '\0';
|
||||
|
||||
nsCOMPtr<nsIXULWindow> xulWindow;
|
||||
GetXULWindowFromWindowPtr(wind, getter_AddRefs(xulWindow));
|
||||
ThrowErrIfNil(xulWindow, paramErr);
|
||||
|
@ -425,9 +426,13 @@ void nsWindowUtils::GetCleanedWindowName(WindowPtr wind, char* outName, long max
|
|||
baseWindow->GetTitle(getter_Copies(title));
|
||||
ThrowErrIfNil(title, paramErr);
|
||||
|
||||
const char* cTitle = NS_ConvertUTF16toUTF8(title).get();
|
||||
strncpy(outName, cTitle, maxLen);
|
||||
outName[maxLen - 1] = '\0';
|
||||
// convert to MacRoman, which is what AppleEvents expects
|
||||
CFStringRef windowTitleCFString = ::CFStringCreateWithCharacters(kCFAllocatorDefault, title.get(), kCFStringEncodingUTF16);
|
||||
if (windowTitleCFString) {
|
||||
::CFStringGetCString(windowTitleCFString, outName, maxLen, kCFStringEncodingMacRoman);
|
||||
outName[maxLen - 1] = '\0'; // in case it didn't get null terminated
|
||||
::CFRelease(windowTitleCFString);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -40,8 +40,7 @@
|
|||
#ifndef nsWindowUtils_h_
|
||||
#define nsWindowUtils_h_
|
||||
|
||||
#include <Quickdraw.h>
|
||||
#include <MacWindows.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
#include "nsAEDefs.h"
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче