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 | /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "assert.h" |
michael@0 | 7 | #include "ANPBase.h" |
michael@0 | 8 | #include <android/log.h> |
michael@0 | 9 | |
michael@0 | 10 | #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) |
michael@0 | 11 | #define ASSIGN(obj, name) (obj)->name = anp_bitmap_##name |
michael@0 | 12 | |
michael@0 | 13 | |
michael@0 | 14 | #define SK_A32_BITS 8 |
michael@0 | 15 | #define SK_R32_BITS 8 |
michael@0 | 16 | #define SK_G32_BITS 8 |
michael@0 | 17 | #define SK_B32_BITS 8 |
michael@0 | 18 | |
michael@0 | 19 | #ifdef IS_BIG_ENDIAN |
michael@0 | 20 | #define SK_R32_SHIFT 24 |
michael@0 | 21 | #define SK_G32_SHIFT 16 |
michael@0 | 22 | #define SK_B32_SHIFT 8 |
michael@0 | 23 | #define SK_A32_SHIFT 0 |
michael@0 | 24 | #else |
michael@0 | 25 | #define SK_R32_SHIFT 0 |
michael@0 | 26 | #define SK_G32_SHIFT 8 |
michael@0 | 27 | #define SK_B32_SHIFT 16 |
michael@0 | 28 | #define SK_A32_SHIFT 24 |
michael@0 | 29 | #endif |
michael@0 | 30 | |
michael@0 | 31 | #define SK_A32_MASK ((1 << SK_A32_BITS) - 1) |
michael@0 | 32 | #define SK_R32_MASK ((1 << SK_R32_BITS) - 1) |
michael@0 | 33 | #define SK_G32_MASK ((1 << SK_G32_BITS) - 1) |
michael@0 | 34 | #define SK_B32_MASK ((1 << SK_B32_BITS) - 1) |
michael@0 | 35 | |
michael@0 | 36 | #define SK_R16_BITS 5 |
michael@0 | 37 | #define SK_G16_BITS 6 |
michael@0 | 38 | #define SK_B16_BITS 5 |
michael@0 | 39 | |
michael@0 | 40 | #define SK_R16_SHIFT (SK_B16_BITS + SK_G16_BITS) |
michael@0 | 41 | #define SK_G16_SHIFT (SK_B16_BITS) |
michael@0 | 42 | #define SK_B16_SHIFT 0 |
michael@0 | 43 | |
michael@0 | 44 | #define SK_R16_MASK ((1 << SK_R16_BITS) - 1) |
michael@0 | 45 | #define SK_G16_MASK ((1 << SK_G16_BITS) - 1) |
michael@0 | 46 | #define SK_B16_MASK ((1 << SK_B16_BITS) - 1) |
michael@0 | 47 | |
michael@0 | 48 | bool |
michael@0 | 49 | anp_bitmap_getPixelPacking(ANPBitmapFormat fmt, ANPPixelPacking* packing) { |
michael@0 | 50 | LOG("%s", __PRETTY_FUNCTION__); |
michael@0 | 51 | switch (fmt) { |
michael@0 | 52 | case kRGBA_8888_ANPBitmapFormat: |
michael@0 | 53 | if (packing) { |
michael@0 | 54 | packing->AShift = SK_A32_SHIFT; |
michael@0 | 55 | packing->ABits = SK_A32_BITS; |
michael@0 | 56 | packing->RShift = SK_R32_SHIFT; |
michael@0 | 57 | packing->RBits = SK_R32_BITS; |
michael@0 | 58 | packing->GShift = SK_G32_SHIFT; |
michael@0 | 59 | packing->GBits = SK_G32_BITS; |
michael@0 | 60 | packing->BShift = SK_B32_SHIFT; |
michael@0 | 61 | packing->BBits = SK_B32_BITS; |
michael@0 | 62 | } |
michael@0 | 63 | return true; |
michael@0 | 64 | case kRGB_565_ANPBitmapFormat: |
michael@0 | 65 | if (packing) { |
michael@0 | 66 | packing->AShift = 0; |
michael@0 | 67 | packing->ABits = 0; |
michael@0 | 68 | packing->RShift = SK_R16_SHIFT; |
michael@0 | 69 | packing->RBits = SK_R16_BITS; |
michael@0 | 70 | packing->GShift = SK_G16_SHIFT; |
michael@0 | 71 | packing->GBits = SK_G16_BITS; |
michael@0 | 72 | packing->BShift = SK_B16_SHIFT; |
michael@0 | 73 | packing->BBits = SK_B16_BITS; |
michael@0 | 74 | } |
michael@0 | 75 | return true; |
michael@0 | 76 | default: |
michael@0 | 77 | break; |
michael@0 | 78 | } |
michael@0 | 79 | return false; |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | void InitBitmapInterface(ANPBitmapInterfaceV0 *i) { |
michael@0 | 83 | _assert(i->inSize == sizeof(*i)); |
michael@0 | 84 | ASSIGN(i, getPixelPacking); |
michael@0 | 85 | } |