Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "gfxDWriteCommon.h"
8 IDWriteFontFileLoader* gfxDWriteFontFileLoader::mInstance = nullptr;
10 HRESULT STDMETHODCALLTYPE
11 gfxDWriteFontFileLoader::CreateStreamFromKey(const void *fontFileReferenceKey,
12 UINT32 fontFileReferenceKeySize,
13 IDWriteFontFileStream **fontFileStream)
14 {
15 if (!fontFileReferenceKey || !fontFileStream) {
16 return E_POINTER;
17 }
19 *fontFileStream =
20 new gfxDWriteFontFileStream(
21 static_cast<const ffReferenceKey*>(fontFileReferenceKey)->mArray);
23 if (!*fontFileStream) {
24 return E_OUTOFMEMORY;
25 }
26 (*fontFileStream)->AddRef();
27 return S_OK;
28 }
30 gfxDWriteFontFileStream::gfxDWriteFontFileStream(FallibleTArray<uint8_t> *aData)
31 {
32 mData.SwapElements(*aData);
33 }
35 gfxDWriteFontFileStream::~gfxDWriteFontFileStream()
36 {
37 }
39 HRESULT STDMETHODCALLTYPE
40 gfxDWriteFontFileStream::GetFileSize(UINT64 *fileSize)
41 {
42 *fileSize = mData.Length();
43 return S_OK;
44 }
46 HRESULT STDMETHODCALLTYPE
47 gfxDWriteFontFileStream::GetLastWriteTime(UINT64 *lastWriteTime)
48 {
49 return E_NOTIMPL;
50 }
52 HRESULT STDMETHODCALLTYPE
53 gfxDWriteFontFileStream::ReadFileFragment(const void **fragmentStart,
54 UINT64 fileOffset,
55 UINT64 fragmentSize,
56 void **fragmentContext)
57 {
58 // We are required to do bounds checking.
59 if (fileOffset + fragmentSize > (UINT64)mData.Length()) {
60 return E_FAIL;
61 }
62 // We should be alive for the duration of this.
63 *fragmentStart = &mData[fileOffset];
64 *fragmentContext = nullptr;
65 return S_OK;
66 }
68 void STDMETHODCALLTYPE
69 gfxDWriteFontFileStream::ReleaseFileFragment(void *fragmentContext)
70 {
71 }