gfx/harfbuzz/src/hb-ucdn.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.

michael@0 1 /*
michael@0 2 * Copyright (C) 2012 Grigori Goronzy <greg@kinoho.net>
michael@0 3 *
michael@0 4 * Permission to use, copy, modify, and/or distribute this software for any
michael@0 5 * purpose with or without fee is hereby granted, provided that the above
michael@0 6 * copyright notice and this permission notice appear in all copies.
michael@0 7 *
michael@0 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
michael@0 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
michael@0 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
michael@0 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
michael@0 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
michael@0 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
michael@0 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
michael@0 15 */
michael@0 16
michael@0 17 #include "hb-private.hh"
michael@0 18
michael@0 19 #include "hb-unicode-private.hh"
michael@0 20
michael@0 21 #include "ucdn.h"
michael@0 22
michael@0 23 static const hb_script_t ucdn_script_translate[] =
michael@0 24 {
michael@0 25 HB_SCRIPT_COMMON,
michael@0 26 HB_SCRIPT_LATIN,
michael@0 27 HB_SCRIPT_GREEK,
michael@0 28 HB_SCRIPT_CYRILLIC,
michael@0 29 HB_SCRIPT_ARMENIAN,
michael@0 30 HB_SCRIPT_HEBREW,
michael@0 31 HB_SCRIPT_ARABIC,
michael@0 32 HB_SCRIPT_SYRIAC,
michael@0 33 HB_SCRIPT_THAANA,
michael@0 34 HB_SCRIPT_DEVANAGARI,
michael@0 35 HB_SCRIPT_BENGALI,
michael@0 36 HB_SCRIPT_GURMUKHI,
michael@0 37 HB_SCRIPT_GUJARATI,
michael@0 38 HB_SCRIPT_ORIYA,
michael@0 39 HB_SCRIPT_TAMIL,
michael@0 40 HB_SCRIPT_TELUGU,
michael@0 41 HB_SCRIPT_KANNADA,
michael@0 42 HB_SCRIPT_MALAYALAM,
michael@0 43 HB_SCRIPT_SINHALA,
michael@0 44 HB_SCRIPT_THAI,
michael@0 45 HB_SCRIPT_LAO,
michael@0 46 HB_SCRIPT_TIBETAN,
michael@0 47 HB_SCRIPT_MYANMAR,
michael@0 48 HB_SCRIPT_GEORGIAN,
michael@0 49 HB_SCRIPT_HANGUL,
michael@0 50 HB_SCRIPT_ETHIOPIC,
michael@0 51 HB_SCRIPT_CHEROKEE,
michael@0 52 HB_SCRIPT_CANADIAN_SYLLABICS,
michael@0 53 HB_SCRIPT_OGHAM,
michael@0 54 HB_SCRIPT_RUNIC,
michael@0 55 HB_SCRIPT_KHMER,
michael@0 56 HB_SCRIPT_MONGOLIAN,
michael@0 57 HB_SCRIPT_HIRAGANA,
michael@0 58 HB_SCRIPT_KATAKANA,
michael@0 59 HB_SCRIPT_BOPOMOFO,
michael@0 60 HB_SCRIPT_HAN,
michael@0 61 HB_SCRIPT_YI,
michael@0 62 HB_SCRIPT_OLD_ITALIC,
michael@0 63 HB_SCRIPT_GOTHIC,
michael@0 64 HB_SCRIPT_DESERET,
michael@0 65 HB_SCRIPT_INHERITED,
michael@0 66 HB_SCRIPT_TAGALOG,
michael@0 67 HB_SCRIPT_HANUNOO,
michael@0 68 HB_SCRIPT_BUHID,
michael@0 69 HB_SCRIPT_TAGBANWA,
michael@0 70 HB_SCRIPT_LIMBU,
michael@0 71 HB_SCRIPT_TAI_LE,
michael@0 72 HB_SCRIPT_LINEAR_B,
michael@0 73 HB_SCRIPT_UGARITIC,
michael@0 74 HB_SCRIPT_SHAVIAN,
michael@0 75 HB_SCRIPT_OSMANYA,
michael@0 76 HB_SCRIPT_CYPRIOT,
michael@0 77 HB_SCRIPT_BRAILLE,
michael@0 78 HB_SCRIPT_BUGINESE,
michael@0 79 HB_SCRIPT_COPTIC,
michael@0 80 HB_SCRIPT_NEW_TAI_LUE,
michael@0 81 HB_SCRIPT_GLAGOLITIC,
michael@0 82 HB_SCRIPT_TIFINAGH,
michael@0 83 HB_SCRIPT_SYLOTI_NAGRI,
michael@0 84 HB_SCRIPT_OLD_PERSIAN,
michael@0 85 HB_SCRIPT_KHAROSHTHI,
michael@0 86 HB_SCRIPT_BALINESE,
michael@0 87 HB_SCRIPT_CUNEIFORM,
michael@0 88 HB_SCRIPT_PHOENICIAN,
michael@0 89 HB_SCRIPT_PHAGS_PA,
michael@0 90 HB_SCRIPT_NKO,
michael@0 91 HB_SCRIPT_SUNDANESE,
michael@0 92 HB_SCRIPT_LEPCHA,
michael@0 93 HB_SCRIPT_OL_CHIKI,
michael@0 94 HB_SCRIPT_VAI,
michael@0 95 HB_SCRIPT_SAURASHTRA,
michael@0 96 HB_SCRIPT_KAYAH_LI,
michael@0 97 HB_SCRIPT_REJANG,
michael@0 98 HB_SCRIPT_LYCIAN,
michael@0 99 HB_SCRIPT_CARIAN,
michael@0 100 HB_SCRIPT_LYDIAN,
michael@0 101 HB_SCRIPT_CHAM,
michael@0 102 HB_SCRIPT_TAI_THAM,
michael@0 103 HB_SCRIPT_TAI_VIET,
michael@0 104 HB_SCRIPT_AVESTAN,
michael@0 105 HB_SCRIPT_EGYPTIAN_HIEROGLYPHS,
michael@0 106 HB_SCRIPT_SAMARITAN,
michael@0 107 HB_SCRIPT_LISU,
michael@0 108 HB_SCRIPT_BAMUM,
michael@0 109 HB_SCRIPT_JAVANESE,
michael@0 110 HB_SCRIPT_MEETEI_MAYEK,
michael@0 111 HB_SCRIPT_IMPERIAL_ARAMAIC,
michael@0 112 HB_SCRIPT_OLD_SOUTH_ARABIAN,
michael@0 113 HB_SCRIPT_INSCRIPTIONAL_PARTHIAN,
michael@0 114 HB_SCRIPT_INSCRIPTIONAL_PAHLAVI,
michael@0 115 HB_SCRIPT_OLD_TURKIC,
michael@0 116 HB_SCRIPT_KAITHI,
michael@0 117 HB_SCRIPT_BATAK,
michael@0 118 HB_SCRIPT_BRAHMI,
michael@0 119 HB_SCRIPT_MANDAIC,
michael@0 120 HB_SCRIPT_CHAKMA,
michael@0 121 HB_SCRIPT_MEROITIC_CURSIVE,
michael@0 122 HB_SCRIPT_MEROITIC_HIEROGLYPHS,
michael@0 123 HB_SCRIPT_MIAO,
michael@0 124 HB_SCRIPT_SHARADA,
michael@0 125 HB_SCRIPT_SORA_SOMPENG,
michael@0 126 HB_SCRIPT_TAKRI,
michael@0 127 HB_SCRIPT_UNKNOWN,
michael@0 128 };
michael@0 129
michael@0 130 static hb_unicode_combining_class_t
michael@0 131 hb_ucdn_combining_class(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
michael@0 132 void *user_data HB_UNUSED)
michael@0 133 {
michael@0 134 return (hb_unicode_combining_class_t) ucdn_get_combining_class(unicode);
michael@0 135 }
michael@0 136
michael@0 137 static unsigned int
michael@0 138 hb_ucdn_eastasian_width(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
michael@0 139 void *user_data HB_UNUSED)
michael@0 140 {
michael@0 141 int w = ucdn_get_east_asian_width(unicode);
michael@0 142 return (w == UCDN_EAST_ASIAN_F || w == UCDN_EAST_ASIAN_W) ? 2 : 1;
michael@0 143 }
michael@0 144
michael@0 145 static hb_unicode_general_category_t
michael@0 146 hb_ucdn_general_category(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
michael@0 147 void *user_data HB_UNUSED)
michael@0 148 {
michael@0 149 return (hb_unicode_general_category_t)ucdn_get_general_category(unicode);
michael@0 150 }
michael@0 151
michael@0 152 static hb_codepoint_t
michael@0 153 hb_ucdn_mirroring(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
michael@0 154 void *user_data HB_UNUSED)
michael@0 155 {
michael@0 156 return ucdn_mirror(unicode);
michael@0 157 }
michael@0 158
michael@0 159 static hb_script_t
michael@0 160 hb_ucdn_script(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
michael@0 161 void *user_data HB_UNUSED)
michael@0 162 {
michael@0 163 return ucdn_script_translate[ucdn_get_script(unicode)];
michael@0 164 }
michael@0 165
michael@0 166 static hb_bool_t
michael@0 167 hb_ucdn_compose(hb_unicode_funcs_t *ufuncs,
michael@0 168 hb_codepoint_t a, hb_codepoint_t b, hb_codepoint_t *ab,
michael@0 169 void *user_data HB_UNUSED)
michael@0 170 {
michael@0 171 return ucdn_compose(ab, a, b);
michael@0 172 }
michael@0 173
michael@0 174 static hb_bool_t
michael@0 175 hb_ucdn_decompose(hb_unicode_funcs_t *ufuncs,
michael@0 176 hb_codepoint_t ab, hb_codepoint_t *a, hb_codepoint_t *b,
michael@0 177 void *user_data HB_UNUSED)
michael@0 178 {
michael@0 179 return ucdn_decompose(ab, a, b);
michael@0 180 }
michael@0 181
michael@0 182 static unsigned int
michael@0 183 hb_ucdn_decompose_compatibility(hb_unicode_funcs_t *ufuncs,
michael@0 184 hb_codepoint_t u, hb_codepoint_t *decomposed,
michael@0 185 void *user_data HB_UNUSED)
michael@0 186 {
michael@0 187 return ucdn_compat_decompose(u, decomposed);
michael@0 188 }
michael@0 189
michael@0 190 extern "C" HB_INTERNAL
michael@0 191 hb_unicode_funcs_t *
michael@0 192 hb_ucdn_get_unicode_funcs (void)
michael@0 193 {
michael@0 194 static const hb_unicode_funcs_t _hb_ucdn_unicode_funcs = {
michael@0 195 HB_OBJECT_HEADER_STATIC,
michael@0 196
michael@0 197 NULL, /* parent */
michael@0 198 true, /* immutable */
michael@0 199 {
michael@0 200 #define HB_UNICODE_FUNC_IMPLEMENT(name) hb_ucdn_##name,
michael@0 201 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
michael@0 202 #undef HB_UNICODE_FUNC_IMPLEMENT
michael@0 203 }
michael@0 204 };
michael@0 205
michael@0 206 return const_cast<hb_unicode_funcs_t *> (&_hb_ucdn_unicode_funcs);
michael@0 207 }
michael@0 208

mercurial