JavaScriptCore:
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Jan 2005 21:38:10 +0000 (21:38 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Jan 2005 21:38:10 +0000 (21:38 +0000)
Fixed <rdar://problem/3972522> (179-180) 40% slowdown on iBench JavaScript test

I added a member variable to ObjectImp.  This changed it's size and consequently
hampered the optimizations built into the garbage collector.  Objects no longer
fit within the allocators cell size, and thus allocation fell back to a slower
allocator.

As a result of this fix I also dramatically cleaned up how runtime objects are
accessed.  The path mostly *removes* code.

        Reviewed by Chris.

        * bindings/runtime_method.cpp:
        (RuntimeMethodImp::call):
        * bindings/runtime_object.cpp:
        (RuntimeObjectImp::get):
        (RuntimeObjectImp::put):
        (RuntimeObjectImp::canPut):
        (RuntimeObjectImp::hasProperty):
        (RuntimeObjectImp::defaultValue):
        * bindings/runtime_object.h:
        * kjs/object.cpp:
        (KJS::ObjectImp::ObjectImp):
        * kjs/object.h:

WebCore:
Fixed <rdar://problem/3972522> (179-180) 40% slowdown on iBench JavaScript test

I added a member variable to ObjectImp.  This changed it's size and consequently
hampered the optimizations built into the garbage collector.  Objects no longer
fit within the allocators cell size, and thus allocation fell back to a slower
allocator.

As a result of this fix I also dramatically cleaned up how runtime objects are
accessed.  The path mostly *removes* code.

        Reviewed by Chris.

        * khtml/ecma/kjs_dom.cpp:
        (DOMDocumentProtoFunc::tryCall):
        (DOMElementProtoFunc::tryCall):
        (KJS::getRuntimeObject):
        * khtml/ecma/kjs_dom.h:
        * khtml/ecma/kjs_html.cpp:
        (KJS::HTMLDocument::tryGet):
        (KJS::HTMLElement::tryGet):
        (KJS::HTMLElement::implementsCall):
        (KJS::HTMLElement::call):
        (KJS::HTMLElement::tryPut):
        (KJS::HTMLCollection::tryGet):
        (KJS::HTMLCollection::getNamedItems):
        * khtml/ecma/kjs_html.h:
        * khtml/ecma/kjs_window.cpp:
        (Window::get):

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

12 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/bindings/runtime_method.cpp
JavaScriptCore/bindings/runtime_object.cpp
JavaScriptCore/bindings/runtime_object.h
JavaScriptCore/kjs/object.cpp
JavaScriptCore/kjs/object.h
WebCore/ChangeLog-2005-08-23
WebCore/khtml/ecma/kjs_dom.cpp
WebCore/khtml/ecma/kjs_dom.h
WebCore/khtml/ecma/kjs_html.cpp
WebCore/khtml/ecma/kjs_html.h
WebCore/khtml/ecma/kjs_window.cpp

index f2569a7dc98706ce268a17e2f370c17a875bd686..85ca41a37a952cc6f577b73bb2975eb2297d3a92 100644 (file)
@@ -1,3 +1,30 @@
+2005-01-26  Richard Williamson   <rjw@apple.com>
+
+       Fixed <rdar://problem/3972522> (179-180) 40% slowdown on iBench JavaScript test
+
+       I added a member variable to ObjectImp.  This changed it's size and consequently
+       hampered the optimizations built into the garbage collector.  Objects no longer
+       fit within the allocators cell size, and thus allocation fell back to a slower
+       allocator.
+
+       As a result of this fix I also dramatically cleaned up how runtime objects are
+       accessed.  The path mostly *removes* code.
+       
+        Reviewed by Chris.
+
+        * bindings/runtime_method.cpp:
+        (RuntimeMethodImp::call):
+        * bindings/runtime_object.cpp:
+        (RuntimeObjectImp::get):
+        (RuntimeObjectImp::put):
+        (RuntimeObjectImp::canPut):
+        (RuntimeObjectImp::hasProperty):
+        (RuntimeObjectImp::defaultValue):
+        * bindings/runtime_object.h:
+        * kjs/object.cpp:
+        (KJS::ObjectImp::ObjectImp):
+        * kjs/object.h:
+
 2005-01-20  Darin Adler  <darin@apple.com>
 
         Reviewed by me, changes by Han Ming Ong.
index 308db7707e00739ce966f7ade911a4a3acc427da..088b1f42c2c561d288005062f707fac1e4198dbb 100644 (file)
@@ -74,7 +74,8 @@ bool RuntimeMethodImp::implementsCall() const
 Value RuntimeMethodImp::call(ExecState *exec, Object &thisObj, const List &args)
 {
     if (_methodList.length() > 0) {
-        RuntimeObjectImp *imp = static_cast<RuntimeObjectImp*>(thisObj.imp());
+       Value runtimeObject = thisObj.get(exec, "__apple_runtime_object");
+        RuntimeObjectImp *imp = static_cast<RuntimeObjectImp*>(runtimeObject.imp());
         if (imp) {
             Instance *instance = imp->getInternalInstance();
             
index c09d5a5a270044f70e847cd84f169e5891aaf139..dd536019a270b3cb8a49f5f43c4a004f54efb82e 100644 (file)
@@ -60,13 +60,6 @@ RuntimeObjectImp::RuntimeObjectImp(Bindings::Instance *i, bool oi) : ObjectImp (
     instance = i;
 }
 
-RuntimeObjectImp::RuntimeObjectImp(Bindings::Instance *i, const Value &fb, bool oi) : ObjectImp ((ObjectImp *)0)
-{
-    ownsInstance = oi;
-    instance = i;
-    fallback = fb;
-}
-
 Value RuntimeObjectImp::get(ExecState *exec, const Identifier &propertyName) const
 {
     Value result = Undefined();
@@ -89,12 +82,6 @@ Value RuntimeObjectImp::get(ExecState *exec, const Identifier &propertyName) con
             if (methodList.length() > 0) {
                 result = Object (new RuntimeMethodImp(exec, propertyName, methodList));
             }
-           else if (!fallback.isNull() && fallback.type() == ObjectType){
-               ObjectImp *imp = static_cast<ObjectImp*>(fallback.imp());
-               imp->setForwardingScriptMessage(true);
-               result = imp->get (exec, propertyName);
-               imp->setForwardingScriptMessage(false);
-           }
         }
        
         if (result.type() == UndefinedType) {
@@ -120,23 +107,7 @@ void RuntimeObjectImp::put(ExecState *exec, const Identifier &propertyName,
         getInternalInstance()->setValueOfField(exec, aField, value);
     }
     else {
-       bool domHasProperty = false;
-       if (!fallback.isNull() && fallback.type() == ObjectType){
-           ObjectImp *imp = static_cast<ObjectImp*>(fallback.imp());
-           imp->setForwardingScriptMessage(true);
-           domHasProperty = imp->hasProperty(exec, propertyName);
-           imp->setForwardingScriptMessage(false);
-       }
-       
-       // If the DOM has the property, give it a crack first (even if it read-only).
-       if (domHasProperty || !getInternalInstance()->supportsSetValueOfUndefinedField()) {
-           ObjectImp *imp = static_cast<ObjectImp*>(fallback.imp());
-           imp->setForwardingScriptMessage(true);
-           imp->put(exec, propertyName, value, attr);
-           imp->setForwardingScriptMessage(false);
-       }
-       // Now let the runtime object attempt to handle the undefined field.
-       else if (getInternalInstance()->supportsSetValueOfUndefinedField()){
+       if (getInternalInstance()->supportsSetValueOfUndefinedField()){
            getInternalInstance()->setValueOfUndefinedField(exec, propertyName, value);
        }
     }
@@ -157,13 +128,6 @@ bool RuntimeObjectImp::canPut(ExecState *exec, const Identifier &propertyName) c
     if (aField)
        return true;
     
-    if (!fallback.isNull() && fallback.type() == ObjectType) {
-       ObjectImp *imp = static_cast<ObjectImp*>(fallback.imp());
-       imp->setForwardingScriptMessage(true);
-       result = imp->canPut (exec, propertyName);
-       imp->setForwardingScriptMessage(false);
-    }
-       
     return result;
 }
 
@@ -187,13 +151,6 @@ bool RuntimeObjectImp::hasProperty(ExecState *exec,
     if (methodList.length() > 0)
         return true;
 
-    if (!fallback.isNull() && fallback.type() == ObjectType) {
-       ObjectImp *imp = static_cast<ObjectImp*>(fallback.imp());
-       imp->setForwardingScriptMessage(true);
-       result = imp->hasProperty (exec, propertyName);
-       imp->setForwardingScriptMessage(false);
-    }
-        
     return result;
 }
 
@@ -210,15 +167,7 @@ Value RuntimeObjectImp::defaultValue(ExecState *exec, Type hint) const
     
     instance->begin();
 
-    if (!fallback.isNull() && fallback.type() == ObjectType) {
-       ObjectImp *imp = static_cast<ObjectImp*>(fallback.imp());
-       imp->setForwardingScriptMessage(true);
-       result = imp->defaultValue (exec, hint);
-       imp->setForwardingScriptMessage(false);
-    }
-    else {
-       result = getInternalInstance()->defaultValue(hint);
-    }
+    result = getInternalInstance()->defaultValue(hint);
     
     instance->end();
     
index 36f22404e6daa94569165fe0c59b59cee2d0c8dc..5f7df0a65b1aa48967f3155da8f0f52e5c453bc0 100644 (file)
@@ -38,7 +38,6 @@ public:
     ~RuntimeObjectImp();
     
     RuntimeObjectImp(Bindings::Instance *i, bool ownsInstance = true);
-    RuntimeObjectImp(Bindings::Instance *i, const Value &fallback, bool ownsInstance = true);
 
     const ClassInfo *classInfo() const { return &info; }
 
@@ -63,13 +62,10 @@ public:
 
     virtual bool implementsCall() const;
     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
-
-    Value fallbackObject() { return fallback; }
     
     static const ClassInfo info;
 
 private:
-    ProtectedValue fallback;
     Bindings::Instance *instance;
     bool ownsInstance;
 };
index 03bfd93bcd7651e7c5b50ba86181cbe2f3f362b5..94f75af4f6527b3a857c9fe039694a8bece9cb2a 100644 (file)
@@ -124,13 +124,13 @@ Value Object::call(ExecState *exec, Object &thisObj, const List &args)
 // ------------------------------ ObjectImp ------------------------------------
 
 ObjectImp::ObjectImp(const Object &proto)
-  : _proto(static_cast<ObjectImp*>(proto.imp())), _internalValue(0L), _forwardingScriptMessage(false)
+  : _proto(static_cast<ObjectImp*>(proto.imp())), _internalValue(0L)
 {
   //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
 }
 
 ObjectImp::ObjectImp(ObjectImp *proto)
-  : _proto(proto), _internalValue(0L), _forwardingScriptMessage(false)
+  : _proto(proto), _internalValue(0L)
 {
   //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
 }
@@ -140,7 +140,6 @@ ObjectImp::ObjectImp()
   //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
   _proto = NullImp::staticNull;
   _internalValue = 0L;
-  _forwardingScriptMessage = false;
 }
 
 ObjectImp::~ObjectImp()
index 8e15825fd80d39d40ba20c9dfe7d68e60cd0ff98..64a076a0afbb7dba9585fff2aae47549af687778 100644 (file)
@@ -600,11 +600,6 @@ namespace KJS {
     void saveProperties(SavedProperties &p) const { _prop.save(p); }
     void restoreProperties(const SavedProperties &p) { _prop.restore(p); }
 
-#if APPLE_CHANGES
-    bool forwardingScriptMessage() const { return _forwardingScriptMessage; }
-    void setForwardingScriptMessage(bool f) { _forwardingScriptMessage = f; }
-#endif
-
   protected:
     PropertyMap _prop;
   private:
@@ -612,10 +607,6 @@ namespace KJS {
     ValueImp *_proto;
     ValueImp *_internalValue;
     ScopeChain _scope;
-
-#if APPLE_CHANGES
-    bool _forwardingScriptMessage;
-#endif    
   };
 
   /**
index 3a2d54cf837fac50e1110e5c65425b1ea639ef30..b5762a181ae9e4938f3a9e991f09100c331e5973 100644 (file)
@@ -1,3 +1,34 @@
+2005-01-26  Richard Williamson   <rjw@apple.com>
+
+       Fixed <rdar://problem/3972522> (179-180) 40% slowdown on iBench JavaScript test
+
+       I added a member variable to ObjectImp.  This changed it's size and consequently
+       hampered the optimizations built into the garbage collector.  Objects no longer
+       fit within the allocators cell size, and thus allocation fell back to a slower
+       allocator.
+
+       As a result of this fix I also dramatically cleaned up how runtime objects are
+       accessed.  The path mostly *removes* code.
+       
+        Reviewed by Chris.
+
+        * khtml/ecma/kjs_dom.cpp:
+        (DOMDocumentProtoFunc::tryCall):
+        (DOMElementProtoFunc::tryCall):
+        (KJS::getRuntimeObject):
+        * khtml/ecma/kjs_dom.h:
+        * khtml/ecma/kjs_html.cpp:
+        (KJS::HTMLDocument::tryGet):
+        (KJS::HTMLElement::tryGet):
+        (KJS::HTMLElement::implementsCall):
+        (KJS::HTMLElement::call):
+        (KJS::HTMLElement::tryPut):
+        (KJS::HTMLCollection::tryGet):
+        (KJS::HTMLCollection::getNamedItems):
+        * khtml/ecma/kjs_html.h:
+        * khtml/ecma/kjs_window.cpp:
+        (Window::get):
+
 2005-01-26  Richard Williamson   <rjw@apple.com>
 
        Fixed <rdar://problem/3757712> REGRESSION (Mail): WebCore does not allow Devanagari ligature input
index 2a64154b1db6a4a08ca3b8683f0392893dd7a502..fd2033ef173ece05296b9f46121025c90eb3d5fb 100644 (file)
@@ -947,24 +947,7 @@ Value DOMDocumentProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List
     return getDOMNodeList(exec,doc.getElementsByTagNameNS(args[0].toString(exec).string(),
                                                           args[1].toString(exec).string()));
   case DOMDocument::GetElementById:
-#if APPLE_CHANGES
-    {
-        DOM::Element node = doc.getElementById(args[0].toString(exec).string());
-        if (!node.isNull()) {
-            Value domValue = getDOMNode(exec, node);
-            ObjectImp *imp = static_cast<ObjectImp *>(domValue.imp());
-            if (!imp->forwardingScriptMessage() && (node.handle()->id() == ID_APPLET || node.handle()->id() == ID_EMBED || node.handle()->id() == ID_OBJECT)) {
-                Value v = getRuntimeObject(exec,node,domValue);
-                if (!v.isNull())
-                    return v;
-            }
-            return domValue;
-        }
-        return getDOMNode(exec,node);
-    }
-#else  
     return getDOMNode(exec,doc.getElementById(args[0].toString(exec).string()));
-#endif
   case DOMDocument::CreateRange:
     return getDOMRange(exec,doc.createRange());
   case DOMDocument::CreateNodeIterator: {
@@ -1102,18 +1085,8 @@ Value DOMElement::tryGet(ExecState *exec, const Identifier &propertyName) const
   return Undefined();
 }
 
-Value DOMElementProtoFunc::tryCall(ExecState *exec, Object &to, const List &args)
+Value DOMElementProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
 {
-  Object thisObj;
-
-  if (to.classInfo() == &KJS::RuntimeObjectImp::info) {
-    KJS::RuntimeObjectImp *imp = static_cast<KJS::RuntimeObjectImp *>(to.imp());
-    thisObj = imp->fallbackObject().toObject(exec);
-  }
-  else {
-    thisObj = to;
-  }
-  
   if (!thisObj.inherits(&KJS::DOMNode::info)) { // node should be enough here, given the cast
     Object err = Error::create(exec,TypeError);
     exec->setException(err);
@@ -1571,7 +1544,7 @@ Value KJS::getDOMNamedNodeMap(ExecState *exec, const DOM::NamedNodeMap &m)
   return Value(cacheDOMObject<DOM::NamedNodeMap, KJS::DOMNamedNodeMap>(exec, m));
 }
 
-Value KJS::getRuntimeObject(ExecState *exec, const DOM::Node &node, const Value &fallback)
+Value KJS::getRuntimeObject(ExecState *exec, const DOM::Node &node)
 {
     DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
 
@@ -1581,7 +1554,7 @@ Value KJS::getRuntimeObject(ExecState *exec, const DOM::Node &node, const Value
             
             if (appletElement->getAppletInstance()) {
                 // The instance is owned by the applet element.
-                RuntimeObjectImp *appletImp = new RuntimeObjectImp(appletElement->getAppletInstance(), fallback, false);
+                RuntimeObjectImp *appletImp = new RuntimeObjectImp(appletElement->getAppletInstance(), false);
                 return Value(appletImp);
             }
         }
@@ -1589,7 +1562,7 @@ Value KJS::getRuntimeObject(ExecState *exec, const DOM::Node &node, const Value
             DOM::HTMLEmbedElementImpl *embedElement = static_cast<DOM::HTMLEmbedElementImpl *>(element.handle());
             
             if (embedElement->getEmbedInstance()) {
-                RuntimeObjectImp *runtimeImp = new RuntimeObjectImp(embedElement->getEmbedInstance(), fallback, false);
+                RuntimeObjectImp *runtimeImp = new RuntimeObjectImp(embedElement->getEmbedInstance(), false);
                 return Value(runtimeImp);
             }
         }
@@ -1597,7 +1570,7 @@ Value KJS::getRuntimeObject(ExecState *exec, const DOM::Node &node, const Value
             DOM::HTMLObjectElementImpl *objectElement = static_cast<DOM::HTMLObjectElementImpl *>(element.handle());
             
             if (objectElement->getObjectInstance()) {
-                RuntimeObjectImp *runtimeImp = new RuntimeObjectImp(objectElement->getObjectInstance(), fallback, false);
+                RuntimeObjectImp *runtimeImp = new RuntimeObjectImp(objectElement->getObjectInstance(), false);
                 return Value(runtimeImp);
             }
         }
index b6308435cb5d423a5ef960f22b8f31444caa1c68..343c67e382669c7e778690bc120bfc1f27cedb6a 100644 (file)
@@ -263,7 +263,7 @@ namespace KJS {
   Value getDOMDocumentNode(ExecState *exec, const DOM::Document &n);
   bool checkNodeSecurity(ExecState *exec, const DOM::Node& n);
 #if APPLE_CHANGES
-  Value getRuntimeObject(ExecState *exec, const DOM::Node &n, const Value &fallback);
+  Value getRuntimeObject(ExecState *exec, const DOM::Node &n);
 #endif
   Value getDOMNode(ExecState *exec, const DOM::Node &n);
   Value getDOMNamedNodeMap(ExecState *exec, const DOM::NamedNodeMap &m);
index 9996bb81a08baec907cac68cd91432731efc9e69..19f4732eaeee22294e138e85ea1f35f87c76440f 100644 (file)
@@ -45,6 +45,7 @@
 #include "ecma/kjs_window.h"
 #include "ecma/kjs_html.lut.h"
 #include "kjs_events.h"
+#include "kjs_proxy.h"
 
 #include "misc/htmltags.h"
 
@@ -317,37 +318,19 @@ Value KJS::HTMLDocument::tryGet(ExecState *exec, const Identifier &propertyName)
     DOM::HTMLCollection applets = doc.applets();
     DOM::HTMLElement anApplet = applets.namedItem (propertyName.string());
     if (!anApplet.isNull()) {
-       Value domValue = getDOMNode(exec,anApplet);
-       ObjectImp *imp = static_cast<ObjectImp *>(domValue.imp());
-       if (!imp->forwardingScriptMessage()) {
-           Value v = getRuntimeObject(exec,anApplet,getDOMNode(exec,anApplet));
-           if (!v.isNull())
-               return v;
-       }
+       return getDOMNode(exec,anApplet);
     }
 
     DOM::HTMLCollection embeds = doc.embeds();
     DOM::HTMLElement anEmbed = embeds.namedItem (propertyName.string());
     if (!anEmbed.isNull()) {
-       Value domValue = getDOMNode(exec,anEmbed);
-       ObjectImp *imp = static_cast<ObjectImp *>(domValue.imp());
-       if (!imp->forwardingScriptMessage()) {
-           Value v = getRuntimeObject(exec,anEmbed,getDOMNode(exec,anEmbed));
-           if (!v.isNull())
-               return v;
-       }
+       return getDOMNode(exec,anApplet);
     }
 
     DOM::HTMLCollection objects = doc.objects();
     DOM::HTMLElement anObject = objects.namedItem (propertyName.string());
     if (!anObject.isNull()) {
-       Value domValue = getDOMNode(exec,anObject);
-       ObjectImp *imp = static_cast<ObjectImp *>(domValue.imp());
-       if (!imp->forwardingScriptMessage()) {
-           Value v = getRuntimeObject(exec,anObject,getDOMNode(exec,anObject));
-           if (!v.isNull())
-               return v;
-       }
+       return getDOMNode(exec,anApplet);
     }
 #endif
 
@@ -1187,12 +1170,17 @@ Value KJS::HTMLElement::tryGet(ExecState *exec, const Identifier &propertyName)
     case ID_EMBED:
     case ID_OBJECT:
     case ID_APPLET: {
+       if (propertyName == "__apple_runtime_object") {
+           return getRuntimeObject(exec,element);
+       }
+
        Value domValue = getDOMNode(exec,element);
-       ObjectImp *imp = static_cast<ObjectImp *>(domValue.imp());
-       if (!imp->forwardingScriptMessage()) { 
-           Value v = getRuntimeObject(exec,element,getDOMNode(exec,element));
-           if (!v.isNull())
-               return v;
+       Value runtimeObject = getRuntimeObject(exec,element);
+       if (!runtimeObject.isNull()) {
+           ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp());
+           if (imp->hasProperty(exec, propertyName)) {
+               return imp->get (exec, propertyName);
+           }
        }
     }
       break;
@@ -1213,6 +1201,53 @@ Value KJS::HTMLElement::tryGet(ExecState *exec, const Identifier &propertyName)
   return DOMObjectLookupGet<KJS::HTMLElementFunction, KJS::HTMLElement, DOMElement>(exec, propertyName, &KJS::HTMLElementTable, this);
 }
 
+#if APPLE_CHANGES
+bool KJS::HTMLElement::implementsCall() const
+{
+    DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
+    switch (element.elementId()) {
+       case ID_EMBED:
+       case ID_OBJECT:
+       case ID_APPLET: {
+               DOM::DocumentImpl* doc = element.handle()->getDocument();
+               KJSProxy *proxy = KJSProxy::proxy(doc->part());
+               ExecState *exec = proxy->interpreter()->globalExec();
+               Value domValue = getDOMNode(exec,element);
+               Value runtimeObject = getRuntimeObject(exec,element);
+               if (!runtimeObject.isNull()) {
+                   ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp());
+                   return imp->implementsCall ();
+               }
+           }
+           break;
+       default:
+           break;
+    }
+    return false;
+}
+
+Value KJS::HTMLElement::call(ExecState *exec, Object &thisObj, const List&args)
+{
+    DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
+    switch (element.elementId()) {
+       case ID_EMBED:
+       case ID_OBJECT:
+       case ID_APPLET: {
+               Value domValue = getDOMNode(exec,element);
+               Value runtimeObject = getRuntimeObject(exec,element);
+               if (!runtimeObject.isNull()) {
+                   ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp());
+                   return imp->call (exec, thisObj, args);
+               }
+           }
+           break;
+       default:
+           break;
+    }
+    return Undefined();
+}
+#endif
+
 Value KJS::HTMLElement::getValueProperty(ExecState *exec, int token) const
 {
   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
@@ -2252,6 +2287,21 @@ void KJS::HTMLElement::tryPut(ExecState *exec, const Identifier &propertyName, c
         return;
       }
     }
+#if APPLE_CHANGES
+    case ID_EMBED:
+    case ID_OBJECT:
+    case ID_APPLET: {
+       Value domValue = getDOMNode(exec,element);
+       Value runtimeObject = getRuntimeObject(exec,element);
+       if (!runtimeObject.isNull()) {
+           ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp());
+           if (imp->canPut(exec, propertyName)) {
+               return imp->put (exec, propertyName, value);
+           }
+       }
+    }
+      break;
+#endif
     break;
   default:
       break;
@@ -3032,21 +3082,7 @@ Value KJS::HTMLCollection::tryGet(ExecState *exec, const Identifier &propertyNam
     if (ok) {
       DOM::Node node = collection.item(u);
 
-#if APPLE_CHANGES
-       if (!node.isNull()) {
-           Value domValue = getDOMNode(exec,node);
-           ObjectImp *imp = static_cast<ObjectImp *>(domValue.imp());
-           if (!imp->forwardingScriptMessage() && 
-                    (node.handle()->id() == ID_APPLET || node.handle()->id() == ID_EMBED || node.handle()->id() == ID_OBJECT)) {
-             Value v = getRuntimeObject(exec, node, domValue);
-             if (!v.isNull())
-               return v;
-           }
-           return domValue;
-       }
-#else
       return getDOMNode(exec,node);
-#endif
     }
     else
       return getNamedItems(exec,propertyName);
@@ -3132,21 +3168,7 @@ Value KJS::HTMLCollection::getNamedItems(ExecState *exec, const Identifier &prop
 
   if (namedItems.count() == 1) {
     DOM::Node node = namedItems[0];
-#if APPLE_CHANGES
-    if (!node.isNull()) {
-       Value domValue = getDOMNode(exec,node);
-       ObjectImp *imp = static_cast<ObjectImp *>(domValue.imp());
-       if (!imp->forwardingScriptMessage() && 
-                (node.handle()->id() == ID_APPLET || node.handle()->id() == ID_EMBED || node.handle()->id() == ID_OBJECT)) {
-         Value v = getRuntimeObject(exec, node, domValue);
-         if (!v.isNull())
-           return v;
-       }
-       return domValue;
-    }
-#else
     return getDOMNode(exec,node);
-#endif
   }
   
   return Value(new DOMNamedNodesCollection(exec,namedItems));
index e684d0004fe82deb9316da6552ca2f7dcfa04dfa..9d71d832f5aed9ab7305a264350154e71ef06056 100644 (file)
@@ -68,6 +68,11 @@ namespace KJS {
     virtual const ClassInfo* classInfo() const;
     static const ClassInfo info;
 
+#if APPLE_CHANGES
+    virtual Value call(ExecState *exec, Object &thisObj, const List&args);
+    virtual bool implementsCall() const;
+#endif
+
     static const ClassInfo html_info, head_info, link_info, title_info,
       meta_info, base_info, isIndex_info, style_info, body_info, form_info,
       select_info, optGroup_info, option_info, input_info, textArea_info,
index be79603659ff7c7ce6e532f5f6cac2e9aa63e636..a22ef493cdf907122f93672998ad8e7f3d66d598 100644 (file)
@@ -852,19 +852,7 @@ Value Window::get(ExecState *exec, const Identifier &p) const
     DOM::HTMLCollection coll = m_part->htmlDocument().all();
     DOM::HTMLElement element = coll.namedItem(p.string());    
     if (!element.isNull()) {
-#if APPLE_CHANGES
-       Value domValue = getDOMNode(exec,element);
-       ObjectImp *imp = static_cast<ObjectImp *>(domValue.imp());
-       if (!imp->forwardingScriptMessage() && 
-               (element.handle()->id() == ID_APPLET || element.handle()->id() == ID_EMBED || element.handle()->id() == ID_OBJECT)) {
-           Value v = getRuntimeObject(exec,element,domValue);
-           if (!v.isNull())
-               return v;
-       }
-       return domValue;
-#else
       return getDOMNode(exec,element);
-#endif
     }
   }