[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/4.0/kdelibs/khtml/ecma
From: Harri Porten <porten () kde ! org>
Date: 2008-01-18 3:18:27
Message-ID: 1200626307.255155.12581.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 762877 by porten:
Implement a proper RangeException object with pseudo constructor
and prototype holding the error code constant. setDOMException()
will be cleaned up once all DOM errors are done this way.
M +8 -1 kjs_binding.cpp
M +20 -0 kjs_range.cpp
M +10 -0 kjs_range.h
M +3 -0 kjs_window.cpp
M +1 -1 kjs_window.h
--- branches/KDE/4.0/kdelibs/khtml/ecma/kjs_binding.cpp #762876:762877
@@ -32,6 +32,7 @@
#include "kjs_dom.h"
+#include "kjs_range.h"
#include <dom/css_stylesheet.h>
#include <dom/dom_exception.h>
@@ -314,6 +315,7 @@
const char *type = "DOM";
int code = DOMExceptionCode;
+ JSObject *errorObject = 0;
const char* const* nameTable;
int nameTableSize;
@@ -322,6 +324,10 @@
code -= DOM::RangeException::_EXCEPTION_OFFSET;
nameTable = rangeExceptionNames;
nameTableSize = sizeof(rangeExceptionNames) / sizeof(rangeExceptionNames[0]);
+ errorObject = new RangeException(exec);
+ exec->setException(errorObject);
+ errorObject->put(exec, exec->propertyNames().name, jsString(UString(type) + " \
Exception")); + errorObject->put(exec, exec->propertyNames().message, \
jsString(nameTable[code])); } else if (code >= DOM::CSSException::_EXCEPTION_OFFSET \
&& code <= DOM::CSSException::_EXCEPTION_MAX) { type = "CSS";
code -= DOM::CSSException::_EXCEPTION_OFFSET;
@@ -353,7 +359,8 @@
else
snprintf(buffer, 99, "%s Exception %d", type, code);
- JSObject *errorObject = throwError(exec, GeneralError, buffer);
+ if (!errorObject)
+ errorObject = throwError(exec, GeneralError, buffer);
errorObject->put(exec, "code", jsNumber(code));
}
--- branches/KDE/4.0/kdelibs/khtml/ecma/kjs_range.cpp #762876:762877
@@ -225,3 +225,23 @@
const DOMRange *dobj = static_cast<const DOMRange*>(obj);
return dobj->impl();
}
+
+/* Source for RangeExceptionProtoTable.
+@begin RangeExceptionProtoTable 2
+BAD_BOUNDARYPOINTS_ERR DOM::RangeException::BAD_BOUNDARYPOINTS_ERR \
DontDelete|ReadOnly +INVALID_NODE_TYPE_ERR \
DOM::RangeException::INVALID_NODE_TYPE_ERR DontDelete|ReadOnly +@end
+*/
+
+DEFINE_CONSTANT_TABLE(RangeExceptionProto)
+IMPLEMENT_CONSTANT_TABLE(RangeExceptionProto, "RangeException")
+
+IMPLEMENT_PSEUDO_CONSTRUCTOR_WITH_PARENT(RangeExceptionPseudoCtor, "RangeException",
+ RangeExceptionProto, RangeExceptionProto)
+
+RangeException::RangeException(ExecState* exec)
+ : DOMObject(RangeExceptionProto::self(exec))
+{
+}
+
+const ClassInfo RangeException::info = { "RangeException", 0, 0, 0 };
--- branches/KDE/4.0/kdelibs/khtml/ecma/kjs_range.h #762876:762877
@@ -61,12 +61,22 @@
JSValue* getDOMRange(ExecState *exec, DOM::RangeImpl* r);
JSValue* getRangeConstructor(ExecState *exec);
+ JSObject* getRangeExceptionConstructor(ExecState *exec);
/**
* Convert an object to a RangeImpl. Returns 0 if not possible
*/
DOM::RangeImpl* toRange(JSValue*);
+ DEFINE_PSEUDO_CONSTRUCTOR(RangeExceptionPseudoCtor);
+
+ class RangeException : public DOMObject {
+ public:
+ RangeException(ExecState* exec);
+ virtual const ClassInfo* classInfo() const { return &info; }
+ static const ClassInfo info;
+ };
+
} // namespace
#endif
--- branches/KDE/4.0/kdelibs/khtml/ecma/kjs_window.cpp #762876:762877
@@ -326,6 +326,7 @@
Range Window::Range DontDelete
NodeFilter Window::NodeFilter DontDelete
DOMException Window::DOMException DontDelete
+ RangeException Window::RangeException DontDelete
CSSRule Window::CSSRule DontDelete
MutationEvent Window::MutationEventCtor DontDelete
KeyboardEvent Window::KeyboardEventCtor DontDelete
@@ -773,6 +774,8 @@
return getNodeFilterConstructor(exec);
case DOMException:
return getDOMExceptionConstructor(exec);
+ case RangeException:
+ return RangeExceptionPseudoCtor::self(exec);
case CSSRule:
return getCSSRuleConstructor(exec);
case ElementCtor:
--- branches/KDE/4.0/kdelibs/khtml/ecma/kjs_window.h #762876:762877
@@ -139,7 +139,7 @@
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Closed, Crypto, DefaultStatus, Status, Document, Node, EventCtor, Range,
- NodeFilter, DOMException, CSSRule, Frames, _History, _External, Event, \
InnerHeight, + NodeFilter, DOMException, RangeException, CSSRule, Frames, \
_History, _External, Event, InnerHeight,
InnerWidth, Length, _Location, Navigate, Name, _Navigator, _Konqueror, \
ClientInformation,
OffscreenBuffering, Opener, OuterHeight, OuterWidth, PageXOffset, \
PageYOffset,
Parent, Personalbar, ScreenX, ScreenY, Scrollbars, Scroll, ScrollBy,
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic