+2005-05-12 Darin Adler <darin@apple.com>
+
+ Reviewed by Maciej (except for some parts outside the ECMA directory).
+
+ - switch KJS wrappers over to using the DOM impl. classes rather than using
+ the DOM wrappers; will allow us to not even compile the DOM wrappers and
+ make the code smaller
+
+ * khtml/css/css_valueimpl.h: Added CSSStyleDeclarationImpl::isPropertyName,
+ removed CSSStyleDeclarationImpl::propertyID.
+ * khtml/css/css_valueimpl.cpp:
+ (DOM::propertyID): Added. Gets property ID given a DOM string. Replaces the
+ previous version that had hacks that we want to leave in the JS wrapper for now.
+ (DOM::CSSStyleDeclarationImpl::isPropertyName): Added.
+
+ * khtml/css/cssproperties.in: Fixed up comments.
+
+ * khtml/css/makeprop: Added new maxCSSPropertyNameLength constant, used for
+ buffer size in the propertyID function.
+
+ * khtml/dom/dom2_events.h: Added handleEventImpl, making it easier to call
+ handleEvent in a way that works either with or without the C++ DOM wrappers.
+ * khtml/dom/dom2_events.cpp: (EventListener::handleEventImpl): Added.
+
+ * khtml/dom/dom2_views.cpp: Added now-needed include.
+ * khtml/dom/dom_doc.cpp: Added now-needed include.
+ * khtml/dom/dom_element.cpp: Tweaked includes.
+
+ * khtml/editing/htmlediting.cpp: Removed now-unneeded include.
+ * khtml/html/html_baseimpl.cpp: Ditto.
+ * khtml/html/html_formimpl.h: Ditto.
+ * khtml/rendering/render_form.h: Ditto.
+ * khtml/rendering/render_style.h: Ditto.
+ * khtml/xml/dom2_eventsimpl.cpp: Ditto.
+ * khtml/xml/dom2_viewsimpl.h: Ditto.
+ * khtml/xml/dom_elementimpl.h: Ditto.
+ * khtml/xml/dom_stringimpl.h: Ditto.
+ * kwq/DOM.mm: Ditto.
+ * kwq/DOMHTML.mm: Ditto.
+
+ * khtml/khtml_part.cpp: Tweaked incluudes.
+ * khtml/khtmlpart_p.h: Ditto.
+
+ * kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::canCachePage): Change to use DOM impl. rather
+ than C++ DOM.
+
+ * khtml/xml/dom_docimpl.cpp:
+ (DOMImplementationImpl::createDocumentType): Disabled the calls to the not-implemented
+ name checks in the C++ DOM wrappers. If we add name changes, we'll want them inside the
+ impl, not in the wrappers.
+ (DOMImplementationImpl::createDocument): Ditto.
+ * khtml/xml/dom_nodeimpl.cpp: (NodeImpl::checkSetPrefix): Ditto.
+
+ * khtml/ecma/kjs_binding.cpp:
+ (KJS::ScriptInterpreter::wasRunByUserGesture):
+ (KJS::KJS::ValueToVariant):
+ (KJS::setDOMException):
+ * khtml/ecma/kjs_binding.h:
+ (KJS::ScriptInterpreter::setCurrentEvent):
+ (KJS::ScriptInterpreter::getCurrentEvent):
+ (KJS::cacheDOMObject):
+ (KJS::DOMExceptionTranslator::DOMExceptionTranslator):
+ (KJS::DOMExceptionTranslator::~DOMExceptionTranslator):
+ (KJS::DOMExceptionTranslator::operator int &):
+ (KJS::cacheGlobalObject):
+ * khtml/ecma/kjs_css.cpp:
+ (KJS::cssPropertyName):
+ (KJS::isCSSPropertyName):
+ (KJS::DOMCSSStyleDeclaration::DOMCSSStyleDeclaration):
+ (KJS::DOMCSSStyleDeclaration::~DOMCSSStyleDeclaration):
+ (KJS::DOMCSSStyleDeclaration::hasProperty):
+ (KJS::DOMCSSStyleDeclaration::tryGet):
+ (KJS::DOMCSSStyleDeclaration::tryPut):
+ (KJS::DOMCSSStyleDeclarationProtoFunc::tryCall):
+ (KJS::getDOMCSSStyleDeclaration):
+ (KJS::DOMStyleSheet::~DOMStyleSheet):
+ (KJS::DOMStyleSheet::getValueProperty):
+ (KJS::DOMStyleSheet::tryPut):
+ (KJS::getDOMStyleSheet):
+ (KJS::DOMStyleSheetList::~DOMStyleSheetList):
+ (KJS::DOMStyleSheetList::tryGet):
+ (KJS::getDOMStyleSheetList):
+ (KJS::DOMStyleSheetListFunc::tryCall):
+ (KJS::DOMMediaList::DOMMediaList):
+ (KJS::DOMMediaList::~DOMMediaList):
+ (KJS::DOMMediaList::tryGet):
+ (KJS::DOMMediaList::tryPut):
+ (KJS::getDOMMediaList):
+ (KJS::KJS::DOMMediaListProtoFunc::tryCall):
+ (KJS::DOMCSSStyleSheet::DOMCSSStyleSheet):
+ (KJS::DOMCSSStyleSheet::tryGet):
+ (KJS::DOMCSSStyleSheetProtoFunc::tryCall):
+ (KJS::DOMCSSRuleList::~DOMCSSRuleList):
+ (KJS::DOMCSSRuleList::tryGet):
+ (KJS::DOMCSSRuleListFunc::tryCall):
+ (KJS::getDOMCSSRuleList):
+ (KJS::DOMCSSRule::~DOMCSSRule):
+ (KJS::DOMCSSRule::classInfo):
+ (KJS::DOMCSSRule::tryGet):
+ (KJS::DOMCSSRule::getValueProperty):
+ (KJS::DOMCSSRule::putValue):
+ (KJS::DOMCSSRuleFunc::tryCall):
+ (KJS::getDOMCSSRule):
+ (KJS::DOMCSSValue::~DOMCSSValue):
+ (KJS::DOMCSSValue::tryGet):
+ (KJS::DOMCSSValue::tryPut):
+ (KJS::getDOMCSSValue):
+ (KJS::DOMCSSPrimitiveValue::DOMCSSPrimitiveValue):
+ (KJS::DOMCSSPrimitiveValue::tryGet):
+ (KJS::DOMCSSPrimitiveValueProtoFunc::tryCall):
+ (KJS::DOMCSSValueList::DOMCSSValueList):
+ (KJS::DOMCSSValueList::tryGet):
+ (KJS::DOMCSSValueListFunc::tryCall):
+ (KJS::DOMRGBColor::getValueProperty):
+ (KJS::getDOMRGBColor):
+ (KJS::DOMRect::~DOMRect):
+ (KJS::DOMRect::getValueProperty):
+ (KJS::getDOMRect):
+ (KJS::DOMCounter::~DOMCounter):
+ (KJS::DOMCounter::getValueProperty):
+ (KJS::getDOMCounter):
+ * khtml/ecma/kjs_css.h:
+ (KJS::DOMCSSStyleDeclaration::impl):
+ (KJS::DOMStyleSheet::DOMStyleSheet):
+ (KJS::DOMStyleSheet::impl):
+ (KJS::DOMStyleSheetList::DOMStyleSheetList):
+ (KJS::DOMStyleSheetList::impl):
+ (KJS::DOMMediaList::impl):
+ (KJS::DOMCSSStyleSheet::):
+ (KJS::DOMCSSRuleList::DOMCSSRuleList):
+ (KJS::DOMCSSRuleList::impl):
+ (KJS::DOMCSSRule::DOMCSSRule):
+ (KJS::DOMCSSRule::impl):
+ (KJS::DOMCSSValue::DOMCSSValue):
+ (KJS::DOMCSSValue::impl):
+ (KJS::DOMCSSValueList::):
+ (KJS::DOMRGBColor::DOMRGBColor):
+ (KJS::DOMRect::DOMRect):
+ (KJS::DOMCounter::DOMCounter):
+ * khtml/ecma/kjs_dom.cpp:
+ (KJS::DOMNodeListFunc::):
+ (KJS::DOMNode::DOMNode):
+ (KJS::DOMNode::toBoolean):
+ (KJS::DOMNode::getValueProperty):
+ (KJS::DOMNode::putValue):
+ (KJS::DOMNode::toPrimitive):
+ (KJS::DOMNode::toString):
+ (KJS::DOMNode::setListener):
+ (KJS::DOMNode::getListener):
+ (KJS::DOMNodeProtoFunc::tryCall):
+ (KJS::toNode):
+ (KJS::DOMNodeList::~DOMNodeList):
+ (KJS::DOMNodeList::toPrimitive):
+ (KJS::DOMNodeList::tryGet):
+ (KJS::DOMNodeList::tryCall):
+ (KJS::DOMNodeListFunc::tryCall):
+ (KJS::DOMAttr::DOMAttr):
+ (KJS::DOMAttr::getValueProperty):
+ (KJS::DOMAttr::putValue):
+ (KJS::toAttr):
+ (KJS::DOMDocument::DOMDocument):
+ (KJS::DOMDocument::~DOMDocument):
+ (KJS::DOMDocument::getValueProperty):
+ (KJS::DOMDocument::putValue):
+ (KJS::DOMDocumentProtoFunc::tryCall):
+ (KJS::DOMElement::DOMElement):
+ (KJS::DOMElement::tryGet):
+ (KJS::DOMElementProtoFunc::tryCall):
+ (KJS::toElement):
+ (KJS::DOMDOMImplementation::DOMDOMImplementation):
+ (KJS::DOMDOMImplementation::~DOMDOMImplementation):
+ (KJS::DOMDOMImplementationProtoFunc::tryCall):
+ (KJS::DOMDocumentType::DOMDocumentType):
+ (KJS::DOMDocumentType::getValueProperty):
+ (KJS::toDocumentType):
+ (KJS::DOMNamedNodeMap::DOMNamedNodeMap):
+ (KJS::DOMNamedNodeMap::~DOMNamedNodeMap):
+ (KJS::DOMNamedNodeMap::tryGet):
+ (KJS::DOMNamedNodeMapProtoFunc::tryCall):
+ (KJS::DOMProcessingInstruction::DOMProcessingInstruction):
+ (KJS::DOMProcessingInstruction::getValueProperty):
+ (KJS::DOMProcessingInstruction::tryPut):
+ (KJS::DOMNotation::DOMNotation):
+ (KJS::DOMNotation::getValueProperty):
+ (KJS::DOMEntity::DOMEntity):
+ (KJS::DOMEntity::getValueProperty):
+ (KJS::getDOMDocumentNode):
+ (KJS::checkNodeSecurity):
+ (KJS::getDOMNode):
+ (KJS::getDOMNamedNodeMap):
+ (KJS::getRuntimeObject):
+ (KJS::getDOMNodeList):
+ (KJS::getDOMDOMImplementation):
+ (KJS::getNodeConstructor):
+ (KJS::getDOMExceptionConstructor):
+ (KJS::DOMNamedNodesCollection::DOMNamedNodesCollection):
+ (KJS::DOMNamedNodesCollection::tryGet):
+ (KJS::DOMCharacterData::DOMCharacterData):
+ (KJS::DOMCharacterData::getValueProperty):
+ (KJS::DOMCharacterData::tryPut):
+ (KJS::DOMCharacterDataProtoFunc::tryCall):
+ (KJS::DOMText::DOMText):
+ (KJS::DOMTextProtoFunc::tryCall):
+ * khtml/ecma/kjs_dom.h:
+ (KJS::DOMNode::impl):
+ (KJS::DOMNodeList::DOMNodeList):
+ (KJS::DOMNodeList::impl):
+ (KJS::DOMDOMImplementation::impl):
+ (KJS::DOMNamedNodeMap::impl):
+ * khtml/ecma/kjs_events.cpp:
+ (KJS::JSAbstractEventListener::handleEvent):
+ (KJS::JSLazyEventListener::handleEvent):
+ (KJS::getNodeEventListener):
+ (KJS::DOMEvent::DOMEvent):
+ (KJS::DOMEvent::~DOMEvent):
+ (KJS::DOMEvent::getValueProperty):
+ (KJS::DOMEvent::putValue):
+ (KJS::DOMEventProtoFunc::tryCall):
+ (KJS::getDOMEvent):
+ (KJS::toEvent):
+ (KJS::DOMUIEvent::DOMUIEvent):
+ (KJS::DOMUIEvent::getValueProperty):
+ (KJS::DOMUIEventProtoFunc::tryCall):
+ (KJS::DOMMouseEvent::DOMMouseEvent):
+ (KJS::DOMMouseEvent::getValueProperty):
+ (KJS::DOMMouseEventProtoFunc::tryCall):
+ (KJS::DOMKeyboardEvent::DOMKeyboardEvent):
+ (KJS::DOMKeyboardEvent::getValueProperty):
+ (KJS::DOMKeyboardEventProtoFunc::tryCall):
+ (KJS::DOMMutationEvent::DOMMutationEvent):
+ (KJS::DOMMutationEvent::getValueProperty):
+ (KJS::DOMMutationEventProtoFunc::tryCall):
+ (KJS::DOMWheelEvent::DOMWheelEvent):
+ (KJS::DOMWheelEvent::getValueProperty):
+ (KJS::ClipboardProtoFunc::tryCall):
+ * khtml/ecma/kjs_events.h:
+ (KJS::DOMEvent::impl):
+ (KJS::DOMUIEvent::):
+ (KJS::DOMMouseEvent::):
+ (KJS::DOMKeyboardEvent::):
+ (KJS::DOMMutationEvent::):
+ * khtml/ecma/kjs_html.cpp:
+ (KJS::KJS::HTMLDocFunction::tryCall):
+ (KJS::HTMLDocument::HTMLDocument):
+ (KJS::HTMLDocument::hasProperty):
+ (KJS::HTMLDocument::tryGet):
+ (KJS::KJS::HTMLDocument::putValue):
+ (KJS::KJS::HTMLElement::classInfo):
+ (KJS::HTMLElement::HTMLElement):
+ (KJS::KJS::HTMLElement::tryGet):
+ (KJS::KJS::HTMLElement::implementsCall):
+ (KJS::KJS::HTMLElement::call):
+ (KJS::KJS::HTMLElement::getValueProperty):
+ (KJS::KJS::HTMLElement::hasProperty):
+ (KJS::KJS::HTMLElement::toString):
+ (KJS::getForm):
+ (KJS::KJS::HTMLElement::pushEventHandlerScope):
+ (KJS::KJS::HTMLElementFunction::tryCall):
+ (KJS::KJS::HTMLElement::tryPut):
+ (KJS::HTMLElement::putValue):
+ (KJS::toHTMLElement):
+ (KJS::toHTMLTableCaptionElement):
+ (KJS::toHTMLTableSectionElement):
+ (KJS::HTMLCollection::HTMLCollection):
+ (KJS::HTMLCollection::~HTMLCollection):
+ (KJS::KJS::HTMLCollection::tryGet):
+ (KJS::KJS::HTMLCollection::tryCall):
+ (KJS::KJS::HTMLCollection::getNamedItems):
+ (KJS::KJS::HTMLCollectionProtoFunc::tryCall):
+ (KJS::HTMLSelectCollection::HTMLSelectCollection):
+ (KJS::KJS::HTMLSelectCollection::tryGet):
+ (KJS::KJS::HTMLSelectCollection::tryPut):
+ (KJS::OptionConstructorImp::OptionConstructorImp):
+ (KJS::OptionConstructorImp::construct):
+ (KJS::ImageConstructorImp::ImageConstructorImp):
+ (KJS::ImageConstructorImp::construct):
+ (KJS::Image::notifyFinished):
+ (KJS::Image::Image):
+ (KJS::KJS::Context2DFunction::tryCall):
+ (KJS::):
+ (KJS::colorRefFromValue):
+ (KJS::colorFromValue):
+ (KJS::Context2D::putValue):
+ (KJS::Context2D::Context2D):
+ (KJS::Context2D::mark):
+ (KJS::GradientFunction::tryCall):
+ (KJS::ImagePattern::tryGet):
+ (KJS::getHTMLCollection):
+ (KJS::getSelectHTMLCollection):
+ * khtml/ecma/kjs_html.h:
+ (KJS::HTMLDocument::):
+ (KJS::HTMLElement::):
+ (KJS::HTMLCollection::impl):
+ * khtml/ecma/kjs_navigator.cpp:
+ * khtml/ecma/kjs_proxy.cpp:
+ (KJSProxyImpl::evaluate):
+ (KJSProxyImpl::finishedWithEvent):
+ * khtml/ecma/kjs_proxy.h:
+ * khtml/ecma/kjs_range.cpp:
+ (KJS::DOMRange::DOMRange):
+ (KJS::DOMRange::~DOMRange):
+ (KJS::DOMRange::tryGet):
+ (KJS::DOMRange::getValueProperty):
+ (KJS::DOMRangeProtoFunc::tryCall):
+ (KJS::getDOMRange):
+ (KJS::RangeConstructor::tryGet):
+ (KJS::getRangeConstructor):
+ (KJS::toRange):
+ * khtml/ecma/kjs_range.h:
+ (KJS::DOMRange::impl):
+ * khtml/ecma/kjs_traversal.cpp:
+ (KJS::DOMNodeIterator::DOMNodeIterator):
+ (KJS::DOMNodeIterator::~DOMNodeIterator):
+ (KJS::DOMNodeIterator::getValueProperty):
+ (KJS::DOMNodeIteratorProtoFunc::tryCall):
+ (KJS::getDOMNodeIterator):
+ (KJS::DOMNodeFilter::DOMNodeFilter):
+ (KJS::DOMNodeFilter::~DOMNodeFilter):
+ (KJS::DOMNodeFilterProtoFunc::tryCall):
+ (KJS::getDOMNodeFilter):
+ (KJS::toNodeFilter):
+ (KJS::DOMTreeWalker::DOMTreeWalker):
+ (KJS::DOMTreeWalker::~DOMTreeWalker):
+ (KJS::DOMTreeWalker::getValueProperty):
+ (KJS::DOMTreeWalker::tryPut):
+ (KJS::DOMTreeWalkerProtoFunc::tryCall):
+ (KJS::getDOMTreeWalker):
+ (KJS::JSNodeFilterCondition::acceptNode):
+ * khtml/ecma/kjs_traversal.h:
+ (KJS::DOMNodeIterator::impl):
+ (KJS::DOMNodeFilter::impl):
+ (KJS::DOMTreeWalker::impl):
+ * khtml/ecma/kjs_views.cpp:
+ (KJS::DOMAbstractView::~DOMAbstractView):
+ (KJS::DOMAbstractView::tryGet):
+ (KJS::DOMAbstractViewFunc::tryCall):
+ (KJS::getDOMAbstractView):
+ (KJS::toAbstractView):
+ * khtml/ecma/kjs_views.h:
+ (KJS::DOMAbstractView::DOMAbstractView):
+ (KJS::DOMAbstractView::impl):
+ * khtml/ecma/kjs_window.cpp:
+ (KJS::Window::get):
+ (KJS::Window::hasProperty):
+ (KJS::Window::put):
+ (KJS::Window::setListener):
+ (KJS::Window::getListener):
+ (KJS::Window::setCurrentEvent):
+ (KJS::WindowFunc::tryCall):
+ (KJS::Location::put):
+ (KJS::LocationFunc::tryCall):
+ (KJS::Selection::get):
+ (KJS::SelectionFunc::tryCall):
+ * khtml/ecma/kjs_window.h:
+ * khtml/ecma/xmlhttprequest.cpp:
+ (KJS::XMLHttpRequestConstructorImp::XMLHttpRequestConstructorImp):
+ (KJS::XMLHttpRequestConstructorImp::~XMLHttpRequestConstructorImp):
+ (KJS::XMLHttpRequestConstructorImp::construct):
+ (KJS::XMLHttpRequest::getValueProperty):
+ (KJS::XMLHttpRequest::XMLHttpRequest):
+ (KJS::XMLHttpRequest::changeState):
+ (KJS::XMLHttpRequest::open):
+ (KJS::XMLHttpRequestProtoFunc::tryCall):
+ * khtml/ecma/xmlhttprequest.h:
+ * khtml/ecma/xmlserializer.cpp:
+ (KJS::XMLSerializerProtoFunc::tryCall):
+ * khtml/ecma/xmlserializer.h:
+ * kwq/DOMInternal.mm:
+ (-[WebScriptObject _initializeScriptDOMNodeImp]):
+ * kwq/DOMUtility.mm:
+ (KJS::ScriptInterpreter::createObjcInstanceForValue):
+
2005-05-11 David Hyatt <hyatt@apple.com>
Improve the display of apple.com. innerWidth and innerHeight refer to the size of the visible view and
// Defined in parser.y, but not in any header, so just declare it here.
int getPropertyID(const char *str, int len);
+static int propertyID(const DOMString &s)
+{
+ char buffer[maxCSSPropertyNameLength];
+
+ unsigned len = s.length();
+ if (len > maxCSSPropertyNameLength)
+ return 0;
+
+ for (unsigned i = 0; i != len; ++i) {
+ unsigned short c = s[i].unicode();
+ if (c == 0 || c >= 0x7F)
+ return 0; // illegal character
+ buffer[i] = c;
+ }
+
+ return getPropertyID(buffer, len);
+}
+
#if 0
// Too risky to quote all legal identifiers right now.
return removeProperty(propID, exception);
}
+bool CSSStyleDeclarationImpl::isPropertyName(const DOMString &propertyName)
+{
+ return propertyID(propertyName);
+}
+
+// --------------------------------------------------------------------------------------
+
CSSMutableStyleDeclarationImpl::CSSMutableStyleDeclarationImpl()
: m_node(0)
{
return a.m_id == b.m_id && a.m_bImportant == b.m_bImportant && a.m_value == b.m_value;
}
-int CSSStyleDeclarationImpl::propertyID(const DOMString &s, bool *hadPixelOrPosPrefix)
-{
- QString prop = s.string();
-
- int i = prop.length();
- while (--i) {
- char c = prop[i].latin1();
- if (!c)
- return 0; // non-ASCII character
- if (c >= 'A' && c <= 'Z')
- prop.insert(i, '-');
- }
-
- prop = prop.lower();
-
- if (hadPixelOrPosPrefix)
- *hadPixelOrPosPrefix = false;
-
- if (prop.startsWith("css-")) {
- prop = prop.mid(4);
- } else if (prop.startsWith("pixel-")) {
- prop = prop.mid(6);
- if (hadPixelOrPosPrefix)
- *hadPixelOrPosPrefix = true;
- } else if (prop.startsWith("pos-")) {
- prop = prop.mid(4);
- if (hadPixelOrPosPrefix)
- *hadPixelOrPosPrefix = true;
- } else if (prop.startsWith("khtml-") || prop.startsWith("apple-") || prop.startsWith("moz-")) {
- prop.insert(0, '-');
- }
-
- return getPropertyID(prop.latin1(), prop.length());
-}
-
}
public:
virtual bool isStyleDeclaration();
- static int propertyID(const DOMString &propertName, bool *hadPixelOrPosPrefix = 0);
+ static bool isPropertyName(const DOMString &propertyName);
CSSRuleImpl *parentRule() const;
#
-# all valid CSS2 properties.
+# CSS property names
#
-# aural properties are commented out, as we don't support them anyway.
-#
-# some properties are used in khtml, but are not part of CSS. They are used to get
+# Some properties are used in khtml, but are not part of CSS. They are used to get
# HTML4 compatibilty in the rendering engine.
#
-# Mircosoft extensions are documented here:
+# Microsoft extensions are documented here:
# http://msdn.microsoft.com/workshop/author/css/reference/attributes.asp
#
-# CSS_PROP_BACKGROUND_COLOR:
-#
background-color
background-image
background-repeat
background-attachment
background-position
-# IE Extensions
background-position-x
background-position-y
-khtml-binding
echo -e '%{\n/* This file is automatically generated from cssproperties.in by makeprop, do not edit */\n/* Copyright 1999 W. Bastian */\n#include "cssproperties.h"\n%}\nstruct props {\n const char *name;\n int id;\n};\n%%' > cssproperties.gperf
cat cssproperties.strip | awk '{ do { prop = $0; gsub("-", "_"); print prop ", CSS_PROP_" toupper($0) } while (getline) }' >> cssproperties.gperf
echo '%%' >> cssproperties.gperf
+
echo -e '/* This file is automatically generated from cssproperties.in by makeprop, do not edit */\n/* Copyright 1998 W. Bastian */\n\n#ifndef CSSPROPERTIES_H\n#define CSSPROPERTIES_H\n\n' > cssproperties.h
cat cssproperties.strip | awk '{ \
i=1; \
print "#define CSS_PROP_MAX CSS_PROP_Z_INDEX"; \
print "#define CSS_PROP_TOTAL " i \
}' >> cssproperties.h
-gperf -a -L 'ANSI-C' -E -C -c -o -t -k '*' -NfindProp -Hhash_prop -Wwordlist_prop -D -s 2 cssproperties.gperf > cssproperties.c || exit 1
+perl -e 'my $max = 0; while (<>) { chomp; $max = length if $ ax < length; } print "const size_t maxCSSPropertyNameLength = $max;\n"' < cssproperties.strip >> cssproperties.h
echo -e '#endif\n' >> cssproperties.h
+gperf -a -L 'ANSI-C' -E -C -c -o -t -k '*' -NfindProp -Hhash_prop -Wwordlist_prop -D -s 2 cssproperties.gperf > cssproperties.c || exit 1
+
cat cssproperties.strip | awk '{ \
i=1; \
print "static const char * const propertyList[] = {"; \
{
}
+void EventListener::handleEventImpl(EventImpl *evt, bool isWindowEvent)
+{
+#if KHTML_NO_CPLUSPLUS_DOM
+ handleEvent(evt, isWindowEvent);
+#else
+ Event wrapper(evt);
+ handleEvent(wrapper, isWindowEvent);
+#endif
+}
+
void EventListener::handleEvent(EventListenerEvent, bool)
{
}
*
*/
virtual void handleEvent(EventListenerEvent evt, bool isWindowEvent);
+ void handleEventImpl(EventImpl *evt, bool isWindowEvent);
/**
* @internal
*/
#include "dom/dom2_views.h"
+
+#include "dom/dom_element.h"
#include "dom/dom_exception.h"
#include "dom/dom_doc.h"
#include "xml/dom_elementimpl.h"
*
*/
+#include "dom_doc.h"
+
+#include "dom/dom_element.h"
#include "dom/dom_exception.h"
#include "dom/dom_xml.h"
#include "dom/dom2_range.h"
*
*/
+#include "dom_element.h"
+
#include "dom/dom_exception.h"
#include "xml/dom_docimpl.h"
#include "xml/dom_elementimpl.h"
-// FIXME: Remove when .style gets moved to html_element.cpp.
-#include "html/html_elementimpl.h"
-
using namespace DOM;
Attr::Attr() : Node()
*/
#include "kjs_binding.h"
+
#include "kjs_dom.h"
#include "kjs_window.h"
#include <kjs/internal.h> // for InterpreterImp
#include "dom/dom_exception.h"
-#include "dom/dom2_range.h"
#include "dom/dom2_events.h"
+#include "dom/dom2_range.h"
+#include "xml/dom_nodeimpl.h"
#include "xml/dom2_eventsimpl.h"
#include <kdebug.h>
+using DOM::CSSException;
using DOM::DOMString;
+using DOM::NodeImpl;
+using DOM::RangeException;
-using namespace KJS;
+namespace KJS {
/* TODO:
* The catch all (...) clauses below shouldn't be necessary.
{
if ( m_evt )
{
- int id = m_evt->handle()->id();
+ int id = m_evt->id();
bool eventOk = ( // mouse events
id == DOM::EventImpl::CLICK_EVENT || id == DOM::EventImpl::MOUSEDOWN_EVENT ||
id == DOM::EventImpl::MOUSEUP_EVENT || id == DOM::EventImpl::KHTML_DBLCLICK_EVENT ||
return QString((QChar*) data(), size());
}
-DOM::Node KJS::toNode(const Value& val)
-{
- Object obj = Object::dynamicCast(val);
- if (obj.isNull() || !obj.inherits(&DOMNode::info))
- return DOM::Node();
-
- const DOMNode *dobj = static_cast<const DOMNode*>(obj.imp());
- return dobj->toNode();
-}
-
Value KJS::getStringOrNull(DOMString s)
{
if (s.isNull())
}
return res;
}
+
+void setDOMException(ExecState *exec, int DOMExceptionCode)
+{
+ if (DOMExceptionCode == 0 || exec->hadException())
+ return;
+
+ const char *type = "DOM";
+ int code = DOMExceptionCode;
+
+ if (code >= RangeException::_EXCEPTION_OFFSET && code <= RangeException::_EXCEPTION_MAX) {
+ type = "DOM Range";
+ code -= RangeException::_EXCEPTION_OFFSET;
+ } else if (code >= CSSException::_EXCEPTION_OFFSET && code <= CSSException::_EXCEPTION_MAX) {
+ type = "CSS";
+ code -= CSSException::_EXCEPTION_OFFSET;
+ }
+
+ char buffer[100]; // needs to fit 20 characters, plus an integer in ASCII, plus a null character
+ sprintf(buffer, "%s exception %d", type, code);
+
+ Object errorObject = Error::create(exec, GeneralError, buffer);
+ errorObject.put(exec, "code", Number(code));
+ exec->setException(errorObject);
+}
+
+}
#define _KJS_BINDING_H_
#include <kjs/interpreter.h>
-#include <dom/dom_node.h>
-#include <dom/dom_doc.h>
#include <qvariant.h>
#include <qptrdict.h>
-#include <kurl.h>
#include <kjs/lookup.h>
#include <kjs/protect.h>
class KHTMLPart;
+namespace DOM {
+ class DocumentImpl;
+ class EventImpl;
+}
+
namespace KJS {
/**
/**
* Set the event that is triggering the execution of a script, if any
*/
- void setCurrentEvent( DOM::Event *evt ) { m_evt = evt; }
+ void setCurrentEvent( DOM::EventImpl *evt ) { m_evt = evt; }
void setInlineCode( bool inlineCode ) { m_inlineCode = inlineCode; }
void setProcessingTimerCallback( bool timerCallback ) { m_timerCallback = timerCallback; }
/**
virtual void mark();
- DOM::Event *getCurrentEvent() const { return m_evt; }
+ DOM::EventImpl *getCurrentEvent() const { return m_evt; }
#if APPLE_CHANGES
virtual bool isGlobalObject(const Value &v);
static QPtrDict<DOMObject> &domObjects();
static QPtrDict<QPtrDict<DOMObject> > &domObjectsPerDocument();
- DOM::Event *m_evt;
+ DOM::EventImpl *m_evt;
bool m_inlineCode;
bool m_timerCallback;
};
+
/**
* Retrieve from cache, or create, a KJS object around a DOM object
*/
template<class DOMObj, class KJSDOMObj>
- inline Value cacheDOMObject(ExecState *exec, DOMObj domObj)
+ inline ValueImp *cacheDOMObject(ExecState *exec, DOMObj *domObj)
{
- DOMObject *ret;
- if (domObj.isNull())
- return Null();
- ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
- if ((ret = interp->getDOMObject(domObj.handle())))
- return Value(ret);
- else {
- ret = new KJSDOMObj(exec, domObj);
- interp->putDOMObject(domObj.handle(),ret);
- return Value(ret);
- }
+ if (!domObj)
+ return null();
+ ScriptInterpreter *interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
+ if (DOMObject *ret = interp->getDOMObject(domObj))
+ return ret;
+ DOMObject *ret = new KJSDOMObj(exec, domObj);
+ interp->putDOMObject(domObj, ret);
+ return ret;
}
- /**
- * Convert an object to a Node. Returns a null Node if not possible.
- */
- DOM::Node toNode(const Value&);
+ // Convert a DOM implementation exception code into a JavaScript exception in the execution state.
+ void setDOMException(ExecState *exec, int DOMExceptionCode);
+
+ // Helper class to call setDOMException on exit without adding lots of separate calls to that function.
+ class DOMExceptionTranslator {
+ public:
+ explicit DOMExceptionTranslator(ExecState *exec) : m_exec(exec), m_code(0) { }
+ ~DOMExceptionTranslator() { setDOMException(m_exec, m_code); }
+ operator int &() { return m_code; }
+ private:
+ ExecState *m_exec;
+ int m_code;
+ };
+
/**
* Get a String object, or Null() if s is null
*/
Value getStringOrNull(DOM::DOMString s);
/**
- * Convery a KJS value into a QVariant
+ * Convert a KJS value into a QVariant
+ * Deprecated: Use variant instead.
*/
QVariant ValueToVariant(ExecState* exec, const Value& val);
* that cached object. Note that the object constructor must take 1 argument, exec.
*/
template <class ClassCtor>
- inline Object cacheGlobalObject(ExecState *exec, const Identifier &propertyName)
+ inline ObjectImp *cacheGlobalObject(ExecState *exec, const Identifier &propertyName)
{
- ValueImp *obj = static_cast<ObjectImp*>(exec->lexicalInterpreter()->globalObject().imp())->getDirect(propertyName);
- if (obj)
- return Object::dynamicCast(Value(obj));
- else
- {
- Object newObject(new ClassCtor(exec));
- exec->lexicalInterpreter()->globalObject().put(exec, propertyName, newObject, Internal);
- return newObject;
+ ObjectImp *globalObject = static_cast<ObjectImp *>(exec->lexicalInterpreter()->globalObject().imp());
+ ValueImp *obj = globalObject->getDirect(propertyName);
+ if (obj) {
+ assert(obj->isObject());
+ return static_cast<ObjectImp *>(obj);
}
+ ObjectImp *newObject = new ClassCtor(exec);
+ globalObject->put(exec, propertyName, Value(newObject), Internal);
+ return newObject;
}
/**
* then the last line will use IMPLEMENT_PROTOTYPE_WITH_PARENT, with DOMNodeProto as last argument.
*/
#define DEFINE_PROTOTYPE(ClassName,ClassProto) \
- namespace KJS { \
class ClassProto : public ObjectImp { \
- friend Object cacheGlobalObject<ClassProto>(ExecState *exec, const Identifier &propertyName); \
+ friend ObjectImp *cacheGlobalObject<ClassProto>(ExecState *exec, const Identifier &propertyName); \
public: \
- static Object self(ExecState *exec) \
+ static ObjectImp *self(ExecState *exec) \
{ \
return cacheGlobalObject<ClassProto>( exec, "[[" ClassName ".prototype]]" ); \
} \
Value get(ExecState *exec, const Identifier &propertyName) const; \
bool hasProperty(ExecState *exec, const Identifier &propertyName) const; \
}; \
- const ClassInfo ClassProto::info = { ClassName, 0, &ClassProto##Table, 0 }; \
- };
+ const ClassInfo ClassProto::info = { ClassName, 0, &ClassProto##Table, 0 };
#define IMPLEMENT_PROTOTYPE(ClassProto,ClassFunc) \
- Value KJS::ClassProto::get(ExecState *exec, const Identifier &propertyName) const \
+ Value ClassProto::get(ExecState *exec, const Identifier &propertyName) const \
{ \
/*fprintf( stderr, "%sProto::get(%s) [in macro, no parent]\n", info.className, propertyName.ascii());*/ \
return lookupGetFunction<ClassFunc,ObjectImp>(exec, propertyName, &ClassProto##Table, this ); \
} \
- bool KJS::ClassProto::hasProperty(ExecState *exec, const Identifier &propertyName) const \
+ bool ClassProto::hasProperty(ExecState *exec, const Identifier &propertyName) const \
{ /*stupid but we need this to have a common macro for the declaration*/ \
return ObjectImp::hasProperty(exec, propertyName); \
}
#define IMPLEMENT_PROTOTYPE_WITH_PARENT(ClassProto,ClassFunc,ParentProto) \
- Value KJS::ClassProto::get(ExecState *exec, const Identifier &propertyName) const \
+ Value ClassProto::get(ExecState *exec, const Identifier &propertyName) const \
{ \
/*fprintf( stderr, "%sProto::get(%s) [in macro]\n", info.className, propertyName.ascii());*/ \
Value val = lookupGetFunction<ClassFunc,ObjectImp>(exec, propertyName, &ClassProto##Table, this ); \
if ( val.type() != UndefinedType ) return val; \
/* Not found -> forward request to "parent" prototype */ \
- return ParentProto::self(exec).get( exec, propertyName ); \
+ return ParentProto::self(exec)->get( exec, propertyName ); \
} \
- bool KJS::ClassProto::hasProperty(ExecState *exec, const Identifier &propertyName) const \
+ bool ClassProto::hasProperty(ExecState *exec, const Identifier &propertyName) const \
{ \
if (ObjectImp::hasProperty(exec, propertyName)) \
return true; \
- return ParentProto::self(exec).hasProperty(exec, propertyName); \
+ return ParentProto::self(exec)->hasProperty(exec, propertyName); \
}
#define IMPLEMENT_PROTOFUNC(ClassFunc) \
- namespace KJS { \
class ClassFunc : public DOMFunction { \
public: \
ClassFunc(ExecState *exec, int i, int len) \
virtual Value tryCall(ExecState *exec, Object &thisObj, const List &args); \
private: \
int id; \
- }; \
};
-}; // namespace
+} // namespace
#endif
*/
#include "kjs_css.h"
-#include "kjs_css.lut.h"
-
-#include <dom/html_head.h> // for HTMLStyleElement
-#include <css/css_base.h>
+#include "css/css_base.h"
+#include "css/css_ruleimpl.h"
+#include "css/css_stylesheetimpl.h"
+#include "css/css_valueimpl.h"
+#include "xml/dom_docimpl.h"
+#include "html/html_headimpl.h" // for HTMLStyleElement
#include "kjs_dom.h"
+#include "misc/htmltags.h"
-using namespace KJS;
#include <kdebug.h>
-static QString cssPropertyName(const Identifier &p, bool *hadPixelOrPosPrefix = 0)
+#include "kjs_css.lut.h"
+
+using DOM::CSSCharsetRuleImpl;
+using DOM::CSSFontFaceRuleImpl;
+using DOM::CSSImportRuleImpl;
+using DOM::CSSMediaRuleImpl;
+using DOM::CSSPageRuleImpl;
+using DOM::CSSPrimitiveValue;
+using DOM::CSSPrimitiveValueImpl;
+using DOM::CSSRule;
+using DOM::CSSRuleImpl;
+using DOM::CSSRuleListImpl;
+using DOM::CSSStyleDeclarationImpl;
+using DOM::CSSStyleRuleImpl;
+using DOM::CSSStyleSheetImpl;
+using DOM::CSSValue;
+using DOM::CSSValueImpl;
+using DOM::CSSValueListImpl;
+using DOM::CounterImpl;
+using DOM::DocumentImpl;
+using DOM::DOMString;
+using DOM::ElementImpl;
+using DOM::HTMLStyleElementImpl;
+using DOM::MediaListImpl;
+using DOM::RectImpl;
+using DOM::StyleSheetImpl;
+using DOM::StyleSheetListImpl;
+
+namespace KJS {
+
+static DOMString cssPropertyName(const Identifier &p, bool *hadPixelOrPosPrefix = 0)
{
QString prop = p.qstring();
return prop;
}
+static bool isCSSPropertyName(const Identifier &JSPropertyName)
+{
+ return CSSStyleDeclarationImpl::isPropertyName(cssPropertyName(JSPropertyName));
+}
+
/*
@begin DOMCSSStyleDeclarationProtoTable 7
getPropertyValue DOMCSSStyleDeclaration::GetPropertyValue DontDelete|Function 1
const ClassInfo DOMCSSStyleDeclaration::info = { "CSSStyleDeclaration", 0, &DOMCSSStyleDeclarationTable, 0 };
-DOMCSSStyleDeclaration::DOMCSSStyleDeclaration(ExecState *exec, DOM::CSSStyleDeclaration s)
- : styleDecl(s)
+DOMCSSStyleDeclaration::DOMCSSStyleDeclaration(ExecState *exec, CSSStyleDeclarationImpl *s)
+ : m_impl(s)
{
setPrototype(DOMCSSStyleDeclarationProto::self(exec));
}
DOMCSSStyleDeclaration::~DOMCSSStyleDeclaration()
{
- ScriptInterpreter::forgetDOMObject(styleDecl.handle());
+ ScriptInterpreter::forgetDOMObject(m_impl.get());
}
bool DOMCSSStyleDeclaration::hasProperty(ExecState *exec, const Identifier &p) const
{
if (p == "cssText")
return true;
-
- QString prop = cssPropertyName(p);
- if (DOM::getPropertyID(prop.ascii(), prop.length()))
- return true;
-
+ if (isCSSPropertyName(p))
+ return true;
return ObjectImp::hasProperty(exec, p);
}
kdDebug(6070) << "DOMCSSStyleDeclaration::tryGet " << propertyName.qstring() << endl;
#endif
const HashEntry* entry = Lookup::findEntry(&DOMCSSStyleDeclarationTable, propertyName);
+ CSSStyleDeclarationImpl &styleDecl = *m_impl;
if (entry)
switch (entry->value) {
case CssText:
bool ok;
long unsigned int u = propertyName.toULong(&ok);
if (ok)
- return getStringOrNull(DOM::CSSStyleDeclaration(styleDecl).item(u));
+ return getStringOrNull(styleDecl.item(u));
#ifdef KJS_VERBOSE
kdDebug(6070) << "DOMCSSStyleDeclaration: converting to css property name: " << cssPropertyName(propertyName) << endl;
#endif
- DOM::CSSStyleDeclaration styleDecl2 = styleDecl;
// Set up pixelOrPos boolean to handle the fact that
// pixelTop returns "CSS Top" as number value in unit pixels
// posTop returns "CSS top" as number value in unit pixels _if_ its a
// positioned element. if it is not a positioned element, return 0
// from MSIE documentation ### IMPLEMENT THAT (Dirk)
- bool pixelOrPos;
- DOM::DOMString p = cssPropertyName(propertyName, &pixelOrPos);
-
- DOM::CSSValue v = styleDecl2.getPropertyCSSValue(p);
- if (!v.isNull()) {
- if (pixelOrPos && v.cssValueType() == DOM::CSSValue::CSS_PRIMITIVE_VALUE)
- return Number(static_cast<DOM::CSSPrimitiveValue>(v).getFloatValue(DOM::CSSPrimitiveValue::CSS_PX));
-
- return getStringOrNull(v.cssText());
+ if (isCSSPropertyName(propertyName)) {
+ bool pixelOrPos;
+ DOMString prop = cssPropertyName(propertyName, &pixelOrPos);
+ CSSValueImpl *v = styleDecl.getPropertyCSSValue(prop);
+ if (v) {
+ if (pixelOrPos && v->cssValueType() == CSSValue::CSS_PRIMITIVE_VALUE)
+ return Number(static_cast<CSSPrimitiveValueImpl *>(v)->getFloatValue(CSSPrimitiveValue::CSS_PX));
+ return getStringOrNull(v->cssText());
+ }
+ return String("");
}
- // see if we know this css property, return empty then
- QCString prop = p.string().latin1();
- if (DOM::getPropertyID(prop.data(), prop.length()))
- return getStringOrNull(DOM::DOMString(""));
-
return DOMObject::tryGet(exec, propertyName);
}
#ifdef KJS_VERBOSE
kdDebug(6070) << "DOMCSSStyleDeclaration::tryPut " << propertyName.qstring() << endl;
#endif
+ DOMExceptionTranslator exception(exec);
+ CSSStyleDeclarationImpl &styleDecl = *m_impl;
if (propertyName == "cssText") {
- styleDecl.setCssText(value.toString(exec).string());
+ styleDecl.setCssText(value.toString(exec).string(), exception);
} else {
- bool pixelOrPos;
- QString prop = cssPropertyName(propertyName, &pixelOrPos);
- if (prop.isAllASCII() && DOM::getPropertyID(prop.ascii(), prop.length())) {
+ if (isCSSPropertyName(propertyName)) {
+ bool pixelOrPos;
+ DOMString prop = cssPropertyName(propertyName, &pixelOrPos);
QString propvalue = value.toString(exec).qstring();
if (pixelOrPos)
propvalue += "px";
#ifdef KJS_VERBOSE
kdDebug(6070) << "DOMCSSStyleDeclaration: prop=" << prop << " propvalue=" << propvalue << endl;
#endif
- styleDecl.removeProperty(prop);
- if(!propvalue.isEmpty())
- styleDecl.setProperty(prop,DOM::DOMString(propvalue),""); // ### is "" ok for priority?
+ styleDecl.removeProperty(prop, exception);
+ if (!exception && !propvalue.isEmpty())
+ styleDecl.setProperty(prop, DOMString(propvalue), "", exception); // ### is "" ok for priority?
} else {
DOMObject::tryPut(exec, propertyName, value, attr);
}
exec->setException(err);
return err;
}
- DOM::CSSStyleDeclaration styleDecl = static_cast<DOMCSSStyleDeclaration *>(thisObj.imp())->toStyleDecl();
+ DOMExceptionTranslator exception(exec);
+ CSSStyleDeclarationImpl &styleDecl = *static_cast<DOMCSSStyleDeclaration *>(thisObj.imp())->impl();
String str = args[0].toString(exec);
DOM::DOMString s = str.value().string();
case DOMCSSStyleDeclaration::GetPropertyCSSValue:
return getDOMCSSValue(exec,styleDecl.getPropertyCSSValue(s));
case DOMCSSStyleDeclaration::RemoveProperty:
- return getStringOrNull(styleDecl.removeProperty(s));
+ return getStringOrNull(styleDecl.removeProperty(s, exception));
case DOMCSSStyleDeclaration::GetPropertyPriority:
return getStringOrNull(styleDecl.getPropertyPriority(s));
case DOMCSSStyleDeclaration::SetProperty:
- styleDecl.setProperty(args[0].toString(exec).string(),
- args[1].toString(exec).string(),
- args[2].toString(exec).string());
+ styleDecl.setProperty(s, args[1].toString(exec).string(), args[2].toString(exec).string(), exception);
return Undefined();
case DOMCSSStyleDeclaration::Item:
return getStringOrNull(styleDecl.item(args[0].toInt32(exec)));
}
}
-Value KJS::getDOMCSSStyleDeclaration(ExecState *exec, DOM::CSSStyleDeclaration s)
+ValueImp *getDOMCSSStyleDeclaration(ExecState *exec, CSSStyleDeclarationImpl *s)
{
- return Value(cacheDOMObject<DOM::CSSStyleDeclaration, KJS::DOMCSSStyleDeclaration>(exec, s));
+ return cacheDOMObject<CSSStyleDeclarationImpl, DOMCSSStyleDeclaration>(exec, s);
}
// -------------------------------------------------------------------------
DOMStyleSheet::~DOMStyleSheet()
{
- ScriptInterpreter::forgetDOMObject(styleSheet.handle());
+ ScriptInterpreter::forgetDOMObject(m_impl.get());
}
Value DOMStyleSheet::tryGet(ExecState *exec, const Identifier &propertyName) const
Value DOMStyleSheet::getValueProperty(ExecState *exec, int token) const
{
+ StyleSheetImpl &styleSheet = *m_impl;
switch (token) {
case Type:
return getStringOrNull(styleSheet.type());
void DOMStyleSheet::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr)
{
if (propertyName == "disabled") {
- styleSheet.setDisabled(value.toBoolean(exec));
+ m_impl->setDisabled(value.toBoolean(exec));
}
else
DOMObject::tryPut(exec, propertyName, value, attr);
}
-Value KJS::getDOMStyleSheet(ExecState *exec, DOM::StyleSheet ss)
+ValueImp *getDOMStyleSheet(ExecState *exec, StyleSheetImpl *ss)
{
DOMObject *ret;
- if (ss.isNull())
+ if (!ss)
return Null();
- ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
- if ((ret = interp->getDOMObject(ss.handle())))
- return Value(ret);
+ ScriptInterpreter *interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
+ if ((ret = interp->getDOMObject(ss)))
+ return ret;
else {
- if (ss.isCSSStyleSheet()) {
- DOM::CSSStyleSheet cs;
- cs = ss;
- ret = new DOMCSSStyleSheet(exec,cs);
- }
+ if (ss->isCSSStyleSheet())
+ ret = new DOMCSSStyleSheet(exec, static_cast<CSSStyleSheetImpl *>(ss));
else
ret = new DOMStyleSheet(exec,ss);
- interp->putDOMObject(ss.handle(),ret);
- return Value(ret);
+ interp->putDOMObject(ss, ret);
+ return ret;
}
}
DOMStyleSheetList::~DOMStyleSheetList()
{
- ScriptInterpreter::forgetDOMObject(styleSheetList.handle());
+ ScriptInterpreter::forgetDOMObject(m_impl.get());
}
Value DOMStyleSheetList::tryGet(ExecState *exec, const Identifier &p) const
#ifdef KJS_VERBOSE
kdDebug(6070) << "DOMStyleSheetList::tryGet " << p.qstring() << endl;
#endif
+ StyleSheetListImpl &styleSheetList = *m_impl;
if (p == lengthPropertyName)
return Number(styleSheetList.length());
else if (p == "item")
bool ok;
long unsigned int u = p.toULong(&ok);
if (ok)
- return getDOMStyleSheet(exec, DOM::StyleSheetList(styleSheetList).item(u));
+ return getDOMStyleSheet(exec, styleSheetList.item(u));
// IE also supports retrieving a stylesheet by name, using the name/id of the <style> tag
// (this is consistent with all the other collections)
// ### Bad implementation because returns a single element (are IDs always unique?)
// and doesn't look for name attribute (see implementation above).
// But unicity of stylesheet ids is good practice anyway ;)
- DOM::DOMString pstr = p.string();
- DOM::HTMLStyleElement styleElem = m_doc.getElementById( pstr );
- if (!styleElem.isNull())
- return getDOMStyleSheet(exec, styleElem.sheet());
+ ElementImpl *element = m_doc->getElementById(p.string());
+ if (element && element->id() == ID_STYLE)
+ return getDOMStyleSheet(exec, static_cast<HTMLStyleElementImpl *>(element)->sheet());
return DOMObject::tryGet(exec, p);
}
-Value KJS::getDOMStyleSheetList(ExecState *exec, DOM::StyleSheetList ssl, DOM::Document doc)
+ValueImp *getDOMStyleSheetList(ExecState *exec, StyleSheetListImpl *ssl, DocumentImpl *doc)
{
// Can't use the cacheDOMObject macro because of the doc argument
DOMObject *ret;
- if (ssl.isNull())
+ if (!ssl)
return Null();
ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
- if ((ret = interp->getDOMObject(ssl.handle())))
- return Value(ret);
+ if ((ret = interp->getDOMObject(ssl)))
+ return ret;
else {
ret = new DOMStyleSheetList(exec, ssl, doc);
- interp->putDOMObject(ssl.handle(),ret);
- return Value(ret);
+ interp->putDOMObject(ssl, ret);
+ return ret;
}
}
exec->setException(err);
return err;
}
- DOM::StyleSheetList styleSheetList = static_cast<DOMStyleSheetList *>(thisObj.imp())->toStyleSheetList();
+ StyleSheetListImpl &styleSheetList = *static_cast<DOMStyleSheetList *>(thisObj.imp())->impl();
if (id == DOMStyleSheetList::Item)
return getDOMStyleSheet(exec, styleSheetList.item(args[0].toInt32(exec)));
return Undefined();
IMPLEMENT_PROTOFUNC(DOMMediaListProtoFunc)
IMPLEMENT_PROTOTYPE(DOMMediaListProto, DOMMediaListProtoFunc)
-DOMMediaList::DOMMediaList(ExecState *exec, DOM::MediaList ml)
- : mediaList(ml)
+DOMMediaList::DOMMediaList(ExecState *exec, MediaListImpl *ml)
+ : m_impl(ml)
{
setPrototype(DOMMediaListProto::self(exec));
}
DOMMediaList::~DOMMediaList()
{
- ScriptInterpreter::forgetDOMObject(mediaList.handle());
+ ScriptInterpreter::forgetDOMObject(m_impl.get());
}
Value DOMMediaList::tryGet(ExecState *exec, const Identifier &p) const
{
+ MediaListImpl &mediaList = *m_impl;
if (p == "mediaText")
return getStringOrNull(mediaList.mediaText());
else if (p == lengthPropertyName)
void DOMMediaList::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr)
{
+ MediaListImpl &mediaList = *m_impl;
if (propertyName == "mediaText")
mediaList.setMediaText(value.toString(exec).string());
else
DOMObject::tryPut(exec, propertyName, value, attr);
}
-Value KJS::getDOMMediaList(ExecState *exec, DOM::MediaList ml)
+ValueImp *getDOMMediaList(ExecState *exec, MediaListImpl *ml)
{
- return cacheDOMObject<DOM::MediaList, KJS::DOMMediaList>(exec, ml);
+ return cacheDOMObject<MediaListImpl, DOMMediaList>(exec, ml);
}
Value KJS::DOMMediaListProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
exec->setException(err);
return err;
}
- DOM::MediaList mediaList = static_cast<DOMMediaList *>(thisObj.imp())->toMediaList();
+ MediaListImpl &mediaList = *static_cast<DOMMediaList *>(thisObj.imp())->impl();
switch (id) {
case DOMMediaList::Item:
return getStringOrNull(mediaList.item(args[0].toInt32(exec)));
IMPLEMENT_PROTOFUNC(DOMCSSStyleSheetProtoFunc)
IMPLEMENT_PROTOTYPE(DOMCSSStyleSheetProto,DOMCSSStyleSheetProtoFunc) // warning, use _WITH_PARENT if DOMStyleSheet gets a proto
-DOMCSSStyleSheet::DOMCSSStyleSheet(ExecState *exec, DOM::CSSStyleSheet ss)
+DOMCSSStyleSheet::DOMCSSStyleSheet(ExecState *exec, CSSStyleSheetImpl *ss)
: DOMStyleSheet(ss)
{
setPrototype(DOMCSSStyleSheetProto::self(exec));
Value DOMCSSStyleSheet::tryGet(ExecState *exec, const Identifier &p) const
{
- DOM::CSSStyleSheet cssStyleSheet = static_cast<DOM::CSSStyleSheet>(styleSheet);
+ CSSStyleSheetImpl &cssStyleSheet = *static_cast<CSSStyleSheetImpl *>(impl());
if (p == "ownerRule")
return getDOMCSSRule(exec,cssStyleSheet.ownerRule());
else if (p == "cssRules" || p == "rules" /* MSIE extension */)
exec->setException(err);
return err;
}
- DOM::CSSStyleSheet styleSheet = static_cast<DOMCSSStyleSheet *>(thisObj.imp())->toCSSStyleSheet();
+ DOMExceptionTranslator exception(exec);
+ CSSStyleSheetImpl &styleSheet = *static_cast<CSSStyleSheetImpl *>(static_cast<DOMCSSStyleSheet *>(thisObj.imp())->impl());
Value result;
switch (id) {
case DOMCSSStyleSheet::InsertRule:
- return Number(styleSheet.insertRule(args[0].toString(exec).string(),(long unsigned int)args[1].toInt32(exec)));
+ return Number(styleSheet.insertRule(args[0].toString(exec).string(), args[1].toInt32(exec), exception));
break;
case DOMCSSStyleSheet::DeleteRule:
- styleSheet.deleteRule(args[0].toInt32(exec));
+ styleSheet.deleteRule(args[0].toInt32(exec), exception);
return Undefined();
case DOMCSSStyleSheet::AddRule: {
long index = args.size() >= 3 ? args[2].toInt32(exec) : -1;
- styleSheet.addRule(args[0].toString(exec).string(), args[1].toString(exec).string(), index);
+ styleSheet.addRule(args[0].toString(exec).string(), args[1].toString(exec).string(), index, exception);
// As per Microsoft documentation, always return -1.
return Number(-1);
}
DOMCSSRuleList::~DOMCSSRuleList()
{
- ScriptInterpreter::forgetDOMObject(cssRuleList.handle());
+ ScriptInterpreter::forgetDOMObject(m_impl.get());
}
Value DOMCSSRuleList::tryGet(ExecState *exec, const Identifier &p) const
{
- Value result;
+ CSSRuleListImpl &cssRuleList = *m_impl;
if (p == lengthPropertyName)
return Number(cssRuleList.length());
else if (p == "item")
- return lookupOrCreateFunction<DOMCSSRuleListFunc>(exec,p,this,DOMCSSRuleList::Item,1,DontDelete|Function);
+ return lookupOrCreateFunction<DOMCSSRuleListFunc>(exec, p, this, DOMCSSRuleList::Item, 1, DontDelete|Function);
bool ok;
long unsigned int u = p.toULong(&ok);
if (ok)
- return getDOMCSSRule(exec,DOM::CSSRuleList(cssRuleList).item(u));
+ return getDOMCSSRule(exec, cssRuleList.item(u));
- return DOMObject::tryGet(exec,p);
+ return DOMObject::tryGet(exec, p);
}
Value DOMCSSRuleListFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
exec->setException(err);
return err;
}
- DOM::CSSRuleList cssRuleList = static_cast<DOMCSSRuleList *>(thisObj.imp())->toCSSRuleList();
+ CSSRuleListImpl &cssRuleList = *static_cast<DOMCSSRuleList *>(thisObj.imp())->impl();
switch (id) {
case DOMCSSRuleList::Item:
return getDOMCSSRule(exec,cssRuleList.item(args[0].toInt32(exec)));
}
}
-Value KJS::getDOMCSSRuleList(ExecState *exec, DOM::CSSRuleList rl)
+ValueImp *getDOMCSSRuleList(ExecState *exec, CSSRuleListImpl *rl)
{
- return cacheDOMObject<DOM::CSSRuleList, KJS::DOMCSSRuleList>(exec, rl);
+ return cacheDOMObject<CSSRuleListImpl, DOMCSSRuleList>(exec, rl);
}
// -------------------------------------------------------------------------
DOMCSSRule::~DOMCSSRule()
{
- ScriptInterpreter::forgetDOMObject(cssRule.handle());
+ ScriptInterpreter::forgetDOMObject(m_impl.get());
}
const ClassInfo DOMCSSRule::info = { "CSSRule", 0, &DOMCSSRuleTable, 0 };
const ClassInfo* DOMCSSRule::classInfo() const
{
+ CSSRuleImpl &cssRule = *m_impl;
switch (cssRule.type()) {
case DOM::CSSRule::STYLE_RULE:
return &style_info;
#ifdef KJS_VERBOSE
kdDebug(6070) << "DOMCSSRule::tryGet " << propertyName.qstring() << endl;
#endif
- const HashTable* table = classInfo()->propHashTable; // get the right hashtable
- const HashEntry* entry = Lookup::findEntry(table, propertyName);
+ const HashEntry *entry = Lookup::findEntry(classInfo()->propHashTable, propertyName);
if (entry) {
if (entry->attr & Function)
return lookupOrCreateFunction<DOMCSSRuleFunc>(exec, propertyName, this, entry->value, entry->params, entry->attr);
Value DOMCSSRule::getValueProperty(ExecState *exec, int token) const
{
+ CSSRuleImpl &cssRule = *m_impl;
switch (token) {
case Type:
return Number(cssRule.type());
// for DOM::CSSRule::STYLE_RULE:
case Style_SelectorText:
- return getStringOrNull(static_cast<DOM::CSSStyleRule>(cssRule).selectorText());
+ return getStringOrNull(static_cast<CSSStyleRuleImpl *>(m_impl.get())->selectorText());
case Style_Style:
- return getDOMCSSStyleDeclaration(exec,static_cast<DOM::CSSStyleRule>(cssRule).style());
+ return getDOMCSSStyleDeclaration(exec, static_cast<CSSStyleRuleImpl *>(m_impl.get())->style());
// for DOM::CSSRule::MEDIA_RULE:
case Media_Media:
- return getDOMMediaList(exec,static_cast<DOM::CSSMediaRule>(cssRule).media());
+ return getDOMMediaList(exec, static_cast<CSSMediaRuleImpl *>(m_impl.get())->media());
case Media_CssRules:
- return getDOMCSSRuleList(exec,static_cast<DOM::CSSMediaRule>(cssRule).cssRules());
+ return getDOMCSSRuleList(exec, static_cast<CSSMediaRuleImpl *>(m_impl.get())->cssRules());
// for DOM::CSSRule::FONT_FACE_RULE:
case FontFace_Style:
- return getDOMCSSStyleDeclaration(exec,static_cast<DOM::CSSFontFaceRule>(cssRule).style());
+ return getDOMCSSStyleDeclaration(exec, static_cast<CSSFontFaceRuleImpl *>(m_impl.get())->style());
// for DOM::CSSRule::PAGE_RULE:
case Page_SelectorText:
- return getStringOrNull(static_cast<DOM::CSSPageRule>(cssRule).selectorText());
+ return getStringOrNull(static_cast<CSSPageRuleImpl *>(m_impl.get())->selectorText());
case Page_Style:
- return getDOMCSSStyleDeclaration(exec,static_cast<DOM::CSSPageRule>(cssRule).style());
+ return getDOMCSSStyleDeclaration(exec, static_cast<CSSPageRuleImpl *>(m_impl.get())->style());
// for DOM::CSSRule::IMPORT_RULE:
case Import_Href:
- return getStringOrNull(static_cast<DOM::CSSImportRule>(cssRule).href());
+ return getStringOrNull(static_cast<CSSImportRuleImpl *>(m_impl.get())->href());
case Import_Media:
- return getDOMMediaList(exec,static_cast<DOM::CSSImportRule>(cssRule).media());
+ return getDOMMediaList(exec, static_cast<CSSImportRuleImpl *>(m_impl.get())->media());
case Import_StyleSheet:
- return getDOMStyleSheet(exec,static_cast<DOM::CSSImportRule>(cssRule).styleSheet());
+ return getDOMStyleSheet(exec, static_cast<CSSImportRuleImpl *>(m_impl.get())->styleSheet());
// for DOM::CSSRule::CHARSET_RULE:
case Charset_Encoding:
- return getStringOrNull(static_cast<DOM::CSSCharsetRule>(cssRule).encoding());
+ return getStringOrNull(static_cast<CSSCharsetRuleImpl *>(m_impl.get())->encoding());
default:
kdWarning() << "DOMCSSRule::getValueProperty unhandled token " << token << endl;
switch (token) {
// for DOM::CSSRule::STYLE_RULE:
case Style_SelectorText:
- static_cast<DOM::CSSStyleRule>(cssRule).setSelectorText(value.toString(exec).string());
+ static_cast<CSSStyleRuleImpl *>(m_impl.get())->setSelectorText(value.toString(exec).string());
return;
// for DOM::CSSRule::PAGE_RULE:
case Page_SelectorText:
- static_cast<DOM::CSSPageRule>(cssRule).setSelectorText(value.toString(exec).string());
+ static_cast<CSSPageRuleImpl *>(m_impl.get())->setSelectorText(value.toString(exec).string());
return;
// for DOM::CSSRule::CHARSET_RULE:
case Charset_Encoding:
- static_cast<DOM::CSSCharsetRule>(cssRule).setEncoding(value.toString(exec).string());
+ static_cast<CSSCharsetRuleImpl *>(m_impl.get())->setEncoding(value.toString(exec).string());
return;
default:
exec->setException(err);
return err;
}
- DOM::CSSRule cssRule = static_cast<DOMCSSRule *>(thisObj.imp())->toCSSRule();
+ CSSRuleImpl &cssRule = *static_cast<DOMCSSRule *>(thisObj.imp())->impl();
if (cssRule.type() == DOM::CSSRule::MEDIA_RULE) {
- DOM::CSSMediaRule rule = static_cast<DOM::CSSMediaRule>(cssRule);
+ CSSMediaRuleImpl &rule = static_cast<CSSMediaRuleImpl &>(cssRule);
if (id == DOMCSSRule::Media_InsertRule)
return Number(rule.insertRule(args[0].toString(exec).string(),args[1].toInt32(exec)));
else if (id == DOMCSSRule::Media_DeleteRule)
return Undefined();
}
-Value KJS::getDOMCSSRule(ExecState *exec, DOM::CSSRule r)
+ValueImp *getDOMCSSRule(ExecState *exec, CSSRuleImpl *r)
{
- return cacheDOMObject<DOM::CSSRule, KJS::DOMCSSRule>(exec, r);
-}
-
-// -------------------------------------------------------------------------
-
-
-DOM::CSSRule KJS::toCSSRule(const Value& val)
-{
- Object obj = Object::dynamicCast(val);
- if (obj.isNull() || !obj.inherits(&DOMCSSRule::info))
- return DOM::CSSRule();
-
- const DOMCSSRule *dobj = static_cast<const DOMCSSRule*>(obj.imp());
- return dobj->toCSSRule();
+ return cacheDOMObject<CSSRuleImpl, DOMCSSRule>(exec, r);
}
// -------------------------------------------------------------------------
*/
DOMCSSValue::~DOMCSSValue()
{
- ScriptInterpreter::forgetDOMObject(cssValue.handle());
+ ScriptInterpreter::forgetDOMObject(m_impl.get());
}
Value DOMCSSValue::tryGet(ExecState *exec, const Identifier &p) const
{
+ CSSValueImpl &cssValue = *m_impl;
if (p == "cssText")
return getStringOrNull(cssValue.cssText());
else if (p == "cssValueType");
void DOMCSSValue::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr)
{
+ CSSValueImpl &cssValue = *m_impl;
if (propertyName == "cssText")
cssValue.setCssText(value.toString(exec).string());
else
DOMObject::tryPut(exec, propertyName, value, attr);
}
-Value KJS::getDOMCSSValue(ExecState *exec, DOM::CSSValue v)
+ValueImp *getDOMCSSValue(ExecState *exec, CSSValueImpl *v)
{
DOMObject *ret;
- if (v.isNull())
+ if (!v)
return Null();
ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
- if ((ret = interp->getDOMObject(v.handle())))
+ if ((ret = interp->getDOMObject(v)))
return Value(ret);
else {
- if (v.isCSSValueList())
- ret = new DOMCSSValueList(exec,v);
- else if (v.isCSSPrimitiveValue())
- ret = new DOMCSSPrimitiveValue(exec,v);
+ if (v->isValueList())
+ ret = new DOMCSSValueList(exec, static_cast<CSSValueListImpl *>(v));
+ else if (v->isPrimitiveValue())
+ ret = new DOMCSSPrimitiveValue(exec, static_cast<CSSPrimitiveValueImpl *>(v));
else
ret = new DOMCSSValue(exec,v);
- interp->putDOMObject(v.handle(),ret);
- return Value(ret);
+ interp->putDOMObject(v, ret);
+ return ret;
}
}
IMPLEMENT_PROTOFUNC(DOMCSSPrimitiveValueProtoFunc)
IMPLEMENT_PROTOTYPE(DOMCSSPrimitiveValueProto,DOMCSSPrimitiveValueProtoFunc)
-DOMCSSPrimitiveValue::DOMCSSPrimitiveValue(ExecState *exec, DOM::CSSPrimitiveValue v)
+DOMCSSPrimitiveValue::DOMCSSPrimitiveValue(ExecState *exec, CSSPrimitiveValueImpl *v)
: DOMCSSValue(v)
{
setPrototype(DOMCSSPrimitiveValueProto::self(exec));
Value DOMCSSPrimitiveValue::tryGet(ExecState *exec, const Identifier &p) const
{
- if (p=="primitiveType")
- return Number(static_cast<DOM::CSSPrimitiveValue>(cssValue).primitiveType());
+ if (p == "primitiveType")
+ return Number(static_cast<CSSPrimitiveValueImpl *>(impl())->primitiveType());
return DOMObject::tryGet(exec,p);
}
exec->setException(err);
return err;
}
- DOM::CSSPrimitiveValue val = static_cast<DOMCSSPrimitiveValue *>(thisObj.imp())->toCSSPrimitiveValue();
+ DOMExceptionTranslator exception(exec);
+ CSSPrimitiveValueImpl &val = *static_cast<CSSPrimitiveValueImpl *>(static_cast<DOMCSSPrimitiveValue *>(thisObj.imp())->impl());
switch (id) {
case DOMCSSPrimitiveValue::SetFloatValue:
- val.setFloatValue(args[0].toInt32(exec),args[1].toNumber(exec));
+ val.setFloatValue(args[0].toInt32(exec), args[1].toNumber(exec), exception);
return Undefined();
case DOMCSSPrimitiveValue::GetFloatValue:
return Number(val.getFloatValue(args[0].toInt32(exec)));
case DOMCSSPrimitiveValue::SetStringValue:
- val.setStringValue(args[0].toInt32(exec),args[1].toString(exec).string());
+ val.setStringValue(args[0].toInt32(exec), args[1].toString(exec).string(), exception);
return Undefined();
case DOMCSSPrimitiveValue::GetStringValue:
return getStringOrNull(val.getStringValue());
*/
IMPLEMENT_PROTOFUNC(DOMCSSValueListFunc) // not really a proto, but doesn't matter
-DOMCSSValueList::DOMCSSValueList(ExecState *exec, DOM::CSSValueList v)
+DOMCSSValueList::DOMCSSValueList(ExecState *exec, CSSValueListImpl *v)
: DOMCSSValue(exec, v)
{
}
Value DOMCSSValueList::tryGet(ExecState *exec, const Identifier &p) const
{
- Value result;
- DOM::CSSValueList valueList = static_cast<DOM::CSSValueList>(cssValue);
+ CSSValueListImpl &valueList = *static_cast<CSSValueListImpl *>(impl());
if (p == lengthPropertyName)
return Number(valueList.length());
exec->setException(err);
return err;
}
- DOM::CSSValueList valueList = static_cast<DOMCSSValueList *>(thisObj.imp())->toValueList();
+ CSSValueListImpl &valueList = *static_cast<CSSValueListImpl *>(static_cast<DOMCSSValueList *>(thisObj.imp())->impl());
switch (id) {
case DOMCSSValueList::Item:
return getDOMCSSValue(exec,valueList.item(args[0].toInt32(exec)));
Value DOMRGBColor::getValueProperty(ExecState *exec, int token) const
{
+ int color = m_color;
switch (token) {
case Red:
- return getDOMCSSValue(exec, rgbColor.red());
+ color >>= 8;
+ // fall through
case Green:
- return getDOMCSSValue(exec, rgbColor.green());
+ color >>= 8;
+ // fall through
case Blue:
- return getDOMCSSValue(exec, rgbColor.blue());
+ return new DOMCSSPrimitiveValue(exec, new CSSPrimitiveValueImpl(color & 0xFF, CSSPrimitiveValue::CSS_NUMBER));
default:
return Value();
}
}
-Value KJS::getDOMRGBColor(ExecState *, DOM::RGBColor c)
+ValueImp *getDOMRGBColor(ExecState *, unsigned c)
{
// ### implement equals for RGBColor since they're not refcounted objects
- return Value(new DOMRGBColor(c));
+ return new DOMRGBColor(c);
}
// -------------------------------------------------------------------------
*/
DOMRect::~DOMRect()
{
- ScriptInterpreter::forgetDOMObject(rect.handle());
+ ScriptInterpreter::forgetDOMObject(m_rect.get());
}
Value DOMRect::tryGet(ExecState *exec, const Identifier &p) const
Value DOMRect::getValueProperty(ExecState *exec, int token) const
{
+ RectImpl &rect = *m_rect;
switch (token) {
case Top:
return getDOMCSSValue(exec, rect.top());
}
}
-Value KJS::getDOMRect(ExecState *exec, DOM::Rect r)
+ValueImp *getDOMRect(ExecState *exec, RectImpl *r)
{
- return cacheDOMObject<DOM::Rect, KJS::DOMRect>(exec, r);
+ return cacheDOMObject<RectImpl, DOMRect>(exec, r);
}
// -------------------------------------------------------------------------
separator DOMCounter::separator DontDelete|ReadOnly
@end
*/
+
DOMCounter::~DOMCounter()
{
- ScriptInterpreter::forgetDOMObject(counter.handle());
+ ScriptInterpreter::forgetDOMObject(m_counter.get());
}
Value DOMCounter::tryGet(ExecState *exec, const Identifier &p) const
Value DOMCounter::getValueProperty(ExecState *, int token) const
{
+ CounterImpl &counter = *m_counter;
switch (token) {
case identifier:
return getStringOrNull(counter.identifier());
}
}
-Value KJS::getDOMCounter(ExecState *exec, DOM::Counter c)
+ValueImp *getDOMCounter(ExecState *exec, CounterImpl *c)
{
- return cacheDOMObject<DOM::Counter, KJS::DOMCounter>(exec, c);
+ return cacheDOMObject<CounterImpl, DOMCounter>(exec, c);
+}
+
}
#ifndef _KJS_CSS_H_
#define _KJS_CSS_H_
-#include <dom/dom_node.h>
-#include <dom/dom_doc.h>
-#include <kjs/object.h>
-#include <dom/css_value.h>
-#include <dom/css_stylesheet.h>
-#include <dom/css_rule.h>
#include "kjs_binding.h"
+#include <qcolor.h>
+#include "misc/shared.h"
+
+namespace DOM {
+ class CounterImpl;
+ class CSSPrimitiveValueImpl;
+ class CSSRuleImpl;
+ class CSSRuleListImpl;
+ class CSSStyleDeclarationImpl;
+ class CSSStyleSheetImpl;
+ class CSSValueImpl;
+ class CSSValueListImpl;
+ class MediaListImpl;
+ class RectImpl;
+ class StyleSheetImpl;
+ class StyleSheetListImpl;
+}
+
namespace KJS {
class DOMCSSStyleDeclaration : public DOMObject {
public:
- DOMCSSStyleDeclaration(ExecState *exec, DOM::CSSStyleDeclaration s);
+ DOMCSSStyleDeclaration(ExecState *exec, DOM::CSSStyleDeclarationImpl *s);
virtual ~DOMCSSStyleDeclaration();
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
enum { CssText, Length, ParentRule,
GetPropertyValue, GetPropertyCSSValue, RemoveProperty, GetPropertyPriority,
SetProperty, Item };
- DOM::CSSStyleDeclaration toStyleDecl() const { return styleDecl; }
- protected:
- DOM::CSSStyleDeclaration styleDecl;
+ DOM::CSSStyleDeclarationImpl *impl() const { return m_impl.get(); }
+ private:
+ khtml::SharedPtr<DOM::CSSStyleDeclarationImpl> m_impl;
};
- Value getDOMCSSStyleDeclaration(ExecState *exec, DOM::CSSStyleDeclaration n);
+ ValueImp *getDOMCSSStyleDeclaration(ExecState *exec, DOM::CSSStyleDeclarationImpl *d);
class DOMStyleSheet : public DOMObject {
public:
- // Build a DOMStyleSheet
- DOMStyleSheet(ExecState *, DOM::StyleSheet ss) : styleSheet(ss) { }
- // Constructor for inherited classes
- DOMStyleSheet(DOM::StyleSheet ss) : styleSheet(ss) { }
+ DOMStyleSheet(ExecState *, DOM::StyleSheetImpl *ss) : m_impl(ss) { }
virtual ~DOMStyleSheet();
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Type, Disabled, OwnerNode, ParentStyleSheet, Href, Title, Media };
+ DOM::StyleSheetImpl *impl() const { return m_impl.get(); }
protected:
- DOM::StyleSheet styleSheet;
+ // Constructor for derived classes; doesn't set up a prototype.
+ DOMStyleSheet(DOM::StyleSheetImpl *ss) : m_impl(ss) { }
+ private:
+ khtml::SharedPtr<DOM::StyleSheetImpl> m_impl;
};
- Value getDOMStyleSheet(ExecState *exec, DOM::StyleSheet ss);
+ ValueImp *getDOMStyleSheet(ExecState *exec, DOM::StyleSheetImpl *ss);
class DOMStyleSheetList : public DOMObject {
public:
- DOMStyleSheetList(ExecState *, DOM::StyleSheetList ssl, DOM::Document doc)
- : styleSheetList(ssl), m_doc(doc) { }
+ DOMStyleSheetList(ExecState *, DOM::StyleSheetListImpl *ssl, DOM::DocumentImpl *doc)
+ : m_impl(ssl), m_doc(doc) { }
virtual ~DOMStyleSheetList();
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
virtual bool toBoolean(ExecState* ) const { return true; }
static const ClassInfo info;
- DOM::StyleSheetList toStyleSheetList() const { return styleSheetList; }
+ DOM::StyleSheetListImpl *impl() const { return m_impl.get(); }
enum { Item, Length };
private:
- DOM::StyleSheetList styleSheetList;
- DOM::Document m_doc;
+ khtml::SharedPtr<DOM::StyleSheetListImpl> m_impl;
+ khtml::SharedPtr<DOM::DocumentImpl> m_doc;
};
// The document is only used for get-stylesheet-by-name (make optional if necessary)
- Value getDOMStyleSheetList(ExecState *exec, DOM::StyleSheetList ss, DOM::Document doc);
+ ValueImp *getDOMStyleSheetList(ExecState *exec, DOM::StyleSheetListImpl *ss, DOM::DocumentImpl *doc);
class DOMMediaList : public DOMObject {
public:
- DOMMediaList(ExecState *, DOM::MediaList ml);
+ DOMMediaList(ExecState *, DOM::MediaListImpl *ml);
virtual ~DOMMediaList();
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
static const ClassInfo info;
enum { MediaText, Length,
Item, DeleteMedium, AppendMedium };
- DOM::MediaList toMediaList() const { return mediaList; }
+ DOM::MediaListImpl *impl() const { return m_impl.get(); }
private:
- DOM::MediaList mediaList;
+ khtml::SharedPtr<DOM::MediaListImpl> m_impl;
};
- Value getDOMMediaList(ExecState *exec, DOM::MediaList ss);
+ ValueImp *getDOMMediaList(ExecState *exec, DOM::MediaListImpl *ml);
class DOMCSSStyleSheet : public DOMStyleSheet {
public:
- DOMCSSStyleSheet(ExecState *exec, DOM::CSSStyleSheet ss);
+ DOMCSSStyleSheet(ExecState *exec, DOM::CSSStyleSheetImpl *ss);
virtual ~DOMCSSStyleSheet();
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
// no put - all read-only
static const ClassInfo info;
enum { OwnerRule, CssRules, Rules,
InsertRule, DeleteRule, AddRule };
- DOM::CSSStyleSheet toCSSStyleSheet() const { return static_cast<DOM::CSSStyleSheet>(styleSheet); }
};
class DOMCSSRuleList : public DOMObject {
public:
- DOMCSSRuleList(ExecState *, DOM::CSSRuleList rl) : cssRuleList(rl) { }
+ DOMCSSRuleList(ExecState *, DOM::CSSRuleListImpl *rl) : m_impl(rl) { }
virtual ~DOMCSSRuleList();
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Item, Length };
- DOM::CSSRuleList toCSSRuleList() const { return cssRuleList; }
- protected:
- DOM::CSSRuleList cssRuleList;
+ DOM::CSSRuleListImpl *impl() const { return m_impl.get(); }
+ private:
+ khtml::SharedPtr<DOM::CSSRuleListImpl> m_impl;
};
- Value getDOMCSSRuleList(ExecState *exec, DOM::CSSRuleList rl);
+ ValueImp *getDOMCSSRuleList(ExecState *exec, DOM::CSSRuleListImpl *rl);
class DOMCSSRule : public DOMObject {
public:
- DOMCSSRule(ExecState *, DOM::CSSRule r) : cssRule(r) { }
+ DOMCSSRule(ExecState *, DOM::CSSRuleImpl *r) : m_impl(r) { }
virtual ~DOMCSSRule();
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
Media_Media, Media_InsertRule, Media_DeleteRule, Media_CssRules,
FontFace_Style, Page_SelectorText, Page_Style,
Import_Href, Import_Media, Import_StyleSheet, Charset_Encoding };
- DOM::CSSRule toCSSRule() const { return cssRule; }
- protected:
- DOM::CSSRule cssRule;
+ DOM::CSSRuleImpl *impl() const { return m_impl.get(); }
+ private:
+ khtml::SharedPtr<DOM::CSSRuleImpl> m_impl;
};
- Value getDOMCSSRule(ExecState *exec, DOM::CSSRule r);
-
- /**
- * Convert an object to a CSSRule. Returns a null CSSRule if not possible.
- */
- DOM::CSSRule toCSSRule(const Value&);
+ ValueImp *getDOMCSSRule(ExecState *exec, DOM::CSSRuleImpl *r);
// Constructor for CSSRule - currently only used for some global values
class CSSRuleConstructor : public DOMObject {
class DOMCSSValue : public DOMObject {
public:
- DOMCSSValue(ExecState *, DOM::CSSValue v) : cssValue(v) { }
- DOMCSSValue(DOM::CSSValue v) : cssValue(v) { }
+ DOMCSSValue(ExecState *, DOM::CSSValueImpl *v) : m_impl(v) { }
virtual ~DOMCSSValue();
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { CssText, CssValueType };
+ DOM::CSSValueImpl *impl() const { return m_impl.get(); }
protected:
- DOM::CSSValue cssValue;
+ // Constructor for derived classes; doesn't set up a prototype.
+ DOMCSSValue(DOM::CSSValueImpl *v) : m_impl(v) { }
+ private:
+ khtml::SharedPtr<DOM::CSSValueImpl> m_impl;
};
- Value getDOMCSSValue(ExecState *exec, DOM::CSSValue v);
+ ValueImp *getDOMCSSValue(ExecState *exec, DOM::CSSValueImpl *v);
// Constructor for CSSValue - currently only used for some global values
class CSSValueConstructor : public DOMObject {
class DOMCSSPrimitiveValue : public DOMCSSValue {
public:
- DOMCSSPrimitiveValue(ExecState *exec, DOM::CSSPrimitiveValue v);
+ DOMCSSPrimitiveValue(ExecState *exec, DOM::CSSPrimitiveValueImpl *v);
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
- DOM::CSSPrimitiveValue toCSSPrimitiveValue() const { return static_cast<DOM::CSSPrimitiveValue>(cssValue); }
enum { PrimitiveType, SetFloatValue, GetFloatValue, SetStringValue, GetStringValue,
GetCounterValue, GetRectValue, GetRGBColorValue };
};
class DOMCSSValueList : public DOMCSSValue {
public:
- DOMCSSValueList(ExecState *exec, DOM::CSSValueList v);
+ DOMCSSValueList(ExecState *exec, DOM::CSSValueListImpl *l);
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Item, Length };
- DOM::CSSValueList toValueList() const { return static_cast<DOM::CSSValueList>(cssValue); }
};
class DOMRGBColor : public DOMObject {
public:
- DOMRGBColor(DOM::RGBColor c) : rgbColor(c) { }
+ DOMRGBColor(unsigned color) : m_color(color) { }
~DOMRGBColor();
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Red, Green, Blue };
- protected:
- DOM::RGBColor rgbColor;
+ private:
+ unsigned m_color;
};
- Value getDOMRGBColor(ExecState *exec, DOM::RGBColor c);
+ ValueImp *getDOMRGBColor(ExecState *exec, unsigned color);
class DOMRect : public DOMObject {
public:
- DOMRect(ExecState *, DOM::Rect r) : rect(r) { }
+ DOMRect(ExecState *, DOM::RectImpl *r) : m_rect(r) { }
~DOMRect();
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Top, Right, Bottom, Left };
- protected:
- DOM::Rect rect;
+ private:
+ khtml::SharedPtr<DOM::RectImpl> m_rect;
};
- Value getDOMRect(ExecState *exec, DOM::Rect r);
+ ValueImp *getDOMRect(ExecState *exec, DOM::RectImpl *r);
class DOMCounter : public DOMObject {
public:
- DOMCounter(ExecState *, DOM::Counter c) : counter(c) { }
+ DOMCounter(ExecState *, DOM::CounterImpl *c) : m_counter(c) { }
~DOMCounter();
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
static const ClassInfo info;
enum { identifier, listStyle, separator };
protected:
- DOM::Counter counter;
+ khtml::SharedPtr<DOM::CounterImpl> m_counter;
};
- Value getDOMCounter(ExecState *exec, DOM::Counter c);
+ ValueImp *getDOMCounter(ExecState *exec, DOM::CounterImpl *c);
-}; // namespace
+} // namespace
#endif
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "kjs_dom.h"
+
+#include <kdebug.h>
+#include <khtml_part.h>
#include <khtmlview.h>
#include "xml/dom2_eventsimpl.h"
+#include "xml/dom2_viewsimpl.h"
#include "rendering/render_canvas.h"
#include "xml/dom_nodeimpl.h"
#include "xml/dom_docimpl.h"
-#include <kdebug.h>
-#include <khtml_part.h>
+#include "xml/dom_textimpl.h"
+#include "xml/dom_xmlimpl.h"
+#include "html/html_documentimpl.h"
+#include "css/css_ruleimpl.h"
+#include "css/css_stylesheetimpl.h"
-#include "kjs_dom.h"
#include "kjs_html.h"
#include "kjs_css.h"
#include "kjs_range.h"
#include "kjs_views.h"
#include "kjs_window.h"
#include "dom/dom_exception.h"
-#include "kjs_dom.lut.h"
#include "khtmlpart_p.h"
#include "html_objectimpl.h"
#include <JavaScriptCore/runtime_object.h>
#endif
-using namespace KJS;
-
+using DOM::AttrImpl;
+using DOM::CharacterDataImpl;
+using DOM::DocumentImpl;
+using DOM::DocumentTypeImpl;
using DOM::DOMException;
+using DOM::DOMImplementationImpl;
using DOM::DOMString;
-using DOM::NodeFilter;
+using DOM::ElementImpl;
+using DOM::EntityImpl;
+using DOM::EventImpl;
+using DOM::HTMLAppletElementImpl;
+using DOM::HTMLDocumentImpl;
+using DOM::HTMLElementImpl;
+using DOM::HTMLEmbedElementImpl;
+using DOM::HTMLObjectElementImpl;
+using DOM::NamedNodeMapImpl;
+using DOM::Node;
+using DOM::NodeFilterImpl;
+using DOM::NodeImpl;
+using DOM::NodeListImpl;
+using DOM::NotationImpl;
+using DOM::ProcessingInstructionImpl;
+using DOM::TextImpl;
+
+using khtml::RenderObject;
+using khtml::SharedPtr;
+
+#include "kjs_dom.lut.h"
+
+namespace KJS {
+
+class DOMNodeListFunc : public DOMFunction {
+ friend class DOMNodeList;
+public:
+ DOMNodeListFunc(ExecState *exec, int id, int len);
+ virtual Value tryCall(ExecState *exec, Object &thisObj, const List &);
+ enum { Item };
+private:
+ int id;
+};
// -------------------------------------------------------------------------
/* Source for DOMNodeProtoTable. Use "make hashtables" to regenerate.
const ClassInfo DOMNode::info = { "Node", 0, &DOMNodeTable, 0 };
-DOMNode::DOMNode(ExecState *exec, const DOM::Node &n)
- : node(n)
+DOMNode::DOMNode(ExecState *exec, NodeImpl *n)
+ : m_impl(n)
{
setPrototype(DOMNodeProto::self(exec));
}
-DOMNode::DOMNode(const DOM::Node &n)
- : node(n)
+DOMNode::DOMNode(NodeImpl *n)
+ : m_impl(n)
{
}
bool DOMNode::toBoolean(ExecState *) const
{
- return !node.isNull();
+ return m_impl.notNull();
}
/* Source for DOMNodeTable. Use "make hashtables" to regenerate.
Value DOMNode::getValueProperty(ExecState *exec, int token) const
{
+ NodeImpl &node = *m_impl;
switch (token) {
case NodeName:
return getStringOrNull(node.nodeName());
case NodeValue:
return getStringOrNull(node.nodeValue());
case NodeType:
- return Number((unsigned int)node.nodeType());
+ return Number(node.nodeType());
case ParentNode:
- return getDOMNode(exec,node.parentNode());
case ParentElement: // IE only apparently
return getDOMNode(exec,node.parentNode());
case ChildNodes:
// no DOM standard, found in IE only
// Make sure our layout is up to date before we allow a query on these attributes.
- DOM::DocumentImpl* docimpl = node.handle()->getDocument();
+ DOM::DocumentImpl* docimpl = node.getDocument();
if (docimpl) {
docimpl->updateLayoutIgnorePendingStylesheets();
}
- khtml::RenderObject *rend = node.handle()->renderer();
+ khtml::RenderObject *rend = node.renderer();
switch (token) {
case OffsetLeft:
void DOMNode::putValue(ExecState *exec, int token, const Value& value, int /*attr*/)
{
+ DOMExceptionTranslator exception(exec);
+ NodeImpl &node = *m_impl;
switch (token) {
case NodeValue:
- node.setNodeValue(value.toString(exec).string());
+ node.setNodeValue(value.toString(exec).string(), exception);
break;
case Prefix:
- node.setPrefix(value.toString(exec).string());
+ node.setPrefix(value.toString(exec).string(), exception);
break;
case OnAbort:
setListener(exec,DOM::EventImpl::ABORT_EVENT,value);
break;
case OnScroll:
setListener(exec,DOM::EventImpl::SCROLL_EVENT,value);
-#if APPLE_CHANGES
+ break;
case OnSearch:
setListener(exec,DOM::EventImpl::SEARCH_EVENT,value);
break;
-#endif
case OnSelect:
setListener(exec,DOM::EventImpl::SELECT_EVENT,value);
break;
setListener(exec,DOM::EventImpl::UNLOAD_EVENT,value);
break;
case ScrollTop: {
- khtml::RenderObject *rend = node.handle() ? node.handle()->renderer() : 0L;
+ khtml::RenderObject *rend = node.renderer();
if (rend && rend->hasOverflowClip())
rend->layer()->scrollToYOffset(value.toInt32(exec));
break;
}
case ScrollLeft: {
- khtml::RenderObject *rend = node.handle() ? node.handle()->renderer() : 0L;
+ khtml::RenderObject *rend = node.renderer();
if (rend && rend->hasOverflowClip())
rend->layer()->scrollToXOffset(value.toInt32(exec));
break;
Value DOMNode::toPrimitive(ExecState *exec, Type /*preferred*/) const
{
- if (node.isNull())
+ if (m_impl.isNull())
return Null();
return String(toString(exec));
UString DOMNode::toString(ExecState *) const
{
- if (node.isNull())
+ if (m_impl.isNull())
return "null";
- UString s;
-
- DOM::Element e = node;
- if ( !e.isNull() ) {
- s = UString(e.nodeName().string());
- } else
- s = className(); // fallback
-
- return "[object " + s + "]";
+ return "[object " + (m_impl->isElementNode() ? m_impl->nodeName() : className()) + "]";
}
-void DOMNode::setListener(ExecState *exec, int eventId, Value func) const
+void DOMNode::setListener(ExecState *exec, int eventId, ValueImp *func) const
{
- node.handle()->setHTMLEventListener(eventId,Window::retrieveActive(exec)->getJSEventListener(func,true));
+ m_impl->setHTMLEventListener(eventId, Window::retrieveActive(exec)->getJSEventListener(func, true));
}
Value DOMNode::getListener(int eventId) const
{
- DOM::EventListener *listener = node.handle()->getHTMLEventListener(eventId);
+ DOM::EventListener *listener = m_impl->getHTMLEventListener(eventId);
JSEventListener *jsListener = static_cast<JSEventListener*>(listener);
if ( jsListener && jsListener->listenerObjImp() )
return jsListener->listenerObj();
exec->setException(err);
return err;
}
- DOM::Node node = static_cast<DOMNode *>( thisObj.imp() )->toNode();
+ DOMExceptionTranslator exception(exec);
+ NodeImpl &node = *static_cast<DOMNode *>(thisObj.imp())->impl();
switch (id) {
case DOMNode::HasAttributes:
return Boolean(node.hasAttributes());
return Undefined();
}
case DOMNode::DispatchEvent:
- return Boolean(node.dispatchEvent(toEvent(args[0])));
+ return Boolean(node.dispatchEvent(toEvent(args[0]), exception));
case DOMNode::AppendChild:
- return getDOMNode(exec,node.appendChild(toNode(args[0])));
+ return getDOMNode(exec,node.appendChild(toNode(args[0]), exception));
case DOMNode::RemoveChild:
- return getDOMNode(exec,node.removeChild(toNode(args[0])));
+ return getDOMNode(exec,node.removeChild(toNode(args[0]), exception));
case DOMNode::InsertBefore:
- return getDOMNode(exec,node.insertBefore(toNode(args[0]), toNode(args[1])));
+ return getDOMNode(exec,node.insertBefore(toNode(args[0]), toNode(args[1]), exception));
case DOMNode::ReplaceChild:
- return getDOMNode(exec,node.replaceChild(toNode(args[0]), toNode(args[1])));
+ return getDOMNode(exec,node.replaceChild(toNode(args[0]), toNode(args[1]), exception));
case DOMNode::Contains:
- {
- DOM::Node other = toNode(args[0]);
- if (!other.isNull() && node.nodeType()==DOM::Node::ELEMENT_NODE)
- {
- DOM::NodeImpl *impl = node.handle();
- return Boolean(impl->isAncestor(other.handle()));
- }
- return Undefined();
- }
+ if (node.isElementNode())
+ if (NodeImpl *node0 = toNode(args[0]))
+ return Boolean(node.isAncestor(node0));
+ // FIXME: Is there a good reason to return undefined rather than false
+ // when the parameter is not a node? When the object is not an element?
+ return Undefined();
case DOMNode::Item:
- return getDOMNode(exec, node.childNodes().item(static_cast<unsigned long>(args[0].toNumber(exec))));
+ return getDOMNode(exec, node.childNodes()->item(args[0].toInt32(exec)));
}
return Undefined();
}
+NodeImpl *toNode(ValueImp *val)
+{
+ if (!val || !val->isObject(&DOMNode::info))
+ return 0;
+ return static_cast<DOMNode *>(val)->impl();
+}
+
// -------------------------------------------------------------------------
const ClassInfo DOMNodeList::info = { "NodeList", 0, 0, 0 };
DOMNodeList::~DOMNodeList()
{
- ScriptInterpreter::forgetDOMObject(list.handle());
+ ScriptInterpreter::forgetDOMObject(m_impl.get());
}
Value DOMNodeList::toPrimitive(ExecState *exec, Type /*preferred*/) const
{
- if (list.isNull())
+ if (m_impl.isNull())
return Null();
return String(toString(exec));
#endif
Value result;
+ NodeListImpl &list = *m_impl;
if (p == lengthPropertyName)
result = Number(list.length());
else if (p == "item") {
// No need for a complete hashtable for a single func, but we still want
// to use the caching feature of lookupOrCreateFunction.
result = lookupOrCreateFunction<DOMNodeListFunc>(exec, p, this, DOMNodeListFunc::Item, 1, DontDelete|Function);
- //result = new DOMNodeListFunc(exec, DOMNodeListFunc::Item, 1);
}
else {
// array index ?
if (ok) {
result = getDOMNode(exec,list.item(idx));
} else {
- DOM::Node node = list.itemById(p.string());
+ NodeImpl *node = list.itemById(p.string());
- if (!node.isNull()) {
+ if (node) {
result = getDOMNode(exec, node);
} else {
result = ObjectImp::get(exec, p);
bool ok;
unsigned int u = s.toULong(&ok);
if (ok)
- return getDOMNode(exec,list.item(u));
+ return getDOMNode(exec, m_impl->item(u));
kdWarning() << "KJS::DOMNodeList::tryCall " << s.qstring() << " not implemented" << endl;
return Undefined();
exec->setException(err);
return err;
}
- DOM::NodeList list = static_cast<DOMNodeList *>(thisObj.imp())->nodeList();
+ DOM::NodeListImpl &list = *static_cast<DOMNodeList *>(thisObj.imp())->impl();
Value result;
if (id == Item)
ownerElement DOMAttr::OwnerElement DontDelete|ReadOnly
@end
*/
+
+DOMAttr::DOMAttr(ExecState *exec, AttrImpl *a)
+ : DOMNode(exec, a)
+{
+}
+
Value DOMAttr::tryGet(ExecState *exec, const Identifier &propertyName) const
{
#ifdef KJS_VERBOSE
Value DOMAttr::getValueProperty(ExecState *exec, int token) const
{
+ AttrImpl *attr = static_cast<AttrImpl *>(impl());
switch (token) {
case Name:
- return getStringOrNull(static_cast<DOM::Attr>(node).name());
+ return getStringOrNull(attr->name());
case Specified:
- return Boolean(static_cast<DOM::Attr>(node).specified());
+ return Boolean(attr->specified());
case ValueProperty:
- return getStringOrNull(static_cast<DOM::Attr>(node).value());
+ return getStringOrNull(attr->value());
case OwnerElement: // DOM2
- return getDOMNode(exec,static_cast<DOM::Attr>(node).ownerElement());
+ return getDOMNode(exec, attr->ownerElement());
}
return Value(); // not reached
}
void DOMAttr::putValue(ExecState *exec, int token, const Value& value, int /*attr*/)
{
+ DOMExceptionTranslator exception(exec);
switch (token) {
case ValueProperty:
- static_cast<DOM::Attr>(node).setValue(value.toString(exec).string());
+ static_cast<AttrImpl *>(impl())->setValue(value.toString(exec).string(), exception);
return;
default:
kdWarning() << "DOMAttr::putValue unhandled token " << token << endl;
}
}
+AttrImpl *toAttr(ValueImp *val)
+{
+ if (!val || !val->isObject(&DOMAttr::info))
+ return 0;
+ return static_cast<AttrImpl *>(static_cast<DOMNode *>(val)->impl());
+}
+
// -------------------------------------------------------------------------
/* Source for DOMDocumentProtoTable. Use "make hashtables" to regenerate.
@end
*/
-DOMDocument::DOMDocument(ExecState *exec, const DOM::Document &d)
+DOMDocument::DOMDocument(ExecState *exec, DocumentImpl *d)
: DOMNode(d)
{
setPrototype(DOMDocumentProto::self(exec));
}
-DOMDocument::DOMDocument(const DOM::Document &d)
+DOMDocument::DOMDocument(DocumentImpl *d)
: DOMNode(d)
{
}
DOMDocument::~DOMDocument()
{
- ScriptInterpreter::forgetDOMObject(node.handle());
+ ScriptInterpreter::forgetDOMObject(static_cast<DocumentImpl *>(m_impl.get()));
}
Value DOMDocument::tryGet(ExecState *exec, const Identifier &propertyName) const
Value DOMDocument::getValueProperty(ExecState *exec, int token) const
{
- DOM::Document doc = static_cast<DOM::Document>(node);
+ DocumentImpl &doc = *static_cast<DocumentImpl *>(impl());
switch(token) {
case DocType:
return getDOMNode(exec,doc.documentElement());
case StyleSheets:
//kdDebug() << "DOMDocument::StyleSheets, returning " << doc.styleSheets().length() << " stylesheets" << endl;
- return getDOMStyleSheetList(exec, doc.styleSheets(), doc);
+ return getDOMStyleSheetList(exec, doc.styleSheets(), &doc);
case PreferredStylesheetSet:
return getStringOrNull(doc.preferredStylesheetSet());
case SelectedStylesheetSet:
return getStringOrNull(doc.selectedStylesheetSet());
case ReadyState:
- {
- DOM::DocumentImpl* docimpl = node.handle()->getDocument();
- if ( docimpl )
- {
- KHTMLPart* part = docimpl->part();
- if ( part ) {
- if (part->d->m_bComplete) return String("complete");
- if (docimpl->parsing()) return String("loading");
- return String("loaded");
- // What does the interactive value mean ?
- // Missing support for "uninitialized"
- }
+ if (KHTMLPart* part = doc.part()) {
+ if (part->d->m_bComplete) return String("complete");
+ if (doc.parsing()) return String("loading");
+ return String("loaded");
+ // What does the interactive value mean ?
+ // Missing support for "uninitialized"
}
return Undefined();
- }
case DOMDocument::DefaultView: // DOM2
return getDOMAbstractView(exec,doc.defaultView());
default:
void DOMDocument::putValue(ExecState *exec, int token, const Value& value, int /*attr*/)
{
- DOM::Document doc = static_cast<DOM::Document>(node);
+ DocumentImpl &doc = *static_cast<DocumentImpl *>(impl());
switch (token) {
case SelectedStylesheetSet: {
doc.setSelectedStylesheetSet(value.toString(exec).string());
exec->setException(err);
return err;
}
- DOM::Node node = static_cast<DOMNode *>( thisObj.imp() )->toNode();
- DOM::Document doc = static_cast<DOM::Document>(node);
+ DOMExceptionTranslator exception(exec);
+ NodeImpl &node = *static_cast<DOMNode *>(thisObj.imp())->impl();
+ DocumentImpl &doc = static_cast<DocumentImpl &>(node);
String str = args[0].toString(exec);
DOM::DOMString s = str.value().string();
switch(id) {
case DOMDocument::CreateElement:
- return getDOMNode(exec,doc.createElement(s));
+ return getDOMNode(exec,doc.createElement(s, exception));
case DOMDocument::CreateDocumentFragment:
return getDOMNode(exec,doc.createDocumentFragment());
case DOMDocument::CreateTextNode:
return getDOMNode(exec,doc.createProcessingInstruction(args[0].toString(exec).string(),
args[1].toString(exec).string()));
case DOMDocument::CreateAttribute:
- return getDOMNode(exec,doc.createAttribute(s));
+ return getDOMNode(exec,doc.createAttribute(s, exception));
case DOMDocument::CreateEntityReference:
- return getDOMNode(exec,doc.createEntityReference(args[0].toString(exec).string()));
+ return getDOMNode(exec,doc.createEntityReference(s));
case DOMDocument::ElementFromPoint:
return getDOMNode(exec,doc.elementFromPoint((int)args[0].toNumber(exec), (int)args[1].toNumber(exec)));
case DOMDocument::GetElementsByTagName:
- return getDOMNodeList(exec,doc.getElementsByTagName(s));
+ return getDOMNodeList(exec,doc.getElementsByTagName(s).get());
case DOMDocument::ImportNode: // DOM2
- return getDOMNode(exec,doc.importNode(toNode(args[0]), args[1].toBoolean(exec)));
+ return getDOMNode(exec,doc.importNode(toNode(args[0]), args[1].toBoolean(exec), exception));
case DOMDocument::CreateElementNS: // DOM2
- return getDOMNode(exec,doc.createElementNS(args[0].toString(exec).string(), args[1].toString(exec).string()));
+ return getDOMNode(exec,doc.createElementNS(s, args[1].toString(exec).string(), exception));
case DOMDocument::CreateAttributeNS: // DOM2
- return getDOMNode(exec,doc.createAttributeNS(args[0].toString(exec).string(),args[1].toString(exec).string()));
+ return getDOMNode(exec,doc.createAttributeNS(s, args[1].toString(exec).string(), exception));
case DOMDocument::GetElementsByTagNameNS: // DOM2
- return getDOMNodeList(exec,doc.getElementsByTagNameNS(args[0].toString(exec).string(),
- args[1].toString(exec).string()));
+ return getDOMNodeList(exec,doc.getElementsByTagNameNS(s, args[1].toString(exec).string()).get());
case DOMDocument::GetElementById:
return getDOMNode(exec,doc.getElementById(args[0].toString(exec).string()));
case DOMDocument::CreateRange:
return getDOMRange(exec,doc.createRange());
case DOMDocument::CreateNodeIterator: {
- NodeFilter filter;
- if (!args[2].isA(NullType)) {
- Object obj = Object::dynamicCast(args[2]);
- if (!obj.isNull())
- filter = NodeFilter(new JSNodeFilterCondition(obj));
+ NodeFilterImpl *filter = 0;
+ ValueImp *arg2 = args.impAt(2);
+ if (arg2->isObject()) {
+ Object o(static_cast<ObjectImp *>(arg2));
+ filter = new NodeFilterImpl(new JSNodeFilterCondition(o));
}
- return getDOMNodeIterator(exec, doc.createNodeIterator(toNode(args[0]), (long unsigned int)(args[1].toNumber(exec)), filter, args[3].toBoolean(exec)));
+ return getDOMNodeIterator(exec,doc.createNodeIterator(toNode(args[0]), args[1].toUInt32(exec),
+ filter, args[3].toBoolean(exec), exception));
}
case DOMDocument::CreateTreeWalker: {
- NodeFilter filter;
- if (!args[2].isA(NullType)) {
- Object obj = Object::dynamicCast(args[2]);
- if (!obj.isNull())
- filter = NodeFilter(new JSNodeFilterCondition(obj));
+ NodeFilterImpl *filter = 0;
+ ValueImp *arg2 = args.impAt(2);
+ if (arg2->isObject()) {
+ Object o(static_cast<ObjectImp *>(arg2));
+ filter = new NodeFilterImpl(new JSNodeFilterCondition(o));
}
- return getDOMTreeWalker(exec, doc.createTreeWalker(toNode(args[0]), (long unsigned int)(args[1].toNumber(exec)), filter, args[3].toBoolean(exec)));
+ return getDOMTreeWalker(exec,doc.createTreeWalker(toNode(args[0]), args[1].toUInt32(exec),
+ filter, args[3].toBoolean(exec), exception));
}
case DOMDocument::CreateEvent:
- return getDOMEvent(exec,doc.createEvent(s));
- case DOMDocument::GetOverrideStyle: {
- DOM::Node arg0 = toNode(args[0]);
- if (arg0.nodeType() != DOM::Node::ELEMENT_NODE)
- return Undefined(); // throw exception?
- else
- return getDOMCSSStyleDeclaration(exec,doc.getOverrideStyle(static_cast<DOM::Element>(arg0),args[1].toString(exec).string()));
- }
+ return getDOMEvent(exec,doc.createEvent(s, exception));
+ case DOMDocument::GetOverrideStyle:
+ if (ElementImpl *element0 = toElement(args[0]))
+ return getDOMCSSStyleDeclaration(exec,doc.getOverrideStyle(element0, args[1].toString(exec).string()));
+ // FIXME: Is undefined right here, or should we raise an exception?
+ return Undefined();
case DOMDocument::ExecCommand: {
return Boolean(doc.execCommand(args[0].toString(exec).string(), args[1].toBoolean(exec), args[2].toString(exec).string()));
}
case DOMDocument::QueryCommandValue: {
DOM::DOMString commandValue(doc.queryCommandValue(args[0].toString(exec).string()));
// Method returns null DOMString to signal command is unsupported.
- // Micorsoft documentation for this method says:
+ // Microsoft documentation for this method says:
// "If not supported [for a command identifier], this method returns a Boolean set to false."
if (commandValue.isNull())
return Boolean(false);
style DOMElement::Style DontDelete|ReadOnly
@end
*/
-DOMElement::DOMElement(ExecState *exec, const DOM::Element &e)
+DOMElement::DOMElement(ExecState *exec, ElementImpl *e)
: DOMNode(e)
{
setPrototype(DOMElementProto::self(exec));
}
-DOMElement::DOMElement(const DOM::Element &e)
+DOMElement::DOMElement(ElementImpl *e)
: DOMNode(e)
{
}
#ifdef KJS_VERBOSE
kdDebug(6070) << "DOMElement::tryGet " << propertyName.qstring() << endl;
#endif
- DOM::Element element = static_cast<DOM::Element>(node);
+ ElementImpl &element = *static_cast<ElementImpl *>(impl());
const HashEntry* entry = Lookup::findEntry(&DOMElementTable, propertyName);
if (entry)
exec->setException(err);
return err;
}
- DOM::Node node = static_cast<DOMNode *>( thisObj.imp() )->toNode();
- DOM::Element element = static_cast<DOM::Element>(node);
+ DOMExceptionTranslator exception(exec);
+ NodeImpl &node = *static_cast<DOMNode *>(thisObj.imp())->impl();
+ ElementImpl &element = static_cast<ElementImpl &>(node);
switch(id) {
case DOMElement::GetAttribute:
- // getString should be used here, since if the attribute isn't present at all, you should
+ // getStringOrNull should be used here, since if the attribute isn't present at all, you should
// return null and not "".
return getStringOrNull(element.getAttribute(args[0].toString(exec).string()));
case DOMElement::SetAttribute:
- element.setAttribute(args[0].toString(exec).string(),args[1].toString(exec).string());
+ element.setAttribute(args[0].toString(exec).string(), args[1].toString(exec).string(), exception);
return Undefined();
case DOMElement::RemoveAttribute:
- element.removeAttribute(args[0].toString(exec).string());
+ element.removeAttribute(args[0].toString(exec).string(), exception);
return Undefined();
case DOMElement::GetAttributeNode:
return getDOMNode(exec,element.getAttributeNode(args[0].toString(exec).string()));
case DOMElement::SetAttributeNode:
- return getDOMNode(exec,element.setAttributeNode((new DOMNode(exec,KJS::toNode(args[0])))->toNode()));
+ return getDOMNode(exec,element.setAttributeNode(toAttr(args[0]), exception).get());
case DOMElement::RemoveAttributeNode:
- return getDOMNode(exec,element.removeAttributeNode((new DOMNode(exec,KJS::toNode(args[0])))->toNode()));
+ return getDOMNode(exec,element.removeAttributeNode(toAttr(args[0]), exception).get());
case DOMElement::GetElementsByTagName:
- return getDOMNodeList(exec,element.getElementsByTagName(args[0].toString(exec).string()));
+ return getDOMNodeList(exec, element.getElementsByTagName(args[0].toString(exec).string()).get());
case DOMElement::HasAttribute: // DOM2
return Boolean(element.hasAttribute(args[0].toString(exec).string()));
case DOMElement::GetAttributeNS: // DOM2
- return String(element.getAttributeNS(args[0].toString(exec).string(),args[1].toString(exec).string()));
+ return String(element.getAttributeNS(args[0].toString(exec).string(),args[1].toString(exec).string()).string());
case DOMElement::SetAttributeNS: // DOM2
- element.setAttributeNS(args[0].toString(exec).string(),args[1].toString(exec).string(),args[2].toString(exec).string());
+ element.setAttributeNS(args[0].toString(exec).string(), args[1].toString(exec).string(), args[2].toString(exec).string(), exception);
return Undefined();
case DOMElement::RemoveAttributeNS: // DOM2
- element.removeAttributeNS(args[0].toString(exec).string(),args[1].toString(exec).string());
+ element.removeAttributeNS(args[0].toString(exec).string(), args[1].toString(exec).string(), exception);
return Undefined();
case DOMElement::GetAttributeNodeNS: // DOM2
return getDOMNode(exec,element.getAttributeNodeNS(args[0].toString(exec).string(),args[1].toString(exec).string()));
case DOMElement::SetAttributeNodeNS: // DOM2
- return getDOMNode(exec,element.setAttributeNodeNS((new DOMNode(exec,KJS::toNode(args[0])))->toNode()));
+ return getDOMNode(exec, element.setAttributeNodeNS(toAttr(args[0]), exception).get());
case DOMElement::GetElementsByTagNameNS: // DOM2
- return getDOMNodeList(exec,element.getElementsByTagNameNS(args[0].toString(exec).string(),args[1].toString(exec).string()));
+ return getDOMNodeList(exec, element.getElementsByTagNameNS(args[0].toString(exec).string() ,args[1].toString(exec).string()).get());
case DOMElement::HasAttributeNS: // DOM2
return Boolean(element.hasAttributeNS(args[0].toString(exec).string(),args[1].toString(exec).string()));
case DOMElement::ScrollByLines:
case DOMElement::ScrollByPages:
- {
- DOM::DocumentImpl* docimpl = node.handle()->getDocument();
- if (docimpl) {
- docimpl->updateLayoutIgnorePendingStylesheets();
- }
- khtml::RenderObject *rend = node.handle() ? node.handle()->renderer() : 0L;
- if (rend && rend->hasOverflowClip()) {
+ if (DocumentImpl* doc = element.getDocument()) {
+ doc->updateLayoutIgnorePendingStylesheets();
+ if (RenderObject *rend = element.renderer())
+ if (rend->hasOverflowClip()) {
KWQScrollDirection direction = KWQScrollDown;
int multiplier = args[0].toInt32(exec);
if (multiplier < 0) {
}
KWQScrollGranularity granularity = id == DOMElement::ScrollByLines ? KWQScrollLine : KWQScrollPage;
rend->layer()->scroll(direction, granularity, multiplier);
- }
- return Undefined();
-
+ }
+ }
+ return Undefined();
+ default:
+ return Undefined();
}
- default:
- return Undefined();
- }
+}
+
+ElementImpl *toElement(ValueImp *val)
+{
+ if (!val || !val->isObject(&DOMElement::info))
+ return 0;
+ return static_cast<ElementImpl *>(static_cast<DOMElement *>(val)->impl());
}
// -------------------------------------------------------------------------
const ClassInfo DOMDOMImplementation::info = { "DOMImplementation", 0, 0, 0 };
-DOMDOMImplementation::DOMDOMImplementation(ExecState *exec, const DOM::DOMImplementation &i)
- : implementation(i)
+DOMDOMImplementation::DOMDOMImplementation(ExecState *exec, DOMImplementationImpl *i)
+ : m_impl(i)
{
setPrototype(DOMDOMImplementationProto::self(exec));
}
DOMDOMImplementation::~DOMDOMImplementation()
{
- ScriptInterpreter::forgetDOMObject(implementation.handle());
+ ScriptInterpreter::forgetDOMObject(m_impl.get());
}
Value DOMDOMImplementationProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
exec->setException(err);
return err;
}
- DOM::DOMImplementation implementation = static_cast<DOMDOMImplementation *>( thisObj.imp() )->toImplementation();
+ DOMExceptionTranslator exception(exec);
+ DOMImplementationImpl &implementation = *static_cast<DOMDOMImplementation *>(thisObj.imp())->impl();
switch(id) {
case DOMDOMImplementation::HasFeature:
return Boolean(implementation.hasFeature(args[0].toString(exec).string(),
(args[1].type() != UndefinedType && args[1].type() != NullType) ? args[1].toString(exec).string() : DOMString()));
case DOMDOMImplementation::CreateDocumentType: // DOM2
- return getDOMNode(exec,implementation.createDocumentType(args[0].toString(exec).string(),args[1].toString(exec).string(),args[2].toString(exec).string()));
+ return getDOMNode(exec, implementation.createDocumentType(args[0].toString(exec).string(),
+ args[1].toString(exec).string(), args[2].toString(exec).string(), exception));
case DOMDOMImplementation::CreateDocument: // DOM2
- return getDOMNode(exec,implementation.createDocument(args[0].toString(exec).string(),args[1].toString(exec).string(),toNode(args[2])));
+ return getDOMNode(exec, implementation.createDocument(args[0].toString(exec).string(),
+ args[1].toString(exec).string(), toDocumentType(args[2]), exception));
case DOMDOMImplementation::CreateCSSStyleSheet: // DOM2
- return getDOMStyleSheet(exec,implementation.createCSSStyleSheet(args[0].toString(exec).string(),args[1].toString(exec).string()));
+ return getDOMStyleSheet(exec, implementation.createCSSStyleSheet(args[0].toString(exec).string(), args[1].toString(exec).string(), exception));
case DOMDOMImplementation::CreateHTMLDocument: // DOM2-HTML
return getDOMNode(exec, implementation.createHTMLDocument(args[0].toString(exec).string()));
default:
internalSubset DOMDocumentType::InternalSubset DontDelete|ReadOnly
@end
*/
-DOMDocumentType::DOMDocumentType(ExecState *exec, const DOM::DocumentType &dt)
+DOMDocumentType::DOMDocumentType(ExecState *exec, DocumentTypeImpl *dt)
: DOMNode( /*### no proto yet*/exec, dt ) { }
Value DOMDocumentType::tryGet(ExecState *exec, const Identifier &propertyName) const
Value DOMDocumentType::getValueProperty(ExecState *exec, int token) const
{
- DOM::DocumentType type = static_cast<DOM::DocumentType>(node);
+ DocumentTypeImpl &type = *static_cast<DocumentTypeImpl *>(impl());
switch (token) {
case Name:
return getStringOrNull(type.name());
}
}
+DocumentTypeImpl *toDocumentType(ValueImp *val)
+{
+ if (!val || !val->isObject(&DOMDocumentType::info))
+ return 0;
+ return static_cast<DocumentTypeImpl *>(static_cast<DOMNode *>(val)->impl());
+}
+
// -------------------------------------------------------------------------
/* Source for DOMNamedNodeMapProtoTable. Use "make hashtables" to regenerate.
const ClassInfo DOMNamedNodeMap::info = { "NamedNodeMap", 0, 0, 0 };
-DOMNamedNodeMap::DOMNamedNodeMap(ExecState *exec, const DOM::NamedNodeMap &m)
- : map(m)
+DOMNamedNodeMap::DOMNamedNodeMap(ExecState *exec, NamedNodeMapImpl *m)
+ : m_impl(m)
{
setPrototype(DOMNamedNodeMapProto::self(exec));
}
DOMNamedNodeMap::~DOMNamedNodeMap()
{
- ScriptInterpreter::forgetDOMObject(map.handle());
+ ScriptInterpreter::forgetDOMObject(m_impl.get());
}
// We have to implement hasProperty since we don't use a hashtable for 'length'
Value DOMNamedNodeMap::tryGet(ExecState* exec, const Identifier &p) const
{
+ NamedNodeMapImpl &map = *m_impl;
if (p == lengthPropertyName)
return Number(map.length());
exec->setException(err);
return err;
}
- DOM::NamedNodeMap map = static_cast<DOMNamedNodeMap *>(thisObj.imp())->toMap();
+ DOMExceptionTranslator exception(exec);
+ NamedNodeMapImpl &map = *static_cast<DOMNamedNodeMap *>(thisObj.imp())->impl();
switch(id) {
case DOMNamedNodeMap::GetNamedItem:
return getDOMNode(exec, map.getNamedItem(args[0].toString(exec).string()));
case DOMNamedNodeMap::SetNamedItem:
- return getDOMNode(exec, map.setNamedItem((new DOMNode(exec,KJS::toNode(args[0])))->toNode()));
+ return getDOMNode(exec, map.setNamedItem(toNode(args[0]), exception).get());
case DOMNamedNodeMap::RemoveNamedItem:
- return getDOMNode(exec, map.removeNamedItem(args[0].toString(exec).string()));
+ return getDOMNode(exec, map.removeNamedItem(args[0].toString(exec).string(), exception).get());
case DOMNamedNodeMap::Item:
return getDOMNode(exec, map.item(args[0].toInt32(exec)));
case DOMNamedNodeMap::GetNamedItemNS: // DOM2
- return getDOMNode(exec, map.getNamedItemNS(args[0].toString(exec).string(),args[1].toString(exec).string()));
+ return getDOMNode(exec, map.getNamedItemNS(args[0].toString(exec).string(), args[1].toString(exec).string()));
case DOMNamedNodeMap::SetNamedItemNS: // DOM2
- return getDOMNode(exec, map.setNamedItemNS(toNode(args[0])));
+ return getDOMNode(exec, map.setNamedItemNS(toNode(args[0]), exception).get());
case DOMNamedNodeMap::RemoveNamedItemNS: // DOM2
- return getDOMNode(exec, map.removeNamedItemNS(args[0].toString(exec).string(),args[1].toString(exec).string()));
+ return getDOMNode(exec, map.removeNamedItemNS(args[0].toString(exec).string(), args[1].toString(exec).string(), exception).get());
default:
break;
}
sheet DOMProcessingInstruction::Sheet DontDelete|ReadOnly
@end
*/
+
+DOMProcessingInstruction::DOMProcessingInstruction(ExecState *exec, ProcessingInstructionImpl *i)
+ : DOMNode(exec, i)
+{
+}
+
Value DOMProcessingInstruction::tryGet(ExecState *exec, const Identifier &propertyName) const
{
return DOMObjectLookupGetValue<DOMProcessingInstruction, DOMNode>(exec, propertyName, &DOMProcessingInstructionTable, this);
Value DOMProcessingInstruction::getValueProperty(ExecState *exec, int token) const
{
+ ProcessingInstructionImpl *pi = static_cast<ProcessingInstructionImpl *>(impl());
switch (token) {
case Target:
- return getStringOrNull(static_cast<DOM::ProcessingInstruction>(node).target());
+ return getStringOrNull(pi->target());
case Data:
- return getStringOrNull(static_cast<DOM::ProcessingInstruction>(node).data());
+ return getStringOrNull(pi->data());
case Sheet:
- return getDOMStyleSheet(exec,static_cast<DOM::ProcessingInstruction>(node).sheet());
+ return getDOMStyleSheet(exec,pi->sheet());
default:
kdWarning() << "DOMProcessingInstruction::getValueProperty unhandled token " << token << endl;
return Value();
void DOMProcessingInstruction::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr)
{
+ ProcessingInstructionImpl *pi = static_cast<ProcessingInstructionImpl *>(impl());
+ DOMExceptionTranslator exception(exec);
// Not worth using the hashtable for this one ;)
if (propertyName == "data")
- static_cast<DOM::ProcessingInstruction>(node).setData(value.toString(exec).string());
+ pi->setData(value.toString(exec).string(), exception);
else
- DOMNode::tryPut(exec, propertyName,value,attr);
+ DOMNode::tryPut(exec, propertyName, value, attr);
}
// -------------------------------------------------------------------------
systemId DOMNotation::SystemId DontDelete|ReadOnly
@end
*/
+
+DOMNotation::DOMNotation(ExecState *exec, NotationImpl *n)
+ : DOMNode(exec, n)
+{
+}
+
Value DOMNotation::tryGet(ExecState *exec, const Identifier &propertyName) const
{
return DOMObjectLookupGetValue<DOMNotation, DOMNode>(exec, propertyName, &DOMNotationTable, this);
{
switch (token) {
case PublicId:
- return getStringOrNull(static_cast<DOM::Notation>(node).publicId());
+ return getStringOrNull(static_cast<NotationImpl *>(impl())->publicId());
case SystemId:
- return getStringOrNull(static_cast<DOM::Notation>(node).systemId());
+ return getStringOrNull(static_cast<NotationImpl *>(impl())->systemId());
default:
kdWarning() << "DOMNotation::getValueProperty unhandled token " << token << endl;
return Value();
notationName DOMEntity::NotationName DontDelete|ReadOnly
@end
*/
+
+DOMEntity::DOMEntity(ExecState *exec, EntityImpl *e)
+ : DOMNode(exec, e)
+{
+}
+
Value DOMEntity::tryGet(ExecState *exec, const Identifier &propertyName) const
{
return DOMObjectLookupGetValue<DOMEntity, DOMNode>(exec, propertyName, &DOMEntityTable, this);
{
switch (token) {
case PublicId:
- return getStringOrNull(static_cast<DOM::Entity>(node).publicId());
+ return getStringOrNull(static_cast<EntityImpl *>(impl())->publicId());
case SystemId:
- return getStringOrNull(static_cast<DOM::Entity>(node).systemId());
+ return getStringOrNull(static_cast<EntityImpl *>(impl())->systemId());
case NotationName:
- return getStringOrNull(static_cast<DOM::Entity>(node).notationName());
+ return getStringOrNull(static_cast<EntityImpl *>(impl())->notationName());
default:
kdWarning() << "DOMEntity::getValueProperty unhandled token " << token << endl;
return Value();
// -------------------------------------------------------------------------
-Value KJS::getDOMDocumentNode(ExecState *exec, const DOM::Document &n)
+ValueImp *getDOMDocumentNode(ExecState *exec, DocumentImpl *n)
{
DOMDocument *ret = 0;
ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
- if ((ret = static_cast<DOMDocument *>(interp->getDOMObject(n.handle()))))
- return Value(ret);
+ if ((ret = static_cast<DOMDocument *>(interp->getDOMObject(n))))
+ return ret;
- if (n.isHTMLDocument())
- ret = new HTMLDocument(exec, static_cast<DOM::HTMLDocument>(n));
+ if (n->isHTMLDocument())
+ ret = new HTMLDocument(exec, static_cast<HTMLDocumentImpl *>(n));
else
ret = new DOMDocument(exec, n);
- Value val(ret);
-
// Make sure the document is kept around by the window object, and works right with the
// back/forward cache.
- if (n.view()) {
+ if (n->view()) {
static Identifier documentIdentifier("document");
- Window::retrieveWindow(n.view()->part())->putDirect(documentIdentifier, ret, DontDelete|ReadOnly);
+ Window::retrieveWindow(n->view()->part())->putDirect(documentIdentifier, ret, DontDelete|ReadOnly);
}
- interp->putDOMObject(n.handle(), ret);
+ interp->putDOMObject(n, ret);
- return val;
+ return ret;
}
-bool KJS::checkNodeSecurity(ExecState *exec, const DOM::Node& n)
+bool checkNodeSecurity(ExecState *exec, NodeImpl *n)
{
- if (!n.handle())
+ if (!n)
return false;
// Check to see if the currently executing interpreter is allowed to access the specified node
- KHTMLPart *part = n.handle()->getDocument()->part();
- Window* win = part ? Window::retrieveWindow(part) : 0L;
- if ( !win || !win->isSafeScript(exec) )
+ KHTMLPart *part = n->getDocument()->part();
+ if (!part)
return false;
- return true;
+ Window *win = Window::retrieveWindow(part);
+ return win && win->isSafeScript(exec);
}
-
-Value KJS::getDOMNode(ExecState *exec, const DOM::Node &n)
+ValueImp *getDOMNode(ExecState *exec, NodeImpl *n)
{
DOMObject *ret = 0;
- if (n.isNull())
+ if (!n)
return Null();
ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
- DOM::NodeImpl *doc = n.ownerDocument().handle();
+ DocumentImpl *doc = n->getDocument();
- if ((ret = interp->getDOMObjectForDocument(static_cast<DOM::DocumentImpl *>(doc), n.handle())))
- return Value(ret);
+ if ((ret = interp->getDOMObjectForDocument(doc, n)))
+ return ret;
- switch (n.nodeType()) {
+ switch (n->nodeType()) {
case DOM::Node::ELEMENT_NODE:
- if (static_cast<DOM::Element>(n).isHTMLElement())
- ret = new HTMLElement(exec, static_cast<DOM::HTMLElement>(n));
+ if (n->isHTMLElement())
+ ret = new HTMLElement(exec, static_cast<HTMLElementImpl *>(n));
else
- ret = new DOMElement(exec, static_cast<DOM::Element>(n));
+ ret = new DOMElement(exec, static_cast<ElementImpl *>(n));
break;
case DOM::Node::ATTRIBUTE_NODE:
- ret = new DOMAttr(exec, static_cast<DOM::Attr>(n));
+ ret = new DOMAttr(exec, static_cast<AttrImpl *>(n));
break;
case DOM::Node::TEXT_NODE:
case DOM::Node::CDATA_SECTION_NODE:
- ret = new DOMText(exec, static_cast<DOM::Text>(n));
- break;
- case DOM::Node::ENTITY_REFERENCE_NODE:
- ret = new DOMNode(exec, n);
+ ret = new DOMText(exec, static_cast<TextImpl *>(n));
break;
case DOM::Node::ENTITY_NODE:
- ret = new DOMEntity(exec, static_cast<DOM::Entity>(n));
+ ret = new DOMEntity(exec, static_cast<EntityImpl *>(n));
break;
case DOM::Node::PROCESSING_INSTRUCTION_NODE:
- ret = new DOMProcessingInstruction(exec, static_cast<DOM::ProcessingInstruction>(n));
+ ret = new DOMProcessingInstruction(exec, static_cast<ProcessingInstructionImpl *>(n));
break;
case DOM::Node::COMMENT_NODE:
- ret = new DOMCharacterData(exec, static_cast<DOM::CharacterData>(n));
+ ret = new DOMCharacterData(exec, static_cast<CharacterDataImpl *>(n));
break;
case DOM::Node::DOCUMENT_NODE:
// we don't want to cache the document itself in the per-document dictionary
- return getDOMDocumentNode(exec, static_cast<DOM::Document>(n));
+ return getDOMDocumentNode(exec, static_cast<DocumentImpl *>(n));
case DOM::Node::DOCUMENT_TYPE_NODE:
- ret = new DOMDocumentType(exec, static_cast<DOM::DocumentType>(n));
- break;
- case DOM::Node::DOCUMENT_FRAGMENT_NODE:
- ret = new DOMNode(exec, n);
+ ret = new DOMDocumentType(exec, static_cast<DocumentTypeImpl *>(n));
break;
case DOM::Node::NOTATION_NODE:
- ret = new DOMNotation(exec, static_cast<DOM::Notation>(n));
+ ret = new DOMNotation(exec, static_cast<NotationImpl *>(n));
break;
+ case DOM::Node::DOCUMENT_FRAGMENT_NODE:
+ case DOM::Node::ENTITY_REFERENCE_NODE:
default:
ret = new DOMNode(exec, n);
}
- interp->putDOMObjectForDocument(static_cast<DOM::DocumentImpl *>(doc), n.handle(), ret);
+ interp->putDOMObjectForDocument(doc, n, ret);
- return Value(ret);
+ return ret;
}
-Value KJS::getDOMNamedNodeMap(ExecState *exec, const DOM::NamedNodeMap &m)
+ValueImp *getDOMNamedNodeMap(ExecState *exec, NamedNodeMapImpl *m)
{
- return Value(cacheDOMObject<DOM::NamedNodeMap, KJS::DOMNamedNodeMap>(exec, m));
+ return cacheDOMObject<NamedNodeMapImpl, DOMNamedNodeMap>(exec, m);
}
-Value KJS::getRuntimeObject(ExecState *exec, const DOM::Node &node)
+ValueImp *getRuntimeObject(ExecState *exec, NodeImpl *n)
{
- DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
+ if (!n)
+ return 0;
- if (!node.isNull()) {
- if (node.handle()->id() == ID_APPLET) {
- DOM::HTMLAppletElementImpl *appletElement = static_cast<DOM::HTMLAppletElementImpl *>(element.handle());
-
- if (appletElement->getAppletInstance()) {
+ switch (n->id()) {
+ case ID_APPLET: {
+ HTMLAppletElementImpl *appletElement = static_cast<HTMLAppletElementImpl *>(n);
+ if (appletElement->getAppletInstance())
// The instance is owned by the applet element.
- RuntimeObjectImp *appletImp = new RuntimeObjectImp(appletElement->getAppletInstance(), false);
- return Value(appletImp);
- }
+ return new RuntimeObjectImp(appletElement->getAppletInstance(), false);
+ break;
}
- else if (node.handle()->id() == ID_EMBED) {
- DOM::HTMLEmbedElementImpl *embedElement = static_cast<DOM::HTMLEmbedElementImpl *>(element.handle());
-
- if (embedElement->getEmbedInstance()) {
- RuntimeObjectImp *runtimeImp = new RuntimeObjectImp(embedElement->getEmbedInstance(), false);
- return Value(runtimeImp);
- }
+ case ID_EMBED: {
+ HTMLEmbedElementImpl *embedElement = static_cast<HTMLEmbedElementImpl *>(n);
+ if (embedElement->getEmbedInstance())
+ return new RuntimeObjectImp(embedElement->getEmbedInstance(), false);
+ break;
}
- else if (node.handle()->id() == ID_OBJECT) {
- DOM::HTMLObjectElementImpl *objectElement = static_cast<DOM::HTMLObjectElementImpl *>(element.handle());
-
- if (objectElement->getObjectInstance()) {
- RuntimeObjectImp *runtimeImp = new RuntimeObjectImp(objectElement->getObjectInstance(), false);
- return Value(runtimeImp);
- }
+ case ID_OBJECT: {
+ HTMLObjectElementImpl *objectElement = static_cast<HTMLObjectElementImpl *>(n);
+ if (objectElement->getObjectInstance())
+ return new RuntimeObjectImp(objectElement->getObjectInstance(), false);
+ break;
}
}
- // If we don't have a runtime object return the a Value that reports isNull() == true.
- return Value();
+ // If we don't have a runtime object return 0.
+ return 0;
}
-Value KJS::getDOMNodeList(ExecState *exec, const DOM::NodeList &l)
+ValueImp *getDOMNodeList(ExecState *exec, NodeListImpl *l)
{
- return Value(cacheDOMObject<DOM::NodeList, KJS::DOMNodeList>(exec, l));
+ return cacheDOMObject<NodeListImpl, DOMNodeList>(exec, l);
}
-Value KJS::getDOMDOMImplementation(ExecState *exec, const DOM::DOMImplementation &i)
+ValueImp *getDOMDOMImplementation(ExecState *exec, DOMImplementationImpl *i)
{
- return Value(cacheDOMObject<DOM::DOMImplementation, KJS::DOMDOMImplementation>(exec, i));
+ return cacheDOMObject<DOMImplementationImpl, DOMDOMImplementation>(exec, i);
}
// -------------------------------------------------------------------------
#endif
}
-Object KJS::getNodeConstructor(ExecState *exec)
+ObjectImp *getNodeConstructor(ExecState *exec)
{
- return Object(cacheGlobalObject<NodeConstructor>(exec, "[[node.constructor]]"));
+ return cacheGlobalObject<NodeConstructor>(exec, "[[node.constructor]]");
}
// -------------------------------------------------------------------------
#endif
}
-Object KJS::getDOMExceptionConstructor(ExecState *exec)
+ObjectImp *getDOMExceptionConstructor(ExecState *exec)
{
return cacheGlobalObject<DOMExceptionConstructor>(exec, "[[DOMException.constructor]]");
}
// Such a collection is usually very short-lived, it only exists
// for constructs like document.forms.<name>[1],
// so it shouldn't be a problem that it's storing all the nodes (with the same name). (David)
-DOMNamedNodesCollection::DOMNamedNodesCollection(ExecState *, const QValueList<DOM::Node>& nodes )
+DOMNamedNodesCollection::DOMNamedNodesCollection(ExecState *, const QValueList< SharedPtr<NodeImpl> >& nodes )
: m_nodes(nodes)
{
- // Maybe we should ref (and deref in the dtor) the nodes, though ?
}
Value DOMNamedNodesCollection::tryGet(ExecState *exec, const Identifier &propertyName) const
bool ok;
unsigned int u = propertyName.toULong(&ok);
if (ok && u < m_nodes.count()) {
- DOM::Node node = m_nodes[u];
- return getDOMNode(exec,node);
+ return getDOMNode(exec, m_nodes[u].get());
}
// For IE compatibility, we need to be able to look up elements in a
// document.formName.name result by id as well as be index.
if (!ok) {
- for (QValueListConstIterator<DOM::Node> it = m_nodes.begin(); it != m_nodes.end(); it++) {
- DOM::Node node = *it;
- DOM::NamedNodeMap attributes = node.attributes();
- if (attributes.isNull()) {
+ QValueListConstIterator< SharedPtr<NodeImpl> > end = m_nodes.end();
+ for (QValueListConstIterator< SharedPtr<NodeImpl> > it = m_nodes.begin(); it != end; it++) {
+ NodeImpl *node = (*it).get();
+ NamedNodeMapImpl *attributes = node->attributes();
+ if (!attributes) {
continue;
}
- DOM::Node idAttr = attributes.getNamedItem("id");
- if (idAttr.isNull()) {
+ NodeImpl *idAttr = attributes->getNamedItem("id");
+ if (!idAttr) {
continue;
}
- if (idAttr.nodeValue() == propertyName.string()) {
+ if (idAttr->nodeValue() == propertyName.string()) {
return getDOMNode(exec,node);
}
}
IMPLEMENT_PROTOFUNC(DOMCharacterDataProtoFunc)
IMPLEMENT_PROTOTYPE_WITH_PARENT(DOMCharacterDataProto,DOMCharacterDataProtoFunc, DOMNodeProto)
-DOMCharacterData::DOMCharacterData(ExecState *exec, const DOM::CharacterData &d)
+DOMCharacterData::DOMCharacterData(ExecState *exec, CharacterDataImpl *d)
: DOMNode(d)
{
setPrototype(DOMCharacterDataProto::self(exec));
}
-DOMCharacterData::DOMCharacterData(const DOM::CharacterData &d)
+DOMCharacterData::DOMCharacterData(CharacterDataImpl *d)
: DOMNode(d)
{
}
Value DOMCharacterData::getValueProperty(ExecState *, int token) const
{
- DOM::CharacterData data = static_cast<DOM::CharacterData>(node);
+ CharacterDataImpl &data = *static_cast<CharacterDataImpl *>(impl());
switch (token) {
case Data:
return String(data.data());
case Length:
return Number(data.length());
- default:
- kdWarning() << "Unhandled token in DOMCharacterData::getValueProperty : " << token << endl;
- return Value();
+ default:
+ kdWarning() << "Unhandled token in DOMCharacterData::getValueProperty : " << token << endl;
+ return Value();
}
}
void DOMCharacterData::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr)
{
+ DOMExceptionTranslator exception(exec);
if (propertyName == "data")
- static_cast<DOM::CharacterData>(node).setData(value.toString(exec).string());
+ static_cast<CharacterDataImpl *>(impl())->setData(value.toString(exec).string(), exception);
else
DOMNode::tryPut(exec, propertyName,value,attr);
}
exec->setException(err);
return err;
}
- DOM::CharacterData data = static_cast<DOMCharacterData *>(thisObj.imp())->toData();
+ DOMExceptionTranslator exception(exec);
+ CharacterDataImpl &data = *static_cast<CharacterDataImpl *>(static_cast<DOMCharacterData *>(thisObj.imp())->impl());
switch(id) {
case DOMCharacterData::SubstringData: {
const int count = args[1].toInt32(exec);
if (count < 0)
- throw DOMException(DOMException::INDEX_SIZE_ERR);
- return getStringOrNull(data.substringData(args[0].toInt32(exec), count));
+ setDOMException(exec, DOMException::INDEX_SIZE_ERR);
+ else
+ return getStringOrNull(data.substringData(args[0].toInt32(exec), count, exception));
}
case DOMCharacterData::AppendData:
- data.appendData(args[0].toString(exec).string());
+ data.appendData(args[0].toString(exec).string(), exception);
return Undefined();
case DOMCharacterData::InsertData:
- data.insertData(args[0].toInt32(exec), args[1].toString(exec).string());
+ data.insertData(args[0].toInt32(exec), args[1].toString(exec).string(), exception);
return Undefined();
case DOMCharacterData::DeleteData: {
const int count = args[1].toInt32(exec);
if (count < 0)
- throw DOMException(DOMException::INDEX_SIZE_ERR);
- data.deleteData(args[0].toInt32(exec), count);
+ setDOMException(exec, DOMException::INDEX_SIZE_ERR);
+ else
+ data.deleteData(args[0].toInt32(exec), count, exception);
return Undefined();
}
case DOMCharacterData::ReplaceData: {
const int count = args[1].toInt32(exec);
if (count < 0)
- throw DOMException(DOMException::INDEX_SIZE_ERR);
- data.replaceData(args[0].toInt32(exec), count, args[2].toString(exec).string());
+ setDOMException(exec, DOMException::INDEX_SIZE_ERR);
+ else
+ data.replaceData(args[0].toInt32(exec), count, args[2].toString(exec).string(), exception);
return Undefined();
}
default:
IMPLEMENT_PROTOFUNC(DOMTextProtoFunc)
IMPLEMENT_PROTOTYPE_WITH_PARENT(DOMTextProto,DOMTextProtoFunc,DOMCharacterDataProto)
-DOMText::DOMText(ExecState *exec, const DOM::Text &t)
+DOMText::DOMText(ExecState *exec, TextImpl *t)
: DOMCharacterData(t)
{
setPrototype(DOMTextProto::self(exec));
exec->setException(err);
return err;
}
- DOM::Text text = static_cast<DOMText *>(thisObj.imp())->toText();
+ DOMExceptionTranslator exception(exec);
+ TextImpl &text = *static_cast<TextImpl *>(static_cast<DOMText *>(thisObj.imp())->impl());
switch(id) {
case DOMText::SplitText:
- return getDOMNode(exec,text.splitText(args[0].toInt32(exec)));
+ return getDOMNode(exec, text.splitText(args[0].toInt32(exec), exception));
}
return Undefined();
}
+} // namespace
#ifndef _KJS_DOM_H_
#define _KJS_DOM_H_
-#include "dom/dom_node.h"
-#include "dom/dom_doc.h"
-#include "dom/dom_element.h"
-#include "dom/dom_xml.h"
+#include "kjs_binding.h"
-#include "ecma/kjs_binding.h"
+#include <qvaluelist.h>
+#include "misc/shared.h"
-#include "qvaluelist.h"
+namespace DOM {
+ class AttrImpl;
+ class CharacterDataImpl;
+ class DocumentTypeImpl;
+ class DOMImplementationImpl;
+ class ElementImpl;
+ class EntityImpl;
+ class NamedNodeMapImpl;
+ class NodeImpl;
+ class NodeListImpl;
+ class NotationImpl;
+ class ProcessingInstructionImpl;
+ class TextImpl;
+};
namespace KJS {
class DOMNode : public DOMObject {
public:
- // Build a DOMNode
- DOMNode(ExecState *exec, const DOM::Node &n);
- // Constructor for inherited classes
- DOMNode(const DOM::Node &n);
+ DOMNode(ExecState *exec, DOM::NodeImpl *n);
virtual bool toBoolean(ExecState *) const;
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
void putValue(ExecState *exec, int token, const Value& value, int attr);
- virtual DOM::Node toNode() const { return node; }
+ DOM::NodeImpl *impl() const { return m_impl.get(); }
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
virtual Value toPrimitive(ExecState *exec, Type preferred = UndefinedType) const;
virtual UString toString(ExecState *exec) const;
- void setListener(ExecState *exec, int eventId, Value func) const;
+ void setListener(ExecState *exec, int eventId, ValueImp *func) const;
Value getListener(int eventId) const;
virtual void pushEventHandlerScope(ExecState *exec, ScopeChain &scope) const;
ClientWidth, ClientHeight, ScrollLeft, ScrollTop, ScrollWidth, ScrollHeight };
protected:
- DOM::Node node;
+ // Constructor for inherited classes; doesn't set up a prototype.
+ DOMNode(DOM::NodeImpl *n);
+ khtml::SharedPtr<DOM::NodeImpl> m_impl;
};
+ DOM::NodeImpl *toNode(ValueImp *); // returns 0 if passed-in value is not a DOMNode object
+
class DOMNodeList : public DOMObject {
public:
- DOMNodeList(ExecState *, const DOM::NodeList &l) : list(l) { }
+ DOMNodeList(ExecState *, DOM::NodeListImpl *l) : m_impl(l) { }
~DOMNodeList();
virtual bool hasProperty(ExecState *exec, const Identifier &p) const;
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
virtual const ClassInfo* classInfo() const { return &info; }
virtual bool toBoolean(ExecState *) const { return true; }
static const ClassInfo info;
- DOM::NodeList nodeList() const { return list; }
+ DOM::NodeListImpl *impl() const { return m_impl.get(); }
virtual Value toPrimitive(ExecState *exec, Type preferred = UndefinedType) const;
private:
- DOM::NodeList list;
- };
-
- class DOMNodeListFunc : public DOMFunction {
- friend class DOMNodeList;
- public:
- DOMNodeListFunc(ExecState *exec, int id, int len);
- virtual Value tryCall(ExecState *exec, Object &thisObj, const List &);
- enum { Item };
- private:
- int id;
+ khtml::SharedPtr<DOM::NodeListImpl> m_impl;
};
class DOMDocument : public DOMNode {
public:
- // Build a DOMDocument
- DOMDocument(ExecState *exec, const DOM::Document &d);
- // Constructor for inherited classes
- DOMDocument(const DOM::Document &d);
+ DOMDocument(ExecState *exec, DOM::DocumentImpl *d);
~DOMDocument();
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
SelectedStylesheetSet, GetOverrideStyle, ReadyState,
ExecCommand, QueryCommandEnabled, QueryCommandIndeterm, QueryCommandState,
QueryCommandSupported, QueryCommandValue };
+
+ protected:
+ // Constructor for inherited classes; doesn't set up a prototype.
+ DOMDocument(DOM::DocumentImpl *d);
};
class DOMAttr : public DOMNode {
public:
- DOMAttr(ExecState *exec, const DOM::Attr &a) : DOMNode(exec, a) { }
+ DOMAttr(ExecState *exec, DOM::AttrImpl *a);
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
Value getValueProperty(ExecState *exec, int token) const;
enum { Name, Specified, ValueProperty, OwnerElement };
};
+ DOM::AttrImpl *toAttr(ValueImp *); // returns 0 if passed-in value is not a DOMAttr object
+
class DOMElement : public DOMNode {
public:
- // Build a DOMElement
- DOMElement(ExecState *exec, const DOM::Element &e);
- // Constructor for inherited classes
- DOMElement(const DOM::Element &e);
+ DOMElement(ExecState *exec, DOM::ElementImpl *e);
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
GetAttributeNS, SetAttributeNS, RemoveAttributeNS, GetAttributeNodeNS,
SetAttributeNodeNS, GetElementsByTagNameNS, HasAttribute, HasAttributeNS,
ScrollByLines, ScrollByPages};
+ protected:
+ // Constructor for inherited classes; doesn't set up a prototype.
+ DOMElement(DOM::ElementImpl *e);
};
+ DOM::ElementImpl *toElement(ValueImp *); // returns 0 if passed-in value is not a DOMElement object
+
class DOMDOMImplementation : public DOMObject {
public:
// Build a DOMDOMImplementation
- DOMDOMImplementation(ExecState *, const DOM::DOMImplementation &i);
+ DOMDOMImplementation(ExecState *, DOM::DOMImplementationImpl *i);
~DOMDOMImplementation();
// no put - all functions
virtual const ClassInfo* classInfo() const { return &info; }
virtual bool toBoolean(ExecState *) const { return true; }
static const ClassInfo info;
enum { HasFeature, CreateDocumentType, CreateDocument, CreateCSSStyleSheet, CreateHTMLDocument };
- DOM::DOMImplementation toImplementation() const { return implementation; }
+ DOM::DOMImplementationImpl *impl() const { return m_impl.get(); }
private:
- DOM::DOMImplementation implementation;
+ khtml::SharedPtr<DOM::DOMImplementationImpl> m_impl;
};
class DOMDocumentType : public DOMNode {
public:
- // Build a DOMDocumentType
- DOMDocumentType(ExecState *exec, const DOM::DocumentType &dt);
+ DOMDocumentType(ExecState *exec, DOM::DocumentTypeImpl *dt);
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
// no put - all read-only
enum { Name, Entities, Notations, PublicId, SystemId, InternalSubset };
};
+ DOM::DocumentTypeImpl *toDocumentType(ValueImp *); // returns 0 if passed-in value is not a DOMDocumentType object
+
class DOMNamedNodeMap : public DOMObject {
public:
- DOMNamedNodeMap(ExecState *, const DOM::NamedNodeMap &m);
+ DOMNamedNodeMap(ExecState *, DOM::NamedNodeMapImpl *m);
~DOMNamedNodeMap();
virtual bool hasProperty(ExecState *exec, const Identifier &p) const;
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
static const ClassInfo info;
enum { GetNamedItem, SetNamedItem, RemoveNamedItem, Item,
GetNamedItemNS, SetNamedItemNS, RemoveNamedItemNS };
- DOM::NamedNodeMap toMap() const { return map; }
+ DOM::NamedNodeMapImpl *impl() const { return m_impl.get(); }
private:
- DOM::NamedNodeMap map;
+ khtml::SharedPtr<DOM::NamedNodeMapImpl> m_impl;
};
class DOMProcessingInstruction : public DOMNode {
public:
- DOMProcessingInstruction(ExecState *exec, const DOM::ProcessingInstruction &pi) : DOMNode(exec, pi) { }
+ DOMProcessingInstruction(ExecState *exec, DOM::ProcessingInstructionImpl *pi);
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
class DOMNotation : public DOMNode {
public:
- DOMNotation(ExecState *exec, const DOM::Notation &n) : DOMNode(exec, n) { }
+ DOMNotation(ExecState *exec, DOM::NotationImpl *n);
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
// no put - all read-only
class DOMEntity : public DOMNode {
public:
- DOMEntity(ExecState *exec, const DOM::Entity &e) : DOMNode(exec, e) { }
+ DOMEntity(ExecState *exec, DOM::EntityImpl *e);
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
// no put - all read-only
static const ClassInfo info;
};
- Value getDOMDocumentNode(ExecState *exec, const DOM::Document &n);
- bool checkNodeSecurity(ExecState *exec, const DOM::Node& n);
-#if APPLE_CHANGES
- Value getRuntimeObject(ExecState *exec, const DOM::Node &n);
-#endif
- Value getDOMNode(ExecState *exec, const DOM::Node &n);
- Value getDOMNamedNodeMap(ExecState *exec, const DOM::NamedNodeMap &m);
- Value getDOMNodeList(ExecState *exec, const DOM::NodeList &l);
- Value getDOMDOMImplementation(ExecState *exec, const DOM::DOMImplementation &i);
- Object getNodeConstructor(ExecState *exec);
- Object getDOMExceptionConstructor(ExecState *exec);
+ ValueImp *getDOMDocumentNode(ExecState *exec, DOM::DocumentImpl *n);
+ bool checkNodeSecurity(ExecState *exec, DOM::NodeImpl *n);
+ ValueImp *getRuntimeObject(ExecState *exec, DOM::NodeImpl *n);
+ ValueImp *getDOMNode(ExecState *exec, DOM::NodeImpl *n);
+ ValueImp *getDOMNamedNodeMap(ExecState *exec, DOM::NamedNodeMapImpl *m);
+ ValueImp *getDOMNodeList(ExecState *exec, DOM::NodeListImpl *l);
+ ValueImp *getDOMDOMImplementation(ExecState *exec, DOM::DOMImplementationImpl *i);
+ ObjectImp *getNodeConstructor(ExecState *exec);
+ ObjectImp *getDOMExceptionConstructor(ExecState *exec);
// Internal class, used for the collection return by e.g. document.forms.myinput
// when multiple nodes have the same name.
class DOMNamedNodesCollection : public DOMObject {
public:
- DOMNamedNodesCollection(ExecState *exec, const QValueList<DOM::Node>& nodes );
+ DOMNamedNodesCollection(ExecState *exec, const QValueList< khtml::SharedPtr<DOM::NodeImpl> >& nodes );
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
private:
- QValueList<DOM::Node> m_nodes;
+ QValueList< khtml::SharedPtr<DOM::NodeImpl> > m_nodes;
};
class DOMCharacterData : public DOMNode {
public:
- // Build a DOMCharacterData
- DOMCharacterData(ExecState *exec, const DOM::CharacterData &d);
- // Constructor for inherited classes
- DOMCharacterData(const DOM::CharacterData &d);
+ DOMCharacterData(ExecState *exec, DOM::CharacterDataImpl *d);
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
Value getValueProperty(ExecState *, int token) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
- DOM::CharacterData toData() const { return static_cast<DOM::CharacterData>(node); }
+ DOM::CharacterDataImpl *toData() const;
enum { Data, Length,
SubstringData, AppendData, InsertData, DeleteData, ReplaceData };
+ protected:
+ // Constructor for inherited classes; doesn't set up a prototype.
+ DOMCharacterData(DOM::CharacterDataImpl *d);
};
class DOMText : public DOMCharacterData {
public:
- DOMText(ExecState *exec, const DOM::Text &t);
+ DOMText(ExecState *exec, DOM::TextImpl *t);
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
Value getValueProperty(ExecState *, int token) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
- DOM::Text toText() const { return static_cast<DOM::Text>(node); }
+ DOM::TextImpl *toText() const;
enum { SplitText };
};
-}; // namespace
+} // namespace
#endif
#include "xml/dom_nodeimpl.h"
#include "xml/dom_docimpl.h"
#include "xml/dom2_eventsimpl.h"
+#include "xml/dom2_viewsimpl.h"
#include "rendering/render_object.h"
#include "misc/loader.h"
#include <kdebug.h>
-using namespace KJS;
-
+using DOM::ClipboardEventImpl;
using DOM::DocumentImpl;
using DOM::EventImpl;
-using DOM::KeyboardEvent;
+using DOM::EventListenerEvent;
+using DOM::KeyboardEventImpl;
+using DOM::MouseEventImpl;
+using DOM::UIEventImpl;
+using DOM::MutationEventImpl;
using DOM::MouseRelatedEventImpl;
using DOM::NodeImpl;
+using DOM::WheelEventImpl;
using khtml::RenderObject;
+namespace KJS {
+
// -------------------------------------------------------------------------
JSAbstractEventListener::JSAbstractEventListener(bool _html)
{
}
-void JSAbstractEventListener::handleEvent(DOM::Event &evt, bool isWindowEvent)
+void JSAbstractEventListener::handleEvent(EventListenerEvent ele, bool isWindowEvent)
{
#ifdef KJS_DEBUGGER
if (KJSDebugWin::instance() && KJSDebugWin::instance()->inSession())
return;
#endif
+
+#if KHTML_NO_CPLUSPLUS_DOM
+ EventImpl *evt = ele;
+#else
+ EventImpl *evt = ele.handle();
+#endif
+
Object listener = listenerObj();
Object win = windowObj();
Window *window = static_cast<Window*>(win.imp());
// Set the event we're handling in the Window object
- window->setCurrentEvent( &evt );
+ window->setCurrentEvent(evt);
// ... and in the interpreter
- interpreter->setCurrentEvent( &evt );
+ interpreter->setCurrentEvent(evt);
Object thisObj;
if (isWindowEvent) {
thisObj = win;
} else {
KJS::Interpreter::lock();
- thisObj = Object::dynamicCast(getDOMNode(exec,evt.currentTarget()));
+ thisObj = Object::dynamicCast(getDOMNode(exec, evt->currentTarget()));
KJS::Interpreter::unlock();
}
{
QVariant ret = ValueToVariant(exec, retval);
if (ret.type() == QVariant::Bool && ret.toBool() == false)
- evt.preventDefault();
+ evt->preventDefault();
}
DOM::DocumentImpl::updateDocumentsRendering();
deref();
originalNode = _originalNode;
}
-void JSLazyEventListener::handleEvent(DOM::Event &evt, bool isWindowEvent)
+void JSLazyEventListener::handleEvent(EventListenerEvent evt, bool isWindowEvent)
{
parseCode();
if (!listener.isNull()) {
}
}
-Value KJS::getNodeEventListener(DOM::Node n, int eventId)
+ValueImp *getNodeEventListener(NodeImpl *n, int eventId)
{
- DOM::EventListener *listener = n.handle()->getHTMLEventListener(eventId);
- JSEventListener *jsListener = static_cast<JSEventListener*>(listener);
- if ( jsListener && jsListener->listenerObjImp() )
- return jsListener->listenerObj();
- else
- return Null();
+ JSAbstractEventListener *listener = static_cast<JSAbstractEventListener *>(n->getHTMLEventListener(eventId));
+ if (listener)
+ if (ValueImp *obj = listener->listenerObjImp())
+ return obj;
+ return null();
}
-
-
// -------------------------------------------------------------------------
const ClassInfo EventConstructor::info = { "EventConstructor", 0, &EventConstructorTable, 0 };
IMPLEMENT_PROTOFUNC(DOMEventProtoFunc)
IMPLEMENT_PROTOTYPE(DOMEventProto, DOMEventProtoFunc)
-DOMEvent::DOMEvent(ExecState *exec, DOM::Event e)
- : event(e), clipboard(0)
+DOMEvent::DOMEvent(ExecState *exec, EventImpl *e)
+ : m_impl(e), clipboard(0)
{
setPrototype(DOMEventProto::self(exec));
}
DOMEvent::~DOMEvent()
{
- ScriptInterpreter::forgetDOMObject(event.handle());
+ ScriptInterpreter::forgetDOMObject(m_impl.get());
}
// pass marks through to JS objects we hold during garbage collection
Value DOMEvent::getValueProperty(ExecState *exec, int token) const
{
+ EventImpl &event = *m_impl;
switch (token) {
case Type:
return String(event.type());
case Target:
case SrcElement: /*MSIE extension - "the object that fired the event"*/
- return getDOMNode(exec,event.target());
+ return getDOMNode(exec, event.target());
case CurrentTarget:
- return getDOMNode(exec,event.currentTarget());
+ return getDOMNode(exec, event.currentTarget());
case EventPhase:
return Number((unsigned int)event.eventPhase());
case Bubbles:
return Number((long unsigned int)event.timeStamp()); // ### long long ?
case ClipboardData:
{
- DOM::EventImpl *ei = event.handle();
- if (ei->isClipboardEvent()) {
- DOM::ClipboardEventImpl *impl = static_cast<DOM::ClipboardEventImpl *>(event.handle());
+ if (event.isClipboardEvent()) {
+ ClipboardEventImpl *impl = static_cast<ClipboardEventImpl *>(&event);
if (!clipboard) {
clipboard = new Clipboard(exec, impl->clipboard());
}
}
case DataTransfer:
{
- DOM::EventImpl *ei = event.handle();
- if (ei->isDragEvent()) {
- DOM::MouseEventImpl *impl = static_cast<DOM::MouseEventImpl *>(event.handle());
+ if (event.isDragEvent()) {
+ MouseEventImpl *impl = static_cast<MouseEventImpl *>(&event);
if (!clipboard) {
clipboard = new Clipboard(exec, impl->clipboard());
}
void DOMEvent::putValue(ExecState *exec, int token, const Value& value, int)
{
+ EventImpl &event = *m_impl;
switch (token) {
case ReturnValue:
event.setDefaultPrevented(!value.toBoolean(exec));
exec->setException(err);
return err;
}
- DOM::Event event = static_cast<DOMEvent *>( thisObj.imp() )->toEvent();
+ EventImpl &event = *static_cast<DOMEvent *>( thisObj.imp() )->impl();
switch (id) {
case DOMEvent::StopPropagation:
event.stopPropagation();
return Undefined();
}
-Value KJS::getDOMEvent(ExecState *exec, DOM::Event e)
+ValueImp *getDOMEvent(ExecState *exec, EventImpl *e)
{
- DOM::EventImpl *ei = e.handle();
- if (!ei)
+ if (!e)
return Null();
ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
KJS::Interpreter::lock();
- DOMObject *ret = interp->getDOMObject(ei);
+ DOMObject *ret = interp->getDOMObject(e);
if (!ret) {
- if (ei->isKeyboardEvent())
- ret = new DOMKeyboardEvent(exec, e);
- else if (ei->isMouseEvent())
- ret = new DOMMouseEvent(exec, e);
- else if (ei->isWheelEvent())
- ret = new DOMWheelEvent(exec, static_cast<DOM::WheelEventImpl *>(ei));
- else if (ei->isUIEvent())
- ret = new DOMUIEvent(exec, e);
- else if (ei->isMutationEvent())
- ret = new DOMMutationEvent(exec, e);
+ if (e->isKeyboardEvent())
+ ret = new DOMKeyboardEvent(exec, static_cast<KeyboardEventImpl *>(e));
+ else if (e->isMouseEvent())
+ ret = new DOMMouseEvent(exec, static_cast<MouseEventImpl *>(e));
+ else if (e->isWheelEvent())
+ ret = new DOMWheelEvent(exec, static_cast<WheelEventImpl *>(e));
+ else if (e->isUIEvent())
+ ret = new DOMUIEvent(exec, static_cast<UIEventImpl *>(e));
+ else if (e->isMutationEvent())
+ ret = new DOMMutationEvent(exec, static_cast<MutationEventImpl *>(e));
else
ret = new DOMEvent(exec, e);
- interp->putDOMObject(ei, ret);
+ interp->putDOMObject(e, ret);
}
KJS::Interpreter::unlock();
- return Value(ret);
+ return ret;
}
-DOM::Event KJS::toEvent(const Value& val)
+EventImpl *toEvent(ValueImp *val)
{
- Object obj = Object::dynamicCast(val);
- if (obj.isNull() || !obj.inherits(&DOMEvent::info))
- return DOM::Event();
-
- const DOMEvent *dobj = static_cast<const DOMEvent*>(obj.imp());
- return dobj->toEvent();
+ if (!val || !val->isObject(&DOMNode::info))
+ return 0;
+ return static_cast<DOMEvent *>(val)->impl();
}
// -------------------------------------------------------------------------
IMPLEMENT_PROTOFUNC(DOMUIEventProtoFunc)
IMPLEMENT_PROTOTYPE_WITH_PARENT(DOMUIEventProto,DOMUIEventProtoFunc,DOMEventProto)
+DOMUIEvent::DOMUIEvent(ExecState *exec, UIEventImpl *e)
+ : DOMEvent(exec, e)
+{
+}
+
DOMUIEvent::~DOMUIEvent()
{
}
Value DOMUIEvent::getValueProperty(ExecState *exec, int token) const
{
+ UIEventImpl &event = *static_cast<UIEventImpl *>(impl());
switch (token) {
case View:
- return getDOMAbstractView(exec,static_cast<DOM::UIEvent>(event).view());
+ return getDOMAbstractView(exec, event.view());
case Detail:
- return Number(static_cast<DOM::UIEvent>(event).detail());
+ return Number(event.detail());
case KeyCode:
- return Number(static_cast<DOM::UIEvent>(event).keyCode());
+ return Number(event.keyCode());
case CharCode:
- return Number(static_cast<DOM::UIEvent>(event).charCode());
+ return Number(event.charCode());
case LayerX:
- return Number(static_cast<DOM::UIEvent>(event).layerX());
+ return Number(event.layerX());
case LayerY:
- return Number(static_cast<DOM::UIEvent>(event).layerY());
+ return Number(event.layerY());
case PageX:
- return Number(static_cast<DOM::UIEvent>(event).pageX());
+ return Number(event.pageX());
case PageY:
- return Number(static_cast<DOM::UIEvent>(event).pageY());
+ return Number(event.pageY());
case Which:
- return Number(static_cast<DOM::UIEvent>(event).which());
+ return Number(event.which());
default:
kdWarning() << "Unhandled token in DOMUIEvent::getValueProperty : " << token << endl;
return Undefined();
exec->setException(err);
return err;
}
- DOM::UIEvent uiEvent = static_cast<DOMUIEvent *>(thisObj.imp())->toUIEvent();
+ UIEventImpl &uiEvent = *static_cast<UIEventImpl *>(static_cast<DOMUIEvent *>(thisObj.imp())->impl());
switch (id) {
- case DOMUIEvent::InitUIEvent: {
- DOM::AbstractView v = toAbstractView(args[3]);
- static_cast<DOM::UIEvent>(uiEvent).initUIEvent(args[0].toString(exec).string(),
- args[1].toBoolean(exec),
- args[2].toBoolean(exec),
- v,
- args[4].toInt32(exec));
- }
+ case DOMUIEvent::InitUIEvent:
+ uiEvent.initUIEvent(args[0].toString(exec).string(),
+ args[1].toBoolean(exec),
+ args[2].toBoolean(exec),
+ toAbstractView(args[3]),
+ args[4].toInt32(exec));
return Undefined();
}
return Undefined();
IMPLEMENT_PROTOFUNC(DOMMouseEventProtoFunc)
IMPLEMENT_PROTOTYPE_WITH_PARENT(DOMMouseEventProto,DOMMouseEventProtoFunc,DOMUIEventProto)
+DOMMouseEvent::DOMMouseEvent(ExecState *exec, MouseEventImpl *e)
+ : DOMUIEvent(exec, e)
+{
+}
+
DOMMouseEvent::~DOMMouseEvent()
{
}
Value DOMMouseEvent::getValueProperty(ExecState *exec, int token) const
{
+ MouseEventImpl &event = *static_cast<MouseEventImpl *>(impl());
switch (token) {
case ScreenX:
- return Number(static_cast<DOM::MouseEvent>(event).screenX());
+ return Number(event.screenX());
case ScreenY:
- return Number(static_cast<DOM::MouseEvent>(event).screenY());
+ return Number(event.screenY());
case ClientX:
case X:
- return Number(static_cast<DOM::MouseEvent>(event).clientX());
+ return Number(event.clientX());
case ClientY:
case Y:
- return Number(static_cast<DOM::MouseEvent>(event).clientY());
+ return Number(event.clientY());
case OffsetX: // MSIE extension
- return Number(offsetFromTarget(static_cast<MouseRelatedEventImpl *>(event.handle())).x());
+ return Number(offsetFromTarget(&event).x());
case OffsetY: // MSIE extension
- return Number(offsetFromTarget(static_cast<MouseRelatedEventImpl *>(event.handle())).y());
+ return Number(offsetFromTarget(&event).y());
case CtrlKey:
- return Boolean(static_cast<DOM::MouseEvent>(event).ctrlKey());
+ return Boolean(event.ctrlKey());
case ShiftKey:
- return Boolean(static_cast<DOM::MouseEvent>(event).shiftKey());
+ return Boolean(event.shiftKey());
case AltKey:
- return Boolean(static_cast<DOM::MouseEvent>(event).altKey());
+ return Boolean(event.altKey());
case MetaKey:
- return Boolean(static_cast<DOM::MouseEvent>(event).metaKey());
+ return Boolean(event.metaKey());
case Button:
{
// Tricky. The DOM (and khtml) use 0 for LMB, 1 for MMB and 2 for RMB
// but MSIE uses 1=LMB, 2=RMB, 4=MMB, as a bitfield
- int domButton = static_cast<DOM::MouseEvent>(event).button();
+ int domButton = event.button();
int button = domButton==0 ? 1 : domButton==1 ? 4 : domButton==2 ? 2 : 0;
return Number( (unsigned int)button );
}
case ToElement:
// MSIE extension - "the object toward which the user is moving the mouse pointer"
- if (event.handle()->id() == DOM::EventImpl::MOUSEOUT_EVENT)
- return getDOMNode(exec,static_cast<DOM::MouseEvent>(event).relatedTarget());
- return getDOMNode(exec,static_cast<DOM::MouseEvent>(event).target());
+ if (event.id() == DOM::EventImpl::MOUSEOUT_EVENT)
+ return getDOMNode(exec, event.relatedTarget());
+ return getDOMNode(exec,event.target());
case FromElement:
// MSIE extension - "object from which activation
// or the mouse pointer is exiting during the event" (huh?)
- if (event.handle()->id() == DOM::EventImpl::MOUSEOUT_EVENT)
- return getDOMNode(exec,static_cast<DOM::MouseEvent>(event).target());
+ if (event.id() == DOM::EventImpl::MOUSEOUT_EVENT)
+ return getDOMNode(exec, event.target());
/* fall through */
case RelatedTarget:
- return getDOMNode(exec,static_cast<DOM::MouseEvent>(event).relatedTarget());
+ return getDOMNode(exec, event.relatedTarget());
default:
kdWarning() << "Unhandled token in DOMMouseEvent::getValueProperty : " << token << endl;
return Value();
exec->setException(err);
return err;
}
- DOM::MouseEvent mouseEvent = static_cast<DOMMouseEvent *>(thisObj.imp())->toMouseEvent();
+ MouseEventImpl &mouseEvent = *static_cast<MouseEventImpl *>(static_cast<DOMMouseEvent *>(thisObj.imp())->impl());
switch (id) {
case DOMMouseEvent::InitMouseEvent:
mouseEvent.initMouseEvent(args[0].toString(exec).string(), // typeArg
IMPLEMENT_PROTOFUNC(DOMKeyboardEventProtoFunc)
IMPLEMENT_PROTOTYPE_WITH_PARENT(DOMKeyboardEventProto, DOMKeyboardEventProtoFunc, DOMUIEventProto)
+DOMKeyboardEvent::DOMKeyboardEvent(ExecState *exec, KeyboardEventImpl *e)
+ : DOMUIEvent(exec, e)
+{
+}
+
DOMKeyboardEvent::~DOMKeyboardEvent()
{
}
Value DOMKeyboardEvent::getValueProperty(ExecState *exec, int token) const
{
+ KeyboardEventImpl &event = *static_cast<KeyboardEventImpl *>(impl());
switch (token) {
case KeyIdentifier:
- return String(static_cast<KeyboardEvent>(event).keyIdentifier());
+ return String(event.keyIdentifier());
case KeyLocation:
- return Number(static_cast<KeyboardEvent>(event).keyLocation());
+ return Number(event.keyLocation());
case CtrlKey:
- return Boolean(static_cast<KeyboardEvent>(event).ctrlKey());
+ return Boolean(event.ctrlKey());
case ShiftKey:
- return Boolean(static_cast<KeyboardEvent>(event).shiftKey());
+ return Boolean(event.shiftKey());
case AltKey:
- return Boolean(static_cast<KeyboardEvent>(event).altKey());
+ return Boolean(event.altKey());
case MetaKey:
- return Boolean(static_cast<KeyboardEvent>(event).metaKey());
+ return Boolean(event.metaKey());
case AltGraphKey:
- return Boolean(static_cast<KeyboardEvent>(event).altGraphKey());
+ return Boolean(event.altGraphKey());
default:
kdWarning() << "Unhandled token in DOMKeyboardEvent::getValueProperty : " << token << endl;
return Value();
exec->setException(err);
return err;
}
- KeyboardEvent event = static_cast<DOMKeyboardEvent *>(thisObj.imp())->toKeyboardEvent();
+ KeyboardEventImpl &event = *static_cast<KeyboardEventImpl *>(static_cast<DOMUIEvent *>(thisObj.imp())->impl());
switch (id) {
case DOMKeyboardEvent::InitKeyboardEvent:
event.initKeyboardEvent(args[0].toString(exec).string(), // typeArg
IMPLEMENT_PROTOFUNC(DOMMutationEventProtoFunc)
IMPLEMENT_PROTOTYPE_WITH_PARENT(DOMMutationEventProto,DOMMutationEventProtoFunc,DOMEventProto)
+DOMMutationEvent::DOMMutationEvent(ExecState *exec, MutationEventImpl *e)
+ : DOMEvent(exec, e)
+{
+}
+
DOMMutationEvent::~DOMMutationEvent()
{
}
Value DOMMutationEvent::getValueProperty(ExecState *exec, int token) const
{
+ MutationEventImpl &event = *static_cast<MutationEventImpl *>(impl());
switch (token) {
case RelatedNode:
- return getDOMNode(exec,static_cast<DOM::MutationEvent>(event).relatedNode());
+ return getDOMNode(exec, event.relatedNode());
case PrevValue:
- return String(static_cast<DOM::MutationEvent>(event).prevValue());
+ return String(event.prevValue());
case NewValue:
- return String(static_cast<DOM::MutationEvent>(event).newValue());
+ return String(event.newValue());
case AttrName:
- return String(static_cast<DOM::MutationEvent>(event).attrName());
+ return String(event.attrName());
case AttrChange:
- return Number((unsigned int)static_cast<DOM::MutationEvent>(event).attrChange());
+ return Number(event.attrChange());
default:
kdWarning() << "Unhandled token in DOMMutationEvent::getValueProperty : " << token << endl;
return Value();
exec->setException(err);
return err;
}
- DOM::MutationEvent mutationEvent = static_cast<DOMMutationEvent *>(thisObj.imp())->toMutationEvent();
+ MutationEventImpl &mutationEvent = *static_cast<MutationEventImpl *>(static_cast<DOMEvent *>(thisObj.imp())->impl());
switch (id) {
case DOMMutationEvent::InitMutationEvent:
mutationEvent.initMutationEvent(args[0].toString(exec).string(), // typeArg,
IMPLEMENT_PROTOTYPE_WITH_PARENT(DOMWheelEventProto,DOMWheelEventProtoFunc,DOMEventProto)
DOMWheelEvent::DOMWheelEvent(ExecState *exec, DOM::WheelEventImpl *e)
- : DOMUIEvent(exec, DOM::UIEvent(e))
+ : DOMUIEvent(exec, e)
{
}
Value DOMWheelEvent::getValueProperty(ExecState *exec, int token) const
{
- DOM::WheelEventImpl *e = static_cast<DOM::WheelEventImpl *>(event.handle());
+ DOM::WheelEventImpl *e = static_cast<DOM::WheelEventImpl *>(impl());
switch (token) {
case AltKey:
return Boolean(e->altKey());
int y = (int)args[2].toNumber(exec);
// See if they passed us a node
- DOM::Node node = toNode(args[0]);
- if (!node.isNull()) {
- if (node.nodeType() == DOM::Node::ELEMENT_NODE) {
- cb->clipboard->setDragImageElement(node.handle(), QPoint(x,y));
+ NodeImpl *node = toNode(args[0]);
+ if (node) {
+ if (node->isElementNode()) {
+ cb->clipboard->setDragImageElement(node, QPoint(x,y));
return Undefined();
} else {
Object err = Error::create(exec, SyntaxError,"setDragImageFromElement: Invalid first argument");
return Undefined();
}
+}
#ifndef _KJS_EVENTS_H_
#define _KJS_EVENTS_H_
-#include "ecma/kjs_dom.h"
-#include "ecma/kjs_html.h"
+#include "kjs_dom.h"
+#include "kjs_html.h"
+
#include "dom/dom2_events.h"
namespace DOM {
class ClipboardImpl;
+ class EventImpl;
+ class KeyboardEventImpl;
+ class MouseEventImpl;
+ class MutationEventImpl;
+ class UIEventImpl;
class WheelEventImpl;
}
public:
JSAbstractEventListener(bool _html = false);
virtual ~JSAbstractEventListener();
- virtual void handleEvent(DOM::Event &evt, bool isWindowEvent);
+ virtual void handleEvent(DOM::EventListenerEvent evt, bool isWindowEvent);
virtual DOM::DOMString eventListenerType();
virtual Object listenerObj() const = 0;
virtual Object windowObj() const = 0;
class JSLazyEventListener : public JSEventListener {
public:
JSLazyEventListener(QString _code, const Object &_win, DOM::NodeImpl *node, int lineno = 0);
- virtual void handleEvent(DOM::Event &evt, bool isWindowEvent);
+ virtual void handleEvent(DOM::EventListenerEvent evt, bool isWindowEvent);
Object listenerObj() const;
private:
DOM::NodeImpl *originalNode;
};
-
- Value getNodeEventListener(DOM::Node n, int eventId);
+ ValueImp *getNodeEventListener(DOM::NodeImpl *n, int eventId);
// Constructor for Event - currently only used for some global vars
class EventConstructor : public DOMObject {
class DOMEvent : public DOMObject {
public:
- DOMEvent(ExecState *exec, DOM::Event e);
+ DOMEvent(ExecState *exec, DOM::EventImpl *e);
~DOMEvent();
virtual Value tryGet(ExecState *exec,const Identifier &p) const;
Value getValueProperty(ExecState *, int token) const;
Cancelable, TimeStamp, StopPropagation, PreventDefault, InitEvent,
// MS IE equivalents
SrcElement, ReturnValue, CancelBubble, ClipboardData, DataTransfer };
- DOM::Event toEvent() const { return event; }
+ DOM::EventImpl *impl() const { return m_impl.get(); }
protected:
- DOM::Event event;
+ khtml::SharedPtr<DOM::EventImpl> m_impl;
mutable Clipboard *clipboard;
};
- Value getDOMEvent(ExecState *exec, DOM::Event e);
+ ValueImp *getDOMEvent(ExecState *exec, DOM::EventImpl *e);
- /**
- * Convert an object to an Event. Returns a null Event if not possible.
- */
- DOM::Event toEvent(const Value&);
+ DOM::EventImpl *toEvent(ValueImp *); // returns 0 if value is not a DOMEvent object
// Constructor object EventException
class EventExceptionConstructor : public DOMObject {
class DOMUIEvent : public DOMEvent {
public:
- DOMUIEvent(ExecState *exec, DOM::UIEvent ue) : DOMEvent(exec, ue) {}
+ DOMUIEvent(ExecState *exec, DOM::UIEventImpl *ue);
~DOMUIEvent();
virtual Value tryGet(ExecState *exec,const Identifier &p) const;
Value getValueProperty(ExecState *, int token) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { View, Detail, KeyCode, CharCode, LayerX, LayerY, PageX, PageY, Which, InitUIEvent };
- DOM::UIEvent toUIEvent() const { return static_cast<DOM::UIEvent>(event); }
};
class DOMMouseEvent : public DOMUIEvent {
public:
- DOMMouseEvent(ExecState *exec, DOM::MouseEvent me) : DOMUIEvent(exec, me) {}
+ DOMMouseEvent(ExecState *exec, DOM::MouseEventImpl *me);
~DOMMouseEvent();
virtual Value tryGet(ExecState *exec,const Identifier &p) const;
Value getValueProperty(ExecState *, int token) const;
CtrlKey, ShiftKey, AltKey,
MetaKey, Button, RelatedTarget, FromElement, ToElement,
InitMouseEvent };
- DOM::MouseEvent toMouseEvent() const { return static_cast<DOM::MouseEvent>(event); }
};
class DOMKeyboardEvent : public DOMUIEvent {
public:
- DOMKeyboardEvent(ExecState *exec, DOM::KeyboardEvent ke) : DOMUIEvent(exec, ke) {}
+ DOMKeyboardEvent(ExecState *exec, DOM::KeyboardEventImpl *ke);
~DOMKeyboardEvent();
virtual Value tryGet(ExecState *exec, const Identifier &p) const;
Value getValueProperty(ExecState *, int token) const;
virtual const ClassInfo* classInfo() const;
static const ClassInfo info;
enum { KeyIdentifier, KeyLocation, CtrlKey, ShiftKey, AltKey, MetaKey, AltGraphKey, InitKeyboardEvent};
- DOM::KeyboardEvent toKeyboardEvent() const { return event; }
};
// Constructor object MutationEvent
class DOMMutationEvent : public DOMEvent {
public:
- DOMMutationEvent(ExecState *exec, DOM::MutationEvent me) : DOMEvent(exec, me) {}
+ DOMMutationEvent(ExecState *exec, DOM::MutationEventImpl *me);
~DOMMutationEvent();
virtual Value tryGet(ExecState *exec,const Identifier &p) const;
Value getValueProperty(ExecState *, int token) const;
static const ClassInfo info;
enum { AttrChange, RelatedNode, AttrName, PrevValue, NewValue,
InitMutationEvent };
- DOM::MutationEvent toMutationEvent() const { return static_cast<DOM::MutationEvent>(event); }
};
class DOMWheelEvent : public DOMUIEvent {
private:
DOM::ClipboardImpl *clipboard;
};
-
-
-}; // namespace
+
+} // namespace
#endif
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "kjs_html.h"
+
#include "misc/loader.h"
-#include "dom/html_block.h"
-#include "dom/html_head.h"
-#include "dom/html_image.h"
-#include "dom/html_inline.h"
-#include "dom/html_list.h"
-#include "dom/html_table.h"
-#include "dom/html_object.h"
#include "dom/dom_exception.h"
#include "xml/dom2_eventsimpl.h"
-// ### HACK
+#include "xml/dom_textimpl.h"
#include "html/html_baseimpl.h"
+#include "html/html_blockimpl.h"
#include "html/html_canvasimpl.h"
#include "html/html_documentimpl.h"
+#include "html/html_formimpl.h"
+#include "html/html_headimpl.h"
#include "html/html_imageimpl.h"
+#include "html/html_inlineimpl.h"
+#include "html/html_listimpl.h"
#include "html/html_objectimpl.h"
+#include "html/html_tableimpl.h"
#include "khtml_part.h"
#include "khtmlview.h"
-#include "ecma/kjs_css.h"
-#include "ecma/kjs_html.h"
-#include "ecma/kjs_window.h"
-#include "ecma/kjs_html.lut.h"
+#include "kjs_css.h"
+#include "kjs_window.h"
#include "kjs_events.h"
#include "kjs_proxy.h"
#include <kdebug.h>
-#include "cssparser.h"
-#include "css_stylesheetimpl.h"
+#include "css/cssparser.h"
+#include "css/css_stylesheetimpl.h"
+#include "css/css_ruleimpl.h"
-#include "qcolor.h"
-#include "qpixmap.h"
-#include "qpainter.h"
+#include <qcolor.h>
+#include <qpixmap.h>
+#include <qpainter.h>
+#if APPLE_CHANGES
#include <ApplicationServices/ApplicationServices.h>
+#endif
-using namespace KJS;
-
-using DOM::DocumentImpl;
using DOM::DOMString;
+using DOM::DocumentImpl;
+using DOM::ElementImpl;
+using DOM::EventImpl;
+using DOM::HTMLAnchorElementImpl;
+using DOM::HTMLAppletElementImpl;
+using DOM::HTMLAreaElementImpl;
+using DOM::HTMLBRElementImpl;
+using DOM::HTMLBaseElementImpl;
+using DOM::HTMLBaseFontElementImpl;
+using DOM::HTMLBlockquoteElementImpl;
+using DOM::HTMLBodyElementImpl;
+using DOM::HTMLButtonElementImpl;
+using DOM::HTMLCanvasElementImpl;
+using DOM::HTMLCollectionImpl;
+using DOM::HTMLDListElementImpl;
+using DOM::HTMLDirectoryElementImpl;
+using DOM::HTMLDivElementImpl;
+using DOM::HTMLDocumentImpl;
+using DOM::HTMLElementImpl;
+using DOM::HTMLFieldSetElementImpl;
+using DOM::HTMLFontElementImpl;
+using DOM::HTMLFormElementImpl;
using DOM::HTMLFrameElementImpl;
+using DOM::HTMLFrameSetElementImpl;
+using DOM::HTMLGenericFormElementImpl;
+using DOM::HTMLHRElementImpl;
+using DOM::HTMLHeadElementImpl;
+using DOM::HTMLHeadingElementImpl;
+using DOM::HTMLHtmlElementImpl;
+using DOM::HTMLIFrameElementImpl;
using DOM::HTMLIFrameElementImpl;
+using DOM::HTMLImageElementImpl;
+using DOM::HTMLInputElementImpl;
+using DOM::HTMLIsIndexElementImpl;
+using DOM::HTMLLIElementImpl;
+using DOM::HTMLLabelElementImpl;
+using DOM::HTMLLegendElementImpl;
+using DOM::HTMLLinkElementImpl;
+using DOM::HTMLMapElementImpl;
+using DOM::HTMLMenuElementImpl;
+using DOM::HTMLMetaElementImpl;
+using DOM::HTMLModElementImpl;
+using DOM::HTMLOListElementImpl;
+using DOM::HTMLObjectElementImpl;
+using DOM::HTMLOptGroupElementImpl;
+using DOM::HTMLOptionElementImpl;
+using DOM::HTMLParagraphElementImpl;
+using DOM::HTMLParamElementImpl;
+using DOM::HTMLPreElementImpl;
+using DOM::HTMLQuoteElementImpl;
+using DOM::HTMLScriptElementImpl;
+using DOM::HTMLSelectElementImpl;
+using DOM::HTMLStyleElementImpl;
+using DOM::HTMLTableCaptionElementImpl;
+using DOM::HTMLTableCellElementImpl;
+using DOM::HTMLTableColElementImpl;
+using DOM::HTMLTableElementImpl;
+using DOM::HTMLTableRowElementImpl;
+using DOM::HTMLTableSectionElementImpl;
+using DOM::HTMLTextAreaElementImpl;
+using DOM::HTMLTitleElementImpl;
+using DOM::HTMLUListElementImpl;
+using DOM::NodeImpl;
+using DOM::NodeListImpl;
+using DOM::TextImpl;
+
+using khtml::RenderCanvasImage;
+using khtml::SharedPtr;
+
+#include "kjs_html.lut.h"
+
+namespace KJS {
+
+class HTMLElementFunction : public DOMFunction {
+public:
+ HTMLElementFunction(ExecState *exec, int i, int len);
+ virtual Value tryCall(ExecState *exec, Object &thisObj, const List&args);
+private:
+ int id;
+};
IMPLEMENT_PROTOFUNC(HTMLDocFunction)
exec->setException(err);
return err;
}
- DOM::HTMLDocument doc = static_cast<KJS::HTMLDocument *>(thisObj.imp())->toDocument();
+ HTMLDocumentImpl &doc = *static_cast<HTMLDocumentImpl *>(static_cast<HTMLDocument *>(thisObj.imp())->impl());
switch (id) {
case HTMLDocument::Clear: // even IE doesn't support that one...
case HTMLDocument::Open:
// For compatibility with other browsers, pass open calls with more than 2 parameters to the window.
if (args.size() > 2) {
- KHTMLPart *part = static_cast<DOM::DocumentImpl *>(doc.handle())->part();
+ KHTMLPart *part = doc.part();
if (part) {
Window *window = Window::retrieveWindow(part);
if (window) {
return Undefined();
}
case HTMLDocument::GetElementsByName:
- return getDOMNodeList(exec,doc.getElementsByName(args[0].toString(exec).string()));
+ return getDOMNodeList(exec, doc.getElementsByName(args[0].toString(exec).string()).get());
case HTMLDocument::CaptureEvents:
case HTMLDocument::ReleaseEvents:
// Do nothing for now. These are NS-specific legacy calls.
# ids
@end
*/
-bool KJS::HTMLDocument::hasProperty(ExecState *exec, const Identifier &p) const
+
+HTMLDocument::HTMLDocument(ExecState *exec, HTMLDocumentImpl *d)
+ : DOMDocument(exec, d)
+{
+}
+
+bool HTMLDocument::hasProperty(ExecState *exec, const Identifier &p) const
{
#ifdef KJS_VERBOSE
- //kdDebug(6070) << "KJS::HTMLDocument::hasProperty " << p.qstring() << endl;
+ //kdDebug(6070) << "HTMLDocument::hasProperty " << p.qstring() << endl;
#endif
- DOM::HTMLDocumentImpl *docImpl = static_cast<DOM::HTMLDocumentImpl *>(node.handle());
-
- return (DOMDocument::hasProperty(exec, p) ||
- docImpl->haveNamedImageOrForm(p.qstring()));
+ HTMLDocumentImpl *doc = static_cast<HTMLDocumentImpl *>(impl());
+ return DOMDocument::hasProperty(exec, p) || doc->haveNamedImageOrForm(p.qstring());
}
-Value KJS::HTMLDocument::tryGet(ExecState *exec, const Identifier &propertyName) const
+Value HTMLDocument::tryGet(ExecState *exec, const Identifier &propertyName) const
{
#ifdef KJS_VERBOSE
kdDebug(6070) << "KJS::HTMLDocument::tryGet " << propertyName.qstring() << endl;
#endif
- DOM::HTMLDocument doc = static_cast<DOM::HTMLDocument>(node);
- DOM::HTMLBodyElement body = doc.body();
+ HTMLDocumentImpl &doc = *static_cast<HTMLDocumentImpl *>(impl());
+ HTMLElementImpl *body = doc.body();
- KHTMLView *view = static_cast<DOM::DocumentImpl*>(doc.handle())->view();
+ KHTMLView *view = doc.view();
+ KHTMLPart *part = doc.part();
const HashEntry* entry = Lookup::findEntry(&HTMLDocumentTable, propertyName);
if (entry) {
case URL:
return String(doc.URL());
case Body:
- return getDOMNode(exec,doc.body());
+ return getDOMNode(exec, body);
case Location:
- if ( view && view->part() )
- {
- Window* win = Window::retrieveWindow(view->part());
+ if (part) {
+ Window* win = Window::retrieveWindow(part);
if (win)
return Value(win->location());
- else
- return Undefined();
}
- else
- return Undefined();
+ return Undefined();
case Cookie:
return String(doc.cookie());
case Images:
- return getHTMLCollection(exec,doc.images());
+ return getHTMLCollection(exec, doc.images().get());
case Embeds:
- return getHTMLCollection(exec,doc.embeds());
+ return getHTMLCollection(exec, doc.embeds().get());
case Applets:
- return getHTMLCollection(exec,doc.applets());
+ return getHTMLCollection(exec, doc.applets().get());
case Links:
- return getHTMLCollection(exec,doc.links());
+ return getHTMLCollection(exec, doc.links().get());
case Forms:
- return getHTMLCollection(exec,doc.forms());
+ return getHTMLCollection(exec, doc.forms().get());
case Anchors:
- return getHTMLCollection(exec,doc.anchors());
+ return getHTMLCollection(exec, doc.anchors().get());
case Scripts: // TODO (IE-specific)
{
// To be implemented. Meanwhile, return an object with a length property set to 0
// Disable document.all when we try to be Netscape-compatible
if ( exec->dynamicInterpreter()->compatMode() == Interpreter::NetscapeCompat )
return Undefined();
- return getHTMLCollection(exec,doc.all());
+ return getHTMLCollection(exec, doc.all().get());
case Clear:
case Open:
case Close:
}
}
// Look for overrides
- ValueImp * val = ObjectImp::getDirect(propertyName);
+ ValueImp *val = ObjectImp::getDirect(propertyName);
if (val)
return Value(val);
+ HTMLBodyElementImpl *bodyElement = (body && body->id() == ID_BODY) ? static_cast<HTMLBodyElementImpl *>(body) : 0;
+
if (entry) {
switch (entry->value) {
case BgColor:
- return String(body.bgColor());
+ if (!bodyElement)
+ return Undefined();
+ return String(bodyElement->bgColor());
case FgColor:
- return String(body.text());
+ if (!bodyElement)
+ return Undefined();
+ return String(bodyElement->text());
case AlinkColor:
- return String(body.aLink());
+ if (!bodyElement)
+ return Undefined();
+ return String(bodyElement->aLink());
case LinkColor:
- return String(body.link());
+ if (!bodyElement)
+ return Undefined();
+ return String(bodyElement->link());
case VlinkColor:
- return String(body.vLink());
+ if (!bodyElement)
+ return Undefined();
+ return String(bodyElement->vLink());
case LastModified:
return String(doc.lastModified());
case Height:
case Width:
return Number(view ? view->contentsWidth() : 0);
case Dir:
- return String(body.dir());
- case DesignMode:
- {
- DocumentImpl *docimpl = static_cast<DocumentImpl *>(doc.handle());
- if (!docimpl)
return Undefined();
- return String(docimpl->inDesignMode() ? "on" : "off");
- }
+ return String(bodyElement->dir());
+ case DesignMode:
+ return String(doc.inDesignMode() ? "on" : "off");
}
}
//kdDebug(6070) << "KJS::HTMLDocument::tryGet " << propertyName.qstring() << " not found, returning element" << endl;
// image and form elements with the name p will be looked up last
-#if APPLE_CHANGES
- // Look for named applets.
- // FIXME: Factor code that creates RuntimeObjectImp for applet. It's also
- // located in applets[0].
- DOM::HTMLCollection applets = doc.applets();
- DOM::HTMLElement anApplet = applets.namedItem (propertyName.string());
- if (!anApplet.isNull()) {
- return getDOMNode(exec,anApplet);
- }
+ // Look for named applets.
+ // FIXME: Factor code that creates RuntimeObjectImp for applet. It's also located in applets[0].
- DOM::HTMLCollection embeds = doc.embeds();
- DOM::HTMLElement anEmbed = embeds.namedItem (propertyName.string());
- if (!anEmbed.isNull()) {
- return getDOMNode(exec,anEmbed);
- }
+ if (NodeImpl *applet = doc.applets()->namedItem(propertyName.string()))
+ return getDOMNode(exec, applet);
- DOM::HTMLCollection objects = doc.objects();
- DOM::HTMLElement anObject = objects.namedItem (propertyName.string());
- if (!anObject.isNull()) {
- return getDOMNode(exec,anObject);
- }
-#endif
+ if (NodeImpl *embed = doc.embeds()->namedItem(propertyName.string()))
+ return getDOMNode(exec, embed);
- DOM::HTMLDocumentImpl *docImpl = static_cast<DOM::HTMLDocumentImpl*>(node.handle());
- if (!docImpl->haveNamedImageOrForm(propertyName.qstring())) {
- return Undefined();
- }
+ if (NodeImpl *object = doc.objects()->namedItem(propertyName.string()))
+ return getDOMNode(exec, object);
- DOM::HTMLCollection nameableItems = doc.nameableItems();
- KJS::HTMLCollection kjsCollection(exec,nameableItems);
- return kjsCollection.getNamedItems(exec, propertyName); // Get all the items with the same name
+ if (!doc.haveNamedImageOrForm(propertyName.qstring()))
+ return Undefined();
- return Undefined();
+ return HTMLCollection(exec, doc.nameableItems().get()).getNamedItems(exec, propertyName); // Get all the items with the same name
}
void KJS::HTMLDocument::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr)
void KJS::HTMLDocument::putValue(ExecState *exec, int token, const Value& value, int /*attr*/)
{
- DOM::HTMLDocument doc = static_cast<DOM::HTMLDocument>(node);
- DOM::HTMLBodyElement body = doc.body();
+ DOMExceptionTranslator exception(exec);
+ HTMLDocumentImpl &doc = *static_cast<HTMLDocumentImpl *>(impl());
+ HTMLElementImpl *body = doc.body();
+ HTMLBodyElementImpl *bodyElement = (body && body->id() == ID_BODY) ? static_cast<HTMLBodyElementImpl *>(body) : 0;
switch (token) {
case Title:
doc.setTitle(value.toString(exec).string());
break;
- case Body: {
- DOMNode *node = new DOMNode(exec, KJS::toNode(value));
- // This is required to avoid leaking the node.
- Value nodeValue(node);
- doc.setBody(node->toNode());
+ case Body:
+ doc.setBody(toHTMLElement(value), exception);
break;
- }
- case Domain: { // not part of the DOM
- DOM::HTMLDocumentImpl* docimpl = static_cast<DOM::HTMLDocumentImpl*>(doc.handle());
- if (docimpl)
- docimpl->setDomain(value.toString(exec).string());
+ case Domain: // not part of the DOM
+ doc.setDomain(value.toString(exec).string());
break;
- }
case Cookie:
doc.setCookie(value.toString(exec).string());
break;
case Location: {
- KHTMLPart *part = static_cast<DOM::DocumentImpl *>( doc.handle() )->part();
+ KHTMLPart *part = doc.part();
if (part)
{
QString str = value.toString(exec).qstring();
// the target frame.
KHTMLPart *activePart = static_cast<KJS::ScriptInterpreter *>( exec->dynamicInterpreter() )->part();
if (activePart)
- str = activePart->htmlDocument().completeURL(str).string();
+ str = activePart->xmlDocImpl()->completeURL(str);
-#if APPLE_CHANGES
// We want a new history item if this JS was called via a user gesture
bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();
part->scheduleLocationChange(str, activePart->referrer(), !userGesture);
-#else
- part->scheduleLocationChange(str, activePart->referrer(), false/*don't lock history*/);
-#endif
}
break;
}
case BgColor:
- body.setBgColor(value.toString(exec).string());
+ if (bodyElement)
+ bodyElement->setBgColor(value.toString(exec).string());
break;
case FgColor:
- body.setText(value.toString(exec).string());
+ if (bodyElement)
+ bodyElement->setText(value.toString(exec).string());
break;
case AlinkColor:
- // this check is a bit silly, but some benchmarks like to set the
- // document's link colors over and over to the same value and we
- // don't want to incur a style update each time.
- {
- DOM::DOMString newColor = value.toString(exec).string();
- if (body.aLink() != newColor) {
- body.setALink(newColor);
- }
+ if (bodyElement) {
+ // this check is a bit silly, but some benchmarks like to set the
+ // document's link colors over and over to the same value and we
+ // don't want to incur a style update each time.
+ DOMString newColor = value.toString(exec).string();
+ if (bodyElement->aLink() != newColor)
+ bodyElement->setALink(newColor);
}
break;
case LinkColor:
- // this check is a bit silly, but some benchmarks like to set the
- // document's link colors over and over to the same value and we
- // don't want to incur a style update each time.
- {
- DOM::DOMString newColor = value.toString(exec).string();
- if (body.link() != newColor) {
- body.setLink(newColor);
- }
+ if (bodyElement) {
+ // this check is a bit silly, but some benchmarks like to set the
+ // document's link colors over and over to the same value and we
+ // don't want to incur a style update each time.
+ DOMString newColor = value.toString(exec).string();
+ if (bodyElement->link() != newColor)
+ bodyElement->setLink(newColor);
}
break;
case VlinkColor:
- // this check is a bit silly, but some benchmarks like to set the
- // document's link colors over and over to the same value and we
- // don't want to incur a style update each time.
- {
- DOM::DOMString newColor = value.toString(exec).string();
- if (body.vLink() != newColor) {
- body.setVLink(newColor);
- }
+ if (bodyElement) {
+ // this check is a bit silly, but some benchmarks like to set the
+ // document's link colors over and over to the same value and we
+ // don't want to incur a style update each time.
+ DOMString newColor = value.toString(exec).string();
+ if (bodyElement->vLink() != newColor)
+ bodyElement->setVLink(newColor);
}
break;
case Dir:
- body.setDir(value.toString(exec).string());
+ body->setDir(value.toString(exec).string());
break;
case DesignMode:
{
- DocumentImpl *docimpl = static_cast<DocumentImpl *>(doc.handle());
- if (!docimpl)
- break;
DOMString modeString = value.toString(exec).string();
DocumentImpl::InheritedBool mode;
if (!strcasecmp(modeString, "on"))
mode = DocumentImpl::off;
else
mode = DocumentImpl::inherit;
- docimpl->setDesignMode(mode);
- }
- break;
+ doc.setDesignMode(mode);
+ break;
+ }
default:
kdWarning() << "HTMLDocument::putValue unhandled token " << token << endl;
}
const ClassInfo* KJS::HTMLElement::classInfo() const
{
- DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
- switch (element.elementId()) {
+ switch (impl()->id()) {
case ID_HTML:
return &html_info;
case ID_HEAD:
@end
*/
+HTMLElement::HTMLElement(ExecState *exec, HTMLElementImpl *e)
+ : DOMElement(exec, e)
+{
+}
+
Value KJS::HTMLElement::tryGet(ExecState *exec, const Identifier &propertyName) const
{
- DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
+ HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl());
#ifdef KJS_VERBOSE
kdDebug(6070) << "KJS::HTMLElement::tryGet " << propertyName.qstring() << " thisTag=" << element.tagName().string() << endl;
#endif
// First look at dynamic properties
- switch (element.elementId()) {
+ switch (element.id()) {
case ID_FORM: {
- DOM::HTMLFormElement form = element;
+ HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element);
// Check if we're retrieving an element (by index or by name)
bool ok;
uint u = propertyName.toULong(&ok);
if (ok)
- return getDOMNode(exec,form.elements().item(u));
- KJS::HTMLCollection coll(exec,form.elements());
- Value namedItems = coll.getNamedItems(exec, propertyName);
- if (namedItems.type() != UndefinedType)
+ return getDOMNode(exec, form.elements()->item(u));
+ ValueImp *namedItems = HTMLCollection(exec, form.elements().get()).getNamedItems(exec, propertyName);
+ if (!namedItems->isUndefined())
return namedItems;
}
break;
case ID_SELECT: {
- DOM::HTMLSelectElement select = element;
+ HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element);
bool ok;
uint u = propertyName.toULong(&ok);
if (ok)
- return getDOMNode(exec,select.options().item(u)); // not specified by DOM(?) but supported in netscape/IE
+ return getDOMNode(exec, select.optionsHTMLCollection()->item(u)); // not specified by DOM(?) but supported in netscape/IE
}
break;
case ID_FRAMESET: {
- DOM::Node frame = element.children().namedItem(propertyName.string());
- if (!frame.isNull() && frame.elementId() == ID_FRAME) {
- DOM::DocumentImpl* doc = static_cast<DOM::HTMLFrameElementImpl *>(frame.handle())->contentDocument();
+ NodeImpl *frame = element.children()->namedItem(propertyName.string());
+ if (frame && frame->id() == ID_FRAME) {
+ DocumentImpl* doc = static_cast<HTMLFrameElementImpl *>(frame)->contentDocument();
if (doc) {
KHTMLPart* part = doc->part();
if (part) {
break;
case ID_FRAME:
case ID_IFRAME: {
- DOM::DocumentImpl* doc = static_cast<DOM::HTMLFrameElementImpl *>(element.handle())->contentDocument();
+ DocumentImpl* doc = static_cast<HTMLFrameElementImpl &>(element).contentDocument();
if ( doc ) {
KHTMLPart* part = doc->part();
if ( part ) {
- Object globalObject = Object::dynamicCast( Window::retrieve( part ) );
- // Calling hasProperty on a Window object doesn't work, it always says true.
- // Hence we need to use getDirect instead.
- if ( !globalObject.isNull() && static_cast<ObjectImp *>(globalObject.imp())->getDirect( propertyName ) )
- return globalObject.get( exec, propertyName );
+ Window *window = Window::retrieveWindow(part);
+ if (window && window->hasProperty(exec, propertyName))
+ return window->get(exec, propertyName);
}
}
}
case ID_OBJECT:
case ID_APPLET: {
if (propertyName == "__apple_runtime_object") {
- return getRuntimeObject(exec,element);
+ return getRuntimeObject(exec,&element);
}
- Value domValue = getDOMNode(exec,element);
- Value runtimeObject = getRuntimeObject(exec,element);
+ Value runtimeObject = getRuntimeObject(exec,&element);
if (!runtimeObject.isNull()) {
ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp());
if (imp->hasProperty(exec, propertyName)) {
}
// Base HTMLElement stuff or parent class forward, as usual
- return DOMObjectLookupGet<KJS::HTMLElementFunction, KJS::HTMLElement, DOMElement>(exec, propertyName, &KJS::HTMLElementTable, this);
+ return DOMObjectLookupGet<KJS::HTMLElementFunction, KJS::HTMLElement, DOMElement>(exec, propertyName, &HTMLElementTable, this);
}
-#if APPLE_CHANGES
bool KJS::HTMLElement::implementsCall() const
{
- DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
- switch (element.elementId()) {
+ HTMLElementImpl *element = static_cast<HTMLElementImpl *>(impl());
+ switch (element->id()) {
case ID_EMBED:
case ID_OBJECT:
case ID_APPLET: {
- DOM::DocumentImpl* doc = element.handle()->getDocument();
+ DocumentImpl* doc = element->getDocument();
KJSProxy *proxy = KJSProxy::proxy(doc->part());
ExecState *exec = proxy->interpreter()->globalExec();
- Value domValue = getDOMNode(exec,element);
Value runtimeObject = getRuntimeObject(exec,element);
if (!runtimeObject.isNull()) {
ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp());
Value KJS::HTMLElement::call(ExecState *exec, Object &thisObj, const List&args)
{
- DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
- switch (element.elementId()) {
+ HTMLElementImpl *element = static_cast<HTMLElementImpl *>(impl());
+ switch (element->id()) {
case ID_EMBED:
case ID_OBJECT:
case ID_APPLET: {
- Value domValue = getDOMNode(exec,element);
Value runtimeObject = getRuntimeObject(exec,element);
if (!runtimeObject.isNull()) {
ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp());
}
return Undefined();
}
-#endif
Value KJS::HTMLElement::getValueProperty(ExecState *exec, int token) const
{
- DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
- switch (element.elementId()) {
+ HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl());
+ switch (element.id()) {
case ID_HTML: {
- DOM::HTMLHtmlElement html = element;
+ HTMLHtmlElementImpl &html = static_cast<HTMLHtmlElementImpl &>(element);
if (token == HtmlVersion) return String(html.version());
}
break;
case ID_HEAD: {
- DOM::HTMLHeadElement head = element;
+ HTMLHeadElementImpl &head = static_cast<HTMLHeadElementImpl &>(element);
if (token == HeadProfile) return String(head.profile());
}
break;
case ID_LINK: {
- DOM::HTMLLinkElement link = element;
+ HTMLLinkElementImpl &link = static_cast<HTMLLinkElementImpl &>(element);
switch (token) {
case LinkDisabled: return Boolean(link.disabled());
case LinkCharset: return String(link.charset());
case LinkRev: return String(link.rev());
case LinkTarget: return String(link.target());
case LinkType: return String(link.type());
- case LinkSheet: return getDOMStyleSheet(exec,static_cast<DOM::ProcessingInstruction>(node).sheet());
+ case LinkSheet: return getDOMStyleSheet(exec, link.sheet());
}
}
break;
case ID_TITLE: {
- DOM::HTMLTitleElement title = element;
+ HTMLTitleElementImpl &title = static_cast<HTMLTitleElementImpl &>(element);
switch (token) {
case TitleText: return String(title.text());
}
}
break;
case ID_META: {
- DOM::HTMLMetaElement meta = element;
+ HTMLMetaElementImpl &meta = static_cast<HTMLMetaElementImpl &>(element);
switch (token) {
case MetaContent: return String(meta.content());
case MetaHttpEquiv: return String(meta.httpEquiv());
}
break;
case ID_BASE: {
- DOM::HTMLBaseElement base = element;
+ HTMLBaseElementImpl &base = static_cast<HTMLBaseElementImpl &>(element);
switch (token) {
case BaseHref: return String(base.href());
case BaseTarget: return String(base.target());
}
break;
case ID_ISINDEX: {
- DOM::HTMLIsIndexElement isindex = element;
+ HTMLIsIndexElementImpl &isindex = static_cast<HTMLIsIndexElementImpl &>(element);
switch (token) {
- case IsIndexForm: return getDOMNode(exec,isindex.form()); // type HTMLFormElement
+ case IsIndexForm: return getDOMNode(exec, isindex.form()); // type HTMLFormElement
case IsIndexPrompt: return String(isindex.prompt());
}
}
break;
case ID_STYLE: {
- DOM::HTMLStyleElement style = element;
+ HTMLStyleElementImpl &style = static_cast<HTMLStyleElementImpl &>(element);
switch (token) {
case StyleDisabled: return Boolean(style.disabled());
case StyleMedia: return String(style.media());
case StyleType: return String(style.type());
- case StyleSheet: return getDOMStyleSheet(exec,static_cast<DOM::ProcessingInstruction>(node).sheet());
+ case StyleSheet: return getDOMStyleSheet(exec, style.sheet());
}
}
break;
case ID_BODY: {
- DOM::HTMLBodyElement body = element;
+ HTMLBodyElementImpl &body = static_cast<HTMLBodyElementImpl &>(element);
switch (token) {
case BodyALink: return String(body.aLink());
case BodyBackground: return String(body.background());
case BodyVLink: return String(body.vLink());
default:
// Update the document's layout before we compute these attributes.
- DOM::DocumentImpl* docimpl = node.handle()->getDocument();
- if (docimpl) {
- docimpl->updateLayoutIgnorePendingStylesheets();
- }
+ DocumentImpl *doc = body.getDocument();
+ if (doc)
+ doc->updateLayoutIgnorePendingStylesheets();
+ KHTMLView *view = doc ? doc->view() : 0;
switch (token) {
case BodyScrollLeft:
- return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsX() : 0);
+ return Number(view ? view->contentsX() : 0);
case BodyScrollTop:
- return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsY() : 0);
- case BodyScrollHeight: return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsHeight() : 0);
- case BodyScrollWidth: return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsWidth() : 0);
+ return Number(view ? view->contentsY() : 0);
+ case BodyScrollHeight: return Number(view ? view->contentsHeight() : 0);
+ case BodyScrollWidth: return Number(view ? view->contentsWidth() : 0);
}
}
}
break;
case ID_FORM: {
- DOM::HTMLFormElement form = element;
+ HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element);
switch (token) {
- case FormElements: return getHTMLCollection(exec,form.elements());
+ case FormElements: return getHTMLCollection(exec, form.elements().get());
case FormLength: return Number(form.length());
case FormName: return String(form.name());
case FormAcceptCharset: return String(form.acceptCharset());
}
break;
case ID_SELECT: {
- DOM::HTMLSelectElement select = element;
+ HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element);
switch (token) {
case SelectType: return String(select.type());
case SelectSelectedIndex: return Number(select.selectedIndex());
case SelectValue: return String(select.value());
case SelectLength: return Number(select.length());
- case SelectForm: return getDOMNode(exec,select.form()); // type HTMLFormElement
- case SelectOptions: return getSelectHTMLCollection(exec, select.options(), select); // type HTMLCollection
+ case SelectForm: return getDOMNode(exec, select.form()); // type HTMLFormElement
+ case SelectOptions: return getSelectHTMLCollection(exec, select.optionsHTMLCollection().get(), &select); // type HTMLCollection
case SelectDisabled: return Boolean(select.disabled());
case SelectMultiple: return Boolean(select.multiple());
case SelectName: return String(select.name());
}
break;
case ID_OPTGROUP: {
- DOM::HTMLOptGroupElement optgroup = element;
+ HTMLOptGroupElementImpl &optgroup = static_cast<HTMLOptGroupElementImpl &>(element);
switch (token) {
case OptGroupDisabled: return Boolean(optgroup.disabled());
case OptGroupLabel: return String(optgroup.label());
}
break;
case ID_OPTION: {
- DOM::HTMLOptionElement option = element;
+ HTMLOptionElementImpl &option = static_cast<HTMLOptionElementImpl &>(element);
switch (token) {
case OptionForm: return getDOMNode(exec,option.form()); // type HTMLFormElement
case OptionDefaultSelected: return Boolean(option.defaultSelected());
}
break;
case ID_INPUT: {
- DOM::HTMLInputElement input = element;
+ HTMLInputElementImpl &input = static_cast<HTMLInputElementImpl &>(element);
switch (token) {
case InputDefaultValue: return String(input.defaultValue());
case InputDefaultChecked: return Boolean(input.defaultChecked());
case InputMaxLength: return Number(input.maxLength());
case InputName: return String(input.name());
case InputReadOnly: return Boolean(input.readOnly());
- case InputSize: return String(input.size());
+ case InputSize: return String(input.sizeDOM());
case InputSrc: return String(input.src());
case InputTabIndex: return Number(input.tabIndex());
case InputType: return String(input.type());
}
break;
case ID_TEXTAREA: {
- DOM::HTMLTextAreaElement textarea = element;
+ HTMLTextAreaElementImpl &textarea = static_cast<HTMLTextAreaElementImpl &>(element);
switch (token) {
case TextAreaDefaultValue: return String(textarea.defaultValue());
case TextAreaForm: return getDOMNode(exec,textarea.form()); // type HTMLFormElement
}
break;
case ID_BUTTON: {
- DOM::HTMLButtonElement button = element;
+ HTMLButtonElementImpl &button = static_cast<HTMLButtonElementImpl &>(element);
switch (token) {
case ButtonForm: return getDOMNode(exec,button.form()); // type HTMLFormElement
case ButtonAccessKey: return String(button.accessKey());
}
break;
case ID_LABEL: {
- DOM::HTMLLabelElement label = element;
+ HTMLLabelElementImpl &label = static_cast<HTMLLabelElementImpl &>(element);
switch (token) {
case LabelForm: return getDOMNode(exec,label.form()); // type HTMLFormElement
case LabelAccessKey: return String(label.accessKey());
}
break;
case ID_FIELDSET: {
- DOM::HTMLFieldSetElement fieldSet = element;
+ HTMLFieldSetElementImpl &fieldSet = static_cast<HTMLFieldSetElementImpl &>(element);
switch (token) {
case FieldSetForm: return getDOMNode(exec,fieldSet.form()); // type HTMLFormElement
}
}
break;
case ID_LEGEND: {
- DOM::HTMLLegendElement legend = element;
+ HTMLLegendElementImpl &legend = static_cast<HTMLLegendElementImpl &>(element);
switch (token) {
case LegendForm: return getDOMNode(exec,legend.form()); // type HTMLFormElement
case LegendAccessKey: return String(legend.accessKey());
}
break;
case ID_UL: {
- DOM::HTMLUListElement uList = element;
+ HTMLUListElementImpl &uList = static_cast<HTMLUListElementImpl &>(element);
switch (token) {
case UListCompact: return Boolean(uList.compact());
case UListType: return String(uList.type());
}
break;
case ID_OL: {
- DOM::HTMLOListElement oList = element;
+ HTMLOListElementImpl &oList = static_cast<HTMLOListElementImpl &>(element);
switch (token) {
case OListCompact: return Boolean(oList.compact());
case OListStart: return Number(oList.start());
}
break;
case ID_DL: {
- DOM::HTMLDListElement dList = element;
+ HTMLDListElementImpl &dList = static_cast<HTMLDListElementImpl &>(element);
switch (token) {
case DListCompact: return Boolean(dList.compact());
}
}
break;
case ID_DIR: {
- DOM::HTMLDirectoryElement directory = element;
+ HTMLDirectoryElementImpl &directory = static_cast<HTMLDirectoryElementImpl &>(element);
switch (token) {
case DirectoryCompact: return Boolean(directory.compact());
}
}
break;
case ID_MENU: {
- DOM::HTMLMenuElement menu = element;
+ HTMLMenuElementImpl &menu = static_cast<HTMLMenuElementImpl &>(element);
switch (token) {
case MenuCompact: return Boolean(menu.compact());
}
}
break;
case ID_LI: {
- DOM::HTMLLIElement li = element;
+ HTMLLIElementImpl &li = static_cast<HTMLLIElementImpl &>(element);
switch (token) {
case LIType: return String(li.type());
case LIValue: return Number(li.value());
}
break;
case ID_DIV: {
- DOM::HTMLDivElement div = element;
+ HTMLDivElementImpl &div = static_cast<HTMLDivElementImpl &>(element);
switch (token) {
case DivAlign: return String(div.align());
}
}
break;
case ID_P: {
- DOM::HTMLParagraphElement paragraph = element;
+ HTMLParagraphElementImpl ¶graph = static_cast<HTMLParagraphElementImpl &>(element);
switch (token) {
case ParagraphAlign: return String(paragraph.align());
}
case ID_H4:
case ID_H5:
case ID_H6: {
- DOM::HTMLHeadingElement heading = element;
+ HTMLHeadingElementImpl &heading = static_cast<HTMLHeadingElementImpl &>(element);
switch (token) {
case HeadingAlign: return String(heading.align());
}
}
break;
case ID_BLOCKQUOTE: {
- DOM::HTMLBlockquoteElement blockquote = element;
+ HTMLBlockquoteElementImpl &blockquote = static_cast<HTMLBlockquoteElementImpl &>(element);
switch (token) {
case BlockQuoteCite: return String(blockquote.cite());
}
}
case ID_Q: {
- DOM::HTMLQuoteElement quote = element;
+ HTMLQuoteElementImpl "e = static_cast<HTMLQuoteElementImpl &>(element);
switch (token) {
case QuoteCite: return String(quote.cite());
}
}
case ID_PRE: {
- DOM::HTMLPreElement pre = element;
+ HTMLPreElementImpl &pre = static_cast<HTMLPreElementImpl &>(element);
switch (token) {
case PreWidth: return Number(pre.width());
}
}
break;
case ID_BR: {
- DOM::HTMLBRElement br = element;
+ HTMLBRElementImpl &br = static_cast<HTMLBRElementImpl &>(element);
switch (token) {
case BRClear: return String(br.clear());
}
}
break;
case ID_BASEFONT: {
- DOM::HTMLBaseFontElement baseFont = element;
+ HTMLBaseFontElementImpl &baseFont = static_cast<HTMLBaseFontElementImpl &>(element);
switch (token) {
case BaseFontColor: return String(baseFont.color());
case BaseFontFace: return String(baseFont.face());
}
break;
case ID_FONT: {
- DOM::HTMLFontElement font = element;
+ HTMLFontElementImpl &font = static_cast<HTMLFontElementImpl &>(element);
switch (token) {
case FontColor: return String(font.color());
case FontFace: return String(font.face());
}
break;
case ID_HR: {
- DOM::HTMLHRElement hr = element;
+ HTMLHRElementImpl &hr = static_cast<HTMLHRElementImpl &>(element);
switch (token) {
case HRAlign: return String(hr.align());
case HRNoShade: return Boolean(hr.noShade());
break;
case ID_INS:
case ID_DEL: {
- DOM::HTMLModElement mod = element;
+ HTMLModElementImpl &mod = static_cast<HTMLModElementImpl &>(element);
switch (token) {
case ModCite: return String(mod.cite());
case ModDateTime: return String(mod.dateTime());
}
break;
case ID_A: {
- DOM::HTMLAnchorElement anchor = element;
+ HTMLAnchorElementImpl &anchor = static_cast<HTMLAnchorElementImpl &>(element);
switch (token) {
case AnchorAccessKey: return String(anchor.accessKey());
case AnchorCharset: return String(anchor.charset());
case AnchorTabIndex: return Number(anchor.tabIndex());
case AnchorTarget: return String(anchor.target());
case AnchorType: return String(anchor.type());
- case AnchorText: {
- DOM::DocumentImpl* docimpl = node.handle()->getDocument();
- if (docimpl) {
- docimpl->updateLayoutIgnorePendingStylesheets();
- }
- }
+ case AnchorText:
+ if (DocumentImpl* doc = anchor.getDocument())
+ doc->updateLayoutIgnorePendingStylesheets();
return String(anchor.innerText());
}
}
break;
case ID_IMG: {
- DOM::HTMLImageElement image = element;
+ HTMLImageElementImpl &image = static_cast<HTMLImageElementImpl &>(element);
switch (token) {
case ImageName: return String(image.name());
case ImageAlign: return String(image.align());
case ImageAlt: return String(image.alt());
case ImageBorder: return Number(image.border());
- case ImageHeight: return Number(static_cast<DOM::HTMLImageElementImpl *>(image.handle())->height(true));
+ case ImageHeight: return Number(image.height(true));
case ImageHspace: return Number(image.hspace());
case ImageIsMap: return Boolean(image.isMap());
case ImageLongDesc: return String(image.longDesc());
case ImageSrc: return String(image.src());
case ImageUseMap: return String(image.useMap());
case ImageVspace: return Number(image.vspace());
- case ImageWidth: return Number(static_cast<DOM::HTMLImageElementImpl *>(image.handle())->width(true));
+ case ImageWidth: return Number(image.width(true));
case ImageX: return Number(image.x());
case ImageY: return Number(image.y());
}
}
break;
case ID_OBJECT: {
- DOM::HTMLObjectElement object = element;
+ HTMLObjectElementImpl &object = static_cast<HTMLObjectElementImpl &>(element);
switch (token) {
case ObjectForm: return getDOMNode(exec,object.form()); // type HTMLFormElement
case ObjectCode: return String(object.code());
}
break;
case ID_PARAM: {
- DOM::HTMLParamElement param = element;
+ HTMLParamElementImpl ¶m = static_cast<HTMLParamElementImpl &>(element);
switch (token) {
case ParamName: return String(param.name());
case ParamType: return String(param.type());
}
break;
case ID_APPLET: {
- DOM::HTMLAppletElement applet = element;
+ HTMLAppletElementImpl &applet = static_cast<HTMLAppletElementImpl &>(element);
switch (token) {
case AppletAlign: return String(applet.align());
case AppletAlt: return String(applet.alt());
}
break;
case ID_MAP: {
- DOM::HTMLMapElement map = element;
+ HTMLMapElementImpl &map = static_cast<HTMLMapElementImpl &>(element);
switch (token) {
- case MapAreas: return getHTMLCollection(exec, map.areas()); // type HTMLCollection
+ case MapAreas: return getHTMLCollection(exec, map.areas().get()); // type HTMLCollection
case MapName: return String(map.name());
}
}
break;
case ID_AREA: {
- DOM::HTMLAreaElement area = element;
+ HTMLAreaElementImpl &area = static_cast<HTMLAreaElementImpl &>(element);
switch (token) {
case AreaAccessKey: return String(area.accessKey());
case AreaAlt: return String(area.alt());
}
break;
case ID_SCRIPT: {
- DOM::HTMLScriptElement script = element;
+ HTMLScriptElementImpl &script = static_cast<HTMLScriptElementImpl &>(element);
switch (token) {
case ScriptText: return String(script.text());
case ScriptHtmlFor: return String(script.htmlFor());
}
break;
case ID_TABLE: {
- DOM::HTMLTableElement table = element;
+ HTMLTableElementImpl &table = static_cast<HTMLTableElementImpl &>(element);
switch (token) {
case TableCaption: return getDOMNode(exec,table.caption()); // type HTMLTableCaptionElement
case TableTHead: return getDOMNode(exec,table.tHead()); // type HTMLTableSectionElement
case TableTFoot: return getDOMNode(exec,table.tFoot()); // type HTMLTableSectionElement
- case TableRows: return getHTMLCollection(exec,table.rows()); // type HTMLCollection
- case TableTBodies: return getHTMLCollection(exec,table.tBodies()); // type HTMLCollection
+ case TableRows: return getHTMLCollection(exec, table.rows().get()); // type HTMLCollection
+ case TableTBodies: return getHTMLCollection(exec, table.tBodies().get()); // type HTMLCollection
case TableAlign: return String(table.align());
case TableBgColor: return String(table.bgColor());
case TableBorder: return String(table.border());
}
break;
case ID_CAPTION: {
- DOM::HTMLTableCaptionElement tableCaption;
+ HTMLTableCaptionElementImpl &tableCaption = static_cast<HTMLTableCaptionElementImpl &>(element);
switch (token) {
case TableCaptionAlign: return String(tableCaption.align());
}
}
break;
case ID_COL: {
- DOM::HTMLTableColElement tableCol = element;
+ HTMLTableColElementImpl &tableCol = static_cast<HTMLTableColElementImpl &>(element);
switch (token) {
case TableColAlign: return String(tableCol.align());
case TableColCh: return String(tableCol.ch());
case ID_THEAD:
case ID_TBODY:
case ID_TFOOT: {
- DOM::HTMLTableSectionElement tableSection = element;
+ HTMLTableSectionElementImpl &tableSection = static_cast<HTMLTableSectionElementImpl &>(element);
switch (token) {
case TableSectionAlign: return String(tableSection.align());
case TableSectionCh: return String(tableSection.ch());
case TableSectionChOff: return String(tableSection.chOff());
case TableSectionVAlign: return String(tableSection.vAlign());
- case TableSectionRows: return getHTMLCollection(exec,tableSection.rows()); // type HTMLCollection
+ case TableSectionRows: return getHTMLCollection(exec, tableSection.rows().get()); // type HTMLCollection
}
}
break;
case ID_TR: {
- DOM::HTMLTableRowElement tableRow = element;
+ HTMLTableRowElementImpl &tableRow = static_cast<HTMLTableRowElementImpl &>(element);
switch (token) {
case TableRowRowIndex: return Number(tableRow.rowIndex());
case TableRowSectionRowIndex: return Number(tableRow.sectionRowIndex());
- case TableRowCells: return getHTMLCollection(exec,tableRow.cells()); // type HTMLCollection
+ case TableRowCells: return getHTMLCollection(exec, tableRow.cells().get()); // type HTMLCollection
case TableRowAlign: return String(tableRow.align());
case TableRowBgColor: return String(tableRow.bgColor());
case TableRowCh: return String(tableRow.ch());
break;
case ID_TH:
case ID_TD: {
- DOM::HTMLTableCellElement tableCell = element;
+ HTMLTableCellElementImpl &tableCell = static_cast<HTMLTableCellElementImpl &>(element);
switch (token) {
case TableCellCellIndex: return Number(tableCell.cellIndex());
case TableCellAbbr: return String(tableCell.abbr());
}
break;
case ID_FRAMESET: {
- DOM::HTMLFrameSetElement frameSet = element;
+ HTMLFrameSetElementImpl &frameSet = static_cast<HTMLFrameSetElementImpl &>(element);
switch (token) {
case FrameSetCols: return String(frameSet.cols());
case FrameSetRows: return String(frameSet.rows());
}
break;
case ID_FRAME: {
- DOM::HTMLFrameElement frameElement = element;
+ HTMLFrameElementImpl &frameElement = static_cast<HTMLFrameElementImpl &>(element);
switch (token) {
case FrameContentDocument: return checkNodeSecurity(exec,frameElement.contentDocument()) ?
getDOMNode(exec, frameElement.contentDocument()) : Undefined();
case FrameContentWindow: return checkNodeSecurity(exec,frameElement.contentDocument())
- ? Window::retrieve(static_cast<HTMLFrameElementImpl *>(frameElement.handle())->contentPart())
+ ? Window::retrieve(frameElement.contentPart())
: Undefined();
case FrameFrameBorder: return String(frameElement.frameBorder());
case FrameLongDesc: return String(frameElement.longDesc());
}
break;
case ID_IFRAME: {
- DOM::HTMLIFrameElement iFrame = element;
+ HTMLIFrameElementImpl &iFrame = static_cast<HTMLIFrameElementImpl &>(element);
switch (token) {
case IFrameAlign: return String(iFrame.align());
// ### security check ?
case IFrameContentDocument: return checkNodeSecurity(exec,iFrame.contentDocument()) ?
getDOMNode(exec, iFrame.contentDocument()) : Undefined();
case IFrameContentWindow: return checkNodeSecurity(exec,iFrame.contentDocument())
- ? Window::retrieve(static_cast<HTMLIFrameElementImpl *>(iFrame.handle())->contentPart())
+ ? Window::retrieve(iFrame.contentPart())
: Undefined();
case IFrameFrameBorder: return String(iFrame.frameBorder());
case IFrameHeight: return String(iFrame.height());
case ElementId:
// iht.com relies on this value being "" when no id is present. Other browsers do this as well.
// So we use String() instead of String() here.
- return String(element.id());
+ return String(element.idDOM());
case ElementTitle:
return String(element.title());
case ElementLang:
case ElementInnerHTML:
return String(element.innerHTML());
case ElementInnerText:
- {
- DOM::DocumentImpl* docimpl = node.handle()->getDocument();
- if (docimpl) {
- docimpl->updateLayoutIgnorePendingStylesheets();
- }
- }
+ if (DocumentImpl* doc = impl()->getDocument())
+ doc->updateLayoutIgnorePendingStylesheets();
return String(element.innerText());
case ElementOuterHTML:
return String(element.outerHTML());
case ElementDocument:
return getDOMNode(exec,element.ownerDocument());
case ElementChildren:
- return getHTMLCollection(exec,element.children());
+ return getHTMLCollection(exec, element.children().get());
case ElementContentEditable:
return String(element.contentEditable());
case ElementIsContentEditable:
#ifdef KJS_VERBOSE
//kdDebug(6070) << "HTMLElement::hasProperty " << propertyName.qstring() << endl;
#endif
- DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
+ HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl());
// First look at dynamic properties - keep this in sync with tryGet
- switch (element.elementId()) {
+ switch (element.id()) {
case ID_FORM: {
- DOM::HTMLFormElement form = element;
+ HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element);
// Check if we're retrieving an element (by index or by name)
bool ok;
uint u = propertyName.toULong(&ok);
- if (ok && !(form.elements().item(u).isNull()))
+ if (ok && form.elements()->item(u))
return true;
- DOM::Node testnode = form.elements().namedItem(propertyName.string());
- if (!testnode.isNull())
+ if (form.elements()->namedItem(propertyName.string()))
return true;
+ break;
}
case ID_SELECT: {
- DOM::HTMLSelectElement select = element;
+ HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element);
bool ok;
uint u = propertyName.toULong(&ok);
- if (ok && !(select.options().item(u).isNull()))
+ if (ok && select.optionsHTMLCollection()->item(u))
return true;
+ break;
}
default:
break;
UString KJS::HTMLElement::toString(ExecState *exec) const
{
- if (node.elementId() == ID_A)
- return UString(static_cast<const DOM::HTMLAnchorElement&>(node).href());
+ if (impl()->id() == ID_A)
+ return UString(static_cast<const HTMLAnchorElementImpl *>(impl())->href());
else
return DOMElement::toString(exec);
}
-static void getForm(DOM::HTMLFormElement* form, const DOM::HTMLElement& element)
+static HTMLFormElementImpl *getForm(HTMLElementImpl *element)
{
- switch (element.elementId()) {
- case ID_ISINDEX: {
- DOM::HTMLIsIndexElement isindex = element;
- *form = isindex.form();
- break;
- }
- case ID_SELECT: {
- DOM::HTMLSelectElement select = element;
- *form = select.form();
- break;
- }
- case ID_OPTION: {
- DOM::HTMLOptionElement option = element;
- *form = option.form();
- break;
- }
- case ID_INPUT: {
- DOM::HTMLInputElement input = element;
- *form = input.form();
- break;
- }
- case ID_TEXTAREA: {
- DOM::HTMLTextAreaElement textarea = element;
- *form = textarea.form();
- break;
- }
- case ID_LABEL: {
- DOM::HTMLLabelElement label = element;
- *form = label.form();
- break;
- }
- case ID_FIELDSET: {
- DOM::HTMLFieldSetElement fieldset = element;
- *form = fieldset.form();
- break;
- }
- case ID_LEGEND: {
- DOM::HTMLLegendElement legend = element;
- *form = legend.form();
- break;
- }
- case ID_OBJECT: {
- DOM::HTMLObjectElement object = element;
- *form = object.form();
- break;
- }
- default:
- break;
- }
+ if (element->isGenericFormElement())
+ return static_cast<HTMLGenericFormElementImpl *>(element)->form();
+
+ switch (element->id()) {
+ case ID_LABEL:
+ return static_cast<HTMLLabelElementImpl *>(element)->form();
+ case ID_OBJECT:
+ return static_cast<HTMLObjectElementImpl *>(element)->form();
+ }
+
+ return 0;
}
void KJS::HTMLElement::pushEventHandlerScope(ExecState *exec, ScopeChain &scope) const
{
- DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
+ HTMLElementImpl *element = static_cast<HTMLElementImpl *>(impl());
// The document is put on first, fall back to searching it only after the element and form.
- scope.push(static_cast<ObjectImp *>(getDOMNode(exec, element.ownerDocument()).imp()));
+ scope.push(static_cast<ObjectImp *>(getDOMNode(exec, element->ownerDocument())));
// The form is next, searched before the document, but after the element itself.
- DOM::HTMLFormElement formElt;
// First try to obtain the form from the element itself. We do this to deal with
// the malformed case where <form>s aren't in our parent chain (e.g., when they were inside
// <table> or <tbody>.
- getForm(&formElt, element);
- if (!formElt.isNull())
- scope.push(static_cast<ObjectImp *>(getDOMNode(exec, formElt).imp()));
+ HTMLFormElementImpl *form = getForm(element);
+ if (form)
+ scope.push(static_cast<ObjectImp *>(getDOMNode(exec, form)));
else {
- DOM::Node form = element.parentNode();
- while (!form.isNull() && form.elementId() != ID_FORM)
- form = form.parentNode();
+ NodeImpl *form = element->parentNode();
+ while (form && form->id() != ID_FORM)
+ form = form->parentNode();
- if (!form.isNull())
- scope.push(static_cast<ObjectImp *>(getDOMNode(exec, form).imp()));
+ if (form)
+ scope.push(static_cast<ObjectImp *>(getDOMNode(exec, form)));
}
// The element is on top, searched first.
- scope.push(static_cast<ObjectImp *>(getDOMNode(exec, element).imp()));
+ scope.push(static_cast<ObjectImp *>(getDOMNode(exec, element)));
}
HTMLElementFunction::HTMLElementFunction(ExecState *exec, int i, int len)
return err;
}
kdDebug() << "KJS::HTMLElementFunction::tryCall " << endl;
- DOM::HTMLElement element = static_cast<KJS::HTMLElement *>(thisObj.imp())->toElement();
+ DOMExceptionTranslator exception(exec);
+ HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(static_cast<HTMLElement *>(thisObj.imp())->impl());
- switch (element.elementId()) {
+ switch (element.id()) {
case ID_FORM: {
- DOM::HTMLFormElement form = element;
+ HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element);
if (id == KJS::HTMLElement::FormSubmit) {
form.submit();
return Undefined();
}
break;
case ID_SELECT: {
- DOM::HTMLSelectElement select = element;
+ HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element);
if (id == KJS::HTMLElement::SelectAdd) {
- select.add(KJS::toNode(args[0]),KJS::toNode(args[1]));
+ select.add(toHTMLElement(args[0]), toHTMLElement(args[1]));
return Undefined();
}
else if (id == KJS::HTMLElement::SelectRemove) {
}
break;
case ID_INPUT: {
- DOM::HTMLInputElement input = element;
+ HTMLInputElementImpl &input = static_cast<HTMLInputElementImpl &>(element);
if (id == KJS::HTMLElement::InputBlur) {
input.blur();
return Undefined();
}
break;
case ID_BUTTON: {
- DOM::HTMLButtonElement button = element;
+ HTMLButtonElementImpl &button = static_cast<HTMLButtonElementImpl &>(element);
if (id == KJS::HTMLElement::ButtonBlur) {
button.blur();
}
break;
case ID_TEXTAREA: {
- DOM::HTMLTextAreaElement textarea = element;
+ HTMLTextAreaElementImpl &textarea = static_cast<HTMLTextAreaElementImpl &>(element);
if (id == KJS::HTMLElement::TextAreaBlur) {
textarea.blur();
return Undefined();
}
break;
case ID_A: {
- DOM::HTMLAnchorElement anchor = element;
+ HTMLAnchorElementImpl &anchor = static_cast<HTMLAnchorElementImpl &>(element);
if (id == KJS::HTMLElement::AnchorBlur) {
anchor.blur();
return Undefined();
}
break;
case ID_TABLE: {
- DOM::HTMLTableElement table = element;
+ HTMLTableElementImpl &table = static_cast<HTMLTableElementImpl &>(element);
if (id == KJS::HTMLElement::TableCreateTHead)
return getDOMNode(exec,table.createTHead());
else if (id == KJS::HTMLElement::TableDeleteTHead) {
return Undefined();
}
else if (id == KJS::HTMLElement::TableInsertRow)
- return getDOMNode(exec,table.insertRow(args[0].toInt32(exec)));
+ return getDOMNode(exec,table.insertRow(args[0].toInt32(exec), exception));
else if (id == KJS::HTMLElement::TableDeleteRow) {
- table.deleteRow(args[0].toInt32(exec));
+ table.deleteRow(args[0].toInt32(exec), exception);
return Undefined();
}
}
case ID_THEAD:
case ID_TBODY:
case ID_TFOOT: {
- DOM::HTMLTableSectionElement tableSection = element;
+ HTMLTableSectionElementImpl &tableSection = static_cast<HTMLTableSectionElementImpl &>(element);
if (id == KJS::HTMLElement::TableSectionInsertRow)
- return getDOMNode(exec,tableSection.insertRow(args[0].toInt32(exec)));
+ return getDOMNode(exec, tableSection.insertRow(args[0].toInt32(exec), exception));
else if (id == KJS::HTMLElement::TableSectionDeleteRow) {
- tableSection.deleteRow(args[0].toInt32(exec));
+ tableSection.deleteRow(args[0].toInt32(exec), exception);
return Undefined();
}
}
break;
case ID_TR: {
- DOM::HTMLTableRowElement tableRow = element;
+ HTMLTableRowElementImpl &tableRow = static_cast<HTMLTableRowElementImpl &>(element);
if (id == KJS::HTMLElement::TableRowInsertCell)
- return getDOMNode(exec,tableRow.insertCell(args[0].toInt32(exec)));
+ return getDOMNode(exec,tableRow.insertCell(args[0].toInt32(exec), exception));
else if (id == KJS::HTMLElement::TableRowDeleteCell) {
- tableRow.deleteCell(args[0].toInt32(exec));
+ tableRow.deleteCell(args[0].toInt32(exec), exception);
return Undefined();
}
}
case ID_MARQUEE: {
- if (id == KJS::HTMLElement::MarqueeStart && element.handle()->renderer() &&
- element.handle()->renderer()->layer() &&
- element.handle()->renderer()->layer()->marquee()) {
- element.handle()->renderer()->layer()->marquee()->start();
+ if (id == KJS::HTMLElement::MarqueeStart && element.renderer() &&
+ element.renderer()->layer() &&
+ element.renderer()->layer()->marquee()) {
+ element.renderer()->layer()->marquee()->start();
return Undefined();
}
- else if (id == KJS::HTMLElement::MarqueeStop && element.handle()->renderer() &&
- element.handle()->renderer()->layer() &&
- element.handle()->renderer()->layer()->marquee()) {
- element.handle()->renderer()->layer()->marquee()->stop();
+ if (id == KJS::HTMLElement::MarqueeStop && element.renderer() &&
+ element.renderer()->layer() &&
+ element.renderer()->layer()->marquee()) {
+ element.renderer()->layer()->marquee()->stop();
return Undefined();
}
break;
case ID_CANVAS: {
if (id == KJS::HTMLElement::GetContext) {
if (args.size() == 0 || (args.size() == 1 && args[0].toString(exec).qstring().lower() == "2d")) {
- return Object(new Context2D(element));
+ return Object(new Context2D(&element));
}
return Undefined();
}
#ifdef KJS_VERBOSE
DOM::DOMString str = value.isA(NullType) ? DOM::DOMString() : value.toString(exec).string();
#endif
- DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
+ HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl());
#ifdef KJS_VERBOSE
kdDebug(6070) << "KJS::HTMLElement::tryPut " << propertyName.qstring()
<< " thisTag=" << element.tagName().string()
<< " str=" << str.string() << endl;
#endif
// First look at dynamic properties
- switch (element.elementId()) {
+ switch (element.id()) {
case ID_SELECT: {
- DOM::HTMLSelectElement select = element;
+ HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element);
bool ok;
/*uint u =*/ propertyName.toULong(&ok);
if (ok) {
- Object coll = Object::dynamicCast( getSelectHTMLCollection(exec, select.options(), select) );
+ Object coll = Object::dynamicCast( getSelectHTMLCollection(exec, select.optionsHTMLCollection().get(), &select) );
if ( !coll.isNull() )
coll.put(exec,propertyName,value);
return;
case ID_EMBED:
case ID_OBJECT:
case ID_APPLET: {
- Value domValue = getDOMNode(exec,element);
- Value runtimeObject = getRuntimeObject(exec,element);
+ Value runtimeObject = getRuntimeObject(exec,&element);
if (!runtimeObject.isNull()) {
ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp());
if (imp->canPut(exec, propertyName)) {
return;
}
}
- DOMObjectLookupPut<KJS::HTMLElement, DOMElement>(exec, propertyName, value, attr, &KJS::HTMLElementTable, this);
+ DOMObjectLookupPut<KJS::HTMLElement, DOMElement>(exec, propertyName, value, attr, &HTMLElementTable, this);
}
-void KJS::HTMLElement::putValue(ExecState *exec, int token, const Value& value, int)
+void HTMLElement::putValue(ExecState *exec, int token, const Value& value, int)
{
+ DOMExceptionTranslator exception(exec);
DOM::DOMString str = value.isA(NullType) ? DOM::DOMString() : value.toString(exec).string();
- DOMNode *kjsNode = new DOMNode(exec, KJS::toNode(value));
- // Need to create a Value wrapper to avoid leaking the KJS::DOMNode
- Value nodeValue(kjsNode);
- DOM::Node n = kjsNode->toNode();
- DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
+ HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl());
#ifdef KJS_VERBOSE
kdDebug(6070) << "KJS::HTMLElement::putValue "
<< " thisTag=" << element.tagName().string()
<< " token=" << token << endl;
#endif
- switch (element.elementId()) {
+ switch (element.id()) {
case ID_HTML: {
- DOM::HTMLHtmlElement html = element;
+ HTMLHtmlElementImpl &html = static_cast<HTMLHtmlElementImpl &>(element);
switch (token) {
case HtmlVersion: { html.setVersion(str); return; }
}
}
break;
case ID_HEAD: {
- DOM::HTMLHeadElement head = element;
+ HTMLHeadElementImpl &head = static_cast<HTMLHeadElementImpl &>(element);
switch (token) {
case HeadProfile: { head.setProfile(str); return; }
}
}
break;
case ID_LINK: {
- DOM::HTMLLinkElement link = element;
+ HTMLLinkElementImpl &link = static_cast<HTMLLinkElementImpl &>(element);
switch (token) {
case LinkDisabled: { link.setDisabled(value.toBoolean(exec)); return; }
case LinkCharset: { link.setCharset(str); return; }
}
break;
case ID_TITLE: {
- DOM::HTMLTitleElement title = element;
+ HTMLTitleElementImpl &title = static_cast<HTMLTitleElementImpl &>(element);
switch (token) {
case TitleText: { title.setText(str); return; }
}
}
break;
case ID_META: {
- DOM::HTMLMetaElement meta = element;
+ HTMLMetaElementImpl &meta = static_cast<HTMLMetaElementImpl &>(element);
switch (token) {
case MetaContent: { meta.setContent(str); return; }
case MetaHttpEquiv: { meta.setHttpEquiv(str); return; }
}
break;
case ID_BASE: {
- DOM::HTMLBaseElement base = element;
+ HTMLBaseElementImpl &base = static_cast<HTMLBaseElementImpl &>(element);
switch (token) {
case BaseHref: { base.setHref(str); return; }
case BaseTarget: { base.setTarget(str); return; }
}
break;
case ID_ISINDEX: {
- DOM::HTMLIsIndexElement isindex = element;
+ HTMLIsIndexElementImpl &isindex = static_cast<HTMLIsIndexElementImpl &>(element);
switch (token) {
// read-only: form
case IsIndexPrompt: { isindex.setPrompt(str); return; }
}
break;
case ID_STYLE: {
- DOM::HTMLStyleElement style = element;
+ HTMLStyleElementImpl &style = static_cast<HTMLStyleElementImpl &>(element);
switch (token) {
case StyleDisabled: { style.setDisabled(value.toBoolean(exec)); return; }
case StyleMedia: { style.setMedia(str); return; }
}
break;
case ID_BODY: {
- DOM::HTMLBodyElement body = element;
+ HTMLBodyElementImpl &body = static_cast<HTMLBodyElementImpl &>(element);
switch (token) {
case BodyALink: { body.setALink(str); return; }
case BodyBackground: { body.setBackground(str); return; }
case BodyVLink: { body.setVLink(str); return; }
case BodyScrollLeft:
case BodyScrollTop: {
- QScrollView* sview = body.ownerDocument().view();
+ QScrollView* sview = body.ownerDocument()->view();
if (sview) {
// Update the document's layout before we compute these attributes.
- DOM::DocumentImpl* docimpl = body.handle()->getDocument();
- if (docimpl)
- docimpl->updateLayoutIgnorePendingStylesheets();
+ if (DocumentImpl* doc = body.getDocument())
+ doc->updateLayoutIgnorePendingStylesheets();
if (token == BodyScrollLeft)
sview->setContentsPos(value.toInt32(exec), sview->contentsY());
else
}
break;
case ID_FORM: {
- DOM::HTMLFormElement form = element;
+ HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element);
switch (token) {
// read-only: elements
// read-only: length
case FormName: { form.setName(str); return; }
case FormAcceptCharset: { form.setAcceptCharset(str); return; }
- case FormAction: { form.setAction(str.string()); return; }
+ case FormAction: { form.setAction(str); return; }
case FormEncType: { form.setEnctype(str); return; }
case FormMethod: { form.setMethod(str); return; }
case FormTarget: { form.setTarget(str); return; }
}
break;
case ID_SELECT: {
- DOM::HTMLSelectElement select = element;
+ HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element);
switch (token) {
// read-only: type
case SelectSelectedIndex: { select.setSelectedIndex(value.toInt32(exec)); return; }
case SelectValue: { select.setValue(str); return; }
case SelectLength: { // read-only according to the NS spec, but webpages need it writeable
- Object coll = Object::dynamicCast( getSelectHTMLCollection(exec, select.options(), select) );
+ Object coll = Object::dynamicCast( getSelectHTMLCollection(exec, select.optionsHTMLCollection().get(), &select) );
if ( !coll.isNull() )
coll.put(exec,lengthPropertyName,value);
return;
}
break;
case ID_OPTGROUP: {
- DOM::HTMLOptGroupElement optgroup = element;
+ HTMLOptGroupElementImpl &optgroup = static_cast<HTMLOptGroupElementImpl &>(element);
switch (token) {
case OptGroupDisabled: { optgroup.setDisabled(value.toBoolean(exec)); return; }
case OptGroupLabel: { optgroup.setLabel(str); return; }
}
break;
case ID_OPTION: {
- DOM::HTMLOptionElement option = element;
+ HTMLOptionElementImpl &option = static_cast<HTMLOptionElementImpl &>(element);
switch (token) {
// read-only: form
case OptionDefaultSelected: { option.setDefaultSelected(value.toBoolean(exec)); return; }
- // read-only: text <--- According to the DOM, but JavaScript and JScript both allow changes.
- // So, we'll do it here and not add it to our DOM headers.
- case OptionText: { DOM::NodeList nl(option.childNodes());
- for (unsigned int i = 0; i < nl.length(); i++) {
- if (nl.item(i).nodeType() == DOM::Node::TEXT_NODE) {
- static_cast<DOM::Text>(nl.item(i)).setData(str);
- return;
- }
- }
- // No child text node found, creating one
- DOM::Text t = option.ownerDocument().createTextNode(str);
- try { option.appendChild(t); }
- catch(DOM::DOMException& e) {
- // #### exec->setException ?
- }
-
- return;
- }
+ case OptionText: { option.setText(str, exception); return; }
// read-only: index
case OptionDisabled: { option.setDisabled(value.toBoolean(exec)); return; }
case OptionLabel: { option.setLabel(str); return; }
}
break;
case ID_INPUT: {
- DOM::HTMLInputElement input = element;
+ HTMLInputElementImpl &input = static_cast<HTMLInputElementImpl &>(element);
switch (token) {
case InputDefaultValue: { input.setDefaultValue(str); return; }
case InputDefaultChecked: { input.setDefaultChecked(value.toBoolean(exec)); return; }
}
break;
case ID_TEXTAREA: {
- DOM::HTMLTextAreaElement textarea = element;
+ HTMLTextAreaElementImpl &textarea = static_cast<HTMLTextAreaElementImpl &>(element);
switch (token) {
case TextAreaDefaultValue: { textarea.setDefaultValue(str); return; }
// read-only: form
}
break;
case ID_BUTTON: {
- DOM::HTMLButtonElement button = element;
+ HTMLButtonElementImpl &button = static_cast<HTMLButtonElementImpl &>(element);
switch (token) {
// read-only: form
case ButtonAccessKey: { button.setAccessKey(str); return; }
}
break;
case ID_LABEL: {
- DOM::HTMLLabelElement label = element;
+ HTMLLabelElementImpl &label = static_cast<HTMLLabelElementImpl &>(element);
switch (token) {
// read-only: form
case LabelAccessKey: { label.setAccessKey(str); return; }
}
}
break;
-// case ID_FIELDSET: {
-// DOM::HTMLFieldSetElement fieldSet = element;
-// // read-only: form
-// }
-// break;
case ID_LEGEND: {
- DOM::HTMLLegendElement legend = element;
+ HTMLLegendElementImpl &legend = static_cast<HTMLLegendElementImpl &>(element);
switch (token) {
// read-only: form
case LegendAccessKey: { legend.setAccessKey(str); return; }
}
break;
case ID_UL: {
- DOM::HTMLUListElement uList = element;
+ HTMLUListElementImpl &uList = static_cast<HTMLUListElementImpl &>(element);
switch (token) {
case UListCompact: { uList.setCompact(value.toBoolean(exec)); return; }
case UListType: { uList.setType(str); return; }
}
break;
case ID_OL: {
- DOM::HTMLOListElement oList = element;
+ HTMLOListElementImpl &oList = static_cast<HTMLOListElementImpl &>(element);
switch (token) {
case OListCompact: { oList.setCompact(value.toBoolean(exec)); return; }
case OListStart: { oList.setStart(value.toInt32(exec)); return; }
}
break;
case ID_DL: {
- DOM::HTMLDListElement dList = element;
+ HTMLDListElementImpl &dList = static_cast<HTMLDListElementImpl &>(element);
switch (token) {
case DListCompact: { dList.setCompact(value.toBoolean(exec)); return; }
}
}
break;
case ID_DIR: {
- DOM::HTMLDirectoryElement directory = element;
+ HTMLDirectoryElementImpl &directory = static_cast<HTMLDirectoryElementImpl &>(element);
switch (token) {
case DirectoryCompact: { directory.setCompact(value.toBoolean(exec)); return; }
}
}
break;
case ID_MENU: {
- DOM::HTMLMenuElement menu = element;
+ HTMLMenuElementImpl &menu = static_cast<HTMLMenuElementImpl &>(element);
switch (token) {
case MenuCompact: { menu.setCompact(value.toBoolean(exec)); return; }
}
}
break;
case ID_LI: {
- DOM::HTMLLIElement li = element;
+ HTMLLIElementImpl &li = static_cast<HTMLLIElementImpl &>(element);
switch (token) {
case LIType: { li.setType(str); return; }
case LIValue: { li.setValue(value.toInt32(exec)); return; }
}
break;
case ID_DIV: {
- DOM::HTMLDivElement div = element;
+ HTMLDivElementImpl &div = static_cast<HTMLDivElementImpl &>(element);
switch (token) {
case DivAlign: { div.setAlign(str); return; }
}
}
break;
case ID_P: {
- DOM::HTMLParagraphElement paragraph = element;
+ HTMLParagraphElementImpl ¶graph = static_cast<HTMLParagraphElementImpl &>(element);
switch (token) {
case ParagraphAlign: { paragraph.setAlign(str); return; }
}
case ID_H4:
case ID_H5:
case ID_H6: {
- DOM::HTMLHeadingElement heading = element;
+ HTMLHeadingElementImpl &heading = static_cast<HTMLHeadingElementImpl &>(element);
switch (token) {
case HeadingAlign: { heading.setAlign(str); return; }
}
}
break;
case ID_BLOCKQUOTE: {
- DOM::HTMLBlockquoteElement blockquote = element;
+ HTMLBlockquoteElementImpl &blockquote = static_cast<HTMLBlockquoteElementImpl &>(element);
switch (token) {
case BlockQuoteCite: { blockquote.setCite(str); return; }
}
}
break;
case ID_Q: {
- DOM::HTMLQuoteElement quote = element;
+ HTMLQuoteElementImpl "e = static_cast<HTMLQuoteElementImpl &>(element);
switch (token) {
case QuoteCite: { quote.setCite(str); return; }
}
}
break;
case ID_PRE: {
- DOM::HTMLPreElement pre = element;
+ HTMLPreElementImpl &pre = static_cast<HTMLPreElementImpl &>(element);
switch (token) {
case PreWidth: { pre.setWidth(value.toInt32(exec)); return; }
}
}
break;
case ID_BR: {
- DOM::HTMLBRElement br = element;
+ HTMLBRElementImpl &br = static_cast<HTMLBRElementImpl &>(element);
switch (token) {
case BRClear: { br.setClear(str); return; }
}
}
break;
case ID_BASEFONT: {
- DOM::HTMLBaseFontElement baseFont = element;
+ HTMLBaseFontElementImpl &baseFont = static_cast<HTMLBaseFontElementImpl &>(element);
switch (token) {
case BaseFontColor: { baseFont.setColor(str); return; }
case BaseFontFace: { baseFont.setFace(str); return; }
}
break;
case ID_FONT: {
- DOM::HTMLFontElement font = element;
+ HTMLFontElementImpl &font = static_cast<HTMLFontElementImpl &>(element);
switch (token) {
case FontColor: { font.setColor(str); return; }
case FontFace: { font.setFace(str); return; }
}
break;
case ID_HR: {
- DOM::HTMLHRElement hr = element;
+ HTMLHRElementImpl &hr = static_cast<HTMLHRElementImpl &>(element);
switch (token) {
case HRAlign: { hr.setAlign(str); return; }
case HRNoShade: { hr.setNoShade(value.toBoolean(exec)); return; }
break;
case ID_INS:
case ID_DEL: {
- DOM::HTMLModElement mod = element;
+ HTMLModElementImpl &mod = static_cast<HTMLModElementImpl &>(element);
switch (token) {
case ModCite: { mod.setCite(str); return; }
case ModDateTime: { mod.setDateTime(str); return; }
}
break;
case ID_A: {
- DOM::HTMLAnchorElement anchor = element;
+ HTMLAnchorElementImpl &anchor = static_cast<HTMLAnchorElementImpl &>(element);
switch (token) {
case AnchorAccessKey: { anchor.setAccessKey(str); return; }
case AnchorCharset: { anchor.setCharset(str); return; }
}
break;
case ID_IMG: {
- DOM::HTMLImageElement image = element;
+ HTMLImageElementImpl &image = static_cast<HTMLImageElementImpl &>(element);
switch (token) {
case ImageName: { image.setName(str); return; }
case ImageAlign: { image.setAlign(str); return; }
}
break;
case ID_OBJECT: {
- DOM::HTMLObjectElement object = element;
+ HTMLObjectElementImpl &object = static_cast<HTMLObjectElementImpl &>(element);
switch (token) {
// read-only: form
case ObjectCode: { object.setCode(str); return; }
}
break;
case ID_PARAM: {
- DOM::HTMLParamElement param = element;
+ HTMLParamElementImpl ¶m = static_cast<HTMLParamElementImpl &>(element);
switch (token) {
case ParamName: { param.setName(str); return; }
case ParamType: { param.setType(str); return; }
}
break;
case ID_APPLET: {
- DOM::HTMLAppletElement applet = element;
+ HTMLAppletElementImpl &applet = static_cast<HTMLAppletElementImpl &>(element);
switch (token) {
case AppletAlign: { applet.setAlign(str); return; }
case AppletAlt: { applet.setAlt(str); return; }
}
break;
case ID_MAP: {
- DOM::HTMLMapElement map = element;
+ HTMLMapElementImpl &map = static_cast<HTMLMapElementImpl &>(element);
switch (token) {
// read-only: areas
case MapName: { map.setName(str); return; }
}
break;
case ID_AREA: {
- DOM::HTMLAreaElement area = element;
+ HTMLAreaElementImpl &area = static_cast<HTMLAreaElementImpl &>(element);
switch (token) {
case AreaAccessKey: { area.setAccessKey(str); return; }
case AreaAlt: { area.setAlt(str); return; }
}
break;
case ID_SCRIPT: {
- DOM::HTMLScriptElement script = element;
+ HTMLScriptElementImpl &script = static_cast<HTMLScriptElementImpl &>(element);
switch (token) {
case ScriptText: { script.setText(str); return; }
case ScriptHtmlFor: { script.setHtmlFor(str); return; }
}
break;
case ID_TABLE: {
- DOM::HTMLTableElement table = element;
+ HTMLTableElementImpl &table = static_cast<HTMLTableElementImpl &>(element);
switch (token) {
- case TableCaption: { table.setCaption(n); return; } // type HTMLTableCaptionElement
- case TableTHead: { table.setTHead(n); return; } // type HTMLTableSectionElement
- case TableTFoot: { table.setTFoot(n); return; } // type HTMLTableSectionElement
+ case TableCaption: { table.setCaption(toHTMLTableCaptionElement(value)); return; }
+ case TableTHead: { table.setTHead(toHTMLTableSectionElement(value)); return; }
+ case TableTFoot: { table.setTFoot(toHTMLTableSectionElement(value)); return; }
// read-only: rows
// read-only: tbodies
case TableAlign: { table.setAlign(str); return; }
}
break;
case ID_CAPTION: {
- DOM::HTMLTableCaptionElement tableCaption;
+ HTMLTableCaptionElementImpl &tableCaption = static_cast<HTMLTableCaptionElementImpl &>(element);
switch (token) {
case TableAlign: { tableCaption.setAlign(str); return; }
}
}
break;
case ID_COL: {
- DOM::HTMLTableColElement tableCol = element;
+ HTMLTableColElementImpl &tableCol = static_cast<HTMLTableColElementImpl &>(element);
switch (token) {
case TableColAlign: { tableCol.setAlign(str); return; }
case TableColCh: { tableCol.setCh(str); return; }
case ID_THEAD:
case ID_TBODY:
case ID_TFOOT: {
- DOM::HTMLTableSectionElement tableSection = element;
+ HTMLTableSectionElementImpl &tableSection = static_cast<HTMLTableSectionElementImpl &>(element);
switch (token) {
case TableSectionAlign: { tableSection.setAlign(str); return; }
case TableSectionCh: { tableSection.setCh(str); return; }
}
break;
case ID_TR: {
- DOM::HTMLTableRowElement tableRow = element;
+ HTMLTableRowElementImpl &tableRow = static_cast<HTMLTableRowElementImpl &>(element);
switch (token) {
// read-only: rowIndex
// read-only: sectionRowIndex
break;
case ID_TH:
case ID_TD: {
- DOM::HTMLTableCellElement tableCell = element;
+ HTMLTableCellElementImpl &tableCell = static_cast<HTMLTableCellElementImpl &>(element);
switch (token) {
// read-only: cellIndex
case TableCellAbbr: { tableCell.setAbbr(str); return; }
}
break;
case ID_FRAMESET: {
- DOM::HTMLFrameSetElement frameSet = element;
+ HTMLFrameSetElementImpl &frameSet = static_cast<HTMLFrameSetElementImpl &>(element);
switch (token) {
case FrameSetCols: { frameSet.setCols(str); return; }
case FrameSetRows: { frameSet.setRows(str); return; }
}
break;
case ID_FRAME: {
- DOM::HTMLFrameElement frameElement = element;
+ HTMLFrameElementImpl &frameElement = static_cast<HTMLFrameElementImpl &>(element);
switch (token) {
// read-only: FrameContentDocument:
case FrameFrameBorder: { frameElement.setFrameBorder(str); return; }
case FrameNoResize: { frameElement.setNoResize(value.toBoolean(exec)); return; }
case FrameScrolling: { frameElement.setScrolling(str); return; }
case FrameSrc: { frameElement.setSrc(str); return; }
- case FrameLocation: {
- static_cast<DOM::HTMLFrameElementImpl *>(frameElement.handle())->setLocation(str);
- return;
- }
+ case FrameLocation: { frameElement.setLocation(str); return; }
}
}
break;
case ID_IFRAME: {
- DOM::HTMLIFrameElement iFrame = element;
+ HTMLIFrameElementImpl &iFrame = static_cast<HTMLIFrameElementImpl &>(element);
switch (token) {
case IFrameAlign: { iFrame.setAlign(str); return; }
// read-only: IFrameContentDocument
element.setClassName(str);
return;
case ElementInnerHTML:
- element.setInnerHTML(str);
+ element.setInnerHTML(str, exception);
return;
case ElementInnerText:
- element.setInnerText(str);
+ element.setInnerText(str, exception);
return;
case ElementOuterHTML:
- element.setOuterHTML(str);
+ element.setOuterHTML(str, exception);
return;
case ElementOuterText:
- element.setOuterText(str);
+ element.setOuterText(str, exception);
return;
case ElementContentEditable:
element.setContentEditable(str);
}
}
+HTMLElementImpl *toHTMLElement(ValueImp *val)
+{
+ if (!val || !val->isObject(&HTMLElement::info))
+ return 0;
+ return static_cast<HTMLElementImpl *>(static_cast<HTMLElement *>(val)->impl());
+}
+
+HTMLTableCaptionElementImpl *toHTMLTableCaptionElement(ValueImp *val)
+{
+ if (HTMLElementImpl *e = toHTMLElement(val))
+ switch (e->id()) {
+ case ID_CAPTION:
+ return static_cast<HTMLTableCaptionElementImpl *>(e);
+ }
+ return 0;
+}
+
+HTMLTableSectionElementImpl *toHTMLTableSectionElement(ValueImp *val)
+{
+ if (HTMLElementImpl *e = toHTMLElement(val))
+ switch (e->id()) {
+ case ID_THEAD:
+ case ID_TBODY:
+ case ID_TFOOT:
+ return static_cast<HTMLTableSectionElementImpl *>(e);
+ }
+ return 0;
+}
+
// -------------------------------------------------------------------------
/* Source for HTMLCollectionProtoTable. Use "make hashtables" to regenerate.
@begin HTMLCollectionProtoTable 3
const ClassInfo HTMLCollection::info = { "HTMLCollection", 0, 0, 0 };
-HTMLCollection::HTMLCollection(ExecState *exec, const DOM::HTMLCollection &c)
- : collection(c)
+HTMLCollection::HTMLCollection(ExecState *exec, HTMLCollectionImpl *c)
+ : m_impl(c)
{
setPrototype(HTMLCollectionProto::self(exec));
}
HTMLCollection::~HTMLCollection()
{
- ScriptInterpreter::forgetDOMObject(collection.handle());
+ ScriptInterpreter::forgetDOMObject(m_impl.get());
}
// We have to implement hasProperty since we don't use a hashtable for 'selectedIndex' and 'length'
#ifdef KJS_VERBOSE
kdDebug() << "KJS::HTMLCollection::tryGet " << propertyName.ascii() << endl;
#endif
+ HTMLCollectionImpl &collection = *m_impl;
if (propertyName == lengthPropertyName)
return Number(collection.length());
- else if (propertyName == "selectedIndex" &&
- collection.item(0).elementId() == ID_OPTION) {
+ else if (propertyName == "selectedIndex") {
// NON-STANDARD options.selectedIndex
- DOM::Node node = collection.item(0).parentNode();
- while(!node.isNull()) {
- if(node.elementId() == ID_SELECT) {
- DOM::HTMLSelectElement sel = static_cast<DOM::HTMLSelectElement>(node);
- return Number(sel.selectedIndex());
- }
- node = node.parentNode();
+ NodeImpl *option = collection.item(0);
+ if (option->id() == ID_OPTION) {
+ NodeImpl *select = option;
+ while ((select = select->parentNode()))
+ if (select->id() == ID_SELECT)
+ return Number(static_cast<HTMLSelectElementImpl *>(select)->selectedIndex());
}
return Undefined();
} else {
// name or index ?
bool ok;
unsigned int u = propertyName.toULong(&ok);
- if (ok) {
- DOM::Node node = collection.item(u);
-
- return getDOMNode(exec,node);
- }
- else
- return getNamedItems(exec,propertyName);
+ if (ok)
+ return getDOMNode(exec, collection.item(u));
+ return getNamedItems(exec, propertyName);
}
- return Undefined();
}
// HTMLCollections are strange objects, they support both get and call,
KJS::printInfo(exec,"KJS::HTMLCollection::tryCall thisObj",thisObj,-1);
KJS::printInfo(exec,"KJS::HTMLCollection::tryCall this",Value(this),-1);
}*/
+ HTMLCollectionImpl &collection = *m_impl;
+
// Also, do we need the TypeError test here ?
if (args.size() == 1) {
bool ok;
UString s = args[0].toString(exec);
unsigned int u = s.toULong(&ok);
- if (ok) {
- DOM::Element element = collection.item(u);
- return getDOMNode(exec,element);
- }
+ if (ok)
+ return getDOMNode(exec, collection.item(u));
// support for document.images('<name>') etc.
return getNamedItems(exec, Identifier(s));
}
if (ok)
{
DOM::DOMString pstr = s.string();
- DOM::Node node = collection.namedItem(pstr);
- while (!node.isNull()) {
+ NodeImpl *node = collection.namedItem(pstr);
+ while (node) {
if (!u)
return getDOMNode(exec,node);
node = collection.nextNamedItem(pstr);
#endif
DOM::DOMString pstr = propertyName.string();
- QValueList<DOM::Node> namedItems = collection.namedItems(pstr);
+ QValueList< SharedPtr<NodeImpl> > namedItems = m_impl->namedItems(pstr);
if (namedItems.isEmpty()) {
#ifdef KJS_VERBOSE
return Undefined();
}
- if (namedItems.count() == 1) {
- DOM::Node node = namedItems[0];
- return getDOMNode(exec,node);
- }
+ if (namedItems.count() == 1)
+ return getDOMNode(exec, namedItems[0].get());
return Value(new DOMNamedNodesCollection(exec,namedItems));
}
exec->setException(err);
return err;
}
- DOM::HTMLCollection coll = static_cast<KJS::HTMLCollection *>(thisObj.imp())->toCollection();
+ HTMLCollectionImpl &coll = *static_cast<HTMLCollection *>(thisObj.imp())->impl();
switch (id) {
case KJS::HTMLCollection::Item:
return getDOMNode(exec,coll.item(args[0].toUInt32(exec)));
case KJS::HTMLCollection::Tags:
- {
- DOM::DOMString tagName = args[0].toString(exec).string();
- DOM::NodeList list;
- // getElementsByTagName exists in Document and in Element, pick up the right one
- if ( coll.base().nodeType() == DOM::Node::DOCUMENT_NODE )
- {
- DOM::Document doc = coll.base();
- list = doc.getElementsByTagName(tagName);
-#ifdef KJS_VERBOSE
- kdDebug() << "KJS::HTMLCollectionProtoFunc::tryCall document.tags(" << tagName.string() << ") -> " << list.length() << " items in node list" << endl;
-#endif
- } else
- {
- DOM::Element e = coll.base();
- list = e.getElementsByTagName(tagName);
-#ifdef KJS_VERBOSE
- kdDebug() << "KJS::HTMLCollectionProtoFunc::tryCall element.tags(" << tagName.string() << ") -> " << list.length() << " items in node list" << endl;
-#endif
- }
- return getDOMNodeList(exec, list);
- }
+ return getDOMNodeList(exec, coll.base()->getElementsByTagName(args[0].toString(exec).string()).get());
case KJS::HTMLCollection::NamedItem:
return static_cast<HTMLCollection *>(thisObj.imp())->getNamedItems(exec, Identifier(args[0].toString(exec)));
default:
}
}
+// -------------------------------------------------------------------------
+
+HTMLSelectCollection::HTMLSelectCollection(ExecState *exec, HTMLCollectionImpl *c, HTMLSelectElementImpl *e)
+ : HTMLCollection(exec, c), m_element(e)
+{
+}
+
Value KJS::HTMLSelectCollection::tryGet(ExecState *exec, const Identifier &p) const
{
if (p == "selectedIndex")
- return Number(element.selectedIndex());
+ return Number(m_element->selectedIndex());
return HTMLCollection::tryGet(exec, p);
}
kdDebug(6070) << "KJS::HTMLSelectCollection::tryPut " << propertyName.qstring() << endl;
#endif
if ( propertyName == "selectedIndex" ) {
- element.setSelectedIndex( value.toInt32( exec ) );
+ m_element->setSelectedIndex( value.toInt32( exec ) );
return;
}
// resize ?
else if (propertyName == lengthPropertyName) {
+ int exception = 0;
+
unsigned newLen;
bool converted = value.toUInt32(newLen);
return;
}
- long diff = element.length() - newLen;
+ long diff = m_element->length() - newLen;
if (diff < 0) { // add dummy elements
do {
- element.add(element.ownerDocument().createElement("option"), DOM::HTMLElement());
+ ElementImpl *option = m_element->ownerDocument()->createElement("option", exception);
+ m_element->add(static_cast<HTMLElementImpl *>(option), 0);
+ if (exception)
+ break;
} while (++diff);
}
else // remove elements
while (diff-- > 0)
- element.remove(newLen);
+ m_element->remove(newLen);
+ setDOMException(exec, exception);
return;
}
// an index ?
if (value.isA(NullType) || value.isA(UndefinedType)) {
// null and undefined delete. others, too ?
- element.remove(u);
+ m_element->remove(u);
return;
}
// is v an option element ?
- DOM::Node node = KJS::toNode(value);
- if (node.isNull() || node.elementId() != ID_OPTION)
+ NodeImpl *option = toNode(value);
+ if (!option || option->id() != ID_OPTION)
return;
- DOM::HTMLOptionElement option = static_cast<DOM::HTMLOptionElement>(node);
- long diff = long(u) - element.length();
- DOM::HTMLElement before;
+ int exception = 0;
+ long diff = long(u) - m_element->length();
+ HTMLElementImpl *before = 0;
// out of array bounds ? first insert empty dummies
if (diff > 0) {
while (diff--) {
- element.add(element.ownerDocument().createElement("option"), before);
+ ElementImpl *dummyOption = m_element->ownerDocument()->createElement("option", exception);
+ if (!dummyOption)
+ break;
+ m_element->add(static_cast<HTMLElementImpl *>(dummyOption), 0);
}
// replace an existing entry ?
} else if (diff < 0) {
- before = element.options().item(u+1);
- element.remove(u);
+ before = static_cast<HTMLElementImpl *>(m_element->options()->item(u+1));
+ m_element->remove(u);
}
// finally add the new element
- element.add(option, before);
+ if (exception == 0)
+ m_element->add(static_cast<HTMLOptionElementImpl *>(option), before);
+
+ setDOMException(exec, exception);
}
////////////////////// Option Object ////////////////////////
-OptionConstructorImp::OptionConstructorImp(ExecState *exec, const DOM::Document &d)
- : ObjectImp(), doc(d)
+OptionConstructorImp::OptionConstructorImp(ExecState *exec, DocumentImpl *d)
+ : m_doc(d)
{
// ## isn't there some redundancy between ObjectImp::_proto and the "prototype" property ?
//put(exec,"prototype", ...,DontEnum|DontDelete|ReadOnly);
Object OptionConstructorImp::construct(ExecState *exec, const List &args)
{
- DOM::Element el = doc.createElement("option");
- DOM::HTMLOptionElement opt = static_cast<DOM::HTMLOptionElement>(el);
- int sz = args.size();
- DOM::Text t = doc.createTextNode("");
- try { opt.appendChild(t); }
- catch(DOM::DOMException& e) {
- // #### exec->setException ?
+ int exception = 0;
+ ElementImpl *el = m_doc->createElement("option", exception);
+ HTMLOptionElementImpl *opt = 0;
+ if (el) {
+ el->ref();
+ opt = static_cast<HTMLOptionElementImpl *>(el);
+ int sz = args.size();
+ TextImpl *t = m_doc->createTextNode("");
+ t->ref();
+ opt->appendChild(t, exception);
+ if (exception == 0 && sz > 0)
+ t->setData(args[0].toString(exec).string(), exception); // set the text
+ if (exception == 0 && sz > 1)
+ opt->setValue(args[1].toString(exec).string());
+ if (exception == 0 && sz > 2)
+ opt->setDefaultSelected(args[2].toBoolean(exec));
+ if (exception == 0 && sz > 3)
+ opt->setSelected(args[3].toBoolean(exec));
+ t->deref();
+ el->deref();
}
- if (sz > 0)
- t.setData(args[0].toString(exec).string()); // set the text
- if (sz > 1)
- opt.setValue(args[1].toString(exec).string());
- if (sz > 2)
- opt.setDefaultSelected(args[2].toBoolean(exec));
- if (sz > 3)
- opt.setSelected(args[3].toBoolean(exec));
+ setDOMException(exec, exception);
return Object::dynamicCast(getDOMNode(exec,opt));
}
////////////////////// Image Object ////////////////////////
-ImageConstructorImp::ImageConstructorImp(ExecState *, const DOM::Document &d)
- : ObjectImp(), doc(d)
+ImageConstructorImp::ImageConstructorImp(ExecState *, DocumentImpl *d)
+ : m_doc(d)
{
}
height = h.toInt32(exec);
}
- Object result(new Image(doc, widthSet, width, heightSet, height));
+ Object result(new Image(m_doc.get(), widthSet, width, heightSet, height));
/* TODO: do we need a prototype ? */
return result;
void Image::notifyFinished(khtml::CachedObject *)
{
if (onLoadListener && doc->part()) {
- DOM::Event ev = doc->part()->document().createEvent("HTMLEvents");
- ev.initEvent("load", true, true);
- onLoadListener->handleEvent(ev, true);
+ int ignoreException;
+ EventImpl *ev = doc->createEvent("HTMLEvents", ignoreException);
+ ev->ref();
+ ev->initEvent("load", true, true);
+ onLoadListener->handleEventImpl(ev, true);
+ ev->deref();
}
}
-Image::Image(const DOM::Document &d, bool ws, int w, bool hs, int h)
- : doc(static_cast<DOM::DocumentImpl*>(d.handle())), img(0), onLoadListener(0)
+Image::Image(DocumentImpl *d, bool ws, int w, bool hs, int h)
+ : doc(d), img(0), onLoadListener(0)
{
widthSet = ws;
width = w;
h = pixmap.height();
}
else if (o->inherits(&KJS::HTMLElement::img_info)){
- DOM::HTMLElement element = static_cast<KJS::HTMLElement *>(args[0].imp())->toElement();
- DOM::HTMLImageElementImpl *e = static_cast<DOM::HTMLImageElementImpl*>(element.handle());
+ NodeImpl *n = static_cast<HTMLElement *>(args[0].imp())->impl();
+ HTMLImageElementImpl *e = static_cast<HTMLImageElementImpl*>(n);
pixmap = e->pixmap();
w = pixmap.width();
h = pixmap.height();
}
else if (o->inherits(&KJS::HTMLElement::canvas_info)){
- DOM::HTMLElement element = static_cast<KJS::HTMLElement *>(args[0].imp())->toElement();
- DOM::HTMLCanvasElementImpl *e = static_cast<DOM::HTMLCanvasElementImpl*>(element.handle());
+ NodeImpl *n = static_cast<HTMLElement *>(args[0].imp())->impl();
+ HTMLCanvasElementImpl *e = static_cast<HTMLCanvasElementImpl*>(n);
khtml::RenderCanvasImage *renderer = static_cast<khtml::RenderCanvasImage*>(e->renderer());
if (!renderer) {
// No renderer, nothing to draw.
return Undefined();
}
-const ClassInfo KJS::Context2D::info = { "Context2D", 0, &Context2DTable, 0 };
+const ClassInfo Context2D::info = { "Context2D", 0, &Context2DTable, 0 };
/* Source for Context2DTable. Use "make hashtables" to regenerate.
@begin Context2DTable 48
}
-CGColorRef Context2D::colorRefFromValue(ExecState *exec, const Value &value)
+CGColorRef colorRefFromValue(ExecState *exec, const Value &value)
{
CGColorSpaceRef colorSpace;
float components[4];
return colorRef;
}
-QColor Context2D::colorFromValue(ExecState *exec, const Value &value)
+QColor colorFromValue(ExecState *exec, const Value &value)
{
QRgb color = DOM::CSSParser::parseColor(value.toString(exec).string());
return QColor(color);
case StrokeStyle: {
_strokeStyle = value;
if (value.type() == StringType) {
- QColor qc = Context2D::colorFromValue(exec, value);
+ QColor qc = colorFromValue(exec, value);
CGContextSetRGBStrokeColor(context, qc.red()/255., qc.green()/255., qc.blue()/255., qc.alpha()/255.);
}
else {
stateStack.removeLast();
}
-Context2D::Context2D(const DOM::HTMLElement &e)
- : _element(static_cast<DOM::HTMLElementImpl*>(e.handle())), _needsFlushRasterCache(0)
+Context2D::Context2D(HTMLElementImpl *e)
+ : _element(e), _needsFlushRasterCache(false)
{
_lineWidth = Number (1.);
_strokeStyle = String ("black");
{
}
+void Context2D::mark()
+{
+ ValueImp *v;
+
+ v = _strokeStyle;
+ if (!v->marked())
+ v->mark();
+
+ v = _fillStyle;
+ if (!v->marked())
+ v->mark();
+
+ v = _lineWidth;
+ if (!v->marked())
+ v->mark();
+
+ v = _lineCap;
+ if (!v->marked())
+ v->mark();
+
+ v = _lineJoin;
+ if (!v->marked())
+ v->mark();
+
+ v = _miterLimit;
+ if (!v->marked())
+ v->mark();
+
+ v = _shadowOffsetX;
+ if (!v->marked())
+ v->mark();
+
+ v = _shadowOffsetY;
+ if (!v->marked())
+ v->mark();
+
+ v = _shadowBlur;
+ if (!v->marked())
+ v->mark();
+
+ v = _shadowColor;
+ if (!v->marked())
+ v->mark();
+
+ v = _globalAlpha;
+ if (!v->marked())
+ v->mark();
+
+ v = _globalComposite;;
+ if (!v->marked())
+ v->mark();
+
+ QPtrListIterator<List> it(stateStack);
+ List *list;
+ while ((list = it.current())) {
+ list->mark();
+ ++it;
+ }
+}
+
const ClassInfo KJS::Gradient::info = { "Gradient", 0, &GradientTable, 0 };
/* Source for GradientTable. Use "make hashtables" to regenerate.
IMPLEMENT_PROTOFUNC(GradientFunction)
-Value KJS::GradientFunction::tryCall(ExecState *exec, Object &thisObj, const List &args)
+Value GradientFunction::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
if (!thisObj.inherits(&Gradient::info)) {
Object err = Error::create(exec,TypeError);
return err;
}
- QColor color = Context2D::colorFromValue(exec, args[1]);
+ 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);
}
}
return stops;
}
-const ClassInfo KJS::ImagePattern::info = { "ImagePattern", 0, &ImagePatternTable, 0 };
+const ClassInfo ImagePattern::info = { "ImagePattern", 0, &ImagePatternTable, 0 };
/* Source for ImagePatternTable. Use "make hashtables" to regenerate.
@begin ImagePatternTable 0
const HashEntry* entry = Lookup::findEntry(table, propertyName);
if (entry) {
if (entry->attr & Function)
- return lookupOrCreateFunction<KJS::GradientFunction>(exec, propertyName, this, entry->value, entry->params, entry->attr);
+ return lookupOrCreateFunction<GradientFunction>(exec, propertyName, this, entry->value, entry->params, entry->attr);
return getValueProperty(exec, entry->value);
}
////////////////////////////////////////////////////////////////
-Value KJS::getHTMLCollection(ExecState *exec, const DOM::HTMLCollection &c)
+ValueImp *getHTMLCollection(ExecState *exec, HTMLCollectionImpl *c)
{
- return cacheDOMObject<DOM::HTMLCollection, KJS::HTMLCollection>(exec, c);
+ return cacheDOMObject<HTMLCollectionImpl, HTMLCollection>(exec, c);
}
-Value KJS::getSelectHTMLCollection(ExecState *exec, const DOM::HTMLCollection &c, const DOM::HTMLSelectElement &e)
+ValueImp *getSelectHTMLCollection(ExecState *exec, HTMLCollectionImpl *c, HTMLSelectElementImpl *e)
{
DOMObject *ret;
- if (c.isNull())
+ if (!c)
return Null();
ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
- if ((ret = interp->getDOMObject(c.handle())))
- return Value(ret);
+ if ((ret = interp->getDOMObject(c)))
+ return ret;
else {
ret = new HTMLSelectCollection(exec, c, e);
- interp->putDOMObject(c.handle(),ret);
- return Value(ret);
+ interp->putDOMObject(c,ret);
+ return ret;
}
}
+
+} // namespace
#ifndef _KJS_HTML_H_
#define _KJS_HTML_H_
-#include "dom/html_document.h"
-#include "dom/html_base.h"
-#include "dom/html_misc.h"
-#include "dom/html_form.h"
-#include "misc/loader_client.h"
-
-#include "ecma/kjs_binding.h"
-#include "ecma/kjs_dom.h"
+#include "kjs_dom.h"
#include <qguardedptr.h>
+#include "misc/loader_client.h"
+#if APPLE_CHANGES
#include <ApplicationServices/ApplicationServices.h>
+#endif
-class HTMLElement;
+namespace DOM {
+ class HTMLCollectionImpl;
+ class HTMLDocumentImpl;
+ class HTMLElementImpl;
+ class HTMLSelectElementImpl;
+ class HTMLTableCaptionElementImpl;
+ class HTMLTableSectionElementImpl;
+};
namespace KJS {
class HTMLDocument : public DOMDocument {
public:
- HTMLDocument(ExecState *exec, const DOM::HTMLDocument &d) : DOMDocument(exec, d) { }
+ HTMLDocument(ExecState *exec, DOM::HTMLDocumentImpl *d);
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
void putValue(ExecState *exec, int token, const Value& value, int /*attr*/);
Images, Applets, Embeds, Links, Forms, Anchors, Scripts, All, Clear, Open, Close,
Write, WriteLn, GetElementsByName, CaptureEvents, ReleaseEvents,
BgColor, FgColor, AlinkColor, LinkColor, VlinkColor, LastModified, Height, Width, Dir, DesignMode };
- DOM::Document toDocument() const { return static_cast<DOM::Document>( node ); }
};
class HTMLElement : public DOMElement {
public:
- HTMLElement(ExecState *exec, const DOM::HTMLElement &e) : DOMElement(exec, e) { }
+ HTMLElement(ExecState *exec, DOM::HTMLElementImpl *e);
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
virtual bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
virtual UString toString(ExecState *exec) const;
virtual void pushEventHandlerScope(ExecState *exec, ScopeChain &scope) const;
- virtual const ClassInfo* classInfo() const;
- static const ClassInfo info;
-
-#if APPLE_CHANGES
virtual Value call(ExecState *exec, Object &thisObj, const List&args);
virtual bool implementsCall() const;
-#endif
+ virtual const ClassInfo* classInfo() const;
+ static const ClassInfo info;
static const ClassInfo html_info, head_info, link_info, title_info,
meta_info, base_info, isIndex_info, style_info, body_info, form_info,
ElementInnerHTML, ElementTitle, ElementId, ElementDir, ElementLang,
ElementClassName, ElementInnerText, ElementDocument, ElementChildren, ElementContentEditable,
ElementIsContentEditable, ElementOuterHTML, ElementOuterText};
-
- DOM::HTMLElement toElement() const { return static_cast<DOM::HTMLElement>(node); }
};
-
- class HTMLElementFunction : public DOMFunction {
- public:
- HTMLElementFunction(ExecState *exec, int i, int len);
- virtual Value tryCall(ExecState *exec, Object &thisObj, const List&args);
- private:
- int id;
- };
+ DOM::HTMLElementImpl *toHTMLElement(ValueImp *); // returns 0 if passed-in value is not a HTMLElement object
+ DOM::HTMLTableCaptionElementImpl *toHTMLTableCaptionElement(ValueImp *); // returns 0 if passed-in value is not a HTMLElement object for a HTMLTableCaptionElementImpl
+ DOM::HTMLTableSectionElementImpl *toHTMLTableSectionElement(ValueImp *); // returns 0 if passed-in value is not a HTMLElement object for a HTMLTableSectionElementImpl
class HTMLCollection : public DOMObject {
public:
- HTMLCollection(ExecState *exec, const DOM::HTMLCollection &c);
+ HTMLCollection(ExecState *exec, DOM::HTMLCollectionImpl *c);
~HTMLCollection();
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
virtual Value call(ExecState *exec, Object &thisObj, const List&args);
Value getNamedItems(ExecState *exec, const Identifier &propertyName) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
- DOM::HTMLCollection toCollection() const { return collection; }
+ DOM::HTMLCollectionImpl *impl() const { return m_impl.get(); }
protected:
- DOM::HTMLCollection collection;
+ khtml::SharedPtr<DOM::HTMLCollectionImpl> m_impl;
};
class HTMLSelectCollection : public HTMLCollection {
public:
- HTMLSelectCollection(ExecState *exec, const DOM::HTMLCollection &c, const DOM::HTMLSelectElement &e)
- : HTMLCollection(exec, c), element(e) { }
+ HTMLSelectCollection(ExecState *exec, DOM::HTMLCollectionImpl *c, DOM::HTMLSelectElementImpl *e);
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
private:
- DOM::HTMLSelectElement element;
+ khtml::SharedPtr<DOM::HTMLSelectElementImpl> m_element;
};
////////////////////// Option Object ////////////////////////
class OptionConstructorImp : public ObjectImp {
public:
- OptionConstructorImp(ExecState *exec, const DOM::Document &d);
+ OptionConstructorImp(ExecState *exec, DOM::DocumentImpl *d);
virtual bool implementsConstruct() const;
virtual Object construct(ExecState *exec, const List &args);
private:
- DOM::Document doc;
+ khtml::SharedPtr<DOM::DocumentImpl> m_doc;
};
////////////////////// Image Object ////////////////////////
class ImageConstructorImp : public ObjectImp {
public:
- ImageConstructorImp(ExecState *exec, const DOM::Document &d);
+ ImageConstructorImp(ExecState *exec, DOM::DocumentImpl *d);
virtual bool implementsConstruct() const;
virtual Object construct(ExecState *exec, const List &args);
private:
- DOM::Document doc;
+ khtml::SharedPtr<DOM::DocumentImpl> m_doc;
};
class Image : public DOMObject, public khtml::CachedObjectClient {
public:
- Image(const DOM::Document &d, bool ws, int w, bool hs, int h);
+ Image(DOM::DocumentImpl *d, bool ws, int w, bool hs, int h);
~Image();
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
class Context2D : public DOMObject {
friend class Context2DFunction;
public:
- Context2D(const DOM::HTMLElement &e);
+ Context2D(DOM::HTMLElementImpl *e);
~Context2D();
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
void putValue(ExecState *exec, int token, const Value& value, int /*attr*/);
virtual bool toBoolean(ExecState *) const { return true; }
+ virtual void mark();
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
CreatePattern
};
- static CGColorRef colorRefFromValue(ExecState *exec, const Value &value);
- static QColor colorFromValue(ExecState *exec, const Value &value);
-
private:
-
void save();
void restore();
+ // FIXME: Macintosh specific, and should be abstracted by KWQ in QPainter.
CGContextRef drawingContext();
+
void setShadow(ExecState *exec);
- DOM::HTMLElementImpl *_element;
- unsigned int _needsFlushRasterCache;
+ khtml::SharedPtr<DOM::HTMLElementImpl> _element;
+ bool _needsFlushRasterCache;
QPtrList<List> stateStack;
- ProtectedValue _strokeStyle;
- ProtectedValue _fillStyle;
- ProtectedValue _lineWidth;
- ProtectedValue _lineCap;
- ProtectedValue _lineJoin;
- ProtectedValue _miterLimit;
- ProtectedValue _shadowOffsetX;
- ProtectedValue _shadowOffsetY;
- ProtectedValue _shadowBlur;
- ProtectedValue _shadowColor;
- ProtectedValue _globalAlpha;
- ProtectedValue _globalComposite;
+ Value _strokeStyle;
+ Value _fillStyle;
+ Value _lineWidth;
+ Value _lineCap;
+ Value _lineJoin;
+ Value _miterLimit;
+ Value _shadowOffsetX;
+ Value _shadowOffsetY;
+ Value _shadowBlur;
+ Value _shadowColor;
+ Value _globalAlpha;
+ Value _globalComposite;
};
+ // FIXME: Macintosh specific, and should be abstracted by KWQ in QPainter.
+ CGColorRef colorRefFromValue(ExecState *exec, ValueImp *value);
+
+ QColor colorFromValue(ExecState *exec, ValueImp *value);
+
struct ColorStop {
float stop;
float red;
ColorStop(float s, float r, float g, float b, float a) : stop(s), red(r), green(g), blue(b), alpha(a) {};
};
-
class Gradient : public DOMObject {
friend class Context2DFunction;
public:
- //Gradient(const DOM::HTMLElement &e);
Gradient(float x0, float y0, float x1, float y1);
Gradient(float x0, float y0, float r0, float x1, float y1, float r1);
~Gradient();
Radial, Linear
};
+ // FIXME: Macintosh specific, and should be abstracted by KWQ in QPainter.
CGShadingRef getShading();
void addColorStop (float s, float r, float g, float b, float alpha);
int _gradientType;
float _x0, _y0, _r0, _x1, _y1, _r1;
+
+ // FIXME: Macintosh specific, and should be abstracted by KWQ in QPainter.
CGShadingRef _shadingRef;
int maxStops;
ColorStop *stops;
mutable int adjustedStopCount;
mutable ColorStop *adjustedStops;
- mutable unsigned int stopsNeedAdjusting:1;
- mutable unsigned int regenerateShading:1;
+ mutable unsigned stopsNeedAdjusting:1;
+ mutable unsigned regenerateShading:1;
};
class ImagePattern : public DOMObject {
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
+ // FIXME: Macintosh specific, and should be abstracted by KWQ in QPainter.
CGPatternRef getPattern() { return _patternRef; }
QPixmap pixmap() { return _pixmap; }
private:
int _repetitionType;
QPixmap _pixmap;
+
+ // FIXME: Macintosh specific, and should be abstracted by KWQ in QPixmap.
CGPatternRef _patternRef;
};
- Value getHTMLCollection(ExecState *exec, const DOM::HTMLCollection &c);
- Value getSelectHTMLCollection(ExecState *exec, const DOM::HTMLCollection &c, const DOM::HTMLSelectElement &e);
-
+ ValueImp *getHTMLCollection(ExecState *exec, DOM::HTMLCollectionImpl *c);
+ ValueImp *getSelectHTMLCollection(ExecState *exec, DOM::HTMLCollectionImpl *c, DOM::HTMLSelectElementImpl *e);
-}; // namespace
+} // namespace
#endif
#include "KWQKCookieJar.h&q