From 17eaf9bf3ff57ed62c0467329e3ec94a60812b15 Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Fri, 13 Nov 2020 07:55:16 +0000 Subject: [PATCH] Bug 1676152 - Generalize StructuredCloneHolder::WriteString to accept a nsAString. r=baku Differential Revision: https://phabricator.services.mozilla.com/D96415 --- dom/base/StructuredCloneHolder.cpp | 5 +++-- dom/base/StructuredCloneHolder.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dom/base/StructuredCloneHolder.cpp b/dom/base/StructuredCloneHolder.cpp index 8573026dc8b7..54ffe8eb14e0 100644 --- a/dom/base/StructuredCloneHolder.cpp +++ b/dom/base/StructuredCloneHolder.cpp @@ -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 { diff --git a/dom/base/StructuredCloneHolder.h b/dom/base/StructuredCloneHolder.h index ad139e100c8e..7e0f39d97bd1 100644 --- a/dom/base/StructuredCloneHolder.h +++ b/dom/base/StructuredCloneHolder.h @@ -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;