Fixed <rdar://problem/3980389> JavaScript bindings access incorrect runtime object
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Jan 2005 00:13:35 +0000 (00:13 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Jan 2005 00:13:35 +0000 (00:13 +0000)
Only use special 'back door' property to get the runtime object if thisObj isn't
already a runtime object.

<gratuitous> Cleaned up a couple of strcmp on ClassInfo name.  Used == on
ClassInfo pointer instead.

        Reviewed by Chris.

        * bindings/c/c_utility.cpp:
        (convertValueToNPVariant):
        * bindings/objc/WebScriptObject.mm:
        (+[WebScriptObject _convertValueToObjcValue:KJS::originExecutionContext:Bindings::executionContext:Bindings::]):
        * bindings/runtime_method.cpp:
        (RuntimeMethodImp::call):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8474 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/bindings/c/c_utility.cpp
JavaScriptCore/bindings/objc/WebScriptObject.mm
JavaScriptCore/bindings/runtime_method.cpp

index d828d7f2ba9fe3a50ec580cbea68227f1946ef1b..d5c3e9d1b1c5d6904ab4dc23937219aa461c9259 100644 (file)
@@ -1,3 +1,22 @@
+2005-01-28  Richard Williamson   <rjw@apple.com>
+
+       Fixed <rdar://problem/3980389> JavaScript bindings access incorrect runtime object
+
+       Only use special 'back door' property to get the runtime object if thisObj isn't
+       already a runtime object.
+
+       <gratuitous> Cleaned up a couple of strcmp on ClassInfo name.  Used == on
+       ClassInfo pointer instead.
+
+        Reviewed by Chris.
+
+        * bindings/c/c_utility.cpp:
+        (convertValueToNPVariant):
+        * bindings/objc/WebScriptObject.mm:
+        (+[WebScriptObject _convertValueToObjcValue:KJS::originExecutionContext:Bindings::executionContext:Bindings::]):
+        * bindings/runtime_method.cpp:
+        (RuntimeMethodImp::call):
+
 === Safari-181 ===
 
 2005-01-26  Richard Williamson   <rjw@apple.com>
index 509f2d898188ec8f54783307b2023a67c7fadc2c..fbe01bff750f6cd94cc9817d2064890109c972fa 100644 (file)
@@ -95,7 +95,7 @@ void convertValueToNPVariant (KJS::ExecState *exec, const KJS::Value &value, NPV
     }
     else if (type == ObjectType) {
         KJS::ObjectImp *objectImp = static_cast<KJS::ObjectImp*>(value.imp());
-        if (strcmp(objectImp->classInfo()->className, "RuntimeObject") == 0) {
+        if (objectImp->classInfo() == &KJS::RuntimeObjectImp::info) {
             KJS::RuntimeObjectImp *imp = static_cast<KJS::RuntimeObjectImp *>(value.imp());
             CInstance *instance = static_cast<CInstance*>(imp->getInternalInstance());
             NPN_InitializeVariantWithObject (result, instance->getObject());
index 4069af5b80ff659791a8bd6b24b836b60150a5df..b91d415ec5bcf2d7d5ec69337eda0a2f85c0b71e 100644 (file)
@@ -412,7 +412,7 @@ static KJS::List listFromNSArray(ExecState *exec, NSArray *array)
     // First see if we have a ObjC instance.
     if (value.type() == KJS::ObjectType){
         ObjectImp *objectImp = static_cast<ObjectImp*>(value.imp());
-        if (strcmp(objectImp->classInfo()->className, "RuntimeObject") == 0) {
+        if (objectImp->classInfo() == &KJS::RuntimeObjectImp::info) {
             RuntimeObjectImp *imp = static_cast<RuntimeObjectImp *>(value.imp());
             ObjcInstance *instance = static_cast<ObjcInstance*>(imp->getInternalInstance());
             if (instance)
index 088b1f42c2c561d288005062f707fac1e4198dbb..1d8e71c632e17498b196c1a896301fe2f3102517 100644 (file)
@@ -74,8 +74,17 @@ bool RuntimeMethodImp::implementsCall() const
 Value RuntimeMethodImp::call(ExecState *exec, Object &thisObj, const List &args)
 {
     if (_methodList.length() > 0) {
-       Value runtimeObject = thisObj.get(exec, "__apple_runtime_object");
-        RuntimeObjectImp *imp = static_cast<RuntimeObjectImp*>(runtimeObject.imp());
+       RuntimeObjectImp *imp;
+       
+       // If thisObj is the DOM object for a plugin, get the corresponding
+       // runtime object from the DOM object.
+       if (thisObj.classInfo() != &KJS::RuntimeObjectImp::info) {
+           Value runtimeObject = thisObj.get(exec, "__apple_runtime_object");
+           imp = static_cast<RuntimeObjectImp*>(runtimeObject.imp());
+       }
+       else {
+           imp = static_cast<RuntimeObjectImp*>(thisObj.imp());
+       }
         if (imp) {
             Instance *instance = imp->getInternalInstance();