From cfb8fb313fc65ddc6bbd1cc1f8a6eb2a58618f7c Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Wed, 2 Sep 2020 09:54:37 +0000 Subject: [PATCH] Bug 1662251 - stop assigning from NS_Convert* values, mostly; r=sg This patch was generated by running: ``` perl -p -i \ -e 's/^(\s+)([a-zA-Z0-9.]+) = NS_ConvertUTF8toUTF16\((.*)\);/\1CopyUTF8toUTF16(\3, \2);/;' \ -e 's/^(\s+)([a-zA-Z0-9.]+) = NS_ConvertUTF16toUTF8\((.*)\);/\1CopyUTF16toUTF8(\3, \2);/;' \ $FILE ``` against every .cpp and .h in mozilla-central, and then fixing up the inevitable errors that happen as a result of matching C++ expressions with regexes. The errors fell into three categories: 1. Calling the convert functions with `std::string::c_str()`; these were changed to simply pass the string instead, relying on implicit conversion to `mozilla::Span`. 2. Calling the convert functions with raw pointers, which is not permitted with the copy functions; these were changed to invoke `MakeStringSpan` first. 3. Other miscellaneous errors resulting from over-eager regexes and/or the replacement not being type-aware. These changes were reverted. Differential Revision: https://phabricator.services.mozilla.com/D88903 --- accessible/atk/AccessibleWrap.h | 2 +- dom/base/BodyConsumer.cpp | 2 +- dom/base/nsContentAreaDragDrop.cpp | 2 +- dom/base/nsContentUtils.cpp | 6 +++--- dom/base/nsGlobalWindowOuter.cpp | 2 +- dom/canvas/ClientWebGLContext.cpp | 10 +++++----- dom/canvas/ClientWebGLContext.h | 2 +- dom/events/EventDispatcher.cpp | 2 +- dom/ipc/ProcessPriorityManager.cpp | 2 +- dom/l10n/DOMLocalization.cpp | 2 +- dom/media/MediaDecoder.cpp | 4 ++-- dom/media/MediaDecoderStateMachine.cpp | 4 ++-- dom/media/MediaFormatReader.cpp | 8 ++++---- dom/media/MediaManager.cpp | 2 +- dom/media/MediaRecorder.cpp | 2 +- dom/media/gmp/GMPChild.cpp | 6 +++--- dom/media/gmp/GMPParent.cpp | 6 +++--- dom/media/gmp/GMPProcessChild.cpp | 2 +- dom/media/gmp/GMPServiceParent.cpp | 2 +- dom/media/mediasink/DecodedStream.cpp | 2 +- dom/media/mediasource/TrackBuffersManager.cpp | 2 +- dom/network/TCPSocket.cpp | 2 +- dom/network/UDPSocket.cpp | 10 +++++----- dom/network/UDPSocket.h | 2 +- dom/notification/Notification.cpp | 4 ++-- dom/performance/Performance.cpp | 2 +- dom/performance/PerformanceMainThread.cpp | 2 +- dom/performance/PerformanceTiming.cpp | 4 ++-- dom/presentation/PresentationRequest.cpp | 2 +- dom/reporting/CrashReport.cpp | 2 +- dom/script/ScriptSettings.cpp | 2 +- dom/security/nsCSPContext.cpp | 10 +++++----- dom/serviceworkers/ServiceWorkerManager.cpp | 2 +- dom/serviceworkers/ServiceWorkerOp.cpp | 4 ++-- dom/url/URLWorker.cpp | 2 +- dom/vr/VRDisplay.cpp | 2 +- .../WebBrowserPersistLocalDocument.cpp | 2 +- dom/workers/RuntimeService.cpp | 2 +- dom/workers/WorkerError.cpp | 2 +- dom/workers/WorkerScope.cpp | 2 +- dom/xhr/XMLHttpRequestMainThread.cpp | 2 +- extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp | 2 +- gfx/layers/apz/testutil/APZTestData.cpp | 2 +- image/RasterImage.cpp | 2 +- intl/unicharutil/util/ICUUtils.cpp | 4 ++-- js/xpconnect/src/XPCShellImpl.cpp | 2 +- layout/base/nsCSSFrameConstructor.cpp | 2 +- layout/printing/nsPrintJob.cpp | 4 ++-- .../signaling/src/peerconnection/RTCDTMFSender.cpp | 2 +- security/manager/ssl/nsCertTree.cpp | 4 ++-- security/manager/ssl/nsNTLMAuthModule.cpp | 2 +- storage/VacuumManager.cpp | 2 +- toolkit/components/extensions/MatchPattern.cpp | 6 +++--- toolkit/components/places/History.cpp | 2 +- toolkit/components/places/nsNavBookmarks.cpp | 4 ++-- .../components/telemetry/core/TelemetryHistogram.cpp | 2 +- toolkit/system/gnome/nsAlertsIconListener.cpp | 6 +++--- toolkit/xre/nsAppRunner.cpp | 2 +- toolkit/xre/nsUpdateDriver.cpp | 10 +++++----- uriloader/exthandler/android/nsMIMEInfoAndroid.cpp | 2 +- widget/WidgetEventImpl.cpp | 2 +- widget/gtk/nsPrintSettingsGTK.cpp | 4 ++-- xpcom/build/NSPRInterposer.cpp | 2 +- xpcom/build/PoisonIOInterposerMac.cpp | 2 +- 64 files changed, 103 insertions(+), 103 deletions(-) diff --git a/accessible/atk/AccessibleWrap.h b/accessible/atk/AccessibleWrap.h index 606d3d2b595a..d7fa3b83557f 100644 --- a/accessible/atk/AccessibleWrap.h +++ b/accessible/atk/AccessibleWrap.h @@ -64,7 +64,7 @@ class AccessibleWrap : public Accessible { static const char* ReturnString(nsAString& aString) { static nsCString returnedString; - returnedString = NS_ConvertUTF16toUTF8(aString); + CopyUTF16toUTF8(aString, returnedString); return returnedString.get(); } diff --git a/dom/base/BodyConsumer.cpp b/dom/base/BodyConsumer.cpp index cbf6e3bebc2c..109fc8219b98 100644 --- a/dom/base/BodyConsumer.cpp +++ b/dom/base/BodyConsumer.cpp @@ -504,7 +504,7 @@ void BodyConsumer::BeginConsumeBodyMainThread(ThreadSafeWorkerRef* aWorkerRef) { rv = GetBodyLocalFile(getter_AddRefs(file)); if (!NS_WARN_IF(NS_FAILED(rv)) && file) { ChromeFilePropertyBag bag; - bag.mType = NS_ConvertUTF8toUTF16(mBodyMimeType); + CopyUTF8toUTF16(mBodyMimeType, bag.mType); ErrorResult error; RefPtr promise = diff --git a/dom/base/nsContentAreaDragDrop.cpp b/dom/base/nsContentAreaDragDrop.cpp index b308a73ff028..691e8a238cba 100644 --- a/dom/base/nsContentAreaDragDrop.cpp +++ b/dom/base/nsContentAreaDragDrop.cpp @@ -287,7 +287,7 @@ nsContentAreaDragDropDataProvider::GetFlavorData(nsITransferable* aTransferable, NS_ENSURE_SUCCESS(rv, rv); newFileName.Append("."); newFileName.Append(primaryExtension); - targetFilename = NS_ConvertUTF8toUTF16(newFileName); + CopyUTF8toUTF16(newFileName, targetFilename); } } } diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index c3d0af5cf97e..0cdfa979f77d 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -5904,7 +5904,7 @@ nsresult nsContentUtils::GetUTFOrigin(nsIPrincipal* aPrincipal, asciiOrigin.AssignLiteral("null"); } - aOrigin = NS_ConvertUTF8toUTF16(asciiOrigin); + CopyUTF8toUTF16(asciiOrigin, aOrigin); return NS_OK; } @@ -5930,7 +5930,7 @@ nsresult nsContentUtils::GetUTFOrigin(nsIURI* aURI, nsAString& aOrigin) { rv = GetASCIIOrigin(aURI, asciiOrigin); NS_ENSURE_SUCCESS(rv, rv); - aOrigin = NS_ConvertUTF8toUTF16(asciiOrigin); + CopyUTF8toUTF16(asciiOrigin, aOrigin); return NS_OK; } @@ -8838,7 +8838,7 @@ void nsContentUtils::GetPresentationURL(nsIDocShell* aDocShell, nsAutoCString uriStr; uri->GetSpec(uriStr); - aPresentationUrl = NS_ConvertUTF8toUTF16(uriStr); + CopyUTF8toUTF16(uriStr, aPresentationUrl); return; } diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index c58834fbf35e..60f2119c76db 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -6002,7 +6002,7 @@ bool nsGlobalWindowOuter::GatherPostMessageData( if (!callerPrin->IsSystemPrincipal()) { nsAutoCString asciiOrigin; callerPrin->GetAsciiOrigin(asciiOrigin); - aOrigin = NS_ConvertUTF8toUTF16(asciiOrigin); + CopyUTF8toUTF16(asciiOrigin, aOrigin); } else if (callerInnerWin) { if (!*aCallerURI) { return false; diff --git a/dom/canvas/ClientWebGLContext.cpp b/dom/canvas/ClientWebGLContext.cpp index ed91984e89c3..35aa539ad824 100644 --- a/dom/canvas/ClientWebGLContext.cpp +++ b/dom/canvas/ClientWebGLContext.cpp @@ -5387,7 +5387,7 @@ void ClientWebGLContext::GetActiveUniformBlockName(const WebGLProgramJS& prog, } const auto& block = list[index]; - retval = NS_ConvertUTF8toUTF16(block.name.c_str()); + CopyUTF8toUTF16(block.name, retval); } void ClientWebGLContext::GetActiveUniformBlockParameter( @@ -5742,7 +5742,7 @@ void ClientWebGLContext::GetProgramInfoLog(const WebGLProgramJS& prog, if (!prog.ValidateUsable(*this, "program")) return; const auto& res = GetLinkResult(prog); - retval = NS_ConvertUTF8toUTF16(res.log); + CopyUTF8toUTF16(res.log, retval); } void ClientWebGLContext::GetProgramParameter( @@ -5826,7 +5826,7 @@ void ClientWebGLContext::GetShaderInfoLog(const WebGLShaderJS& shader, if (!shader.ValidateUsable(*this, "shader")) return; const auto& result = GetCompileResult(shader); - retval = NS_ConvertUTF8toUTF16(result.log); + CopyUTF8toUTF16(result.log, retval); } void ClientWebGLContext::GetShaderParameter( @@ -5864,7 +5864,7 @@ void ClientWebGLContext::GetShaderSource(const WebGLShaderJS& shader, if (IsContextLost()) return; if (!shader.ValidateUsable(*this, "shader")) return; - retval = NS_ConvertUTF8toUTF16(shader.mSource.c_str()); + CopyUTF8toUTF16(shader.mSource, retval); } void ClientWebGLContext::GetTranslatedShaderSource(const WebGLShaderJS& shader, @@ -5875,7 +5875,7 @@ void ClientWebGLContext::GetTranslatedShaderSource(const WebGLShaderJS& shader, if (!shader.ValidateUsable(*this, "shader")) return; const auto& result = GetCompileResult(shader); - retval = NS_ConvertUTF8toUTF16(result.translatedSource); + CopyUTF8toUTF16(result.translatedSource, retval); } void ClientWebGLContext::ShaderSource(WebGLShaderJS& shader, diff --git a/dom/canvas/ClientWebGLContext.h b/dom/canvas/ClientWebGLContext.h index de26cf3bf5a0..e7cd6d908dfc 100644 --- a/dom/canvas/ClientWebGLContext.h +++ b/dom/canvas/ClientWebGLContext.h @@ -70,7 +70,7 @@ class WebGLActiveInfoJS final : public RefCounted { GLenum Type() const { return mInfo.elemType; } void GetName(nsString& retval) const { - retval = NS_ConvertUTF8toUTF16(mInfo.name.c_str()); + CopyUTF8toUTF16(mInfo.name, retval); } bool WrapObject(JSContext*, JS::Handle, diff --git a/dom/events/EventDispatcher.cpp b/dom/events/EventDispatcher.cpp index c0b4738d943a..373388d7d919 100644 --- a/dom/events/EventDispatcher.cpp +++ b/dom/events/EventDispatcher.cpp @@ -749,7 +749,7 @@ nsresult EventDispatcher::Dispatch(nsISupports* aTarget, } else { Event::GetWidgetEventType(aEvent, eventTypeU16); } - eventType = NS_ConvertUTF16toUTF8(eventTypeU16); + CopyUTF16toUTF8(eventTypeU16, eventType); nsCOMPtr element = do_QueryInterface(aTarget); nsAutoString elementId; diff --git a/dom/ipc/ProcessPriorityManager.cpp b/dom/ipc/ProcessPriorityManager.cpp index a2ee913323e3..0f02d7728a86 100644 --- a/dom/ipc/ProcessPriorityManager.cpp +++ b/dom/ipc/ProcessPriorityManager.cpp @@ -624,7 +624,7 @@ const nsAutoCString& ParticularProcessPriorityManager::NameWithComma() { return mNameWithComma; // empty string } - mNameWithComma = NS_ConvertUTF16toUTF8(name); + CopyUTF16toUTF8(name, mNameWithComma); mNameWithComma.AppendLiteral(", "); return mNameWithComma; } diff --git a/dom/l10n/DOMLocalization.cpp b/dom/l10n/DOMLocalization.cpp index cf08222e04e8..e1b5a463906d 100644 --- a/dom/l10n/DOMLocalization.cpp +++ b/dom/l10n/DOMLocalization.cpp @@ -153,7 +153,7 @@ void DOMLocalization::GetAttributes(Element& aElement, L10nIdArgs& aResult, nsAutoString l10nArgs; if (aElement.GetAttr(kNameSpaceID_None, nsGkAtoms::datal10nid, l10nId)) { - aResult.mId = NS_ConvertUTF16toUTF8(l10nId); + CopyUTF16toUTF8(l10nId, aResult.mId); } if (aElement.GetAttr(kNameSpaceID_None, nsGkAtoms::datal10nargs, l10nArgs)) { diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index 041d3229b999..73ada481ca17 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -1339,12 +1339,12 @@ MediaDecoderOwner::NextFrameStatus MediaDecoder::NextFrameBufferedStatus() { } void MediaDecoder::GetDebugInfo(dom::MediaDecoderDebugInfo& aInfo) { - aInfo.mInstance = NS_ConvertUTF8toUTF16(nsPrintfCString("%p", this)); + CopyUTF8toUTF16(nsPrintfCString("%p", this), aInfo.mInstance); aInfo.mChannels = mInfo ? mInfo->mAudio.mChannels : 0; aInfo.mRate = mInfo ? mInfo->mAudio.mRate : 0; aInfo.mHasAudio = mInfo ? mInfo->HasAudio() : false; aInfo.mHasVideo = mInfo ? mInfo->HasVideo() : false; - aInfo.mPlayState = NS_ConvertUTF8toUTF16(PlayStateStr()); + CopyUTF8toUTF16(MakeStringSpan(PlayStateStr()), aInfo.mPlayState); aInfo.mContainerType = NS_ConvertUTF8toUTF16(ContainerType().Type().AsString()); mReader->GetDebugInfo(aInfo.mReader); diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 9aea22e32b64..ab322bac4451 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -3925,8 +3925,8 @@ void MediaDecoderStateMachine::GetDebugInfo( aInfo.mPlayState = int32_t(mPlayState.Ref()); aInfo.mSentFirstFrameLoadedEvent = mSentFirstFrameLoadedEvent; aInfo.mIsPlaying = IsPlaying(); - aInfo.mAudioRequestStatus = NS_ConvertUTF8toUTF16(AudioRequestStatus()); - aInfo.mVideoRequestStatus = NS_ConvertUTF8toUTF16(VideoRequestStatus()); + CopyUTF8toUTF16(MakeStringSpan(AudioRequestStatus()), aInfo.mAudioRequestStatus); + CopyUTF8toUTF16(MakeStringSpan(VideoRequestStatus()), aInfo.mVideoRequestStatus); aInfo.mDecodedAudioEndTime = mDecodedAudioEndTime.ToMicroseconds(); aInfo.mDecodedVideoEndTime = mDecodedVideoEndTime.ToMicroseconds(); aInfo.mAudioCompleted = mAudioCompleted; diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index ed3c483a7a39..838fbf26911a 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -2975,8 +2975,8 @@ void MediaFormatReader::GetDebugInfo(dom::MediaFormatReaderDebugInfo& aInfo) { } } - aInfo.mAudioDecoderName = NS_ConvertUTF8toUTF16(audioDecoderName); - aInfo.mAudioType = NS_ConvertUTF8toUTF16(audioType); + CopyUTF8toUTF16(audioDecoderName, aInfo.mAudioDecoderName); + CopyUTF8toUTF16(audioType, aInfo.mAudioType); aInfo.mAudioChannels = audioInfo.mChannels; aInfo.mAudioRate = audioInfo.mRate / 1000.0f; aInfo.mAudioFramesDecoded = mAudio.mNumSamplesOutputTotal; @@ -3005,8 +3005,8 @@ void MediaFormatReader::GetDebugInfo(dom::MediaFormatReaderDebugInfo& aInfo) { aInfo.mAudioState.mLastStreamSourceID = mAudio.mLastStreamSourceID; } - aInfo.mVideoDecoderName = NS_ConvertUTF8toUTF16(videoDecoderName); - aInfo.mVideoType = NS_ConvertUTF8toUTF16(videoType); + CopyUTF8toUTF16(videoDecoderName, aInfo.mVideoDecoderName); + CopyUTF8toUTF16(videoType, aInfo.mVideoType); aInfo.mVideoWidth = videoInfo.mDisplay.width < 0 ? 0 : videoInfo.mDisplay.width; aInfo.mVideoHeight = diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 42676f752d51..cae6e4ec6147 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -3016,7 +3016,7 @@ nsresult MediaManager::AnonymizeId(nsAString& aId, return rv; } - aId = NS_ConvertUTF8toUTF16(mac); + CopyUTF8toUTF16(mac, aId); return NS_OK; } diff --git a/dom/media/MediaRecorder.cpp b/dom/media/MediaRecorder.cpp index 44df7b357365..ff3c0dcf6770 100644 --- a/dom/media/MediaRecorder.cpp +++ b/dom/media/MediaRecorder.cpp @@ -457,7 +457,7 @@ nsString SelectMimeType(bool aHasVideo, bool aHasAudio, if (constrainedType && constrainedType->ExtendedType().HaveCodecs()) { // The constrained mime type is fully defined (it has codecs!). No need to // select anything. - result = NS_ConvertUTF8toUTF16(constrainedType->OriginalString()); + CopyUTF8toUTF16(constrainedType->OriginalString(), result); } else { // There is no constrained mime type, or there is and it is not fully // defined but still valid. Select what's missing, so that we have major diff --git a/dom/media/gmp/GMPChild.cpp b/dom/media/gmp/GMPChild.cpp index 48220d0f8fb2..1c14bea146f5 100644 --- a/dom/media/gmp/GMPChild.cpp +++ b/dom/media/gmp/GMPChild.cpp @@ -279,7 +279,7 @@ bool GMPChild::GetUTF8LibPath(nsACString& aOutLibPath) { nsAutoString path; libFile->GetPath(path); - aOutLibPath = NS_ConvertUTF16toUTF8(path); + CopyUTF16toUTF8(path, aOutLibPath); return true; #endif @@ -396,7 +396,7 @@ static bool AppendHostPath(nsCOMPtr& aFile, nsCOMPtr sigFile; if (GetSigPath(2, binary, aFile, sigFile) && NS_SUCCEEDED(sigFile->GetPath(str))) { - sigFilePath = NS_ConvertUTF16toUTF8(str); + CopyUTF16toUTF8(str, sigFilePath); } else { // Cannot successfully get the sig file path. // Assume it is located at the same place as plugin-container @@ -431,7 +431,7 @@ GMPChild::MakeCDMHostVerificationPaths() { const std::string pluginContainer = WideToUTF8(CommandLine::ForCurrentProcess()->program()); path = nullptr; - str = NS_ConvertUTF8toUTF16(nsDependentCString(pluginContainer.c_str())); + CopyUTF8toUTF16(nsDependentCString(pluginContainer.c_str()), str); if (NS_FAILED(NS_NewLocalFile(str, true, /* aFollowLinks */ getter_AddRefs(path))) || !AppendHostPath(path, paths)) { diff --git a/dom/media/gmp/GMPParent.cpp b/dom/media/gmp/GMPParent.cpp index 8dc155e0b38a..1fa9c18a8aed 100644 --- a/dom/media/gmp/GMPParent.cpp +++ b/dom/media/gmp/GMPParent.cpp @@ -698,9 +698,9 @@ RefPtr GMPParent::ParseChromiumManifest( return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__); } - mDisplayName = NS_ConvertUTF16toUTF8(m.mName); - mDescription = NS_ConvertUTF16toUTF8(m.mDescription); - mVersion = NS_ConvertUTF16toUTF8(m.mVersion); + CopyUTF16toUTF8(m.mName, mDisplayName); + CopyUTF16toUTF8(m.mDescription, mDescription); + CopyUTF16toUTF8(m.mVersion, mVersion); #if defined(XP_LINUX) && defined(MOZ_SANDBOX) if (!mozilla::SandboxInfo::Get().CanSandboxMedia()) { diff --git a/dom/media/gmp/GMPProcessChild.cpp b/dom/media/gmp/GMPProcessChild.cpp index 5ed5d3e67ac9..bd11d7c7d35c 100644 --- a/dom/media/gmp/GMPProcessChild.cpp +++ b/dom/media/gmp/GMPProcessChild.cpp @@ -29,7 +29,7 @@ bool GMPProcessChild::Init(int aArgc, char* aArgv[]) { // Keep in sync with dom/plugins/PluginModuleParent. std::vector values = CommandLine::ForCurrentProcess()->argv(); MOZ_ASSERT(values.size() >= 2, "not enough args"); - pluginFilename = NS_ConvertUTF8toUTF16(nsDependentCString(values[1].c_str())); + CopyUTF8toUTF16(nsDependentCString(values[1].c_str()), pluginFilename); #elif defined(OS_WIN) std::vector values = CommandLine::ForCurrentProcess()->GetLooseValues(); diff --git a/dom/media/gmp/GMPServiceParent.cpp b/dom/media/gmp/GMPServiceParent.cpp index 92077f4bc16b..2c197c38e9a7 100644 --- a/dom/media/gmp/GMPServiceParent.cpp +++ b/dom/media/gmp/GMPServiceParent.cpp @@ -175,7 +175,7 @@ static nsresult GMPPlatformString(nsAString& aOutPlatform) { platform.AppendLiteral("_"); platform.Append(arch); - aOutPlatform = NS_ConvertUTF8toUTF16(platform); + CopyUTF8toUTF16(platform, aOutPlatform); return NS_OK; } diff --git a/dom/media/mediasink/DecodedStream.cpp b/dom/media/mediasink/DecodedStream.cpp index dba09924c71d..26757653464a 100644 --- a/dom/media/mediasink/DecodedStream.cpp +++ b/dom/media/mediasink/DecodedStream.cpp @@ -357,7 +357,7 @@ MediaEventSource& DecodedStreamData::OnOutput() { void DecodedStreamData::Forget() { mListener->Forget(); } void DecodedStreamData::GetDebugInfo(dom::DecodedStreamDataDebugInfo& aInfo) { - aInfo.mInstance = NS_ConvertUTF8toUTF16(nsPrintfCString("%p", this)); + CopyUTF8toUTF16(nsPrintfCString("%p", this), aInfo.mInstance); aInfo.mAudioFramesWritten = mAudioFramesWritten; aInfo.mStreamAudioWritten = mAudioTrackWritten; aInfo.mNextAudioTime = mNextAudioTime.ToMicroseconds(); diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index c202bdd11a7a..1342024cebfd 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -2859,7 +2859,7 @@ void TrackBuffersManager::TrackData::AddSizeOfResources( void TrackBuffersManager::GetDebugInfo( dom::TrackBuffersManagerDebugInfo& aInfo) { - aInfo.mType = NS_ConvertUTF8toUTF16(mType.Type().AsString()); + CopyUTF8toUTF16(mType.Type().AsString(), aInfo.mType); if (HasAudio()) { aInfo.mNextSampleTime = mAudioTracks.mNextSampleTime.ToSeconds(); diff --git a/dom/network/TCPSocket.cpp b/dom/network/TCPSocket.cpp index 74e7c93995bd..a7efda0accc9 100644 --- a/dom/network/TCPSocket.cpp +++ b/dom/network/TCPSocket.cpp @@ -272,7 +272,7 @@ nsresult TCPSocket::InitWithTransport(nsISocketTransport* aTransport) { nsAutoCString host; mTransport->GetHost(host); - mHost = NS_ConvertUTF8toUTF16(host); + CopyUTF8toUTF16(host, mHost); int32_t port; mTransport->GetPort(&port); mPort = port; diff --git a/dom/network/UDPSocket.cpp b/dom/network/UDPSocket.cpp index ce069cc68682..9c49b0037788 100644 --- a/dom/network/UDPSocket.cpp +++ b/dom/network/UDPSocket.cpp @@ -62,7 +62,7 @@ already_AddRefed UDPSocket::Constructor(const GlobalObject& aGlobal, nsCString remoteAddress; if (aOptions.mRemoteAddress.WasPassed()) { - remoteAddress = NS_ConvertUTF16toUTF8(aOptions.mRemoteAddress.Value()); + CopyUTF16toUTF8(aOptions.mRemoteAddress.Value(), remoteAddress); } else { remoteAddress.SetIsVoid(true); } @@ -303,7 +303,7 @@ bool UDPSocket::Send(const StringOrBlobOrArrayBufferOrArrayBufferView& aData, // arguments, throw InvalidAccessError. nsCString remoteAddress; if (aRemoteAddress.WasPassed()) { - remoteAddress = NS_ConvertUTF16toUTF8(aRemoteAddress.Value()); + CopyUTF16toUTF8(aRemoteAddress.Value(), remoteAddress); UDPSOCKET_LOG(("%s: Send to %s", __FUNCTION__, remoteAddress.get())); } else if (!mRemoteAddress.IsVoid()) { remoteAddress = mRemoteAddress; @@ -433,7 +433,7 @@ nsresult UDPSocket::InitLocal(const nsAString& aLocalAddress, if (NS_FAILED(rv)) { return rv; } - mLocalAddress = NS_ConvertUTF8toUTF16(localAddress); + CopyUTF8toUTF16(localAddress, mLocalAddress); uint16_t localPort; rv = localAddr->GetPort(&localPort); @@ -598,7 +598,7 @@ nsresult UDPSocket::DispatchReceivedData(const nsACString& aRemoteAddress, // Create DOM event RootedDictionary init(cx); - init.mRemoteAddress = NS_ConvertUTF8toUTF16(aRemoteAddress); + CopyUTF8toUTF16(aRemoteAddress, init.mRemoteAddress); init.mRemotePort = aRemotePort; init.mData = jsData; @@ -685,7 +685,7 @@ UDPSocket::CallListenerOpened() { MOZ_ASSERT(mSocketChild); // Get real local address and local port - mLocalAddress = NS_ConvertUTF8toUTF16(mSocketChild->LocalAddress()); + CopyUTF8toUTF16(mSocketChild->LocalAddress(), mLocalAddress); mLocalPort.SetValue(mSocketChild->LocalPort()); diff --git a/dom/network/UDPSocket.h b/dom/network/UDPSocket.h index 580250e4b045..ddcedb3af86a 100644 --- a/dom/network/UDPSocket.h +++ b/dom/network/UDPSocket.h @@ -66,7 +66,7 @@ class UDPSocket final : public DOMEventTargetHelper, return; } - aRetVal = NS_ConvertUTF8toUTF16(mRemoteAddress); + CopyUTF8toUTF16(mRemoteAddress, aRetVal); } Nullable GetRemotePort() const { return mRemotePort; } diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp index 54ea1420b603..c409d3e4911a 100644 --- a/dom/notification/Notification.cpp +++ b/dom/notification/Notification.cpp @@ -1598,7 +1598,7 @@ nsresult Notification::ResolveIconAndSoundURL(nsString& iconUrl, if (NS_SUCCEEDED(rv)) { nsAutoCString src; srcUri->GetSpec(src); - iconUrl = NS_ConvertUTF8toUTF16(src); + CopyUTF8toUTF16(src, iconUrl); } } if (mBehavior.mSoundFile.Length() > 0) { @@ -1608,7 +1608,7 @@ nsresult Notification::ResolveIconAndSoundURL(nsString& iconUrl, if (NS_SUCCEEDED(rv)) { nsAutoCString src; srcUri->GetSpec(src); - soundUrl = NS_ConvertUTF8toUTF16(src); + CopyUTF8toUTF16(src, soundUrl); } } } diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp index 581ba7744ff3..4076c18313d2 100644 --- a/dom/performance/Performance.cpp +++ b/dom/performance/Performance.cpp @@ -364,7 +364,7 @@ void Performance::TimingNotification(PerformanceEntry* aEntry, init.mStartTime = aEntry->StartTime(); init.mDuration = aEntry->Duration(); init.mEpoch = aEpoch; - init.mOrigin = NS_ConvertUTF8toUTF16(aOwner.BeginReading()); + CopyUTF8toUTF16(aOwner, init.mOrigin); RefPtr perfEntryEvent = PerformanceEntryEvent::Constructor(this, u"performanceentry"_ns, init); diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp index ef673b2a6a95..ec9a337e5f3b 100644 --- a/dom/performance/PerformanceMainThread.cpp +++ b/dom/performance/PerformanceMainThread.cpp @@ -34,7 +34,7 @@ void GetURLSpecFromChannel(nsITimedChannel* aChannel, nsAString& aSpec) { return; } - aSpec = NS_ConvertUTF8toUTF16(spec); + CopyUTF8toUTF16(spec, aSpec); } } // namespace diff --git a/dom/performance/PerformanceTiming.cpp b/dom/performance/PerformanceTiming.cpp index b9823eecb8fc..57fec5b74f78 100644 --- a/dom/performance/PerformanceTiming.cpp +++ b/dom/performance/PerformanceTiming.cpp @@ -62,7 +62,7 @@ PerformanceTimingData* PerformanceTimingData::Create( nsAutoCString name; originalURI->GetSpec(name); - aEntryName = NS_ConvertUTF8toUTF16(name); + CopyUTF8toUTF16(name, aEntryName); // The nsITimedChannel argument will be used to gather all the timings. // The nsIHttpChannel argument will be used to check if any cross-origin @@ -211,7 +211,7 @@ void PerformanceTimingData::SetPropertiesFromHttpChannel( nsAutoCString protocol; Unused << aHttpChannel->GetProtocolVersion(protocol); - mNextHopProtocol = NS_ConvertUTF8toUTF16(protocol); + CopyUTF8toUTF16(protocol, mNextHopProtocol); Unused << aHttpChannel->GetEncodedBodySize(&mEncodedBodySize); Unused << aHttpChannel->GetTransferSize(&mTransferSize); diff --git a/dom/presentation/PresentationRequest.cpp b/dom/presentation/PresentationRequest.cpp index 4572221857c6..d0462e86ed4e 100644 --- a/dom/presentation/PresentationRequest.cpp +++ b/dom/presentation/PresentationRequest.cpp @@ -58,7 +58,7 @@ static nsresult GetAbsoluteURL(const nsAString& aUrl, nsIURI* aBaseUri, nsAutoCString spec; uri->GetSpec(spec); - aAbsoluteUrl = NS_ConvertUTF8toUTF16(spec); + CopyUTF8toUTF16(spec, aAbsoluteUrl); return NS_OK; } diff --git a/dom/reporting/CrashReport.cpp b/dom/reporting/CrashReport.cpp index 4cc44a6b8b42..4c260be1410f 100644 --- a/dom/reporting/CrashReport.cpp +++ b/dom/reporting/CrashReport.cpp @@ -43,7 +43,7 @@ bool CrashReport::Deliver(nsIPrincipal* aPrincipal, bool aIsOOM) { ReportDeliver::ReportData data; data.mType = u"crash"_ns; data.mGroupName = u"default"_ns; - data.mURL = NS_ConvertUTF8toUTF16(safe_origin_spec); + CopyUTF8toUTF16(safe_origin_spec, data.mURL); data.mCreationTime = TimeStamp::Now(); Navigator::GetUserAgent(nullptr, aPrincipal, false, data.mUserAgent); diff --git a/dom/script/ScriptSettings.cpp b/dom/script/ScriptSettings.cpp index 9dccd5f03055..d4ea48eab22c 100644 --- a/dom/script/ScriptSettings.cpp +++ b/dom/script/ScriptSettings.cpp @@ -656,7 +656,7 @@ void AutoEntryScript::DocshellEntryMonitor::Entry( rootedScript = JS_GetFunctionScript(aCx, rootedFunction); } if (rootedScript) { - filename = NS_ConvertUTF8toUTF16(JS_GetScriptFilename(rootedScript)); + CopyUTF8toUTF16(MakeStringSpan(JS_GetScriptFilename(rootedScript)), filename); lineNumber = JS_GetScriptBaseLineNumber(aCx, rootedScript); } diff --git a/dom/security/nsCSPContext.cpp b/dom/security/nsCSPContext.cpp index b1feecc1e46d..cf43c2d20dae 100644 --- a/dom/security/nsCSPContext.cpp +++ b/dom/security/nsCSPContext.cpp @@ -421,7 +421,7 @@ nsCSPContext::AppendPolicy(const nsAString& aPolicyString, bool aReportOnly, if (mSelfURI) { mSelfURI->GetAsciiSpec(selfURIspec); } - referrer = NS_ConvertUTF16toUTF8(mReferrer); + CopyUTF16toUTF8(mReferrer, referrer); CSPCONTEXTLOG( ("nsCSPContext::AppendPolicy added UPGRADE_IF_INSECURE_DIRECTIVE " "self-uri=%s referrer=%s", @@ -997,7 +997,7 @@ nsresult nsCSPContext::GatherSecurityPolicyViolationEventData( // document-uri nsAutoCString reportDocumentURI; StripURIForReporting(mSelfURI, mSelfURI, reportDocumentURI); - aViolationEventInit.mDocumentURI = NS_ConvertUTF8toUTF16(reportDocumentURI); + CopyUTF8toUTF16(reportDocumentURI, aViolationEventInit.mDocumentURI); // referrer aViolationEventInit.mReferrer = mReferrer; @@ -1015,9 +1015,9 @@ nsresult nsCSPContext::GatherSecurityPolicyViolationEventData( } nsAutoCString reportBlockedURI; StripURIForReporting(uriToReport, mSelfURI, reportBlockedURI); - aViolationEventInit.mBlockedURI = NS_ConvertUTF8toUTF16(reportBlockedURI); + CopyUTF8toUTF16(reportBlockedURI, aViolationEventInit.mBlockedURI); } else { - aViolationEventInit.mBlockedURI = NS_ConvertUTF8toUTF16(aBlockedString); + CopyUTF8toUTF16(aBlockedString, aViolationEventInit.mBlockedURI); } // effective-directive @@ -1043,7 +1043,7 @@ nsresult nsCSPContext::GatherSecurityPolicyViolationEventData( if (sourceURI) { nsAutoCString spec; sourceURI->GetSpecIgnoringRef(spec); - aSourceFile = NS_ConvertUTF8toUTF16(spec); + CopyUTF8toUTF16(spec, aSourceFile); } aViolationEventInit.mSourceFile = aSourceFile; } diff --git a/dom/serviceworkers/ServiceWorkerManager.cpp b/dom/serviceworkers/ServiceWorkerManager.cpp index 0d43a2977113..97b676e9daa5 100644 --- a/dom/serviceworkers/ServiceWorkerManager.cpp +++ b/dom/serviceworkers/ServiceWorkerManager.cpp @@ -2112,7 +2112,7 @@ ServiceWorkerManager::GetScopeForUrl(nsIPrincipal* aPrincipal, return NS_ERROR_FAILURE; } - aScope = NS_ConvertUTF8toUTF16(r->Scope()); + CopyUTF8toUTF16(r->Scope(), aScope); return NS_OK; } diff --git a/dom/serviceworkers/ServiceWorkerOp.cpp b/dom/serviceworkers/ServiceWorkerOp.cpp index 0b219ff5baee..67bc5aebfe45 100644 --- a/dom/serviceworkers/ServiceWorkerOp.cpp +++ b/dom/serviceworkers/ServiceWorkerOp.cpp @@ -998,7 +998,7 @@ class MessageEventOp final : public ExtendableEventOp { nsCString origin; mozUrl->Origin(origin); - init.mOrigin = NS_ConvertUTF8toUTF16(origin); + CopyUTF8toUTF16(origin, init.mOrigin); init.mSource.SetValue().SetAsClient() = new Client( sgo, mArgs.get_ServiceWorkerMessageEventOpArgs().clientInfoAndState()); @@ -1297,7 +1297,7 @@ void FetchEventOp::GetRequestURL(nsAString& aOutRequestURL) { mArgs.get_ServiceWorkerFetchEventOpArgs().internalRequest().urlList(); MOZ_ASSERT(!urls.IsEmpty()); - aOutRequestURL = NS_ConvertUTF8toUTF16(urls.LastElement()); + CopyUTF8toUTF16(urls.LastElement(), aOutRequestURL); } void FetchEventOp::ResolvedCallback(JSContext* aCx, diff --git a/dom/url/URLWorker.cpp b/dom/url/URLWorker.cpp index bd06ddc6d06f..b64783d01411 100644 --- a/dom/url/URLWorker.cpp +++ b/dom/url/URLWorker.cpp @@ -47,7 +47,7 @@ class CreateURLRunnable : public WorkerMainThreadRunnable { return false; } - mURL = NS_ConvertUTF8toUTF16(url); + CopyUTF8toUTF16(url, mURL); return true; } }; diff --git a/dom/vr/VRDisplay.cpp b/dom/vr/VRDisplay.cpp index e1a6b8e9816f..8cbdde64d7f3 100644 --- a/dom/vr/VRDisplay.cpp +++ b/dom/vr/VRDisplay.cpp @@ -379,7 +379,7 @@ uint32_t VRDisplay::DisplayId() const { void VRDisplay::GetDisplayName(nsAString& aDisplayName) const { const gfx::VRDisplayInfo& info = mClient->GetDisplayInfo(); - aDisplayName = NS_ConvertUTF8toUTF16(info.GetDisplayName()); + CopyUTF8toUTF16(MakeStringSpan(info.GetDisplayName()), aDisplayName); } void VRDisplay::UpdateFrameInfo() { diff --git a/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp b/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp index c45075c75cdd..ae1e2240da60 100644 --- a/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp +++ b/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp @@ -619,7 +619,7 @@ nsresult PersistNodeFixup::FixupURI(nsAString& aURI) { return NS_ERROR_FAILURE; } if (!replacement->IsEmpty()) { - aURI = NS_ConvertUTF8toUTF16(*replacement); + CopyUTF8toUTF16(*replacement, aURI); } return NS_OK; } diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index da8266b5a036..23bfe777a103 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -547,7 +547,7 @@ bool ContentSecurityPolicyAllows(JSContext* aCx, JS::HandleString aCode) { JS::AutoFilename file; if (JS::DescribeScriptedCaller(aCx, &file, &lineNum, &columnNum) && file.get()) { - fileName = NS_ConvertUTF8toUTF16(file.get()); + CopyUTF8toUTF16(MakeStringSpan(file.get()), fileName); } else { MOZ_ASSERT(!JS_IsExceptionPending(aCx)); } diff --git a/dom/workers/WorkerError.cpp b/dom/workers/WorkerError.cpp index cbf01435b722..95724c4873b6 100644 --- a/dom/workers/WorkerError.cpp +++ b/dom/workers/WorkerError.cpp @@ -216,7 +216,7 @@ class ReportGenericErrorRunnable final : public WorkerDebuggeeRunnable { } // namespace void WorkerErrorBase::AssignErrorBase(JSErrorBase* aReport) { - mFilename = NS_ConvertUTF8toUTF16(aReport->filename); + CopyUTF8toUTF16(MakeStringSpan(aReport->filename), mFilename); mLineNumber = aReport->lineno; mColumnNumber = aReport->column; mErrorNumber = aReport->errorNumber; diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index a748e652a5b1..37757ac937ce 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -354,7 +354,7 @@ void WorkerGlobalScope::ImportScripts(JSContext* aCx, if (profiler_can_accept_markers()) { const uint32_t urlCount = aScriptURLs.Length(); if (urlCount) { - urls = NS_ConvertUTF16toUTF8(aScriptURLs[0]); + CopyUTF16toUTF8(aScriptURLs[0], urls); for (uint32_t index = 1; index < urlCount; index++) { urls.AppendLiteral(","); urls.Append(NS_ConvertUTF16toUTF8(aScriptURLs[index])); diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index 8bd0b55213e0..aea5bb0a67e1 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -2160,7 +2160,7 @@ XMLHttpRequestMainThread::OnStopRequest(nsIRequest* request, nsresult status) { } ChromeFilePropertyBag bag; - bag.mType = NS_ConvertUTF8toUTF16(contentType); + CopyUTF8toUTF16(contentType, bag.mType); nsCOMPtr global = GetOwnerGlobal(); diff --git a/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp b/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp index 27412757f345..fed68dd8f2f4 100644 --- a/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp +++ b/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp @@ -137,7 +137,7 @@ nsresult EvaluateAdminConfigScript(JS::HandleObject sandbox, nsString convertedScript; bool isUTF8 = IsUtf8(script); if (isUTF8) { - convertedScript = NS_ConvertUTF8toUTF16(script); + CopyUTF8toUTF16(script, convertedScript); } else { nsContentUtils::ReportToConsoleNonLocalized( nsLiteralString( diff --git a/gfx/layers/apz/testutil/APZTestData.cpp b/gfx/layers/apz/testutil/APZTestData.cpp index 7b0d208d9387..08780cf20a8c 100644 --- a/gfx/layers/apz/testutil/APZTestData.cpp +++ b/gfx/layers/apz/testutil/APZTestData.cpp @@ -84,7 +84,7 @@ struct APZTestDataToJSConverter { } static void ConvertString(const std::string& aFrom, nsString& aOutTo) { - aOutTo = NS_ConvertUTF8toUTF16(aFrom.c_str(), aFrom.size()); + CopyUTF8toUTF16(aFrom, aOutTo); } static void ConvertHitResult(const APZTestData::HitResult& aResult, diff --git a/image/RasterImage.cpp b/image/RasterImage.cpp index d2fff56600d5..8aa708f28ccd 100644 --- a/image/RasterImage.cpp +++ b/image/RasterImage.cpp @@ -1814,7 +1814,7 @@ void RasterImage::ReportDecoderError() { if (!GetSpecTruncatedTo1k(uri)) { msg += u" URI in this note truncated due to length."_ns; } - src = NS_ConvertUTF8toUTF16(uri); + CopyUTF8toUTF16(uri, src); } if (NS_SUCCEEDED(errorObject->InitWithWindowID(msg, src, EmptyString(), 0, 0, nsIScriptError::errorFlag, diff --git a/intl/unicharutil/util/ICUUtils.cpp b/intl/unicharutil/util/ICUUtils.cpp index 512780b94807..3aa0b84ac4f6 100644 --- a/intl/unicharutil/util/ICUUtils.cpp +++ b/intl/unicharutil/util/ICUUtils.cpp @@ -38,7 +38,7 @@ void ICUUtils::LanguageTagIterForContent::GetNext(nsACString& aBCP47LangTag) { nsAutoString lang; mContent->GetLang(lang); if (!lang.IsEmpty()) { - aBCP47LangTag = NS_ConvertUTF16toUTF8(lang); + CopyUTF16toUTF8(lang, aBCP47LangTag); return; } } @@ -50,7 +50,7 @@ void ICUUtils::LanguageTagIterForContent::GetNext(nsACString& aBCP47LangTag) { nsAutoString lang; mContent->OwnerDoc()->GetContentLanguage(lang); if (!lang.IsEmpty()) { - aBCP47LangTag = NS_ConvertUTF16toUTF8(lang); + CopyUTF16toUTF8(lang, aBCP47LangTag); return; } } diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index 39d013d0db6c..fcb245f0e813 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -1023,7 +1023,7 @@ static bool GetCurrentWorkingDirectory(nsAString& workingDirectory) { // size back down to the actual string length cwd.SetLength(strlen(result) + 1); cwd.Replace(cwd.Length() - 1, 1, '/'); - workingDirectory = NS_ConvertUTF8toUTF16(cwd); + CopyUTF8toUTF16(cwd, workingDirectory); #endif return true; } diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 36ce3a6103fb..8fb571fc0f9f 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -1538,7 +1538,7 @@ already_AddRefed nsCSSFrameConstructor::CreateGeneratedContent( } else { auto& counters = item.AsCounters(); name = counters._0.AsAtom(); - separator = NS_ConvertUTF8toUTF16(counters._1.AsString()); + CopyUTF8toUTF16(counters._1.AsString(), separator); ptr = CounterStylePtr::FromStyle(counters._2); } diff --git a/layout/printing/nsPrintJob.cpp b/layout/printing/nsPrintJob.cpp index 92c0b8af07cf..20ba7acfaf4a 100644 --- a/layout/printing/nsPrintJob.cpp +++ b/layout/printing/nsPrintJob.cpp @@ -2944,8 +2944,8 @@ static void GetDocTitleAndURL(const UniquePtr& aPO, nsAutoString docTitleStr; nsAutoString docURLStr; GetDocumentTitleAndURL(aPO->mDocument, docTitleStr, docURLStr); - aDocStr = NS_ConvertUTF16toUTF8(docTitleStr); - aURLStr = NS_ConvertUTF16toUTF8(docURLStr); + CopyUTF16toUTF8(docTitleStr, aDocStr); + CopyUTF16toUTF8(docURLStr, aURLStr); } //------------------------------------------------------------- diff --git a/media/webrtc/signaling/src/peerconnection/RTCDTMFSender.cpp b/media/webrtc/signaling/src/peerconnection/RTCDTMFSender.cpp index 429a3406176e..41c82eea2d81 100644 --- a/media/webrtc/signaling/src/peerconnection/RTCDTMFSender.cpp +++ b/media/webrtc/signaling/src/peerconnection/RTCDTMFSender.cpp @@ -85,7 +85,7 @@ void RTCDTMFSender::InsertDTMF(const nsAString& aTones, uint32_t aDuration, return; } - mToneBuffer = NS_ConvertUTF8toUTF16(utf8Tones.c_str()); + CopyUTF8toUTF16(utf8Tones, mToneBuffer); mDuration = std::clamp(aDuration, 40U, 6000U); mInterToneGap = std::clamp(aInterToneGap, 30U, 6000U); diff --git a/security/manager/ssl/nsCertTree.cpp b/security/manager/ssl/nsCertTree.cpp index 7f9fb0499476..9ca0f3543f2a 100644 --- a/security/manager/ssl/nsCertTree.cpp +++ b/security/manager/ssl/nsCertTree.cpp @@ -124,7 +124,7 @@ NS_IMETHODIMP nsCertTreeDispInfo::GetHostPort(nsAString& aHostPort) { nsAutoCString hostPort; nsCertOverrideService::GetHostWithPort(mAsciiHost, mPort, hostPort); - aHostPort = NS_ConvertUTF8toUTF16(hostPort); + CopyUTF8toUTF16(hostPort, aHostPort); return NS_OK; } @@ -926,7 +926,7 @@ nsCertTree::GetCellText(int32_t row, nsTreeColumn* col, nsAString& _retval) { nsAutoCString hostPort; nsCertOverrideService::GetHostWithPort(certdi->mAsciiHost, certdi->mPort, hostPort); - _retval = NS_ConvertUTF8toUTF16(hostPort); + CopyUTF8toUTF16(hostPort, _retval); } else { _retval = u"*"_ns; } diff --git a/security/manager/ssl/nsNTLMAuthModule.cpp b/security/manager/ssl/nsNTLMAuthModule.cpp index d57495036ff2..d3901c524bee 100644 --- a/security/manager/ssl/nsNTLMAuthModule.cpp +++ b/security/manager/ssl/nsNTLMAuthModule.cpp @@ -568,7 +568,7 @@ static nsresult GenerateType3Msg(const nsString& domain, } if (unicode) { - ucsHostBuf = NS_ConvertUTF8toUTF16(hostBuf); + CopyUTF8toUTF16(hostBuf, ucsHostBuf); hostPtr = ucsHostBuf.get(); hostLen = ucsHostBuf.Length() * 2; #ifdef IS_BIG_ENDIAN diff --git a/storage/VacuumManager.cpp b/storage/VacuumManager.cpp index a01abf742602..70267515711d 100644 --- a/storage/VacuumManager.cpp +++ b/storage/VacuumManager.cpp @@ -152,7 +152,7 @@ bool Vacuumer::execute() { nsAutoString databaseFilename; rv = databaseFile->GetLeafName(databaseFilename); NS_ENSURE_SUCCESS(rv, false); - mDBFilename = NS_ConvertUTF16toUTF8(databaseFilename); + CopyUTF16toUTF8(databaseFilename, mDBFilename); MOZ_ASSERT(!mDBFilename.IsEmpty(), "Database filename cannot be empty"); // Check interval from last vacuum. diff --git a/toolkit/components/extensions/MatchPattern.cpp b/toolkit/components/extensions/MatchPattern.cpp index 862271e167f9..8e4675227222 100644 --- a/toolkit/components/extensions/MatchPattern.cpp +++ b/toolkit/components/extensions/MatchPattern.cpp @@ -323,15 +323,15 @@ void MatchPattern::Init(JSContext* aCx, const nsAString& aPattern, if (host.EqualsLiteral("*")) { mMatchSubdomain = true; } else if (StringHead(host, 2).EqualsLiteral("*.")) { - mDomain = NS_ConvertUTF16toUTF8(Substring(host, 2)); + CopyUTF16toUTF8(Substring(host, 2), mDomain); mMatchSubdomain = true; } else if (host.Length() > 1 && host[0] == '[' && host[host.Length() - 1] == ']') { // This is an IPv6 literal, we drop the enclosing `[]` to be // consistent with nsIURI. - mDomain = NS_ConvertUTF16toUTF8(Substring(host, 1, host.Length() - 2)); + CopyUTF16toUTF8(Substring(host, 1, host.Length() - 2), mDomain); } else { - mDomain = NS_ConvertUTF16toUTF8(host); + CopyUTF16toUTF8(host, mDomain); } } diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index 23a5cbbffb44..8d0a09de3f96 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -2024,7 +2024,7 @@ History::UpdatePlaces(JS::Handle aPlaceInfos, if (fatGUID.IsVoid()) { guid.SetIsVoid(true); } else { - guid = NS_ConvertUTF16toUTF8(fatGUID); + CopyUTF16toUTF8(fatGUID, guid); } } diff --git a/toolkit/components/places/nsNavBookmarks.cpp b/toolkit/components/places/nsNavBookmarks.cpp index 37a868634716..001b0248416d 100644 --- a/toolkit/components/places/nsNavBookmarks.cpp +++ b/toolkit/components/places/nsNavBookmarks.cpp @@ -1870,7 +1870,7 @@ void nsNavBookmarks::HandlePlacesEvent(const PlacesEventSequence& aEvents) { ItemVisitData visitData; visitData.visitId = visit->mVisitId; - visitData.bookmark.url = NS_ConvertUTF16toUTF8(visit->mUrl); + CopyUTF16toUTF8(visit->mUrl, visitData.bookmark.url); visitData.time = visit->mVisitTime * 1000; visitData.transitionType = visit->mTransitionType; RefPtr> notifier = @@ -1923,7 +1923,7 @@ nsNavBookmarks::OnPageChanged(nsIURI* aURI, uint32_t aChangedAttribute, NS_ENSURE_SUCCESS(rv, rv); changeData.property = "favicon"_ns; changeData.isAnnotation = false; - changeData.newValue = NS_ConvertUTF16toUTF8(aNewValue); + CopyUTF16toUTF8(aNewValue, changeData.newValue); changeData.bookmark.lastModified = 0; changeData.bookmark.type = TYPE_BOOKMARK; diff --git a/toolkit/components/telemetry/core/TelemetryHistogram.cpp b/toolkit/components/telemetry/core/TelemetryHistogram.cpp index 5de61b503949..98d024cb6f51 100644 --- a/toolkit/components/telemetry/core/TelemetryHistogram.cpp +++ b/toolkit/components/telemetry/core/TelemetryHistogram.cpp @@ -3100,7 +3100,7 @@ nsresult internal_ParseHistogramData( return NS_ERROR_FAILURE; } - aOutName = NS_ConvertUTF16toUTF8(histogramName); + CopyUTF16toUTF8(histogramName, aOutName); // Get the data for this histogram. JS::RootedValue histogramData(aCx); diff --git a/toolkit/system/gnome/nsAlertsIconListener.cpp b/toolkit/system/gnome/nsAlertsIconListener.cpp index 079510baf659..9c3d796c9d68 100644 --- a/toolkit/system/gnome/nsAlertsIconListener.cpp +++ b/toolkit/system/gnome/nsAlertsIconListener.cpp @@ -284,7 +284,7 @@ nsresult nsAlertsIconListener::InitAlertAsync(nsIAlertNotification* aAlert, if (bundle) { bundle->GetStringFromName("brandShortName", appName); - appShortName = NS_ConvertUTF16toUTF8(appName); + CopyUTF16toUTF8(appName, appShortName); } else { NS_WARNING( "brand.properties not present, using default application name"); @@ -329,13 +329,13 @@ nsresult nsAlertsIconListener::InitAlertAsync(nsIAlertNotification* aAlert, if (title.IsEmpty()) { mAlertTitle = " "_ns; } else { - mAlertTitle = NS_ConvertUTF16toUTF8(title); + CopyUTF16toUTF8(title, mAlertTitle); } nsAutoString text; rv = aAlert->GetText(text); NS_ENSURE_SUCCESS(rv, rv); - mAlertText = NS_ConvertUTF16toUTF8(text); + CopyUTF16toUTF8(text, mAlertText); mAlertListener = aAlertListener; diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index aea441f9c442..a198ca1f7a67 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -4034,7 +4034,7 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) { nsString leafName; rv = mProfD->GetLeafName(leafName); if (NS_SUCCEEDED(rv)) { - profileName = NS_ConvertUTF16toUTF8(leafName); + CopyUTF16toUTF8(leafName, profileName); } } diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp index 3694ec6f364c..a7bf142a57fe 100644 --- a/toolkit/xre/nsUpdateDriver.cpp +++ b/toolkit/xre/nsUpdateDriver.cpp @@ -151,7 +151,7 @@ static nsresult GetInstallDirPath(nsIFile* appDir, nsACString& installDirPath) { nsAutoString installDirPathW; rv = appDir->GetPath(installDirPathW); NS_ENSURE_SUCCESS(rv, rv); - installDirPath = NS_ConvertUTF16toUTF8(installDirPathW); + CopyUTF16toUTF8(installDirPathW, installDirPath); #else rv = appDir->GetNativePath(installDirPath); NS_ENSURE_SUCCESS(rv, rv); @@ -336,7 +336,7 @@ static void ApplyUpdate(nsIFile* greDir, nsIFile* updateDir, nsIFile* appDir, if (NS_FAILED(rv)) { return; } - updaterPath = NS_ConvertUTF16toUTF8(updaterPathW); + CopyUTF16toUTF8(updaterPathW, updaterPath); // Get the path to the update dir. nsAutoString updateDirPathW; @@ -344,7 +344,7 @@ static void ApplyUpdate(nsIFile* greDir, nsIFile* updateDir, nsIFile* appDir, if (NS_FAILED(rv)) { return; } - updateDirPath = NS_ConvertUTF16toUTF8(updateDirPathW); + CopyUTF16toUTF8(updateDirPathW, updateDirPath); #elif defined(XP_MACOSX) // Get an nsIFile reference for the updater in the installation dir. if (!GetFile(appDir, nsLiteralCString(UPDATER_APP), updater)) { @@ -418,7 +418,7 @@ static void ApplyUpdate(nsIFile* greDir, nsIFile* updateDir, nsIFile* appDir, if (NS_FAILED(rv)) { return; } - appFilePath = NS_ConvertUTF16toUTF8(appFilePathW); + CopyUTF16toUTF8(appFilePathW, appFilePath); #else rv = appFile->GetNativePath(appFilePath); if (NS_FAILED(rv)) { @@ -454,7 +454,7 @@ static void ApplyUpdate(nsIFile* greDir, nsIFile* updateDir, nsIFile* appDir, if (NS_FAILED(rv)) { return; } - applyToDirPath = NS_ConvertUTF16toUTF8(applyToDirPathW); + CopyUTF16toUTF8(applyToDirPathW, applyToDirPath); #else rv = updatedDir->GetNativePath(applyToDirPath); #endif diff --git a/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp b/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp index 9778dbd94d35..5ea32590f4d0 100644 --- a/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp +++ b/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp @@ -32,7 +32,7 @@ nsMIMEInfoAndroid::LoadUriInternal(nsIURI* aURI) { if (mType.Equals(uriScheme) || mType.Equals(uriSpec)) { mimeType = EmptyString(); } else { - mimeType = NS_ConvertUTF8toUTF16(mType); + CopyUTF8toUTF16(mType, mimeType); } if (java::GeckoAppShell::OpenUriExternal( diff --git a/widget/WidgetEventImpl.cpp b/widget/WidgetEventImpl.cpp index c00850842c0a..4604d7c48be8 100644 --- a/widget/WidgetEventImpl.cpp +++ b/widget/WidgetEventImpl.cpp @@ -213,7 +213,7 @@ Command GetInternalCommand(const char* aCommandName, if (NS_FAILED(rv)) { return Command::FormatJustifyNone; } - cValue = NS_ConvertUTF16toUTF8(value); + CopyUTF16toUTF8(value, cValue); } if (cValue.LowerCaseEqualsASCII("left")) { return Command::FormatJustifyLeft; diff --git a/widget/gtk/nsPrintSettingsGTK.cpp b/widget/gtk/nsPrintSettingsGTK.cpp index 39808c12435f..669f73f1c88e 100644 --- a/widget/gtk/nsPrintSettingsGTK.cpp +++ b/widget/gtk/nsPrintSettingsGTK.cpp @@ -424,7 +424,7 @@ nsPrintSettingsGTK::GetPrinterName(nsAString& aPrinter) { return NS_OK; } } - aPrinter = NS_ConvertUTF8toUTF16(gtkPrintName); + CopyUTF8toUTF16(MakeStringSpan(gtkPrintName), aPrinter); return NS_OK; } @@ -479,7 +479,7 @@ NS_IMETHODIMP nsPrintSettingsGTK::GetPaperName(nsAString& aPaperName) { const gchar* name = gtk_paper_size_get_name(gtk_page_setup_get_paper_size(mPageSetup)); - aPaperName = NS_ConvertUTF8toUTF16(name); + CopyUTF8toUTF16(MakeStringSpan(name), aPaperName); return NS_OK; } NS_IMETHODIMP diff --git a/xpcom/build/NSPRInterposer.cpp b/xpcom/build/NSPRInterposer.cpp index 010374a68b98..184c3793e746 100644 --- a/xpcom/build/NSPRInterposer.cpp +++ b/xpcom/build/NSPRInterposer.cpp @@ -65,7 +65,7 @@ class NSPRIOAutoObservation : public mozilla::IOInterposeObserver::Observation { if (mShouldReport && aFd && GetPathFromFd(PR_FileDesc2NativeHandle(aFd), filename, sizeof(filename)) != -1) { - mFilename = NS_ConvertUTF8toUTF16(filename); + CopyUTF8toUTF16(mozilla::MakeStringSpan(filename), mFilename); } else { mFilename.Truncate(); } diff --git a/xpcom/build/PoisonIOInterposerMac.cpp b/xpcom/build/PoisonIOInterposerMac.cpp index 4df2b2d6b175..beb8c2b38376 100644 --- a/xpcom/build/PoisonIOInterposerMac.cpp +++ b/xpcom/build/PoisonIOInterposerMac.cpp @@ -100,7 +100,7 @@ void MacIOAutoObservation::Filename(nsAString& aFilename) { char filename[MAXPATHLEN]; if (fcntl(mFd, F_GETPATH, filename) != -1) { - mFilename = NS_ConvertUTF8toUTF16(filename); + CopyUTF8toUTF16(filename, mFilename); } else { mFilename.Truncate(); }