Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
michael@0 | 2 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 3 | // found in the LICENSE file. |
michael@0 | 4 | |
michael@0 | 5 | #include "vhea.h" |
michael@0 | 6 | |
michael@0 | 7 | #include "gsub.h" |
michael@0 | 8 | #include "head.h" |
michael@0 | 9 | #include "maxp.h" |
michael@0 | 10 | |
michael@0 | 11 | // vhea - Vertical Header Table |
michael@0 | 12 | // http://www.microsoft.com/typography/otspec/vhea.htm |
michael@0 | 13 | |
michael@0 | 14 | #define TABLE_NAME "vhea" |
michael@0 | 15 | |
michael@0 | 16 | namespace ots { |
michael@0 | 17 | |
michael@0 | 18 | bool ots_vhea_parse(OpenTypeFile *file, const uint8_t *data, size_t length) { |
michael@0 | 19 | Buffer table(data, length); |
michael@0 | 20 | OpenTypeVHEA *vhea = new OpenTypeVHEA; |
michael@0 | 21 | file->vhea = vhea; |
michael@0 | 22 | |
michael@0 | 23 | if (!table.ReadU32(&vhea->header.version)) { |
michael@0 | 24 | return OTS_FAILURE_MSG("Failed to read version"); |
michael@0 | 25 | } |
michael@0 | 26 | if (vhea->header.version != 0x00010000 && |
michael@0 | 27 | vhea->header.version != 0x00011000) { |
michael@0 | 28 | return OTS_FAILURE_MSG("Bad vhea version %x", vhea->header.version); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | if (!ParseMetricsHeader(file, &table, &vhea->header)) { |
michael@0 | 32 | return OTS_FAILURE_MSG("Failed to parse metrics in vhea"); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | return true; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | bool ots_vhea_should_serialise(OpenTypeFile *file) { |
michael@0 | 39 | // vhea should'nt serialise when vmtx doesn't exist. |
michael@0 | 40 | // Firefox developer pointed out that vhea/vmtx should serialise iff GSUB is |
michael@0 | 41 | // preserved. See http://crbug.com/77386 |
michael@0 | 42 | return file->vhea != NULL && file->vmtx != NULL && |
michael@0 | 43 | ots_gsub_should_serialise(file); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | bool ots_vhea_serialise(OTSStream *out, OpenTypeFile *file) { |
michael@0 | 47 | if (!SerialiseMetricsHeader(file, out, &file->vhea->header)) { |
michael@0 | 48 | return OTS_FAILURE_MSG("Failed to write vhea metrics"); |
michael@0 | 49 | } |
michael@0 | 50 | return true; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | void ots_vhea_free(OpenTypeFile *file) { |
michael@0 | 54 | delete file->vhea; |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | } // namespace ots |
michael@0 | 58 |