Changeset 31746 in webkit
- Timestamp:
- Apr 8, 2008, 7:17:49 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 48 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSObjectRef.cpp
r30534 r31746 287 287 288 288 if (!jsThisObject) 289 jsThisObject = exec-> dynamicGlobalObject();290 289 jsThisObject = exec->globalThisValue(); 290 291 291 List argList; 292 292 for (size_t i = 0; i < argumentCount; i++) -
trunk/JavaScriptCore/ChangeLog
r31745 r31746 1 2008-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 1 80 2008-04-08 Brady Eidson <beidson@apple.com> 2 81 -
trunk/JavaScriptCore/JavaScriptCore.exp
r31738 r31746 122 122 __ZN3KJS14StringInstanceC1EPNS_8JSObjectERKNS_7UStringE 123 123 __ZN3KJS14StringInstanceC2EPNS_8JSObjectERKNS_7UStringE 124 __ZN3KJS15GlobalExecStateC1EPNS_14JSGlobalObjectE 124 __ZN3KJS15GlobalExecStateC1EPNS_14JSGlobalObjectEPNS_8JSObjectE 125 125 __ZN3KJS15JSWrapperObject4markEv 126 126 __ZN3KJS15SavedPropertiesC1Ev … … 169 169 __ZN3KJS8DebuggerD2Ev 170 170 __ZN3KJS8JSObject11hasInstanceEPNS_9ExecStateEPNS_7JSValueE 171 __ZN3KJS8JSObject12defineGetterEPNS_9ExecStateERKNS_10IdentifierEPS0_ 172 __ZN3KJS8JSObject12defineSetterEPNS_9ExecStateERKNS_10IdentifierEPS0_ 173 __ZN3KJS8JSObject12lookupGetterEPNS_9ExecStateERKNS_10IdentifierE 174 __ZN3KJS8JSObject12lookupSetterEPNS_9ExecStateERKNS_10IdentifierE 171 175 __ZN3KJS8JSObject12removeDirectERKNS_10IdentifierE 172 176 __ZN3KJS8JSObject14callAsFunctionEPNS_9ExecStateEPS0_RKNS_4ListE … … 231 235 __ZNK3KJS14JSGlobalObject12saveBuiltinsERNS_13SavedBuiltinsE 232 236 __ZNK3KJS14JSGlobalObject14isDynamicScopeEv 237 __ZNK3KJS14JSGlobalObject14toGlobalObjectEPNS_9ExecStateE 233 238 __ZNK3KJS16JSVariableObject16isVariableObjectEv 234 239 __ZNK3KJS16JSVariableObject16saveLocalStorageERNS_15SavedPropertiesE … … 258 263 __ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateEj 259 264 __ZNK3KJS8JSObject12defaultValueEPNS_9ExecStateENS_6JSTypeE 265 __ZNK3KJS8JSObject12toThisObjectEPNS_9ExecStateE 260 266 __ZNK3KJS8JSObject14implementsCallEv 267 __ZNK3KJS8JSObject14toGlobalObjectEPNS_9ExecStateE 261 268 __ZNK3KJS8JSObject19implementsConstructEv 262 269 __ZNK3KJS8JSObject21getPropertyAttributesERKNS_10IdentifierERj -
trunk/JavaScriptCore/kjs/Activation.h
r31136 r31746 67 67 static const ClassInfo info; 68 68 69 virtual JSObject* toThisObject(ExecState*) const; 70 69 71 virtual void mark(); 70 72 void markChildren(); -
trunk/JavaScriptCore/kjs/ExecState.cpp
r31267 r31746 43 43 44 44 // The constructor for the globalExec pseudo-ExecState 45 inline ExecState::ExecState(JSGlobalObject* globalObject )45 inline ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisObject) 46 46 : m_globalObject(globalObject) 47 47 , m_exception(0) … … 56 56 , m_inlineScopeChainNode(0, 0) 57 57 , m_variableObject(globalObject) 58 , m_thisValue(globalObject) 58 , m_thisValue(thisObject) 59 , m_globalThisValue(thisObject) 59 60 , m_iterationDepth(0) 60 61 , m_switchDepth(0) … … 78 79 , m_variableObject(globalObject) 79 80 , m_thisValue(thisObject) 81 , m_globalThisValue(thisObject) 80 82 , m_iterationDepth(0) 81 83 , m_switchDepth(0) … … 101 103 , m_variableObject(variableObject) 102 104 , m_thisValue(thisObject) 105 , m_globalThisValue(thisObject) 103 106 , m_iterationDepth(0) 104 107 , m_switchDepth(0) … … 116 119 } 117 120 118 GlobalExecState::GlobalExecState(JSGlobalObject* globalObject )119 : ExecState(globalObject )121 GlobalExecState::GlobalExecState(JSGlobalObject* globalObject, JSObject* thisObject) 122 : ExecState(globalObject, thisObject) 120 123 { 121 124 } -
trunk/JavaScriptCore/kjs/ExecState.h
r31172 r31746 74 74 75 75 JSObject* thisValue() const { return m_thisValue; } 76 JSObject* globalThisValue() const { return m_globalThisValue; } 76 77 77 78 ExecState* callingExecState() { return m_callingExec; } … … 165 166 166 167 protected: 167 ExecState(JSGlobalObject* );168 ExecState(JSGlobalObject*, JSObject* thisObject); 168 169 ExecState(JSGlobalObject*, JSObject* thisObject, ProgramNode*); 169 170 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); 171 172 ~ExecState(); 172 173 … … 191 192 ScopeChainNode m_inlineScopeChainNode; 192 193 JSVariableObject* m_variableObject; 194 193 195 JSObject* m_thisValue; 196 JSObject* m_globalThisValue; 194 197 195 198 LabelStack m_labelStack; … … 204 207 class GlobalExecState : public ExecState { 205 208 public: 206 GlobalExecState(JSGlobalObject* );209 GlobalExecState(JSGlobalObject*, JSObject* thisObject); 207 210 ~GlobalExecState(); 208 211 }; … … 222 225 class FunctionExecState : public ExecState { 223 226 public: 224 FunctionExecState(JSGlobalObject*, JSObject* thisObject, FunctionBodyNode*,227 FunctionExecState(JSGlobalObject*, JSObject* thisObject, JSObject* globalThisValue, FunctionBodyNode*, 225 228 ExecState* callingExecState, FunctionImp*, const List& args); 226 229 ~FunctionExecState(); -
trunk/JavaScriptCore/kjs/ExecStateInlines.h
r31205 r31746 31 31 namespace KJS { 32 32 33 inline ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisObject, 33 inline ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisObject, JSObject* globalThisValue, 34 34 FunctionBodyNode* functionBodyNode, ExecState* callingExec, 35 35 FunctionImp* func, const List& args) … … 45 45 , m_inlineScopeChainNode(0, 0) 46 46 , m_thisValue(thisObject) 47 , m_globalThisValue(globalThisValue) 47 48 , m_iterationDepth(0) 48 49 , m_switchDepth(0) … … 69 70 } 70 71 71 inline FunctionExecState::FunctionExecState(JSGlobalObject* globalObject, JSObject* thisObject, 72 inline FunctionExecState::FunctionExecState(JSGlobalObject* globalObject, JSObject* thisObject, JSObject* globalThisValue, 72 73 FunctionBodyNode* functionBodyNode, ExecState* callingExec, 73 74 FunctionImp* func, const List& args) 74 : ExecState(globalObject, thisObject, functionBodyNode, callingExec, func, args)75 : ExecState(globalObject, thisObject, globalThisValue, functionBodyNode, callingExec, func, args) 75 76 { 76 77 m_globalObject->activeExecStates().append(this); -
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r31226 r31746 328 328 // Set global functions. 329 329 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); 331 331 putDirectFunction(d()->evalFunction, DontEnum); 332 332 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 2, "parseInt", globalFuncParseInt), DontEnum); … … 535 535 } 536 536 537 JSGlobalObject* JSGlobalObject::toGlobalObject(ExecState*) const 538 { 539 return const_cast<JSGlobalObject*>(this); 540 } 541 537 542 ExecState* JSGlobalObject::globalExec() 538 543 { -
trunk/JavaScriptCore/kjs/JSGlobalObject.h
r31173 r31746 77 77 78 78 struct JSGlobalObjectData : public JSVariableObjectData { 79 JSGlobalObjectData(JSGlobalObject* globalObject )79 JSGlobalObjectData(JSGlobalObject* globalObject, JSObject* thisValue) 80 80 : JSVariableObjectData(&inlineSymbolTable) 81 , globalExec(globalObject )81 , globalExec(globalObject, thisValue) 82 82 { 83 83 } … … 142 142 public: 143 143 JSGlobalObject() 144 : JSVariableObject(new JSGlobalObjectData(this ))144 : JSVariableObject(new JSGlobalObjectData(this, this)) 145 145 { 146 146 init(); … … 148 148 149 149 protected: 150 JSGlobalObject(JSValue* proto )151 : JSVariableObject(proto, new JSGlobalObjectData(this ))150 JSGlobalObject(JSValue* proto, JSObject* globalThisValue) 151 : JSVariableObject(proto, new JSGlobalObjectData(this, globalThisValue)) 152 152 { 153 153 init(); … … 226 226 227 227 virtual bool isGlobalObject() const { return true; } 228 virtual JSGlobalObject* toGlobalObject(ExecState*) const; 228 229 229 230 virtual ExecState* globalExec(); -
trunk/JavaScriptCore/kjs/array_instance.cpp
r31343 r31746 24 24 #include "array_instance.h" 25 25 26 #include "JSGlobalObject.h"27 26 #include "PropertyNameArray.h" 28 27 #include <wtf/Assertions.h> … … 490 489 : exec(e) 491 490 , compareFunction(cf) 492 , global Object(e->dynamicGlobalObject())491 , globalThisValue(e->globalThisValue()) 493 492 { 494 493 } … … 497 496 JSObject *compareFunction; 498 497 List arguments; 499 JS GlobalObject* globalObject;498 JSObject* globalThisValue; 500 499 }; 501 500 … … 514 513 args->arguments.append(va); 515 514 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); 518 516 return compareResult < 0 ? -1 : compareResult > 0 ? 1 : 0; 519 517 } -
trunk/JavaScriptCore/kjs/array_object.cpp
r30041 r31746 405 405 l.append(jObj); 406 406 l.append(minObj); 407 compareResult = sortFunction->call(exec, exec-> dynamicGlobalObject(), l)->toNumber(exec);407 compareResult = sortFunction->call(exec, exec->globalThisValue(), l)->toNumber(exec); 408 408 } else 409 409 compareResult = (jObj->toString(exec) < minObj->toString(exec)) ? -1 : 1; … … 503 503 return throwError(exec, TypeError); 504 504 505 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec-> dynamicGlobalObject() : args[1]->toObject(exec);505 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec); 506 506 JSObject* resultArray = static_cast<JSObject*>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList())); 507 507 … … 536 536 return throwError(exec, TypeError); 537 537 538 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec-> dynamicGlobalObject() : args[1]->toObject(exec);538 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec); 539 539 540 540 unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); … … 576 576 return throwError(exec, TypeError); 577 577 578 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec-> dynamicGlobalObject() : args[1]->toObject(exec);578 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec); 579 579 580 580 JSValue* result = jsBoolean(true); … … 611 611 return throwError(exec, TypeError); 612 612 613 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec-> dynamicGlobalObject() : args[1]->toObject(exec);613 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec); 614 614 615 615 unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); … … 636 636 return throwError(exec, TypeError); 637 637 638 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec-> dynamicGlobalObject() : args[1]->toObject(exec);638 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec); 639 639 640 640 JSValue* result = jsBoolean(false); -
trunk/JavaScriptCore/kjs/function.cpp
r31173 r31746 74 74 JSValue* FunctionImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) 75 75 { 76 FunctionExecState newExec(exec->dynamicGlobalObject(), thisObj, body.get(), exec, this, args);76 FunctionExecState newExec(exec->dynamicGlobalObject(), thisObj, exec->globalThisValue(), body.get(), exec, this, args); 77 77 JSValue* result = body->execute(&newExec); 78 78 if (newExec.completionType() == ReturnValue) … … 465 465 // call instead of storing the list ourselves. 466 466 d()->argumentsObject = new Arguments(exec, d()->exec->function(), *d()->exec->arguments(), this); 467 } 468 469 JSObject* ActivationImp::toThisObject(ExecState* exec) const 470 { 471 return exec->globalThisValue(); 467 472 } 468 473 … … 739 744 JSValue* globalFuncEval(ExecState* exec, PrototypeReflexiveFunction* function, JSObject* thisObj, const List& args) 740 745 { 741 JSGlobalObject* globalObject = thisObj-> isGlobalObject() ? static_cast<JSGlobalObject*>(thisObj) : 0;746 JSGlobalObject* globalObject = thisObj->toGlobalObject(exec); 742 747 743 748 if (!globalObject || globalObject->evalFunction() != function) … … 745 750 746 751 ScopeChain scopeChain(globalObject); 747 return eval(exec, scopeChain, globalObject, globalObject, globalObject, args);752 return eval(exec, scopeChain, globalObject, globalObject, function->cachedGlobalObject()->toThisObject(exec), args); 748 753 } 749 754 … … 891 896 // ------------------------------ PrototypeReflexiveFunction ------------------------------- 892 897 893 PrototypeReflexiveFunction::PrototypeReflexiveFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, JSMemberFunction function )898 PrototypeReflexiveFunction::PrototypeReflexiveFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, JSMemberFunction function, JSGlobalObject* cachedGlobalObject) 894 899 : InternalFunctionImp(functionPrototype, name) 895 900 , m_function(function) 901 , m_cachedGlobalObject(cachedGlobalObject) 896 902 { 897 903 ASSERT_ARG(function, function); 904 ASSERT_ARG(cachedGlobalObject, cachedGlobalObject); 898 905 putDirect(exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum); 899 906 } … … 904 911 } 905 912 913 void PrototypeReflexiveFunction::mark() 914 { 915 InternalFunctionImp::mark(); 916 if (!m_cachedGlobalObject->marked()) 917 m_cachedGlobalObject->mark(); 918 } 919 906 920 } // namespace KJS -
trunk/JavaScriptCore/kjs/function.h
r30871 r31746 143 143 typedef JSValue* (*JSMemberFunction)(ExecState*, PrototypeReflexiveFunction*, JSObject* thisObj, const List&); 144 144 145 PrototypeReflexiveFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, JSMemberFunction );145 PrototypeReflexiveFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, JSMemberFunction, JSGlobalObject* expectedThisObject); 146 146 147 virtual void mark(); 147 148 virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List&); 149 150 JSGlobalObject* cachedGlobalObject() const { return m_cachedGlobalObject; } 148 151 149 152 private: 150 153 const JSMemberFunction m_function; 154 JSGlobalObject* m_cachedGlobalObject; 151 155 }; 152 156 -
trunk/JavaScriptCore/kjs/function_object.cpp
r31208 r31746 87 87 JSObject* applyThis; 88 88 if (thisArg->isUndefinedOrNull()) 89 applyThis = exec-> dynamicGlobalObject();89 applyThis = exec->globalThisValue(); 90 90 else 91 91 applyThis = thisArg->toObject(exec); … … 117 117 JSObject* callThis; 118 118 if (thisArg->isUndefinedOrNull()) 119 callThis = exec-> dynamicGlobalObject();119 callThis = exec->globalThisValue(); 120 120 else 121 121 callThis = thisArg->toObject(exec); -
trunk/JavaScriptCore/kjs/nodes.cpp
r31431 r31746 1123 1123 KJS_CHECKEXCEPTIONVALUE 1124 1124 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 provided1128 // by the caller is null, the global object should be used. It also says1129 // that the section does not apply to internal functions, but for simplicity1130 // of implementation we use the global object anyway here. This guarantees1131 // that in host objects you always get a valid object for this.1132 if (thisObj->isActivationObject())1133 thisObj = exec->dynamicGlobalObject();1134 1135 1125 if (callerType == EvalOperator) { 1136 1126 if (base == exec->lexicalGlobalObject() && func == exec->lexicalGlobalObject()->evalFunction()) { … … 1139 1129 } 1140 1130 } 1131 1132 JSObject* thisObj = base->toThisObject(exec); 1141 1133 return func->call(exec, thisObj, argList); 1142 1134 } … … 1183 1175 KJS_CHECKEXCEPTIONVALUE 1184 1176 1185 JSObject* thisObj = exec->dynamicGlobalObject(); 1186 1177 JSObject* thisObj = exec->globalThisValue(); 1187 1178 return func->call(exec, thisObj, argList); 1188 1179 } … … 1267 1258 KJS_CHECKEXCEPTIONVALUE 1268 1259 1269 return func->call(exec, exec->dynamicGlobalObject(), argList); 1260 JSObject* thisObj = exec->globalThisValue(); 1261 return func->call(exec, thisObj, argList); 1270 1262 } 1271 1263 … … 1319 1311 m_args->evaluateList(exec, argList); 1320 1312 KJS_CHECKEXCEPTIONVALUE 1321 1322 return func->call(exec, exec->dynamicGlobalObject(), argList); 1313 1314 JSObject* thisObj = exec->globalThisValue(); 1315 return func->call(exec, thisObj, argList); 1323 1316 } 1324 1317 … … 1449 1442 ASSERT(!thisObj->isActivationObject()); 1450 1443 1444 // No need to call toThisObject() on the thisObj as it is known not to be the GlobalObject or ActivationObject 1451 1445 return func->call(exec, thisObj, argList); 1452 1446 } … … 1498 1492 ASSERT(!thisObj->isActivationObject()); 1499 1493 1494 // No need to call toThisObject() on the thisObj as it is known not to be the GlobalObject or ActivationObject 1500 1495 return func->call(exec, thisObj, argList); 1501 1496 } -
trunk/JavaScriptCore/kjs/object.cpp
r31147 r31746 94 94 #endif 95 95 96 JSValue *ret = callAsFunction(exec,thisObj,args);96 JSValue* ret = callAsFunction(exec, thisObj, args); 97 97 98 98 #if KJS_MAX_STACK > 0 … … 262 262 args.append(value); 263 263 264 setterFunc->call(exec, this , args);264 setterFunc->call(exec, this->toThisObject(exec), args); 265 265 return; 266 266 } else { … … 338 338 if (o->implementsCall()) { // spec says "not primitive type" but ... 339 339 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()); 341 341 JSType defType = def->type(); 342 342 ASSERT(defType != GetterSetterType); … … 418 418 _prop.setHasGetterSetterProperties(true); 419 419 gs->setSetter(setterFunc); 420 } 421 422 JSValue* 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 442 JSValue* 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 } 420 460 } 421 461 … … 546 586 } 547 587 588 JSObject* JSObject::toThisObject(ExecState*) const 589 { 590 return const_cast<JSObject*>(this); 591 } 592 593 JSGlobalObject* JSObject::toGlobalObject(ExecState*) const 594 { 595 return 0; 596 } 597 548 598 void JSObject::putDirect(const Identifier &propertyName, JSValue *value, int attr) 549 599 { … … 571 621 JSObject *getterFunc = gs->getGetter(); 572 622 if (getterFunc) 573 slot.setGetterSlot(this , getterFunc);623 slot.setGetterSlot(this->toThisObject(0), getterFunc); 574 624 else 575 625 slot.setUndefined(this); -
trunk/JavaScriptCore/kjs/object.h
r31225 r31746 403 403 virtual UString toString(ExecState *exec) const; 404 404 virtual JSObject *toObject(ExecState *exec) const; 405 405 406 virtual JSObject* toThisObject(ExecState*) const; 407 virtual JSGlobalObject* toGlobalObject(ExecState*) const; 408 406 409 virtual bool getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const; 407 410 … … 425 428 void fillGetterPropertySlot(PropertySlot& slot, JSValue **location); 426 429 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); 429 434 430 435 void saveProperties(SavedProperties &p) const { _prop.save(p); } -
trunk/JavaScriptCore/kjs/object_object.cpp
r31208 r31746 110 110 JSValue* objectProtoFuncLookupGetter(ExecState* exec, JSObject* thisObj, const List& args) 111 111 { 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))); 129 113 } 130 114 131 115 JSValue* objectProtoFuncLookupSetter(ExecState* exec, JSObject* thisObj, const List& args) 132 116 { 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))); 150 118 } 151 119 -
trunk/JavaScriptCore/kjs/string_object.cpp
r30942 r31746 351 351 args.append(sourceVal); 352 352 353 substitutedReplacement = replacementFunction->call(exec, exec->dynamicGlobalObject(), 354 args)->toString(exec); 353 substitutedReplacement = replacementFunction->call(exec, exec->globalThisValue(), args)->toString(exec); 355 354 } else 356 355 substitutedReplacement = substituteBackreferences(replacementString, source, ovector, reg); … … 401 400 args.append(sourceVal); 402 401 403 replacementString = replacementFunction->call(exec, exec->dynamicGlobalObject(), 404 args)->toString(exec); 402 replacementString = replacementFunction->call(exec, exec->globalThisValue(), args)->toString(exec); 405 403 } 406 404 -
trunk/WebCore/ChangeLog
r31745 r31746 1 2008-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 1 101 2008-04-08 Brady Eidson <beidson@apple.com> 2 102 -
trunk/WebCore/GNUmakefile.am
r31730 r31746 482 482 WebCore/bindings/js/JSDOMWindowBase.cpp \ 483 483 WebCore/bindings/js/JSDOMWindowCustom.cpp \ 484 WebCore/bindings/js/JSDOMWindowWrapper.cpp \ 484 485 WebCore/bindings/js/JSElementCustom.cpp \ 485 486 WebCore/bindings/js/JSEventCustom.cpp \ -
trunk/WebCore/WebCore.base.exp
r31591 r31746 265 265 __ZN7WebCore13TypingCommand39insertParagraphSeparatorInQuotedContentEPNS_8DocumentE 266 266 __ZN7WebCore13toDeviceSpaceERKNS_9FloatRectEP8NSWindow 267 __ZN7WebCore13toJSDOMWindowEPNS_5FrameE 267 268 __ZN7WebCore14CachedResource5derefEPNS_20CachedResourceClientE 268 269 __ZN7WebCore14DocumentLoader13attachToFrameEv … … 790 791 __ZNK7WebCore7IntRectcv7_NSRectEv 791 792 __ZNK7WebCore8Document11completeURLERKNS_6StringE 792 __ZNK7WebCore8Document11defaultViewEv793 793 __ZNK7WebCore8Document13axObjectCacheEv 794 794 __ZNK7WebCore8Document15documentElementEv -
trunk/WebCore/WebCore.pro
r31739 r31746 413 413 bindings/js/JSDOMWindowBase.cpp \ 414 414 bindings/js/JSDOMWindowCustom.cpp \ 415 bindings/js/JSDOMWindowWrapper.cpp \ 415 416 bindings/js/JSElementCustom.cpp \ 416 417 bindings/js/JSEventCustom.cpp \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r31744 r31746 13106 13106 </File> 13107 13107 <File 13108 RelativePath="..\bindings\js\JSDOMWindowWrapper.cpp" 13109 > 13110 </File> 13111 <File 13112 RelativePath="..\bindings\js\JSDOMWindowWrapper.h" 13113 > 13114 </File> 13115 <File 13108 13116 RelativePath="..\bindings\js\JSElementCustom.cpp" 13109 13117 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r31733 r31746 3552 3552 BC3452440D7E00EA0016574A /* JSRGBColor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3452420D7E00EA0016574A /* JSRGBColor.h */; }; 3553 3553 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, ); }; }; 3554 3556 BC3C39B60C0D3D8D005F4D7A /* JSMediaList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */; }; 3555 3557 BC3C39B70C0D3D8D005F4D7A /* JSMediaList.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */; }; … … 7801 7803 BC3452420D7E00EA0016574A /* JSRGBColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRGBColor.h; sourceTree = "<group>"; }; 7802 7804 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>"; }; 7803 7807 BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaList.cpp; sourceTree = "<group>"; }; 7804 7808 BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSMediaList.h; sourceTree = "<group>"; }; … … 11894 11898 BC6932710D7E293900AE44D1 /* JSDOMWindowBase.cpp */, 11895 11899 BC6932720D7E293900AE44D1 /* JSDOMWindowBase.h */, 11900 BC3A9E860DA2E18200A05E6A /* JSDOMWindowWrapper.cpp */, 11901 BC3A9E870DA2E18200A05E6A /* JSDOMWindowWrapper.h */, 11896 11902 B25BE50E0D06B70800B524C6 /* JSEventTargetBase.cpp */, 11897 11903 B25BE50F0D06B70800B524C6 /* JSEventTargetBase.h */, … … 14754 14760 650FBF2B0D9AF047008FC292 /* SVGHKernElement.h in Headers */, 14755 14761 37ACCE420DA2980F0089E602 /* FontRenderingMode.h in Headers */, 14762 BC3A9E890DA2E18200A05E6A /* JSDOMWindowWrapper.h in Headers */, 14756 14763 51E0BABB0DA5547100A9E417 /* StorageEvent.h in Headers */, 14757 14764 51E0BAEB0DA55D4A00A9E417 /* JSStorageEvent.h in Headers */, … … 16414 16421 BCE1C43B0D9830D3003B02F2 /* JSLocation.cpp in Sources */, 16415 16422 BCE1C4400D9830F4003B02F2 /* JSLocationCustom.cpp in Sources */, 16423 BC3A9E880DA2E18200A05E6A /* JSDOMWindowWrapper.cpp in Sources */, 16416 16424 51E3F9C70DA059DC00250911 /* Storage.cpp in Sources */, 16417 16425 51E3F9D60DA05E1D00250911 /* JSStorage.cpp in Sources */, -
trunk/WebCore/WebCoreSources.bkl
r31730 r31746 52 52 bindings/js/JSDOMWindowBase.cpp 53 53 bindings/js/JSDOMWindowCustom.cpp 54 bindings/js/JSDOMWindowWrapper.cpp 54 55 bindings/js/JSDocumentCustom.cpp 55 56 bindings/js/JSElementCustom.cpp -
trunk/WebCore/bindings/js/JSDOMWindowBase.cpp
r31341 r31746 193 193 194 194 JSDOMWindowBase::JSDOMWindowBase(JSObject* prototype, DOMWindow* window) 195 : JSGlobalObject(prototype )195 : JSGlobalObject(prototype, window->frame()->scriptProxy()->windowWrapper()) 196 196 , m_impl(window) 197 197 , d(new JSDOMWindowBasePrivate) … … 214 214 ListenersMap::iterator e2 = d->jsEventListeners.end(); 215 215 for (; i2 != e2; ++i2) 216 i2->second->clearWindow Obj();216 i2->second->clearWindowWrapper(); 217 217 i2 = d->jsHTMLEventListeners.begin(); 218 218 e2 = d->jsHTMLEventListeners.end(); 219 219 for (; i2 != e2; ++i2) 220 i2->second->clearWindow Obj();220 i2->second->clearWindowWrapper(); 221 221 222 222 UnprotectedListenersMap::iterator i1 = d->jsUnprotectedEventListeners.begin(); 223 223 UnprotectedListenersMap::iterator e1 = d->jsUnprotectedEventListeners.end(); 224 224 for (; i1 != e1; ++i1) 225 i1->second->clearWindow Obj();225 i1->second->clearWindowWrapper(); 226 226 i1 = d->jsUnprotectedHTMLEventListeners.begin(); 227 227 e1 = d->jsUnprotectedHTMLEventListeners.end(); 228 228 for (; i1 != e1; ++i1) 229 i1->second->clearWindow Obj();229 i1->second->clearWindowWrapper(); 230 230 } 231 231 … … 916 916 917 917 // 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); 919 919 } 920 920 … … 938 938 939 939 // The JSUnprotectedEventListener constructor adds it to our jsUnprotectedEventListeners map. 940 return new JSUnprotectedEventListener(object, toJSDOMWindow(this), html);940 return new JSUnprotectedEventListener(object, wrapper(), html); 941 941 } 942 942 … … 958 958 // Now recreate a working global object for the next URL that will use us; but only if we haven't been 959 959 // 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 } 962 967 963 968 // there's likely to be lots of garbage now … … 975 980 } 976 981 982 JSObject* JSDOMWindowBase::toThisObject(ExecState*) const 983 { 984 return wrapper(); 985 } 986 987 JSDOMWindowWrapper* JSDOMWindowBase::wrapper() const 988 { 989 return impl()->frame()->scriptProxy()->windowWrapper(); 990 } 991 977 992 JSValue* windowProtoFuncAToB(ExecState* exec, JSObject* thisObj, const List& args) 978 993 { 979 if (!thisObj->inherits(&JSDOMWindowBase::s_info)) 994 ASSERT(!thisObj->inherits(&JSDOMWindow::s_info)); 995 if (!thisObj->inherits(&JSDOMWindowWrapper::s_info)) 980 996 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)) 982 999 return jsUndefined(); 983 1000 … … 1008 1025 JSValue* windowProtoFuncBToA(ExecState* exec, JSObject* thisObj, const List& args) 1009 1026 { 1010 if (!thisObj->inherits(&JSDOMWindowBase::s_info)) 1027 ASSERT(!thisObj->inherits(&JSDOMWindow::s_info)); 1028 if (!thisObj->inherits(&JSDOMWindowWrapper::s_info)) 1011 1029 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)) 1013 1032 return jsUndefined(); 1014 1033 … … 1038 1057 JSValue* windowProtoFuncOpen(ExecState* exec, JSObject* thisObj, const List& args) 1039 1058 { 1040 if (!thisObj->inherits(&JSDOMWindowBase::s_info)) 1059 ASSERT(!thisObj->inherits(&JSDOMWindow::s_info)); 1060 if (!thisObj->inherits(&JSDOMWindowWrapper::s_info)) 1041 1061 return throwError(exec, TypeError); 1042 JSDOMWindow Base* window = static_cast<JSDOMWindowBase*>(thisObj);1043 if (!window->allowsAccessFrom(exec)) 1062 JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window(); 1063 if (!window->allowsAccessFrom(exec)) 1044 1064 return jsUndefined(); 1045 1065 … … 1108 1128 JSValue* windowProtoFuncSetTimeout(ExecState* exec, JSObject* thisObj, const List& args) 1109 1129 { 1110 if (!thisObj->inherits(&JSDOMWindowBase::s_info)) 1130 ASSERT(!thisObj->inherits(&JSDOMWindow::s_info)); 1131 if (!thisObj->inherits(&JSDOMWindowWrapper::s_info)) 1111 1132 return throwError(exec, TypeError); 1112 JSDOMWindow Base* window = static_cast<JSDOMWindowBase*>(thisObj);1113 if (!window->allowsAccessFrom(exec)) 1133 JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window(); 1134 if (!window->allowsAccessFrom(exec)) 1114 1135 return jsUndefined(); 1115 1136 … … 1129 1150 { 1130 1151 // 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)) 1132 1154 return throwError(exec, TypeError); 1133 JSDOMWindow Base* window = static_cast<JSDOMWindowBase*>(thisObj);1134 if (!window->allowsAccessFrom(exec)) 1155 JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window(); 1156 if (!window->allowsAccessFrom(exec)) 1135 1157 return jsUndefined(); 1136 1158 … … 1141 1163 JSValue* windowProtoFuncSetInterval(ExecState* exec, JSObject* thisObj, const List& args) 1142 1164 { 1143 if (!thisObj->inherits(&JSDOMWindowBase::s_info)) 1165 ASSERT(!thisObj->inherits(&JSDOMWindow::s_info)); 1166 if (!thisObj->inherits(&JSDOMWindowWrapper::s_info)) 1144 1167 return throwError(exec, TypeError); 1145 JSDOMWindow Base* window = static_cast<JSDOMWindowBase*>(thisObj);1146 if (!window->allowsAccessFrom(exec)) 1168 JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window(); 1169 if (!window->allowsAccessFrom(exec)) 1147 1170 return jsUndefined(); 1148 1171 … … 1165 1188 JSValue* windowProtoFuncAddEventListener(ExecState* exec, JSObject* thisObj, const List& args) 1166 1189 { 1167 if (!thisObj->inherits(&JSDOMWindowBase::s_info)) 1190 ASSERT(!thisObj->inherits(&JSDOMWindow::s_info)); 1191 if (!thisObj->inherits(&JSDOMWindowWrapper::s_info)) 1168 1192 return throwError(exec, TypeError); 1169 JSDOMWindow Base* window = static_cast<JSDOMWindowBase*>(thisObj);1170 if (!window->allowsAccessFrom(exec)) 1193 JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window(); 1194 if (!window->allowsAccessFrom(exec)) 1171 1195 return jsUndefined(); 1172 1196 … … 1185 1209 JSValue* windowProtoFuncRemoveEventListener(ExecState* exec, JSObject* thisObj, const List& args) 1186 1210 { 1187 if (!thisObj->inherits(&JSDOMWindowBase::s_info)) 1211 ASSERT(!thisObj->inherits(&JSDOMWindow::s_info)); 1212 if (!thisObj->inherits(&JSDOMWindowWrapper::s_info)) 1188 1213 return throwError(exec, TypeError); 1189 JSDOMWindow Base* window = static_cast<JSDOMWindowBase*>(thisObj);1190 if (!window->allowsAccessFrom(exec)) 1214 JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window(); 1215 if (!window->allowsAccessFrom(exec)) 1191 1216 return jsUndefined(); 1192 1217 … … 1205 1230 JSValue* windowProtoFuncShowModalDialog(ExecState* exec, JSObject* thisObj, const List& args) 1206 1231 { 1207 if (!thisObj->inherits(&JSDOMWindowBase::s_info)) 1232 ASSERT(!thisObj->inherits(&JSDOMWindow::s_info)); 1233 if (!thisObj->inherits(&JSDOMWindowWrapper::s_info)) 1208 1234 return throwError(exec, TypeError); 1209 JSDOMWindow Base* window = static_cast<JSDOMWindowBase*>(thisObj);1210 if (!window->allowsAccessFrom(exec)) 1235 JSDOMWindow* window = static_cast<JSDOMWindowWrapper*>(thisObj)->window(); 1236 if (!window->allowsAccessFrom(exec)) 1211 1237 return jsUndefined(); 1212 1238 … … 1220 1246 JSValue* windowProtoFuncNotImplemented(ExecState* exec, JSObject* thisObj, const List& args) 1221 1247 { 1222 if (!thisObj->inherits(&JSDOMWindowBase::s_info)) 1248 ASSERT(!thisObj->inherits(&JSDOMWindow::s_info)); 1249 if (!thisObj->inherits(&JSDOMWindowWrapper::s_info)) 1223 1250 return throwError(exec, TypeError); 1224 1225 1251 return jsUndefined(); 1226 1252 } … … 1333 1359 int timeoutId = timer->timeoutId(); 1334 1360 1335 timer->action()->execute( toJSDOMWindow(this));1361 timer->action()->execute(wrapper()); 1336 1362 // The DOMWindowTimer object may have been deleted or replaced during execution, 1337 1363 // so we re-fetch it. … … 1352 1378 d->m_timeouts.remove(timer->timeoutId()); 1353 1379 delete timer; 1354 action->execute( toJSDOMWindow(this));1380 action->execute(wrapper()); 1355 1381 1356 1382 JSLock lock; … … 1397 1423 if (!frame) 1398 1424 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(); 1405 1426 } 1406 1427 1407 1428 JSDOMWindow* toJSDOMWindow(Frame* frame) 1408 1429 { 1409 if (!frame || !frame->scriptProxy()->isEnabled())1430 if (!frame) 1410 1431 return 0; 1411 return frame->scriptProxy()-> globalObject();1432 return frame->scriptProxy()->windowWrapper()->window(); 1412 1433 } 1413 1434 -
trunk/WebCore/bindings/js/JSDOMWindowBase.h
r31341 r31746 35 35 class Frame; 36 36 class JSDOMWindow; 37 class JSDOMWindowWrapper; 37 38 class JSEventListener; 38 39 class JSLocation; … … 114 115 virtual bool allowsAccessFrom(const KJS::JSGlobalObject*) const; 115 116 117 virtual KJS::JSObject* toThisObject(KJS::ExecState*) const; 118 JSDOMWindowWrapper* wrapper() const; 119 116 120 enum { 117 121 // Attributes -
trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp
r31697 r31746 28 28 #include "FrameLoader.h" 29 29 #include "FrameTree.h" 30 #include "JSDOMWindowWrapper.h" 30 31 #include "Settings.h" 31 32 #include "kjs_proxy.h" … … 201 202 { 202 203 DOMWindow* window = impl(); 203 204 204 205 DOMWindow* source = toJSDOMWindow(exec->dynamicGlobalObject())->impl(); 205 206 String domain = source->frame()->loader()->url().host(); 206 207 String uri = source->frame()->loader()->url().string(); 207 208 String message = args[0]->toString(exec); 208 209 209 210 if (exec->hadException()) 210 211 return jsUndefined(); 211 212 212 213 window->postMessage(message, domain, uri, source); 213 214 214 215 return jsUndefined(); 215 216 } 216 217 #endif 217 218 219 DOMWindow* 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 218 228 } // namespace WebCore -
trunk/WebCore/bindings/js/JSDocumentCustom.cpp
r31341 r31746 94 94 // back/forward cache. 95 95 if (doc->frame()) 96 toJSDOMWindow (doc->frame())->putDirect("document", ret, DontDelete|ReadOnly);96 toJSDOMWindowWrapper(doc->frame())->window()->putDirect("document", ret, DontDelete|ReadOnly); 97 97 else { 98 98 size_t nodeCount = 0; -
trunk/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
r31122 r31746 35 35 #include "HTMLNames.h" 36 36 #include "JSDOMWindow.h" 37 #include "JSDOMWindowWrapper.h" 37 38 #include "JSHTMLCollection.h" 38 39 #include "kjs_html.h" … … 67 68 Frame* frame; 68 69 if (node->hasTagName(iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame())) 69 return toJS DOMWindow(frame);70 return toJS(exec, frame); 70 71 71 72 return toJS(exec, node); … … 100 101 Frame* frame = static_cast<HTMLDocument*>(impl())->frame(); 101 102 if (frame) { 102 JSDOMWindow * window = toJSDOMWindow(frame);103 if (w indow) {104 JSObject* functionObject = w indow->get(exec, "open")->getObject();103 JSDOMWindowWrapper* wrapper = toJSDOMWindowWrapper(frame); 104 if (wrapper) { 105 JSObject* functionObject = wrapper->get(exec, "open")->getObject(); 105 106 if (!functionObject || !functionObject->implementsCall()) 106 107 return throwError(exec, TypeError); 107 return functionObject->call(exec, w indow, args);108 return functionObject->call(exec, wrapper, args); 108 109 } 109 110 } -
trunk/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp
r30787 r31746 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 #include "HTMLNames.h" 33 33 #include "JSDOMWindow.h" 34 #include "JSDOMWindowWrapper.h" 34 35 #include "kjs_binding.h" 36 37 using namespace KJS; 35 38 36 39 namespace WebCore { 37 40 38 using namespace KJS;39 41 using namespace HTMLNames; 40 42 … … 52 54 Node* frame = element->children()->namedItem(propertyName); 53 55 if (Document* doc = static_cast<HTMLFrameElement*>(frame)->contentDocument()) { 54 if (JSDOMWindow * window = toJSDOMWindow(doc->frame()))56 if (JSDOMWindowWrapper* window = toJSDOMWindowWrapper(doc->frame())) 55 57 return window; 56 58 } -
trunk/WebCore/bindings/js/JSSVGLazyEventListener.cpp
r30731 r31746 29 29 namespace WebCore { 30 30 31 JSSVGLazyEventListener::JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindow * win, Node* node, int lineNumber)32 : JSLazyEventListener(functionName, code, win , node, lineNumber)31 JSSVGLazyEventListener::JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindowWrapper* windowWrapper, Node* node, int lineNumber) 32 : JSLazyEventListener(functionName, code, windowWrapper, node, lineNumber) 33 33 { 34 34 } -
trunk/WebCore/bindings/js/JSSVGLazyEventListener.h
r30731 r31746 30 30 class JSSVGLazyEventListener : public JSLazyEventListener { 31 31 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); 33 33 34 34 private: -
trunk/WebCore/bindings/js/ScheduledAction.cpp
r30787 r31746 47 47 48 48 49 void ScheduledAction::execute(JSDOMWindow * window)49 void ScheduledAction::execute(JSDOMWindowWrapper* windowWrapper) 50 50 { 51 RefPtr<Frame> frame = window ->impl()->frame();51 RefPtr<Frame> frame = windowWrapper->window()->impl()->frame(); 52 52 if (!frame) 53 53 return; … … 57 57 58 58 KJSProxy* scriptProxy = frame->scriptProxy(); 59 JSDOMWindow* globalObject = scriptProxy->globalObject();59 60 60 61 61 scriptProxy->setProcessingTimerCallback(true); … … 64 64 JSLock lock; 65 65 if (func->isObject() && static_cast<JSObject*>(func)->implementsCall()) { 66 JSDOMWindow* window = windowWrapper->window(); 66 67 ExecState* exec = window->globalExec(); 67 ASSERT(window == globalObject);68 68 69 69 List args; … … 72 72 args.append(m_args[i]); 73 73 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(); 77 77 if (exec->hadException()) { 78 78 JSObject* exception = exec->exception()->toObject(exec); -
trunk/WebCore/bindings/js/ScheduledAction.h
r30779 r31746 32 32 namespace WebCore { 33 33 34 class JSDOMWindow ;34 class JSDOMWindowWrapper; 35 35 36 36 /** … … 47 47 } 48 48 49 void execute(JSDOMWindow *);49 void execute(JSDOMWindowWrapper*); 50 50 51 51 private: -
trunk/WebCore/bindings/js/kjs_events.cpp
r31197 r31746 55 55 return; 56 56 57 JSDOMWindow * window = windowObj();58 // Null check as clearWindow Obj() can clear this and we still get called back by57 JSDOMWindowWrapper* windowWrapper = this->windowWrapper(); 58 // Null check as clearWindowWrapper() can clear this and we still get called back by 59 59 // 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(); 63 63 if (!frame) 64 64 return; … … 69 69 JSLock lock; 70 70 71 JSGlobalObject* globalObject = scriptProxy->globalObject(); 72 ExecState* exec = globalObject->globalExec(); 71 ExecState* exec = windowWrapper->window()->globalExec(); 73 72 74 73 JSValue* handleEventFuncValue = listener->get(exec, "handleEvent"); … … 86 85 args.append(toJS(exec, event)); 87 86 88 window ->setCurrentEvent(event);87 windowWrapper->window()->setCurrentEvent(event); 89 88 90 89 JSValue* retval; 91 90 if (handleEventFunc) { 92 globalObject->startTimeoutCheck();91 windowWrapper->window()->startTimeoutCheck(); 93 92 retval = handleEventFunc->call(exec, listener, args); 94 93 } else { 95 94 JSObject* thisObj; 96 95 if (isWindowEvent) 97 thisObj = window ;96 thisObj = windowWrapper; 98 97 else 99 98 thisObj = static_cast<JSObject*>(toJS(exec, event->currentTarget())); 100 globalObject->startTimeoutCheck();99 windowWrapper->window()->startTimeoutCheck(); 101 100 retval = listener->call(exec, thisObj, args); 102 101 } 103 globalObject->stopTimeoutCheck();104 105 window ->setCurrentEvent(0);102 windowWrapper->window()->stopTimeoutCheck(); 103 104 windowWrapper->window()->setCurrentEvent(0); 106 105 107 106 if (exec->hadException()) { … … 137 136 // ------------------------------------------------------------------------- 138 137 139 JSUnprotectedEventListener::JSUnprotectedEventListener(JSObject* listener, JSDOMWindow * win, bool html)138 JSUnprotectedEventListener::JSUnprotectedEventListener(JSObject* listener, JSDOMWindowWrapper* windowWrapper, bool html) 140 139 : JSAbstractEventListener(html) 141 140 , m_listener(listener) 142 , m_win (win)141 , m_windowWrapper(windowWrapper) 143 142 { 144 143 if (m_listener) { 145 144 JSDOMWindow::UnprotectedListenersMap& listeners = html 146 ? m_win ->jsUnprotectedHTMLEventListeners() : m_win->jsUnprotectedEventListeners();145 ? m_windowWrapper->window()->jsUnprotectedHTMLEventListeners() : m_windowWrapper->window()->jsUnprotectedEventListeners(); 147 146 listeners.set(m_listener, this); 148 147 } … … 151 150 JSUnprotectedEventListener::~JSUnprotectedEventListener() 152 151 { 153 if (m_listener && m_win ) {152 if (m_listener && m_windowWrapper) { 154 153 JSDOMWindow::UnprotectedListenersMap& listeners = isHTMLEventListener() 155 ? m_win ->jsUnprotectedHTMLEventListeners() : m_win->jsUnprotectedEventListeners();154 ? m_windowWrapper->window()->jsUnprotectedHTMLEventListeners() : m_windowWrapper->window()->jsUnprotectedEventListeners(); 156 155 listeners.remove(m_listener); 157 156 } … … 163 162 } 164 163 165 JSDOMWindow * JSUnprotectedEventListener::windowObj() const166 { 167 return m_win ;168 } 169 170 void JSUnprotectedEventListener::clearWindow Obj()171 { 172 m_win = 0;164 JSDOMWindowWrapper* JSUnprotectedEventListener::windowWrapper() const 165 { 166 return m_windowWrapper; 167 } 168 169 void JSUnprotectedEventListener::clearWindowWrapper() 170 { 171 m_windowWrapper = 0; 173 172 } 174 173 … … 199 198 // ------------------------------------------------------------------------- 200 199 201 JSEventListener::JSEventListener(JSObject* listener, JSDOMWindow * win, bool html)200 JSEventListener::JSEventListener(JSObject* listener, JSDOMWindowWrapper* windowWrapper, bool html) 202 201 : JSAbstractEventListener(html) 203 202 , m_listener(listener) 204 , m_win (win)203 , m_windowWrapper(windowWrapper) 205 204 { 206 205 if (m_listener) { 207 206 JSDOMWindow::ListenersMap& listeners = html 208 ? m_win ->jsHTMLEventListeners() : m_win->jsEventListeners();207 ? m_windowWrapper->window()->jsHTMLEventListeners() : m_windowWrapper->window()->jsEventListeners(); 209 208 listeners.set(m_listener, this); 210 209 } … … 216 215 JSEventListener::~JSEventListener() 217 216 { 218 if (m_listener && m_win ) {217 if (m_listener && m_windowWrapper) { 219 218 JSDOMWindow::ListenersMap& listeners = isHTMLEventListener() 220 ? m_win ->jsHTMLEventListeners() : m_win->jsEventListeners();219 ? m_windowWrapper->window()->jsHTMLEventListeners() : m_windowWrapper->window()->jsEventListeners(); 221 220 listeners.remove(m_listener); 222 221 } … … 231 230 } 232 231 233 JSDOMWindow * JSEventListener::windowObj() const234 { 235 return m_win ;236 } 237 238 void JSEventListener::clearWindow Obj()239 { 240 m_win = 0;232 JSDOMWindowWrapper* JSEventListener::windowWrapper() const 233 { 234 return m_windowWrapper; 235 } 236 237 void JSEventListener::clearWindowWrapper() 238 { 239 m_windowWrapper = 0; 241 240 } 242 241 243 242 // ------------------------------------------------------------------------- 244 243 245 JSLazyEventListener::JSLazyEventListener(const String& functionName, const String& code, JSDOMWindow * win, Node* node, int lineNumber)246 : JSEventListener(0, win , true)244 JSLazyEventListener::JSLazyEventListener(const String& functionName, const String& code, JSDOMWindowWrapper* windowWrapper, Node* node, int lineNumber) 245 : JSEventListener(0, windowWrapper, true) 247 246 , m_functionName(functionName) 248 247 , m_code(code) … … 276 275 m_parsed = true; 277 276 278 Frame* frame = window Obj()->impl()->frame();277 Frame* frame = windowWrapper()->window()->impl()->frame(); 279 278 if (frame && frame->scriptProxy()->isEnabled()) { 280 ExecState* exec = frame->scriptProxy()->globalObject()->globalExec();279 ExecState* exec = windowWrapper()->window()->globalExec(); 281 280 282 281 JSLock lock; 283 JSObject* constr = frame->scriptProxy()->globalObject()->functionConstructor();282 JSObject* constr = windowWrapper()->window()->functionConstructor(); 284 283 List args; 285 284 … … 315 314 if (m_listener) { 316 315 JSDOMWindow::ListenersMap& listeners = isHTMLEventListener() 317 ? window Obj()->jsHTMLEventListeners() : windowObj()->jsEventListeners();316 ? windowWrapper()->window()->jsHTMLEventListeners() : windowWrapper()->window()->jsEventListeners(); 318 317 listeners.set(m_listener, const_cast<JSLazyEventListener*>(this)); 319 318 } -
trunk/WebCore/bindings/js/kjs_events.h
r30735 r31746 28 28 29 29 class Event; 30 class JSDOMWindow ;30 class JSDOMWindowWrapper; 31 31 class Node; 32 32 … … 38 38 virtual bool isHTMLEventListener() const; 39 39 virtual KJS::JSObject* listenerObj() const = 0; 40 virtual JSDOMWindow * windowObj() const = 0;40 virtual JSDOMWindowWrapper* windowWrapper() const = 0; 41 41 42 42 private: … … 46 46 class JSUnprotectedEventListener : public JSAbstractEventListener { 47 47 public: 48 JSUnprotectedEventListener(KJS::JSObject* listener, JSDOMWindow *, bool html = false);48 JSUnprotectedEventListener(KJS::JSObject* listener, JSDOMWindowWrapper*, bool html = false); 49 49 virtual ~JSUnprotectedEventListener(); 50 50 51 51 virtual KJS::JSObject* listenerObj() const; 52 virtual JSDOMWindow * windowObj() const;53 void clearWindow Obj();52 virtual JSDOMWindowWrapper* windowWrapper() const; 53 void clearWindowWrapper(); 54 54 void mark(); 55 55 56 56 private: 57 57 KJS::JSObject* m_listener; 58 JSDOMWindow * m_win;58 JSDOMWindowWrapper* m_windowWrapper; 59 59 }; 60 60 61 61 class JSEventListener : public JSAbstractEventListener { 62 62 public: 63 JSEventListener(KJS::JSObject* listener, JSDOMWindow *, bool html = false);63 JSEventListener(KJS::JSObject* listener, JSDOMWindowWrapper*, bool html = false); 64 64 virtual ~JSEventListener(); 65 65 66 66 virtual KJS::JSObject* listenerObj() const; 67 virtual JSDOMWindow * windowObj() const;68 void clearWindow Obj();67 virtual JSDOMWindowWrapper* windowWrapper() const; 68 void clearWindowWrapper(); 69 69 70 70 protected: … … 72 72 73 73 private: 74 KJS::ProtectedPtr<JSDOMWindow > m_win;74 KJS::ProtectedPtr<JSDOMWindowWrapper> m_windowWrapper; 75 75 }; 76 76 77 77 class JSLazyEventListener : public JSEventListener { 78 78 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); 80 80 virtual KJS::JSObject* listenerObj() const; 81 81 -
trunk/WebCore/bindings/js/kjs_proxy.cpp
r31267 r31746 56 56 KJSProxy::~KJSProxy() 57 57 { 58 if (m_ globalObject) {59 m_ globalObject= 0;58 if (m_windowWrapper) { 59 m_windowWrapper = 0; 60 60 61 61 // It's likely that releasing the global object has created a lot of garbage. … … 74 74 // expected value in all cases. 75 75 // See smart window.open policy for where this is used. 76 ExecState* exec = m_ globalObject->globalExec();76 ExecState* exec = m_windowWrapper->window()->globalExec(); 77 77 m_processingInlineCode = filename.isNull(); 78 78 … … 83 83 m_frame->keepAlive(); 84 84 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 89 89 if (comp.complType() == Normal || comp.complType() == ReturnValue) { 90 90 m_processingInlineCode = false; … … 109 109 // We have to keep it, so that the Window object for the frame remains the same. 110 110 // (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(); 113 113 } 114 114 … … 117 117 initScriptIfNeeded(); 118 118 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); 120 120 } 121 121 … … 125 125 initScriptIfNeeded(); 126 126 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); 128 128 } 129 129 #endif … … 140 140 void KJSProxy::initScript() 141 141 { 142 if (m_ globalObject)142 if (m_windowWrapper) 143 143 return; 144 144 145 145 JSLock lock; 146 146 147 m_globalObject = new JSDOMWindow(m_frame->domWindow()); 147 m_windowWrapper = new JSDOMWindowWrapper(); 148 m_windowWrapper->setWindow(new JSDOMWindow(m_frame->domWindow())); 148 149 149 150 if (Page* page = m_frame->page()) … … 155 156 void KJSProxy::clearDocumentWrapper() 156 157 { 157 if (!m_ globalObject)158 if (!m_windowWrapper) 158 159 return; 159 160 160 161 JSLock lock; 161 m_ globalObject->removeDirect("document");162 m_windowWrapper->window()->removeDirect("document"); 162 163 } 163 164 164 165 bool KJSProxy::processingUserGesture() const 165 166 { 166 if (!m_ globalObject)167 if (!m_windowWrapper) 167 168 return false; 168 169 169 if (Event* event = m_ globalObject->currentEvent()) {170 if (Event* event = m_windowWrapper->window()->currentEvent()) { 170 171 const AtomicString& type = event->type(); 171 172 if ( // mouse events … … 198 199 void KJSProxy::attachDebugger(KJS::Debugger* debugger) 199 200 { 200 if (!m_ globalObject)201 if (!m_windowWrapper) 201 202 return; 202 203 203 204 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()); 207 208 } 208 209 -
trunk/WebCore/bindings/js/kjs_proxy.h
r31197 r31746 1 1 /* 2 * This file is part of the KDE libraries3 2 * Copyright (C) 1999 Harri Porten (porten@kde.org) 4 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 4 * Copyright (C) 2008 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 22 22 #define kjs_proxy_h 23 23 24 #include "JSDOMWindow .h"24 #include "JSDOMWindowWrapper.h" 25 25 #include <kjs/protect.h> 26 26 #include <wtf/RefPtr.h> … … 46 46 ~KJSProxy(); 47 47 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 49 55 JSDOMWindow* globalObject() 50 56 { 51 57 initScriptIfNeeded(); 52 return m_ globalObject;58 return m_windowWrapper->window(); 53 59 } 54 60 … … 77 83 void initScriptIfNeeded() 78 84 { 79 if (!m_ globalObject)85 if (!m_windowWrapper) 80 86 initScript(); 81 87 } 82 88 void initScript(); 83 89 84 KJS::ProtectedPtr<JSDOMWindow > m_globalObject;90 KJS::ProtectedPtr<JSDOMWindowWrapper> m_windowWrapper; 85 91 Frame* m_frame; 86 92 int m_handlerLineno; … … 91 97 }; 92 98 93 } 99 } // namespace WebCore 94 100 95 #endif 101 #endif // kjs_proxy_h -
trunk/WebCore/bindings/objc/DOMUtility.mm
r31221 r31746 36 36 #import "JSDOMImplementation.h" 37 37 #import "JSDOMWindow.h" 38 #import "JSDOMWindowWrapper.h" 38 39 #import "JSEvent.h" 39 40 #import "JSHTMLCollection.h" … … 102 103 if (object->inherits(&WebCore::JSDOMWindow::s_info)) 103 104 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 104 108 if (object->inherits(&WebCore::JSDOMImplementation::s_info)) 105 109 return [DOMImplementation _wrapDOMImplementation:implementationFront(static_cast<WebCore::JSDOMImplementation*>(object))]; -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r31745 r31746 1127 1127 if ($numFunctions > 0) { 1128 1128 foreach my $function (@{$dataNode->functions}) { 1129 AddIncludesForType($function->signature->type); 1130 1129 1131 my $functionName = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($function->signature->name); 1130 1132 push(@implContent, "JSValue* ${functionName}(ExecState* exec, JSObject* thisObj, const List& args)\n"); 1131 1133 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 1138 1147 1139 1148 if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && -
trunk/WebCore/dom/Document.cpp
r31549 r31746 2528 2528 } 2529 2529 2530 DOMWindow* Document::defaultView() const 2530 // FIXME: eventually, this should return a DOMWindow stored in the document. 2531 DOMWindow* Document::domWindow() const 2531 2532 { 2532 2533 if (!frame()) 2533 2534 return 0; 2534 2535 2535 return frame()->domWindow(); 2536 2536 } -
trunk/WebCore/dom/Document.h
r31549 r31746 488 488 void textNodeSplit(Text* oldNode); 489 489 490 DOMWindow* defaultView() const; 490 DOMWindow* defaultView() const { return domWindow(); } 491 DOMWindow* domWindow() const; 492 491 493 PassRefPtr<Event> createEvent(const String& eventType, ExceptionCode&); 492 494 -
trunk/WebCore/loader/FrameLoader.cpp
r31697 r31746 4782 4782 void FrameLoader::dispatchWindowObjectAvailable() 4783 4783 { 4784 if (!m_frame->scriptProxy()->isEnabled() || !m_frame->scriptProxy()->have GlobalObject())4784 if (!m_frame->scriptProxy()->isEnabled() || !m_frame->scriptProxy()->haveWindowWrapper()) 4785 4785 return; 4786 4786 -
trunk/WebCore/page/DOMWindow.idl
r31697 r31746 28 28 interface [ 29 29 CheckDomainSecurity, 30 CustomNativeConverter, 30 31 CustomDeleteProperty, 31 32 CustomGetOwnPropertySlot, -
trunk/WebCore/page/Frame.cpp
r31160 r31746 53 53 #include "HTMLTableCellElement.h" 54 54 #include "HitTestResult.h" 55 #include "JSDOMWindow .h"55 #include "JSDOMWindowWrapper.h" 56 56 #include "Logging.h" 57 57 #include "MediaFeatureNames.h" … … 174 174 #endif 175 175 176 if (d->m_jscript && d->m_jscript->have GlobalObject())177 static_cast<JSDOMWindow*>(d->m_jscript->globalObject())->disconnectFrame();176 if (d->m_jscript && d->m_jscript->haveWindowWrapper()) 177 d->m_jscript->windowWrapper()->disconnectFrame(); 178 178 179 179 disconnectOwnerElement(); … … 1705 1705 1706 1706 // 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 } 1710 1711 1711 1712 clearScriptObjects(); -
trunk/WebCore/page/InspectorController.cpp
r31743 r31746 418 418 419 419 KJS::JSLock lock; 420 JSValueRef documentValue = toRef(toJS(toJSDOMWindow (frame)->globalExec(), document));420 JSValueRef documentValue = toRef(toJS(toJSDOMWindowWrapper(frame)->window()->globalExec(), document)); 421 421 return documentValue; 422 422 } … … 622 622 return JSValueMakeUndefined(ctx); 623 623 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())); 629 625 } 630 626
Note:
See TracChangeset
for help on using the changeset viewer.