1 /* -*- Mode: C++; tab-width: 20; 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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef MODULES_WOFF2_RLBOXWOFF2_HOST_H_
8 #define MODULES_WOFF2_RLBOXWOFF2_HOST_H_
10 #include "RLBoxWOFF2Types.h"
12 // Load general firefox configuration of RLBox
13 #include "mozilla/rlbox/rlbox_config.h"
15 #ifdef MOZ_WASM_SANDBOXING_WOFF2
16 // Include the generated header file so that we are able to resolve the symbols
18 # include "rlbox.wasm.h"
19 # define RLBOX_USE_STATIC_CALLS() rlbox_wasm2c_sandbox_lookup_symbol
20 # include "mozilla/rlbox/rlbox_wasm2c_sandbox.hpp"
22 // Extra configuration for no-op sandbox
23 # define RLBOX_USE_STATIC_CALLS() rlbox_noop_sandbox_lookup_symbol
24 # include "mozilla/rlbox/rlbox_noop_sandbox.hpp"
27 #include "mozilla/rlbox/rlbox.hpp"
29 #include "woff2/RLBoxWOFF2Sandbox.h"
30 #include "./src/ots.h"
32 class RLBoxWOFF2SandboxData
: public mozilla::RLBoxSandboxDataBase
{
33 friend class RLBoxWOFF2SandboxPool
;
36 RLBoxWOFF2SandboxData(uint64_t aSize
,
37 mozilla::UniquePtr
<rlbox_sandbox_woff2
> aSandbox
);
38 ~RLBoxWOFF2SandboxData();
40 rlbox_sandbox_woff2
* Sandbox() const { return mSandbox
.get(); }
43 mozilla::UniquePtr
<rlbox_sandbox_woff2
> mSandbox
;
44 sandbox_callback_woff2
<BrotliDecompressCallback
*> mDecompressCallback
;
47 using ProcessTTCFunc
= bool(ots::FontFile
* aHeader
, ots::OTSStream
* aOutput
,
48 const uint8_t* aData
, size_t aLength
,
51 using ProcessTTFFunc
= bool(ots::FontFile
* aHeader
, ots::Font
* aFont
,
52 ots::OTSStream
* aOutput
, const uint8_t* aData
,
53 size_t aLength
, uint32_t aOffset
);
55 bool RLBoxProcessWOFF2(ots::FontFile
* aHeader
, ots::OTSStream
* aOutput
,
56 const uint8_t* aData
, size_t aLength
, uint32_t aIndex
,
57 ProcessTTCFunc
* aProcessTTC
,
58 ProcessTTFFunc
* aProcessTTF
);