Bug 1806169 - Add ScriptLoader::ConvertToUTF8 overload r=jonco

Similar to the ConvertToUTF16 overload for JS owned strings, add an overload for
the UTF8 case. This simplifies later work to switch parsing to UTF8.

Differential Revision: https://phabricator.services.mozilla.com/D164930
This commit is contained in:
Ted Campbell
2022-12-23 21:26:25 +00:00
parent 5b3c63b61e
commit ee986225db

View File

@@ -276,12 +276,12 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
Document* aDocument, char16_t*& aBufOut,
size_t& aLengthOut);
static inline nsresult ConvertToUTF16(nsIChannel* aChannel,
const uint8_t* aData, uint32_t aLength,
const nsAString& aHintCharset,
Document* aDocument,
JS::UniqueTwoByteChars& aBufOut,
size_t& aLengthOut) {
static nsresult ConvertToUTF16(nsIChannel* aChannel, const uint8_t* aData,
uint32_t aLength,
const nsAString& aHintCharset,
Document* aDocument,
JS::UniqueTwoByteChars& aBufOut,
size_t& aLengthOut) {
char16_t* bufOut;
nsresult rv = ConvertToUTF16(aChannel, aData, aLength, aHintCharset,
aDocument, bufOut, aLengthOut);
@@ -316,6 +316,19 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
Document* aDocument, Utf8Unit*& aBufOut,
size_t& aLengthOut);
static inline nsresult ConvertToUTF8(
nsIChannel* aChannel, const uint8_t* aData, uint32_t aLength,
const nsAString& aHintCharset, Document* aDocument,
UniquePtr<Utf8Unit[], JS::FreePolicy>& aBufOut, size_t& aLengthOut) {
Utf8Unit* bufOut;
nsresult rv = ConvertToUTF8(aChannel, aData, aLength, aHintCharset,
aDocument, bufOut, aLengthOut);
if (NS_SUCCEEDED(rv)) {
aBufOut.reset(bufOut);
}
return rv;
};
/**
* Handle the completion of a stream. This is called by the
* ScriptLoadHandler object which observes the IncrementalStreamLoader