Bug 1676152 - Generalize StructuredCloneHolder::WriteString to accept a nsAString. r=baku

Differential Revision: https://phabricator.services.mozilla.com/D96415
This commit is contained in:
Simon Giesecke 2020-11-13 07:55:16 +00:00
Родитель 119d8f1aa7
Коммит 17eaf9bf3f
2 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -481,10 +481,11 @@ bool StructuredCloneHolder::ReadString(JSStructuredCloneReader* aReader,
/* static */
bool StructuredCloneHolder::WriteString(JSStructuredCloneWriter* aWriter,
const nsString& aString) {
const nsAString& aString) {
size_t charSize = sizeof(nsString::char_type);
return JS_WriteUint32Pair(aWriter, aString.Length(), 0) &&
JS_WriteBytes(aWriter, aString.get(), aString.Length() * charSize);
JS_WriteBytes(aWriter, aString.BeginReading(),
aString.Length() * charSize);
}
namespace {

Просмотреть файл

@ -296,7 +296,7 @@ class StructuredCloneHolder : public StructuredCloneHolderBase {
// Helper functions for reading and writing strings.
static bool ReadString(JSStructuredCloneReader* aReader, nsString& aString);
static bool WriteString(JSStructuredCloneWriter* aWriter,
const nsString& aString);
const nsAString& aString);
static const JSStructuredCloneCallbacks sCallbacks;