Changeset 31746 in webkit


Ignore:
Timestamp:
Apr 8, 2008, 7:17:49 PM (17 years ago)
Author:
weinig@apple.com
Message:

JavaScriptCore:

2008-04-04 Sam Weinig <sam@webkit.org>

Reviewed by Geoffrey Garen.

First step in implementing the "split window"

  • Add a GlobalThisValue to ExecState which should be used in places that used to implement the "use the global object as this if null" rule.
  • Factor out lookupGetter/lookupSetter into virtual methods on JSObject so that they can be forwarded.
  • Make defineGetter/defineSetter virtual methods for the same reason.
  • Have PrototypeReflexiveFunction store the globalObject used to create it so that it can be used to get the correct thisObject for eval.
  • API/JSObjectRef.cpp: (JSObjectCallAsFunction):
  • JavaScriptCore.exp:
  • kjs/Activation.h:
  • kjs/ExecState.cpp: (KJS::ExecState::ExecState): (KJS::GlobalExecState::GlobalExecState):
  • kjs/ExecState.h: (KJS::ExecState::globalThisValue):
  • kjs/ExecStateInlines.h: (KJS::ExecState::ExecState): (KJS::FunctionExecState::FunctionExecState):
  • kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::reset): (KJS::JSGlobalObject::toGlobalObject):
  • kjs/JSGlobalObject.h: (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): (KJS::JSGlobalObject::JSGlobalObject):
  • kjs/array_instance.cpp: (KJS::CompareWithCompareFunctionArguments::CompareWithCompareFunctionArguments): (KJS::compareWithCompareFunctionForQSort):
  • kjs/array_object.cpp: (KJS::arrayProtoFuncSort): (KJS::arrayProtoFuncFilter): (KJS::arrayProtoFuncMap): (KJS::arrayProtoFuncEvery): (KJS::arrayProtoFuncForEach): (KJS::arrayProtoFuncSome):
  • kjs/function.cpp: (KJS::FunctionImp::callAsFunction): (KJS::ActivationImp::toThisObject): (KJS::globalFuncEval): (KJS::PrototypeReflexiveFunction::PrototypeReflexiveFunction): (KJS::PrototypeReflexiveFunction::mark):
  • kjs/function.h: (KJS::PrototypeReflexiveFunction::cachedGlobalObject):
  • kjs/function_object.cpp: (KJS::functionProtoFuncApply): (KJS::functionProtoFuncCall):
  • kjs/nodes.cpp: (KJS::ExpressionNode::resolveAndCall): (KJS::FunctionCallValueNode::evaluate): (KJS::LocalVarFunctionCallNode::inlineEvaluate): (KJS::ScopedVarFunctionCallNode::inlineEvaluate): (KJS::FunctionCallBracketNode::evaluate): (KJS::FunctionCallDotNode::inlineEvaluate):
  • kjs/object.cpp: (KJS::JSObject::call): (KJS::JSObject::put): (KJS::tryGetAndCallProperty): (KJS::JSObject::lookupGetter): (KJS::JSObject::lookupSetter): (KJS::JSObject::toThisObject): (KJS::JSObject::toGlobalObject): (KJS::JSObject::fillGetterPropertySlot):
  • kjs/object.h:
  • kjs/object_object.cpp: (KJS::objectProtoFuncLookupGetter): (KJS::objectProtoFuncLookupSetter):
  • kjs/string_object.cpp: (KJS::replace):

WebCore:

2008-04-04 Sam Weinig <sam@webkit.org>

Reviewed by Geoffrey Garen.

First step in implementing the "split window"

  • This patch takes the first step in changing the window navigation model from clearing the window properties on navigation, to replacing an inner window. This is necessary to safely perform security checks using the lexical global object.

This first step adds a new class called JSDOMWindowWrapper, which wraps
the real window object. All JS calls that would go to the window object
now go to it, which it forwards to the current inner window. To accomplish
this, the wrapper window is used as the ThisValue wherever the window was used
before.

  • WebCore.base.exp:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowBase::JSDOMWindowBase): (WebCore::JSDOMWindowBase::clear): Reset the wrapper windows prototype too. (WebCore::JSDOMWindowBase::toThisObject): (WebCore::JSDOMWindowBase::wrapper): (WebCore::windowProtoFuncAToB): (WebCore::windowProtoFuncBToA): (WebCore::windowProtoFuncOpen): (WebCore::windowProtoFuncSetTimeout): (WebCore::windowProtoFuncClearTimeout): (WebCore::windowProtoFuncSetInterval): (WebCore::windowProtoFuncAddEventListener): (WebCore::windowProtoFuncRemoveEventListener): (WebCore::windowProtoFuncShowModalDialog): (WebCore::windowProtoFuncNotImplemented): (WebCore::toJS):
  • bindings/js/JSDOMWindowBase.h: Fix to expect the wrapper as the thisObj.
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::postMessage): (WebCore::toDOMWindow):
  • bindings/js/JSDOMWindowWrapper.cpp: Added. (WebCore::): (WebCore::JSDOMWindowWrapper::JSDOMWindowWrapper): (WebCore::JSDOMWindowWrapper::~JSDOMWindowWrapper): (WebCore::JSDOMWindowWrapper::mark): (WebCore::JSDOMWindowWrapper::className): (WebCore::JSDOMWindowWrapper::getOwnPropertySlot): (WebCore::JSDOMWindowWrapper::put): (WebCore::JSDOMWindowWrapper::deleteProperty): (WebCore::JSDOMWindowWrapper::getPropertyNames): (WebCore::JSDOMWindowWrapper::getPropertyAttributes): (WebCore::JSDOMWindowWrapper::defineGetter): (WebCore::JSDOMWindowWrapper::defineSetter): (WebCore::JSDOMWindowWrapper::lookupGetter): (WebCore::JSDOMWindowWrapper::lookupSetter): (WebCore::JSDOMWindowWrapper::toGlobalObject): (WebCore::JSDOMWindowWrapper::impl): (WebCore::JSDOMWindowWrapper::disconnectFrame): (WebCore::JSDOMWindowWrapper::clear): (WebCore::toJS):
  • bindings/js/JSDOMWindowWrapper.h: Added. (WebCore::JSDOMWindowWrapper::innerWindow): (WebCore::JSDOMWindowWrapper::setInnerWindow): (WebCore::JSDOMWindowWrapper::classInfo): Forward methods to the innerWindow.
  • bindings/js/JSHTMLDocumentCustom.cpp: (WebCore::JSHTMLDocument::open):
  • bindings/js/ScheduledAction.cpp: (WebCore::ScheduledAction::execute):
  • bindings/js/kjs_events.cpp: (WebCore::JSAbstractEventListener::handleEvent):
  • bindings/js/kjs_proxy.cpp: (WebCore::KJSProxy::~KJSProxy): (WebCore::KJSProxy::evaluate): (WebCore::KJSProxy::clear): (WebCore::KJSProxy::initScript): (WebCore::KJSProxy::clearDocumentWrapper): (WebCore::KJSProxy::processingUserGesture): (WebCore::KJSProxy::attachDebugger):
  • bindings/js/kjs_proxy.h: (WebCore::KJSProxy::haveWindowWrapper): (WebCore::KJSProxy::windowWrapper): (WebCore::KJSProxy::globalObject): (WebCore::KJSProxy::initScriptIfNeeded): Hold onto the wrapper window instead of global object. As a convenience, keep the globalObject() as a forward to the inner window.
  • bindings/objc/DOMUtility.mm: (KJS::createDOMWrapper):
  • bindings/scripts/CodeGeneratorJS.pm:
  • dom/Document.cpp: (WebCore::Document::domWindow):
  • dom/Document.h: (WebCore::Document::defaultView):
  • loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchWindowObjectAvailable):
  • page/DOMWindow.idl:
  • page/Frame.cpp: (WebCore::Frame::~Frame): (WebCore::Frame::pageDestroyed):
Location:
trunk
Files:
2 added
48 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r30534 r31746  
    287287
    288288    if (!jsThisObject)
    289         jsThisObject = exec->dynamicGlobalObject();
    290    
     289        jsThisObject = exec->globalThisValue();
     290
    291291    List argList;
    292292    for (size_t i = 0; i < argumentCount; i++)
  • trunk/JavaScriptCore/ChangeLog

    r31745 r31746  
     12008-04-04  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        First step in implementing the "split window"
     6
     7        - Add a GlobalThisValue to ExecState which should be used
     8          in places that used to implement the "use the global object
     9          as this if null" rule.
     10        - Factor out lookupGetter/lookupSetter into virtual methods
     11          on JSObject so that they can be forwarded.
     12        - Make defineGetter/defineSetter virtual methods for the same
     13          reason.
     14        - Have PrototypeReflexiveFunction store the globalObject used
     15          to create it so that it can be used to get the correct thisObject
     16          for eval.
     17
     18        * API/JSObjectRef.cpp:
     19        (JSObjectCallAsFunction):
     20        * JavaScriptCore.exp:
     21        * kjs/Activation.h:
     22        * kjs/ExecState.cpp:
     23        (KJS::ExecState::ExecState):
     24        (KJS::GlobalExecState::GlobalExecState):
     25        * kjs/ExecState.h:
     26        (KJS::ExecState::globalThisValue):
     27        * kjs/ExecStateInlines.h:
     28        (KJS::ExecState::ExecState):
     29        (KJS::FunctionExecState::FunctionExecState):
     30        * kjs/JSGlobalObject.cpp:
     31        (KJS::JSGlobalObject::reset):
     32        (KJS::JSGlobalObject::toGlobalObject):
     33        * kjs/JSGlobalObject.h:
     34        (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData):
     35        (KJS::JSGlobalObject::JSGlobalObject):
     36        * kjs/array_instance.cpp:
     37        (KJS::CompareWithCompareFunctionArguments::CompareWithCompareFunctionArguments):
     38        (KJS::compareWithCompareFunctionForQSort):
     39        * kjs/array_object.cpp:
     40        (KJS::arrayProtoFuncSort):
     41        (KJS::arrayProtoFuncFilter):
     42        (KJS::arrayProtoFuncMap):
     43        (KJS::arrayProtoFuncEvery):
     44        (KJS::arrayProtoFuncForEach):
     45        (KJS::arrayProtoFuncSome):
     46        * kjs/function.cpp:
     47        (KJS::FunctionImp::callAsFunction):
     48        (KJS::ActivationImp::toThisObject):
     49        (KJS::globalFuncEval):
     50        (KJS::PrototypeReflexiveFunction::PrototypeReflexiveFunction):
     51        (KJS::PrototypeReflexiveFunction::mark):
     52        * kjs/function.h:
     53        (KJS::PrototypeReflexiveFunction::cachedGlobalObject):
     54        * kjs/function_object.cpp:
     55        (KJS::functionProtoFuncApply):
     56        (KJS::functionProtoFuncCall):
     57        * kjs/nodes.cpp:
     58        (KJS::ExpressionNode::resolveAndCall):
     59        (KJS::FunctionCallValueNode::evaluate):
     60        (KJS::LocalVarFunctionCallNode::inlineEvaluate):
     61        (KJS::ScopedVarFunctionCallNode::inlineEvaluate):
     62        (KJS::FunctionCallBracketNode::evaluate):
     63        (KJS::FunctionCallDotNode::inlineEvaluate):
     64        * kjs/object.cpp:
     65        (KJS::JSObject::call):
     66        (KJS::JSObject::put):
     67        (KJS::tryGetAndCallProperty):
     68        (KJS::JSObject::lookupGetter):
     69        (KJS::JSObject::lookupSetter):
     70        (KJS::JSObject::toThisObject):
     71        (KJS::JSObject::toGlobalObject):
     72        (KJS::JSObject::fillGetterPropertySlot):
     73        * kjs/object.h:
     74        * kjs/object_object.cpp:
     75        (KJS::objectProtoFuncLookupGetter):
     76        (KJS::objectProtoFuncLookupSetter):
     77        * kjs/string_object.cpp:
     78        (KJS::replace):
     79
    1802008-04-08  Brady Eidson  <beidson@apple.com>
    281
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r31738 r31746  
    122122__ZN3KJS14StringInstanceC1EPNS_8JSObjectERKNS_7UStringE
    123123__ZN3KJS14StringInstanceC2EPNS_8JSObjectERKNS_7UStringE
    124 __ZN3KJS15GlobalExecStateC1EPNS_14JSGlobalObjectE
     124__ZN3KJS15GlobalExecStateC1EPNS_14JSGlobalObjectEPNS_8JSObjectE
    125125__ZN3KJS15JSWrapperObject4markEv
    126126__ZN3KJS15SavedPropertiesC1Ev
     
    169169__ZN3KJS8DebuggerD2Ev
    170170__ZN3KJS8JSObject11hasInstanceEPNS_9ExecStateEPNS_7JSValueE
     171__ZN3KJS8JSObject12defineGetterEPNS_9ExecStateERKNS_10IdentifierEPS0_
     172__ZN3KJS8JSObject12defineSetterEPNS_9ExecStateERKNS_10IdentifierEPS0_
     173__ZN3KJS8JSObject12lookupGetterEPNS_9ExecStateERKNS_10IdentifierE
     174__ZN3KJS8JSObject12lookupSetterEPNS_9ExecStateERKNS_10IdentifierE
    171175__ZN3KJS8JSObject12removeDirectERKNS_10IdentifierE
    172176__ZN3KJS8JSObject14callAsFunctionEPNS_9ExecStateEPS0_RKNS_4ListE
     
    231235__ZNK3KJS14JSGlobalObject12saveBuiltinsERNS_13SavedBuiltinsE
    232236__ZNK3KJS14JSGlobalObject14isDynamicScopeEv
     237__ZNK3KJS14JSGlobalObject14toGlobalObjectEPNS_9ExecStateE
    233238__ZNK3KJS16JSVariableObject16isVariableObjectEv
    234239__ZNK3KJS16JSVariableObject16saveLocalStorageERNS_15SavedPropertiesE
     
    258263__ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateEj
    259264__ZNK3KJS8JSObject12defaultValueEPNS_9ExecStateENS_6JSTypeE
     265__ZNK3KJS8JSObject12toThisObjectEPNS_9ExecStateE
    260266__ZNK3KJS8JSObject14implementsCallEv
     267__ZNK3KJS8JSObject14toGlobalObjectEPNS_9ExecStateE
    261268__ZNK3KJS8JSObject19implementsConstructEv
    262269__ZNK3KJS8JSObject21getPropertyAttributesERKNS_10IdentifierERj
  • trunk/JavaScriptCore/kjs/Activation.h

    r31136 r31746  
    6767        static const ClassInfo info;
    6868
     69        virtual JSObject* toThisObject(ExecState*) const;
     70
    6971        virtual void mark();
    7072        void markChildren();
  • trunk/JavaScriptCore/kjs/ExecState.cpp

    r31267 r31746  
    4343
    4444// The constructor for the globalExec pseudo-ExecState
    45 inline ExecState::ExecState(JSGlobalObject* globalObject)
     45inline ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisObject)
    4646    : m_globalObject(globalObject)
    4747    , m_exception(0)
     
    5656    , m_inlineScopeChainNode(0, 0)
    5757    , m_variableObject(globalObject)
    58     , m_thisValue(globalObject)
     58    , m_thisValue(thisObject)
     59    , m_globalThisValue(thisObject)
    5960    , m_iterationDepth(0)
    6061    , m_switchDepth(0)
     
    7879    , m_variableObject(globalObject)
    7980    , m_thisValue(thisObject)
     81    , m_globalThisValue(thisObject)
    8082    , m_iterationDepth(0)
    8183    , m_switchDepth(0)
     
    101103    , m_variableObject(variableObject)
    102104    , m_thisValue(thisObject)
     105    , m_globalThisValue(thisObject)
    103106    , m_iterationDepth(0)
    104107    , m_switchDepth(0)
     
    116119}
    117120
    118 GlobalExecState::GlobalExecState(JSGlobalObject* globalObject)
    119     : ExecState(globalObject)
     121GlobalExecState::GlobalExecState(JSGlobalObject* globalObject, JSObject* thisObject)
     122    : ExecState(globalObject, thisObject)
    120123{
    121124}
  • trunk/JavaScriptCore/kjs/ExecState.h

    r31172 r31746  
    7474       
    7575        JSObject* thisValue() const { return m_thisValue; }
     76        JSObject* globalThisValue() const { return m_globalThisValue; }
    7677       
    7778        ExecState* callingExecState() { return m_callingExec; }
     
    165166
    166167    protected:
    167         ExecState(JSGlobalObject*);
     168        ExecState(JSGlobalObject*, JSObject* thisObject);
    168169        ExecState(JSGlobalObject*, JSObject* thisObject, ProgramNode*);
    169170        ExecState(JSGlobalObject*, JSObject* thisObject, EvalNode*, ExecState* callingExecState, const ScopeChain&, JSVariableObject*);
    170         ExecState(JSGlobalObject*, JSObject* thisObject, FunctionBodyNode*, ExecState* callingExecState, FunctionImp*, const List& args);
     171        ExecState(JSGlobalObject*, JSObject* thisObject, JSObject* globalThisValue, FunctionBodyNode*, ExecState* callingExecState, FunctionImp*, const List& args);
    171172        ~ExecState();
    172173
     
    191192        ScopeChainNode m_inlineScopeChainNode;
    192193        JSVariableObject* m_variableObject;
     194
    193195        JSObject* m_thisValue;
     196        JSObject* m_globalThisValue;
    194197       
    195198        LabelStack m_labelStack;
     
    204207    class GlobalExecState : public ExecState {
    205208    public:
    206         GlobalExecState(JSGlobalObject*);
     209        GlobalExecState(JSGlobalObject*, JSObject* thisObject);
    207210        ~GlobalExecState();
    208211    };
     
    222225    class FunctionExecState : public ExecState {
    223226    public:
    224         FunctionExecState(JSGlobalObject*, JSObject* thisObject, FunctionBodyNode*,
     227        FunctionExecState(JSGlobalObject*, JSObject* thisObject, JSObject* globalThisValue, FunctionBodyNode*,
    225228            ExecState* callingExecState, FunctionImp*, const List& args);
    226229        ~FunctionExecState();
  • trunk/JavaScriptCore/kjs/ExecStateInlines.h

    r31205 r31746  
    3131namespace KJS  {
    3232
    33     inline ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisObject,
     33    inline ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisObject, JSObject* globalThisValue,
    3434                                FunctionBodyNode* functionBodyNode, ExecState* callingExec,
    3535                                FunctionImp* func, const List& args)
     
    4545        , m_inlineScopeChainNode(0, 0)
    4646        , m_thisValue(thisObject)
     47        , m_globalThisValue(globalThisValue)
    4748        , m_iterationDepth(0)
    4849        , m_switchDepth(0)
     
    6970    }
    7071
    71     inline FunctionExecState::FunctionExecState(JSGlobalObject* globalObject, JSObject* thisObject,
     72    inline FunctionExecState::FunctionExecState(JSGlobalObject* globalObject, JSObject* thisObject, JSObject* globalThisValue,
    7273                                                FunctionBodyNode* functionBodyNode, ExecState* callingExec,
    7374                                                FunctionImp* func, const List& args)
    74         : ExecState(globalObject, thisObject, functionBodyNode, callingExec, func, args)
     75        : ExecState(globalObject, thisObject, globalThisValue, functionBodyNode, callingExec, func, args)
    7576    {
    7677        m_globalObject->activeExecStates().append(this);
  • trunk/JavaScriptCore/kjs/JSGlobalObject.cpp

    r31226 r31746  
    328328    // Set global functions.
    329329
    330     d()->evalFunction = new PrototypeReflexiveFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval);
     330    d()->evalFunction = new PrototypeReflexiveFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this);
    331331    putDirectFunction(d()->evalFunction, DontEnum);
    332332    putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 2, "parseInt", globalFuncParseInt), DontEnum);
     
    535535}
    536536
     537JSGlobalObject* JSGlobalObject::toGlobalObject(ExecState*) const
     538{
     539    return const_cast<JSGlobalObject*>(this);
     540}
     541
    537542ExecState* JSGlobalObject::globalExec()
    538543{
  • trunk/JavaScriptCore/kjs/JSGlobalObject.h

    r31173 r31746  
    7777
    7878        struct JSGlobalObjectData : public JSVariableObjectData {
    79             JSGlobalObjectData(JSGlobalObject* globalObject)
     79            JSGlobalObjectData(JSGlobalObject* globalObject, JSObject* thisValue)
    8080                : JSVariableObjectData(&inlineSymbolTable)
    81                 , globalExec(globalObject)
     81                , globalExec(globalObject, thisValue)
    8282            {
    8383            }
     
    142142    public:
    143143        JSGlobalObject()
    144             : JSVariableObject(new JSGlobalObjectData(this))
     144            : JSVariableObject(new JSGlobalObjectData(this, this))
    145145        {
    146146            init();
     
    148148
    149149    protected:
    150         JSGlobalObject(JSValue* proto)
    151             : JSVariableObject(proto, new JSGlobalObjectData(this))
     150        JSGlobalObject(JSValue* proto, JSObject* globalThisValue)
     151            : JSVariableObject(proto, new JSGlobalObjectData(this, globalThisValue))
    152152        {
    153153            init();
     
    226226
    227227        virtual bool isGlobalObject() const { return true; }
     228        virtual JSGlobalObject* toGlobalObject(ExecState*) const;
    228229
    229230        virtual ExecState* globalExec();
  • trunk/JavaScriptCore/kjs/array_instance.cpp

    r31343 r31746  
    2424#include "array_instance.h"
    2525
    26 #include "JSGlobalObject.h"
    2726#include "PropertyNameArray.h"
    2827#include <wtf/Assertions.h>
     
    490489        : exec(e)
    491490        , compareFunction(cf)
    492         , globalObject(e->dynamicGlobalObject())
     491        , globalThisValue(e->globalThisValue())
    493492    {
    494493    }
     
    497496    JSObject *compareFunction;
    498497    List arguments;
    499     JSGlobalObject* globalObject;
     498    JSObject* globalThisValue;
    500499};
    501500
     
    514513    args->arguments.append(va);
    515514    args->arguments.append(vb);
    516     double compareResult = args->compareFunction->call
    517         (args->exec, args->globalObject, args->arguments)->toNumber(args->exec);
     515    double compareResult = args->compareFunction->call(args->exec, args->globalThisValue, args->arguments)->toNumber(args->exec);
    518516    return compareResult < 0 ? -1 : compareResult > 0 ? 1 : 0;
    519517}
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r30041 r31746  
    405405                l.append(jObj);
    406406                l.append(minObj);
    407                 compareResult = sortFunction->call(exec, exec->dynamicGlobalObject(), l)->toNumber(exec);
     407                compareResult = sortFunction->call(exec, exec->globalThisValue(), l)->toNumber(exec);
    408408            } else
    409409                compareResult = (jObj->toString(exec) < minObj->toString(exec)) ? -1 : 1;
     
    503503        return throwError(exec, TypeError);
    504504
    505     JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() :  args[1]->toObject(exec);
     505    JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() :  args[1]->toObject(exec);
    506506    JSObject* resultArray = static_cast<JSObject*>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()));
    507507
     
    536536        return throwError(exec, TypeError);
    537537
    538     JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() :  args[1]->toObject(exec);
     538    JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() :  args[1]->toObject(exec);
    539539
    540540    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
     
    576576        return throwError(exec, TypeError);
    577577
    578     JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() :  args[1]->toObject(exec);
     578    JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() :  args[1]->toObject(exec);
    579579
    580580    JSValue* result = jsBoolean(true);
     
    611611        return throwError(exec, TypeError);
    612612
    613     JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() :  args[1]->toObject(exec);
     613    JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() :  args[1]->toObject(exec);
    614614
    615615    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
     
    636636        return throwError(exec, TypeError);
    637637
    638     JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() :  args[1]->toObject(exec);
     638    JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() :  args[1]->toObject(exec);
    639639
    640640    JSValue* result = jsBoolean(false);
  • trunk/JavaScriptCore/kjs/function.cpp

    r31173 r31746  
    7474JSValue* FunctionImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    7575{
    76     FunctionExecState newExec(exec->dynamicGlobalObject(), thisObj, body.get(), exec, this, args);
     76    FunctionExecState newExec(exec->dynamicGlobalObject(), thisObj, exec->globalThisValue(), body.get(), exec, this, args);
    7777    JSValue* result = body->execute(&newExec);
    7878    if (newExec.completionType() == ReturnValue)
     
    465465    // call instead of storing the list ourselves.
    466466    d()->argumentsObject = new Arguments(exec, d()->exec->function(), *d()->exec->arguments(), this);
     467}
     468
     469JSObject* ActivationImp::toThisObject(ExecState* exec) const
     470{
     471    return exec->globalThisValue();
    467472}
    468473
     
    739744JSValue* globalFuncEval(ExecState* exec, PrototypeReflexiveFunction* function, JSObject* thisObj, const List& args)
    740745{
    741     JSGlobalObject* globalObject = thisObj->isGlobalObject() ? static_cast<JSGlobalObject*>(thisObj) : 0;
     746    JSGlobalObject* globalObject = thisObj->toGlobalObject(exec);
    742747
    743748    if (!globalObject || globalObject->evalFunction() != function)
     
    745750
    746751    ScopeChain scopeChain(globalObject);
    747     return eval(exec, scopeChain, globalObject, globalObject, globalObject, args);
     752    return eval(exec, scopeChain, globalObject, globalObject, function->cachedGlobalObject()->toThisObject(exec), args);
    748753}
    749754
     
    891896// ------------------------------ PrototypeReflexiveFunction -------------------------------
    892897
    893 PrototypeReflexiveFunction::PrototypeReflexiveFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, JSMemberFunction function)
     898PrototypeReflexiveFunction::PrototypeReflexiveFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, JSMemberFunction function, JSGlobalObject* cachedGlobalObject)
    894899    : InternalFunctionImp(functionPrototype, name)
    895900    , m_function(function)
     901    , m_cachedGlobalObject(cachedGlobalObject)
    896902{
    897903    ASSERT_ARG(function, function);
     904    ASSERT_ARG(cachedGlobalObject, cachedGlobalObject);
    898905    putDirect(exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum);
    899906}
     
    904911}
    905912
     913void PrototypeReflexiveFunction::mark()
     914{
     915    InternalFunctionImp::mark();
     916    if (!m_cachedGlobalObject->marked())
     917        m_cachedGlobalObject->mark();
     918}
     919
    906920} // namespace KJS
  • trunk/JavaScriptCore/kjs/function.h

    r30871 r31746  
    143143    typedef JSValue* (*JSMemberFunction)(ExecState*, PrototypeReflexiveFunction*, JSObject* thisObj, const List&);
    144144
    145     PrototypeReflexiveFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, JSMemberFunction);
     145    PrototypeReflexiveFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, JSMemberFunction, JSGlobalObject* expectedThisObject);
    146146
     147    virtual void mark();
    147148    virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List&);
     149
     150    JSGlobalObject* cachedGlobalObject() const { return m_cachedGlobalObject; }
    148151
    149152  private:
    150153    const JSMemberFunction m_function;
     154    JSGlobalObject* m_cachedGlobalObject;
    151155  };
    152156
  • trunk/JavaScriptCore/kjs/function_object.cpp

    r31208 r31746  
    8787    JSObject* applyThis;
    8888    if (thisArg->isUndefinedOrNull())
    89         applyThis = exec->dynamicGlobalObject();
     89        applyThis = exec->globalThisValue();
    9090    else
    9191        applyThis = thisArg->toObject(exec);
     
    117117    JSObject* callThis;
    118118    if (thisArg->isUndefinedOrNull())
    119         callThis = exec->dynamicGlobalObject();
     119        callThis = exec->globalThisValue();
    120120    else
    121121        callThis = thisArg->toObject(exec);
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r31431 r31746  
    11231123            KJS_CHECKEXCEPTIONVALUE
    11241124
    1125             JSObject* thisObj = base;
    1126             // ECMA 11.2.3 says that in this situation the this value should be null.
    1127             // However, section 10.2.3 says that in the case where the value provided
    1128             // by the caller is null, the global object should be used. It also says
    1129             // that the section does not apply to internal functions, but for simplicity
    1130             // of implementation we use the global object anyway here. This guarantees
    1131             // that in host objects you always get a valid object for this.
    1132             if (thisObj->isActivationObject())
    1133                 thisObj = exec->dynamicGlobalObject();
    1134 
    11351125            if (callerType == EvalOperator) {
    11361126                if (base == exec->lexicalGlobalObject() && func == exec->lexicalGlobalObject()->evalFunction()) {
     
    11391129                }
    11401130            }
     1131
     1132            JSObject* thisObj = base->toThisObject(exec);
    11411133            return func->call(exec, thisObj, argList);
    11421134        }
     
    11831175    KJS_CHECKEXCEPTIONVALUE
    11841176
    1185     JSObject* thisObj =  exec->dynamicGlobalObject();
    1186 
     1177    JSObject* thisObj = exec->globalThisValue();
    11871178    return func->call(exec, thisObj, argList);
    11881179}
     
    12671258    KJS_CHECKEXCEPTIONVALUE
    12681259
    1269     return func->call(exec, exec->dynamicGlobalObject(), argList);
     1260    JSObject* thisObj = exec->globalThisValue();
     1261    return func->call(exec, thisObj, argList);
    12701262}
    12711263
     
    13191311    m_args->evaluateList(exec, argList);
    13201312    KJS_CHECKEXCEPTIONVALUE
    1321    
    1322     return func->call(exec, exec->dynamicGlobalObject(), argList);
     1313
     1314    JSObject* thisObj = exec->globalThisValue();
     1315    return func->call(exec, thisObj, argList);
    13231316}
    13241317
     
    14491442    ASSERT(!thisObj->isActivationObject());
    14501443
     1444    // No need to call toThisObject() on the thisObj as it is known not to be the GlobalObject or ActivationObject
    14511445    return func->call(exec, thisObj, argList);
    14521446}
     
    14981492    ASSERT(!thisObj->isActivationObject());
    14991493
     1494    // No need to call toThisObject() on the thisObj as it is known not to be the GlobalObject or ActivationObject
    15001495    return func->call(exec, thisObj, argList);
    15011496}
  • trunk/JavaScriptCore/kjs/object.cpp

    r31147 r31746  
    9494#endif
    9595
    96   JSValue *ret = callAsFunction(exec,thisObj,args);
     96  JSValue* ret = callAsFunction(exec, thisObj, args);
    9797
    9898#if KJS_MAX_STACK > 0
     
    262262          args.append(value);
    263263       
    264           setterFunc->call(exec, this, args);
     264          setterFunc->call(exec, this->toThisObject(exec), args);
    265265          return;
    266266        } else {
     
    338338    if (o->implementsCall()) { // spec says "not primitive type" but ...
    339339      JSObject *thisObj = const_cast<JSObject*>(object);
    340       JSValue* def = o->call(exec, thisObj, exec->emptyList());
     340      JSValue* def = o->call(exec, thisObj->toThisObject(exec), exec->emptyList());
    341341      JSType defType = def->type();
    342342      ASSERT(defType != GetterSetterType);
     
    418418    _prop.setHasGetterSetterProperties(true);
    419419    gs->setSetter(setterFunc);
     420}
     421
     422JSValue* JSObject::lookupGetter(ExecState*, const Identifier& propertyName)
     423{
     424    JSObject* obj = this;
     425    while (true) {
     426        JSValue* v = obj->getDirect(propertyName);
     427        if (v) {
     428            if (v->type() != GetterSetterType)
     429                return jsUndefined();
     430            JSObject* funcObj = static_cast<GetterSetterImp*>(v)->getGetter();
     431            if (!funcObj)
     432                return jsUndefined();
     433            return funcObj;
     434        }
     435
     436        if (!obj->prototype() || !obj->prototype()->isObject())
     437            return jsUndefined();
     438        obj = static_cast<JSObject*>(obj->prototype());
     439    }
     440}
     441
     442JSValue* JSObject::lookupSetter(ExecState*, const Identifier& propertyName)
     443{
     444    JSObject* obj = this;
     445    while (true) {
     446        JSValue* v = obj->getDirect(propertyName);
     447        if (v) {
     448            if (v->type() != GetterSetterType)
     449                return jsUndefined();
     450            JSObject* funcObj = static_cast<GetterSetterImp*>(v)->getSetter();
     451            if (!funcObj)
     452                return jsUndefined();
     453            return funcObj;
     454        }
     455
     456        if (!obj->prototype() || !obj->prototype()->isObject())
     457            return jsUndefined();
     458        obj = static_cast<JSObject*>(obj->prototype());
     459    }
    420460}
    421461
     
    546586}
    547587
     588JSObject* JSObject::toThisObject(ExecState*) const
     589{
     590    return const_cast<JSObject*>(this);
     591}
     592
     593JSGlobalObject* JSObject::toGlobalObject(ExecState*) const
     594{
     595    return 0;
     596}
     597
    548598void JSObject::putDirect(const Identifier &propertyName, JSValue *value, int attr)
    549599{
     
    571621    JSObject *getterFunc = gs->getGetter();
    572622    if (getterFunc)
    573         slot.setGetterSlot(this, getterFunc);
     623        slot.setGetterSlot(this->toThisObject(0), getterFunc);
    574624    else
    575625        slot.setUndefined(this);
  • trunk/JavaScriptCore/kjs/object.h

    r31225 r31746  
    403403    virtual UString toString(ExecState *exec) const;
    404404    virtual JSObject *toObject(ExecState *exec) const;
    405    
     405
     406    virtual JSObject* toThisObject(ExecState*) const;
     407    virtual JSGlobalObject* toGlobalObject(ExecState*) const;
     408
    406409    virtual bool getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const;
    407410   
     
    425428    void fillGetterPropertySlot(PropertySlot& slot, JSValue **location);
    426429
    427     void defineGetter(ExecState *exec, const Identifier& propertyName, JSObject *getterFunc);
    428     void defineSetter(ExecState *exec, const Identifier& propertyName, JSObject *setterFunc);
     430    virtual void defineGetter(ExecState*, const Identifier& propertyName, JSObject* getterFunction);
     431    virtual void defineSetter(ExecState*, const Identifier& propertyName, JSObject* setterFunction);
     432    virtual JSValue* lookupGetter(ExecState*, const Identifier& propertyName);
     433    virtual JSValue* lookupSetter(ExecState*, const Identifier& propertyName);
    429434
    430435    void saveProperties(SavedProperties &p) const { _prop.save(p); }
  • trunk/JavaScriptCore/kjs/object_object.cpp

    r31208 r31746  
    110110JSValue* objectProtoFuncLookupGetter(ExecState* exec, JSObject* thisObj, const List& args)
    111111{
    112     Identifier propertyName = Identifier(args[0]->toString(exec));
    113     JSObject* obj = thisObj;
    114     while (true) {
    115         JSValue* v = obj->getDirect(propertyName);
    116         if (v) {
    117             if (v->type() != GetterSetterType)
    118                 return jsUndefined();
    119             JSObject* funcObj = static_cast<GetterSetterImp*>(v)->getGetter();
    120             if (!funcObj)
    121                 return jsUndefined();
    122             return funcObj;
    123         }
    124 
    125         if (!obj->prototype() || !obj->prototype()->isObject())
    126             return jsUndefined();
    127         obj = static_cast<JSObject*>(obj->prototype());
    128     }
     112    return thisObj->lookupGetter(exec, Identifier(args[0]->toString(exec)));
    129113}
    130114
    131115JSValue* objectProtoFuncLookupSetter(ExecState* exec, JSObject* thisObj, const List& args)
    132116{
    133     Identifier propertyName = Identifier(args[0]->toString(exec));
    134     JSObject* obj = thisObj;
    135     while (true) {
    136         JSValue* v = obj->getDirect(propertyName);
    137         if (v) {
    138             if (v->type() != GetterSetterType)
    139                 return jsUndefined();
    140             JSObject* funcObj = static_cast<GetterSetterImp*>(v)->getSetter();
    141             if (!funcObj)
    142                 return jsUndefined();
    143             return funcObj;
    144         }
    145 
    146         if (!obj->prototype() || !obj->prototype()->isObject())
    147             return jsUndefined();
    148         obj = static_cast<JSObject*>(obj->prototype());
    149     }
     117    return thisObj->lookupSetter(exec, Identifier(args[0]->toString(exec)));
    150118}
    151119
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r30942 r31746  
    351351          args.append(sourceVal);
    352352
    353           substitutedReplacement = replacementFunction->call(exec, exec->dynamicGlobalObject(),
    354                                                              args)->toString(exec);
     353          substitutedReplacement = replacementFunction->call(exec, exec->globalThisValue(), args)->toString(exec);
    355354      } else
    356355          substitutedReplacement = substituteBackreferences(replacementString, source, ovector, reg);
     
    401400      args.append(sourceVal);
    402401     
    403       replacementString = replacementFunction->call(exec, exec->dynamicGlobalObject(),
    404                                                     args)->toString(exec);
     402      replacementString = replacementFunction->call(exec, exec->globalThisValue(), args)->toString(exec);
    405403  }
    406404
  • trunk/WebCore/ChangeLog

    r31745 r31746  
     12008-04-04  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        First step in implementing the "split window"
     6
     7        - This patch takes the first step in changing the window navigation model
     8          from clearing the window properties on navigation, to replacing
     9          an inner window.  This is necessary to safely perform security checks
     10          using the lexical global object.
     11
     12          This first step adds a new class called JSDOMWindowWrapper, which wraps
     13          the real window object.  All JS calls that would go to the window object
     14          now go to it, which it forwards to the current inner window.  To accomplish
     15          this, the wrapper window is used as the ThisValue wherever the window was used
     16          before.
     17
     18        * WebCore.base.exp:
     19        * WebCore.xcodeproj/project.pbxproj:
     20        * bindings/js/JSDOMWindowBase.cpp:
     21        (WebCore::JSDOMWindowBase::JSDOMWindowBase):
     22        (WebCore::JSDOMWindowBase::clear): Reset the wrapper windows prototype too.
     23        (WebCore::JSDOMWindowBase::toThisObject):
     24        (WebCore::JSDOMWindowBase::wrapper):
     25        (WebCore::windowProtoFuncAToB):
     26        (WebCore::windowProtoFuncBToA):
     27        (WebCore::windowProtoFuncOpen):
     28        (WebCore::windowProtoFuncSetTimeout):
     29        (WebCore::windowProtoFuncClearTimeout):
     30        (WebCore::windowProtoFuncSetInterval):
     31        (WebCore::windowProtoFuncAddEventListener):
     32        (WebCore::windowProtoFuncRemoveEventListener):
     33        (WebCore::windowProtoFuncShowModalDialog):
     34        (WebCore::windowProtoFuncNotImplemented):
     35        (WebCore::toJS):
     36        * bindings/js/JSDOMWindowBase.h:
     37        Fix to expect the wrapper as the thisObj.
     38        * bindings/js/JSDOMWindowCustom.cpp:
     39        (WebCore::JSDOMWindow::postMessage):
     40        (WebCore::toDOMWindow):
     41        * bindings/js/JSDOMWindowWrapper.cpp: Added.
     42        (WebCore::):
     43        (WebCore::JSDOMWindowWrapper::JSDOMWindowWrapper):
     44        (WebCore::JSDOMWindowWrapper::~JSDOMWindowWrapper):
     45        (WebCore::JSDOMWindowWrapper::mark):
     46        (WebCore::JSDOMWindowWrapper::className):
     47        (WebCore::JSDOMWindowWrapper::getOwnPropertySlot):
     48        (WebCore::JSDOMWindowWrapper::put):
     49        (WebCore::JSDOMWindowWrapper::deleteProperty):
     50        (WebCore::JSDOMWindowWrapper::getPropertyNames):
     51        (WebCore::JSDOMWindowWrapper::getPropertyAttributes):
     52        (WebCore::JSDOMWindowWrapper::defineGetter):
     53        (WebCore::JSDOMWindowWrapper::defineSetter):
     54        (WebCore::JSDOMWindowWrapper::lookupGetter):
     55        (WebCore::JSDOMWindowWrapper::lookupSetter):
     56        (WebCore::JSDOMWindowWrapper::toGlobalObject):
     57        (WebCore::JSDOMWindowWrapper::impl):
     58        (WebCore::JSDOMWindowWrapper::disconnectFrame):
     59        (WebCore::JSDOMWindowWrapper::clear):
     60        (WebCore::toJS):
     61        * bindings/js/JSDOMWindowWrapper.h: Added.
     62        (WebCore::JSDOMWindowWrapper::innerWindow):
     63        (WebCore::JSDOMWindowWrapper::setInnerWindow):
     64        (WebCore::JSDOMWindowWrapper::classInfo):
     65        Forward methods to the innerWindow.
     66        * bindings/js/JSHTMLDocumentCustom.cpp:
     67        (WebCore::JSHTMLDocument::open):
     68        * bindings/js/ScheduledAction.cpp:
     69        (WebCore::ScheduledAction::execute):
     70        * bindings/js/kjs_events.cpp:
     71        (WebCore::JSAbstractEventListener::handleEvent):
     72        * bindings/js/kjs_proxy.cpp:
     73        (WebCore::KJSProxy::~KJSProxy):
     74        (WebCore::KJSProxy::evaluate):
     75        (WebCore::KJSProxy::clear):
     76        (WebCore::KJSProxy::initScript):
     77        (WebCore::KJSProxy::clearDocumentWrapper):
     78        (WebCore::KJSProxy::processingUserGesture):
     79        (WebCore::KJSProxy::attachDebugger):
     80        * bindings/js/kjs_proxy.h:
     81        (WebCore::KJSProxy::haveWindowWrapper):
     82        (WebCore::KJSProxy::windowWrapper):
     83        (WebCore::KJSProxy::globalObject):
     84        (WebCore::KJSProxy::initScriptIfNeeded):
     85        Hold onto the wrapper window instead of global object.  As a convenience,
     86        keep the globalObject() as a forward to the inner window.
     87        * bindings/objc/DOMUtility.mm:
     88        (KJS::createDOMWrapper):
     89        * bindings/scripts/CodeGeneratorJS.pm:
     90        * dom/Document.cpp:
     91        (WebCore::Document::domWindow):
     92        * dom/Document.h:
     93        (WebCore::Document::defaultView):
     94        * loader/FrameLoader.cpp:
     95        (WebCore::FrameLoader::dispatchWindowObjectAvailable):
     96        * page/DOMWindow.idl:
     97        * page/Frame.cpp:
     98        (WebCore::Frame::~Frame):
     99        (WebCore::Frame::pageDestroyed):
     100
    11012008-04-08  Brady Eidson  <beidson@apple.com>
    2102
  • trunk/WebCore/GNUmakefile.am

    r31730 r31746  
    482482        WebCore/bindings/js/JSDOMWindowBase.cpp \
    483483        WebCore/bindings/js/JSDOMWindowCustom.cpp \
     484        WebCore/bindings/js/JSDOMWindowWrapper.cpp \
    484485        WebCore/bindings/js/JSElementCustom.cpp \
    485486        WebCore/bindings/js/JSEventCustom.cpp \
  • trunk/WebCore/WebCore.base.exp

    r31591 r31746  
    265265__ZN7WebCore13TypingCommand39insertParagraphSeparatorInQuotedContentEPNS_8DocumentE
    266266__ZN7WebCore13toDeviceSpaceERKNS_9FloatRectEP8NSWindow
     267__ZN7WebCore13toJSDOMWindowEPNS_5FrameE
    267268__ZN7WebCore14CachedResource5derefEPNS_20CachedResourceClientE
    268269__ZN7WebCore14DocumentLoader13attachToFrameEv
     
    790791__ZNK7WebCore7IntRectcv7_NSRectEv
    791792__ZNK7WebCore8Document11completeURLERKNS_6StringE
    792 __ZNK7WebCore8Document11defaultViewEv
    793793__ZNK7WebCore8Document13axObjectCacheEv
    794794__ZNK7WebCore8Document15documentElementEv
  • trunk/WebCore/WebCore.pro

    r31739 r31746  
    413413    bindings/js/JSDOMWindowBase.cpp \
    414414    bindings/js/JSDOMWindowCustom.cpp \
     415    bindings/js/JSDOMWindowWrapper.cpp \
    415416    bindings/js/JSElementCustom.cpp \
    416417    bindings/js/JSEventCustom.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r31744 r31746  
    1310613106                                </File>
    1310713107                                <File
     13108                                        RelativePath="..\bindings\js\JSDOMWindowWrapper.cpp"
     13109                                        >
     13110                                </File>
     13111                                <File
     13112                                        RelativePath="..\bindings\js\JSDOMWindowWrapper.h"
     13113                                        >
     13114                                </File>
     13115                                <File
    1310813116                                        RelativePath="..\bindings\js\JSElementCustom.cpp"
    1310913117                                        >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r31733 r31746  
    35523552                BC3452440D7E00EA0016574A /* JSRGBColor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3452420D7E00EA0016574A /* JSRGBColor.h */; };
    35533553                BC3452560D7E02850016574A /* JSRGBColor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3452550D7E02850016574A /* JSRGBColor.lut.h */; };
     3554                BC3A9E880DA2E18200A05E6A /* JSDOMWindowWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC3A9E860DA2E18200A05E6A /* JSDOMWindowWrapper.cpp */; };
     3555                BC3A9E890DA2E18200A05E6A /* JSDOMWindowWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3A9E870DA2E18200A05E6A /* JSDOMWindowWrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
    35543556                BC3C39B60C0D3D8D005F4D7A /* JSMediaList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */; };
    35553557                BC3C39B70C0D3D8D005F4D7A /* JSMediaList.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */; };
     
    78017803                BC3452420D7E00EA0016574A /* JSRGBColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRGBColor.h; sourceTree = "<group>"; };
    78027804                BC3452550D7E02850016574A /* JSRGBColor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRGBColor.lut.h; sourceTree = "<group>"; };
     7805                BC3A9E860DA2E18200A05E6A /* JSDOMWindowWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMWindowWrapper.cpp; sourceTree = "<group>"; };
     7806                BC3A9E870DA2E18200A05E6A /* JSDOMWindowWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMWindowWrapper.h; sourceTree = "<group>"; };
    78037807                BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaList.cpp; sourceTree = "<group>"; };
    78047808                BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSMediaList.h; sourceTree = "<group>"; };
     
    1189411898                                BC6932710D7E293900AE44D1 /* JSDOMWindowBase.cpp */,
    1189511899                                BC6932720D7E293900AE44D1 /* JSDOMWindowBase.h */,
     11900                                BC3A9E860DA2E18200A05E6A /* JSDOMWindowWrapper.cpp */,
     11901                                BC3A9E870DA2E18200A05E6A /* JSDOMWindowWrapper.h */,
    1189611902                                B25BE50E0D06B70800B524C6 /* JSEventTargetBase.cpp */,
    1189711903                                B25BE50F0D06B70800B524C6 /* JSEventTargetBase.h */,
     
    1475414760                                650FBF2B0D9AF047008FC292 /* SVGHKernElement.h in Headers */,
    1475514761                                37ACCE420DA2980F0089E602 /* FontRenderingMode.h in Headers */,
     14762                                BC3A9E890DA2E18200A05E6A /* JSDOMWindowWrapper.h in Headers */,
    1475614763                                51E0BABB0DA5547100A9E417 /* StorageEvent.h in Headers */,
    1475714764                                51E0BAEB0DA55D4A00A9E417 /* JSStorageEvent.h in Headers */,
     
    1641416421                                BCE1C43B0D9830D3003B02F2 /* JSLocation.cpp in Sources */,
    1641516422                                BCE1C4400D9830F4003B02F2 /* JSLocationCustom.cpp in Sources */,
     16423                                BC3A9E880DA2E18200A05E6A /* JSDOMWindowWrapper.cpp in Sources */,
    1641616424                                51E3F9C70DA059DC00250911 /* Storage.cpp in Sources */,
    1641716425                                51E3F9D60DA05E1D00250911 /* JSStorage.cpp in Sources */,
  • trunk/WebCore/WebCoreSources.bkl

    r31730 r31746  
    5252        bindings/js/JSDOMWindowBase.cpp
    5353        bindings/js/JSDOMWindowCustom.cpp
     54        bindings/js/JSDOMWindowWrapper.cpp
    5455        bindings/js/JSDocumentCustom.cpp
    5556        bindings/js/JSElementCustom.cpp
  • trunk/WebCore/bindings/js/JSDOMWindowBase.cpp

    r31341 r31746  
    193193
    194194JSDOMWindowBase::JSDOMWindowBase(JSObject* prototype, DOMWindow* window)
    195     : JSGlobalObject(prototype)
     195    : JSGlobalObject(prototype, window->frame()->scriptProxy()->windowWrapper())
    196196    , m_impl(window)
    197197    , d(new JSDOMWindowBasePrivate)
     
    214214    ListenersMap::iterator e2 = d->jsEventListeners.end();
    215215    for (; i2 != e2; ++i2)
    216         i2->second->clearWindowObj();
     216        i2->second->clearWindowWrapper();
    217217    i2 = d->jsHTMLEventListeners.begin();
    218218    e2 = d->jsHTMLEventListeners.end();
    219219    for (; i2 != e2; ++i2)
    220         i2->second->clearWindowObj();
     220        i2->second->clearWindowWrapper();
    221221
    222222    UnprotectedListenersMap::iterator i1 = d->jsUnprotectedEventListeners.begin();
    223223    UnprotectedListenersMap::iterator e1 = d->jsUnprotectedEventListeners.end();
    224224    for (; i1 != e1; ++i1)
    225         i1->second->clearWindowObj();
     225        i1->second->clearWindowWrapper();
    226226    i1 = d->jsUnprotectedHTMLEventListeners.begin();
    227227    e1 = d->jsUnprotectedHTMLEventListeners.end();
    228228    for (; i1 != e1; ++i1)
    229         i1->second->clearWindowObj();
     229        i1->second->clearWindowWrapper();
    230230}
    231231
     
    916916
    917917    // Note that the JSEventListener constructor adds it to our jsEventListeners list
    918     return new JSEventListener(object, toJSDOMWindow(this), html);
     918    return new JSEventListener(object, wrapper(), html);
    919919}
    920920
     
    938938
    939939    // The JSUnprotectedEventListener constructor adds it to our jsUnprotectedEventListeners map.
    940     return new JSUnprotectedEventListener(object, toJSDOMWindow(this), html);
     940    return new JSUnprotectedEventListener(object, wrapper(), html);
    941941}
    942942
     
    958958  // Now recreate a working global object for the next URL that will use us; but only if we haven't been
    959959  // disconnected yet
    960   if (Frame* frame = impl()->frame())
    961     frame->scriptProxy()->globalObject()->reset(JSDOMWindowPrototype::self());
     960  if (Frame* frame = impl()->frame()) {
     961    JSDOMWindowWrapper* wrapper = frame->scriptProxy()->windowWrapper();
     962    wrapper->window()->reset(JSDOMWindowPrototype::self());
     963
     964    // Set the prototype on the wrapper to point to it's window's prototype so resolving worksing correctly
     965    wrapper->setPrototype(wrapper->window()->prototype());
     966  }
    962967
    963968  // there's likely to be lots of garbage now
     
    975980}
    976981
     982JSObject* JSDOMWindowBase::toThisObject(ExecState*) const
     983{
     984    return wrapper();
     985}
     986
     987JSDOMWindowWrapper* JSDOMWindowBase::wrapper() const
     988{
     989    return impl()->frame()->scriptProxy()->windowWrapper();
     990}
     991
    977992JSValue* windowProtoFuncAToB(ExecState* exec, JSObject* thisObj, const List& args)
    978993{
    979     if (!thisObj->inherits(&JSDOMWindowBase::s_info))
     994    ASSERT(!thisObj->inherits(&JSDOMWindow::s_info));
     995    if (!thisObj->inherits(&JSDOMWindowWrapper::s_info))
    980996        return throwError(exec, TypeError);
    981     if (!static_cast<JSDOMWindowBase*>(thisObj)->allowsAccessFrom(exec))
     997    JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window();
     998    if (!window->allowsAccessFrom(exec))
    982999        return jsUndefined();
    9831000
     
    10081025JSValue* windowProtoFuncBToA(ExecState* exec, JSObject* thisObj, const List& args)
    10091026{
    1010     if (!thisObj->inherits(&JSDOMWindowBase::s_info))
     1027    ASSERT(!thisObj->inherits(&JSDOMWindow::s_info));
     1028    if (!thisObj->inherits(&JSDOMWindowWrapper::s_info))
    10111029        return throwError(exec, TypeError);
    1012     if (!static_cast<JSDOMWindowBase*>(thisObj)->allowsAccessFrom(exec))
     1030    JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window();
     1031    if (!window->allowsAccessFrom(exec))
    10131032        return jsUndefined();
    10141033
     
    10381057JSValue* windowProtoFuncOpen(ExecState* exec, JSObject* thisObj, const List& args)
    10391058{
    1040     if (!thisObj->inherits(&JSDOMWindowBase::s_info))
     1059    ASSERT(!thisObj->inherits(&JSDOMWindow::s_info));
     1060    if (!thisObj->inherits(&JSDOMWindowWrapper::s_info))
    10411061        return throwError(exec, TypeError);
    1042     JSDOMWindowBase* window = static_cast<JSDOMWindowBase*>(thisObj);
    1043     if (!window->allowsAccessFrom(exec)) 
     1062    JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window();
     1063    if (!window->allowsAccessFrom(exec))
    10441064        return jsUndefined();
    10451065
     
    11081128JSValue* windowProtoFuncSetTimeout(ExecState* exec, JSObject* thisObj, const List& args)
    11091129{
    1110     if (!thisObj->inherits(&JSDOMWindowBase::s_info))
     1130    ASSERT(!thisObj->inherits(&JSDOMWindow::s_info));
     1131    if (!thisObj->inherits(&JSDOMWindowWrapper::s_info))
    11111132        return throwError(exec, TypeError);
    1112     JSDOMWindowBase* window = static_cast<JSDOMWindowBase*>(thisObj);
    1113     if (!window->allowsAccessFrom(exec)) 
     1133    JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window();
     1134    if (!window->allowsAccessFrom(exec))
    11141135        return jsUndefined();
    11151136
     
    11291150{
    11301151    // Also the implementation for window.clearInterval()
    1131     if (!thisObj->inherits(&JSDOMWindowBase::s_info))
     1152    ASSERT(!thisObj->inherits(&JSDOMWindow::s_info));
     1153    if (!thisObj->inherits(&JSDOMWindowWrapper::s_info))
    11321154        return throwError(exec, TypeError);
    1133     JSDOMWindowBase* window = static_cast<JSDOMWindowBase*>(thisObj);
    1134     if (!window->allowsAccessFrom(exec)) 
     1155    JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window();
     1156    if (!window->allowsAccessFrom(exec))
    11351157        return jsUndefined();
    11361158
     
    11411163JSValue* windowProtoFuncSetInterval(ExecState* exec, JSObject* thisObj, const List& args)
    11421164{
    1143     if (!thisObj->inherits(&JSDOMWindowBase::s_info))
     1165    ASSERT(!thisObj->inherits(&JSDOMWindow::s_info));
     1166    if (!thisObj->inherits(&JSDOMWindowWrapper::s_info))
    11441167        return throwError(exec, TypeError);
    1145     JSDOMWindowBase* window = static_cast<JSDOMWindowBase*>(thisObj);
    1146     if (!window->allowsAccessFrom(exec)) 
     1168    JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window();
     1169    if (!window->allowsAccessFrom(exec))
    11471170        return jsUndefined();
    11481171
     
    11651188JSValue* windowProtoFuncAddEventListener(ExecState* exec, JSObject* thisObj, const List& args)
    11661189{
    1167     if (!thisObj->inherits(&JSDOMWindowBase::s_info))
     1190    ASSERT(!thisObj->inherits(&JSDOMWindow::s_info));
     1191    if (!thisObj->inherits(&JSDOMWindowWrapper::s_info))
    11681192        return throwError(exec, TypeError);
    1169     JSDOMWindowBase* window = static_cast<JSDOMWindowBase*>(thisObj);
    1170     if (!window->allowsAccessFrom(exec)) 
     1193    JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window();
     1194    if (!window->allowsAccessFrom(exec))
    11711195        return jsUndefined();
    11721196
     
    11851209JSValue* windowProtoFuncRemoveEventListener(ExecState* exec, JSObject* thisObj, const List& args)
    11861210{
    1187     if (!thisObj->inherits(&JSDOMWindowBase::s_info))
     1211    ASSERT(!thisObj->inherits(&JSDOMWindow::s_info));
     1212    if (!thisObj->inherits(&JSDOMWindowWrapper::s_info))
    11881213        return throwError(exec, TypeError);
    1189     JSDOMWindowBase* window = static_cast<JSDOMWindowBase*>(thisObj);
    1190     if (!window->allowsAccessFrom(exec)) 
     1214    JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window();
     1215    if (!window->allowsAccessFrom(exec))
    11911216        return jsUndefined();
    11921217
     
    12051230JSValue* windowProtoFuncShowModalDialog(ExecState* exec, JSObject* thisObj, const List& args)
    12061231{
    1207     if (!thisObj->inherits(&JSDOMWindowBase::s_info))
     1232    ASSERT(!thisObj->inherits(&JSDOMWindow::s_info));
     1233    if (!thisObj->inherits(&JSDOMWindowWrapper::s_info))
    12081234        return throwError(exec, TypeError);
    1209     JSDOMWindowBase* window = static_cast<JSDOMWindowBase*>(thisObj);
    1210     if (!window->allowsAccessFrom(exec)) 
     1235    JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window();
     1236    if (!window->allowsAccessFrom(exec))
    12111237        return jsUndefined();
    12121238
     
    12201246JSValue* windowProtoFuncNotImplemented(ExecState* exec, JSObject* thisObj, const List& args)
    12211247{
    1222     if (!thisObj->inherits(&JSDOMWindowBase::s_info))
     1248    ASSERT(!thisObj->inherits(&JSDOMWindow::s_info));
     1249    if (!thisObj->inherits(&JSDOMWindowWrapper::s_info))
    12231250        return throwError(exec, TypeError);
    1224 
    12251251    return jsUndefined();
    12261252}
     
    13331359        int timeoutId = timer->timeoutId();
    13341360
    1335         timer->action()->execute(toJSDOMWindow(this));
     1361        timer->action()->execute(wrapper());
    13361362        // The DOMWindowTimer object may have been deleted or replaced during execution,
    13371363        // so we re-fetch it.
     
    13521378    d->m_timeouts.remove(timer->timeoutId());
    13531379    delete timer;
    1354     action->execute(toJSDOMWindow(this));
     1380    action->execute(wrapper());
    13551381
    13561382    JSLock lock;
     
    13971423    if (!frame)
    13981424        return jsNull();
    1399 
    1400     // FIXME: is this check needed?
    1401     if (!frame->scriptProxy()->isEnabled())
    1402         return jsNull();
    1403 
    1404     return frame->scriptProxy()->globalObject();
     1425    return frame->scriptProxy()->windowWrapper();
    14051426}
    14061427
    14071428JSDOMWindow* toJSDOMWindow(Frame* frame)
    14081429{
    1409     if (!frame || !frame->scriptProxy()->isEnabled())
     1430    if (!frame)
    14101431        return 0;
    1411     return frame->scriptProxy()->globalObject();
     1432    return frame->scriptProxy()->windowWrapper()->window();
    14121433}
    14131434
  • trunk/WebCore/bindings/js/JSDOMWindowBase.h

    r31341 r31746  
    3535    class Frame;
    3636    class JSDOMWindow;
     37    class JSDOMWindowWrapper;
    3738    class JSEventListener;
    3839    class JSLocation;
     
    114115        virtual bool allowsAccessFrom(const KJS::JSGlobalObject*) const;
    115116
     117        virtual KJS::JSObject* toThisObject(KJS::ExecState*) const;
     118        JSDOMWindowWrapper* wrapper() const;
     119
    116120        enum {
    117121            // Attributes
  • trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r31697 r31746  
    2828#include "FrameLoader.h"
    2929#include "FrameTree.h"
     30#include "JSDOMWindowWrapper.h"
    3031#include "Settings.h"
    3132#include "kjs_proxy.h"
     
    201202{
    202203    DOMWindow* window = impl();
    203    
     204
    204205    DOMWindow* source = toJSDOMWindow(exec->dynamicGlobalObject())->impl();
    205206    String domain = source->frame()->loader()->url().host();
    206207    String uri = source->frame()->loader()->url().string();
    207208    String message = args[0]->toString(exec);
    208    
     209
    209210    if (exec->hadException())
    210211        return jsUndefined();
    211    
     212
    212213    window->postMessage(message, domain, uri, source);
    213    
     214
    214215    return jsUndefined();
    215216}
    216217#endif
    217218
     219DOMWindow* toDOMWindow(JSValue* val)
     220{
     221    if (val->isObject(&JSDOMWindow::s_info))
     222        return static_cast<JSDOMWindow*>(val)->impl();
     223    if (val->isObject(&JSDOMWindowWrapper::s_info))
     224        return static_cast<JSDOMWindowWrapper*>(val)->impl();
     225    return 0;
     226}
     227
    218228} // namespace WebCore
  • trunk/WebCore/bindings/js/JSDocumentCustom.cpp

    r31341 r31746  
    9494    // back/forward cache.
    9595    if (doc->frame())
    96         toJSDOMWindow(doc->frame())->putDirect("document", ret, DontDelete|ReadOnly);
     96        toJSDOMWindowWrapper(doc->frame())->window()->putDirect("document", ret, DontDelete|ReadOnly);
    9797    else {
    9898        size_t nodeCount = 0;
  • trunk/WebCore/bindings/js/JSHTMLDocumentCustom.cpp

    r31122 r31746  
    3535#include "HTMLNames.h"
    3636#include "JSDOMWindow.h"
     37#include "JSDOMWindowWrapper.h"
    3738#include "JSHTMLCollection.h"
    3839#include "kjs_html.h"
     
    6768        Frame* frame;
    6869        if (node->hasTagName(iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
    69             return toJSDOMWindow(frame);
     70            return toJS(exec, frame);
    7071
    7172        return toJS(exec, node);
     
    100101        Frame* frame = static_cast<HTMLDocument*>(impl())->frame();
    101102        if (frame) {
    102             JSDOMWindow* window = toJSDOMWindow(frame);
    103             if (window) {
    104                 JSObject* functionObject = window->get(exec, "open")->getObject();
     103            JSDOMWindowWrapper* wrapper = toJSDOMWindowWrapper(frame);
     104            if (wrapper) {
     105                JSObject* functionObject = wrapper->get(exec, "open")->getObject();
    105106                if (!functionObject || !functionObject->implementsCall())
    106107                    return throwError(exec, TypeError);
    107                 return functionObject->call(exec, window, args);
     108                return functionObject->call(exec, wrapper, args);
    108109            }
    109110        }
  • trunk/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp

    r30787 r31746  
    11/*
    2  * Copyright (C) 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3232#include "HTMLNames.h"
    3333#include "JSDOMWindow.h"
     34#include "JSDOMWindowWrapper.h"
    3435#include "kjs_binding.h"
     36
     37using namespace KJS;
    3538
    3639namespace WebCore {
    3740
    38 using namespace KJS;
    3941using namespace HTMLNames;
    4042
     
    5254    Node* frame = element->children()->namedItem(propertyName);
    5355    if (Document* doc = static_cast<HTMLFrameElement*>(frame)->contentDocument()) {
    54         if (JSDOMWindow* window = toJSDOMWindow(doc->frame()))
     56        if (JSDOMWindowWrapper* window = toJSDOMWindowWrapper(doc->frame()))
    5557            return window;
    5658    }
  • trunk/WebCore/bindings/js/JSSVGLazyEventListener.cpp

    r30731 r31746  
    2929namespace WebCore {
    3030
    31 JSSVGLazyEventListener::JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindow* win, Node* node, int lineNumber)
    32     : JSLazyEventListener(functionName, code, win, node, lineNumber)
     31JSSVGLazyEventListener::JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindowWrapper* windowWrapper, Node* node, int lineNumber)
     32    : JSLazyEventListener(functionName, code, windowWrapper, node, lineNumber)
    3333{
    3434}
  • trunk/WebCore/bindings/js/JSSVGLazyEventListener.h

    r30731 r31746  
    3030    class JSSVGLazyEventListener : public JSLazyEventListener {
    3131    public:
    32         JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindow*, Node*, int lineNumber = 0);
     32        JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindowWrapper*, Node*, int lineNumber = 0);
    3333
    3434    private:
  • trunk/WebCore/bindings/js/ScheduledAction.cpp

    r30787 r31746  
    4747
    4848
    49 void ScheduledAction::execute(JSDOMWindow* window)
     49void ScheduledAction::execute(JSDOMWindowWrapper* windowWrapper)
    5050{
    51     RefPtr<Frame> frame = window->impl()->frame();
     51    RefPtr<Frame> frame = windowWrapper->window()->impl()->frame();
    5252    if (!frame)
    5353        return;
     
    5757
    5858    KJSProxy* scriptProxy = frame->scriptProxy();
    59     JSDOMWindow* globalObject = scriptProxy->globalObject();
     59   
    6060
    6161    scriptProxy->setProcessingTimerCallback(true);
     
    6464        JSLock lock;
    6565        if (func->isObject() && static_cast<JSObject*>(func)->implementsCall()) {
     66            JSDOMWindow* window = windowWrapper->window();
    6667            ExecState* exec = window->globalExec();
    67             ASSERT(window == globalObject);
    6868
    6969            List args;
     
    7272                args.append(m_args[i]);
    7373
    74             globalObject->startTimeoutCheck();
    75             static_cast<JSObject*>(func)->call(exec, window, args);
    76             globalObject->stopTimeoutCheck();
     74            window->startTimeoutCheck();
     75            static_cast<JSObject*>(func)->call(exec, windowWrapper, args);
     76            window->stopTimeoutCheck();
    7777            if (exec->hadException()) {
    7878                JSObject* exception = exec->exception()->toObject(exec);
  • trunk/WebCore/bindings/js/ScheduledAction.h

    r30779 r31746  
    3232namespace WebCore {
    3333
    34     class JSDOMWindow;
     34    class JSDOMWindowWrapper;
    3535
    3636   /**
     
    4747        }
    4848
    49         void execute(JSDOMWindow*);
     49        void execute(JSDOMWindowWrapper*);
    5050
    5151    private:
  • trunk/WebCore/bindings/js/kjs_events.cpp

    r31197 r31746  
    5555        return;
    5656
    57     JSDOMWindow* window = windowObj();
    58     // Null check as clearWindowObj() can clear this and we still get called back by
     57    JSDOMWindowWrapper* windowWrapper = this->windowWrapper();
     58    // Null check as clearWindowWrapper() can clear this and we still get called back by
    5959    // xmlhttprequest objects. See http://bugs.webkit.org/show_bug.cgi?id=13275
    60     if (!window)
    61         return;
    62     Frame* frame = window->impl()->frame();
     60    if (!windowWrapper)
     61        return;
     62    Frame* frame = windowWrapper->window()->impl()->frame();
    6363    if (!frame)
    6464        return;
     
    6969    JSLock lock;
    7070
    71     JSGlobalObject* globalObject = scriptProxy->globalObject();
    72     ExecState* exec = globalObject->globalExec();
     71    ExecState* exec = windowWrapper->window()->globalExec();
    7372
    7473    JSValue* handleEventFuncValue = listener->get(exec, "handleEvent");
     
    8685        args.append(toJS(exec, event));
    8786
    88         window->setCurrentEvent(event);
     87        windowWrapper->window()->setCurrentEvent(event);
    8988
    9089        JSValue* retval;
    9190        if (handleEventFunc) {
    92             globalObject->startTimeoutCheck();
     91            windowWrapper->window()->startTimeoutCheck();
    9392            retval = handleEventFunc->call(exec, listener, args);
    9493        } else {
    9594            JSObject* thisObj;
    9695            if (isWindowEvent)
    97                 thisObj = window;
     96                thisObj = windowWrapper;
    9897            else
    9998                thisObj = static_cast<JSObject*>(toJS(exec, event->currentTarget()));
    100             globalObject->startTimeoutCheck();
     99            windowWrapper->window()->startTimeoutCheck();
    101100            retval = listener->call(exec, thisObj, args);
    102101        }
    103         globalObject->stopTimeoutCheck();
    104 
    105         window->setCurrentEvent(0);
     102        windowWrapper->window()->stopTimeoutCheck();
     103
     104        windowWrapper->window()->setCurrentEvent(0);
    106105
    107106        if (exec->hadException()) {
     
    137136// -------------------------------------------------------------------------
    138137
    139 JSUnprotectedEventListener::JSUnprotectedEventListener(JSObject* listener, JSDOMWindow* win, bool html)
     138JSUnprotectedEventListener::JSUnprotectedEventListener(JSObject* listener, JSDOMWindowWrapper* windowWrapper, bool html)
    140139    : JSAbstractEventListener(html)
    141140    , m_listener(listener)
    142     , m_win(win)
     141    , m_windowWrapper(windowWrapper)
    143142{
    144143    if (m_listener) {
    145144        JSDOMWindow::UnprotectedListenersMap& listeners = html
    146             ? m_win->jsUnprotectedHTMLEventListeners() : m_win->jsUnprotectedEventListeners();
     145            ? m_windowWrapper->window()->jsUnprotectedHTMLEventListeners() : m_windowWrapper->window()->jsUnprotectedEventListeners();
    147146        listeners.set(m_listener, this);
    148147    }
     
    151150JSUnprotectedEventListener::~JSUnprotectedEventListener()
    152151{
    153     if (m_listener && m_win) {
     152    if (m_listener && m_windowWrapper) {
    154153        JSDOMWindow::UnprotectedListenersMap& listeners = isHTMLEventListener()
    155             ? m_win->jsUnprotectedHTMLEventListeners() : m_win->jsUnprotectedEventListeners();
     154            ? m_windowWrapper->window()->jsUnprotectedHTMLEventListeners() : m_windowWrapper->window()->jsUnprotectedEventListeners();
    156155        listeners.remove(m_listener);
    157156    }
     
    163162}
    164163
    165 JSDOMWindow* JSUnprotectedEventListener::windowObj() const
    166 {
    167     return m_win;
    168 }
    169 
    170 void JSUnprotectedEventListener::clearWindowObj()
    171 {
    172     m_win = 0;
     164JSDOMWindowWrapper* JSUnprotectedEventListener::windowWrapper() const
     165{
     166    return m_windowWrapper;
     167}
     168
     169void JSUnprotectedEventListener::clearWindowWrapper()
     170{
     171    m_windowWrapper = 0;
    173172}
    174173
     
    199198// -------------------------------------------------------------------------
    200199
    201 JSEventListener::JSEventListener(JSObject* listener, JSDOMWindow* win, bool html)
     200JSEventListener::JSEventListener(JSObject* listener, JSDOMWindowWrapper* windowWrapper, bool html)
    202201    : JSAbstractEventListener(html)
    203202    , m_listener(listener)
    204     , m_win(win)
     203    , m_windowWrapper(windowWrapper)
    205204{
    206205    if (m_listener) {
    207206        JSDOMWindow::ListenersMap& listeners = html
    208             ? m_win->jsHTMLEventListeners() : m_win->jsEventListeners();
     207            ? m_windowWrapper->window()->jsHTMLEventListeners() : m_windowWrapper->window()->jsEventListeners();
    209208        listeners.set(m_listener, this);
    210209    }
     
    216215JSEventListener::~JSEventListener()
    217216{
    218     if (m_listener && m_win) {
     217    if (m_listener && m_windowWrapper) {
    219218        JSDOMWindow::ListenersMap& listeners = isHTMLEventListener()
    220             ? m_win->jsHTMLEventListeners() : m_win->jsEventListeners();
     219            ? m_windowWrapper->window()->jsHTMLEventListeners() : m_windowWrapper->window()->jsEventListeners();
    221220        listeners.remove(m_listener);
    222221    }
     
    231230}
    232231
    233 JSDOMWindow* JSEventListener::windowObj() const
    234 {
    235     return m_win;
    236 }
    237 
    238 void JSEventListener::clearWindowObj()
    239 {
    240     m_win = 0;
     232JSDOMWindowWrapper* JSEventListener::windowWrapper() const
     233{
     234    return m_windowWrapper;
     235}
     236
     237void JSEventListener::clearWindowWrapper()
     238{
     239    m_windowWrapper = 0;
    241240}
    242241
    243242// -------------------------------------------------------------------------
    244243
    245 JSLazyEventListener::JSLazyEventListener(const String& functionName, const String& code, JSDOMWindow* win, Node* node, int lineNumber)
    246     : JSEventListener(0, win, true)
     244JSLazyEventListener::JSLazyEventListener(const String& functionName, const String& code, JSDOMWindowWrapper* windowWrapper, Node* node, int lineNumber)
     245    : JSEventListener(0, windowWrapper, true)
    247246    , m_functionName(functionName)
    248247    , m_code(code)
     
    276275    m_parsed = true;
    277276
    278     Frame* frame = windowObj()->impl()->frame();
     277    Frame* frame = windowWrapper()->window()->impl()->frame();
    279278    if (frame && frame->scriptProxy()->isEnabled()) {
    280         ExecState* exec = frame->scriptProxy()->globalObject()->globalExec();
     279        ExecState* exec = windowWrapper()->window()->globalExec();
    281280
    282281        JSLock lock;
    283         JSObject* constr = frame->scriptProxy()->globalObject()->functionConstructor();
     282        JSObject* constr = windowWrapper()->window()->functionConstructor();
    284283        List args;
    285284
     
    315314    if (m_listener) {
    316315        JSDOMWindow::ListenersMap& listeners = isHTMLEventListener()
    317             ? windowObj()->jsHTMLEventListeners() : windowObj()->jsEventListeners();
     316            ? windowWrapper()->window()->jsHTMLEventListeners() : windowWrapper()->window()->jsEventListeners();
    318317        listeners.set(m_listener, const_cast<JSLazyEventListener*>(this));
    319318    }
  • trunk/WebCore/bindings/js/kjs_events.h

    r30735 r31746  
    2828
    2929    class Event;
    30     class JSDOMWindow;
     30    class JSDOMWindowWrapper;
    3131    class Node;
    3232
     
    3838        virtual bool isHTMLEventListener() const;
    3939        virtual KJS::JSObject* listenerObj() const = 0;
    40         virtual JSDOMWindow* windowObj() const = 0;
     40        virtual JSDOMWindowWrapper* windowWrapper() const = 0;
    4141
    4242    private:
     
    4646    class JSUnprotectedEventListener : public JSAbstractEventListener {
    4747    public:
    48         JSUnprotectedEventListener(KJS::JSObject* listener, JSDOMWindow*, bool html = false);
     48        JSUnprotectedEventListener(KJS::JSObject* listener, JSDOMWindowWrapper*, bool html = false);
    4949        virtual ~JSUnprotectedEventListener();
    5050
    5151        virtual KJS::JSObject* listenerObj() const;
    52         virtual JSDOMWindow* windowObj() const;
    53         void clearWindowObj();
     52        virtual JSDOMWindowWrapper* windowWrapper() const;
     53        void clearWindowWrapper();
    5454        void mark();
    5555
    5656    private:
    5757        KJS::JSObject* m_listener;
    58         JSDOMWindow* m_win;
     58        JSDOMWindowWrapper* m_windowWrapper;
    5959    };
    6060
    6161    class JSEventListener : public JSAbstractEventListener {
    6262    public:
    63         JSEventListener(KJS::JSObject* listener, JSDOMWindow*, bool html = false);
     63        JSEventListener(KJS::JSObject* listener, JSDOMWindowWrapper*, bool html = false);
    6464        virtual ~JSEventListener();
    6565
    6666        virtual KJS::JSObject* listenerObj() const;
    67         virtual JSDOMWindow* windowObj() const;
    68         void clearWindowObj();
     67        virtual JSDOMWindowWrapper* windowWrapper() const;
     68        void clearWindowWrapper();
    6969
    7070    protected:
     
    7272
    7373    private:
    74         KJS::ProtectedPtr<JSDOMWindow> m_win;
     74        KJS::ProtectedPtr<JSDOMWindowWrapper> m_windowWrapper;
    7575    };
    7676
    7777    class JSLazyEventListener : public JSEventListener {
    7878    public:
    79         JSLazyEventListener(const String& functionName, const String& code, JSDOMWindow*, Node*, int lineNumber = 0);
     79        JSLazyEventListener(const String& functionName, const String& code, JSDOMWindowWrapper*, Node*, int lineNumber = 0);
    8080        virtual KJS::JSObject* listenerObj() const;
    8181
  • trunk/WebCore/bindings/js/kjs_proxy.cpp

    r31267 r31746  
    5656KJSProxy::~KJSProxy()
    5757{
    58     if (m_globalObject) {
    59         m_globalObject = 0;
     58    if (m_windowWrapper) {
     59        m_windowWrapper = 0;
    6060   
    6161        // It's likely that releasing the global object has created a lot of garbage.
     
    7474    // expected value in all cases.
    7575    // See smart window.open policy for where this is used.
    76     ExecState* exec = m_globalObject->globalExec();
     76    ExecState* exec = m_windowWrapper->window()->globalExec();
    7777    m_processingInlineCode = filename.isNull();
    7878
     
    8383    m_frame->keepAlive();
    8484
    85     m_globalObject->startTimeoutCheck();
    86     Completion comp = Interpreter::evaluate(exec, filename, baseLine, str.characters(), str.length());
    87     m_globalObject->stopTimeoutCheck();
    88  
     85    m_windowWrapper->window()->startTimeoutCheck();
     86    Completion comp = Interpreter::evaluate(exec, filename, baseLine, str.characters(), str.length(), m_windowWrapper);
     87    m_windowWrapper->window()->stopTimeoutCheck();
     88
    8989    if (comp.complType() == Normal || comp.complType() == ReturnValue) {
    9090        m_processingInlineCode = false;
     
    109109    // We have to keep it, so that the Window object for the frame remains the same.
    110110    // (we used to delete and re-create it, previously)
    111     if (m_globalObject)
    112         m_globalObject->clear();
     111    if (m_windowWrapper)
     112        m_windowWrapper->clear();
    113113}
    114114
     
    117117    initScriptIfNeeded();
    118118    JSLock lock;
    119     return new JSLazyEventListener(functionName, code, toJSDOMWindow(m_frame), node, m_handlerLineno);
     119    return new JSLazyEventListener(functionName, code, m_windowWrapper, node, m_handlerLineno);
    120120}
    121121
     
    125125    initScriptIfNeeded();
    126126    JSLock lock;
    127     return new JSSVGLazyEventListener(functionName, code, toJSDOMWindow(m_frame), node, m_handlerLineno);
     127    return new JSSVGLazyEventListener(functionName, code, m_windowWrapper, node, m_handlerLineno);
    128128}
    129129#endif
     
    140140void KJSProxy::initScript()
    141141{
    142     if (m_globalObject)
     142    if (m_windowWrapper)
    143143        return;
    144144
    145145    JSLock lock;
    146146
    147     m_globalObject = new JSDOMWindow(m_frame->domWindow());
     147    m_windowWrapper = new JSDOMWindowWrapper();
     148    m_windowWrapper->setWindow(new JSDOMWindow(m_frame->domWindow()));
    148149
    149150    if (Page* page = m_frame->page())
     
    155156void KJSProxy::clearDocumentWrapper()
    156157{
    157     if (!m_globalObject)
     158    if (!m_windowWrapper)
    158159        return;
    159160
    160161    JSLock lock;
    161     m_globalObject->removeDirect("document");
     162    m_windowWrapper->window()->removeDirect("document");
    162163}
    163164
    164165bool KJSProxy::processingUserGesture() const
    165166{
    166     if (!m_globalObject)
     167    if (!m_windowWrapper)
    167168        return false;
    168169
    169     if (Event* event = m_globalObject->currentEvent()) {
     170    if (Event* event = m_windowWrapper->window()->currentEvent()) {
    170171        const AtomicString& type = event->type();
    171172        if ( // mouse events
     
    198199void KJSProxy::attachDebugger(KJS::Debugger* debugger)
    199200{
    200     if (!m_globalObject)
     201    if (!m_windowWrapper)
    201202        return;
    202203
    203204    if (debugger)
    204         debugger->attach(m_globalObject);
    205     else if (KJS::Debugger* currentDebugger = m_globalObject->debugger())
    206         currentDebugger->detach(m_globalObject);
     205        debugger->attach(m_windowWrapper->window());
     206    else if (KJS::Debugger* currentDebugger = m_windowWrapper->window()->debugger())
     207        currentDebugger->detach(m_windowWrapper->window());
    207208}
    208209
  • trunk/WebCore/bindings/js/kjs_proxy.h

    r31197 r31746  
    11/*
    2  *  This file is part of the KDE libraries
    32 *  Copyright (C) 1999 Harri Porten (porten@kde.org)
    43 *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
     4 *  Copyright (C) 2008 Apple Inc. All rights reserved.
    55 *
    66 *  This library is free software; you can redistribute it and/or
     
    2222#define kjs_proxy_h
    2323
    24 #include "JSDOMWindow.h"
     24#include "JSDOMWindowWrapper.h"
    2525#include <kjs/protect.h>
    2626#include <wtf/RefPtr.h>
     
    4646    ~KJSProxy();
    4747
    48     bool haveGlobalObject() const { return m_globalObject; }
     48    bool haveWindowWrapper() const { return m_windowWrapper; }
     49    JSDOMWindowWrapper* windowWrapper()
     50    {
     51        initScriptIfNeeded();
     52        return m_windowWrapper;
     53    }
     54
    4955    JSDOMWindow* globalObject()
    5056    {
    5157        initScriptIfNeeded();
    52         return m_globalObject;
     58        return m_windowWrapper->window();
    5359    }
    5460
     
    7783    void initScriptIfNeeded()
    7884    {
    79         if (!m_globalObject)
     85        if (!m_windowWrapper)
    8086            initScript();
    8187    }
    8288    void initScript();
    8389
    84     KJS::ProtectedPtr<JSDOMWindow> m_globalObject;
     90    KJS::ProtectedPtr<JSDOMWindowWrapper> m_windowWrapper;
    8591    Frame* m_frame;
    8692    int m_handlerLineno;
     
    9197};
    9298
    93 }
     99} // namespace WebCore
    94100
    95 #endif
     101#endif // kjs_proxy_h
  • trunk/WebCore/bindings/objc/DOMUtility.mm

    r31221 r31746  
    3636#import "JSDOMImplementation.h"
    3737#import "JSDOMWindow.h"
     38#import "JSDOMWindowWrapper.h"
    3839#import "JSEvent.h"
    3940#import "JSHTMLCollection.h"
     
    102103    if (object->inherits(&WebCore::JSDOMWindow::s_info))
    103104        return [DOMAbstractView _wrapAbstractView:static_cast<WebCore::JSDOMWindow*>(object)->impl()];
     105    if (object->inherits(&WebCore::JSDOMWindowWrapper::s_info))
     106        return [DOMAbstractView _wrapAbstractView:static_cast<WebCore::JSDOMWindowWrapper*>(object)->impl()];
     107
    104108    if (object->inherits(&WebCore::JSDOMImplementation::s_info))
    105109        return [DOMImplementation _wrapDOMImplementation:implementationFront(static_cast<WebCore::JSDOMImplementation*>(object))];
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r31745 r31746  
    11271127    if ($numFunctions > 0) {
    11281128        foreach my $function (@{$dataNode->functions}) {
     1129            AddIncludesForType($function->signature->type);
     1130
    11291131            my $functionName = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($function->signature->name);
    11301132            push(@implContent, "JSValue* ${functionName}(ExecState* exec, JSObject* thisObj, const List& args)\n");
    11311133            push(@implContent, "{\n");
    1132             push(@implContent, "    if (!thisObj->inherits(&${className}::s_info))\n");
    1133             push(@implContent, "        return throwError(exec, TypeError);\n");
    1134 
    1135             AddIncludesForType($function->signature->type);
    1136 
    1137             push(@implContent, "    $className* castedThisObj = static_cast<$className*>(thisObj);\n");
     1134
     1135            if ($interfaceName eq "DOMWindow") {
     1136                AddIncludesForType("JSDOMWindowWrapper");
     1137                push(@implContent, "    ASSERT(!thisObj->inherits(&JSDOMWindow::s_info));\n");
     1138                push(@implContent, "    if (!thisObj->inherits(&JSDOMWindowWrapper::s_info))\n");
     1139                push(@implContent, "        return throwError(exec, TypeError);\n");
     1140                push(@implContent, "    $className* castedThisObj = static_cast<JSDOMWindowWrapper*>(thisObj)->window();\n");
     1141            } else {
     1142                push(@implContent, "    if (!thisObj->inherits(&${className}::s_info))\n");
     1143                push(@implContent, "        return throwError(exec, TypeError);\n");
     1144                push(@implContent, "    $className* castedThisObj = static_cast<$className*>(thisObj);\n");
     1145            }
     1146
    11381147
    11391148            if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} &&
  • trunk/WebCore/dom/Document.cpp

    r31549 r31746  
    25282528}
    25292529
    2530 DOMWindow* Document::defaultView() const
     2530// FIXME: eventually, this should return a DOMWindow stored in the document.
     2531DOMWindow* Document::domWindow() const
    25312532{
    25322533    if (!frame())
    25332534        return 0;
    2534    
    25352535    return frame()->domWindow();
    25362536}
  • trunk/WebCore/dom/Document.h

    r31549 r31746  
    488488    void textNodeSplit(Text* oldNode);
    489489
    490     DOMWindow* defaultView() const;
     490    DOMWindow* defaultView() const { return domWindow(); }
     491    DOMWindow* domWindow() const;
     492
    491493    PassRefPtr<Event> createEvent(const String& eventType, ExceptionCode&);
    492494
  • trunk/WebCore/loader/FrameLoader.cpp

    r31697 r31746  
    47824782void FrameLoader::dispatchWindowObjectAvailable()
    47834783{
    4784     if (!m_frame->scriptProxy()->isEnabled() || !m_frame->scriptProxy()->haveGlobalObject())
     4784    if (!m_frame->scriptProxy()->isEnabled() || !m_frame->scriptProxy()->haveWindowWrapper())
    47854785        return;
    47864786
  • trunk/WebCore/page/DOMWindow.idl

    r31697 r31746  
    2828    interface [
    2929        CheckDomainSecurity,
     30        CustomNativeConverter,
    3031        CustomDeleteProperty,
    3132        CustomGetOwnPropertySlot,
  • trunk/WebCore/page/Frame.cpp

    r31160 r31746  
    5353#include "HTMLTableCellElement.h"
    5454#include "HitTestResult.h"
    55 #include "JSDOMWindow.h"
     55#include "JSDOMWindowWrapper.h"
    5656#include "Logging.h"
    5757#include "MediaFeatureNames.h"
     
    174174#endif
    175175
    176     if (d->m_jscript && d->m_jscript->haveGlobalObject())
    177         static_cast<JSDOMWindow*>(d->m_jscript->globalObject())->disconnectFrame();
     176    if (d->m_jscript && d->m_jscript->haveWindowWrapper())
     177        d->m_jscript->windowWrapper()->disconnectFrame();
    178178
    179179    disconnectOwnerElement();
     
    17051705
    17061706    // This will stop any JS timers
    1707     if (d->m_jscript && d->m_jscript->haveGlobalObject())
    1708         if (JSDOMWindow* w = toJSDOMWindow(this))
    1709             w->disconnectFrame();
     1707    if (d->m_jscript && d->m_jscript->haveWindowWrapper()) {
     1708        if (JSDOMWindowWrapper* windowWrapper = toJSDOMWindowWrapper(this))
     1709            windowWrapper->disconnectFrame();
     1710    }
    17101711
    17111712    clearScriptObjects();
  • trunk/WebCore/page/InspectorController.cpp

    r31743 r31746  
    418418
    419419    KJS::JSLock lock;
    420     JSValueRef documentValue = toRef(toJS(toJSDOMWindow(frame)->globalExec(), document));
     420    JSValueRef documentValue = toRef(toJS(toJSDOMWindowWrapper(frame)->window()->globalExec(), document));
    421421    return documentValue;
    422422}
     
    622622        return JSValueMakeUndefined(ctx);
    623623
    624     JSDOMWindow* window = toJSDOMWindow(controller->inspectedPage()->mainFrame());
    625     if (!window)
    626         return JSValueMakeNull(ctx);
    627 
    628     return toRef(window);
     624    return toRef(toJS(toJS(ctx), controller->inspectedPage()->mainFrame()));
    629625}
    630626
Note: See TracChangeset for help on using the changeset viewer.