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: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
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 | /* XPTI_PUBLIC_API and XPTI_GetInterfaceInfoManager declarations. */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef xptiinfo_h___ |
michael@0 | 9 | #define xptiinfo_h___ |
michael@0 | 10 | |
michael@0 | 11 | #include "nscore.h" |
michael@0 | 12 | #include "xpt_struct.h" |
michael@0 | 13 | |
michael@0 | 14 | class nsIInterfaceInfoManager; |
michael@0 | 15 | |
michael@0 | 16 | // Flyweight wrapper classes for xpt_struct.h structs. |
michael@0 | 17 | // Everything here is dependent upon - and sensitive to changes in - |
michael@0 | 18 | // xpcom/typelib/xpt/public/xpt_struct.h! |
michael@0 | 19 | |
michael@0 | 20 | class nsXPTType : public XPTTypeDescriptorPrefix |
michael@0 | 21 | { |
michael@0 | 22 | // NO DATA - this a flyweight wrapper |
michael@0 | 23 | public: |
michael@0 | 24 | nsXPTType() |
michael@0 | 25 | {} // random contents |
michael@0 | 26 | nsXPTType(const XPTTypeDescriptorPrefix& prefix) |
michael@0 | 27 | {*(XPTTypeDescriptorPrefix*)this = prefix;} |
michael@0 | 28 | |
michael@0 | 29 | nsXPTType(const uint8_t& prefix) |
michael@0 | 30 | {*(uint8_t*)this = prefix;} |
michael@0 | 31 | |
michael@0 | 32 | nsXPTType& operator=(uint8_t val) |
michael@0 | 33 | {flags = val; return *this;} |
michael@0 | 34 | |
michael@0 | 35 | nsXPTType& operator=(const nsXPTType& other) |
michael@0 | 36 | {flags = other.flags; return *this;} |
michael@0 | 37 | |
michael@0 | 38 | operator uint8_t() const |
michael@0 | 39 | {return flags;} |
michael@0 | 40 | |
michael@0 | 41 | // 'Arithmetic' here roughly means that the value is self-contained and |
michael@0 | 42 | // doesn't depend on anything else in memory (ie: not a pointer, not an |
michael@0 | 43 | // XPCOM object, not a jsval, etc). |
michael@0 | 44 | // |
michael@0 | 45 | // Supposedly this terminology comes from Harbison/Steele, but it's still |
michael@0 | 46 | // a rather crappy name. We'd change it if it wasn't used all over the |
michael@0 | 47 | // place in xptcall. :-( |
michael@0 | 48 | bool IsArithmetic() const |
michael@0 | 49 | {return flags <= T_WCHAR;} |
michael@0 | 50 | |
michael@0 | 51 | // We used to abuse 'pointer' flag bit in typelib format quite extensively. |
michael@0 | 52 | // We've gotten rid of most of the cases, but there's still a fair amount |
michael@0 | 53 | // of refactoring to be done in XPCWrappedJSClass before we can safely stop |
michael@0 | 54 | // asking about this. In the mean time, we've got a temporary version of |
michael@0 | 55 | // IsPointer() that should be equivalent to what's in the typelib. |
michael@0 | 56 | bool deprecated_IsPointer() const |
michael@0 | 57 | {return !IsArithmetic() && TagPart() != T_JSVAL;} |
michael@0 | 58 | |
michael@0 | 59 | bool IsInterfacePointer() const |
michael@0 | 60 | { switch (TagPart()) { |
michael@0 | 61 | default: |
michael@0 | 62 | return false; |
michael@0 | 63 | case T_INTERFACE: |
michael@0 | 64 | case T_INTERFACE_IS: |
michael@0 | 65 | return true; |
michael@0 | 66 | } |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | bool IsArray() const |
michael@0 | 70 | {return TagPart() == T_ARRAY;} |
michael@0 | 71 | |
michael@0 | 72 | // 'Dependent' means that params of this type are dependent upon other |
michael@0 | 73 | // params. e.g. an T_INTERFACE_IS is dependent upon some other param at |
michael@0 | 74 | // runtime to say what the interface type of this param really is. |
michael@0 | 75 | bool IsDependent() const |
michael@0 | 76 | { switch (TagPart()) { |
michael@0 | 77 | default: |
michael@0 | 78 | return false; |
michael@0 | 79 | case T_INTERFACE_IS: |
michael@0 | 80 | case TD_ARRAY: |
michael@0 | 81 | case T_PSTRING_SIZE_IS: |
michael@0 | 82 | case T_PWSTRING_SIZE_IS: |
michael@0 | 83 | return true; |
michael@0 | 84 | } |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | uint8_t TagPart() const |
michael@0 | 88 | {return (uint8_t) (flags & XPT_TDP_TAGMASK);} |
michael@0 | 89 | |
michael@0 | 90 | enum |
michael@0 | 91 | { |
michael@0 | 92 | T_I8 = TD_INT8 , |
michael@0 | 93 | T_I16 = TD_INT16 , |
michael@0 | 94 | T_I32 = TD_INT32 , |
michael@0 | 95 | T_I64 = TD_INT64 , |
michael@0 | 96 | T_U8 = TD_UINT8 , |
michael@0 | 97 | T_U16 = TD_UINT16 , |
michael@0 | 98 | T_U32 = TD_UINT32 , |
michael@0 | 99 | T_U64 = TD_UINT64 , |
michael@0 | 100 | T_FLOAT = TD_FLOAT , |
michael@0 | 101 | T_DOUBLE = TD_DOUBLE , |
michael@0 | 102 | T_BOOL = TD_BOOL , |
michael@0 | 103 | T_CHAR = TD_CHAR , |
michael@0 | 104 | T_WCHAR = TD_WCHAR , |
michael@0 | 105 | T_VOID = TD_VOID , |
michael@0 | 106 | T_IID = TD_PNSIID , |
michael@0 | 107 | T_DOMSTRING = TD_DOMSTRING , |
michael@0 | 108 | T_CHAR_STR = TD_PSTRING , |
michael@0 | 109 | T_WCHAR_STR = TD_PWSTRING , |
michael@0 | 110 | T_INTERFACE = TD_INTERFACE_TYPE , |
michael@0 | 111 | T_INTERFACE_IS = TD_INTERFACE_IS_TYPE, |
michael@0 | 112 | T_ARRAY = TD_ARRAY , |
michael@0 | 113 | T_PSTRING_SIZE_IS = TD_PSTRING_SIZE_IS , |
michael@0 | 114 | T_PWSTRING_SIZE_IS = TD_PWSTRING_SIZE_IS , |
michael@0 | 115 | T_UTF8STRING = TD_UTF8STRING , |
michael@0 | 116 | T_CSTRING = TD_CSTRING , |
michael@0 | 117 | T_ASTRING = TD_ASTRING , |
michael@0 | 118 | T_JSVAL = TD_JSVAL |
michael@0 | 119 | }; |
michael@0 | 120 | // NO DATA - this a flyweight wrapper |
michael@0 | 121 | }; |
michael@0 | 122 | |
michael@0 | 123 | class nsXPTParamInfo : public XPTParamDescriptor |
michael@0 | 124 | { |
michael@0 | 125 | // NO DATA - this a flyweight wrapper |
michael@0 | 126 | public: |
michael@0 | 127 | nsXPTParamInfo(const XPTParamDescriptor& desc) |
michael@0 | 128 | {*(XPTParamDescriptor*)this = desc;} |
michael@0 | 129 | |
michael@0 | 130 | |
michael@0 | 131 | bool IsIn() const {return 0 != (XPT_PD_IS_IN(flags));} |
michael@0 | 132 | bool IsOut() const {return 0 != (XPT_PD_IS_OUT(flags));} |
michael@0 | 133 | bool IsRetval() const {return 0 != (XPT_PD_IS_RETVAL(flags));} |
michael@0 | 134 | bool IsShared() const {return 0 != (XPT_PD_IS_SHARED(flags));} |
michael@0 | 135 | bool IsDipper() const {return 0 != (XPT_PD_IS_DIPPER(flags));} |
michael@0 | 136 | bool IsOptional() const {return 0 != (XPT_PD_IS_OPTIONAL(flags));} |
michael@0 | 137 | const nsXPTType GetType() const {return type.prefix;} |
michael@0 | 138 | |
michael@0 | 139 | // Whether this parameter is passed indirectly on the stack. This mainly |
michael@0 | 140 | // applies to out/inout params, but we use it unconditionally for certain |
michael@0 | 141 | // types. |
michael@0 | 142 | bool IsIndirect() const {return IsOut() || |
michael@0 | 143 | GetType().TagPart() == nsXPTType::T_JSVAL;} |
michael@0 | 144 | |
michael@0 | 145 | // NOTE: other activities on types are done via methods on nsIInterfaceInfo |
michael@0 | 146 | |
michael@0 | 147 | private: |
michael@0 | 148 | nsXPTParamInfo(); // no implementation |
michael@0 | 149 | // NO DATA - this a flyweight wrapper |
michael@0 | 150 | }; |
michael@0 | 151 | |
michael@0 | 152 | class nsXPTMethodInfo : public XPTMethodDescriptor |
michael@0 | 153 | { |
michael@0 | 154 | // NO DATA - this a flyweight wrapper |
michael@0 | 155 | public: |
michael@0 | 156 | nsXPTMethodInfo(const XPTMethodDescriptor& desc) |
michael@0 | 157 | {*(XPTMethodDescriptor*)this = desc;} |
michael@0 | 158 | |
michael@0 | 159 | bool IsGetter() const {return 0 != (XPT_MD_IS_GETTER(flags) );} |
michael@0 | 160 | bool IsSetter() const {return 0 != (XPT_MD_IS_SETTER(flags) );} |
michael@0 | 161 | bool IsNotXPCOM() const {return 0 != (XPT_MD_IS_NOTXPCOM(flags));} |
michael@0 | 162 | bool IsConstructor() const {return 0 != (XPT_MD_IS_CTOR(flags) );} |
michael@0 | 163 | bool IsHidden() const {return 0 != (XPT_MD_IS_HIDDEN(flags) );} |
michael@0 | 164 | bool WantsOptArgc() const {return 0 != (XPT_MD_WANTS_OPT_ARGC(flags));} |
michael@0 | 165 | bool WantsContext() const {return 0 != (XPT_MD_WANTS_CONTEXT(flags));} |
michael@0 | 166 | const char* GetName() const {return name;} |
michael@0 | 167 | uint8_t GetParamCount() const {return num_args;} |
michael@0 | 168 | /* idx was index before I got _sick_ of the warnings on Unix, sorry jband */ |
michael@0 | 169 | const nsXPTParamInfo GetParam(uint8_t idx) const |
michael@0 | 170 | { |
michael@0 | 171 | NS_PRECONDITION(idx < GetParamCount(),"bad arg"); |
michael@0 | 172 | return params[idx]; |
michael@0 | 173 | } |
michael@0 | 174 | const nsXPTParamInfo GetResult() const |
michael@0 | 175 | {return result;} |
michael@0 | 176 | private: |
michael@0 | 177 | nsXPTMethodInfo(); // no implementation |
michael@0 | 178 | // NO DATA - this a flyweight wrapper |
michael@0 | 179 | }; |
michael@0 | 180 | |
michael@0 | 181 | |
michael@0 | 182 | // forward declaration |
michael@0 | 183 | struct nsXPTCMiniVariant; |
michael@0 | 184 | |
michael@0 | 185 | class nsXPTConstant : public XPTConstDescriptor |
michael@0 | 186 | { |
michael@0 | 187 | // NO DATA - this a flyweight wrapper |
michael@0 | 188 | public: |
michael@0 | 189 | nsXPTConstant(const XPTConstDescriptor& desc) |
michael@0 | 190 | {*(XPTConstDescriptor*)this = desc;} |
michael@0 | 191 | |
michael@0 | 192 | const char* GetName() const |
michael@0 | 193 | {return name;} |
michael@0 | 194 | |
michael@0 | 195 | const nsXPTType GetType() const |
michael@0 | 196 | {return type.prefix;} |
michael@0 | 197 | |
michael@0 | 198 | // XXX this is ugly. But sometimes you gotta do what you gotta do. |
michael@0 | 199 | // A reinterpret_cast won't do the trick here. And this plain C cast |
michael@0 | 200 | // works correctly and is safe enough. |
michael@0 | 201 | // See http://bugzilla.mozilla.org/show_bug.cgi?id=49641 |
michael@0 | 202 | const nsXPTCMiniVariant* GetValue() const |
michael@0 | 203 | {return (nsXPTCMiniVariant*) &value;} |
michael@0 | 204 | private: |
michael@0 | 205 | nsXPTConstant(); // no implementation |
michael@0 | 206 | // NO DATA - this a flyweight wrapper |
michael@0 | 207 | }; |
michael@0 | 208 | |
michael@0 | 209 | #endif /* xptiinfo_h___ */ |