Bug 1476477 - Replace nsAutoCString with nsCString for local result variables in windows widget. r?masayuki
MozReview-Commit-ID: JN6GVPTZNg2
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -267,17 +267,17 @@ GetKeyLocationName(uint32_t aLocation)
}
static const nsCString
GetCharacterCodeName(const char16_t* aChars, uint32_t aLength)
{
if (!aLength) {
return EmptyCString();
}
- nsAutoCString result;
+ nsCString result;
for (uint32_t i = 0; i < aLength; ++i) {
if (!result.IsEmpty()) {
result.AppendLiteral(", ");
} else {
result.AssignLiteral("\"");
}
result.Append(GetCharacterCodeName(aChars[i]));
}
@@ -286,17 +286,17 @@ GetCharacterCodeName(const char16_t* aCh
}
static const nsCString
GetCharacterCodeName(const UniCharsAndModifiers& aUniCharsAndModifiers)
{
if (aUniCharsAndModifiers.IsEmpty()) {
return EmptyCString();
}
- nsAutoCString result;
+ nsCString result;
for (uint32_t i = 0; i < aUniCharsAndModifiers.Length(); i++) {
if (!result.IsEmpty()) {
result.AppendLiteral(", ");
} else {
result.AssignLiteral("\"");
}
result.Append(GetCharacterCodeName(aUniCharsAndModifiers.CharAt(i)));
}
@@ -573,17 +573,17 @@ private:
AppendLiteral(" | ");
}
}
};
static const nsCString
ToString(const MSG& aMSG)
{
- nsAutoCString result;
+ nsCString result;
result.AssignLiteral("{ message=");
result.Append(GetMessageName(aMSG.message).get());
result.AppendLiteral(", ");
switch (aMSG.message) {
case WM_KEYDOWN:
case WM_KEYUP:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
@@ -636,17 +636,17 @@ ToString(const MSG& aMSG)
}
static const nsCString
ToString(const UniCharsAndModifiers& aUniCharsAndModifiers)
{
if (aUniCharsAndModifiers.IsEmpty()) {
return NS_LITERAL_CSTRING("{}");
}
- nsAutoCString result;
+ nsCString result;
result.AssignLiteral("{ ");
result.Append(GetCharacterCodeName(aUniCharsAndModifiers.CharAt(0)));
for (size_t i = 1; i < aUniCharsAndModifiers.Length(); ++i) {
if (aUniCharsAndModifiers.ModifiersAt(i - 1) !=
aUniCharsAndModifiers.ModifiersAt(i)) {
result.AppendLiteral(" [");
result.Append(GetModifiersName(aUniCharsAndModifiers.ModifiersAt(0)));
result.AppendLiteral("]");
@@ -659,17 +659,17 @@ ToString(const UniCharsAndModifiers& aUn
result.Append(GetModifiersName(aUniCharsAndModifiers.ModifiersAt(lastIndex)));
result.AppendLiteral("] }");
return result;
}
const nsCString
ToString(const ModifierKeyState& aModifierKeyState)
{
- nsAutoCString result;
+ nsCString result;
result.AssignLiteral("{ ");
result.Append(GetModifiersName(aModifierKeyState.GetModifiers()).get());
result.AppendLiteral(" }");
return result;
}
// Unique id counter associated with a keydown / keypress events. Used in
// identifing keypress events for removal from async event dispatch queue
@@ -2852,17 +2852,17 @@ NativeKey::NeedsToHandleWithoutFollowing
static nsCString
GetResultOfInSendMessageEx()
{
DWORD ret = ::InSendMessageEx(nullptr);
if (!ret) {
return NS_LITERAL_CSTRING("ISMEX_NOSEND");
}
- nsAutoCString result;
+ nsCString result;
if (ret & ISMEX_CALLBACK) {
result = "ISMEX_CALLBACK";
}
if (ret & ISMEX_NOTIFY) {
if (!result.IsEmpty()) {
result += " | ";
}
result += "ISMEX_NOTIFY";
@@ -4192,17 +4192,17 @@ KeyboardLayout::GetLayoutName(HKL aLayou
key.get(), L"Layout Text",
buf, sizeof(buf)))) {
return NS_LITERAL_CSTRING("No name or too long name");
}
return NS_ConvertUTF16toUTF8(buf);
}
if (NS_WARN_IF((layout & 0xF000) != 0xF000)) {
- nsAutoCString result;
+ nsCString result;
result.AppendPrintf("Odd HKL: 0x%08X",
reinterpret_cast<uintptr_t>(aLayout));
return result;
}
// Otherwise, we need to walk the registry under "Keyboard Layouts".
nsCOMPtr<nsIWindowsRegKey> regKey =
do_CreateInstance("@mozilla.org/windows-registry-key;1");
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -63,17 +63,17 @@ HandleSeparator(nsCString& aDesc)
if (!aDesc.IsEmpty()) {
aDesc.AppendLiteral(" | ");
}
}
static const nsCString
GetFindFlagName(DWORD aFindFlag)
{
- nsAutoCString description;
+ nsCString description;
if (!aFindFlag) {
description.AppendLiteral("no flags (0)");
return description;
}
if (aFindFlag & TS_ATTR_FIND_BACKWARDS) {
description.AppendLiteral("TS_ATTR_FIND_BACKWARDS");
}
if (aFindFlag & TS_ATTR_FIND_WANT_OFFSET) {
@@ -157,17 +157,17 @@ static nsCString
GetCLSIDNameStr(REFCLSID aCLSID)
{
LPOLESTR str = nullptr;
HRESULT hr = ::StringFromCLSID(aCLSID, &str);
if (FAILED(hr) || !str || !str[0]) {
return EmptyCString();
}
- nsAutoCString result;
+ nsCString result;
result = NS_ConvertUTF16toUTF8(str);
::CoTaskMemFree(str);
return result;
}
static nsCString
GetGUIDNameStr(REFGUID aGUID)
{
@@ -286,17 +286,17 @@ GetRIIDNameStr(REFIID aRIID)
HRESULT hr = ::StringFromIID(aRIID, &str);
if (FAILED(hr) || !str || !str[0]) {
return EmptyCString();
}
nsAutoString key(L"Interface\\");
key += str;
- nsAutoCString result;
+ nsCString result;
wchar_t buf[256];
if (WinUtils::GetRegistryKey(HKEY_CLASSES_ROOT, key.get(), nullptr,
buf, sizeof(buf))) {
result = NS_ConvertUTF16toUTF8(buf);
} else {
result = NS_ConvertUTF16toUTF8(str);
}
@@ -366,17 +366,17 @@ GetTextStoreReturnValueName(HRESULT aRes
default:
return GetCommonReturnValueName(aResult);
}
}
static const nsCString
GetSinkMaskNameStr(DWORD aSinkMask)
{
- nsAutoCString description;
+ nsCString description;
if (aSinkMask & TS_AS_TEXT_CHANGE) {
description.AppendLiteral("TS_AS_TEXT_CHANGE");
}
if (aSinkMask & TS_AS_SEL_CHANGE) {
HandleSeparator(description);
description.AppendLiteral("TS_AS_SEL_CHANGE");
}
if (aSinkMask & TS_AS_LAYOUT_CHANGE) {
@@ -403,17 +403,17 @@ GetActiveSelEndName(TsActiveSelEnd aSelE
return aSelEnd == TS_AE_NONE ? "TS_AE_NONE" :
aSelEnd == TS_AE_START ? "TS_AE_START" :
aSelEnd == TS_AE_END ? "TS_AE_END" : "Unknown";
}
static const nsCString
GetLockFlagNameStr(DWORD aLockFlags)
{
- nsAutoCString description;
+ nsCString description;
if ((aLockFlags & TS_LF_READWRITE) == TS_LF_READWRITE) {
description.AppendLiteral("TS_LF_READWRITE");
} else if (aLockFlags & TS_LF_READ) {
description.AppendLiteral("TS_LF_READ");
}
if (aLockFlags & TS_LF_SYNC) {
if (!description.IsEmpty()) {
description.AppendLiteral(" | ");
@@ -502,17 +502,17 @@ GetClauseAttrName(TF_DA_ATTR_INFO aAttr)
return nsPrintfCString("Unknown(%08X)", static_cast<int32_t>(aAttr));
}
}
}
static nsCString
GetDisplayAttrStr(const TF_DISPLAYATTRIBUTE& aDispAttr)
{
- nsAutoCString str;
+ nsCString str;
str = "crText:{ ";
str += GetColorName(aDispAttr.crText);
str += " }, crBk:{ ";
str += GetColorName(aDispAttr.crBk);
str += " }, lsStyle: ";
str += GetLineStyleName(aDispAttr.lsStyle);
str += ", fBoldLine: ";
str += GetBoolName(aDispAttr.fBoldLine);
@@ -544,17 +544,17 @@ GetMouseButtonName(int16_t aButton)
}
static nsCString
GetMouseButtonsName(int16_t aButtons)
{
if (!aButtons) {
return NS_LITERAL_CSTRING("no buttons");
}
- nsAutoCString names;
+ nsCString names;
if (aButtons & WidgetMouseEventBase::eLeftButtonFlag) {
names = "LeftButton";
}
if (aButtons & WidgetMouseEventBase::eRightButtonFlag) {
ADD_SEPARATOR_IF_NECESSARY(names);
names += "RightButton";
}
if (aButtons & WidgetMouseEventBase::eMiddleButtonFlag) {
@@ -573,17 +573,17 @@ GetMouseButtonsName(int16_t aButtons)
}
static nsCString
GetModifiersName(Modifiers aModifiers)
{
if (aModifiers == MODIFIER_NONE) {
return NS_LITERAL_CSTRING("no modifiers");
}
- nsAutoCString names;
+ nsCString names;
if (aModifiers & MODIFIER_ALT) {
names = NS_DOM_KEYNAME_ALT;
}
if (aModifiers & MODIFIER_ALTGRAPH) {
ADD_SEPARATOR_IF_NECESSARY(names);
names += NS_DOM_KEYNAME_ALTGRAPH;
}
if (aModifiers & MODIFIER_CAPSLOCK) {