mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1092737 part 1. Update TextEncoder to various spec changes. r=emk
This commit is contained in:
parent
d35c2686c4
commit
be526b5304
@ -44,8 +44,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=882653
|
||||
[ 'document.createTreeWalker(document, 0xFFFFFFFF, { acceptNode: 5 }).nextNode()',
|
||||
"Property 'acceptNode' is not callable.",
|
||||
"non-callable callback interface operation property" ],
|
||||
[ '(new TextEncoder).encode("", new RegExp())',
|
||||
"Argument 2 of TextEncoder.encode can't be converted to a dictionary.",
|
||||
[ '(new TextDecoder).decode(new Uint8Array(), new RegExp())',
|
||||
"Argument 2 of TextDecoder.decode can't be converted to a dictionary.",
|
||||
"regexp passed for a dictionary" ],
|
||||
[ 'URL.createObjectURL(null, null)',
|
||||
"Argument 1 is not valid for any of the 2-argument overloads of URL.createObjectURL.",
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -38,8 +39,7 @@ void
|
||||
TextEncoder::Encode(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aObj,
|
||||
const nsAString& aString,
|
||||
const bool aStream,
|
||||
JS::MutableHandle<JSObject*> aRetval,
|
||||
JS::MutableHandle<JSObject*> aRetval,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
// Run the steps of the encoding algorithm.
|
||||
@ -63,14 +63,11 @@ TextEncoder::Encode(JSContext* aCx,
|
||||
int32_t dstLen = maxLen;
|
||||
rv = mEncoder->Convert(data, &srcLen, buf, &dstLen);
|
||||
|
||||
// If the internal streaming flag is not set, then reset
|
||||
// the encoding algorithm state to the default values for encoding.
|
||||
if (!aStream) {
|
||||
int32_t finishLen = maxLen - dstLen;
|
||||
rv = mEncoder->Finish(buf + dstLen, &finishLen);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
dstLen += finishLen;
|
||||
}
|
||||
// Now reset the encoding algorithm state to the default values for encoding.
|
||||
int32_t finishLen = maxLen - dstLen;
|
||||
rv = mEncoder->Finish(buf + dstLen, &finishLen);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
dstLen += finishLen;
|
||||
}
|
||||
|
||||
JSObject* outView = nullptr;
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -46,15 +47,6 @@ public:
|
||||
return TextEncoderBinding::Wrap(aCx, this, aTookOwnership);
|
||||
}
|
||||
|
||||
void Encode(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aObj,
|
||||
const nsAString& aString,
|
||||
const TextEncodeOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aRetval,
|
||||
ErrorResult& aRv) {
|
||||
TextEncoder::Encode(aCx, aObj, aString, aOptions.mStream, aRetval, aRv);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
@ -82,20 +74,14 @@ public:
|
||||
* @param aCx Javascript context.
|
||||
* @param aObj the wrapper of the TextEncoder
|
||||
* @param aString utf-16 code units to be encoded.
|
||||
* @param aOptions Streaming option. Initialised by default to false.
|
||||
* If the streaming option is false, then the encoding
|
||||
* algorithm state will get reset. If set to true then
|
||||
* the previous encoding is reused/continued.
|
||||
* @return JSObject* The Uint8Array wrapped in a JS object. Returned via
|
||||
* the aRetval out param.
|
||||
*/
|
||||
void Encode(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aObj,
|
||||
const nsAString& aString,
|
||||
const bool aStream,
|
||||
JS::MutableHandle<JSObject*> aRetval,
|
||||
ErrorResult& aRv);
|
||||
|
||||
JS::Handle<JSObject*> aObj,
|
||||
const nsAString& aString,
|
||||
JS::MutableHandle<JSObject*> aRetval,
|
||||
ErrorResult& aRv);
|
||||
private:
|
||||
nsCString mEncoding;
|
||||
nsCOMPtr<nsIUnicodeEncoder> mEncoder;
|
||||
|
@ -15,11 +15,6 @@
|
||||
interface TextEncoder {
|
||||
[Constant]
|
||||
readonly attribute DOMString encoding;
|
||||
[Throws]
|
||||
Uint8Array encode(optional DOMString input = "", optional TextEncodeOptions options);
|
||||
[Throws, NewObject]
|
||||
Uint8Array encode(optional ScalarValueString input = "");
|
||||
};
|
||||
|
||||
dictionary TextEncodeOptions {
|
||||
boolean stream = false;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user