Sat, 03 Jan 2015 20:18:00 +0100
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 /*
2 * Copyright © 2009 Red Hat, Inc.
3 * Copyright © 2011 Codethink Limited
4 * Copyright © 2010,2011,2012 Google, Inc.
5 *
6 * This is part of HarfBuzz, a text shaping library.
7 *
8 * Permission is hereby granted, without written agreement and without
9 * license or royalty fees, to use, copy, modify, and distribute this
10 * software and its documentation for any purpose, provided that the
11 * above copyright notice and the following two paragraphs appear in
12 * all copies of this software.
13 *
14 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
15 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
16 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
17 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18 * DAMAGE.
19 *
20 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
21 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
23 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
24 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 *
26 * Red Hat Author(s): Behdad Esfahbod
27 * Codethink Author(s): Ryan Lortie
28 * Google Author(s): Behdad Esfahbod
29 */
31 #ifndef HB_UNICODE_PRIVATE_HH
32 #define HB_UNICODE_PRIVATE_HH
34 #include "hb-private.hh"
35 #include "hb-object-private.hh"
38 extern HB_INTERNAL const uint8_t _hb_modified_combining_class[256];
40 /*
41 * hb_unicode_funcs_t
42 */
44 #define HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS \
45 HB_UNICODE_FUNC_IMPLEMENT (combining_class) \
46 HB_UNICODE_FUNC_IMPLEMENT (eastasian_width) \
47 HB_UNICODE_FUNC_IMPLEMENT (general_category) \
48 HB_UNICODE_FUNC_IMPLEMENT (mirroring) \
49 HB_UNICODE_FUNC_IMPLEMENT (script) \
50 HB_UNICODE_FUNC_IMPLEMENT (compose) \
51 HB_UNICODE_FUNC_IMPLEMENT (decompose) \
52 HB_UNICODE_FUNC_IMPLEMENT (decompose_compatibility) \
53 /* ^--- Add new callbacks here */
55 /* Simple callbacks are those taking a hb_codepoint_t and returning a hb_codepoint_t */
56 #define HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE \
57 HB_UNICODE_FUNC_IMPLEMENT (hb_unicode_combining_class_t, combining_class) \
58 HB_UNICODE_FUNC_IMPLEMENT (unsigned int, eastasian_width) \
59 HB_UNICODE_FUNC_IMPLEMENT (hb_unicode_general_category_t, general_category) \
60 HB_UNICODE_FUNC_IMPLEMENT (hb_codepoint_t, mirroring) \
61 HB_UNICODE_FUNC_IMPLEMENT (hb_script_t, script) \
62 /* ^--- Add new simple callbacks here */
64 struct hb_unicode_funcs_t {
65 hb_object_header_t header;
66 ASSERT_POD ();
68 hb_unicode_funcs_t *parent;
70 bool immutable;
72 #define HB_UNICODE_FUNC_IMPLEMENT(return_type, name) \
73 inline return_type name (hb_codepoint_t unicode) { return func.name (this, unicode, user_data.name); }
74 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
75 #undef HB_UNICODE_FUNC_IMPLEMENT
77 inline hb_bool_t compose (hb_codepoint_t a, hb_codepoint_t b,
78 hb_codepoint_t *ab)
79 {
80 *ab = 0;
81 if (unlikely (!a || !b)) return false;
82 return func.compose (this, a, b, ab, user_data.compose);
83 }
85 inline hb_bool_t decompose (hb_codepoint_t ab,
86 hb_codepoint_t *a, hb_codepoint_t *b)
87 {
88 *a = ab; *b = 0;
89 return func.decompose (this, ab, a, b, user_data.decompose);
90 }
92 inline unsigned int decompose_compatibility (hb_codepoint_t u,
93 hb_codepoint_t *decomposed)
94 {
95 unsigned int ret = func.decompose_compatibility (this, u, decomposed, user_data.decompose_compatibility);
96 if (ret == 1 && u == decomposed[0]) {
97 decomposed[0] = 0;
98 return 0;
99 }
100 decomposed[ret] = 0;
101 return ret;
102 }
105 unsigned int
106 modified_combining_class (hb_codepoint_t unicode)
107 {
108 /* XXX This hack belongs to the Myanmar shaper. */
109 if (unlikely (unicode == 0x1037)) unicode = 0x103A;
111 /* XXX This hack belongs to the SEA shaper (for Tai Tham):
112 * Reorder SAKOT to ensure it comes after any tone marks. */
113 if (unlikely (unicode == 0x1A60)) return 254;
115 return _hb_modified_combining_class[combining_class (unicode)];
116 }
118 inline hb_bool_t
119 is_variation_selector (hb_codepoint_t unicode)
120 {
121 return unlikely (hb_in_ranges<hb_codepoint_t> (unicode,
122 0x180B, 0x180D, /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */
123 0xFE00, 0xFE0F, /* VARIATION SELECTOR-1..16 */
124 0xE0100, 0xE01EF)); /* VARIATION SELECTOR-17..256 */
125 }
127 /* Default_Ignorable codepoints:
128 *
129 * Note that as of Oct 2012 (Unicode 6.2), U+180E MONGOLIAN VOWEL SEPARATOR
130 * is NOT Default_Ignorable, but it really behaves in a way that it should
131 * be. That has been reported to the Unicode Technical Committee for
132 * consideration. As such, we include it here, since Uniscribe removes it.
133 * It *is* in Unicode 6.3 however. U+061C ARABIC LETTER MARK from Unicode
134 * 6.3 is also added manually. The new Unicode 6.3 bidi formatting
135 * characters are encoded in a block that was Default_Ignorable already.
136 *
137 * Note: While U+115F, U+1160, U+3164 and U+FFA0 are Default_Ignorable,
138 * we do NOT want to hide them, as the way Uniscribe has implemented them
139 * is with regular spacing glyphs, and that's the way fonts are made to work.
140 * As such, we make exceptions for those four.
141 *
142 * Gathered from:
143 * http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[:DI:]&abb=on&ucd=on&esc=on
144 *
145 * Last updated to the page with the following versions:
146 * Version 3.6; ICU version: 50.0.1.0; Unicode version: 6.1.0.0
147 *
148 * 4,167 Code Points
149 *
150 * [\u00AD\u034F\u115F\u1160\u17B4\u17B5\u180B-\u180D\u200B-\u200F\u202A-\u202E\u2060-\u206F\u3164\uFE00-\uFE0F\uFEFF\uFFA0\uFFF0-\uFFF8\U0001D173-\U0001D17A\U000E0000-\U000E0FFF]
151 *
152 * 00AD ;SOFT HYPHEN
153 * 034F ;COMBINING GRAPHEME JOINER
154 * #115F ;HANGUL CHOSEONG FILLER
155 * #1160 ;HANGUL JUNGSEONG FILLER
156 * 17B4 ;KHMER VOWEL INHERENT AQ
157 * 17B5 ;KHMER VOWEL INHERENT AA
158 * 180B..180D ;MONGOLIAN FREE VARIATION SELECTOR THREE
159 * 200B..200F ;RIGHT-TO-LEFT MARK
160 * 202A..202E ;RIGHT-TO-LEFT OVERRIDE
161 * 2060..206F ;NOMINAL DIGIT SHAPES
162 * #3164 ;HANGUL FILLER
163 * FE00..FE0F ;VARIATION SELECTOR-16
164 * FEFF ;ZERO WIDTH NO-BREAK SPACE
165 * #FFA0 ;HALFWIDTH HANGUL FILLER
166 * FFF0..FFF8 ;<unassigned-FFF8>
167 * 1D173..1D17A ;MUSICAL SYMBOL END PHRASE
168 * E0000..E0FFF ;<unassigned-E0FFF>
169 */
170 inline hb_bool_t
171 is_default_ignorable (hb_codepoint_t ch)
172 {
173 hb_codepoint_t plane = ch >> 16;
174 if (likely (plane == 0))
175 {
176 /* BMP */
177 hb_codepoint_t page = ch >> 8;
178 switch (page) {
179 case 0x00: return unlikely (ch == 0x00AD);
180 case 0x03: return unlikely (ch == 0x034F);
181 case 0x06: return unlikely (ch == 0x061C);
182 case 0x17: return hb_in_range<hb_codepoint_t> (ch, 0x17B4, 0x17B5);
183 case 0x18: return hb_in_range<hb_codepoint_t> (ch, 0x180B, 0x180E);
184 case 0x20: return hb_in_ranges<hb_codepoint_t> (ch, 0x200B, 0x200F,
185 0x202A, 0x202E,
186 0x2060, 0x206F);
187 case 0xFE: return hb_in_range<hb_codepoint_t> (ch, 0xFE00, 0xFE0F) || ch == 0xFEFF;
188 case 0xFF: return hb_in_range<hb_codepoint_t> (ch, 0xFFF0, 0xFFF8);
189 default: return false;
190 }
191 }
192 else
193 {
194 /* Other planes */
195 switch (plane) {
196 case 0x01: return hb_in_range<hb_codepoint_t> (ch, 0x0001D173, 0x0001D17A);
197 case 0x0E: return hb_in_range<hb_codepoint_t> (ch, 0x000E0000, 0x000E0FFF);
198 default: return false;
199 }
200 }
201 }
204 struct {
205 #define HB_UNICODE_FUNC_IMPLEMENT(name) hb_unicode_##name##_func_t name;
206 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
207 #undef HB_UNICODE_FUNC_IMPLEMENT
208 } func;
210 struct {
211 #define HB_UNICODE_FUNC_IMPLEMENT(name) void *name;
212 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
213 #undef HB_UNICODE_FUNC_IMPLEMENT
214 } user_data;
216 struct {
217 #define HB_UNICODE_FUNC_IMPLEMENT(name) hb_destroy_func_t name;
218 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
219 #undef HB_UNICODE_FUNC_IMPLEMENT
220 } destroy;
221 };
224 extern HB_INTERNAL const hb_unicode_funcs_t _hb_unicode_funcs_nil;
227 /* Modified combining marks */
229 /* Hebrew
230 *
231 * We permute the "fixed-position" classes 10-26 into the order
232 * described in the SBL Hebrew manual:
233 *
234 * http://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf
235 *
236 * (as recommended by:
237 * http://forum.fontlab.com/archive-old-microsoft-volt-group/vista-and-diacritic-ordering-t6751.0.html)
238 *
239 * More details here:
240 * https://bugzilla.mozilla.org/show_bug.cgi?id=662055
241 */
242 #define HB_MODIFIED_COMBINING_CLASS_CCC10 22 /* sheva */
243 #define HB_MODIFIED_COMBINING_CLASS_CCC11 15 /* hataf segol */
244 #define HB_MODIFIED_COMBINING_CLASS_CCC12 16 /* hataf patah */
245 #define HB_MODIFIED_COMBINING_CLASS_CCC13 17 /* hataf qamats */
246 #define HB_MODIFIED_COMBINING_CLASS_CCC14 23 /* hiriq */
247 #define HB_MODIFIED_COMBINING_CLASS_CCC15 18 /* tsere */
248 #define HB_MODIFIED_COMBINING_CLASS_CCC16 19 /* segol */
249 #define HB_MODIFIED_COMBINING_CLASS_CCC17 20 /* patah */
250 #define HB_MODIFIED_COMBINING_CLASS_CCC18 21 /* qamats */
251 #define HB_MODIFIED_COMBINING_CLASS_CCC19 14 /* holam */
252 #define HB_MODIFIED_COMBINING_CLASS_CCC20 24 /* qubuts */
253 #define HB_MODIFIED_COMBINING_CLASS_CCC21 12 /* dagesh */
254 #define HB_MODIFIED_COMBINING_CLASS_CCC22 25 /* meteg */
255 #define HB_MODIFIED_COMBINING_CLASS_CCC23 13 /* rafe */
256 #define HB_MODIFIED_COMBINING_CLASS_CCC24 10 /* shin dot */
257 #define HB_MODIFIED_COMBINING_CLASS_CCC25 11 /* sin dot */
258 #define HB_MODIFIED_COMBINING_CLASS_CCC26 26 /* point varika */
260 /*
261 * Arabic
262 *
263 * Modify to move Shadda (ccc=33) before other marks. See:
264 * http://unicode.org/faq/normalization.html#8
265 * http://unicode.org/faq/normalization.html#9
266 */
267 #define HB_MODIFIED_COMBINING_CLASS_CCC27 28 /* fathatan */
268 #define HB_MODIFIED_COMBINING_CLASS_CCC28 29 /* dammatan */
269 #define HB_MODIFIED_COMBINING_CLASS_CCC29 30 /* kasratan */
270 #define HB_MODIFIED_COMBINING_CLASS_CCC30 31 /* fatha */
271 #define HB_MODIFIED_COMBINING_CLASS_CCC31 32 /* damma */
272 #define HB_MODIFIED_COMBINING_CLASS_CCC32 33 /* kasra */
273 #define HB_MODIFIED_COMBINING_CLASS_CCC33 27 /* shadda */
274 #define HB_MODIFIED_COMBINING_CLASS_CCC34 34 /* sukun */
275 #define HB_MODIFIED_COMBINING_CLASS_CCC35 35 /* superscript alef */
277 /* Syriac */
278 #define HB_MODIFIED_COMBINING_CLASS_CCC36 36 /* superscript alaph */
280 /* Telugu
281 *
282 * Modify Telugu length marks (ccc=84, ccc=91).
283 * These are the only matras in the main Indic scripts range that have
284 * a non-zero ccc. That makes them reorder with the Halant that is
285 * ccc=9. Just zero them, we don't need them in our Indic shaper.
286 */
287 #define HB_MODIFIED_COMBINING_CLASS_CCC84 0 /* length mark */
288 #define HB_MODIFIED_COMBINING_CLASS_CCC91 0 /* ai length mark */
290 /* Thai
291 *
292 * Modify U+0E38 and U+0E39 (ccc=103) to be reordered before U+0E3A (ccc=9).
293 * Assign 3, which is unassigned otherwise.
294 * Uniscribe does this reordering too.
295 */
296 #define HB_MODIFIED_COMBINING_CLASS_CCC103 3 /* sara u / sara uu */
297 #define HB_MODIFIED_COMBINING_CLASS_CCC107 107 /* mai * */
299 /* Lao */
300 #define HB_MODIFIED_COMBINING_CLASS_CCC118 118 /* sign u / sign uu */
301 #define HB_MODIFIED_COMBINING_CLASS_CCC122 122 /* mai * */
303 /* Tibetan */
304 #define HB_MODIFIED_COMBINING_CLASS_CCC129 129 /* sign aa */
305 #define HB_MODIFIED_COMBINING_CLASS_CCC130 130 /* sign i */
306 #define HB_MODIFIED_COMBINING_CLASS_CCC132 132 /* sign u */
309 /* Misc */
311 #define HB_UNICODE_GENERAL_CATEGORY_IS_MARK(gen_cat) \
312 (FLAG (gen_cat) & \
313 (FLAG (HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK) | \
314 FLAG (HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK) | \
315 FLAG (HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)))
318 #endif /* HB_UNICODE_PRIVATE_HH */