js/src/vm/ScopeObject-inl.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

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

mercurial