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 © 1998-2004 David Turner and Werner Lemberg |
michael@0 | 3 | * Copyright © 2004,2007,2009 Red Hat, Inc. |
michael@0 | 4 | * Copyright © 2011,2012 Google, Inc. |
michael@0 | 5 | * |
michael@0 | 6 | * This is part of HarfBuzz, a text shaping library. |
michael@0 | 7 | * |
michael@0 | 8 | * Permission is hereby granted, without written agreement and without |
michael@0 | 9 | * license or royalty fees, to use, copy, modify, and distribute this |
michael@0 | 10 | * software and its documentation for any purpose, provided that the |
michael@0 | 11 | * above copyright notice and the following two paragraphs appear in |
michael@0 | 12 | * all copies of this software. |
michael@0 | 13 | * |
michael@0 | 14 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
michael@0 | 15 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
michael@0 | 16 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
michael@0 | 17 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
michael@0 | 18 | * DAMAGE. |
michael@0 | 19 | * |
michael@0 | 20 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
michael@0 | 21 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
michael@0 | 22 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
michael@0 | 23 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
michael@0 | 24 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
michael@0 | 25 | * |
michael@0 | 26 | * Red Hat Author(s): Owen Taylor, Behdad Esfahbod |
michael@0 | 27 | * Google Author(s): Behdad Esfahbod |
michael@0 | 28 | */ |
michael@0 | 29 | |
michael@0 | 30 | #ifndef HB_H_IN |
michael@0 | 31 | #error "Include <hb.h> instead." |
michael@0 | 32 | #endif |
michael@0 | 33 | |
michael@0 | 34 | #ifndef HB_BUFFER_H |
michael@0 | 35 | #define HB_BUFFER_H |
michael@0 | 36 | |
michael@0 | 37 | #include "hb-common.h" |
michael@0 | 38 | #include "hb-unicode.h" |
michael@0 | 39 | #include "hb-font.h" |
michael@0 | 40 | |
michael@0 | 41 | HB_BEGIN_DECLS |
michael@0 | 42 | |
michael@0 | 43 | |
michael@0 | 44 | typedef struct hb_glyph_info_t { |
michael@0 | 45 | hb_codepoint_t codepoint; |
michael@0 | 46 | hb_mask_t mask; |
michael@0 | 47 | uint32_t cluster; |
michael@0 | 48 | |
michael@0 | 49 | /*< private >*/ |
michael@0 | 50 | hb_var_int_t var1; |
michael@0 | 51 | hb_var_int_t var2; |
michael@0 | 52 | } hb_glyph_info_t; |
michael@0 | 53 | |
michael@0 | 54 | typedef struct hb_glyph_position_t { |
michael@0 | 55 | hb_position_t x_advance; |
michael@0 | 56 | hb_position_t y_advance; |
michael@0 | 57 | hb_position_t x_offset; |
michael@0 | 58 | hb_position_t y_offset; |
michael@0 | 59 | |
michael@0 | 60 | /*< private >*/ |
michael@0 | 61 | hb_var_int_t var; |
michael@0 | 62 | } hb_glyph_position_t; |
michael@0 | 63 | |
michael@0 | 64 | |
michael@0 | 65 | typedef struct hb_segment_properties_t { |
michael@0 | 66 | hb_direction_t direction; |
michael@0 | 67 | hb_script_t script; |
michael@0 | 68 | hb_language_t language; |
michael@0 | 69 | /*< private >*/ |
michael@0 | 70 | void *reserved1; |
michael@0 | 71 | void *reserved2; |
michael@0 | 72 | } hb_segment_properties_t; |
michael@0 | 73 | |
michael@0 | 74 | #define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \ |
michael@0 | 75 | HB_SCRIPT_INVALID, \ |
michael@0 | 76 | HB_LANGUAGE_INVALID, \ |
michael@0 | 77 | NULL, \ |
michael@0 | 78 | NULL} |
michael@0 | 79 | |
michael@0 | 80 | hb_bool_t |
michael@0 | 81 | hb_segment_properties_equal (const hb_segment_properties_t *a, |
michael@0 | 82 | const hb_segment_properties_t *b); |
michael@0 | 83 | |
michael@0 | 84 | unsigned int |
michael@0 | 85 | hb_segment_properties_hash (const hb_segment_properties_t *p); |
michael@0 | 86 | |
michael@0 | 87 | |
michael@0 | 88 | |
michael@0 | 89 | /* |
michael@0 | 90 | * hb_buffer_t |
michael@0 | 91 | */ |
michael@0 | 92 | |
michael@0 | 93 | typedef struct hb_buffer_t hb_buffer_t; |
michael@0 | 94 | |
michael@0 | 95 | hb_buffer_t * |
michael@0 | 96 | hb_buffer_create (void); |
michael@0 | 97 | |
michael@0 | 98 | hb_buffer_t * |
michael@0 | 99 | hb_buffer_get_empty (void); |
michael@0 | 100 | |
michael@0 | 101 | hb_buffer_t * |
michael@0 | 102 | hb_buffer_reference (hb_buffer_t *buffer); |
michael@0 | 103 | |
michael@0 | 104 | void |
michael@0 | 105 | hb_buffer_destroy (hb_buffer_t *buffer); |
michael@0 | 106 | |
michael@0 | 107 | hb_bool_t |
michael@0 | 108 | hb_buffer_set_user_data (hb_buffer_t *buffer, |
michael@0 | 109 | hb_user_data_key_t *key, |
michael@0 | 110 | void * data, |
michael@0 | 111 | hb_destroy_func_t destroy, |
michael@0 | 112 | hb_bool_t replace); |
michael@0 | 113 | |
michael@0 | 114 | void * |
michael@0 | 115 | hb_buffer_get_user_data (hb_buffer_t *buffer, |
michael@0 | 116 | hb_user_data_key_t *key); |
michael@0 | 117 | |
michael@0 | 118 | |
michael@0 | 119 | typedef enum { |
michael@0 | 120 | HB_BUFFER_CONTENT_TYPE_INVALID = 0, |
michael@0 | 121 | HB_BUFFER_CONTENT_TYPE_UNICODE, |
michael@0 | 122 | HB_BUFFER_CONTENT_TYPE_GLYPHS |
michael@0 | 123 | } hb_buffer_content_type_t; |
michael@0 | 124 | |
michael@0 | 125 | void |
michael@0 | 126 | hb_buffer_set_content_type (hb_buffer_t *buffer, |
michael@0 | 127 | hb_buffer_content_type_t content_type); |
michael@0 | 128 | |
michael@0 | 129 | hb_buffer_content_type_t |
michael@0 | 130 | hb_buffer_get_content_type (hb_buffer_t *buffer); |
michael@0 | 131 | |
michael@0 | 132 | |
michael@0 | 133 | void |
michael@0 | 134 | hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, |
michael@0 | 135 | hb_unicode_funcs_t *unicode_funcs); |
michael@0 | 136 | |
michael@0 | 137 | hb_unicode_funcs_t * |
michael@0 | 138 | hb_buffer_get_unicode_funcs (hb_buffer_t *buffer); |
michael@0 | 139 | |
michael@0 | 140 | void |
michael@0 | 141 | hb_buffer_set_direction (hb_buffer_t *buffer, |
michael@0 | 142 | hb_direction_t direction); |
michael@0 | 143 | |
michael@0 | 144 | hb_direction_t |
michael@0 | 145 | hb_buffer_get_direction (hb_buffer_t *buffer); |
michael@0 | 146 | |
michael@0 | 147 | void |
michael@0 | 148 | hb_buffer_set_script (hb_buffer_t *buffer, |
michael@0 | 149 | hb_script_t script); |
michael@0 | 150 | |
michael@0 | 151 | hb_script_t |
michael@0 | 152 | hb_buffer_get_script (hb_buffer_t *buffer); |
michael@0 | 153 | |
michael@0 | 154 | void |
michael@0 | 155 | hb_buffer_set_language (hb_buffer_t *buffer, |
michael@0 | 156 | hb_language_t language); |
michael@0 | 157 | |
michael@0 | 158 | |
michael@0 | 159 | hb_language_t |
michael@0 | 160 | hb_buffer_get_language (hb_buffer_t *buffer); |
michael@0 | 161 | |
michael@0 | 162 | void |
michael@0 | 163 | hb_buffer_set_segment_properties (hb_buffer_t *buffer, |
michael@0 | 164 | const hb_segment_properties_t *props); |
michael@0 | 165 | |
michael@0 | 166 | void |
michael@0 | 167 | hb_buffer_get_segment_properties (hb_buffer_t *buffer, |
michael@0 | 168 | hb_segment_properties_t *props); |
michael@0 | 169 | |
michael@0 | 170 | void |
michael@0 | 171 | hb_buffer_guess_segment_properties (hb_buffer_t *buffer); |
michael@0 | 172 | |
michael@0 | 173 | |
michael@0 | 174 | typedef enum { /*< flags >*/ |
michael@0 | 175 | HB_BUFFER_FLAG_DEFAULT = 0x00000000u, |
michael@0 | 176 | HB_BUFFER_FLAG_BOT = 0x00000001u, /* Beginning-of-text */ |
michael@0 | 177 | HB_BUFFER_FLAG_EOT = 0x00000002u, /* End-of-text */ |
michael@0 | 178 | HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u |
michael@0 | 179 | } hb_buffer_flags_t; |
michael@0 | 180 | |
michael@0 | 181 | void |
michael@0 | 182 | hb_buffer_set_flags (hb_buffer_t *buffer, |
michael@0 | 183 | hb_buffer_flags_t flags); |
michael@0 | 184 | |
michael@0 | 185 | hb_buffer_flags_t |
michael@0 | 186 | hb_buffer_get_flags (hb_buffer_t *buffer); |
michael@0 | 187 | |
michael@0 | 188 | |
michael@0 | 189 | /* Resets the buffer. Afterwards it's as if it was just created, |
michael@0 | 190 | * except that it has a larger buffer allocated perhaps... */ |
michael@0 | 191 | void |
michael@0 | 192 | hb_buffer_reset (hb_buffer_t *buffer); |
michael@0 | 193 | |
michael@0 | 194 | /* Like reset, but does NOT clear unicode_funcs. */ |
michael@0 | 195 | void |
michael@0 | 196 | hb_buffer_clear_contents (hb_buffer_t *buffer); |
michael@0 | 197 | |
michael@0 | 198 | /* Returns false if allocation failed */ |
michael@0 | 199 | hb_bool_t |
michael@0 | 200 | hb_buffer_pre_allocate (hb_buffer_t *buffer, |
michael@0 | 201 | unsigned int size); |
michael@0 | 202 | |
michael@0 | 203 | |
michael@0 | 204 | /* Returns false if allocation has failed before */ |
michael@0 | 205 | hb_bool_t |
michael@0 | 206 | hb_buffer_allocation_successful (hb_buffer_t *buffer); |
michael@0 | 207 | |
michael@0 | 208 | void |
michael@0 | 209 | hb_buffer_reverse (hb_buffer_t *buffer); |
michael@0 | 210 | |
michael@0 | 211 | void |
michael@0 | 212 | hb_buffer_reverse_clusters (hb_buffer_t *buffer); |
michael@0 | 213 | |
michael@0 | 214 | |
michael@0 | 215 | /* Filling the buffer in */ |
michael@0 | 216 | |
michael@0 | 217 | void |
michael@0 | 218 | hb_buffer_add (hb_buffer_t *buffer, |
michael@0 | 219 | hb_codepoint_t codepoint, |
michael@0 | 220 | unsigned int cluster); |
michael@0 | 221 | |
michael@0 | 222 | void |
michael@0 | 223 | hb_buffer_add_utf8 (hb_buffer_t *buffer, |
michael@0 | 224 | const char *text, |
michael@0 | 225 | int text_length, |
michael@0 | 226 | unsigned int item_offset, |
michael@0 | 227 | int item_length); |
michael@0 | 228 | |
michael@0 | 229 | void |
michael@0 | 230 | hb_buffer_add_utf16 (hb_buffer_t *buffer, |
michael@0 | 231 | const uint16_t *text, |
michael@0 | 232 | int text_length, |
michael@0 | 233 | unsigned int item_offset, |
michael@0 | 234 | int item_length); |
michael@0 | 235 | |
michael@0 | 236 | void |
michael@0 | 237 | hb_buffer_add_utf32 (hb_buffer_t *buffer, |
michael@0 | 238 | const uint32_t *text, |
michael@0 | 239 | int text_length, |
michael@0 | 240 | unsigned int item_offset, |
michael@0 | 241 | int item_length); |
michael@0 | 242 | |
michael@0 | 243 | |
michael@0 | 244 | /* Clears any new items added at the end */ |
michael@0 | 245 | hb_bool_t |
michael@0 | 246 | hb_buffer_set_length (hb_buffer_t *buffer, |
michael@0 | 247 | unsigned int length); |
michael@0 | 248 | |
michael@0 | 249 | /* Return value valid as long as buffer not modified */ |
michael@0 | 250 | unsigned int |
michael@0 | 251 | hb_buffer_get_length (hb_buffer_t *buffer); |
michael@0 | 252 | |
michael@0 | 253 | /* Getting glyphs out of the buffer */ |
michael@0 | 254 | |
michael@0 | 255 | /* Return value valid as long as buffer not modified */ |
michael@0 | 256 | hb_glyph_info_t * |
michael@0 | 257 | hb_buffer_get_glyph_infos (hb_buffer_t *buffer, |
michael@0 | 258 | unsigned int *length); |
michael@0 | 259 | |
michael@0 | 260 | /* Return value valid as long as buffer not modified */ |
michael@0 | 261 | hb_glyph_position_t * |
michael@0 | 262 | hb_buffer_get_glyph_positions (hb_buffer_t *buffer, |
michael@0 | 263 | unsigned int *length); |
michael@0 | 264 | |
michael@0 | 265 | |
michael@0 | 266 | /* Reorders a glyph buffer to have canonical in-cluster glyph order / position. |
michael@0 | 267 | * The resulting clusters should behave identical to pre-reordering clusters. |
michael@0 | 268 | * NOTE: This has nothing to do with Unicode normalization. */ |
michael@0 | 269 | void |
michael@0 | 270 | hb_buffer_normalize_glyphs (hb_buffer_t *buffer); |
michael@0 | 271 | |
michael@0 | 272 | |
michael@0 | 273 | /* |
michael@0 | 274 | * Serialize |
michael@0 | 275 | */ |
michael@0 | 276 | |
michael@0 | 277 | typedef enum { /*< flags >*/ |
michael@0 | 278 | HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u, |
michael@0 | 279 | HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u, |
michael@0 | 280 | HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u, |
michael@0 | 281 | HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u |
michael@0 | 282 | } hb_buffer_serialize_flags_t; |
michael@0 | 283 | |
michael@0 | 284 | typedef enum { |
michael@0 | 285 | HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'), |
michael@0 | 286 | HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'), |
michael@0 | 287 | HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE |
michael@0 | 288 | } hb_buffer_serialize_format_t; |
michael@0 | 289 | |
michael@0 | 290 | /* len=-1 means str is NUL-terminated. */ |
michael@0 | 291 | hb_buffer_serialize_format_t |
michael@0 | 292 | hb_buffer_serialize_format_from_string (const char *str, int len); |
michael@0 | 293 | |
michael@0 | 294 | const char * |
michael@0 | 295 | hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format); |
michael@0 | 296 | |
michael@0 | 297 | const char ** |
michael@0 | 298 | hb_buffer_serialize_list_formats (void); |
michael@0 | 299 | |
michael@0 | 300 | /* Returns number of items, starting at start, that were serialized. */ |
michael@0 | 301 | unsigned int |
michael@0 | 302 | hb_buffer_serialize_glyphs (hb_buffer_t *buffer, |
michael@0 | 303 | unsigned int start, |
michael@0 | 304 | unsigned int end, |
michael@0 | 305 | char *buf, |
michael@0 | 306 | unsigned int buf_size, |
michael@0 | 307 | unsigned int *buf_consumed, /* May be NULL */ |
michael@0 | 308 | hb_font_t *font, /* May be NULL */ |
michael@0 | 309 | hb_buffer_serialize_format_t format, |
michael@0 | 310 | hb_buffer_serialize_flags_t flags); |
michael@0 | 311 | |
michael@0 | 312 | hb_bool_t |
michael@0 | 313 | hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, |
michael@0 | 314 | const char *buf, |
michael@0 | 315 | int buf_len, /* -1 means nul-terminated */ |
michael@0 | 316 | const char **end_ptr, /* May be NULL */ |
michael@0 | 317 | hb_font_t *font, /* May be NULL */ |
michael@0 | 318 | hb_buffer_serialize_format_t format); |
michael@0 | 319 | |
michael@0 | 320 | |
michael@0 | 321 | HB_END_DECLS |
michael@0 | 322 | |
michael@0 | 323 | #endif /* HB_BUFFER_H */ |