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 | * vim: set ts=8 sts=4 et sw=4 tw=99: |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef vm_ScopeObject_inl_h |
michael@0 | 8 | #define vm_ScopeObject_inl_h |
michael@0 | 9 | |
michael@0 | 10 | #include "vm/ScopeObject.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "jsinferinlines.h" |
michael@0 | 13 | |
michael@0 | 14 | namespace js { |
michael@0 | 15 | |
michael@0 | 16 | inline void |
michael@0 | 17 | ScopeObject::setAliasedVar(JSContext *cx, ScopeCoordinate sc, PropertyName *name, const Value &v) |
michael@0 | 18 | { |
michael@0 | 19 | JS_ASSERT(is<CallObject>() || is<ClonedBlockObject>()); |
michael@0 | 20 | JS_STATIC_ASSERT(CallObject::RESERVED_SLOTS == BlockObject::RESERVED_SLOTS); |
michael@0 | 21 | |
michael@0 | 22 | setSlot(sc.slot(), v); |
michael@0 | 23 | |
michael@0 | 24 | // name may be null if we don't need to track side effects on the object. |
michael@0 | 25 | if (hasSingletonType() && !hasLazyType()) { |
michael@0 | 26 | JS_ASSERT(name); |
michael@0 | 27 | types::AddTypePropertyId(cx, this, NameToId(name), v); |
michael@0 | 28 | } |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | inline void |
michael@0 | 32 | CallObject::setAliasedVar(JSContext *cx, AliasedFormalIter fi, PropertyName *name, const Value &v) |
michael@0 | 33 | { |
michael@0 | 34 | JS_ASSERT(name == fi->name()); |
michael@0 | 35 | setSlot(fi.scopeSlot(), v); |
michael@0 | 36 | if (hasSingletonType()) |
michael@0 | 37 | types::AddTypePropertyId(cx, this, NameToId(name), v); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | inline void |
michael@0 | 41 | CallObject::setAliasedVarFromArguments(JSContext *cx, const Value &argsValue, jsid id, const Value &v) |
michael@0 | 42 | { |
michael@0 | 43 | setSlot(argsValue.magicUint32(), v); |
michael@0 | 44 | if (hasSingletonType()) |
michael@0 | 45 | types::AddTypePropertyId(cx, this, id, v); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | template <AllowGC allowGC> |
michael@0 | 49 | inline bool |
michael@0 | 50 | StaticScopeIter<allowGC>::done() const |
michael@0 | 51 | { |
michael@0 | 52 | return !obj; |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | template <AllowGC allowGC> |
michael@0 | 56 | inline void |
michael@0 | 57 | StaticScopeIter<allowGC>::operator++(int) |
michael@0 | 58 | { |
michael@0 | 59 | if (obj->template is<NestedScopeObject>()) { |
michael@0 | 60 | obj = obj->template as<NestedScopeObject>().enclosingScopeForStaticScopeIter(); |
michael@0 | 61 | } else if (onNamedLambda || !obj->template as<JSFunction>().isNamedLambda()) { |
michael@0 | 62 | onNamedLambda = false; |
michael@0 | 63 | obj = obj->template as<JSFunction>().nonLazyScript()->enclosingStaticScope(); |
michael@0 | 64 | } else { |
michael@0 | 65 | onNamedLambda = true; |
michael@0 | 66 | } |
michael@0 | 67 | JS_ASSERT_IF(obj, obj->template is<NestedScopeObject>() || obj->template is<JSFunction>()); |
michael@0 | 68 | JS_ASSERT_IF(onNamedLambda, obj->template is<JSFunction>()); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | template <AllowGC allowGC> |
michael@0 | 72 | inline bool |
michael@0 | 73 | StaticScopeIter<allowGC>::hasDynamicScopeObject() const |
michael@0 | 74 | { |
michael@0 | 75 | return obj->template is<StaticBlockObject>() |
michael@0 | 76 | ? obj->template as<StaticBlockObject>().needsClone() |
michael@0 | 77 | : (obj->template is<StaticWithObject>() || |
michael@0 | 78 | obj->template as<JSFunction>().isHeavyweight()); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | template <AllowGC allowGC> |
michael@0 | 82 | inline Shape * |
michael@0 | 83 | StaticScopeIter<allowGC>::scopeShape() const |
michael@0 | 84 | { |
michael@0 | 85 | JS_ASSERT(hasDynamicScopeObject()); |
michael@0 | 86 | JS_ASSERT(type() != NAMED_LAMBDA); |
michael@0 | 87 | if (type() == BLOCK) |
michael@0 | 88 | return block().lastProperty(); |
michael@0 | 89 | return funScript()->callObjShape(); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | template <AllowGC allowGC> |
michael@0 | 93 | inline typename StaticScopeIter<allowGC>::Type |
michael@0 | 94 | StaticScopeIter<allowGC>::type() const |
michael@0 | 95 | { |
michael@0 | 96 | if (onNamedLambda) |
michael@0 | 97 | return NAMED_LAMBDA; |
michael@0 | 98 | return obj->template is<StaticBlockObject>() |
michael@0 | 99 | ? BLOCK |
michael@0 | 100 | : (obj->template is<StaticWithObject>() ? WITH : FUNCTION); |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | template <AllowGC allowGC> |
michael@0 | 104 | inline StaticBlockObject & |
michael@0 | 105 | StaticScopeIter<allowGC>::block() const |
michael@0 | 106 | { |
michael@0 | 107 | JS_ASSERT(type() == BLOCK); |
michael@0 | 108 | return obj->template as<StaticBlockObject>(); |
michael@0 | 109 | } |
michael@0 | 110 | |
michael@0 | 111 | template <AllowGC allowGC> |
michael@0 | 112 | inline StaticWithObject & |
michael@0 | 113 | StaticScopeIter<allowGC>::staticWith() const |
michael@0 | 114 | { |
michael@0 | 115 | JS_ASSERT(type() == WITH); |
michael@0 | 116 | return obj->template as<StaticWithObject>(); |
michael@0 | 117 | } |
michael@0 | 118 | |
michael@0 | 119 | template <AllowGC allowGC> |
michael@0 | 120 | inline JSScript * |
michael@0 | 121 | StaticScopeIter<allowGC>::funScript() const |
michael@0 | 122 | { |
michael@0 | 123 | JS_ASSERT(type() == FUNCTION); |
michael@0 | 124 | return obj->template as<JSFunction>().nonLazyScript(); |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | } /* namespace js */ |
michael@0 | 128 | |
michael@0 | 129 | #endif /* vm_ScopeObject_inl_h */ |