Bug 801487 - Update WebIDL definitions. r=sicking

This commit is contained in:
Masatoshi Kimura 2012-10-24 22:03:21 -04:00
parent 08d52f057c
commit 867145ce8f
4 changed files with 15 additions and 24 deletions

View File

@ -12,18 +12,11 @@ namespace mozilla {
namespace dom {
void
TextEncoder::Init(const Optional<nsAString>& aEncoding,
TextEncoder::Init(const nsAString& aEncoding,
ErrorResult& aRv)
{
// If the constructor is called with no arguments, let label be the "utf-8".
// Otherwise, let label be the value of the encoding argument.
nsAutoString label;
if (!aEncoding.WasPassed()) {
label.AssignLiteral("utf-8");
} else {
label.Assign(aEncoding.Value());
EncodingUtils::TrimSpaceCharacters(label);
}
nsAutoString label(aEncoding);
EncodingUtils::TrimSpaceCharacters(label);
// Run the steps to get an encoding from Encoding.
if (!EncodingUtils::FindEncodingForLabel(label, mEncoding)) {

View File

@ -28,7 +28,7 @@ public:
// The WebIDL constructor.
static already_AddRefed<TextEncoder>
Constructor(nsISupports* aGlobal,
const Optional<nsAString>& aEncoding,
const nsAString& aEncoding,
ErrorResult& aRv)
{
nsRefPtr<TextEncoder> txtEncoder = new TextEncoder(aGlobal);
@ -98,7 +98,7 @@ private:
* Default value is "utf-8" if no encoding is provided.
* @return aRv EncodingError exception else null.
*/
void Init(const Optional<nsAString>& aEncoding,
void Init(const nsAString& aEncoding,
ErrorResult& aRv);
};

View File

@ -3,20 +3,18 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://wiki.whatwg.org/wiki/StringEncoding
* http://encoding.spec.whatwg.org/#interface-textdecoder
*
* Copyright © 2006 The WHATWG Contributors
* http://wiki.whatwg.org/wiki/WHATWG_Wiki:Copyrights
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
[Constructor(optional DOMString encoding = "utf-8",
optional TextDecoderOptions options)]
[Constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options)]
interface TextDecoder {
[SetterThrows]
readonly attribute DOMString encoding;
[Throws]
DOMString decode(optional ArrayBufferView? view = null,
optional TextDecodeOptions options);
DOMString decode(optional ArrayBufferView? input = null, optional TextDecodeOptions options);
};
dictionary TextDecoderOptions {

View File

@ -3,18 +3,18 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://wiki.whatwg.org/wiki/StringEncoding
* http://encoding.spec.whatwg.org/#interface-textencoder
*
* Copyright © 2006 The WHATWG Contributors
* http://wiki.whatwg.org/wiki/WHATWG_Wiki:Copyrights
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
[Constructor(optional DOMString encoding)]
[Constructor(optional DOMString label = "utf-8")]
interface TextEncoder {
[SetterThrows]
readonly attribute DOMString encoding;
[Throws]
Uint8Array encode(DOMString? string, optional TextEncodeOptions options);
Uint8Array encode(optional DOMString? input = null, optional TextEncodeOptions options);
};
dictionary TextEncodeOptions {