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 "SkGraphics.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "SkBlitter.h" |
michael@0 | 13 | #include "SkCanvas.h" |
michael@0 | 14 | #include "SkFloat.h" |
michael@0 | 15 | #include "SkGeometry.h" |
michael@0 | 16 | #include "SkMath.h" |
michael@0 | 17 | #include "SkMatrix.h" |
michael@0 | 18 | #include "SkPath.h" |
michael@0 | 19 | #include "SkPathEffect.h" |
michael@0 | 20 | #include "SkPixelRef.h" |
michael@0 | 21 | #include "SkRefCnt.h" |
michael@0 | 22 | #include "SkRTConf.h" |
michael@0 | 23 | #include "SkScalerContext.h" |
michael@0 | 24 | #include "SkShader.h" |
michael@0 | 25 | #include "SkStream.h" |
michael@0 | 26 | #include "SkTSearch.h" |
michael@0 | 27 | #include "SkTime.h" |
michael@0 | 28 | #include "SkUtils.h" |
michael@0 | 29 | #include "SkXfermode.h" |
michael@0 | 30 | |
michael@0 | 31 | void SkGraphics::GetVersion(int32_t* major, int32_t* minor, int32_t* patch) { |
michael@0 | 32 | if (major) { |
michael@0 | 33 | *major = SKIA_VERSION_MAJOR; |
michael@0 | 34 | } |
michael@0 | 35 | if (minor) { |
michael@0 | 36 | *minor = SKIA_VERSION_MINOR; |
michael@0 | 37 | } |
michael@0 | 38 | if (patch) { |
michael@0 | 39 | *patch = SKIA_VERSION_PATCH; |
michael@0 | 40 | } |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | #define typesizeline(type) { #type , sizeof(type) } |
michael@0 | 44 | |
michael@0 | 45 | #ifdef BUILD_EMBOSS_TABLE |
michael@0 | 46 | extern void SkEmbossMask_BuildTable(); |
michael@0 | 47 | #endif |
michael@0 | 48 | |
michael@0 | 49 | #ifdef BUILD_RADIALGRADIENT_TABLE |
michael@0 | 50 | extern void SkRadialGradient_BuildTable(); |
michael@0 | 51 | #endif |
michael@0 | 52 | |
michael@0 | 53 | void SkGraphics::Init() { |
michael@0 | 54 | #ifdef SK_DEVELOPER |
michael@0 | 55 | skRTConfRegistry().possiblyDumpFile(); |
michael@0 | 56 | skRTConfRegistry().validate(); |
michael@0 | 57 | if (skRTConfRegistry().hasNonDefault()) { |
michael@0 | 58 | SkDebugf("Non-default runtime configuration options:\n"); |
michael@0 | 59 | skRTConfRegistry().printNonDefault(); |
michael@0 | 60 | } |
michael@0 | 61 | #endif |
michael@0 | 62 | |
michael@0 | 63 | #ifdef BUILD_EMBOSS_TABLE |
michael@0 | 64 | SkEmbossMask_BuildTable(); |
michael@0 | 65 | #endif |
michael@0 | 66 | #ifdef BUILD_RADIALGRADIENT_TABLE |
michael@0 | 67 | SkRadialGradient_BuildTable(); |
michael@0 | 68 | #endif |
michael@0 | 69 | |
michael@0 | 70 | #ifdef SK_DEBUGx |
michael@0 | 71 | int i; |
michael@0 | 72 | |
michael@0 | 73 | static const struct { |
michael@0 | 74 | const char* fTypeName; |
michael@0 | 75 | size_t fSizeOf; |
michael@0 | 76 | } gTypeSize[] = { |
michael@0 | 77 | typesizeline(char), |
michael@0 | 78 | typesizeline(short), |
michael@0 | 79 | typesizeline(int), |
michael@0 | 80 | typesizeline(long), |
michael@0 | 81 | typesizeline(size_t), |
michael@0 | 82 | typesizeline(void*), |
michael@0 | 83 | |
michael@0 | 84 | typesizeline(S8CPU), |
michael@0 | 85 | typesizeline(U8CPU), |
michael@0 | 86 | typesizeline(S16CPU), |
michael@0 | 87 | typesizeline(U16CPU), |
michael@0 | 88 | |
michael@0 | 89 | typesizeline(SkPoint), |
michael@0 | 90 | typesizeline(SkRect), |
michael@0 | 91 | typesizeline(SkMatrix), |
michael@0 | 92 | typesizeline(SkPath), |
michael@0 | 93 | typesizeline(SkGlyph), |
michael@0 | 94 | typesizeline(SkRefCnt), |
michael@0 | 95 | |
michael@0 | 96 | typesizeline(SkPaint), |
michael@0 | 97 | typesizeline(SkCanvas), |
michael@0 | 98 | typesizeline(SkBlitter), |
michael@0 | 99 | typesizeline(SkShader), |
michael@0 | 100 | typesizeline(SkXfermode), |
michael@0 | 101 | typesizeline(SkPathEffect) |
michael@0 | 102 | }; |
michael@0 | 103 | |
michael@0 | 104 | #ifdef SK_CPU_BENDIAN |
michael@0 | 105 | SkDebugf("SkGraphics: big-endian\n"); |
michael@0 | 106 | #else |
michael@0 | 107 | SkDebugf("SkGraphics: little-endian\n"); |
michael@0 | 108 | #endif |
michael@0 | 109 | |
michael@0 | 110 | { |
michael@0 | 111 | char test = 0xFF; |
michael@0 | 112 | int itest = test; // promote to int, see if it sign-extended |
michael@0 | 113 | if (itest < 0) |
michael@0 | 114 | SkDebugf("SkGraphics: char is signed\n"); |
michael@0 | 115 | else |
michael@0 | 116 | SkDebugf("SkGraphics: char is unsigned\n"); |
michael@0 | 117 | } |
michael@0 | 118 | for (i = 0; i < (int)SK_ARRAY_COUNT(gTypeSize); i++) { |
michael@0 | 119 | SkDebugf("SkGraphics: sizeof(%s) = %d\n", |
michael@0 | 120 | gTypeSize[i].fTypeName, gTypeSize[i].fSizeOf); |
michael@0 | 121 | } |
michael@0 | 122 | SkDebugf("SkGraphics: font cache limit %dK\n", |
michael@0 | 123 | GetFontCacheLimit() >> 10); |
michael@0 | 124 | |
michael@0 | 125 | #endif |
michael@0 | 126 | |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | void SkGraphics::Term() { |
michael@0 | 130 | PurgeFontCache(); |
michael@0 | 131 | SkPaint::Term(); |
michael@0 | 132 | SkXfermode::Term(); |
michael@0 | 133 | } |
michael@0 | 134 | |
michael@0 | 135 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 136 | |
michael@0 | 137 | static const char kFontCacheLimitStr[] = "font-cache-limit"; |
michael@0 | 138 | static const size_t kFontCacheLimitLen = sizeof(kFontCacheLimitStr) - 1; |
michael@0 | 139 | |
michael@0 | 140 | static const struct { |
michael@0 | 141 | const char* fStr; |
michael@0 | 142 | size_t fLen; |
michael@0 | 143 | size_t (*fFunc)(size_t); |
michael@0 | 144 | } gFlags[] = { |
michael@0 | 145 | { kFontCacheLimitStr, kFontCacheLimitLen, SkGraphics::SetFontCacheLimit } |
michael@0 | 146 | }; |
michael@0 | 147 | |
michael@0 | 148 | /* flags are of the form param; or param=value; */ |
michael@0 | 149 | void SkGraphics::SetFlags(const char* flags) { |
michael@0 | 150 | if (!flags) { |
michael@0 | 151 | return; |
michael@0 | 152 | } |
michael@0 | 153 | const char* nextSemi; |
michael@0 | 154 | do { |
michael@0 | 155 | size_t len = strlen(flags); |
michael@0 | 156 | const char* paramEnd = flags + len; |
michael@0 | 157 | const char* nextEqual = strchr(flags, '='); |
michael@0 | 158 | if (nextEqual && paramEnd > nextEqual) { |
michael@0 | 159 | paramEnd = nextEqual; |
michael@0 | 160 | } |
michael@0 | 161 | nextSemi = strchr(flags, ';'); |
michael@0 | 162 | if (nextSemi && paramEnd > nextSemi) { |
michael@0 | 163 | paramEnd = nextSemi; |
michael@0 | 164 | } |
michael@0 | 165 | size_t paramLen = paramEnd - flags; |
michael@0 | 166 | for (int i = 0; i < (int)SK_ARRAY_COUNT(gFlags); ++i) { |
michael@0 | 167 | if (paramLen != gFlags[i].fLen) { |
michael@0 | 168 | continue; |
michael@0 | 169 | } |
michael@0 | 170 | if (strncmp(flags, gFlags[i].fStr, paramLen) == 0) { |
michael@0 | 171 | size_t val = 0; |
michael@0 | 172 | if (nextEqual) { |
michael@0 | 173 | val = (size_t) atoi(nextEqual + 1); |
michael@0 | 174 | } |
michael@0 | 175 | (gFlags[i].fFunc)(val); |
michael@0 | 176 | break; |
michael@0 | 177 | } |
michael@0 | 178 | } |
michael@0 | 179 | flags = nextSemi + 1; |
michael@0 | 180 | } while (nextSemi); |
michael@0 | 181 | } |