gfx/ots/src/cvt.cc

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
     2 // Use of this source code is governed by a BSD-style license that can be
     3 // found in the LICENSE file.
     5 #include "cvt.h"
     7 // cvt - Control Value Table
     8 // http://www.microsoft.com/typography/otspec/cvt.htm
    10 #define TABLE_NAME "cvt"
    12 namespace ots {
    14 bool ots_cvt_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
    15   Buffer table(data, length);
    17   OpenTypeCVT *cvt = new OpenTypeCVT;
    18   file->cvt = cvt;
    20   if (length >= 128 * 1024u) {
    21     return OTS_FAILURE_MSG("Length (%d) > 120K");  // almost all cvt tables are less than 4k bytes.
    22   }
    24   if (length % 2 != 0) {
    25     return OTS_FAILURE_MSG("Uneven cvt length (%d)", length);
    26   }
    28   if (!table.Skip(length)) {
    29     return OTS_FAILURE_MSG("Length too high");
    30   }
    32   cvt->data = data;
    33   cvt->length = length;
    34   return true;
    35 }
    37 bool ots_cvt_should_serialise(OpenTypeFile *file) {
    38   if (!file->glyf) {
    39     return false;  // this table is not for CFF fonts.
    40   }
    41   return g_transcode_hints && file->cvt;
    42 }
    44 bool ots_cvt_serialise(OTSStream *out, OpenTypeFile *file) {
    45   const OpenTypeCVT *cvt = file->cvt;
    47   if (!out->Write(cvt->data, cvt->length)) {
    48     return OTS_FAILURE_MSG("Failed to write CVT table");
    49   }
    51   return true;
    52 }
    54 void ots_cvt_free(OpenTypeFile *file) {
    55   delete file->cvt;
    56 }
    58 }  // namespace ots

mercurial