[webkit-changes] cvs commit: WebCore/khtml/ecma domparser.cpp
kjs_binding.cpp kjs_css.cpp kjs_dom.cpp kjs_events.cpp
kjs_html.cpp kjs_navigator.cpp kjs_range.cpp
kjs_traversal.cpp kjs_views.cpp kjs_window.cpp
xmlhttprequest.cpp xmlserializer.cpp
Darin
darin at opensource.apple.com
Mon Aug 15 17:47:49 PDT 2005
darin 05/08/15 17:47:49
Modified: . ChangeLog
bindings NP_jsobject.cpp runtime.h runtime_array.cpp
runtime_object.h
bindings/jni jni_instance.cpp jni_runtime.cpp
bindings/objc WebScriptObject.mm objc_class.h objc_header.h
objc_runtime.h objc_runtime.mm objc_utility.h
objc_utility.mm
kjs array_object.cpp bool_object.cpp date_object.cpp
function.cpp function_object.cpp internal.cpp
nodes.cpp number_object.cpp object.cpp object.h
object_object.cpp reference.cpp regexp_object.cpp
string_object.cpp
. ChangeLog
khtml/css cssstyleselector.cpp
khtml/ecma domparser.cpp kjs_binding.cpp kjs_css.cpp
kjs_dom.cpp kjs_events.cpp kjs_html.cpp
kjs_navigator.cpp kjs_range.cpp kjs_traversal.cpp
kjs_views.cpp kjs_window.cpp xmlhttprequest.cpp
xmlserializer.cpp
Log:
JavaScriptCore:
Reviewed by Geoff.
- fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4437
clean up error creation with new throwError function
* bindings/NP_jsobject.cpp:
(_NPN_SetException):
* bindings/jni/jni_instance.cpp:
(JavaInstance::invokeMethod):
* bindings/jni/jni_runtime.cpp:
(JavaField::dispatchValueFromInstance):
(JavaField::dispatchSetValueToInstance):
* bindings/objc/WebScriptObject.mm:
(-[WebScriptObject _initializeWithObjectImp:originExecutionContext:executionContext:]):
(-[WebScriptObject _initWithObjectImp:originExecutionContext:executionContext:]):
(+[WebScriptObject throwException:]):
(-[WebScriptObject setException:]):
(+[WebScriptObject _convertValueToObjcValue:originExecutionContext:executionContext:]):
* bindings/objc/objc_class.h:
(KJS::Bindings::ObjcClass::~ObjcClass):
(KJS::Bindings::ObjcClass::ObjcClass):
(KJS::Bindings::ObjcClass::operator=):
(KJS::Bindings::ObjcClass::constructorAt):
(KJS::Bindings::ObjcClass::numConstructors):
* bindings/objc/objc_header.h:
* bindings/objc/objc_runtime.h:
(KJS::Bindings::ObjcField::~ObjcField):
(KJS::Bindings::ObjcField::ObjcField):
(KJS::Bindings::ObjcField::operator=):
(KJS::Bindings::ObjcMethod::ObjcMethod):
(KJS::Bindings::ObjcMethod::~ObjcMethod):
(KJS::Bindings::ObjcMethod::operator=):
* bindings/objc/objc_runtime.mm:
(ObjcField::valueFromInstance):
(ObjcField::setValueToInstance):
(ObjcArray::setValueAt):
(ObjcArray::valueAt):
* bindings/objc/objc_utility.h:
* bindings/objc/objc_utility.mm:
(KJS::Bindings::JSMethodNameToObjCMethodName):
(KJS::Bindings::convertValueToObjcValue):
(KJS::Bindings::convertNSStringToString):
(KJS::Bindings::convertObjcValueToValue):
(KJS::Bindings::objcValueTypeForType):
(KJS::Bindings::createObjcInstanceForValue):
(KJS::Bindings::throwError):
* bindings/runtime.h:
(KJS::Bindings::Parameter::~Parameter):
(KJS::Bindings::Method::~Method):
(KJS::Bindings::Instance::Instance):
(KJS::Bindings::Instance::begin):
(KJS::Bindings::Instance::end):
(KJS::Bindings::Instance::getValueOfUndefinedField):
(KJS::Bindings::Instance::supportsSetValueOfUndefinedField):
(KJS::Bindings::Instance::setValueOfUndefinedField):
(KJS::Bindings::Instance::valueOf):
* bindings/runtime_array.cpp:
(RuntimeArrayImp::put):
* bindings/runtime_object.h:
(KJS::RuntimeObjectImp::setInternalInstance):
(KJS::RuntimeObjectImp::getInternalInstance):
* kjs/array_object.cpp:
(getProperty):
(ArrayProtoFuncImp::callAsFunction):
(ArrayObjectImp::construct):
* kjs/bool_object.cpp:
(BooleanProtoFuncImp::callAsFunction):
* kjs/date_object.cpp:
(KJS::DateProtoFuncImp::callAsFunction):
* kjs/function.cpp:
(KJS::decode):
(KJS::GlobalFuncImp::callAsFunction):
* kjs/function_object.cpp:
(FunctionProtoFuncImp::callAsFunction):
(FunctionObjectImp::construct):
* kjs/internal.cpp:
(KJS::UndefinedImp::toObject):
(KJS::NullImp::toObject):
(KJS::InterpreterImp::evaluate):
(KJS::InternalFunctionImp::hasInstance):
* kjs/nodes.cpp:
(Node::throwError):
(substitute):
(Node::setExceptionDetailsIfNeeded):
(undefinedVariableError):
(ProgramNode::ProgramNode):
* kjs/number_object.cpp:
(NumberProtoFuncImp::callAsFunction):
* kjs/object.cpp:
(KJS::ObjectImp::call):
(KJS::ObjectImp::defaultValue):
(KJS::Error::create):
(KJS::throwError):
* kjs/object.h:
(KJS::ObjectImp::clearProperties):
(KJS::ObjectImp::getPropertySlot):
(KJS::ObjectImp::getOwnPropertySlot):
* kjs/object_object.cpp:
(ObjectProtoFuncImp::callAsFunction):
* kjs/reference.cpp:
(KJS::Reference::getBase):
(KJS::Reference::getValue):
(KJS::Reference::putValue):
(KJS::Reference::deleteValue):
* kjs/regexp_object.cpp:
(RegExpProtoFuncImp::callAsFunction):
(RegExpObjectImp::construct):
* kjs/string_object.cpp:
(StringProtoFuncImp::callAsFunction):
WebCore:
Reviewed by Geoff.
- fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4437
clean up error creation with new throwError function
* khtml/css/cssstyleselector.cpp:
(khtml::CSSStyleSelector::CSSStyleSelector):
(khtml::parseUASheet):
(khtml::CSSStyleSelector::initElementAndPseudoState):
(khtml::checkPseudoState):
(khtml::CSSStyleSelector::locateCousinList):
(khtml::CSSStyleSelector::locateSharedStyle):
(khtml::CSSStyleSelector::adjustRenderStyle):
(khtml::CSSStyleSelector::checkOneSelector):
(khtml::CSSRuleSet::addToRuleSet):
(khtml::colorForCSSValue):
(khtml::CSSStyleSelector::applyProperty):
(khtml::CSSStyleSelector::mapBackgroundAttachment):
(khtml::CSSStyleSelector::mapBackgroundImage):
(khtml::CSSStyleSelector::mapBackgroundRepeat):
(khtml::CSSStyleSelector::mapBackgroundXPosition):
(khtml::CSSStyleSelector::mapBackgroundYPosition):
(khtml::CSSStyleSelector::getComputedSizeFromSpecifiedSize):
* khtml/ecma/domparser.cpp:
(KJS::DOMParserProtoFunc::callAsFunction):
* khtml/ecma/kjs_binding.cpp:
(KJS::ScriptInterpreter::putDOMObject):
(KJS::ScriptInterpreter::putDOMNodeForDocument):
(KJS::setDOMException):
* khtml/ecma/kjs_css.cpp:
(KJS::DOMCSSStyleDeclarationProtoFunc::callAsFunction):
(KJS::DOMStyleSheetListFunc::callAsFunction):
(KJS::KJS::DOMMediaListProtoFunc::callAsFunction):
(KJS::DOMCSSStyleSheetProtoFunc::callAsFunction):
(KJS::DOMCSSRuleListFunc::callAsFunction):
(KJS::DOMCSSRuleFunc::callAsFunction):
(KJS::DOMCSSPrimitiveValueProtoFunc::callAsFunction):
(KJS::DOMCSSValueListFunc::callAsFunction):
* khtml/ecma/kjs_dom.cpp:
(KJS::DOMNodeProtoFunc::callAsFunction):
(KJS::DOMNodeListFunc::callAsFunction):
(KJS::DOMDocumentProtoFunc::callAsFunction):
(KJS::DOMElementProtoFunc::callAsFunction):
(KJS::DOMDOMImplementationProtoFunc::callAsFunction):
(KJS::DOMNamedNodeMapProtoFunc::callAsFunction):
(KJS::DOMCharacterDataProtoFunc::callAsFunction):
(KJS::DOMTextProtoFunc::callAsFunction):
* khtml/ecma/kjs_events.cpp:
(KJS::DOMEventProtoFunc::callAsFunction):
(KJS::DOMUIEventProtoFunc::callAsFunction):
(KJS::DOMMouseEventProtoFunc::callAsFunction):
(KJS::DOMKeyboardEventProtoFunc::callAsFunction):
(KJS::DOMMutationEventProtoFunc::callAsFunction):
(KJS::DOMWheelEventProtoFunc::callAsFunction):
(KJS::ClipboardProtoFunc::callAsFunction):
* khtml/ecma/kjs_html.cpp:
(KJS::KJS::HTMLDocFunction::callAsFunction):
(KJS::KJS::HTMLElementFunction::callAsFunction):
(KJS::KJS::HTMLCollectionProtoFunc::callAsFunction):
(KJS::KJS::Context2DFunction::callAsFunction):
(KJS::Context2D::putValueProperty):
(KJS::GradientFunction::callAsFunction):
* khtml/ecma/kjs_navigator.cpp:
(KJS::NavigatorFunc::callAsFunction):
* khtml/ecma/kjs_range.cpp:
(KJS::DOMRangeProtoFunc::callAsFunction):
* khtml/ecma/kjs_traversal.cpp:
(KJS::DOMNodeIteratorProtoFunc::callAsFunction):
(KJS::DOMNodeFilterProtoFunc::callAsFunction):
(KJS::DOMTreeWalkerProtoFunc::callAsFunction):
* khtml/ecma/kjs_views.cpp:
(KJS::DOMAbstractViewFunc::callAsFunction):
* khtml/ecma/kjs_window.cpp:
(KJS::Window::interpreter):
(KJS::Window::retrieveWindow):
(KJS::Window::retrieveActive):
(KJS::Window::isSafeScript):
(KJS::Window::clear):
(KJS::WindowFunc::callAsFunction):
(KJS::ScheduledAction::execute):
(KJS::WindowQObject::pauseTimeouts):
(KJS::LocationFunc::callAsFunction):
(KJS::Selection::toString):
(KJS::SelectionFunc::callAsFunction):
(KJS::HistoryFunc::callAsFunction):
* khtml/ecma/xmlhttprequest.cpp:
(KJS::XMLHttpRequestProtoFunc::callAsFunction):
* khtml/ecma/xmlserializer.cpp:
(KJS::XMLSerializerProtoFunc::callAsFunction):
Revision Changes Path
1.800 +116 -4 JavaScriptCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
retrieving revision 1.799
retrieving revision 1.800
diff -u -r1.799 -r1.800
--- ChangeLog 15 Aug 2005 20:37:09 -0000 1.799
+++ ChangeLog 16 Aug 2005 00:47:20 -0000 1.800
@@ -1,11 +1,123 @@
+2005-08-15 Darin Adler <darin at apple.com>
+
+ Reviewed by Geoff.
+
+ - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4437
+ clean up error creation with new throwError function
+
+ * bindings/NP_jsobject.cpp:
+ (_NPN_SetException):
+ * bindings/jni/jni_instance.cpp:
+ (JavaInstance::invokeMethod):
+ * bindings/jni/jni_runtime.cpp:
+ (JavaField::dispatchValueFromInstance):
+ (JavaField::dispatchSetValueToInstance):
+ * bindings/objc/WebScriptObject.mm:
+ (-[WebScriptObject _initializeWithObjectImp:originExecutionContext:executionContext:]):
+ (-[WebScriptObject _initWithObjectImp:originExecutionContext:executionContext:]):
+ (+[WebScriptObject throwException:]):
+ (-[WebScriptObject setException:]):
+ (+[WebScriptObject _convertValueToObjcValue:originExecutionContext:executionContext:]):
+ * bindings/objc/objc_class.h:
+ (KJS::Bindings::ObjcClass::~ObjcClass):
+ (KJS::Bindings::ObjcClass::ObjcClass):
+ (KJS::Bindings::ObjcClass::operator=):
+ (KJS::Bindings::ObjcClass::constructorAt):
+ (KJS::Bindings::ObjcClass::numConstructors):
+ * bindings/objc/objc_header.h:
+ * bindings/objc/objc_runtime.h:
+ (KJS::Bindings::ObjcField::~ObjcField):
+ (KJS::Bindings::ObjcField::ObjcField):
+ (KJS::Bindings::ObjcField::operator=):
+ (KJS::Bindings::ObjcMethod::ObjcMethod):
+ (KJS::Bindings::ObjcMethod::~ObjcMethod):
+ (KJS::Bindings::ObjcMethod::operator=):
+ * bindings/objc/objc_runtime.mm:
+ (ObjcField::valueFromInstance):
+ (ObjcField::setValueToInstance):
+ (ObjcArray::setValueAt):
+ (ObjcArray::valueAt):
+ * bindings/objc/objc_utility.h:
+ * bindings/objc/objc_utility.mm:
+ (KJS::Bindings::JSMethodNameToObjCMethodName):
+ (KJS::Bindings::convertValueToObjcValue):
+ (KJS::Bindings::convertNSStringToString):
+ (KJS::Bindings::convertObjcValueToValue):
+ (KJS::Bindings::objcValueTypeForType):
+ (KJS::Bindings::createObjcInstanceForValue):
+ (KJS::Bindings::throwError):
+ * bindings/runtime.h:
+ (KJS::Bindings::Parameter::~Parameter):
+ (KJS::Bindings::Method::~Method):
+ (KJS::Bindings::Instance::Instance):
+ (KJS::Bindings::Instance::begin):
+ (KJS::Bindings::Instance::end):
+ (KJS::Bindings::Instance::getValueOfUndefinedField):
+ (KJS::Bindings::Instance::supportsSetValueOfUndefinedField):
+ (KJS::Bindings::Instance::setValueOfUndefinedField):
+ (KJS::Bindings::Instance::valueOf):
+ * bindings/runtime_array.cpp:
+ (RuntimeArrayImp::put):
+ * bindings/runtime_object.h:
+ (KJS::RuntimeObjectImp::setInternalInstance):
+ (KJS::RuntimeObjectImp::getInternalInstance):
+ * kjs/array_object.cpp:
+ (getProperty):
+ (ArrayProtoFuncImp::callAsFunction):
+ (ArrayObjectImp::construct):
+ * kjs/bool_object.cpp:
+ (BooleanProtoFuncImp::callAsFunction):
+ * kjs/date_object.cpp:
+ (KJS::DateProtoFuncImp::callAsFunction):
+ * kjs/function.cpp:
+ (KJS::decode):
+ (KJS::GlobalFuncImp::callAsFunction):
+ * kjs/function_object.cpp:
+ (FunctionProtoFuncImp::callAsFunction):
+ (FunctionObjectImp::construct):
+ * kjs/internal.cpp:
+ (KJS::UndefinedImp::toObject):
+ (KJS::NullImp::toObject):
+ (KJS::InterpreterImp::evaluate):
+ (KJS::InternalFunctionImp::hasInstance):
+ * kjs/nodes.cpp:
+ (Node::throwError):
+ (substitute):
+ (Node::setExceptionDetailsIfNeeded):
+ (undefinedVariableError):
+ (ProgramNode::ProgramNode):
+ * kjs/number_object.cpp:
+ (NumberProtoFuncImp::callAsFunction):
+ * kjs/object.cpp:
+ (KJS::ObjectImp::call):
+ (KJS::ObjectImp::defaultValue):
+ (KJS::Error::create):
+ (KJS::throwError):
+ * kjs/object.h:
+ (KJS::ObjectImp::clearProperties):
+ (KJS::ObjectImp::getPropertySlot):
+ (KJS::ObjectImp::getOwnPropertySlot):
+ * kjs/object_object.cpp:
+ (ObjectProtoFuncImp::callAsFunction):
+ * kjs/reference.cpp:
+ (KJS::Reference::getBase):
+ (KJS::Reference::getValue):
+ (KJS::Reference::putValue):
+ (KJS::Reference::deleteValue):
+ * kjs/regexp_object.cpp:
+ (RegExpProtoFuncImp::callAsFunction):
+ (RegExpObjectImp::construct):
+ * kjs/string_object.cpp:
+ (StringProtoFuncImp::callAsFunction):
+
2005-08-15 Anders Carlsson <andersca at mac.com>
Reviewed by Darin.
* tests/mozilla/ecma_3/Date/15.9.5.5.js:
- Remove the code which tests that Date.toLocaleString should be parsable
- by Date.parse. That is not true according to the spec.
-
+ Remove the code which tests that Date.toLocaleString should be parsable
+ by Date.parse. That is not true according to the spec.
+
2005-08-15 Darin Adler <darin at apple.com>
Reviewed by Geoff.
@@ -132,7 +244,7 @@
Reviewed by John.
- - two simple speed improvements for a 3% speed gain
+ - two simple speed improvements for a 3% speed gain
* JavaScriptCore.xcodeproj/project.pbxproj: turn on -fstrict-aliasing
1.21 +2 -3 JavaScriptCore/bindings/NP_jsobject.cpp
Index: NP_jsobject.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/bindings/NP_jsobject.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- NP_jsobject.cpp 8 Aug 2005 04:07:22 -0000 1.20
+++ NP_jsobject.cpp 16 Aug 2005 00:47:21 -0000 1.21
@@ -397,14 +397,13 @@
return false;
}
-void _NPN_SetException (NPObject *o, const NPUTF8 *message)
+void _NPN_SetException(NPObject *o, const NPUTF8 *message)
{
if (o->_class == NPScriptObjectClass) {
JavaScriptObject *obj = (JavaScriptObject *)o;
ExecState *exec = obj->executionContext->interpreter()->globalExec();
Interpreter::lock();
- ObjectImp *err = Error::create(exec, GeneralError, message);
- exec->setException (err);
+ throwError(exec, GeneralError, message);
Interpreter::unlock();
}
}
1.31 +11 -14 JavaScriptCore/bindings/runtime.h
Index: runtime.h
===================================================================
RCS file: /cvs/root/JavaScriptCore/bindings/runtime.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- runtime.h 8 Aug 2005 04:07:22 -0000 1.30
+++ runtime.h 16 Aug 2005 00:47:21 -0000 1.31
@@ -29,11 +29,8 @@
#include "object.h"
#include "value.h"
-namespace KJS
-{
-
-namespace Bindings
-{
+namespace KJS {
+namespace Bindings {
class Instance;
class Method;
@@ -47,7 +44,7 @@
{
public:
virtual RuntimeType type() const = 0;
- virtual ~Parameter() {};
+ virtual ~Parameter() {}
};
// FIXME: Constructor should be removed from abstract runtime classes
@@ -102,7 +99,7 @@
virtual long numParameters() const = 0;
- virtual ~Method() {};
+ virtual ~Method() {}
};
class Class
@@ -140,7 +137,7 @@
static void *createLanguageInstanceForValue(ExecState *exec, BindingLanguage language, ObjectImp *value, const RootObject *origin, const RootObject *current);
static ObjectImp *createRuntimeObject(BindingLanguage language, void *nativeInstance, const RootObject *r = 0);
- Instance() : _executionContext(0) {};
+ Instance() : _executionContext(0) {}
Instance(const Instance &other);
@@ -149,23 +146,23 @@
// These functions are called before and after the main entry points into
// the native implementations. They can be used to establish and cleanup
// any needed state.
- virtual void begin() {};
- virtual void end() {};
+ virtual void begin() {}
+ virtual void end() {}
virtual Class *getClass() const = 0;
virtual ValueImp *getValueOfField(ExecState *exec, const Field *aField) const;
- virtual ValueImp *getValueOfUndefinedField(ExecState *exec, const Identifier &property, Type hint) const { return Undefined(); };
+ virtual ValueImp *getValueOfUndefinedField(ExecState *exec, const Identifier &property, Type hint) const { return Undefined(); }
virtual void setValueOfField(ExecState *exec, const Field *aField, ValueImp *aValue) const;
- virtual bool supportsSetValueOfUndefinedField() { return false; };
- virtual void setValueOfUndefinedField(ExecState *exec, const Identifier &property, ValueImp *aValue) {};
+ virtual bool supportsSetValueOfUndefinedField() { return false; }
+ virtual void setValueOfUndefinedField(ExecState *exec, const Identifier &property, ValueImp *aValue) {}
virtual ValueImp *invokeMethod(ExecState *exec, const MethodList &method, const List &args) = 0;
virtual ValueImp *invokeDefaultMethod(ExecState *exec, const List &args) = 0;
virtual ValueImp *defaultValue(Type hint) const = 0;
- virtual ValueImp *valueOf() const { return String(getClass()->name()); };
+ virtual ValueImp *valueOf() const { return String(getClass()->name()); }
void setExecutionContext(const RootObject *r) { _executionContext = r; }
const RootObject *executionContext() const { return _executionContext; }
1.11 +2 -4 JavaScriptCore/bindings/runtime_array.cpp
Index: runtime_array.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/bindings/runtime_array.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- runtime_array.cpp 8 Aug 2005 04:07:22 -0000 1.10
+++ runtime_array.cpp 16 Aug 2005 00:47:21 -0000 1.11
@@ -87,8 +87,7 @@
void RuntimeArrayImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
{
if (propertyName == lengthPropertyName) {
- ObjectImp *err = Error::create(exec,RangeError);
- exec->setException(err);
+ throwError(exec, RangeError);
return;
}
@@ -105,8 +104,7 @@
void RuntimeArrayImp::put(ExecState *exec, unsigned index, ValueImp *value, int attr)
{
if (index >= getLength()) {
- ObjectImp *err = Error::create(exec,RangeError);
- exec->setException(err);
+ throwError(exec, RangeError);
return;
}
1.17 +10 -19 JavaScriptCore/bindings/runtime_object.h
Index: runtime_object.h
===================================================================
RCS file: /cvs/root/JavaScriptCore/bindings/runtime_object.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- runtime_object.h 8 Aug 2005 04:07:22 -0000 1.16
+++ runtime_object.h 16 Aug 2005 00:47:21 -0000 1.17
@@ -22,19 +22,17 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _RUNTIME_OBJECT_H_
-#define _RUNTIME_OBJECT_H_
-#include <JavaScriptCore/runtime.h>
-#include <JavaScriptCore/object.h>
-#include <JavaScriptCore/protect.h>
+#ifndef KJS_RUNTIME_OBJECT_H
+#define KJS_RUNTIME_OBJECT_H
+
+#include "runtime.h"
namespace KJS {
class RuntimeObjectImp : public ObjectImp {
public:
RuntimeObjectImp(ObjectImp *proto);
-
~RuntimeObjectImp();
RuntimeObjectImp(Bindings::Instance *i, bool ownsInstance = true);
@@ -42,23 +40,16 @@
const ClassInfo *classInfo() const { return &info; }
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
-
- virtual void put(ExecState *exec, const Identifier &propertyName,
- ValueImp *value, int attr = None);
-
virtual bool canPut(ExecState *exec, const Identifier &propertyName) const;
-
- virtual bool deleteProperty(ExecState *exec,
- const Identifier &propertyName);
-
+ virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
+ virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual ValueImp *defaultValue(ExecState *exec, Type hint) const;
-
- void setInternalInstance (Bindings::Instance *i) { instance = i; }
- Bindings::Instance *getInternalInstance() const { return instance; }
-
virtual bool implementsCall() const;
virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ void setInternalInstance(Bindings::Instance *i) { instance = i; }
+ Bindings::Instance *getInternalInstance() const { return instance; }
+
static const ClassInfo info;
private:
@@ -70,6 +61,6 @@
bool ownsInstance;
};
-}; // namespace
+} // namespace
#endif
1.29 +1 -3 JavaScriptCore/bindings/jni/jni_instance.cpp
Index: jni_instance.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/bindings/jni/jni_instance.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- jni_instance.cpp 10 Aug 2005 20:51:00 -0000 1.28
+++ jni_instance.cpp 16 Aug 2005 00:47:22 -0000 1.29
@@ -151,9 +151,7 @@
const char *callingURL = 0; // FIXME, need to propagate calling URL to Java
handled = dispatchJNICall (execContext->nativeHandle(), obj, jMethod->isStatic(), jMethod->JNIReturnType(), jMethod->methodID(obj), jArgs, result, callingURL, exceptionDescription);
if (exceptionDescription) {
- ObjectImp *error = Error::create(exec, GeneralError, exceptionDescription->toString(exec).UTF8String().c_str());
- exec->setException(error);
-
+ throwError(exec, GeneralError, exceptionDescription->toString(exec));
free (jArgs);
return Undefined();
}
1.28 +4 -8 JavaScriptCore/bindings/jni/jni_runtime.cpp
Index: jni_runtime.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/bindings/jni/jni_runtime.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- jni_runtime.cpp 8 Aug 2005 21:14:54 -0000 1.27
+++ jni_runtime.cpp 16 Aug 2005 00:47:22 -0000 1.28
@@ -95,10 +95,8 @@
args[0].l = jinstance;
dispatchJNICall (execContext->nativeHandle(), fieldJInstance, false, returnType, mid, args, result, 0, exceptionDescription);
- if (exceptionDescription) {
- ObjectImp *error = Error::create(exec, GeneralError, exceptionDescription->toString(exec).UTF8String().c_str());
- exec->setException(error);
- }
+ if (exceptionDescription)
+ throwError(exec, GeneralError, exceptionDescription->toString(exec));
}
}
}
@@ -183,10 +181,8 @@
args[0].l = jinstance;
args[1] = javaValue;
dispatchJNICall (execContext->nativeHandle(), fieldJInstance, false, void_type, mid, args, result, 0, exceptionDescription);
- if (exceptionDescription) {
- ObjectImp *error = Error::create(exec, GeneralError, exceptionDescription->toString(exec).UTF8String().c_str());
- exec->setException(error);
- }
+ if (exceptionDescription)
+ throwError(exec, GeneralError, exceptionDescription->toString(exec));
}
}
}
1.22 +17 -22 JavaScriptCore/bindings/objc/WebScriptObject.mm
Index: WebScriptObject.mm
===================================================================
RCS file: /cvs/root/JavaScriptCore/bindings/objc/WebScriptObject.mm,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- WebScriptObject.mm 8 Aug 2005 04:07:26 -0000 1.21
+++ WebScriptObject.mm 16 Aug 2005 00:47:23 -0000 1.22
@@ -23,18 +23,18 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import <JavaScriptCore/WebScriptObjectPrivate.h>
+#import "WebScriptObjectPrivate.h"
-#include <JavaScriptCore/internal.h>
-#include <JavaScriptCore/list.h>
-#include <JavaScriptCore/value.h>
-
-#include <objc_jsobject.h>
-#include <objc_instance.h>
-#include <objc_utility.h>
+#import "internal.h"
+#import "list.h"
+#import "value.h"
+
+#import "objc_jsobject.h"
+#import "objc_instance.h"
+#import "objc_utility.h"
-#include <runtime_object.h>
-#include <runtime_root.h>
+#import "runtime_object.h"
+#import "runtime_root.h"
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3
@@ -65,7 +65,7 @@
func (exec, static_cast<ObjectImp*>([obj _executionContext]->rootObjectImp()));
}
-- (void)_initializeWithObjectImp:(ObjectImp *)imp originExecutionContext:(const Bindings::RootObject *)originExecutionContext executionContext:(const Bindings::RootObject *)executionContext
+- (void)_initializeWithObjectImp:(ObjectImp *)imp originExecutionContext:(const RootObject *)originExecutionContext executionContext:(const RootObject *)executionContext
{
_private->imp = imp;
_private->executionContext = executionContext;
@@ -74,7 +74,7 @@
addNativeReference (executionContext, imp);
}
-- _initWithObjectImp:(ObjectImp *)imp originExecutionContext:(const Bindings::RootObject *)originExecutionContext executionContext:(const Bindings::RootObject *)executionContext
+- _initWithObjectImp:(ObjectImp *)imp originExecutionContext:(const RootObject *)originExecutionContext executionContext:(const RootObject *)executionContext
{
assert (imp != 0);
//assert (root != 0);
@@ -158,8 +158,7 @@
ExecState *exec = interp->globalExec();
// If the interpreter has a context, we set the exception.
if (interp->context()) {
- ObjectImp *err = Error::create(exec, GeneralError, [exceptionMessage UTF8String]);
- exec->setException (err);
+ throwError(exec, GeneralError, exceptionMessage);
return YES;
}
interp = interp->nextInterpreter();
@@ -401,17 +400,13 @@
_didExecute(self);
}
-- (void)setException: (NSString *)description
+- (void)setException:(NSString *)description
{
- if (![self _executionContext])
- return;
-
- ExecState *exec = [self _executionContext]->interpreter()->globalExec();
- ObjectImp *err = Error::create(exec, GeneralError, [description UTF8String]);
- exec->setException (err);
+ if (const RootObject *root = [self _executionContext])
+ throwError(root->interpreter()->globalExec(), GeneralError, description);
}
-+ (id)_convertValueToObjcValue:(ValueImp *)value originExecutionContext:(const RootObject *)originExecutionContext executionContext:(const Bindings::RootObject *)executionContext
++ (id)_convertValueToObjcValue:(ValueImp *)value originExecutionContext:(const RootObject *)originExecutionContext executionContext:(const RootObject *)executionContext
{
id result = 0;
1.5 +13 -26 JavaScriptCore/bindings/objc/objc_class.h
Index: objc_class.h
===================================================================
RCS file: /cvs/root/JavaScriptCore/bindings/objc/objc_class.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- objc_class.h 8 Aug 2005 04:07:26 -0000 1.4
+++ objc_class.h 16 Aug 2005 00:47:23 -0000 1.5
@@ -22,26 +22,23 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _BINDINGS_OBJC_CLASS_H_
-#define _BINDINGS_OBJC_CLASS_H_
-#include <CoreFoundation/CoreFoundation.h>
+#ifndef KJS_BINDINGS_OBJC_CLASS_H
+#define KJS_BINDINGS_OBJC_CLASS_H
+#include <CoreFoundation/CoreFoundation.h>
-#include <runtime.h>
-#include <objc_header.h>
-#include <objc_runtime.h>
+#include "objc_runtime.h"
namespace KJS {
-
namespace Bindings {
-class ObjcClass : public KJS::Bindings::Class
+class ObjcClass : public Class
{
// Use the public static factory methods to get instances of JavaClass.
protected:
- void _commonInit (ClassStructPtr aClass);
+ void _commonInit(ClassStructPtr aClass);
void _commonCopy(const ObjcClass &other);
void _commonDelete();
@@ -49,16 +46,11 @@
public:
// Return the cached ObjC of the specified name.
- //static ObjcClass *classForName (const char *name);
- static ObjcClass *classForIsA (ClassStructPtr aClass);
+ static ObjcClass *classForIsA(ClassStructPtr);
- ~ObjcClass () {
- _commonDelete();
- }
+ ~ObjcClass() { _commonDelete(); }
- ObjcClass (const ObjcClass &other) : Class() {
- _commonCopy (other);
- };
+ ObjcClass(const ObjcClass &other) : Class() { _commonCopy(other); }
ObjcClass &operator=(const ObjcClass &other)
{
@@ -66,7 +58,7 @@
return *this;
_commonDelete();
- _commonCopy (other);
+ _commonCopy(other);
return *this;
}
@@ -74,16 +66,12 @@
virtual const char *name() const;
virtual MethodList methodsNamed(const char *name, Instance *instance) const;
-
virtual Field *fieldNamed(const char *name, Instance *instance) const;
virtual ValueImp *fallbackObject(ExecState *exec, Instance *instance, const Identifier &propertyName);
- virtual Constructor *constructorAt(long i) const {
- return 0;
- };
-
- virtual long numConstructors() const { return 0; };
+ virtual Constructor *constructorAt(long i) const { return 0; }
+ virtual long numConstructors() const { return 0; }
ClassStructPtr isa() { return _isa; }
@@ -94,7 +82,6 @@
};
} // namespace Bindings
-
} // namespace KJS
-#endif
\ No newline at end of file
+#endif
1.2 +8 -6 JavaScriptCore/bindings/objc/objc_header.h
Index: objc_header.h
===================================================================
RCS file: /cvs/root/JavaScriptCore/bindings/objc/objc_header.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- objc_header.h 13 Feb 2004 22:39:36 -0000 1.1
+++ objc_header.h 16 Aug 2005 00:47:23 -0000 1.2
@@ -22,10 +22,12 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _BINDINGS_OBJC_HEADER_H_
-#define _BINDINGS_OBJC_HEADER_H_
+
+#ifndef KJS_BINDINGS_OBJC_HEADER_H
+#define KJS_BINDINGS_OBJC_HEADER_H
#ifdef __OBJC__
+
#include <objc/objc-class.h>
#include <objc/objc-runtime.h>
@@ -36,12 +38,12 @@
#else
-typedef struct objc_ivar {} *Ivar;
-typedef struct objc_class {} *ClassStructPtr;
-typedef struct objc_object {} *ObjectStructPtr;
+typedef struct objc_ivar *Ivar;
+typedef struct objc_class *ClassStructPtr;
+typedef struct objc_object *ObjectStructPtr;
class NSMethodSignature;
#endif
-#endif
\ No newline at end of file
+#endif
1.14 +44 -58 JavaScriptCore/bindings/objc/objc_runtime.h
Index: objc_runtime.h
===================================================================
RCS file: /cvs/root/JavaScriptCore/bindings/objc/objc_runtime.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- objc_runtime.h 8 Aug 2005 04:07:26 -0000 1.13
+++ objc_runtime.h 16 Aug 2005 00:47:23 -0000 1.14
@@ -22,21 +22,19 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _BINDINGS_OBJC_RUNTIME_H_
-#define _BINDINGS_OBJC_RUNTIME_H_
+
+#ifndef KJS_BINDINGS_OBJC_RUNTIME_H
+#define KJS_BINDINGS_OBJC_RUNTIME_H
#include <CoreFoundation/CoreFoundation.h>
-#include <runtime.h>
-#include <ustring.h>
+#include "runtime.h"
+#include "ustring.h"
-#include <objc_header.h>
+#include "objc_header.h"
-namespace KJS
-{
-
-namespace Bindings
-{
+namespace KJS {
+namespace Bindings {
class ObjcInstance;
@@ -44,28 +42,26 @@
{
public:
ObjcField(Ivar ivar);
-
ObjcField(CFStringRef name);
- ~ObjcField() {
+ ~ObjcField()
+ {
if (_name)
- CFRelease (_name);
- };
+ CFRelease(_name);
+ }
- ObjcField(const ObjcField &other) : Field() {
+ ObjcField(const ObjcField &other) : Field()
+ {
_ivar = other._ivar;
- if (other._name != _name) {
- if (_name)
- CFRelease (_name);
- if (other._name)
- _name = (CFStringRef)CFRetain (other._name);
- else
- _name = 0;
- }
- };
+ if (other._name)
+ _name = (CFStringRef)CFRetain(other._name);
+ else
+ _name = 0;
+ }
- ObjcField &operator=(const ObjcField &other) {
+ ObjcField &operator=(const ObjcField &other)
+ {
if (this == &other)
return *this;
@@ -73,16 +69,16 @@
if (other._name != _name) {
if (_name)
- CFRelease (_name);
+ CFRelease(_name);
if (other._name)
- _name = (CFStringRef)CFRetain (other._name);
+ _name = (CFStringRef)CFRetain(other._name);
else
_name = 0;
}
return *this;
- };
-
+ }
+
virtual ValueImp *valueFromInstance(ExecState *exec, const Instance *instance) const;
virtual void setValueToInstance(ExecState *exec, const Instance *instance, ValueImp *aValue) const;
@@ -94,41 +90,40 @@
CFStringRef _name;
};
-
class ObjcMethod : public Method
{
public:
- ObjcMethod() : Method(), _objcClass(0), _selector(0) {};
-
+ ObjcMethod() : _objcClass(0), _selector(0) {}
ObjcMethod(struct objc_class *aClass, const char *_selector);
- ~ObjcMethod () {
+ ~ObjcMethod ()
+ {
if (_javaScriptName);
- CFRelease (_javaScriptName);
- };
+ CFRelease(_javaScriptName);
+ }
- ObjcMethod(const ObjcMethod &other) : Method() {
+ ObjcMethod(const ObjcMethod &other) : Method()
+ {
_objcClass = other._objcClass;
_selector = other._selector;
- };
+ }
- ObjcMethod &operator=(const ObjcMethod &other) {
+ ObjcMethod &operator=(const ObjcMethod &other)
+ {
if (this == &other)
return *this;
-
_objcClass = other._objcClass;
_selector = other._selector;
-
return *this;
}
virtual const char *name() const;
virtual long numParameters() const;
-
+
NSMethodSignature *getMethodSignature() const;
bool isFallbackMethod() const { return strcmp(_selector, "invokeUndefinedMethodFromWebScript:withArguments:") == 0; }
- void setJavaScriptName (CFStringRef n);
+ void setJavaScriptName(CFStringRef n);
CFStringRef javaScriptName() const { return _javaScriptName; }
private:
@@ -140,21 +135,20 @@
class ObjcArray : public Array
{
public:
- ObjcArray (ObjectStructPtr a);
-
- ObjcArray (const ObjcArray &other);
+ ObjcArray(ObjectStructPtr);
- ObjcArray &operator=(const ObjcArray &other);
+ ObjcArray(const ObjcArray &);
+ ObjcArray &operator=(const ObjcArray &);
+ virtual ~ObjcArray();
+
virtual void setValueAt(ExecState *exec, unsigned int index, ValueImp *aValue) const;
virtual ValueImp *valueAt(ExecState *exec, unsigned int index) const;
virtual unsigned int getLength() const;
- virtual ~ObjcArray();
-
ObjectStructPtr getObjcArray() const { return _array; }
- static ValueImp *convertObjcArrayToArray (ExecState *exec, ObjectStructPtr anObject);
+ static ValueImp *convertObjcArrayToArray(ExecState *exec, ObjectStructPtr anObject);
private:
ObjectStructPtr _array;
@@ -163,23 +157,16 @@
class ObjcFallbackObjectImp : public ObjectImp {
public:
ObjcFallbackObjectImp(ObjectImp *proto);
-
ObjcFallbackObjectImp(ObjcInstance *i, const Identifier propertyName);
const ClassInfo *classInfo() const { return &info; }
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
-
- virtual void put(ExecState *exec, const Identifier &propertyName,
- ValueImp *value, int attr = None);
-
virtual bool canPut(ExecState *exec, const Identifier &propertyName) const;
-
+ virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
virtual bool implementsCall() const;
virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
-
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
-
virtual ValueImp *defaultValue(ExecState *exec, Type hint) const;
virtual Type type() const;
@@ -193,7 +180,6 @@
};
} // namespace Bindings
-
} // namespace KJS
#endif
1.20 +8 -17 JavaScriptCore/bindings/objc/objc_runtime.mm
Index: objc_runtime.mm
===================================================================
RCS file: /cvs/root/JavaScriptCore/bindings/objc/objc_runtime.mm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- objc_runtime.mm 8 Aug 2005 04:07:26 -0000 1.19
+++ objc_runtime.mm 16 Aug 2005 00:47:23 -0000 1.20
@@ -115,8 +115,7 @@
NS_HANDLER
- ValueImp *exceptionValue = Error::create(exec, GeneralError, [[localException reason] lossyCString]);
- exec->setException(exceptionValue);
+ throwError(exec, GeneralError, [localException reason]);
NS_ENDHANDLER
@@ -152,8 +151,7 @@
NS_HANDLER
- ValueImp *aValue = Error::create(exec, GeneralError, [[localException reason] lossyCString]);
- exec->setException(aValue);
+ throwError(exec, GeneralError, [localException reason]);
NS_ENDHANDLER
}
@@ -189,14 +187,12 @@
void ObjcArray::setValueAt(ExecState *exec, unsigned int index, ValueImp *aValue) const
{
if (![_array respondsToSelector:@selector(insertObject:atIndex:)]) {
- ObjectImp *error = Error::create(exec, TypeError, "Array is not mutable.");
- exec->setException(error);
+ throwError(exec, TypeError, "Array is not mutable.");
return;
}
if (index > [_array count]) {
- ObjectImp *error = Error::create(exec, RangeError, "Index exceeds array size.");
- exec->setException(error);
+ throwError(exec, RangeError, "Index exceeds array size.");
return;
}
@@ -210,8 +206,7 @@
NS_HANDLER
- ObjectImp *error = Error::create(exec, GeneralError, "ObjectiveC exception.");
- exec->setException(error);
+ throwError(exec, GeneralError, "Objective-C exception.");
NS_ENDHANDLER
}
@@ -219,11 +214,8 @@
ValueImp *ObjcArray::valueAt(ExecState *exec, unsigned int index) const
{
- if (index > [_array count]) {
- ObjectImp *error = Error::create(exec, RangeError, "Index exceeds array size.");
- exec->setException(error);
- return error;
- }
+ if (index > [_array count])
+ return throwError(exec, RangeError, "Index exceeds array size.");
ObjectStructPtr obj = 0;
ObjectImp * volatile error;
@@ -235,8 +227,7 @@
NS_HANDLER
- error = Error::create(exec, GeneralError, "ObjectiveC exception.");
- exec->setException(error);
+ error = throwError(exec, GeneralError, "Objective-C exception.");
haveError = true;
NS_ENDHANDLER
1.6 +10 -12 JavaScriptCore/bindings/objc/objc_utility.h
Index: objc_utility.h
===================================================================
RCS file: /cvs/root/JavaScriptCore/bindings/objc/objc_utility.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- objc_utility.h 8 Aug 2005 04:07:26 -0000 1.5
+++ objc_utility.h 16 Aug 2005 00:47:23 -0000 1.6
@@ -22,14 +22,14 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _BINDINGS_OBJC_UTILITY_H_
-#define _BINDINGS_OBJC_UTILITY_H_
-#include <CoreFoundation/CoreFoundation.h>
+#ifndef KJS_BINDINGS_OBJC_UTILITY_H
+#define KJS_BINDINGS_OBJC_UTILITY_H
-#include <value.h>
+#include <CoreFoundation/CoreFoundation.h>
-#include <objc_header.h>
+#include "object.h"
+#include "objc_header.h"
#ifdef __OBJC__
@class NSString;
@@ -37,11 +37,8 @@
class NSString;
#endif
-namespace KJS
-{
-
-namespace Bindings
-{
+namespace KJS {
+namespace Bindings {
typedef union {
ObjectStructPtr objectValue;
@@ -75,10 +72,11 @@
void JSMethodNameToObjCMethodName(const char *name, char *name, unsigned int length);
-void *createObjcInstanceForValue(ObjectImp *value, const RootObject *origin, const RootObject *current);
+void *createObjcInstanceForValue(ValueImp *value, const RootObject *origin, const RootObject *current);
-} // namespace Bindings
+ObjectImp *throwError(ExecState *, ErrorType, NSString *message);
+} // namespace Bindings
} // namespace KJS
#endif
1.20 +35 -22 JavaScriptCore/bindings/objc/objc_utility.mm
Index: objc_utility.mm
===================================================================
RCS file: /cvs/root/JavaScriptCore/bindings/objc/objc_utility.mm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- objc_utility.mm 8 Aug 2005 04:07:26 -0000 1.19
+++ objc_utility.mm 16 Aug 2005 00:47:23 -0000 1.20
@@ -22,22 +22,23 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <Foundation/Foundation.h>
-#include <JavaScriptCore/internal.h>
+#include "objc_utility.h"
+
+#include <Foundation/Foundation.h>
-#include <objc_instance.h>
-#include <objc_utility.h>
+#include "internal.h"
-#include <runtime_array.h>
-#include <runtime_object.h>
-#include <runtime_root.h>
+#include "objc_instance.h"
-#include <WebScriptObjectPrivate.h>
+#include "runtime_array.h"
+#include "runtime_object.h"
+#include "runtime_root.h"
+#include "WebScriptObjectPrivate.h"
-using namespace KJS;
-using namespace KJS::Bindings;
+namespace KJS {
+namespace Bindings {
/*
The default name concatenates the components of the
@@ -50,7 +51,7 @@
moveTo$_ moveTo$$$_
@result Returns the name to be used to represent the specificed selector in the
*/
-void Bindings::JSMethodNameToObjCMethodName(const char *name, char *buffer, unsigned int len)
+void JSMethodNameToObjCMethodName(const char *name, char *buffer, unsigned int len)
{
const char *np = name;
char *bp;
@@ -87,7 +88,7 @@
[], other exception
*/
-ObjcValue Bindings::convertValueToObjcValue (ExecState *exec, ValueImp *value, ObjcValueType type)
+ObjcValue convertValueToObjcValue (ExecState *exec, ValueImp *value, ObjcValueType type)
{
ObjcValue result;
double d = 0;
@@ -98,7 +99,7 @@
switch (type){
case ObjcObjectType: {
Interpreter *originInterpreter = exec->interpreter();
- const Bindings::RootObject *originExecutionContext = rootForInterpreter(originInterpreter);
+ const RootObject *originExecutionContext = rootForInterpreter(originInterpreter);
Interpreter *interpreter = 0;
if (originInterpreter->isGlobalObject(value)) {
@@ -108,9 +109,9 @@
if (!interpreter)
interpreter = originInterpreter;
- const Bindings::RootObject *executionContext = rootForInterpreter(interpreter);
+ const RootObject *executionContext = rootForInterpreter(interpreter);
if (!executionContext) {
- Bindings::RootObject *newExecutionContext = new Bindings::RootObject(0);
+ RootObject *newExecutionContext = new RootObject(0);
newExecutionContext->setInterpreter (interpreter);
executionContext = newExecutionContext;
}
@@ -164,7 +165,7 @@
return result;
}
-ValueImp *Bindings::convertNSStringToString(NSString *nsstring)
+ValueImp *convertNSStringToString(NSString *nsstring)
{
unichar *chars;
unsigned int length = [nsstring length];
@@ -192,7 +193,7 @@
other should not happen
*/
-ValueImp *Bindings::convertObjcValueToValue (ExecState *exec, void *buffer, ObjcValueType type)
+ValueImp *convertObjcValueToValue (ExecState *exec, void *buffer, ObjcValueType type)
{
ValueImp *aValue = NULL;
@@ -286,7 +287,7 @@
}
-ObjcValueType Bindings::objcValueTypeForType (const char *type)
+ObjcValueType objcValueTypeForType (const char *type)
{
int typeLength = strlen(type);
ObjcValueType objcValueType = ObjcInvalidType;
@@ -332,12 +333,24 @@
}
-void *Bindings::createObjcInstanceForValue (ObjectImp *value, const RootObject *origin, const RootObject *current)
+void *createObjcInstanceForValue(ValueImp *value, const RootObject *origin, const RootObject *current)
{
if (!value->isObject())
return 0;
+ ObjectImp *object = static_cast<ObjectImp *>(value);
+ return [[[WebScriptObject alloc] _initWithObjectImp:object originExecutionContext:origin executionContext:current] autorelease];
+}
- ObjectImp *imp = static_cast<ObjectImp*>(value);
-
- return [[[WebScriptObject alloc] _initWithObjectImp:imp originExecutionContext:origin executionContext:current] autorelease];
+ObjectImp *throwError(ExecState *exec, ErrorType type, NSString *message)
+{
+ assert(message);
+ size_t length = [message length];
+ unichar *buffer = new unichar[length];
+ [message getCharacters:buffer];
+ ObjectImp *error = throwError(exec, type, UString(reinterpret_cast<UChar *>(buffer), length));
+ delete [] buffer;
+ return error;
+}
+
+}
}
1.51 +30 -43 JavaScriptCore/kjs/array_object.cpp
Index: array_object.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/array_object.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- array_object.cpp 8 Aug 2005 04:35:22 -0000 1.50
+++ array_object.cpp 16 Aug 2005 00:47:24 -0000 1.51
@@ -421,6 +421,14 @@
return true;
}
+static ValueImp *getProperty(ExecState *exec, ObjectImp *obj, unsigned index)
+{
+ PropertySlot slot;
+ if (!obj->getPropertySlot(exec, index, slot))
+ return NULL;
+ return slot.getValue(exec, index);
+}
+
// ECMA 15.4.4
ValueImp *ArrayProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
@@ -432,11 +440,8 @@
case ToLocaleString:
case ToString:
- if (!thisObj->inherits(&ArrayInstanceImp::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&ArrayInstanceImp::info))
+ return throwError(exec, TypeError);
// fall through
case Join: {
@@ -472,10 +477,7 @@
if (conversionFunction->isObject() && static_cast<ObjectImp *>(conversionFunction)->implementsCall()) {
str += static_cast<ObjectImp *>(conversionFunction)->call(exec, o, List())->toString(exec);
} else {
- UString msg = "Can't convert " + o->className() + " object to string";
- ObjectImp *error = Error::create(exec, RangeError, msg.cstring().c_str());
- exec->setException(error);
- return error;
+ return throwError(exec, RangeError, "Can't convert " + o->className() + " object to string");
}
} else {
str += element->toString(exec);
@@ -502,8 +504,7 @@
// by checking for n != 0, but that doesn't work if thisObj is an empty array.
length = curObj->get(exec,lengthPropertyName)->toUInt32(exec);
while (k < length) {
- ValueImp *v;
- if (curObj->getProperty(exec, k, v))
+ if (ValueImp *v = getProperty(exec, curObj, k))
arr->put(exec, n, v);
n++;
k++;
@@ -546,17 +547,15 @@
for (unsigned int k = 0; k < middle; k++) {
unsigned lk1 = length - k - 1;
- ValueImp *obj;
- ValueImp *obj2;
- bool has2 = thisObj->getProperty(exec, lk1, obj2);
- bool has1 = thisObj->getProperty(exec, k, obj);
+ ValueImp *obj2 = getProperty(exec, thisObj, lk1);
+ ValueImp *obj = getProperty(exec, thisObj, k);
- if (has2)
+ if (obj2)
thisObj->put(exec, k, obj2);
else
thisObj->deleteProperty(exec, k);
- if (has1)
+ if (obj)
thisObj->put(exec, lk1, obj);
else
thisObj->deleteProperty(exec, lk1);
@@ -571,8 +570,7 @@
} else {
result = thisObj->get(exec, 0);
for(unsigned int k = 1; k < length; k++) {
- ValueImp *obj;
- if (thisObj->getProperty(exec, k, obj))
+ if (ValueImp *obj = getProperty(exec, thisObj, k))
thisObj->put(exec, k-1, obj);
else
thisObj->deleteProperty(exec, k-1);
@@ -618,9 +616,8 @@
int b = static_cast<int>(begin);
int e = static_cast<int>(end);
for(int k = b; k < e; k++, n++) {
- ValueImp *obj;
- if (thisObj->getProperty(exec, k, obj))
- resObj->put(exec, n, obj);
+ if (ValueImp *v = getProperty(exec, thisObj, k))
+ resObj->put(exec, n, v);
}
resObj->put(exec, lengthPropertyName, Number(n), DontEnum | DontDelete);
break;
@@ -712,9 +709,8 @@
//printf( "Splicing from %d, deleteCount=%d \n", begin, deleteCount );
for(unsigned int k = 0; k < deleteCount; k++) {
- ValueImp *obj;
- if (thisObj->getProperty(exec, k+begin, obj))
- resObj->put(exec, k, obj);
+ if (ValueImp *v = getProperty(exec, thisObj, k+begin))
+ resObj->put(exec, k, v);
}
resObj->put(exec, lengthPropertyName, Number(deleteCount), DontEnum | DontDelete);
@@ -725,9 +721,8 @@
{
for ( unsigned int k = begin; k < length - deleteCount; ++k )
{
- ValueImp *obj;
- if (thisObj->getProperty(exec, k+deleteCount, obj))
- thisObj->put(exec, k+additionalArgs, obj);
+ if (ValueImp *v = getProperty(exec, thisObj, k+deleteCount))
+ thisObj->put(exec, k+additionalArgs, v);
else
thisObj->deleteProperty(exec, k+additionalArgs);
}
@@ -738,8 +733,7 @@
{
for ( unsigned int k = length - deleteCount; (int)k > begin; --k )
{
- ValueImp *obj;
- if (thisObj->getProperty(exec, k + deleteCount - 1, obj))
+ if (ValueImp *obj = getProperty(exec, thisObj, k + deleteCount - 1))
thisObj->put(exec, k + additionalArgs - 1, obj);
else
thisObj->deleteProperty(exec, k+additionalArgs-1);
@@ -757,9 +751,8 @@
unsigned int nrArgs = args.size();
for ( unsigned int k = length; k > 0; --k )
{
- ValueImp *obj;
- if (thisObj->getProperty(exec, k - 1, obj))
- thisObj->put(exec, k+nrArgs-1, obj);
+ if (ValueImp *v = getProperty(exec, thisObj, k - 1))
+ thisObj->put(exec, k+nrArgs-1, v);
else
thisObj->deleteProperty(exec, k+nrArgs-1);
}
@@ -779,11 +772,8 @@
ObjectImp *eachFunction = args[0]->toObject(exec);
- if (!eachFunction->implementsCall()) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!eachFunction->implementsCall())
+ return throwError(exec, TypeError);
ObjectImp *applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicInterpreter()->globalObject() : args[1]->toObject(exec);
@@ -847,11 +837,8 @@
// a single numeric argument denotes the array size (!)
if (args.size() == 1 && args[0]->isNumber()) {
uint32_t n = args[0]->toUInt32(exec);
- if (n != args[0]->toNumber(exec)) {
- ObjectImp *error = Error::create(exec, RangeError, "Array size is not a small enough positive integer.");
- exec->setException(error);
- return error;
- }
+ if (n != args[0]->toNumber(exec))
+ return throwError(exec, RangeError, "Array size is not a small enough positive integer.");
return new ArrayInstanceImp(exec->lexicalInterpreter()->builtinArrayPrototype(), n);
}
1.13 +2 -5 JavaScriptCore/kjs/bool_object.cpp
Index: bool_object.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/bool_object.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- bool_object.cpp 8 Aug 2005 04:07:27 -0000 1.12
+++ bool_object.cpp 16 Aug 2005 00:47:24 -0000 1.13
@@ -78,11 +78,8 @@
ValueImp *BooleanProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &/*args*/)
{
// no generic function. "this" has to be a Boolean object
- if (!thisObj->inherits(&BooleanInstanceImp::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&BooleanInstanceImp::info))
+ return throwError(exec, TypeError);
// execute "toString()" or "valueOf()", respectively
1.52 +1 -3 JavaScriptCore/kjs/date_object.cpp
Index: date_object.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/date_object.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- date_object.cpp 11 Aug 2005 10:57:19 -0000 1.51
+++ date_object.cpp 16 Aug 2005 00:47:24 -0000 1.52
@@ -526,9 +526,7 @@
// ToString and ValueOf are generic according to the spec, but the mozilla
// tests suggest otherwise...
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
+ return throwError(exec, TypeError);
}
1.53 +4 -11 JavaScriptCore/kjs/function.cpp
Index: function.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/function.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- function.cpp 8 Aug 2005 04:07:28 -0000 1.52
+++ function.cpp 16 Aug 2005 00:47:25 -0000 1.53
@@ -628,11 +628,8 @@
}
}
if (charLen == 0) {
- if (strict) {
- ObjectImp *error = Error::create(exec, URIError);
- exec->setException(error);
- return error;
- }
+ if (strict)
+ return throwError(exec, URIError);
// The only case where we don't use "strict" mode is the "unescape" function.
// For that, it's good to support the wonky "%u" syntax for compatibility with WinIE.
if (k <= len - 6 && p[1] == 'u'
@@ -806,12 +803,8 @@
}
// no program node means a syntax occurred
- if (!progNode) {
- ObjectImp *err = Error::create(exec,SyntaxError,errMsg.ascii(),errLine);
- err->put(exec,"sid",Number(sid));
- exec->setException(err);
- return err;
- }
+ if (!progNode)
+ return throwError(exec, SyntaxError, errMsg, errLine, sid, NULL);
progNode->ref();
1.29 +10 -28 JavaScriptCore/kjs/function_object.cpp
Index: function_object.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/function_object.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- function_object.cpp 14 Aug 2005 16:04:19 -0000 1.28
+++ function_object.cpp 16 Aug 2005 00:47:25 -0000 1.29
@@ -88,9 +88,7 @@
#ifndef NDEBUG
fprintf(stderr,"attempted toString() call on null or non-function object\n");
#endif
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
+ return throwError(exec, TypeError);
}
if (thisObj->inherits(&DeclaredFunctionImp::info)) {
DeclaredFunctionImp *fi = static_cast<DeclaredFunctionImp*>
@@ -111,11 +109,8 @@
ValueImp *argArray = args[1];
ObjectImp *func = thisObj;
- if (!func->implementsCall()) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!func->implementsCall())
+ return throwError(exec, TypeError);
ObjectImp *applyThis;
if (thisArg->isUndefinedOrNull())
@@ -134,11 +129,8 @@
for (unsigned int i = 0; i < length; i++)
applyArgs.append(argArrayObj->get(exec,i));
}
- else {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ else
+ return throwError(exec, TypeError);
}
result = func->call(exec,applyThis,applyArgs);
}
@@ -147,11 +139,8 @@
ValueImp *thisArg = args[0];
ObjectImp *func = thisObj;
- if (!func->implementsCall()) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!func->implementsCall())
+ return throwError(exec, TypeError);
ObjectImp *callThis;
if (thisArg->isUndefinedOrNull())
@@ -222,13 +211,10 @@
}
// no program node == syntax error - throw a syntax error
- if (!progNode) {
- ObjectImp *err = Error::create(exec,SyntaxError,errMsg.ascii(),errLine);
+ if (!progNode)
// we can't return a Completion(Throw) here, so just set the exception
// and return it
- exec->setException(err);
- return err;
- }
+ return throwError(exec, SyntaxError, errMsg, errLine, sid, &sourceURL);
ScopeChain scopeChain;
scopeChain.push(exec->dynamicInterpreter()->globalObject());
@@ -266,11 +252,7 @@
continue;
} // else error
}
- ObjectImp *err = Error::create(exec,SyntaxError,
- I18N_NOOP("Syntax error in parameter list"),
- -1);
- exec->setException(err);
- return err;
+ return throwError(exec, SyntaxError, "Syntax error in parameter list");
}
List consArgs;
1.64 +4 -11 JavaScriptCore/kjs/internal.cpp
Index: internal.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/internal.cpp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- internal.cpp 14 Aug 2005 16:41:47 -0000 1.63
+++ internal.cpp 16 Aug 2005 00:47:25 -0000 1.64
@@ -127,9 +127,7 @@
ObjectImp *UndefinedImp::toObject(ExecState *exec) const
{
- ObjectImp *err = Error::create(exec, TypeError, I18N_NOOP("Undefined value"));
- exec->setException(err);
- return err;
+ return throwError(exec, TypeError, "Undefined value");
}
// ------------------------------ NullImp --------------------------------------
@@ -156,9 +154,7 @@
ObjectImp *NullImp::toObject(ExecState *exec) const
{
- ObjectImp *err = Error::create(exec, TypeError, I18N_NOOP("Null value"));
- exec->setException(err);
- return err;
+ return throwError(exec, TypeError, "Null value");
}
// ------------------------------ BooleanImp -----------------------------------
@@ -664,8 +660,7 @@
// no program node means a syntax error occurred
if (!progNode) {
- ObjectImp *err = Error::create(&globExec, SyntaxError, errMsg.ascii(), errLine, -1, &sourceURL);
- err->put(&globExec, "sid", Number(sid));
+ ObjectImp *err = Error::create(&globExec, SyntaxError, errMsg, errLine, sid, &sourceURL);
#if APPLE_CHANGES
unlockInterpreter();
#endif
@@ -826,9 +821,7 @@
ValueImp *prot = get(exec,prototypePropertyName);
if (!prot->isObject() && !prot->isNull()) {
- ObjectImp *err = Error::create(exec, TypeError, "Invalid prototype encountered "
- "in instanceof operation.");
- exec->setException(err);
+ throwError(exec, TypeError, "Invalid prototype encountered in instanceof operation.");
return false;
}
1.74 +35 -75 JavaScriptCore/kjs/nodes.cpp
Index: nodes.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/nodes.cpp,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- nodes.cpp 12 Aug 2005 23:20:48 -0000 1.73
+++ nodes.cpp 16 Aug 2005 00:47:25 -0000 1.74
@@ -63,7 +63,7 @@
return Completion(Throw, exec->exception()); \
} \
if (Collector::outOfMemory()) \
- return Completion(Throw, Error::create(exec,GeneralError,"Out of memory"));
+ return Completion(Throw, Error::create(exec, GeneralError, "Out of memory"));
#define KJS_CHECKEXCEPTIONVALUE \
if (exec->hadException()) { \
@@ -135,108 +135,71 @@
ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg)
{
- ObjectImp *err = Error::create(exec, e, msg, lineNo(), sourceId(), &sourceURL);
- exec->setException(err);
- return err;
+ return KJS::throwError(exec, e, msg, lineNo(), sourceId(), &sourceURL);
}
-ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *expr)
+static void substitute(UString &string, const UString &substring)
{
- char *vStr = strdup(v->toString(exec).ascii());
- char *exprStr = strdup(expr->toString().ascii());
-
- int length = strlen(msg) - 4 /* two %s */ + strlen(vStr) + strlen(exprStr) + 1 /* null terminator */;
- char *str = new char[length];
- sprintf(str, msg, vStr, exprStr);
- free(vStr);
- free(exprStr);
+ int position = string.find("%s");
+ assert(position != -1);
+ string = string.substr(0, position) + substring + string.substr(position + 2);
+}
- ValueImp *result = throwError(exec, e, str);
- delete [] str;
-
- return result;
+ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *expr)
+{
+ UString message = msg;
+ substitute(message, v->toString(exec));
+ substitute(message, expr->toString());
+ return KJS::throwError(exec, e, message, lineNo(), sourceId(), &sourceURL);
}
ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label)
{
- const char *l = label.ascii();
- int length = strlen(msg) - 2 /* %s */ + strlen(l) + 1 /* null terminator */;
- char *message = new char[length];
- sprintf(message, msg, l);
-
- ValueImp *result = throwError(exec, e, message);
- delete [] message;
-
- return result;
+ UString message = msg;
+ substitute(message, label.ustring());
+ return KJS::throwError(exec, e, message, lineNo(), sourceId(), &sourceURL);
}
ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *e1, Node *e2)
{
- char *vStr = strdup(v->toString(exec).ascii());
- char *e1Str = strdup(e1->toString().ascii());
- char *e2Str = strdup(e2->toString().ascii());
-
- int length = strlen(msg) - 6 /* three %s */ + strlen(vStr) + strlen(e1Str) + strlen(e2Str) + 1 /* null terminator */;
- char *str = new char[length];
- sprintf(str, msg, vStr, e1Str, e2Str);
- free(vStr);
- free(e1Str);
- free(e2Str);
-
- ValueImp *result = throwError(exec, e, str);
- delete [] str;
-
- return result;
+ UString message = msg;
+ substitute(message, v->toString(exec));
+ substitute(message, e1->toString());
+ substitute(message, e2->toString());
+ return KJS::throwError(exec, e, message, lineNo(), sourceId(), &sourceURL);
}
ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *expr, Identifier label)
{
- char *vStr = strdup(v->toString(exec).ascii());
- char *exprStr = strdup(expr->toString().ascii());
- const char *l = label.ascii();
- int length = strlen(msg) - 6 /* three %s */ + strlen(vStr) + strlen(exprStr) + strlen(l) + 1 /* null terminator */;
- char *message = new char[length];
- sprintf(message, msg, vStr, exprStr, l);
- free(vStr);
- free(exprStr);
-
- ValueImp *result = throwError(exec, e, message);
- delete [] message;
-
- return result;
+ UString message = msg;
+ substitute(message, v->toString(exec));
+ substitute(message, expr->toString());
+ return KJS::throwError(exec, e, message, lineNo(), sourceId(), &sourceURL);
}
ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Identifier label)
{
- char *vStr = strdup(v->toString(exec).ascii());
- const char *l = label.ascii();
- int length = strlen(msg) - 4 /* two %s */ + strlen(vStr) + strlen(l) + 1 /* null terminator */;
- char *message = new char[length];
- sprintf(message, msg, vStr, l);
- free(vStr);
-
- ValueImp *result = throwError(exec, e, message);
- delete [] message;
-
- return result;
+ UString message = msg;
+ substitute(message, v->toString(exec));
+ substitute(message, label.ustring());
+ return KJS::throwError(exec, e, message, lineNo(), sourceId(), &sourceURL);
}
void Node::setExceptionDetailsIfNeeded(ExecState *exec)
{
if (exec->hadException()) {
- ObjectImp *exception = exec->exception()->toObject(exec);
- if (!exception->hasProperty(exec, "line") &&
- !exception->hasProperty(exec, "sourceURL")) {
+ ObjectImp *exception = static_cast<ObjectImp *>(exec->exception());
+ if (!exception->hasProperty(exec, "line") && !exception->hasProperty(exec, "sourceURL")) {
exception->put(exec, "line", Number(line));
exception->put(exec, "sourceURL", String(sourceURL));
}
}
}
-
// ------------------------------ StatementNode --------------------------------
+
StatementNode::StatementNode() : l0(-1), l1(-1), sid(-1), breakPoint(false)
{
}
@@ -324,10 +287,7 @@
static ValueImp *undefinedVariableError(ExecState *exec, const Identifier &ident)
{
- UString m = I18N_NOOP("Can't find variable: ") + ident.ustring();
- ObjectImp *err = Error::create(exec, ReferenceError, m.ascii());
- exec->setException(err);
- return err;
+ return throwError(exec, ReferenceError, "Can't find variable: " + ident.ustring());
}
// ECMA 11.1.2 & 10.1.4
@@ -3322,6 +3282,6 @@
n->element->processVarDecls(exec);
}
-ProgramNode::ProgramNode(SourceElementsNode *s): FunctionBodyNode(s) {
- //fprintf(stderr,"ProgramNode::ProgramNode %p\n",this);
+ProgramNode::ProgramNode(SourceElementsNode *s) : FunctionBodyNode(s)
+{
}
1.21 +8 -24 JavaScriptCore/kjs/number_object.cpp
Index: number_object.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/number_object.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- number_object.cpp 8 Aug 2005 04:07:28 -0000 1.20
+++ number_object.cpp 16 Aug 2005 00:47:25 -0000 1.21
@@ -128,11 +128,8 @@
ValueImp *NumberProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
// no generic function. "this" has to be a Number object
- if (!thisObj->inherits(&NumberInstanceImp::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&NumberInstanceImp::info))
+ return throwError(exec, TypeError);
ValueImp *v = thisObj->internalValue();
switch (id) {
@@ -162,13 +159,8 @@
{
ValueImp *fractionDigits = args[0];
double df = fractionDigits->toInteger(exec);
- if (!(df >= 0 && df <= 20)) { // true for NaN
- ObjectImp *err = Error::create(exec, RangeError,
- "toFixed() digits argument must be between 0 and 20");
-
- exec->setException(err);
- return err;
- }
+ if (!(df >= 0 && df <= 20)) // true for NaN
+ return throwError(exec, RangeError, "toFixed() digits argument must be between 0 and 20");
int f = (int)df;
double x = v->toNumber(exec);
@@ -212,12 +204,8 @@
ValueImp *fractionDigits = args[0];
double df = fractionDigits->toInteger(exec);
- if (!(df >= 0 && df <= 20)) { // true for NaN
- ObjectImp *err = Error::create(exec, RangeError,
- "toExponential() argument must between 0 and 20");
- exec->setException(err);
- return err;
- }
+ if (!(df >= 0 && df <= 20)) // true for NaN
+ return throwError(exec, RangeError, "toExponential() argument must between 0 and 20");
int f = (int)df;
int decimalAdjust = 0;
@@ -314,12 +302,8 @@
x = -x;
}
- if (dp < 1 || dp > 21) {
- ObjectImp *err = Error::create(exec, RangeError,
- "toPrecision() argument must be between 1 and 21");
- exec->setException(err);
- return err;
- }
+ if (!(dp >= 1 && dp <= 21)) // true for NaN
+ return throwError(exec, RangeError, "toPrecision() argument must be between 1 and 21");
int p = (int)dp;
if (x != 0) {
1.51 +38 -53 JavaScriptCore/kjs/object.cpp
Index: object.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/object.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- object.cpp 8 Aug 2005 04:07:28 -0000 1.50
+++ object.cpp 16 Aug 2005 00:47:26 -0000 1.51
@@ -88,10 +88,7 @@
if (++depth > KJS_MAX_STACK) {
--depth;
- ObjectImp *err = Error::create(exec, RangeError,
- "Maximum call stack size exceeded.");
- exec->setException(err);
- return err;
+ return throwError(exec, RangeError, "Maximum call stack size exceeded.");
}
#endif
@@ -169,28 +166,6 @@
return Undefined();
}
-bool ObjectImp::getProperty(ExecState *exec, const Identifier& propertyName, ValueImp*& result) const
-{
- PropertySlot slot;
- if (const_cast<ObjectImp *>(this)->getPropertySlot(exec, propertyName, slot)) {
- result = slot.getValue(exec, propertyName);
- return true;
- }
-
- return false;
-}
-
-bool ObjectImp::getProperty(ExecState *exec, unsigned propertyName, ValueImp*& result) const
-{
- PropertySlot slot;
- if (const_cast<ObjectImp *>(this)->getPropertySlot(exec, propertyName, slot)) {
- result = slot.getValue(exec, propertyName);
- return true;
- }
-
- return false;
-}
-
bool ObjectImp::getPropertySlot(ExecState *exec, unsigned propertyName, PropertySlot& slot)
{
ObjectImp *imp = this;
@@ -277,18 +252,6 @@
return const_cast<ObjectImp *>(this)->getPropertySlot(exec, propertyName, slot);
}
-bool ObjectImp::hasOwnProperty(ExecState *exec, const Identifier &propertyName) const
-{
- PropertySlot slot;
- return const_cast<ObjectImp *>(this)->getOwnPropertySlot(exec, propertyName, slot);
-}
-
-bool ObjectImp::hasOwnProperty(ExecState *exec, unsigned propertyName) const
-{
- PropertySlot slot;
- return const_cast<ObjectImp *>(this)->getOwnPropertySlot(exec, propertyName, slot);
-}
-
// ECMA 8.6.2.5
bool ObjectImp::deleteProperty(ExecState */*exec*/, const Identifier &propertyName)
{
@@ -313,11 +276,6 @@
return deleteProperty(exec, Identifier::from(propertyName));
}
-void ObjectImp::deleteAllProperties( ExecState * )
-{
- _prop.clear();
-}
-
// ECMA 8.6.2.6
ValueImp *ObjectImp::defaultValue(ExecState *exec, Type hint) const
{
@@ -371,9 +329,7 @@
if (exec->hadException())
return exec->exception();
- ObjectImp *err = Error::create(exec, TypeError, I18N_NOOP("No default value"));
- exec->setException(err);
- return err;
+ return throwError(exec, TypeError, "No default value");
}
const HashEntry* ObjectImp::findPropertyHashEntry(const Identifier& propertyName) const
@@ -505,8 +461,8 @@
const char * const * const Error::errorNames = errorNamesArr;
-ObjectImp *Error::create(ExecState *exec, ErrorType errtype, const char *message,
- int lineno, int sourceId, const UString *sourceURL)
+ObjectImp *Error::create(ExecState *exec, ErrorType errtype, const UString &message,
+ int lineno, int sourceId, const UString *sourceURL)
{
ObjectImp *cons;
switch (errtype) {
@@ -533,10 +489,11 @@
break;
}
- if (!message)
- message = errorNames[errtype];
List args;
- args.append(String(message));
+ if (message.isEmpty())
+ args.append(jsString(errorNames[errtype]));
+ else
+ args.append(jsString(message));
ObjectImp *err = static_cast<ObjectImp *>(cons->construct(exec,args));
if (lineno != -1)
@@ -562,9 +519,37 @@
*/
}
-ObjectImp *error(ExecState *exec, ErrorType type, const char *message, int line, int sourceId, const UString *sourceURL)
+ObjectImp *Error::create(ExecState *exec, ErrorType type, const char *message)
+{
+ return create(exec, type, message, -1, -1, NULL);
+}
+
+ObjectImp *throwError(ExecState *exec, ErrorType type)
+{
+ ObjectImp *error = Error::create(exec, type, UString(), -1, -1, NULL);
+ exec->setException(error);
+ return error;
+}
+
+ObjectImp *throwError(ExecState *exec, ErrorType type, const UString &message)
+{
+ ObjectImp *error = Error::create(exec, type, message, -1, -1, NULL);
+ exec->setException(error);
+ return error;
+}
+
+ObjectImp *throwError(ExecState *exec, ErrorType type, const char *message)
+{
+ ObjectImp *error = Error::create(exec, type, message, -1, -1, NULL);
+ exec->setException(error);
+ return error;
+}
+
+ObjectImp *throwError(ExecState *exec, ErrorType type, const UString &message, int line, int sourceId, const UString *sourceURL)
{
- return Error::create(exec, type, message, line, sourceId, sourceURL);
+ ObjectImp *error = Error::create(exec, type, message, line, sourceId, sourceURL);
+ exec->setException(error);
+ return error;
}
} // namespace KJS
1.45 +60 -115 JavaScriptCore/kjs/object.h
Index: object.h
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/object.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- object.h 14 Aug 2005 16:27:13 -0000 1.44
+++ object.h 16 Aug 2005 00:47:26 -0000 1.45
@@ -90,15 +90,13 @@
ObjectImp(ObjectImp *proto);
/**
- * Creates a new ObjectImp with a prototype of Null()
+ * Creates a new ObjectImp with a prototype of jsNull()
* (that is, the ECMAScript "null" value, not a null object pointer).
- *
*/
ObjectImp();
virtual void mark();
-
- Type type() const;
+ virtual Type type() const;
/**
* A pointer to a ClassInfo struct for this class. This provides a basic
@@ -177,10 +175,6 @@
*
* @return The object's prototype
*/
- /**
- * Implementation of the [[Prototype]] internal property (implemented by
- * all Objects)
- */
ValueImp *prototype() const;
void setPrototype(ValueImp *proto);
@@ -214,17 +208,9 @@
*
* @return The specified property, or Undefined
*/
- /**
- * Implementation of the [[Get]] internal property (implemented by all
- * Objects)
- */
- // [[Get]] - must be implemented by all Objects
ValueImp *get(ExecState *exec, const Identifier &propertyName) const;
ValueImp *get(ExecState *exec, unsigned propertyName) const;
- bool getProperty(ExecState *exec, const Identifier& propertyName, ValueImp*& result) const;
- bool getProperty(ExecState *exec, unsigned propertyName, ValueImp*& result) const;
-
bool getPropertySlot(ExecState *, const Identifier&, PropertySlot&);
bool getPropertySlot(ExecState *, unsigned, PropertySlot&);
@@ -240,14 +226,8 @@
* @param propertyName The name of the property to set
* @param propertyValue The value to set
*/
- /**
- * Implementation of the [[Put]] internal property (implemented by all
- * Objects)
- */
- virtual void put(ExecState *exec, const Identifier &propertyName,
- ValueImp *value, int attr = None);
- virtual void put(ExecState *exec, unsigned propertyName,
- ValueImp *value, int attr = None);
+ virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
+ virtual void put(ExecState *exec, unsigned propertyName, ValueImp *value, int attr = None);
/**
* Used to check whether or not a particular property is allowed to be set
@@ -275,27 +255,10 @@
* @param propertyName The name of the property to check for
* @return true if the object has the property, otherwise false
*/
- /**
- * Implementation of the [[HasProperty]] internal property (implemented by
- * all Objects)
- */
- bool hasProperty(ExecState *exec,
- const Identifier &propertyName) const;
+ bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
bool hasProperty(ExecState *exec, unsigned propertyName) const;
/**
- * Checks to see whether the object has a property with the specified name.
- *
- * See ECMA 15.2.4.5
- *
- * @param exec The current execution state
- * @param propertyName The name of the property to check for
- * @return true if the object has the property, otherwise false
- */
- virtual bool hasOwnProperty(ExecState *exec, const Identifier &propertyName) const;
- virtual bool hasOwnProperty(ExecState *exec, unsigned propertyName) const;
-
- /**
* Removes the specified property from the object.
*
* See ECMA 8.6.2.5
@@ -306,22 +269,10 @@
* exist on the object. false if deleting the specified property is not
* allowed.
*/
- /**
- * Implementation of the [[Delete]] internal property (implemented by all
- * Objects)
- */
- virtual bool deleteProperty(ExecState *exec,
- const Identifier &propertyName);
+ virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
/**
- * Remove all properties from this object.
- * This doesn't take DontDelete into account, and isn't in the ECMA spec.
- * It's simply a quick way to remove everything before destroying.
- */
- void deleteAllProperties(ExecState *);
-
- /**
* Converts the object into a primitive value. The value return may differ
* depending on the supplied hint
*
@@ -407,9 +358,6 @@
* @param args List of arguments to be passed to the function
* @return The return value from the function
*/
- /**
- * Implementation of the [[Call]] internal property
- */
ValueImp *call(ExecState *exec, ObjectImp *thisObj, const List &args);
virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
@@ -432,9 +380,6 @@
* @return true if value delegates behavior to this object, otherwise
* false
*/
- /**
- * Implementation of the [[HasInstance]] internal property
- */
virtual bool hasInstance(ExecState *exec, ValueImp *value);
/**
@@ -463,9 +408,6 @@
* @param exec The current execution state
* @return The function's scope
*/
- /**
- * Implementation of the [[Scope]] internal property
- */
const ScopeChain &scope() const { return _scope; }
void setScope(const ScopeChain &s) { _scope = s; }
@@ -504,7 +446,6 @@
*
* @param v The new internal value
*/
-
void setInternalValue(ValueImp *v);
ValueImp *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;
@@ -513,8 +454,7 @@
UString toString(ExecState *exec) const;
ObjectImp *toObject(ExecState *exec) const;
- // This get method only looks at the property map.
- // A bit like hasProperty(recursive=false), this doesn't go to the prototype.
+ // This get function only looks at the property map.
// This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want
// to look up in the prototype, it might already exist there)
ValueImp *getDirect(const Identifier& propertyName) const
@@ -524,6 +464,13 @@
void putDirect(const Identifier &propertyName, ValueImp *value, int attr = 0);
void putDirect(const Identifier &propertyName, int value, int attr = 0);
+ /**
+ * Remove all properties from this object.
+ * This doesn't take DontDelete into account, and isn't in the ECMA spec.
+ * It's simply a quick way to remove everything stored in the property map.
+ */
+ void clearProperties() { _prop.clear(); }
+
void saveProperties(SavedProperties &p) const { _prop.save(p); }
void restoreProperties(const SavedProperties &p) { _prop.restore(p); }
@@ -537,46 +484,6 @@
ScopeChain _scope;
};
- // it may seem crazy to inline a function this large but it makes a big difference
- // since this is function very hot in variable lookup
- inline bool ObjectImp::getPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
- {
- ObjectImp *imp = this;
-
- while (true) {
- if (imp->getOwnPropertySlot(exec, propertyName, slot))
- return true;
-
- ValueImp *proto = imp->_proto;
- if (!proto->isObject())
- break;
-
- imp = static_cast<ObjectImp *>(proto);
- }
-
- return false;
- }
-
- // it may seem crazy to inline a function this large, especially a virtual function,
- // but it makes a big difference to property lookup if subclasses can inline their
- // superclass call to this
- inline bool ObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
- {
- ValueImp **impLocation = getDirectLocation(propertyName);
- if (impLocation) {
- slot.setValueSlot(this, impLocation);
- return true;
- }
-
- // non-standard netscape extension
- if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
- slot.setValueSlot(this, &_proto);
- return true;
- }
-
- return false;
- }
-
/**
* Types of Native Errors available. For custom errors, GeneralError
* should be used.
@@ -589,9 +496,6 @@
TypeError = 5,
URIError = 6};
- ObjectImp *error(ExecState *exec, ErrorType type = GeneralError,
- const char *message = 0, int lineno = -1, int sourceId = -1, const UString *sourceURL = 0);
-
/**
* @short Factory methods for error objects.
*/
@@ -603,12 +507,12 @@
* @param exec The current execution state
* @param errtype Type of error.
* @param message Optional error message.
- * @param lineno Optional line number.
- * @param lineno Optional source id.
+ * @param lineNumber Optional line number.
+ * @param sourceId Optional source id.
+ * @param sourceURL Optional source URL.
*/
- static ObjectImp *create(ExecState *exec, ErrorType errtype = GeneralError,
- const char *message = 0, int lineno = -1,
- int sourceId = -1, const UString *sourceURL = 0);
+ static ObjectImp *create(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL);
+ static ObjectImp *create(ExecState *, ErrorType, const char *message);
/**
* Array of error names corresponding to ErrorType
@@ -616,6 +520,11 @@
static const char * const * const errorNames;
};
+ObjectImp *throwError(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL);
+ObjectImp *throwError(ExecState *, ErrorType, const UString &message);
+ObjectImp *throwError(ExecState *, ErrorType, const char *message);
+ObjectImp *throwError(ExecState *, ErrorType);
+
inline bool AllocatedValueImp::isObject(const ClassInfo *info) const
{
return isObject() && static_cast<const ObjectImp *>(this)->inherits(info);
@@ -661,6 +570,42 @@
return false;
}
+// It may seem crazy to inline a function this large but it makes a big difference
+// since this is function very hot in variable lookup
+inline bool ObjectImp::getPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+{
+ ObjectImp *object = this;
+ while (true) {
+ if (object->getOwnPropertySlot(exec, propertyName, slot))
+ return true;
+
+ ValueImp *proto = object->_proto;
+ if (!proto->isObject())
+ return false;
+
+ object = static_cast<ObjectImp *>(proto);
+ }
+}
+
+// It may seem crazy to inline a function this large, especially a virtual function,
+// but it makes a big difference to property lookup that derived classes can inline their
+// base class call to this.
+inline bool ObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+{
+ if (ValueImp **location = getDirectLocation(propertyName)) {
+ slot.setValueSlot(this, location);
+ return true;
+ }
+
+ // non-standard Netscape extension
+ if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
+ slot.setValueSlot(this, &_proto);
+ return true;
+ }
+
+ return false;
+}
+
} // namespace
#endif // KJS_OBJECT_H
1.14 +4 -3 JavaScriptCore/kjs/object_object.cpp
Index: object_object.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/object_object.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- object_object.cpp 8 Aug 2005 04:07:29 -0000 1.13
+++ object_object.cpp 16 Aug 2005 00:47:26 -0000 1.14
@@ -67,9 +67,10 @@
switch (id) {
case ValueOf:
return thisObj;
- case HasOwnProperty:
- // Same as the in operator but without checking the prototype
- return jsBoolean(thisObj->hasOwnProperty(exec, Identifier(args[0]->toString(exec))));
+ case HasOwnProperty: {
+ PropertySlot slot;
+ return jsBoolean(thisObj->getOwnPropertySlot(exec, Identifier(args[0]->toString(exec)), slot));
+ }
case ToLocaleString:
return jsString(thisObj->toString(exec));
case ToString:
1.14 +9 -26 JavaScriptCore/kjs/reference.cpp
Index: reference.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/reference.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- reference.cpp 8 Aug 2005 04:07:29 -0000 1.13
+++ reference.cpp 16 Aug 2005 00:47:26 -0000 1.14
@@ -69,12 +69,8 @@
ValueImp *Reference::getBase(ExecState *exec) const
{
- if (baseIsValue) {
- ObjectImp *err = Error::create(exec, ReferenceError, I18N_NOOP("Invalid reference base"));
- exec->setException(err);
- return err;
- }
-
+ if (baseIsValue)
+ return throwError(exec, ReferenceError, "Invalid reference base");
return base;
}
@@ -94,25 +90,14 @@
ValueImp *Reference::getValue(ExecState *exec) const
{
- if (baseIsValue) {
+ if (baseIsValue)
return base;
- }
ValueImp *o = base;
- Type t = o ? o->type() : NullType;
-
- if (t == NullType) {
- UString m = I18N_NOOP("Can't find variable: ") + getPropertyName(exec).ustring();
- ObjectImp *err = Error::create(exec, ReferenceError, m.ascii());
- exec->setException(err);
- return err;
- }
-
- if (t != ObjectType) {
- UString m = I18N_NOOP("Base is not an object");
- ObjectImp *err = Error::create(exec, ReferenceError, m.ascii());
- exec->setException(err);
- return err;
+ if (!o || !o->isObject()) {
+ if (!o || o->isNull())
+ return throwError(exec, ReferenceError, "Can't find variable: " + getPropertyName(exec).ustring());
+ return throwError(exec, ReferenceError, "Base is not an object");
}
if (propertyNameIsNumber)
@@ -123,8 +108,7 @@
void Reference::putValue(ExecState *exec, ValueImp *w)
{
if (baseIsValue) {
- ObjectImp *err = Error::create(exec, ReferenceError);
- exec->setException(err);
+ throwError(exec, ReferenceError);
return;
}
@@ -146,8 +130,7 @@
bool Reference::deleteValue(ExecState *exec)
{
if (baseIsValue) {
- ObjectImp *err = Error::create(exec,ReferenceError);
- exec->setException(err);
+ throwError(exec, ReferenceError);
return false;
}
1.22 +3 -8 JavaScriptCore/kjs/regexp_object.cpp
Index: regexp_object.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/regexp_object.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- regexp_object.cpp 8 Aug 2005 04:07:29 -0000 1.21
+++ regexp_object.cpp 16 Aug 2005 00:47:26 -0000 1.22
@@ -78,9 +78,7 @@
case ToString: return String("//");
}
}
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
+ return throwError(exec, TypeError);
}
RegExpImp *reimp = static_cast<RegExpImp*>(thisObj);
@@ -254,11 +252,8 @@
{
ObjectImp *o = args[0]->getObject();
if (o && o->inherits(&RegExpImp::info)) {
- if (!args[1]->isUndefined()) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!args[1]->isUndefined())
+ return throwError(exec, TypeError);
return o;
}
1.43 +2 -5 JavaScriptCore/kjs/string_object.cpp
Index: string_object.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/string_object.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- string_object.cpp 8 Aug 2005 04:07:29 -0000 1.42
+++ string_object.cpp 16 Aug 2005 00:47:26 -0000 1.43
@@ -369,11 +369,8 @@
// toString and valueOf are no generic function.
if (id == ToString || id == ValueOf) {
- if (!thisObj || !thisObj->inherits(&StringInstanceImp::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj || !thisObj->inherits(&StringInstanceImp::info))
+ return throwError(exec, TypeError);
return String(thisObj->internalValue()->toString(exec));
}
1.4580 +92 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.4579
retrieving revision 1.4580
diff -u -r1.4579 -r1.4580
--- ChangeLog 15 Aug 2005 23:31:04 -0000 1.4579
+++ ChangeLog 16 Aug 2005 00:47:29 -0000 1.4580
@@ -1,3 +1,95 @@
+2005-08-15 Darin Adler <darin at apple.com>
+
+ Reviewed by Geoff.
+
+ - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4437
+ clean up error creation with new throwError function
+
+ * khtml/css/cssstyleselector.cpp:
+ (khtml::CSSStyleSelector::CSSStyleSelector):
+ (khtml::parseUASheet):
+ (khtml::CSSStyleSelector::initElementAndPseudoState):
+ (khtml::checkPseudoState):
+ (khtml::CSSStyleSelector::locateCousinList):
+ (khtml::CSSStyleSelector::locateSharedStyle):
+ (khtml::CSSStyleSelector::adjustRenderStyle):
+ (khtml::CSSStyleSelector::checkOneSelector):
+ (khtml::CSSRuleSet::addToRuleSet):
+ (khtml::colorForCSSValue):
+ (khtml::CSSStyleSelector::applyProperty):
+ (khtml::CSSStyleSelector::mapBackgroundAttachment):
+ (khtml::CSSStyleSelector::mapBackgroundImage):
+ (khtml::CSSStyleSelector::mapBackgroundRepeat):
+ (khtml::CSSStyleSelector::mapBackgroundXPosition):
+ (khtml::CSSStyleSelector::mapBackgroundYPosition):
+ (khtml::CSSStyleSelector::getComputedSizeFromSpecifiedSize):
+ * khtml/ecma/domparser.cpp:
+ (KJS::DOMParserProtoFunc::callAsFunction):
+ * khtml/ecma/kjs_binding.cpp:
+ (KJS::ScriptInterpreter::putDOMObject):
+ (KJS::ScriptInterpreter::putDOMNodeForDocument):
+ (KJS::setDOMException):
+ * khtml/ecma/kjs_css.cpp:
+ (KJS::DOMCSSStyleDeclarationProtoFunc::callAsFunction):
+ (KJS::DOMStyleSheetListFunc::callAsFunction):
+ (KJS::KJS::DOMMediaListProtoFunc::callAsFunction):
+ (KJS::DOMCSSStyleSheetProtoFunc::callAsFunction):
+ (KJS::DOMCSSRuleListFunc::callAsFunction):
+ (KJS::DOMCSSRuleFunc::callAsFunction):
+ (KJS::DOMCSSPrimitiveValueProtoFunc::callAsFunction):
+ (KJS::DOMCSSValueListFunc::callAsFunction):
+ * khtml/ecma/kjs_dom.cpp:
+ (KJS::DOMNodeProtoFunc::callAsFunction):
+ (KJS::DOMNodeListFunc::callAsFunction):
+ (KJS::DOMDocumentProtoFunc::callAsFunction):
+ (KJS::DOMElementProtoFunc::callAsFunction):
+ (KJS::DOMDOMImplementationProtoFunc::callAsFunction):
+ (KJS::DOMNamedNodeMapProtoFunc::callAsFunction):
+ (KJS::DOMCharacterDataProtoFunc::callAsFunction):
+ (KJS::DOMTextProtoFunc::callAsFunction):
+ * khtml/ecma/kjs_events.cpp:
+ (KJS::DOMEventProtoFunc::callAsFunction):
+ (KJS::DOMUIEventProtoFunc::callAsFunction):
+ (KJS::DOMMouseEventProtoFunc::callAsFunction):
+ (KJS::DOMKeyboardEventProtoFunc::callAsFunction):
+ (KJS::DOMMutationEventProtoFunc::callAsFunction):
+ (KJS::DOMWheelEventProtoFunc::callAsFunction):
+ (KJS::ClipboardProtoFunc::callAsFunction):
+ * khtml/ecma/kjs_html.cpp:
+ (KJS::KJS::HTMLDocFunction::callAsFunction):
+ (KJS::KJS::HTMLElementFunction::callAsFunction):
+ (KJS::KJS::HTMLCollectionProtoFunc::callAsFunction):
+ (KJS::KJS::Context2DFunction::callAsFunction):
+ (KJS::Context2D::putValueProperty):
+ (KJS::GradientFunction::callAsFunction):
+ * khtml/ecma/kjs_navigator.cpp:
+ (KJS::NavigatorFunc::callAsFunction):
+ * khtml/ecma/kjs_range.cpp:
+ (KJS::DOMRangeProtoFunc::callAsFunction):
+ * khtml/ecma/kjs_traversal.cpp:
+ (KJS::DOMNodeIteratorProtoFunc::callAsFunction):
+ (KJS::DOMNodeFilterProtoFunc::callAsFunction):
+ (KJS::DOMTreeWalkerProtoFunc::callAsFunction):
+ * khtml/ecma/kjs_views.cpp:
+ (KJS::DOMAbstractViewFunc::callAsFunction):
+ * khtml/ecma/kjs_window.cpp:
+ (KJS::Window::interpreter):
+ (KJS::Window::retrieveWindow):
+ (KJS::Window::retrieveActive):
+ (KJS::Window::isSafeScript):
+ (KJS::Window::clear):
+ (KJS::WindowFunc::callAsFunction):
+ (KJS::ScheduledAction::execute):
+ (KJS::WindowQObject::pauseTimeouts):
+ (KJS::LocationFunc::callAsFunction):
+ (KJS::Selection::toString):
+ (KJS::SelectionFunc::callAsFunction):
+ (KJS::HistoryFunc::callAsFunction):
+ * khtml/ecma/xmlhttprequest.cpp:
+ (KJS::XMLHttpRequestProtoFunc::callAsFunction):
+ * khtml/ecma/xmlserializer.cpp:
+ (KJS::XMLSerializerProtoFunc::callAsFunction):
+
2005-08-15 David Harrison <harrison at apple.com>
Reviewed by Darin.
1.199 +29 -30 WebCore/khtml/css/cssstyleselector.cpp
Index: cssstyleselector.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/cssstyleselector.cpp,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -r1.198 -r1.199
--- cssstyleselector.cpp 30 Jul 2005 02:33:12 -0000 1.198
+++ cssstyleselector.cpp 16 Aug 2005 00:47:42 -0000 1.199
@@ -34,10 +34,6 @@
#include "dom/css_value.h"
#include "khtml_factory.h"
#include "khtmlpart_p.h"
-using namespace khtml;
-using namespace DOM;
-using namespace HTMLNames;
-
#include "css/cssproperties.h"
#include "css/cssvalues.h"
@@ -69,6 +65,9 @@
#include <qintcache.h>
#include <stdlib.h>
+using namespace DOM;
+using namespace HTMLNames;
+
// #define STYLE_SHARING_STATS 1
#define HANDLE_INHERIT(prop, Prop) \
@@ -186,7 +185,7 @@
RenderStyle* CSSStyleSelector::styleNotYetAvailable = 0;
CSSStyleSheetImpl *CSSStyleSelector::quirksSheet = 0;
-static CSSStyleSelector::Encodedurl *encodedurl = 0;
+static CSSStyleSelector::Encodedurl *currentEncodedURL = 0;
static PseudoState pseudoState;
CSSStyleSelector::CSSStyleSelector( DocumentImpl* doc, QString userStyleSheet, StyleSheetListImpl *styleSheets,
@@ -206,7 +205,7 @@
// FIXME: This sucks! The user sheet is reparsed every time!
if (!userStyleSheet.isEmpty()) {
- m_userSheet = new DOM::CSSStyleSheetImpl(doc);
+ m_userSheet = new CSSStyleSheetImpl(doc);
m_userSheet->parseString(DOMString(userStyleSheet), strictParsing);
m_userStyle = new CSSRuleSet();
@@ -287,7 +286,7 @@
style += s->settingsToCSS();
DOMString str(style);
- CSSStyleSheetImpl* sheet = new DOM::CSSStyleSheetImpl((DOM::CSSStyleSheetImpl*)0);
+ CSSStyleSheetImpl* sheet = new CSSStyleSheetImpl((CSSStyleSheetImpl*)0);
sheet->parseString(str);
return sheet;
}
@@ -470,7 +469,7 @@
styledElement = static_cast<StyledElementImpl*>(element);
else
styledElement = 0;
- ::encodedurl = &encodedurl;
+ currentEncodedURL = &encodedurl;
pseudoState = PseudoUnknown;
}
@@ -537,7 +536,7 @@
//kdDebug() << "checkPseudoState " << path << endl;
}
-static void checkPseudoState( DOM::ElementImpl *e, bool checkVisited = true )
+static void checkPseudoState( ElementImpl *e, bool checkVisited = true )
{
if (!e->isLink()) {
pseudoState = PseudoNone;
@@ -559,11 +558,11 @@
QString u = cu.string();
if ( !u.contains("://") ) {
if ( u[0] == '/' )
- u.prepend(encodedurl->host);
+ u.prepend(currentEncodedURL->host);
else if ( u[0] == '#' )
- u.prepend(encodedurl->file);
+ u.prepend(currentEncodedURL->file);
else
- u.prepend(encodedurl->path);
+ u.prepend(currentEncodedURL->path);
cleanpath( u );
}
//completeURL( attr.string() );
@@ -582,7 +581,7 @@
if (parent && parent->isHTMLElement()) {
HTMLElementImpl* p = static_cast<HTMLElementImpl*>(parent);
if (p->renderer() && !p->inlineStyleDecl() && !p->hasID()) {
- DOM::NodeImpl* r = p->previousSibling();
+ NodeImpl* r = p->previousSibling();
int subcount = 0;
RenderStyle* st = p->renderer()->style();
while (r) {
@@ -656,7 +655,7 @@
!styledElement->getDocument()->usesSiblingRules()) {
// Check previous siblings.
int count = 0;
- DOM::NodeImpl* n;
+ NodeImpl* n;
for (n = element->previousSibling(); n && !n->isElementNode(); n = n->previousSibling());
while (n) {
if (canShareStyleWithElement(n))
@@ -875,7 +874,7 @@
return style;
}
-void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, DOM::ElementImpl *e)
+void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, ElementImpl *e)
{
// Cache our original display.
style->setOriginalDisplay(style->display());
@@ -1096,7 +1095,7 @@
return true;
}
-bool CSSStyleSelector::checkOneSelector(DOM::CSSSelector *sel, DOM::ElementImpl *e)
+bool CSSStyleSelector::checkOneSelector(CSSSelector *sel, ElementImpl *e)
{
if(!e)
return false;
@@ -1235,7 +1234,7 @@
case CSSSelector::PseudoFirstChild: {
// first-child matches the first child that is an element!
if (e->parentNode()) {
- DOM::NodeImpl* n = e->previousSibling();
+ NodeImpl* n = e->previousSibling();
while ( n && !n->isElementNode() )
n = n->previousSibling();
if ( !n )
@@ -1246,7 +1245,7 @@
case CSSSelector::PseudoLastChild: {
// last-child matches the last child that is an element!
if (e->parentNode()) {
- DOM::NodeImpl* n = e->nextSibling();
+ NodeImpl* n = e->nextSibling();
while ( n && !n->isElementNode() )
n = n->nextSibling();
if ( !n )
@@ -1257,7 +1256,7 @@
case CSSSelector::PseudoOnlyChild: {
// If both first-child and last-child apply, then only-child applies.
if (e->parentNode()) {
- DOM::NodeImpl* n = e->previousSibling();
+ NodeImpl* n = e->previousSibling();
while ( n && !n->isElementNode() )
n = n->previousSibling();
if ( !n ) {
@@ -1426,7 +1425,7 @@
}
-void CSSRuleSet::addToRuleSet(DOM::DOMStringImpl* key, AtomRuleMap& map,
+void CSSRuleSet::addToRuleSet(DOMStringImpl* key, AtomRuleMap& map,
CSSStyleRuleImpl* rule, CSSSelector* sel)
{
if (!key) return;
@@ -1720,7 +1719,7 @@
// Desktop background.
return bckgrConfig.readColorEntry("Color1", &qApp->palette().disabled().background());
}
- return khtml::invalidColor;
+ return invalidColor;
}
const QPalette &pal = qApp->palette();
@@ -1778,7 +1777,7 @@
}
}
-void CSSStyleSelector::applyProperty( int id, DOM::CSSValueImpl *value )
+void CSSStyleSelector::applyProperty( int id, CSSValueImpl *value )
{
//kdDebug( 6080 ) << "applying property " << prop->m_id << endl;
@@ -2819,7 +2818,7 @@
HANDLE_INHERIT_AND_INITIAL(verticalAlign, VerticalAlign)
if (!primitiveValue) return;
if (primitiveValue->getIdent()) {
- khtml::EVerticalAlign align;
+ EVerticalAlign align;
switch(primitiveValue->getIdent())
{
@@ -3474,7 +3473,7 @@
int x = item->x->computeLength(style, paintDeviceMetrics);
int y = item->y->computeLength(style, paintDeviceMetrics);
int blur = item->blur ? item->blur->computeLength(style, paintDeviceMetrics) : 0;
- QColor col = khtml::transparentColor;
+ QColor col = transparentColor;
if (item->color) {
int ident = item->color->getIdent();
if (ident)
@@ -3860,7 +3859,7 @@
}
}
-void CSSStyleSelector::mapBackgroundAttachment(BackgroundLayer* layer, DOM::CSSValueImpl* value)
+void CSSStyleSelector::mapBackgroundAttachment(BackgroundLayer* layer, CSSValueImpl* value)
{
if (value->cssValueType() == CSSValue::CSS_INITIAL) {
layer->setBackgroundAttachment(RenderStyle::initialBackgroundAttachment());
@@ -3881,7 +3880,7 @@
}
}
-void CSSStyleSelector::mapBackgroundImage(BackgroundLayer* layer, DOM::CSSValueImpl* value)
+void CSSStyleSelector::mapBackgroundImage(BackgroundLayer* layer, CSSValueImpl* value)
{
if (value->cssValueType() == CSSValue::CSS_INITIAL) {
layer->setBackgroundImage(RenderStyle::initialBackgroundImage());
@@ -3893,7 +3892,7 @@
layer->setBackgroundImage(static_cast<CSSImageValueImpl *>(primitiveValue)->image(element->getDocument()->docLoader()));
}
-void CSSStyleSelector::mapBackgroundRepeat(BackgroundLayer* layer, DOM::CSSValueImpl* value)
+void CSSStyleSelector::mapBackgroundRepeat(BackgroundLayer* layer, CSSValueImpl* value)
{
if (value->cssValueType() == CSSValue::CSS_INITIAL) {
layer->setBackgroundRepeat(RenderStyle::initialBackgroundRepeat());
@@ -3920,7 +3919,7 @@
}
}
-void CSSStyleSelector::mapBackgroundXPosition(BackgroundLayer* layer, DOM::CSSValueImpl* value)
+void CSSStyleSelector::mapBackgroundXPosition(BackgroundLayer* layer, CSSValueImpl* value)
{
if (value->cssValueType() == CSSValue::CSS_INITIAL) {
layer->setBackgroundXPosition(RenderStyle::initialBackgroundXPosition());
@@ -3940,7 +3939,7 @@
layer->setBackgroundXPosition(l);
}
-void CSSStyleSelector::mapBackgroundYPosition(BackgroundLayer* layer, DOM::CSSValueImpl* value)
+void CSSStyleSelector::mapBackgroundYPosition(BackgroundLayer* layer, CSSValueImpl* value)
{
if (value->cssValueType() == CSSValue::CSS_INITIAL) {
layer->setBackgroundYPosition(RenderStyle::initialBackgroundYPosition());
@@ -4021,7 +4020,7 @@
int minSize = settings->minFontSize();
int minLogicalSize = settings->minLogicalFontSize();
- float zoomPercent = (!khtml::printpainter && view) ? view->part()->zoomFactor()/100.0f : 1.0f;
+ float zoomPercent = (!printpainter && view) ? view->part()->zoomFactor()/100.0f : 1.0f;
float zoomedSize = specifiedSize * zoomPercent;
// Apply the hard minimum first. We only apply the hard minimum if after zooming we're still too small.
1.4 +2 -5 WebCore/khtml/ecma/domparser.cpp
Index: domparser.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/domparser.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- domparser.cpp 8 Aug 2005 04:07:40 -0000 1.3
+++ domparser.cpp 16 Aug 2005 00:47:43 -0000 1.4
@@ -69,11 +69,8 @@
ValueImp *DOMParserProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&DOMParser::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&DOMParser::info))
+ return throwError(exec, TypeError);
DOMParser *parser = static_cast<DOMParser *>(thisObj);
1.39 +4 -5 WebCore/khtml/ecma/kjs_binding.cpp
Index: kjs_binding.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_binding.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- kjs_binding.cpp 9 Aug 2005 21:29:41 -0000 1.38
+++ kjs_binding.cpp 16 Aug 2005 00:47:43 -0000 1.39
@@ -92,7 +92,7 @@
void ScriptInterpreter::putDOMObject(void* objectHandle, DOMObject* obj)
{
- domObjects()->insert(objectHandle, obj);
+ domObjects()->set(objectHandle, obj);
}
void ScriptInterpreter::deleteDOMObject(void* objectHandle)
@@ -126,9 +126,9 @@
NodeMap *documentDict = domNodesPerDocument()->get(document);
if (!documentDict) {
documentDict = new NodeMap();
- domNodesPerDocument()->insert(document, documentDict);
+ domNodesPerDocument()->set(document, documentDict);
}
- documentDict->insert(nodeHandle, nodeWrapper);
+ documentDict->set(nodeHandle, nodeWrapper);
}
void ScriptInterpreter::forgetAllDOMNodesForDocument(DOM::DocumentImpl *document)
@@ -349,9 +349,8 @@
char buffer[100]; // needs to fit 20 characters, plus an integer in ASCII, plus a null character
sprintf(buffer, "%s exception %d", type, code);
- ObjectImp *errorObject = Error::create(exec, GeneralError, buffer);
+ ObjectImp *errorObject = throwError(exec, GeneralError, buffer);
errorObject->put(exec, "code", Number(code));
- exec->setException(errorObject);
}
}
1.35 +16 -40 WebCore/khtml/ecma/kjs_css.cpp
Index: kjs_css.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_css.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- kjs_css.cpp 8 Aug 2005 04:07:40 -0000 1.34
+++ kjs_css.cpp 16 Aug 2005 00:47:43 -0000 1.35
@@ -239,11 +239,8 @@
ValueImp *DOMCSSStyleDeclarationProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMCSSStyleDeclaration::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMCSSStyleDeclaration::info))
+ return throwError(exec, TypeError);
DOMExceptionTranslator exception(exec);
CSSStyleDeclarationImpl &styleDecl = *static_cast<DOMCSSStyleDeclaration *>(thisObj)->impl();
UString str = args[0]->toString(exec);
@@ -466,11 +463,8 @@
ValueImp *DOMStyleSheetListFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMStyleSheetList::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMStyleSheetList::info))
+ return throwError(exec, TypeError);
StyleSheetListImpl &styleSheetList = *static_cast<DOMStyleSheetList *>(thisObj)->impl();
if (id == DOMStyleSheetList::Item)
return getDOMStyleSheet(exec, styleSheetList.item(args[0]->toInt32(exec)));
@@ -560,11 +554,8 @@
ValueImp *KJS::DOMMediaListProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMMediaList::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMMediaList::info))
+ return throwError(exec, TypeError);
MediaListImpl &mediaList = *static_cast<DOMMediaList *>(thisObj)->impl();
switch (id) {
case DOMMediaList::Item:
@@ -633,11 +624,8 @@
ValueImp *DOMCSSStyleSheetProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMCSSStyleSheet::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMCSSStyleSheet::info))
+ return throwError(exec, TypeError);
DOMExceptionTranslator exception(exec);
CSSStyleSheetImpl &styleSheet = *static_cast<CSSStyleSheetImpl *>(static_cast<DOMCSSStyleSheet *>(thisObj)->impl());
switch (id) {
@@ -715,11 +703,8 @@
ValueImp *DOMCSSRuleListFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMCSSRuleList::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMCSSRuleList::info))
+ return throwError(exec, TypeError);
CSSRuleListImpl &cssRuleList = *static_cast<DOMCSSRuleList *>(thisObj)->impl();
switch (id) {
case DOMCSSRuleList::Item:
@@ -915,11 +900,8 @@
ValueImp *DOMCSSRuleFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMCSSRule::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMCSSRule::info))
+ return throwError(exec, TypeError);
CSSRuleImpl &cssRule = *static_cast<DOMCSSRule *>(thisObj)->impl();
if (cssRule.type() == DOM::CSSRule::MEDIA_RULE) {
@@ -1123,11 +1105,8 @@
ValueImp *DOMCSSPrimitiveValueProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMCSSPrimitiveValue::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMCSSPrimitiveValue::info))
+ return throwError(exec, TypeError);
DOMExceptionTranslator exception(exec);
CSSPrimitiveValueImpl &val = *static_cast<CSSPrimitiveValueImpl *>(static_cast<DOMCSSPrimitiveValue *>(thisObj)->impl());
switch (id) {
@@ -1255,11 +1234,8 @@
ValueImp *DOMCSSValueListFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMCSSValue::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMCSSValue::info))
+ return throwError(exec, TypeError);
CSSValueListImpl &valueList = *static_cast<CSSValueListImpl *>(static_cast<DOMCSSValueList *>(thisObj)->impl());
switch (id) {
case DOMCSSValueList::Item:
1.87 +16 -40 WebCore/khtml/ecma/kjs_dom.cpp
Index: kjs_dom.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_dom.cpp,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- kjs_dom.cpp 8 Aug 2005 04:07:40 -0000 1.86
+++ kjs_dom.cpp 16 Aug 2005 00:47:43 -0000 1.87
@@ -638,11 +638,8 @@
ValueImp *DOMNodeProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&DOMNode::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&DOMNode::info))
+ return throwError(exec, TypeError);
DOMExceptionTranslator exception(exec);
NodeImpl &node = *static_cast<DOMNode *>(thisObj)->impl();
switch (id) {
@@ -795,11 +792,8 @@
// Not a prototype class currently, but should probably be converted to one
ValueImp *DOMNodeListFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMNodeList::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMNodeList::info))
+ return throwError(exec, TypeError);
DOM::NodeListImpl &list = *static_cast<DOMNodeList *>(thisObj)->impl();
if (id == DOMNodeList::Item)
@@ -1003,11 +997,8 @@
ValueImp *DOMDocumentProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMNode::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMNode::info))
+ return throwError(exec, TypeError);
DOMExceptionTranslator exception(exec);
NodeImpl &node = *static_cast<DOMNode *>(thisObj)->impl();
DocumentImpl &doc = static_cast<DocumentImpl &>(node);
@@ -1212,11 +1203,8 @@
ValueImp *DOMElementProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMNode::info)) { // node should be enough here, given the cast
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMNode::info))
+ return throwError(exec, TypeError);
DOMExceptionTranslator exception(exec);
NodeImpl &node = *static_cast<DOMNode *>(thisObj)->impl();
ElementImpl &element = static_cast<ElementImpl &>(node);
@@ -1321,11 +1309,8 @@
ValueImp *DOMDOMImplementationProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMDOMImplementation::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMDOMImplementation::info))
+ return throwError(exec, TypeError);
DOMExceptionTranslator exception(exec);
DOMImplementationImpl &implementation = *static_cast<DOMDOMImplementation *>(thisObj)->impl();
@@ -1465,11 +1450,8 @@
ValueImp *DOMNamedNodeMapProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMNamedNodeMap::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMNamedNodeMap::info))
+ return throwError(exec, TypeError);
DOMExceptionTranslator exception(exec);
NamedNodeMapImpl &map = *static_cast<DOMNamedNodeMap *>(thisObj)->impl();
@@ -2009,11 +1991,8 @@
ValueImp *DOMCharacterDataProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMCharacterData::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMCharacterData::info))
+ return throwError(exec, TypeError);
DOMExceptionTranslator exception(exec);
CharacterDataImpl &data = *static_cast<CharacterDataImpl *>(static_cast<DOMCharacterData *>(thisObj)->impl());
switch(id) {
@@ -2072,11 +2051,8 @@
ValueImp *DOMTextProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMText::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMText::info))
+ return throwError(exec, TypeError);
DOMExceptionTranslator exception(exec);
TextImpl &text = *static_cast<TextImpl *>(static_cast<DOMText *>(thisObj)->impl());
switch(id) {
1.56 +21 -55 WebCore/khtml/ecma/kjs_events.cpp
Index: kjs_events.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_events.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- kjs_events.cpp 14 Aug 2005 08:28:01 -0000 1.55
+++ kjs_events.cpp 16 Aug 2005 00:47:44 -0000 1.56
@@ -511,11 +511,8 @@
ValueImp *DOMEventProtoFunc::callAsFunction(ExecState *exec, ObjectImp * thisObj, const List &args)
{
- if (!thisObj->inherits(&DOMEvent::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&DOMEvent::info))
+ return throwError(exec, TypeError);
EventImpl &event = *static_cast<DOMEvent *>( thisObj )->impl();
switch (id) {
case DOMEvent::StopPropagation:
@@ -661,11 +658,8 @@
ValueImp *DOMUIEventProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&DOMUIEvent::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&DOMUIEvent::info))
+ return throwError(exec, TypeError);
UIEventImpl &uiEvent = *static_cast<UIEventImpl *>(static_cast<DOMUIEvent *>(thisObj)->impl());
switch (id) {
case DOMUIEvent::InitUIEvent:
@@ -803,11 +797,8 @@
ValueImp *DOMMouseEventProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&DOMMouseEvent::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&DOMMouseEvent::info))
+ return throwError(exec, TypeError);
MouseEventImpl &mouseEvent = *static_cast<MouseEventImpl *>(static_cast<DOMMouseEvent *>(thisObj)->impl());
switch (id) {
case DOMMouseEvent::InitMouseEvent:
@@ -899,11 +890,8 @@
ValueImp *DOMKeyboardEventProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&DOMKeyboardEvent::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&DOMKeyboardEvent::info))
+ return throwError(exec, TypeError);
KeyboardEventImpl &event = *static_cast<KeyboardEventImpl *>(static_cast<DOMUIEvent *>(thisObj)->impl());
switch (id) {
case DOMKeyboardEvent::InitKeyboardEvent:
@@ -1005,11 +993,8 @@
ValueImp *DOMMutationEventProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&DOMMutationEvent::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&DOMMutationEvent::info))
+ return throwError(exec, TypeError);
MutationEventImpl &mutationEvent = *static_cast<MutationEventImpl *>(static_cast<DOMEvent *>(thisObj)->impl());
switch (id) {
case DOMMutationEvent::InitMutationEvent:
@@ -1096,11 +1081,8 @@
ValueImp *DOMWheelEventProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&DOMWheelEvent::info)) {
- ObjectImp *error = Error::create(exec,TypeError);
- exec->setException(error);
- return error;
- }
+ if (!thisObj->inherits(&DOMWheelEvent::info))
+ return throwError(exec, TypeError);
return Undefined();
}
@@ -1208,11 +1190,8 @@
ValueImp *ClipboardProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&Clipboard::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&Clipboard::info))
+ return throwError(exec, TypeError);
Clipboard *cb = static_cast<Clipboard *>(thisObj);
switch (id) {
@@ -1224,9 +1203,7 @@
cb->clipboard->clearData(args[0]->toString(exec).string());
return Undefined();
} else {
- ObjectImp *err = Error::create(exec,SyntaxError,"clearData: Invalid number of arguments");
- exec->setException(err);
- return err;
+ return throwError(exec, SyntaxError, "clearData: Invalid number of arguments");
}
case Clipboard::GetData:
{
@@ -1239,18 +1216,14 @@
return Undefined();
}
} else {
- ObjectImp *err = Error::create(exec,SyntaxError,"getData: Invalid number of arguments");
- exec->setException(err);
- return err;
+ return throwError(exec, SyntaxError, "getData: Invalid number of arguments");
}
}
case Clipboard::SetData:
if (args.size() == 2) {
return Boolean(cb->clipboard->setData(args[0]->toString(exec).string(), args[1]->toString(exec).string()));
} else {
- ObjectImp *err = Error::create(exec,SyntaxError,"setData: Invalid number of arguments");
- exec->setException(err);
- return err;
+ return throwError(exec, SyntaxError, "setData: Invalid number of arguments");
}
case Clipboard::SetDragImage:
{
@@ -1258,11 +1231,8 @@
return Undefined();
}
- if (args.size() != 3) {
- ObjectImp *err = Error::create(exec, SyntaxError,"setDragImage: Invalid number of arguments");
- exec->setException(err);
- return err;
- }
+ if (args.size() != 3)
+ return throwError(exec, SyntaxError, "setDragImage: Invalid number of arguments");
int x = (int)args[1]->toNumber(exec);
int y = (int)args[2]->toNumber(exec);
@@ -1274,9 +1244,7 @@
cb->clipboard->setDragImageElement(node, QPoint(x,y));
return Undefined();
} else {
- ObjectImp *err = Error::create(exec, SyntaxError,"setDragImageFromElement: Invalid first argument");
- exec->setException(err);
- return err;
+ return throwError(exec, SyntaxError, "setDragImageFromElement: Invalid first argument");
}
}
@@ -1287,9 +1255,7 @@
cb->clipboard->setDragImage(JSImage->image()->pixmap(), QPoint(x,y));
return Undefined();
} else {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
+ return throwError(exec, TypeError);
}
}
}
1.135 +100 -250 WebCore/khtml/ecma/kjs_html.cpp
Index: kjs_html.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_html.cpp,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -r1.134 -r1.135
--- kjs_html.cpp 14 Aug 2005 08:07:22 -0000 1.134
+++ kjs_html.cpp 16 Aug 2005 00:47:44 -0000 1.135
@@ -151,11 +151,8 @@
ValueImp *KJS::HTMLDocFunction::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&HTMLDocument::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&HTMLDocument::info))
+ return throwError(exec, TypeError);
HTMLDocumentImpl &doc = *static_cast<HTMLDocumentImpl *>(static_cast<HTMLDocument *>(thisObj)->impl());
switch (id) {
@@ -170,11 +167,8 @@
Window *window = Window::retrieveWindow(part);
if (window) {
ObjectImp *functionObject = window->get(exec, "open")->getObject();
- if (!functionObject || !functionObject->implementsCall()) {
- ObjectImp *exception = Error::create(exec, TypeError);
- exec->setException(exception);
- return exception;
- }
+ if (!functionObject || !functionObject->implementsCall())
+ return throwError(exec, TypeError);
return functionObject->call(exec, window, args);
}
}
@@ -2329,11 +2323,8 @@
ValueImp *KJS::HTMLElementFunction::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::HTMLElement::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::HTMLElement::info))
+ return throwError(exec, TypeError);
kdDebug() << "KJS::HTMLElementFunction::tryCall " << endl;
DOMExceptionTranslator exception(exec);
HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(static_cast<HTMLElement *>(thisObj)->impl());
@@ -3430,11 +3421,8 @@
ValueImp *KJS::HTMLCollectionProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::HTMLCollection::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::HTMLCollection::info))
+ return throwError(exec, TypeError);
HTMLCollectionImpl &coll = *static_cast<HTMLCollection *>(thisObj)->impl();
switch (id) {
@@ -3769,11 +3757,8 @@
ValueImp *KJS::Context2DFunction::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&Context2D::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&Context2D::info))
+ return throwError(exec, TypeError);
Context2D *contextObject = static_cast<KJS::Context2D *>(thisObj);
khtml::RenderCanvasImage *renderer = static_cast<khtml::RenderCanvasImage*>(contextObject->_element->renderer());
@@ -3786,11 +3771,8 @@
switch (id) {
case Context2D::Save: {
- if (args.size() != 0) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 0)
+ return throwError(exec, SyntaxError);
CGContextSaveGState(drawingContext);
contextObject->save();
@@ -3798,11 +3780,8 @@
break;
}
case Context2D::Restore: {
- if (args.size() != 0) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 0)
+ return throwError(exec, SyntaxError);
CGContextRestoreGState(drawingContext);
contextObject->restore();
@@ -3810,20 +3789,14 @@
break;
}
case Context2D::BeginPath: {
- if (args.size() != 0) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 0)
+ return throwError(exec, SyntaxError);
CGContextBeginPath(drawingContext);
break;
}
case Context2D::ClosePath: {
- if (args.size() != 0) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 0)
+ return throwError(exec, SyntaxError);
CGContextClosePath(drawingContext);
break;
}
@@ -3879,11 +3852,8 @@
CGContextSetCMYKStrokeColor(drawingContext, c, m, y, k, a);
}
break;
- default: {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ default:
+ return throwError(exec, SyntaxError);
}
break;
}
@@ -3938,30 +3908,21 @@
CGContextSetCMYKStrokeColor(drawingContext, c, m, y, k, a);
}
break;
- default: {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ default:
+ return throwError(exec, SyntaxError);
}
break;
}
case Context2D::SetLineWidth: {
- if (args.size() != 1) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 1)
+ return throwError(exec, SyntaxError);
float w = (float)args[0]->toNumber(exec);
CGContextSetLineWidth (drawingContext, w);
break;
}
case Context2D::SetLineCap: {
- if (args.size() != 1) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 1)
+ return throwError(exec, SyntaxError);
CGLineCap cap = kCGLineCapButt;
QString capString = args[0]->toString(exec).qstring().lower();
if (capString == "round")
@@ -3972,11 +3933,8 @@
break;
}
case Context2D::SetLineJoin: {
- if (args.size() != 1) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 1)
+ return throwError(exec, SyntaxError);
CGLineJoin join = kCGLineJoinMiter;
QString joinString = args[0]->toString(exec).qstring().lower();
if (joinString == "round")
@@ -3987,21 +3945,15 @@
break;
}
case Context2D::SetMiterLimit: {
- if (args.size() != 1) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 1)
+ return throwError(exec, SyntaxError);
float l = (float)args[0]->toNumber(exec);
CGContextSetMiterLimit (drawingContext, l);
break;
}
case Context2D::Fill: {
- if (args.size() != 0) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 0)
+ return throwError(exec, SyntaxError);
if (isGradient(contextObject->_fillStyle)) {
CGContextSaveGState(drawingContext);
@@ -4027,11 +3979,8 @@
break;
}
case Context2D::Stroke: {
- if (args.size() != 0) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 0)
+ return throwError(exec, SyntaxError);
if (isGradient(contextObject->_strokeStyle)) {
CGContextSaveGState(drawingContext);
@@ -4059,11 +4008,8 @@
break;
}
case Context2D::Scale: {
- if (args.size() != 2) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 2)
+ return throwError(exec, SyntaxError);
float sx = (float)args[0]->toNumber(exec);
float sy = (float)args[1]->toNumber(exec);
CGContextScaleCTM (drawingContext, sx, sy);
@@ -4071,33 +4017,24 @@
break;
}
case Context2D::Rotate: {
- if (args.size() != 1) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 1)
+ return throwError(exec, SyntaxError);
float angle = (float)args[0]->toNumber(exec);
CGContextRotateCTM (drawingContext, angle);
contextObject->_needsFlushRasterCache = true;
break;
}
case Context2D::Translate: {
- if (args.size() != 2) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 2)
+ return throwError(exec, SyntaxError);
float tx = (float)args[0]->toNumber(exec);
float ty = (float)args[1]->toNumber(exec);
CGContextTranslateCTM (drawingContext, tx, ty);
break;
}
case Context2D::MoveTo: {
- if (args.size() != 2) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 2)
+ return throwError(exec, SyntaxError);
float x = (float)args[0]->toNumber(exec);
float y = (float)args[1]->toNumber(exec);
CGContextMoveToPoint (drawingContext, x, y);
@@ -4105,11 +4042,8 @@
break;
}
case Context2D::LineTo: {
- if (args.size() != 2) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 2)
+ return throwError(exec, SyntaxError);
float x = (float)args[0]->toNumber(exec);
float y = (float)args[1]->toNumber(exec);
CGContextAddLineToPoint (drawingContext, x, y);
@@ -4117,11 +4051,8 @@
break;
}
case Context2D::QuadraticCurveTo: {
- if (args.size() != 4) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 4)
+ return throwError(exec, SyntaxError);
float cpx = (float)args[0]->toNumber(exec);
float cpy = (float)args[1]->toNumber(exec);
float x = (float)args[2]->toNumber(exec);
@@ -4131,11 +4062,8 @@
break;
}
case Context2D::BezierCurveTo: {
- if (args.size() != 6) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 6)
+ return throwError(exec, SyntaxError);
float cp1x = (float)args[0]->toNumber(exec);
float cp1y = (float)args[1]->toNumber(exec);
float cp2x = (float)args[2]->toNumber(exec);
@@ -4147,11 +4075,8 @@
break;
}
case Context2D::ArcTo: {
- if (args.size() != 5) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 5)
+ return throwError(exec, SyntaxError);
float x1 = (float)args[0]->toNumber(exec);
float y1 = (float)args[1]->toNumber(exec);
float x2 = (float)args[2]->toNumber(exec);
@@ -4161,11 +4086,8 @@
break;
}
case Context2D::Arc: {
- if (args.size() != 6) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 6)
+ return throwError(exec, SyntaxError);
float x = (float)args[0]->toNumber(exec);
float y = (float)args[1]->toNumber(exec);
float r = (float)args[2]->toNumber(exec);
@@ -4176,11 +4098,8 @@
break;
}
case Context2D::Rect: {
- if (args.size() != 4) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 4)
+ return throwError(exec, SyntaxError);
float x = (float)args[0]->toNumber(exec);
float y = (float)args[1]->toNumber(exec);
float w = (float)args[2]->toNumber(exec);
@@ -4189,21 +4108,15 @@
break;
}
case Context2D::Clip: {
- if (args.size() != 0) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 0)
+ return throwError(exec, SyntaxError);
CGContextClip (drawingContext);
break;
}
case Context2D::ClearRect: {
- if (args.size() != 4) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 4)
+ return throwError(exec, SyntaxError);
float x = (float)args[0]->toNumber(exec);
float y = (float)args[1]->toNumber(exec);
float w = (float)args[2]->toNumber(exec);
@@ -4213,11 +4126,8 @@
break;
}
case Context2D::FillRect: {
- if (args.size() != 4) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 4)
+ return throwError(exec, SyntaxError);
float x = (float)args[0]->toNumber(exec);
float y = (float)args[1]->toNumber(exec);
float w = (float)args[2]->toNumber(exec);
@@ -4230,11 +4140,8 @@
}
case Context2D::StrokeRect: {
int size = args.size();
- if (size < 4) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (size < 4)
+ return throwError(exec, SyntaxError);
float x = (float)args[0]->toNumber(exec);
float y = (float)args[1]->toNumber(exec);
float w = (float)args[2]->toNumber(exec);
@@ -4252,11 +4159,8 @@
case Context2D::SetShadow: {
int numArgs = args.size();
- if (numArgs < 3) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (numArgs < 3)
+ return throwError(exec, SyntaxError);
CGSize offset;
offset.width = (float)args[0]->toNumber(exec);
@@ -4325,11 +4229,8 @@
colorSpace = CGColorSpaceCreateDeviceCMYK();
}
break;
- default: {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ default:
+ return throwError(exec, SyntaxError);
}
CGColorRef colorRef = CGColorCreate (colorSpace, components);
@@ -4340,11 +4241,8 @@
break;
}
case Context2D::ClearShadow: {
- if (args.size() != 0) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 0)
+ return throwError(exec, SyntaxError);
CGContextSetShadowWithColor (drawingContext, CGSizeMake(0, 0), 0, nil);
break;
}
@@ -4356,19 +4254,13 @@
// composite operation is specified with globalCompositeOperation
// img parameter can be a JavaScript Image, <img>, or a <canvas>
case Context2D::DrawImage: {
- if (args.size() < 3) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() < 3)
+ return throwError(exec, SyntaxError);
// Make sure first argument is an object.
ObjectImp *o = static_cast<ObjectImp*>(args[0]);
- if (!o->isObject()) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!o->isObject())
+ return throwError(exec, TypeError);
float w = 0; // quiet incorrect gcc 4.0 warning
float h = 0; // quiet incorrect gcc 4.0 warning
@@ -4409,11 +4301,8 @@
w = (float)CGBitmapContextGetWidth(sourceContext);
h = (float)CGBitmapContextGetHeight(sourceContext);
}
- else {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ else
+ return throwError(exec, TypeError);
float dx, dy, dw = w, dh = h;
float sx = 0.f, sy = 0.f, sw = w, sh = h;
@@ -4438,11 +4327,8 @@
dw = args[7]->toNumber(exec);
dh = args[8]->toNumber(exec);
}
- else {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ else
+ return throwError(exec, SyntaxError);
if (!sourceContext) {
QPainter p;
@@ -4492,17 +4378,11 @@
break;
}
case Context2D::DrawImageFromRect: {
- if (args.size() != 10) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 10)
+ return throwError(exec, SyntaxError);
ObjectImp *o = static_cast<ObjectImp*>(args[0]);
- if (!o->isObject() || !o->inherits(&Image::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!o->isObject() || !o->inherits(&Image::info))
+ return throwError(exec, TypeError);
Image *i = static_cast<Image*>(o);
float sx = args[1]->toNumber(exec);
float sy = args[2]->toNumber(exec);
@@ -4528,32 +4408,23 @@
break;
}
case Context2D::SetAlpha: {
- if (args.size() != 1) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 1)
+ return throwError(exec, SyntaxError);
float a = (float)args[0]->toNumber(exec);
CGContextSetAlpha (drawingContext, a);
break;
}
case Context2D::SetCompositeOperation: {
- if (args.size() != 1) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 1)
+ return throwError(exec, SyntaxError);
QString compositeOperator = args[0]->toString(exec).qstring().lower();
QPainter::setCompositeOperation (drawingContext,compositeOperator);
break;
}
case Context2D::CreateLinearGradient: {
- if (args.size() != 4) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 4)
+ return throwError(exec, SyntaxError);
float x0 = args[0]->toNumber(exec);
float y0 = args[1]->toNumber(exec);
float x1 = args[2]->toNumber(exec);
@@ -4563,11 +4434,8 @@
}
case Context2D::CreateRadialGradient: {
- if (args.size() != 6) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 6)
+ return throwError(exec, SyntaxError);
float x0 = args[0]->toNumber(exec);
float y0 = args[1]->toNumber(exec);
float r0 = args[2]->toNumber(exec);
@@ -4579,17 +4447,11 @@
}
case Context2D::CreatePattern: {
- if (args.size() != 2) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 2)
+ return throwError(exec, SyntaxError);
ObjectImp *o = static_cast<ObjectImp*>(args[0]);
- if (!o->isObject() || !o->inherits(&Image::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!o->isObject() || !o->inherits(&Image::info))
+ return throwError(exec, TypeError);
int repetitionType = ImagePattern::Repeat;
QString repetitionString = args[1]->toString(exec).qstring().lower();
if (repetitionString == "repeat-x")
@@ -4842,11 +4704,8 @@
// CG doesn't have the notion of a setting a stroke gradient.
ObjectImp *o = static_cast<ObjectImp*>(value);
- if (!o->isObject() || !(o->inherits(&Gradient::info) || o->inherits(&ImagePattern::info))) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return;
- }
+ if (!o->isObject() || !(o->inherits(&Gradient::info) || o->inherits(&ImagePattern::info)))
+ throwError(exec, TypeError);
}
break;
}
@@ -4862,11 +4721,8 @@
// CG doesn't have the notion of setting a fill gradient.
ObjectImp *o = static_cast<ObjectImp*>(value);
- if (o->type() != ObjectType || !(o->inherits(&Gradient::info) || o->inherits(&ImagePattern::info))) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return;
- }
+ if (!o->isObject() || !(o->inherits(&Gradient::info) || o->inherits(&ImagePattern::info)))
+ throwError(exec, TypeError);
// Gradients and image patterns are constructed when needed during fill and stroke operations.
}
@@ -5116,21 +4972,15 @@
ValueImp *GradientFunction::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&Gradient::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&Gradient::info))
+ return throwError(exec, TypeError);
Gradient *gradient = static_cast<KJS::Gradient *>(thisObj);
switch (id) {
case Gradient::AddColorStop: {
- if (args.size() != 2) {
- ObjectImp *err = Error::create(exec,SyntaxError);
- exec->setException(err);
- return err;
- }
+ if (args.size() != 2)
+ return throwError(exec, SyntaxError);
QColor color = colorFromValue(exec, args[1]);
gradient->addColorStop ((float)args[0]->toNumber(exec), color.red()/255.f, color.green()/255.f, color.blue()/255.f, color.alpha()/255.f);
1.34 +2 -5 WebCore/khtml/ecma/kjs_navigator.cpp
Index: kjs_navigator.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_navigator.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- kjs_navigator.cpp 8 Aug 2005 04:07:41 -0000 1.33
+++ kjs_navigator.cpp 16 Aug 2005 00:47:45 -0000 1.34
@@ -580,11 +580,8 @@
ValueImp *NavigatorFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &)
{
- if (!thisObj->inherits(&KJS::Navigator::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::Navigator::info))
+ return throwError(exec, TypeError);
Navigator *nav = static_cast<Navigator *>(thisObj);
// javaEnabled()
return Boolean(nav->part()->javaEnabled());
1.15 +2 -5 WebCore/khtml/ecma/kjs_range.cpp
Index: kjs_range.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_range.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- kjs_range.cpp 8 Aug 2005 04:07:41 -0000 1.14
+++ kjs_range.cpp 16 Aug 2005 00:47:45 -0000 1.15
@@ -113,11 +113,8 @@
ValueImp *DOMRangeProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMRange::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMRange::info))
+ return throwError(exec, TypeError);
RangeImpl &range = *static_cast<DOMRange *>(thisObj)->impl();
ValueImp *result = Undefined();
int exception = 0;
1.16 +6 -15 WebCore/khtml/ecma/kjs_traversal.cpp
Index: kjs_traversal.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_traversal.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- kjs_traversal.cpp 8 Aug 2005 04:07:41 -0000 1.15
+++ kjs_traversal.cpp 16 Aug 2005 00:47:45 -0000 1.16
@@ -97,11 +97,8 @@
ValueImp *DOMNodeIteratorProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &)
{
- if (!thisObj->inherits(&KJS::DOMNodeIterator::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMNodeIterator::info))
+ return throwError(exec, TypeError);
DOMExceptionTranslator exception(exec);
NodeIteratorImpl &nodeIterator = *static_cast<DOMNodeIterator *>(thisObj)->impl();
switch (id) {
@@ -186,11 +183,8 @@
ValueImp *DOMNodeFilterProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&KJS::DOMNodeFilter::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMNodeFilter::info))
+ return throwError(exec, TypeError);
NodeFilterImpl &nodeFilter = *static_cast<DOMNodeFilter *>(thisObj)->impl();
switch (id) {
case DOMNodeFilter::AcceptNode:
@@ -285,11 +279,8 @@
ValueImp *DOMTreeWalkerProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &)
{
- if (!thisObj->inherits(&KJS::DOMTreeWalker::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&KJS::DOMTreeWalker::info))
+ return throwError(exec, TypeError);
TreeWalkerImpl &treeWalker = *static_cast<DOMTreeWalker *>(thisObj)->impl();
switch (id) {
case DOMTreeWalker::ParentNode:
1.10 +2 -5 WebCore/khtml/ecma/kjs_views.cpp
Index: kjs_views.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_views.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- kjs_views.cpp 8 Aug 2005 04:07:41 -0000 1.9
+++ kjs_views.cpp 16 Aug 2005 00:47:45 -0000 1.10
@@ -67,11 +67,8 @@
ValueImp *DOMAbstractViewFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&DOMAbstractView::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&DOMAbstractView::info))
+ return throwError(exec, TypeError);
AbstractViewImpl &abstractView = *static_cast<DOMAbstractView *>(thisObj)->impl();
switch (id) {
case DOMAbstractView::GetComputedStyle: {
1.171 +23 -38 WebCore/khtml/ecma/kjs_window.cpp
Index: kjs_window.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_window.cpp,v
retrieving revision 1.170
retrieving revision 1.171
diff -u -r1.170 -r1.171
--- kjs_window.cpp 8 Aug 2005 04:07:41 -0000 1.170
+++ kjs_window.cpp 16 Aug 2005 00:47:45 -0000 1.171
@@ -355,7 +355,7 @@
delete winq;
}
-KJS::Interpreter *Window::interpreter() const
+Interpreter *Window::interpreter() const
{
return KJSProxy::proxy( m_part )->interpreter();
}
@@ -369,7 +369,7 @@
{
assert(obj);
#ifndef QWS
- //assert( dynamic_cast<KJS::Window*>(obj) ); // type checking
+ //assert( dynamic_cast<Window*>(obj) ); // type checking
#endif
}
#endif
@@ -383,9 +383,9 @@
ValueImp *imp = exec->dynamicInterpreter()->globalObject();
assert( imp );
#ifndef QWS
- //assert( dynamic_cast<KJS::Window*>(imp) );
+ //assert( dynamic_cast<Window*>(imp) );
#endif
- return static_cast<KJS::Window*>(imp);
+ return static_cast<Window*>(imp);
}
ValueImp *Window::retrieve(KHTMLPart *p)
@@ -1297,7 +1297,7 @@
return url.protocol().lower() == "about" || url.isEmpty();
}
-bool Window::isSafeScript (const KJS::ScriptInterpreter *origin, const KJS::ScriptInterpreter *target)
+bool Window::isSafeScript(const ScriptInterpreter *origin, const ScriptInterpreter *target)
{
if (origin == target)
return true;
@@ -1360,7 +1360,7 @@
kdDebug(6070) << "Window::isSafeScript: accessing deleted part !" << endl;
return false;
}
- KHTMLPart *activePart = static_cast<KJS::ScriptInterpreter *>( exec->dynamicInterpreter() )->part();
+ KHTMLPart *activePart = static_cast<ScriptInterpreter *>( exec->dynamicInterpreter() )->part();
if (!activePart) {
kdDebug(6070) << "Window::isSafeScript: current interpreter's part is 0L!" << endl;
return false;
@@ -1484,7 +1484,7 @@
void Window::clear( ExecState *exec )
{
- KJS::Interpreter::lock();
+ Interpreter::lock();
if (m_returnValueSlot)
if (ValueImp *returnValue = getDirect("returnValue"))
*m_returnValueSlot = returnValue;
@@ -1492,13 +1492,13 @@
delete winq;
winq = new WindowQObject(this);
// Get rid of everything, those user vars could hold references to DOM nodes
- deleteAllProperties( exec );
+ clearProperties();
// Really delete those properties, so that the DOM nodes get deref'ed
- KJS::Collector::collect();
+ Collector::collect();
// Now recreate a working global object for the next URL that will use us
- KJS::Interpreter *interpreter = KJSProxy::proxy( m_part )->interpreter();
+ Interpreter *interpreter = KJSProxy::proxy( m_part )->interpreter();
interpreter->initGlobalObject();
- KJS::Interpreter::unlock();
+ Interpreter::unlock();
}
void Window::setCurrentEvent(EventImpl *evt)
@@ -1509,11 +1509,8 @@
ValueImp *WindowFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&Window::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&Window::info))
+ return throwError(exec, TypeError);
Window *window = static_cast<Window *>(thisObj);
QString str, str2;
@@ -2061,7 +2058,7 @@
Q_ASSERT( window->m_part );
if ( window->m_part )
{
- KJS::Interpreter *interpreter = KJSProxy::proxy( window->m_part )->interpreter();
+ Interpreter *interpreter = KJSProxy::proxy( window->m_part )->interpreter();
ExecState *exec = interpreter->globalExec();
Q_ASSERT( window == interpreter->globalObject() );
ObjectImp *obj( window );
@@ -2147,7 +2144,7 @@
{
QMapIterator<int,ScheduledAction*> it;
- QMap<int, KJS::ScheduledAction*>*pausedActions = new QMap<int, KJS::ScheduledAction*>;
+ QMap<int, ScheduledAction*>*pausedActions = new QMap<int, ScheduledAction*>;
for (it = scheduledActions.begin(); it != scheduledActions.end(); ++it) {
int timerId = it.key();
pauseTimer (timerId, key);
@@ -2469,11 +2466,8 @@
ValueImp *LocationFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&Location::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&Location::info))
+ return throwError(exec, TypeError);
Location *location = static_cast<Location *>(thisObj);
KHTMLPart *part = location->part();
if (part) {
@@ -2620,19 +2614,13 @@
UString Selection::toString(ExecState *) const
{
- if (!m_part->selection().isRange())
- return UString("");
- int exception = 0;
- return UString(m_part->selection().toRange()->toString(exception));
+ return UString(m_part->selectedText());
}
ValueImp *SelectionFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&Selection::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&Selection::info))
+ return throwError(exec, TypeError);
Selection *selection = static_cast<Selection *>(thisObj);
KHTMLPart *part = selection->part();
if (part) {
@@ -2688,7 +2676,7 @@
granularity = khtml::WORD;
else if (granularityString == "line")
granularity = khtml::LINE;
- else if (granularityString == "pargraph")
+ else if (granularityString == "paragraph")
granularity = khtml::PARAGRAPH;
s.modify(alter, direction, granularity);
part->setSelection(s);
@@ -2797,11 +2785,8 @@
ValueImp *HistoryFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&History::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&History::info))
+ return throwError(exec, TypeError);
History *history = static_cast<History *>(thisObj);
int steps;
1.37 +2 -5 WebCore/khtml/ecma/xmlhttprequest.cpp
Index: xmlhttprequest.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/xmlhttprequest.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- xmlhttprequest.cpp 10 Aug 2005 22:46:08 -0000 1.36
+++ xmlhttprequest.cpp 16 Aug 2005 00:47:46 -0000 1.37
@@ -654,11 +654,8 @@
ValueImp *XMLHttpRequestProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&XMLHttpRequest::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&XMLHttpRequest::info))
+ return throwError(exec, TypeError);
XMLHttpRequest *request = static_cast<XMLHttpRequest *>(thisObj);
1.7 +2 -5 WebCore/khtml/ecma/xmlserializer.cpp
Index: xmlserializer.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/xmlserializer.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- xmlserializer.cpp 9 Aug 2005 19:15:56 -0000 1.6
+++ xmlserializer.cpp 16 Aug 2005 00:47:46 -0000 1.7
@@ -72,11 +72,8 @@
ValueImp *XMLSerializerProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj->inherits(&XMLSerializer::info)) {
- ObjectImp *err = Error::create(exec,TypeError);
- exec->setException(err);
- return err;
- }
+ if (!thisObj->inherits(&XMLSerializer::info))
+ return throwError(exec, TypeError);
switch (id) {
case XMLSerializer::SerializeToString:
More information about the webkit-changes
mailing list