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 | #ifndef SkMemberInfo_DEFINED |
michael@0 | 11 | #define SkMemberInfo_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #if defined SK_BUILD_CONDENSED |
michael@0 | 14 | #define SK_USE_CONDENSED_INFO 0 |
michael@0 | 15 | #endif |
michael@0 | 16 | |
michael@0 | 17 | #include "SkDisplayType.h" |
michael@0 | 18 | #include "SkScript.h" |
michael@0 | 19 | #include "SkString.h" |
michael@0 | 20 | #include "SkIntArray.h" |
michael@0 | 21 | |
michael@0 | 22 | class SkAnimateMaker; |
michael@0 | 23 | class SkDisplayable; |
michael@0 | 24 | class SkScriptEngine; |
michael@0 | 25 | |
michael@0 | 26 | // temporary hacks until name change is more complete |
michael@0 | 27 | #define SkFloat SkScalar |
michael@0 | 28 | #define SkInt SkS32 |
michael@0 | 29 | |
michael@0 | 30 | struct SkMemberInfo { |
michael@0 | 31 | //!!! alternative: |
michael@0 | 32 | // if fCount == 0, record is member property |
michael@0 | 33 | // then fType can be type, so caller doesn't have to check |
michael@0 | 34 | #if SK_USE_CONDENSED_INFO == 0 |
michael@0 | 35 | const char* fName; // may be NULL for anonymous functions |
michael@0 | 36 | size_t fOffset; // if negative, is index into member pointer table (for properties and functions) |
michael@0 | 37 | SkDisplayTypes fType; |
michael@0 | 38 | int fCount; // for properties, actual type (count is always assumed to be 1) |
michael@0 | 39 | #else |
michael@0 | 40 | unsigned char fName; |
michael@0 | 41 | signed char fOffset; |
michael@0 | 42 | unsigned char fType; |
michael@0 | 43 | signed char fCount; |
michael@0 | 44 | #endif |
michael@0 | 45 | SkDisplayTypes arrayType() const { |
michael@0 | 46 | SkASSERT(fType == SkType_Array); |
michael@0 | 47 | return (SkDisplayTypes) fCount; // hack, but worth it? |
michael@0 | 48 | } |
michael@0 | 49 | int functionIndex() const { |
michael@0 | 50 | SkASSERT(fType == SkType_MemberFunction); |
michael@0 | 51 | return (signed) fOffset > 0 ? -1 + (int) fOffset : -1 - (int) fOffset; |
michael@0 | 52 | } |
michael@0 | 53 | bool getArrayValue(const SkDisplayable* displayable, int index, SkOperand* value) const; |
michael@0 | 54 | int getCount() const { |
michael@0 | 55 | return fType == SkType_MemberProperty || fType == SkType_Array || |
michael@0 | 56 | fType == SkType_MemberFunction ? 1 : fCount; |
michael@0 | 57 | } |
michael@0 | 58 | const SkMemberInfo* getInherited() const; |
michael@0 | 59 | size_t getSize(const SkDisplayable* ) const; |
michael@0 | 60 | void getString(const SkDisplayable* , SkString** string) const; |
michael@0 | 61 | SkDisplayTypes getType() const { |
michael@0 | 62 | return fType == SkType_MemberProperty || fType == SkType_Array || |
michael@0 | 63 | fType == SkType_MemberFunction ? (SkDisplayTypes) fCount : (SkDisplayTypes) fType; |
michael@0 | 64 | } |
michael@0 | 65 | void getValue(const SkDisplayable* , SkOperand values[], int count) const; |
michael@0 | 66 | bool isEnum() const; |
michael@0 | 67 | const char* mapEnums(const char* match, int* value) const; |
michael@0 | 68 | void* memberData(const SkDisplayable* displayable) const { |
michael@0 | 69 | SkASSERT(fType != SkType_MemberProperty && fType != SkType_MemberFunction); |
michael@0 | 70 | return (void*) ((const char*) displayable + fOffset); |
michael@0 | 71 | } |
michael@0 | 72 | int propertyIndex() const { |
michael@0 | 73 | SkASSERT(fType == SkType_MemberProperty); |
michael@0 | 74 | return (signed) fOffset > 0 ? -1 + (int) fOffset : -1 - (int) fOffset; |
michael@0 | 75 | } |
michael@0 | 76 | SkDisplayTypes propertyType() const { |
michael@0 | 77 | SkASSERT(fType == SkType_MemberProperty || fType == SkType_Array); |
michael@0 | 78 | return (SkDisplayTypes) fCount; // hack, but worth it? |
michael@0 | 79 | } |
michael@0 | 80 | void setMemberData(SkDisplayable* displayable, const void* child, size_t size) const { |
michael@0 | 81 | SkASSERT(fType != SkType_MemberProperty && fType != SkType_MemberFunction); |
michael@0 | 82 | memcpy((char*) displayable + fOffset, child, size); |
michael@0 | 83 | } |
michael@0 | 84 | void setString(SkDisplayable* , SkString* ) const; |
michael@0 | 85 | void setValue(SkDisplayable* , const SkOperand values[], int count) const; |
michael@0 | 86 | bool setValue(SkAnimateMaker& , SkTDOperandArray* storage, |
michael@0 | 87 | int storageOffset, int maxStorage, SkDisplayable* , |
michael@0 | 88 | SkDisplayTypes outType, const char value[], size_t len) const; |
michael@0 | 89 | bool setValue(SkAnimateMaker& , SkTDOperandArray* storage, |
michael@0 | 90 | int storageOffset, int maxStorage, SkDisplayable* , |
michael@0 | 91 | SkDisplayTypes outType, SkString& str) const; |
michael@0 | 92 | // void setValue(SkDisplayable* , const char value[], const char name[]) const; |
michael@0 | 93 | bool writeValue(SkDisplayable* displayable, SkTDOperandArray* arrayStorage, |
michael@0 | 94 | int storageOffset, int maxStorage, void* untypedStorage, SkDisplayTypes outType, |
michael@0 | 95 | SkScriptValue& scriptValue) const; |
michael@0 | 96 | #if SK_USE_CONDENSED_INFO == 0 |
michael@0 | 97 | static const SkMemberInfo* Find(const SkMemberInfo [], int count, int* index); |
michael@0 | 98 | static const SkMemberInfo* Find(const SkMemberInfo [], int count, const char** name); |
michael@0 | 99 | #else |
michael@0 | 100 | static const SkMemberInfo* Find(SkDisplayTypes type, int* index); |
michael@0 | 101 | static const SkMemberInfo* Find(SkDisplayTypes type, const char** name); |
michael@0 | 102 | #endif |
michael@0 | 103 | static size_t GetSize(SkDisplayTypes type); // size of simple types only |
michael@0 | 104 | // static bool SetValue(void* value, const char* name, SkDisplayTypes , int count); |
michael@0 | 105 | }; |
michael@0 | 106 | |
michael@0 | 107 | #define SK_MEMBER(_member, _type) \ |
michael@0 | 108 | { #_member, SK_OFFSETOF(BASE_CLASS, _member), SkType_##_type, \ |
michael@0 | 109 | sizeof(((BASE_CLASS*) 1)->_member) / sizeof(SkScalar) } |
michael@0 | 110 | |
michael@0 | 111 | #define SK_MEMBER_ALIAS(_member, _alias, _type) \ |
michael@0 | 112 | { #_member, SK_OFFSETOF(BASE_CLASS, _alias), SkType_##_type, \ |
michael@0 | 113 | sizeof(((BASE_CLASS*) 1)->_alias) / sizeof(SkScalar) } |
michael@0 | 114 | |
michael@0 | 115 | #define SK_MEMBER_ARRAY(_member, _type) \ |
michael@0 | 116 | { #_member, SK_OFFSETOF(BASE_CLASS, _member), SkType_Array, \ |
michael@0 | 117 | (int) SkType_##_type } |
michael@0 | 118 | |
michael@0 | 119 | #define SK_MEMBER_INHERITED \ |
michael@0 | 120 | { (const char*) INHERITED::fInfo, 0, SkType_BaseClassInfo, INHERITED::fInfoCount } |
michael@0 | 121 | |
michael@0 | 122 | // #define SK_MEMBER_KEY_TYPE(_member, _type) |
michael@0 | 123 | // {#_member, (size_t) -1, SkType_##_type, 0} |
michael@0 | 124 | |
michael@0 | 125 | #define SK_FUNCTION(_member) \ |
michael@0 | 126 | k_##_member##Function |
michael@0 | 127 | |
michael@0 | 128 | #define SK_PROPERTY(_member) \ |
michael@0 | 129 | k_##_member##Property |
michael@0 | 130 | |
michael@0 | 131 | #define SK_MEMBER_DYNAMIC_FUNCTION(_member, _type) \ |
michael@0 | 132 | {#_member, (size_t) (+1 + SK_FUNCTION(_member)), SkType_MemberFunction, \ |
michael@0 | 133 | (int) SkType_##_type } |
michael@0 | 134 | |
michael@0 | 135 | #define SK_MEMBER_DYNAMIC_PROPERTY(_member, _type) \ |
michael@0 | 136 | {#_member, (size_t) (1 + SK_PROPERTY(_member)), SkType_MemberProperty, \ |
michael@0 | 137 | (int) SkType_##_type } |
michael@0 | 138 | |
michael@0 | 139 | #define SK_MEMBER_FUNCTION(_member, _type) \ |
michael@0 | 140 | {#_member, (size_t) (-1 - SK_FUNCTION(_member)), SkType_MemberFunction, \ |
michael@0 | 141 | (int) SkType_##_type } |
michael@0 | 142 | |
michael@0 | 143 | #define SK_MEMBER_PROPERTY(_member, _type) \ |
michael@0 | 144 | {#_member, (size_t) (-1 - SK_PROPERTY(_member)), SkType_MemberProperty, \ |
michael@0 | 145 | (int) SkType_##_type } |
michael@0 | 146 | |
michael@0 | 147 | #if SK_USE_CONDENSED_INFO == 0 |
michael@0 | 148 | |
michael@0 | 149 | #define DECLARE_PRIVATE_MEMBER_INFO(_type) \ |
michael@0 | 150 | public: \ |
michael@0 | 151 | static const SkMemberInfo fInfo[]; \ |
michael@0 | 152 | static const int fInfoCount; \ |
michael@0 | 153 | virtual const SkMemberInfo* getMember(int index); \ |
michael@0 | 154 | virtual const SkMemberInfo* getMember(const char name[]); \ |
michael@0 | 155 | typedef Sk##_type BASE_CLASS |
michael@0 | 156 | |
michael@0 | 157 | #define DECLARE_MEMBER_INFO(_type) \ |
michael@0 | 158 | public: \ |
michael@0 | 159 | static const SkMemberInfo fInfo[]; \ |
michael@0 | 160 | static const int fInfoCount; \ |
michael@0 | 161 | virtual const SkMemberInfo* getMember(int index); \ |
michael@0 | 162 | virtual const SkMemberInfo* getMember(const char name[]); \ |
michael@0 | 163 | virtual SkDisplayTypes getType() const { return SkType_##_type; } \ |
michael@0 | 164 | typedef Sk##_type BASE_CLASS |
michael@0 | 165 | |
michael@0 | 166 | #define DECLARE_DRAW_MEMBER_INFO(_type) \ |
michael@0 | 167 | public: \ |
michael@0 | 168 | static const SkMemberInfo fInfo[]; \ |
michael@0 | 169 | static const int fInfoCount; \ |
michael@0 | 170 | virtual const SkMemberInfo* getMember(int index); \ |
michael@0 | 171 | virtual const SkMemberInfo* getMember(const char name[]); \ |
michael@0 | 172 | virtual SkDisplayTypes getType() const { return SkType_##_type; } \ |
michael@0 | 173 | typedef SkDraw##_type BASE_CLASS |
michael@0 | 174 | |
michael@0 | 175 | #define DECLARE_DISPLAY_MEMBER_INFO(_type) \ |
michael@0 | 176 | public: \ |
michael@0 | 177 | static const SkMemberInfo fInfo[]; \ |
michael@0 | 178 | static const int fInfoCount; \ |
michael@0 | 179 | virtual const SkMemberInfo* getMember(int index); \ |
michael@0 | 180 | virtual const SkMemberInfo* getMember(const char name[]); \ |
michael@0 | 181 | virtual SkDisplayTypes getType() const { return SkType_##_type; } \ |
michael@0 | 182 | typedef SkDisplay##_type BASE_CLASS |
michael@0 | 183 | |
michael@0 | 184 | #define DECLARE_EMPTY_MEMBER_INFO(_type) \ |
michael@0 | 185 | public: \ |
michael@0 | 186 | virtual SkDisplayTypes getType() const { return SkType_##_type; } |
michael@0 | 187 | |
michael@0 | 188 | #define DECLARE_EXTRAS_MEMBER_INFO(_type) \ |
michael@0 | 189 | public: \ |
michael@0 | 190 | static const SkMemberInfo fInfo[]; \ |
michael@0 | 191 | static const int fInfoCount; \ |
michael@0 | 192 | virtual const SkMemberInfo* getMember(int index); \ |
michael@0 | 193 | virtual const SkMemberInfo* getMember(const char name[]); \ |
michael@0 | 194 | SkDisplayTypes fType; \ |
michael@0 | 195 | virtual SkDisplayTypes getType() const { return fType; } \ |
michael@0 | 196 | typedef _type BASE_CLASS |
michael@0 | 197 | |
michael@0 | 198 | #define DECLARE_NO_VIRTUALS_MEMBER_INFO(_type) \ |
michael@0 | 199 | public: \ |
michael@0 | 200 | static const SkMemberInfo fInfo[]; \ |
michael@0 | 201 | static const int fInfoCount; \ |
michael@0 | 202 | typedef Sk##_type BASE_CLASS |
michael@0 | 203 | |
michael@0 | 204 | #define DEFINE_GET_MEMBER(_class) \ |
michael@0 | 205 | const SkMemberInfo* _class::getMember(int index) { \ |
michael@0 | 206 | const SkMemberInfo* result = SkMemberInfo::Find(fInfo, SK_ARRAY_COUNT(fInfo), &index); \ |
michael@0 | 207 | return result; \ |
michael@0 | 208 | } \ |
michael@0 | 209 | const SkMemberInfo* _class::getMember(const char name[]) { \ |
michael@0 | 210 | const SkMemberInfo* result = SkMemberInfo::Find(fInfo, SK_ARRAY_COUNT(fInfo), &name); \ |
michael@0 | 211 | return result; \ |
michael@0 | 212 | } \ |
michael@0 | 213 | const int _class::fInfoCount = SK_ARRAY_COUNT(fInfo) |
michael@0 | 214 | |
michael@0 | 215 | #define DEFINE_NO_VIRTUALS_GET_MEMBER(_class) \ |
michael@0 | 216 | const int _class::fInfoCount = SK_ARRAY_COUNT(fInfo) |
michael@0 | 217 | |
michael@0 | 218 | #else |
michael@0 | 219 | |
michael@0 | 220 | #define DECLARE_PRIVATE_MEMBER_INFO(_type) \ |
michael@0 | 221 | public: \ |
michael@0 | 222 | typedef Sk##_type BASE_CLASS |
michael@0 | 223 | |
michael@0 | 224 | #define DECLARE_MEMBER_INFO(_type) \ |
michael@0 | 225 | public: \ |
michael@0 | 226 | virtual const SkMemberInfo* getMember(int index) { \ |
michael@0 | 227 | return SkDisplayType::GetMember(NULL, SkType_##_type, &index); } \ |
michael@0 | 228 | virtual const SkMemberInfo* getMember(const char name[]) { \ |
michael@0 | 229 | return SkDisplayType::GetMember(NULL, SkType_##_type, &name); } \ |
michael@0 | 230 | virtual SkDisplayTypes getType() const { return SkType_##_type; } \ |
michael@0 | 231 | typedef Sk##_type BASE_CLASS |
michael@0 | 232 | |
michael@0 | 233 | #define DECLARE_DRAW_MEMBER_INFO(_type) \ |
michael@0 | 234 | public: \ |
michael@0 | 235 | virtual const SkMemberInfo* getMember(int index) { \ |
michael@0 | 236 | return SkDisplayType::GetMember(NULL, SkType_##_type, &index); } \ |
michael@0 | 237 | virtual const SkMemberInfo* getMember(const char name[]) { \ |
michael@0 | 238 | return SkDisplayType::GetMember(NULL, SkType_##_type, &name); } \ |
michael@0 | 239 | virtual SkDisplayTypes getType() const { return SkType_##_type; } \ |
michael@0 | 240 | typedef SkDraw##_type BASE_CLASS |
michael@0 | 241 | |
michael@0 | 242 | #define DECLARE_DISPLAY_MEMBER_INFO(_type) \ |
michael@0 | 243 | public: \ |
michael@0 | 244 | virtual const SkMemberInfo* getMember(int index) { \ |
michael@0 | 245 | return SkDisplayType::GetMember(NULL, SkType_##_type, &index); } \ |
michael@0 | 246 | virtual const SkMemberInfo* getMember(const char name[]) { \ |
michael@0 | 247 | return SkDisplayType::GetMember(NULL, SkType_##_type, &name); } \ |
michael@0 | 248 | virtual SkDisplayTypes getType() const { return SkType_##_type; } \ |
michael@0 | 249 | typedef SkDisplay##_type BASE_CLASS |
michael@0 | 250 | |
michael@0 | 251 | #define DECLARE_EXTRAS_MEMBER_INFO(_type) \ |
michael@0 | 252 | public: \ |
michael@0 | 253 | virtual const SkMemberInfo* getMember(int index) { \ |
michael@0 | 254 | return SkDisplayType::GetMember(NULL, SkType_##_type, &index); } \ |
michael@0 | 255 | virtual const SkMemberInfo* getMember(const char name[]) { \ |
michael@0 | 256 | return SkDisplayType::GetMember(NULL, fType, &name); } \ |
michael@0 | 257 | SkDisplayTypes fType; \ |
michael@0 | 258 | virtual SkDisplayTypes getType() const { return fType; } \ |
michael@0 | 259 | typedef _type BASE_CLASS |
michael@0 | 260 | |
michael@0 | 261 | #define DECLARE_NO_VIRTUALS_MEMBER_INFO(_type) \ |
michael@0 | 262 | public: \ |
michael@0 | 263 | typedef Sk##_type BASE_CLASS |
michael@0 | 264 | |
michael@0 | 265 | #define DEFINE_GET_MEMBER(_class) |
michael@0 | 266 | #define DEFINE_NO_VIRTUALS_GET_MEMBER(_class) |
michael@0 | 267 | |
michael@0 | 268 | #endif |
michael@0 | 269 | |
michael@0 | 270 | #endif // SkMemberInfo_DEFINED |