no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / encoding / TextEncoder.h
blob662a54adb4d9d9ac2fad95ad4f255faf9654bf0e
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_textencoder_h_
8 #define mozilla_dom_textencoder_h_
10 #include "mozilla/dom/NonRefcountedDOMObject.h"
11 #include "mozilla/dom/TextEncoderBinding.h"
12 #include "mozilla/dom/TypedArray.h"
13 #include "mozilla/Encoding.h"
15 namespace mozilla {
16 class ErrorResult;
18 namespace dom {
20 class TextEncoder final : public NonRefcountedDOMObject {
21 public:
22 // The WebIDL constructor.
24 static UniquePtr<TextEncoder> Constructor(const GlobalObject& aGlobal) {
25 return MakeUnique<TextEncoder>();
28 TextEncoder() = default;
30 virtual ~TextEncoder() = default;
32 bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto,
33 JS::MutableHandle<JSObject*> aReflector) {
34 return TextEncoder_Binding::Wrap(aCx, this, aGivenProto, aReflector);
37 public:
38 /**
39 * Return the encoding name.
41 * @param aEncoding, current encoding.
43 void GetEncoding(nsACString& aEncoding);
45 /**
46 * Encodes incoming code units to utf-8.
48 * @param aCx Javascript context.
49 * @param aObj the wrapper of the TextEncoder
50 * @param aString already-encoded utf-8 code units to be returned, via
51 * UTF8String.
52 * @return JSObject* The Uint8Array wrapped in a JS object. Returned via
53 * the aRetval out param.
55 void Encode(JSContext* aCx, JS::Handle<JSObject*> aObj,
56 const nsACString& aUtf8String,
57 JS::MutableHandle<JSObject*> aRetval, ErrorResult& aRv);
59 void EncodeInto(JSContext* aCx, JS::Handle<JSString*> aSrc,
60 const Uint8Array& aDst, TextEncoderEncodeIntoResult& aResult,
61 OOMReporter& aError);
64 } // namespace dom
65 } // namespace mozilla
67 #endif // mozilla_dom_textencoder_h_