tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

RLBoxWOFF2Host.h (2210B)


      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/. */
      6 
      7 #ifndef MODULES_WOFF2_RLBOXWOFF2_HOST_H_
      8 #define MODULES_WOFF2_RLBOXWOFF2_HOST_H_
      9 
     10 #include "RLBoxWOFF2Types.h"
     11 
     12 // Load general firefox configuration of RLBox
     13 #include "mozilla/rlbox/rlbox_config.h"
     14 
     15 #ifdef MOZ_WASM_SANDBOXING_WOFF2
     16 // Include the generated header file so that we are able to resolve the symbols
     17 // in the wasm binary
     18 #  include "rlbox.wasm.h"
     19 #  define RLBOX_USE_STATIC_CALLS() rlbox_wasm2c_sandbox_lookup_symbol
     20 #  include "mozilla/rlbox/rlbox_wasm2c_sandbox.hpp"
     21 #else
     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"
     25 #endif
     26 
     27 #include "mozilla/rlbox/rlbox.hpp"
     28 
     29 #include "woff2/RLBoxWOFF2Sandbox.h"
     30 #include "./src/ots.h"
     31 
     32 class RLBoxWOFF2SandboxData : public mozilla::RLBoxSandboxDataBase {
     33  friend class RLBoxWOFF2SandboxPool;
     34 
     35 public:
     36  RLBoxWOFF2SandboxData(uint64_t aSize,
     37                        mozilla::UniquePtr<rlbox_sandbox_woff2> aSandbox);
     38  ~RLBoxWOFF2SandboxData();
     39 
     40  rlbox_sandbox_woff2* Sandbox() const { return mSandbox.get(); }
     41 
     42 private:
     43  mozilla::UniquePtr<rlbox_sandbox_woff2> mSandbox;
     44  sandbox_callback_woff2<BrotliDecompressCallback*> mDecompressCallback;
     45 };
     46 
     47 using ProcessTTCFunc = bool(ots::FontFile* aHeader, ots::OTSStream* aOutput,
     48                            const uint8_t* aData, size_t aLength,
     49                            uint32_t aIndex);
     50 
     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);
     54 
     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);
     59 #endif