[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/3.5/kdelibs/khtml/ecma
From: Germain Garand <germain () ebooksfrance ! com>
Date: 2006-10-01 13:41:46
Message-ID: 1159710106.292073.32765.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 591021 by ggarand:
commiting partial fix for #134771 to get a working instanceof on most DOM objects
the rest of it is completely above my head and in the benevolent hands of Mighty Maksim...
CCBUG: 134771
M +22 -0 kjs_binding.cpp
M +2 -1 kjs_binding.h
--- branches/KDE/3.5/kdelibs/khtml/ecma/kjs_binding.cpp #591020:591021
@@ -92,6 +92,28 @@
return "[object " + className() + "]";
}
+Boolean DOMObject::hasInstance(ExecState *exec, const Value &value)
+{
+ if (value.type() != ObjectType)
+ return Boolean(false);
+
+ Value prot = get(exec,prototypePropertyName);
+ if (prot.type() != ObjectType && prot.type() != NullType) {
+ Object err = Error::create(exec, TypeError, "Invalid prototype encountered "
+ "in instanceof operation.");
+ exec->setException(err);
+ return Boolean(false);
+ }
+
+ Object v = Object(static_cast<ObjectImp*>(value.imp()));
+ while ((v = Object::dynamicCast(v.prototype())).imp()) {
+ if (v.imp() == prot.imp())
+ return Boolean(true);
+ }
+ return Boolean(false);
+}
+
+
Value DOMFunction::get(ExecState *exec, const Identifier &propertyName) const
{
try {
--- branches/KDE/3.5/kdelibs/khtml/ecma/kjs_binding.h #591020:591021
@@ -53,7 +53,8 @@
virtual Value get(ExecState *exec, const Identifier &propertyName) const;
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const
{ return ObjectImp::get(exec, propertyName); }
-
+ virtual bool implementsHasInstance() const { return true; }
+ virtual Boolean hasInstance(ExecState *exec, const Value &value);
virtual void put(ExecState *exec, const Identifier &propertyName,
const Value &value, int attr = None);
virtual void tryPut(ExecState *exec, const Identifier &propertyName,
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic