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.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright © 2011,2012 Google, Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * This is part of HarfBuzz, a text shaping library. |
michael@0 | 5 | * |
michael@0 | 6 | * Permission is hereby granted, without written agreement and without |
michael@0 | 7 | * license or royalty fees, to use, copy, modify, and distribute this |
michael@0 | 8 | * software and its documentation for any purpose, provided that the |
michael@0 | 9 | * above copyright notice and the following two paragraphs appear in |
michael@0 | 10 | * all copies of this software. |
michael@0 | 11 | * |
michael@0 | 12 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
michael@0 | 13 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
michael@0 | 14 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
michael@0 | 15 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
michael@0 | 16 | * DAMAGE. |
michael@0 | 17 | * |
michael@0 | 18 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
michael@0 | 19 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
michael@0 | 20 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
michael@0 | 21 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
michael@0 | 22 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
michael@0 | 23 | * |
michael@0 | 24 | * Google Author(s): Behdad Esfahbod |
michael@0 | 25 | */ |
michael@0 | 26 | |
michael@0 | 27 | #ifndef HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH |
michael@0 | 28 | #define HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH |
michael@0 | 29 | |
michael@0 | 30 | #include "hb-private.hh" |
michael@0 | 31 | |
michael@0 | 32 | %%{ |
michael@0 | 33 | machine indic_syllable_machine; |
michael@0 | 34 | alphtype unsigned char; |
michael@0 | 35 | write data; |
michael@0 | 36 | }%% |
michael@0 | 37 | |
michael@0 | 38 | %%{ |
michael@0 | 39 | |
michael@0 | 40 | # Same order as enum indic_category_t. Not sure how to avoid duplication. |
michael@0 | 41 | X = 0; |
michael@0 | 42 | C = 1; |
michael@0 | 43 | V = 2; |
michael@0 | 44 | N = 3; |
michael@0 | 45 | H = 4; |
michael@0 | 46 | ZWNJ = 5; |
michael@0 | 47 | ZWJ = 6; |
michael@0 | 48 | M = 7; |
michael@0 | 49 | SM = 8; |
michael@0 | 50 | VD = 9; |
michael@0 | 51 | A = 10; |
michael@0 | 52 | NBSP = 11; |
michael@0 | 53 | DOTTEDCIRCLE = 12; |
michael@0 | 54 | RS = 13; |
michael@0 | 55 | Coeng = 14; |
michael@0 | 56 | Repha = 15; |
michael@0 | 57 | Ra = 16; |
michael@0 | 58 | CM = 17; |
michael@0 | 59 | Avag = 18; |
michael@0 | 60 | CM2 = 31; |
michael@0 | 61 | |
michael@0 | 62 | c = (C | Ra); # is_consonant |
michael@0 | 63 | n = ((ZWNJ?.RS)? (N.N?)?); # is_consonant_modifier |
michael@0 | 64 | z = ZWJ|ZWNJ; # is_joiner |
michael@0 | 65 | h = H | Coeng; # is_halant_or_coeng |
michael@0 | 66 | reph = (Ra H | Repha); # possible reph |
michael@0 | 67 | |
michael@0 | 68 | cn = c.ZWJ?.n?; |
michael@0 | 69 | forced_rakar = ZWJ H ZWJ Ra; |
michael@0 | 70 | avagraha = Avag.N?; |
michael@0 | 71 | matra_group = z{0,3}.M.N?.(H | forced_rakar)?; |
michael@0 | 72 | syllable_tail2 = (SM.SM?.ZWNJ?)? (A.A?)? VD?; |
michael@0 | 73 | syllable_tail = (Coeng (cn|V))? avagraha? syllable_tail2; |
michael@0 | 74 | place_holder = NBSP | DOTTEDCIRCLE; |
michael@0 | 75 | halant_group = (z?.h.(ZWJ.N?)?); |
michael@0 | 76 | final_halant_group = halant_group | h.ZWNJ; |
michael@0 | 77 | medial_group = CM?.CM2?; |
michael@0 | 78 | halant_or_matra_group = (final_halant_group | (h.ZWJ)? matra_group{0,4}); |
michael@0 | 79 | |
michael@0 | 80 | |
michael@0 | 81 | consonant_syllable = Repha? (cn.halant_group){0,4} cn medial_group halant_or_matra_group syllable_tail; |
michael@0 | 82 | vowel_syllable = reph? V.n? (ZWJ | (halant_group.cn){0,4} medial_group halant_or_matra_group syllable_tail); |
michael@0 | 83 | standalone_cluster = reph? place_holder.n? (halant_group.cn){0,4} medial_group halant_or_matra_group syllable_tail; |
michael@0 | 84 | avagraha_cluster = avagraha syllable_tail2; |
michael@0 | 85 | broken_cluster = reph? n? (halant_group.cn){0,4} medial_group halant_or_matra_group syllable_tail; |
michael@0 | 86 | other = any; |
michael@0 | 87 | |
michael@0 | 88 | main := |* |
michael@0 | 89 | consonant_syllable => { found_syllable (consonant_syllable); }; |
michael@0 | 90 | vowel_syllable => { found_syllable (vowel_syllable); }; |
michael@0 | 91 | standalone_cluster => { found_syllable (standalone_cluster); }; |
michael@0 | 92 | avagraha_cluster => { found_syllable (avagraha_cluster); }; |
michael@0 | 93 | broken_cluster => { found_syllable (broken_cluster); }; |
michael@0 | 94 | other => { found_syllable (non_indic_cluster); }; |
michael@0 | 95 | *|; |
michael@0 | 96 | |
michael@0 | 97 | |
michael@0 | 98 | }%% |
michael@0 | 99 | |
michael@0 | 100 | #define found_syllable(syllable_type) \ |
michael@0 | 101 | HB_STMT_START { \ |
michael@0 | 102 | if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \ |
michael@0 | 103 | for (unsigned int i = last; i < p+1; i++) \ |
michael@0 | 104 | info[i].syllable() = (syllable_serial << 4) | syllable_type; \ |
michael@0 | 105 | last = p+1; \ |
michael@0 | 106 | syllable_serial++; \ |
michael@0 | 107 | if (unlikely (syllable_serial == 16)) syllable_serial = 1; \ |
michael@0 | 108 | } HB_STMT_END |
michael@0 | 109 | |
michael@0 | 110 | static void |
michael@0 | 111 | find_syllables (hb_buffer_t *buffer) |
michael@0 | 112 | { |
michael@0 | 113 | unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED; |
michael@0 | 114 | int cs; |
michael@0 | 115 | hb_glyph_info_t *info = buffer->info; |
michael@0 | 116 | %%{ |
michael@0 | 117 | write init; |
michael@0 | 118 | getkey info[p].indic_category(); |
michael@0 | 119 | }%% |
michael@0 | 120 | |
michael@0 | 121 | p = 0; |
michael@0 | 122 | pe = eof = buffer->len; |
michael@0 | 123 | |
michael@0 | 124 | unsigned int last = 0; |
michael@0 | 125 | unsigned int syllable_serial = 1; |
michael@0 | 126 | %%{ |
michael@0 | 127 | write exec; |
michael@0 | 128 | }%% |
michael@0 | 129 | } |
michael@0 | 130 | |
michael@0 | 131 | #endif /* HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH */ |