2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-09-28 14:19:18 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_textencoder_h_
|
|
|
|
#define mozilla_dom_textencoder_h_
|
|
|
|
|
2013-08-23 09:17:10 +04:00
|
|
|
#include "mozilla/dom/NonRefcountedDOMObject.h"
|
2012-09-28 14:19:18 +04:00
|
|
|
#include "mozilla/dom/TextEncoderBinding.h"
|
2013-08-23 09:17:10 +04:00
|
|
|
#include "mozilla/dom/TypedArray.h"
|
2017-04-27 13:27:03 +03:00
|
|
|
#include "mozilla/Encoding.h"
|
2012-09-28 14:19:18 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-08-23 09:17:10 +04:00
|
|
|
class ErrorResult;
|
|
|
|
|
2012-09-28 14:19:18 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class TextEncoder final : public NonRefcountedDOMObject {
|
2012-09-28 14:19:18 +04:00
|
|
|
public:
|
|
|
|
// The WebIDL constructor.
|
2013-08-23 09:17:10 +04:00
|
|
|
|
2019-09-12 14:01:17 +03:00
|
|
|
static TextEncoder* Constructor(const GlobalObject& aGlobal) {
|
|
|
|
return new TextEncoder();
|
2012-09-28 14:19:18 +04:00
|
|
|
}
|
|
|
|
|
2020-02-20 19:16:10 +03:00
|
|
|
TextEncoder() = default;
|
2012-09-28 14:19:18 +04:00
|
|
|
|
2020-02-20 19:16:10 +03:00
|
|
|
virtual ~TextEncoder() = default;
|
2012-09-28 14:19:18 +04:00
|
|
|
|
Bug 1117172 part 2. Change the non-wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, Codegen.py, and
StructuredClone.cpp. The rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/WrapObject\((JSContext *\* *(?:aCx|cx)),(\s*)(JS::MutableHandle<JSObject\*> aReflector)/WrapObject(\1,\2JS::Handle<JSObject*> aGivenProto,\2\3/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx)), this, aReflector/\1, this, aGivenProto, aReflector/'
2015-03-19 17:13:32 +03:00
|
|
|
bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto,
|
|
|
|
JS::MutableHandle<JSObject*> aReflector) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return TextEncoder_Binding::Wrap(aCx, this, aGivenProto, aReflector);
|
2012-09-28 14:19:18 +04:00
|
|
|
}
|
|
|
|
|
2013-08-23 09:17:10 +04:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Return the encoding name.
|
|
|
|
*
|
|
|
|
* @param aEncoding, current encoding.
|
|
|
|
*/
|
2019-09-18 11:26:52 +03:00
|
|
|
void GetEncoding(nsACString& aEncoding);
|
2013-08-23 09:17:10 +04:00
|
|
|
|
|
|
|
/**
|
2020-01-07 11:46:31 +03:00
|
|
|
* Encodes incoming code units to utf-8.
|
2013-08-23 09:17:10 +04:00
|
|
|
*
|
|
|
|
* @param aCx Javascript context.
|
|
|
|
* @param aObj the wrapper of the TextEncoder
|
2020-01-07 11:46:31 +03:00
|
|
|
* @param aString already-encoded utf-8 code units to be returned, via
|
|
|
|
* UTF8String.
|
2014-06-12 00:26:52 +04:00
|
|
|
* @return JSObject* The Uint8Array wrapped in a JS object. Returned via
|
|
|
|
* the aRetval out param.
|
2013-08-23 09:17:10 +04:00
|
|
|
*/
|
2014-11-21 22:58:45 +03:00
|
|
|
void Encode(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
2020-01-07 11:46:31 +03:00
|
|
|
const nsACString& aUtf8String,
|
2019-09-24 11:51:47 +03:00
|
|
|
JS::MutableHandle<JSObject*> aRetval, OOMReporter& aRv);
|
2018-12-17 19:44:43 +03:00
|
|
|
|
2019-09-18 11:26:52 +03:00
|
|
|
void EncodeInto(JSContext* aCx, JS::Handle<JSString*> aSrc,
|
|
|
|
const Uint8Array& aDst, TextEncoderEncodeIntoResult& aResult,
|
|
|
|
OOMReporter& aError);
|
2012-09-28 14:19:18 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2012-09-28 14:19:18 +04:00
|
|
|
|
|
|
|
#endif // mozilla_dom_textencoder_h_
|