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 | /* |
michael@0 | 3 | * Copyright 2006 The Android Open Source Project |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #include "SkAntiRun.h" |
michael@0 | 11 | #include "SkUtils.h" |
michael@0 | 12 | |
michael@0 | 13 | void SkAlphaRuns::reset(int width) { |
michael@0 | 14 | SkASSERT(width > 0); |
michael@0 | 15 | |
michael@0 | 16 | #ifdef SK_DEBUG |
michael@0 | 17 | sk_memset16((uint16_t*)fRuns, (uint16_t)(-42), width); |
michael@0 | 18 | #endif |
michael@0 | 19 | fRuns[0] = SkToS16(width); |
michael@0 | 20 | fRuns[width] = 0; |
michael@0 | 21 | fAlpha[0] = 0; |
michael@0 | 22 | |
michael@0 | 23 | SkDEBUGCODE(fWidth = width;) |
michael@0 | 24 | SkDEBUGCODE(this->validate();) |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | #ifdef SK_DEBUG |
michael@0 | 28 | void SkAlphaRuns::assertValid(int y, int maxStep) const { |
michael@0 | 29 | int max = (y + 1) * maxStep - (y == maxStep - 1); |
michael@0 | 30 | |
michael@0 | 31 | const int16_t* runs = fRuns; |
michael@0 | 32 | const uint8_t* alpha = fAlpha; |
michael@0 | 33 | |
michael@0 | 34 | while (*runs) { |
michael@0 | 35 | SkASSERT(*alpha <= max); |
michael@0 | 36 | alpha += *runs; |
michael@0 | 37 | runs += *runs; |
michael@0 | 38 | } |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | void SkAlphaRuns::dump() const { |
michael@0 | 42 | const int16_t* runs = fRuns; |
michael@0 | 43 | const uint8_t* alpha = fAlpha; |
michael@0 | 44 | |
michael@0 | 45 | SkDebugf("Runs"); |
michael@0 | 46 | while (*runs) { |
michael@0 | 47 | int n = *runs; |
michael@0 | 48 | |
michael@0 | 49 | SkDebugf(" %02x", *alpha); |
michael@0 | 50 | if (n > 1) { |
michael@0 | 51 | SkDebugf(",%d", n); |
michael@0 | 52 | } |
michael@0 | 53 | alpha += n; |
michael@0 | 54 | runs += n; |
michael@0 | 55 | } |
michael@0 | 56 | SkDebugf("\n"); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | void SkAlphaRuns::validate() const { |
michael@0 | 60 | SkASSERT(fWidth > 0); |
michael@0 | 61 | |
michael@0 | 62 | int count = 0; |
michael@0 | 63 | const int16_t* runs = fRuns; |
michael@0 | 64 | |
michael@0 | 65 | while (*runs) { |
michael@0 | 66 | SkASSERT(*runs > 0); |
michael@0 | 67 | count += *runs; |
michael@0 | 68 | SkASSERT(count <= fWidth); |
michael@0 | 69 | runs += *runs; |
michael@0 | 70 | } |
michael@0 | 71 | SkASSERT(count == fWidth); |
michael@0 | 72 | } |
michael@0 | 73 | #endif |