mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1382563 - Remove ns*String::AssignWithConversion. r=erahm.
This patch replaces four functions of the name AssignWithConversion which are essentially wrappers around CopyASCIItoUTF16 and LossyCopyUTF16toASCII with direct calls to the latter two functions. The replaced functions are: void nsCString::AssignWithConversion( const nsAString& aData ) void nsString::AssignWithConversion( const nsACString& aData ) void nsTString_CharT::AssignWithConversion( const incompatible_char_type* aData, int32_t aLength = -1); The last of the three exists inside the double-included nsTString* world and so describes two functions, giving four in total. This has two advantages: * it removes code * at the call points, it makes clear (from the replacement name) which conversion is being carried out. The generic name "AssignWithConversion" doesn't make that obvious -- one had to infer it from the types. The patch also removes two commented out lines from editor/composer/nsComposerCommands.cpp, that appear to be related. They are at top level, where they would never have compiled. They look like leftovers from some previous change. --HG-- extra : rebase_source : fb47bf450771c3c9ee3341dd14520f5da69ec4f5
This commit is contained in:
parent
04a45b0f66
commit
408d24da56
@ -583,7 +583,7 @@ private:
|
||||
innerID = NS_LITERAL_STRING("ServiceWorker");
|
||||
// Use scope as ID so the webconsole can decide if the message should
|
||||
// show up per tab
|
||||
id.AssignWithConversion(mWorkerPrivate->ServiceWorkerScope());
|
||||
CopyASCIItoUTF16(mWorkerPrivate->ServiceWorkerScope(), id);
|
||||
} else {
|
||||
innerID = NS_LITERAL_STRING("Worker");
|
||||
}
|
||||
|
@ -4420,7 +4420,7 @@ struct StorageOpenTraits<nsIFile*>
|
||||
nsString path;
|
||||
MOZ_ALWAYS_SUCCEEDS(aFile->GetPath(path));
|
||||
|
||||
aPath.AssignWithConversion(path);
|
||||
LossyCopyUTF16toASCII(path, aPath);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
@ -22201,7 +22201,7 @@ OpenDatabaseOp::UpdateLocaleAwareIndex(mozIStorageConnection* aConnection,
|
||||
}
|
||||
|
||||
nsString locale;
|
||||
locale.AssignWithConversion(aLocale);
|
||||
CopyASCIItoUTF16(aLocale, locale);
|
||||
rv = metaStmt->BindStringByName(NS_LITERAL_CSTRING("locale"), locale);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
|
@ -253,7 +253,7 @@ IDBIndex::GetLocale(nsString& aLocale) const
|
||||
if (mMetadata->locale().IsEmpty()) {
|
||||
SetDOMStringToNull(aLocale);
|
||||
} else {
|
||||
aLocale.AssignWithConversion(mMetadata->locale());
|
||||
CopyASCIItoUTF16(mMetadata->locale(), aLocale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1541,7 +1541,7 @@ nsWebBrowserPersist::GetExtensionForContentType(const char16_t *aContentType, ch
|
||||
}
|
||||
|
||||
nsAutoCString contentType;
|
||||
contentType.AssignWithConversion(aContentType);
|
||||
LossyCopyUTF16toASCII(aContentType, contentType);
|
||||
nsAutoCString ext;
|
||||
rv = mMIMEService->GetPrimaryExtension(contentType, EmptyCString(), ext);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
@ -2091,7 +2091,7 @@ nsWebBrowserPersist::CalculateUniqueFilename(nsIURI *aURI)
|
||||
if (localFile)
|
||||
{
|
||||
nsAutoString filenameAsUnichar;
|
||||
filenameAsUnichar.AssignWithConversion(filename.get());
|
||||
CopyASCIItoUTF16(filename, filenameAsUnichar);
|
||||
localFile->SetLeafName(filenameAsUnichar);
|
||||
|
||||
// Resync the URI with the file after the extension has been appended
|
||||
@ -2126,7 +2126,7 @@ nsWebBrowserPersist::MakeFilenameFromURI(nsIURI *aURI, nsString &aFilename)
|
||||
url->GetFileName(nameFromURL);
|
||||
if (mPersistFlags & PERSIST_FLAGS_DONT_CHANGE_FILENAMES)
|
||||
{
|
||||
fileName.AssignWithConversion(NS_UnescapeURL(nameFromURL).BeginReading());
|
||||
CopyASCIItoUTF16(NS_UnescapeURL(nameFromURL), fileName);
|
||||
aFilename = fileName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -635,7 +635,7 @@ nsXBLPrototypeBinding::ConstructAttributeTable(nsIContent* aElement)
|
||||
int32_t attributeNsID = kNameSpaceID_None;
|
||||
|
||||
// Figure out if this token contains a :.
|
||||
nsAutoString attrTok; attrTok.AssignWithConversion(token);
|
||||
NS_ConvertASCIItoUTF16 attrTok(token);
|
||||
int32_t index = attrTok.Find("=", true);
|
||||
nsresult rv;
|
||||
if (index != -1) {
|
||||
@ -655,8 +655,7 @@ nsXBLPrototypeBinding::ConstructAttributeTable(nsIContent* aElement)
|
||||
return;
|
||||
}
|
||||
else {
|
||||
nsAutoString tok;
|
||||
tok.AssignWithConversion(token);
|
||||
NS_ConvertASCIItoUTF16 tok(token);
|
||||
rv = nsContentUtils::SplitQName(aElement, tok, &atomNsID,
|
||||
getter_AddRefs(atom));
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -772,7 +772,7 @@ static const keyCodeData gKeyCodes[] = {
|
||||
int32_t nsXBLPrototypeHandler::GetMatchingKeyCode(const nsAString& aKeyName)
|
||||
{
|
||||
nsAutoCString keyName;
|
||||
keyName.AssignWithConversion(aKeyName);
|
||||
LossyCopyUTF16toASCII(aKeyName, keyName);
|
||||
ToUpperCase(keyName); // We want case-insensitive comparison with data
|
||||
// stored as uppercase.
|
||||
|
||||
|
@ -448,7 +448,7 @@ public:
|
||||
, mReceivedLoadStart(false)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
mEventType.AssignWithConversion(sEventStrings[STRING_loadstart]);
|
||||
CopyASCIItoUTF16(sEventStrings[STRING_loadstart], mEventType);
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
@ -3814,7 +3814,7 @@ XULDocument::OverlayForwardReference::Resolve()
|
||||
|
||||
if (MOZ_LOG_TEST(gXULLog, LogLevel::Debug)) {
|
||||
nsAutoCString idC;
|
||||
idC.AssignWithConversion(id);
|
||||
LossyCopyUTF16toASCII(id, idC);
|
||||
MOZ_LOG(gXULLog, LogLevel::Debug,
|
||||
("xul: overlay resolved '%s'",
|
||||
idC.get()));
|
||||
@ -3986,7 +3986,7 @@ XULDocument::OverlayForwardReference::~OverlayForwardReference()
|
||||
mOverlay->GetAttr(kNameSpaceID_None, nsGkAtoms::id, id);
|
||||
|
||||
nsAutoCString idC;
|
||||
idC.AssignWithConversion(id);
|
||||
LossyCopyUTF16toASCII(id, idC);
|
||||
|
||||
nsIURI *protoURI = mDocument->mCurrentPrototype->GetURI();
|
||||
|
||||
@ -4037,8 +4037,8 @@ XULDocument::BroadcasterHookup::~BroadcasterHookup()
|
||||
}
|
||||
|
||||
nsAutoCString attributeC,broadcasteridC;
|
||||
attributeC.AssignWithConversion(attribute);
|
||||
broadcasteridC.AssignWithConversion(broadcasterID);
|
||||
LossyCopyUTF16toASCII(attribute, attributeC);
|
||||
LossyCopyUTF16toASCII(broadcasterID, broadcasteridC);
|
||||
MOZ_LOG(gXULLog, LogLevel::Warning,
|
||||
("xul: broadcaster hookup failed <%s attribute='%s'> to %s",
|
||||
nsAtomCString(mObservesElement->NodeInfo()->NameAtom()).get(),
|
||||
@ -4249,8 +4249,8 @@ XULDocument::CheckBroadcasterHookup(Element* aElement,
|
||||
return rv;
|
||||
|
||||
nsAutoCString attributeC,broadcasteridC;
|
||||
attributeC.AssignWithConversion(attribute);
|
||||
broadcasteridC.AssignWithConversion(broadcasterID);
|
||||
LossyCopyUTF16toASCII(attribute, attributeC);
|
||||
LossyCopyUTF16toASCII(broadcasterID, broadcasteridC);
|
||||
MOZ_LOG(gXULLog, LogLevel::Debug,
|
||||
("xul: broadcaster hookup <%s attribute='%s'> to %s",
|
||||
nsAtomCString(content->NodeInfo()->NameAtom()).get(),
|
||||
|
@ -263,8 +263,8 @@ nsXULCommandDispatcher::AddCommandUpdater(nsIDOMElement* aElement,
|
||||
#ifdef DEBUG
|
||||
if (MOZ_LOG_TEST(gCommandLog, LogLevel::Debug)) {
|
||||
nsAutoCString eventsC, targetsC, aeventsC, atargetsC;
|
||||
eventsC.AssignWithConversion(updater->mEvents);
|
||||
targetsC.AssignWithConversion(updater->mTargets);
|
||||
LossyCopyUTF16toASCII(updater->mEvents, eventsC);
|
||||
LossyCopyUTF16toASCII(updater->mTargets, targetsC);
|
||||
CopyUTF16toUTF8(aEvents, aeventsC);
|
||||
CopyUTF16toUTF8(aTargets, atargetsC);
|
||||
MOZ_LOG(gCommandLog, LogLevel::Debug,
|
||||
@ -322,8 +322,8 @@ nsXULCommandDispatcher::RemoveCommandUpdater(nsIDOMElement* aElement)
|
||||
#ifdef DEBUG
|
||||
if (MOZ_LOG_TEST(gCommandLog, LogLevel::Debug)) {
|
||||
nsAutoCString eventsC, targetsC;
|
||||
eventsC.AssignWithConversion(updater->mEvents);
|
||||
targetsC.AssignWithConversion(updater->mTargets);
|
||||
LossyCopyUTF16toASCII(updater->mEvents, eventsC);
|
||||
LossyCopyUTF16toASCII(updater->mTargets, targetsC);
|
||||
MOZ_LOG(gCommandLog, LogLevel::Debug,
|
||||
("xulcmd[%p] remove %p(events=%s targets=%s)",
|
||||
this, aElement,
|
||||
|
@ -1013,7 +1013,7 @@ nsXULTemplateQueryProcessorRDF::Log(const char* aOperation,
|
||||
return rv;
|
||||
|
||||
nsAutoCString targetstrC;
|
||||
targetstrC.AssignWithConversion(targetStr);
|
||||
LossyCopyUTF16toASCII(targetStr, targetstrC);
|
||||
MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
|
||||
(" --[%s]-->[%s]",
|
||||
propertyStr,
|
||||
@ -1239,7 +1239,7 @@ nsXULTemplateQueryProcessorRDF::CompileQueryChild(nsIAtom* aTag,
|
||||
aTag->ToString(tagstr);
|
||||
|
||||
nsAutoCString tagstrC;
|
||||
tagstrC.AssignWithConversion(tagstr);
|
||||
LossyCopyUTF16toASCII(tagstr, tagstrC);
|
||||
MOZ_LOG(gXULTemplateLog, LogLevel::Info,
|
||||
("xultemplate[%p] unrecognized condition test <%s>",
|
||||
this, tagstrC.get()));
|
||||
|
@ -587,7 +587,7 @@ nsMultiStateCommand::DoCommandParams(const char *aCommandName,
|
||||
nsXPIDLCString s;
|
||||
rv = aParams->GetCStringValue(STATE_ATTRIBUTE, getter_Copies(s));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
tString.AssignWithConversion(s);
|
||||
CopyASCIItoUTF16(s, tString);
|
||||
else
|
||||
rv = aParams->GetStringValue(STATE_ATTRIBUTE, tString);
|
||||
}
|
||||
@ -630,7 +630,7 @@ nsParagraphStateCommand::GetCurrentState(nsIEditor *aEditor,
|
||||
nsresult rv = htmlEditor->GetParagraphState(&outMixed, outStateString);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoCString tOutStateString;
|
||||
tOutStateString.AssignWithConversion(outStateString);
|
||||
LossyCopyUTF16toASCII(outStateString, tOutStateString);
|
||||
aParams->SetBooleanValue(STATE_MIXED,outMixed);
|
||||
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
|
||||
}
|
||||
@ -707,8 +707,6 @@ nsFontSizeStateCommand::nsFontSizeStateCommand()
|
||||
{
|
||||
}
|
||||
|
||||
// nsAutoCString tOutStateString;
|
||||
// tOutStateString.AssignWithConversion(outStateString);
|
||||
nsresult
|
||||
nsFontSizeStateCommand::GetCurrentState(nsIEditor *aEditor,
|
||||
nsICommandParams *aParams)
|
||||
@ -728,7 +726,7 @@ nsFontSizeStateCommand::GetCurrentState(nsIEditor *aEditor,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoCString tOutStateString;
|
||||
tOutStateString.AssignWithConversion(outStateString);
|
||||
LossyCopyUTF16toASCII(outStateString, tOutStateString);
|
||||
aParams->SetBooleanValue(STATE_MIXED, anyHas && !allHas);
|
||||
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
|
||||
aParams->SetBooleanValue(STATE_ENABLED, true);
|
||||
@ -791,7 +789,7 @@ nsFontColorStateCommand::GetCurrentState(nsIEditor *aEditor,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoCString tOutStateString;
|
||||
tOutStateString.AssignWithConversion(outStateString);
|
||||
LossyCopyUTF16toASCII(outStateString, tOutStateString);
|
||||
aParams->SetBooleanValue(STATE_MIXED, outMixed);
|
||||
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
|
||||
return NS_OK;
|
||||
@ -832,7 +830,7 @@ nsHighlightColorStateCommand::GetCurrentState(nsIEditor *aEditor,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoCString tOutStateString;
|
||||
tOutStateString.AssignWithConversion(outStateString);
|
||||
LossyCopyUTF16toASCII(outStateString, tOutStateString);
|
||||
aParams->SetBooleanValue(STATE_MIXED, outMixed);
|
||||
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
|
||||
return NS_OK;
|
||||
@ -889,7 +887,7 @@ nsBackgroundColorStateCommand::GetCurrentState(nsIEditor *aEditor,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoCString tOutStateString;
|
||||
tOutStateString.AssignWithConversion(outStateString);
|
||||
LossyCopyUTF16toASCII(outStateString, tOutStateString);
|
||||
aParams->SetBooleanValue(STATE_MIXED, outMixed);
|
||||
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
|
||||
return NS_OK;
|
||||
@ -945,7 +943,7 @@ nsAlignCommand::GetCurrentState(nsIEditor *aEditor, nsICommandParams *aParams)
|
||||
break;
|
||||
}
|
||||
nsAutoCString tOutStateString;
|
||||
tOutStateString.AssignWithConversion(outStateString);
|
||||
LossyCopyUTF16toASCII(outStateString, tOutStateString);
|
||||
aParams->SetBooleanValue(STATE_MIXED,outMixed);
|
||||
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
|
||||
return NS_OK;
|
||||
@ -1408,7 +1406,8 @@ nsInsertTagCommand::DoCommandParams(const char *aCommandName,
|
||||
nsXPIDLCString s;
|
||||
nsresult rv = aParams->GetCStringValue(STATE_ATTRIBUTE, getter_Copies(s));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAutoString attrib; attrib.AssignWithConversion(s);
|
||||
nsAutoString attrib;
|
||||
CopyASCIItoUTF16(s, attrib);
|
||||
|
||||
if (attrib.IsEmpty())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
@ -3488,7 +3488,7 @@ HTMLEditor::StyleSheetLoaded(StyleSheet* aSheet,
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Save it so we can remove before applying the next one
|
||||
mLastStyleSheetURL.AssignWithConversion(spec.get());
|
||||
CopyASCIItoUTF16(spec, mLastStyleSheetURL);
|
||||
|
||||
// Also save in our arrays of urls and sheets
|
||||
AddNewStyleSheetToList(mLastStyleSheetURL, aSheet);
|
||||
|
@ -1153,7 +1153,7 @@ HTMLEditor::InsertFromTransferable(nsITransferable* transferable,
|
||||
&len))) {
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(this);
|
||||
nsAutoString flavor;
|
||||
flavor.AssignWithConversion(bestFlavor);
|
||||
CopyASCIItoUTF16(bestFlavor, flavor);
|
||||
nsAutoString stuffToPaste;
|
||||
bool isSafe = IsSafeToInsertData(aSourceDoc);
|
||||
|
||||
|
@ -184,7 +184,7 @@ xpc::ErrorBase::Init(JSErrorBase* aReport)
|
||||
if (!aReport->filename)
|
||||
mFileName.SetIsVoid(true);
|
||||
else
|
||||
mFileName.AssignWithConversion(aReport->filename);
|
||||
CopyASCIItoUTF16(aReport->filename, mFileName);
|
||||
|
||||
mLineNumber = aReport->lineno;
|
||||
mColumn = aReport->column;
|
||||
|
@ -6741,7 +6741,7 @@ CSSParserImpl::ParseColor(nsCSSValue& aValue)
|
||||
case eCSSToken_Number:
|
||||
if (tk->mIntegerValid && tk->mInteger < 1000000 && tk->mInteger >= 0) {
|
||||
SprintfLiteral(buffer, "%06d", tk->mInteger);
|
||||
str.AssignWithConversion(buffer);
|
||||
CopyASCIItoUTF16(buffer, str);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -6751,7 +6751,7 @@ CSSParserImpl::ParseColor(nsCSSValue& aValue)
|
||||
tk->mInteger >= 0) {
|
||||
SprintfLiteral(buffer, "%06d", tk->mInteger);
|
||||
nsAutoString temp;
|
||||
temp.AssignWithConversion(buffer);
|
||||
CopyASCIItoUTF16(buffer, temp);
|
||||
temp.Right(str, 6 - tk->mIdent.Length());
|
||||
str.Append(tk->mIdent);
|
||||
}
|
||||
|
@ -89,13 +89,13 @@ GetModuleNameForTelemetry(/*in*/ const SECMODModule* module,
|
||||
{
|
||||
result.Truncate();
|
||||
if (module->dllName) {
|
||||
result.AssignWithConversion(module->dllName);
|
||||
CopyASCIItoUTF16(module->dllName, result);
|
||||
int32_t separatorIndex = result.RFind(FILE_PATH_SEPARATOR);
|
||||
if (separatorIndex != kNotFound) {
|
||||
result = Substring(result, separatorIndex + 1);
|
||||
}
|
||||
} else {
|
||||
result.AssignWithConversion(module->commonName);
|
||||
CopyASCIItoUTF16(module->commonName, result);
|
||||
}
|
||||
if (result.Length() >= 70) {
|
||||
result.Truncate(69);
|
||||
|
@ -255,9 +255,9 @@ static HWND CreateRadioBtn(HINSTANCE aHInst,
|
||||
const char* aStr,
|
||||
const nsIntRect& aRect)
|
||||
{
|
||||
nsString cStr;
|
||||
cStr.AssignWithConversion(aStr);
|
||||
return CreateControl("BUTTON", BS_RADIOBUTTON, aHInst, aHdlg, aId, cStr, aRect);
|
||||
nsString str;
|
||||
CopyASCIItoUTF16(aStr, str);
|
||||
return CreateControl("BUTTON", BS_RADIOBUTTON, aHInst, aHdlg, aId, str, aRect);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
@ -585,7 +585,7 @@ XRE_InitChildProcess(int aArgc,
|
||||
// '-' implies no support
|
||||
if (*appModelUserId != '-') {
|
||||
nsString appId;
|
||||
appId.AssignWithConversion(nsDependentCString(appModelUserId));
|
||||
CopyASCIItoUTF16(nsDependentCString(appModelUserId), appId);
|
||||
// The version string is encased in quotes
|
||||
appId.Trim("\"");
|
||||
// Set the id
|
||||
|
@ -948,7 +948,7 @@ nsCocoaUtils::ConvertGeckoNameToMacCharCode(const nsAString& aKeyCodeName)
|
||||
}
|
||||
|
||||
nsAutoCString keyCodeName;
|
||||
keyCodeName.AssignWithConversion(aKeyCodeName);
|
||||
LossyCopyUTF16toASCII(aKeyCodeName, keyCodeName);
|
||||
// We want case-insensitive comparison with data stored as uppercase.
|
||||
ToUpperCase(keyCodeName);
|
||||
|
||||
|
@ -1031,21 +1031,4 @@ nsString::ToDouble(nsresult* aErrorCode) const
|
||||
return NS_LossyConvertUTF16toASCII(*this).ToDouble(aErrorCode);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nsTString::AssignWithConversion
|
||||
*/
|
||||
|
||||
void
|
||||
nsCString::AssignWithConversion( const nsAString& aData )
|
||||
{
|
||||
LossyCopyUTF16toASCII(aData, *this);
|
||||
}
|
||||
|
||||
void
|
||||
nsString::AssignWithConversion( const nsACString& aData )
|
||||
{
|
||||
CopyASCIItoUTF16(aData, *this);
|
||||
}
|
||||
|
||||
#endif // !MOZ_STRING_WITH_OBSOLETE_API
|
||||
|
@ -430,15 +430,6 @@ public:
|
||||
void CompressWhitespace(bool aEliminateLeading = true,
|
||||
bool aEliminateTrailing = true);
|
||||
|
||||
|
||||
/**
|
||||
* assign/append/insert with _LOSSY_ conversion
|
||||
*/
|
||||
|
||||
void AssignWithConversion(const nsTAString_IncompatibleCharT& aString);
|
||||
void AssignWithConversion(const incompatible_char_type* aData,
|
||||
int32_t aLength = -1);
|
||||
|
||||
#endif // !MOZ_STRING_WITH_OBSOLETE_API
|
||||
|
||||
/**
|
||||
|
@ -718,26 +718,3 @@ nsTString_CharT::CompressWhitespace( bool aTrimLeading, bool aTrimTrailing )
|
||||
*to = char_type(0); // add the null
|
||||
mLength = to - mData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nsTString::AssignWithConversion
|
||||
*/
|
||||
|
||||
void
|
||||
nsTString_CharT::AssignWithConversion( const incompatible_char_type* aData, int32_t aLength )
|
||||
{
|
||||
// for compatibility with the old string implementation, we need to allow
|
||||
// for a nullptr input buffer :-(
|
||||
if (!aData)
|
||||
{
|
||||
Truncate();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aLength < 0)
|
||||
aLength = nsCharTraits<incompatible_char_type>::length(aData);
|
||||
|
||||
AssignWithConversion(Substring(aData, aLength));
|
||||
}
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ static void Check(const char* s1, const char* s2, int n)
|
||||
int clib_n = PL_strncmp(s1, s2, n);
|
||||
|
||||
nsAutoString t1,t2;
|
||||
t1.AssignWithConversion(s1);
|
||||
t2.AssignWithConversion(s2);
|
||||
CopyASCIItoUTF16(s1, t1);
|
||||
CopyASCIItoUTF16(s2, t2);
|
||||
const char16_t* us1 = t1.get();
|
||||
const char16_t* us2 = t2.get();
|
||||
|
||||
|
@ -323,8 +323,8 @@ TEST(Strings, replace_substr_2)
|
||||
const char *newName = "user";
|
||||
nsString acctName; acctName.AssignLiteral("forums.foo.com");
|
||||
nsAutoString newAcctName, oldVal, newVal;
|
||||
oldVal.AssignWithConversion(oldName);
|
||||
newVal.AssignWithConversion(newName);
|
||||
CopyASCIItoUTF16(oldName, oldVal);
|
||||
CopyASCIItoUTF16(newName, newVal);
|
||||
newAcctName.Assign(acctName);
|
||||
|
||||
// here, oldVal is empty. we are testing that this function
|
||||
|
@ -1655,7 +1655,7 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
|
||||
if ((mPersistentAttributesDirty & PAD_POSITION) && gotRestoredBounds) {
|
||||
if (persistString.Find("screenX") >= 0) {
|
||||
SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.x / posScale.scale));
|
||||
sizeString.AssignWithConversion(sizeBuf);
|
||||
CopyASCIItoUTF16(sizeBuf, sizeString);
|
||||
docShellElement->SetAttribute(SCREENX_ATTRIBUTE, sizeString, rv);
|
||||
if (shouldPersist) {
|
||||
ownerXULDoc->Persist(windowElementId, SCREENX_ATTRIBUTE);
|
||||
@ -1663,7 +1663,7 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
|
||||
}
|
||||
if (persistString.Find("screenY") >= 0) {
|
||||
SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.y / posScale.scale));
|
||||
sizeString.AssignWithConversion(sizeBuf);
|
||||
CopyASCIItoUTF16(sizeBuf, sizeString);
|
||||
docShellElement->SetAttribute(SCREENY_ATTRIBUTE, sizeString, rv);
|
||||
if (shouldPersist) {
|
||||
ownerXULDoc->Persist(windowElementId, SCREENY_ATTRIBUTE);
|
||||
@ -1674,7 +1674,7 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
|
||||
if ((mPersistentAttributesDirty & PAD_SIZE) && gotRestoredBounds) {
|
||||
if (persistString.Find("width") >= 0) {
|
||||
SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.width / sizeScale.scale));
|
||||
sizeString.AssignWithConversion(sizeBuf);
|
||||
CopyASCIItoUTF16(sizeBuf, sizeString);
|
||||
docShellElement->SetAttribute(WIDTH_ATTRIBUTE, sizeString, rv);
|
||||
if (shouldPersist) {
|
||||
ownerXULDoc->Persist(windowElementId, WIDTH_ATTRIBUTE);
|
||||
@ -1682,7 +1682,7 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
|
||||
}
|
||||
if (persistString.Find("height") >= 0) {
|
||||
SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.height / sizeScale.scale));
|
||||
sizeString.AssignWithConversion(sizeBuf);
|
||||
CopyASCIItoUTF16(sizeBuf, sizeString);
|
||||
docShellElement->SetAttribute(HEIGHT_ATTRIBUTE, sizeString, rv);
|
||||
if (shouldPersist) {
|
||||
ownerXULDoc->Persist(windowElementId, HEIGHT_ATTRIBUTE);
|
||||
@ -1711,7 +1711,7 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
|
||||
if (mediator) {
|
||||
mediator->GetZLevel(this, &zLevel);
|
||||
SprintfLiteral(sizeBuf, "%" PRIu32, zLevel);
|
||||
sizeString.AssignWithConversion(sizeBuf);
|
||||
CopyASCIItoUTF16(sizeBuf, sizeString);
|
||||
docShellElement->SetAttribute(ZLEVEL_ATTRIBUTE, sizeString, rv);
|
||||
if (shouldPersist) {
|
||||
ownerXULDoc->Persist(windowElementId, ZLEVEL_ATTRIBUTE);
|
||||
|
@ -164,7 +164,7 @@ nsHTTPIndex::OnFTPControlLog(bool server, const char *msg)
|
||||
NS_ENSURE_TRUE(global, NS_OK);
|
||||
|
||||
nsString unicodeMsg;
|
||||
unicodeMsg.AssignWithConversion(msg);
|
||||
CopyASCIItoUTF16(msg, unicodeMsg);
|
||||
JSString* jsMsgStr = JS_NewUCStringCopyZ(cx, unicodeMsg.get());
|
||||
NS_ENSURE_TRUE(jsMsgStr, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
@ -407,7 +407,7 @@ nsHTTPIndex::OnIndexAvailable(nsIRequest* aRequest, nsISupports *aContext,
|
||||
nsCOMPtr<nsIRDFLiteral> lit;
|
||||
nsString str;
|
||||
|
||||
str.AssignWithConversion(entryuriC.get());
|
||||
CopyASCIItoUTF16(entryuriC, str);
|
||||
|
||||
rv = mDirRDF->GetLiteral(str.get(), getter_AddRefs(lit));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user