mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 966911 Part 4: Recreate the underlying nsAString when an an external string is passed back to C++ r=bholley
This commit is contained in:
parent
d2cea95d46
commit
581a903d05
@ -516,6 +516,14 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
|
||||
|
||||
if (!str) {
|
||||
ws->AssignLiteral(MOZ_UTF16("undefined"));
|
||||
} else if (XPCStringConvert::IsDOMString(str)) {
|
||||
// The characters represent an existing nsStringBuffer that
|
||||
// was shared by XPCStringConvert::ReadableToJSVal.
|
||||
nsStringBuffer::FromData((void *)chars)->ToString(length, *ws);
|
||||
} else if (XPCStringConvert::IsLiteral(str)) {
|
||||
// The characters represent a literal char16_t string constant
|
||||
// compiled into libxul, such as the string "undefined" above.
|
||||
ws->AssignLiteral(chars, length);
|
||||
} else if (useAllocator && STRING_TO_JSVAL(str) == s) {
|
||||
// The JS string will exist over the function call.
|
||||
// We don't need to copy the characters in this case.
|
||||
|
@ -234,6 +234,18 @@ public:
|
||||
static void FreeZoneCache(JS::Zone *zone);
|
||||
static void ClearZoneCache(JS::Zone *zone);
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool IsLiteral(JSString *str)
|
||||
{
|
||||
return JS_IsExternalString(str) &&
|
||||
JS_GetExternalStringFinalizer(str) == &sLiteralFinalizer;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool IsDOMString(JSString *str)
|
||||
{
|
||||
return JS_IsExternalString(str) &&
|
||||
JS_GetExternalStringFinalizer(str) == &sDOMStringFinalizer;
|
||||
}
|
||||
|
||||
private:
|
||||
static const JSStringFinalizer sLiteralFinalizer, sDOMStringFinalizer;
|
||||
|
||||
|
@ -834,13 +834,16 @@ class nsTSubstring_CharT
|
||||
mFlags = dataFlags | (mFlags & 0xFFFF0000);
|
||||
}
|
||||
|
||||
void NS_FASTCALL AssignLiteral( const char_type* data, size_type length );
|
||||
void NS_FASTCALL ReplaceLiteral( index_type cutStart, size_type cutLength, const char_type* data, size_type length );
|
||||
|
||||
static int AppendFunc( void* arg, const char* s, uint32_t len);
|
||||
|
||||
public:
|
||||
|
||||
// NOTE: this method is declared public _only_ for convenience for
|
||||
// callers who don't have access to the original nsLiteralString_CharT.
|
||||
void NS_FASTCALL AssignLiteral( const char_type* data, size_type length );
|
||||
|
||||
// mFlags is a bitwise combination of the following flags. the meaning
|
||||
// and interpretation of these flags is an implementation detail.
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user