Reviewed by Hyatt.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Mar 2006 08:41:16 +0000 (08:41 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Mar 2006 08:41:16 +0000 (08:41 +0000)
        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=7749
          canvas should be in DOM, not implemented in the JS bindings

        * WebCore.xcodeproj/project.pbxproj: Added new files.
        Changed bindings-generation code to work on the new html directory
        as well as the dom one.

        * bindings/js/JSCanvasRenderingContext2DBase.cpp: Added.
        * bindings/js/JSCanvasRenderingContext2DBase.h: Added.
        * bindings/js/JSDOMHTML.cpp: Added.
        * html: Added.
        * html/CanvasGradient.cpp: Added.
        * html/CanvasGradient.h: Added.
        * html/CanvasGradient.idl: Added.
        * html/CanvasPattern.cpp: Added.
        * html/CanvasPattern.h: Added.
        * html/CanvasPattern.idl: Added.
        * html/CanvasRenderingContext2D.cpp: Added.
        * html/CanvasRenderingContext2D.h: Added.
        * html/CanvasRenderingContext2D.idl: Added.
        * html/CanvasStyle.cpp: Added.
        * html/CanvasStyle.h: Added.

        * bindings/js/JSDOMCore.cpp: Touched so that it will recompile.
        * bindings/js/JSDOMEvents.cpp: Ditto.
        * dom/Attr.idl: Ditto.
        * dom/DOMImplementation.idl: Ditto.
        * dom/DocumentType.idl: Ditto.
        * dom/MutationEvent.idl: Ditto.
        * dom/ProcessingInstruction.idl: Ditto.
        * dom/Text.idl: Ditto.

        * khtml/ecma/kjs_binding.h: (KJS::toJS): Added. Template so that you can call
        toJS on a PassRefPtr as well as on a raw pointer.

        * bindings/scripts/CodeGeneratorJS.pm: Fixed handling of a class that has only
        a legacy parent, no conventional parents. Added JSCanvasRenderingContext2DBase
        as a legacy parent, and html as a legacy module. Added CanvasRenderingContext2D,
        CanvasGradient, and CanvasPattern to the "waht to include". Added a special
        case for strings beginning with Canvas to not add an "Impl" suffix. Made the
        generated impl() function be a const member function. Made m_mimpl be private
        instead of protected. Generate a toJS function for each class. Added flaot as
        a type. Generate String, not DOMString. Made the HashTable const.

        * bindings/scripts/IDLParser.pm: Fix a couple small things. I had started to
        try to make a missing semicolon trigger an error, but ended up giving up on
        that for now.

        * khtml/html/html_canvasimpl.h:
        * khtml/html/html_canvasimpl.cpp:
        (WebCore::HTMLCanvasElementImpl::HTMLCanvasElementImpl): Set m_2DContext to 0.
        (WebCore::HTMLCanvasElementImpl::~HTMLCanvasElementImpl): Call detachCanvas
        on m_2DContext, if any.
        (WebCore::HTMLCanvasElementImpl::detach): Call reset on m_2DContext, if any.
        (WebCore::HTMLCanvasElementImpl::getContext): Added.
        (WebCore::HTMLCanvasElementImpl::size): Added.
        (WebCore::HTMLCanvasElementImpl::createPlatformImage): Added.

        * platform/Image.h:
        * platform/Image.cpp: (WebCore::Image::compositeOperatorFromString):
        Changed to take a String instead of a const char*.

        * khtml/html/html_imageimpl.h:
        * khtml/html/html_imageimpl.cpp: (WebCore::HTMLMapElementImpl::areas):
        Tweaked formatting. Changed to use PassRefPtr.

        * bindings/objc/DOMInternal.mm: (-[WebScriptObject _initializeScriptDOMNodeImp]):
        * khtml/ecma/JSXMLHttpRequest.cpp: (KJS::JSXMLHttpRequest::getValueProperty):
        * khtml/ecma/XSLTProcessor.cpp: (KJS::XSLTProcessorProtoFunc::callAsFunction):
        * khtml/ecma/domparser.cpp: (KJS::DOMParserProtoFunc::callAsFunction):
        * khtml/ecma/kjs_css.cpp:
        (KJS::DOMCSSStyleDeclaration::getValueProperty):
        (KJS::DOMCSSStyleDeclarationProtoFunc::callAsFunction):
        (KJS::toJS):
        (KJS::DOMStyleSheet::getValueProperty):
        (KJS::DOMStyleSheetList::indexGetter):
        (KJS::DOMStyleSheetList::nameGetter):
        (KJS::DOMStyleSheetListFunc::callAsFunction):
        (KJS::DOMCSSStyleSheet::getValueProperty):
        (KJS::DOMCSSRuleList::indexGetter):
        (KJS::DOMCSSRuleListFunc::callAsFunction):
        (KJS::DOMCSSRule::getValueProperty):
        (KJS::DOMCSSPrimitiveValueProtoFunc::callAsFunction):
        (KJS::DOMCSSValueList::indexGetter):
        (KJS::DOMCSSValueListFunc::callAsFunction):
        (KJS::DOMRect::getValueProperty):
        * khtml/ecma/kjs_css.h:
        * khtml/ecma/kjs_dom.cpp:
        (KJS::DOMNode::getValueProperty):
        (KJS::DOMNodeProtoFunc::callAsFunction):
        (KJS::DOMNodeList::indexGetter):
        (KJS::DOMNodeList::nameGetter):
        (KJS::DOMNodeList::callAsFunction):
        (KJS::DOMNodeListFunc::callAsFunction):
        (KJS::DOMDocument::getValueProperty):
        (KJS::DOMDocumentProtoFunc::callAsFunction):
        (KJS::DOMNamedNodeMap::indexGetter):
        (KJS::DOMNamedNodeMap::nameGetter):
        (KJS::DOMNamedNodeMapProtoFunc::callAsFunction):
        (KJS::toJS):
        (KJS::DOMNamedNodesCollection::indexGetter):
        * khtml/ecma/kjs_dom.h:
        * khtml/ecma/kjs_events.cpp:
        (KJS::JSAbstractEventListener::handleEvent):
        (KJS::JSLazyEventListener::parseCode):
        (KJS::DOMEvent::getValueProperty):
        (KJS::toJS):
        (KJS::DOMUIEvent::getValueProperty):
        (KJS::DOMMouseEvent::getValueProperty):
        * khtml/ecma/kjs_events.h:
        * khtml/ecma/kjs_html.cpp:
        (KJS::HTMLDocFunction::callAsFunction):
        (KJS::HTMLDocument::namedItemGetter):
        (KJS::HTMLDocument::getValueProperty):
        (KJS::HTMLDocument::put):
        (KJS::HTMLDocument::putValueProperty):
        (KJS::HTMLElement::classInfo):
        (KJS::HTMLElement::formIndexGetter):
        (KJS::HTMLElement::selectIndexGetter):
        (KJS::HTMLElement::implementsCall):
        (KJS::HTMLElement::callAsFunction):
        (KJS::HTMLElement::linkGetter):
        (KJS::HTMLElement::isIndexGetter):
        (KJS::HTMLElement::styleGetter):
        (KJS::HTMLElement::selectGetter):
        (KJS::HTMLElement::optionGetter):
        (KJS::HTMLElement::inputGetter):
        (KJS::HTMLElement::textAreaGetter):
        (KJS::HTMLElement::buttonGetter):
        (KJS::HTMLElement::labelGetter):
        (KJS::HTMLElement::fieldSetGetter):
        (KJS::HTMLElement::legendGetter):
        (KJS::HTMLElement::objectGetter):
        (KJS::HTMLElement::tableGetter):
        (KJS::HTMLElement::frameGetter):
        (KJS::HTMLElement::iFrameGetter):
        (KJS::HTMLElement::getValueProperty):
        (KJS::HTMLElement::toString):
        (KJS::HTMLElement::pushEventHandlerScope):
        (KJS::toJS):
        (KJS::HTMLElementFunction::callAsFunction):
        (KJS::HTMLElement::put):
        (KJS::HTMLCollection::indexGetter):
        (KJS::HTMLCollection::callAsFunction):
        (KJS::HTMLCollection::getNamedItems):
        (KJS::HTMLCollectionProtoFunc::callAsFunction):
        (KJS::HTMLSelectCollection::put):
        (KJS::OptionConstructorImp::construct):
        (KJS::ImageConstructorImp::construct):
        * khtml/ecma/kjs_html.h:
        * khtml/ecma/kjs_proxy.cpp: (WebCore::KJSProxyImpl::evaluate):
        * khtml/ecma/kjs_range.cpp:
        (KJS::DOMRange::getValueProperty):
        (KJS::DOMRangeProtoFunc::callAsFunction):
        (KJS::toJS):
        * khtml/ecma/kjs_range.h:
        * khtml/ecma/kjs_traversal.cpp:
        (KJS::DOMNodeIterator::getValueProperty):
        (KJS::DOMNodeIteratorProtoFunc::callAsFunction):
        (KJS::toJS):
        (KJS::DOMTreeWalker::getValueProperty):
        (KJS::DOMTreeWalkerProtoFunc::callAsFunction):
        (KJS::JSNodeFilterCondition::acceptNode):
        * khtml/ecma/kjs_traversal.h:
        * khtml/ecma/kjs_views.cpp:
        (KJS::DOMAbstractView::getValueProperty):
        (KJS::DOMAbstractViewProtoFunc::callAsFunction):
        (KJS::toJS):
        * khtml/ecma/kjs_views.h:
        * khtml/ecma/kjs_window.cpp:
        (KJS::Window::getValueProperty):
        (KJS::Window::namedItemGetter):
        (KJS::Selection::getValueProperty):
        (KJS::SelectionFunc::callAsFunction):
        Rename uses and definitions of all the various converstions to JavaScript
        wrappers to the new common overloaded name: "toJS".

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

46 files changed:
WebCore/ChangeLog
WebCore/WebCore.vcproj/WebCore/build-generated-files.sh
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSCanvasRenderingContext2DBase.cpp [new file with mode: 0644]
WebCore/bindings/js/JSCanvasRenderingContext2DBase.h [new file with mode: 0644]
WebCore/bindings/js/JSDOMCore.cpp
WebCore/bindings/js/JSDOMEvents.cpp
WebCore/bindings/js/JSDOMHTML.cpp [new file with mode: 0644]
WebCore/bindings/objc/DOMInternal.mm
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/bindings/scripts/IDLParser.pm
WebCore/dom/Attr.idl
WebCore/dom/DOMImplementation.idl
WebCore/dom/DocumentType.idl
WebCore/dom/MutationEvent.idl
WebCore/dom/ProcessingInstruction.idl
WebCore/dom/Text.idl
WebCore/khtml/ecma/JSXMLHttpRequest.cpp
WebCore/khtml/ecma/XSLTProcessor.cpp
WebCore/khtml/ecma/domparser.cpp
WebCore/khtml/ecma/kjs_binding.h
WebCore/khtml/ecma/kjs_css.cpp
WebCore/khtml/ecma/kjs_css.h
WebCore/khtml/ecma/kjs_dom.cpp
WebCore/khtml/ecma/kjs_dom.h
WebCore/khtml/ecma/kjs_events.cpp
WebCore/khtml/ecma/kjs_events.h
WebCore/khtml/ecma/kjs_html.cpp
WebCore/khtml/ecma/kjs_html.h
WebCore/khtml/ecma/kjs_proxy.cpp
WebCore/khtml/ecma/kjs_range.cpp
WebCore/khtml/ecma/kjs_range.h
WebCore/khtml/ecma/kjs_traversal.cpp
WebCore/khtml/ecma/kjs_traversal.h
WebCore/khtml/ecma/kjs_views.cpp
WebCore/khtml/ecma/kjs_views.h
WebCore/khtml/ecma/kjs_window.cpp
WebCore/khtml/html/html_canvasimpl.cpp
WebCore/khtml/html/html_canvasimpl.h
WebCore/khtml/html/html_imageimpl.cpp
WebCore/khtml/html/html_imageimpl.h
WebCore/platform/FontData.h [changed mode: 0755->0644]
WebCore/platform/FontPlatformData.h [changed mode: 0755->0644]
WebCore/platform/Image.cpp
WebCore/platform/Image.h
WebCore/platform/win/FontPlatformDataWin.cpp [changed mode: 0755->0644]

index fd23d5a..a17df11 100644 (file)
@@ -1,3 +1,184 @@
+2006-03-15  Darin Adler  <darin@apple.com>
+
+        Reviewed by Hyatt.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=7749
+          canvas should be in DOM, not implemented in the JS bindings
+
+        * WebCore.xcodeproj/project.pbxproj: Added new files.
+        Changed bindings-generation code to work on the new html directory
+        as well as the dom one.
+
+        * bindings/js/JSCanvasRenderingContext2DBase.cpp: Added.
+        * bindings/js/JSCanvasRenderingContext2DBase.h: Added.
+        * bindings/js/JSDOMHTML.cpp: Added.
+        * html: Added.
+        * html/CanvasGradient.cpp: Added.
+        * html/CanvasGradient.h: Added.
+        * html/CanvasGradient.idl: Added.
+        * html/CanvasPattern.cpp: Added.
+        * html/CanvasPattern.h: Added.
+        * html/CanvasPattern.idl: Added.
+        * html/CanvasRenderingContext2D.cpp: Added.
+        * html/CanvasRenderingContext2D.h: Added.
+        * html/CanvasRenderingContext2D.idl: Added.
+        * html/CanvasStyle.cpp: Added.
+        * html/CanvasStyle.h: Added.
+
+        * bindings/js/JSDOMCore.cpp: Touched so that it will recompile.
+        * bindings/js/JSDOMEvents.cpp: Ditto.
+        * dom/Attr.idl: Ditto.
+        * dom/DOMImplementation.idl: Ditto.
+        * dom/DocumentType.idl: Ditto.
+        * dom/MutationEvent.idl: Ditto.
+        * dom/ProcessingInstruction.idl: Ditto.
+        * dom/Text.idl: Ditto.
+
+        * khtml/ecma/kjs_binding.h: (KJS::toJS): Added. Template so that you can call
+        toJS on a PassRefPtr as well as on a raw pointer.
+
+        * bindings/scripts/CodeGeneratorJS.pm: Fixed handling of a class that has only
+        a legacy parent, no conventional parents. Added JSCanvasRenderingContext2DBase
+        as a legacy parent, and html as a legacy module. Added CanvasRenderingContext2D,
+        CanvasGradient, and CanvasPattern to the "waht to include". Added a special
+        case for strings beginning with Canvas to not add an "Impl" suffix. Made the
+        generated impl() function be a const member function. Made m_mimpl be private
+        instead of protected. Generate a toJS function for each class. Added flaot as
+        a type. Generate String, not DOMString. Made the HashTable const.
+
+        * bindings/scripts/IDLParser.pm: Fix a couple small things. I had started to
+        try to make a missing semicolon trigger an error, but ended up giving up on
+        that for now.
+
+        * khtml/html/html_canvasimpl.h:
+        * khtml/html/html_canvasimpl.cpp:
+        (WebCore::HTMLCanvasElementImpl::HTMLCanvasElementImpl): Set m_2DContext to 0.
+        (WebCore::HTMLCanvasElementImpl::~HTMLCanvasElementImpl): Call detachCanvas
+        on m_2DContext, if any.
+        (WebCore::HTMLCanvasElementImpl::detach): Call reset on m_2DContext, if any.
+        (WebCore::HTMLCanvasElementImpl::getContext): Added.
+        (WebCore::HTMLCanvasElementImpl::size): Added.
+        (WebCore::HTMLCanvasElementImpl::createPlatformImage): Added.
+
+        * platform/Image.h:
+        * platform/Image.cpp: (WebCore::Image::compositeOperatorFromString):
+        Changed to take a String instead of a const char*.
+
+        * khtml/html/html_imageimpl.h:
+        * khtml/html/html_imageimpl.cpp: (WebCore::HTMLMapElementImpl::areas):
+        Tweaked formatting. Changed to use PassRefPtr.
+
+        * bindings/objc/DOMInternal.mm: (-[WebScriptObject _initializeScriptDOMNodeImp]):
+        * khtml/ecma/JSXMLHttpRequest.cpp: (KJS::JSXMLHttpRequest::getValueProperty):
+        * khtml/ecma/XSLTProcessor.cpp: (KJS::XSLTProcessorProtoFunc::callAsFunction):
+        * khtml/ecma/domparser.cpp: (KJS::DOMParserProtoFunc::callAsFunction):
+        * khtml/ecma/kjs_css.cpp:
+        (KJS::DOMCSSStyleDeclaration::getValueProperty):
+        (KJS::DOMCSSStyleDeclarationProtoFunc::callAsFunction):
+        (KJS::toJS):
+        (KJS::DOMStyleSheet::getValueProperty):
+        (KJS::DOMStyleSheetList::indexGetter):
+        (KJS::DOMStyleSheetList::nameGetter):
+        (KJS::DOMStyleSheetListFunc::callAsFunction):
+        (KJS::DOMCSSStyleSheet::getValueProperty):
+        (KJS::DOMCSSRuleList::indexGetter):
+        (KJS::DOMCSSRuleListFunc::callAsFunction):
+        (KJS::DOMCSSRule::getValueProperty):
+        (KJS::DOMCSSPrimitiveValueProtoFunc::callAsFunction):
+        (KJS::DOMCSSValueList::indexGetter):
+        (KJS::DOMCSSValueListFunc::callAsFunction):
+        (KJS::DOMRect::getValueProperty):
+        * khtml/ecma/kjs_css.h:
+        * khtml/ecma/kjs_dom.cpp:
+        (KJS::DOMNode::getValueProperty):
+        (KJS::DOMNodeProtoFunc::callAsFunction):
+        (KJS::DOMNodeList::indexGetter):
+        (KJS::DOMNodeList::nameGetter):
+        (KJS::DOMNodeList::callAsFunction):
+        (KJS::DOMNodeListFunc::callAsFunction):
+        (KJS::DOMDocument::getValueProperty):
+        (KJS::DOMDocumentProtoFunc::callAsFunction):
+        (KJS::DOMNamedNodeMap::indexGetter):
+        (KJS::DOMNamedNodeMap::nameGetter):
+        (KJS::DOMNamedNodeMapProtoFunc::callAsFunction):
+        (KJS::toJS):
+        (KJS::DOMNamedNodesCollection::indexGetter):
+        * khtml/ecma/kjs_dom.h:
+        * khtml/ecma/kjs_events.cpp:
+        (KJS::JSAbstractEventListener::handleEvent):
+        (KJS::JSLazyEventListener::parseCode):
+        (KJS::DOMEvent::getValueProperty):
+        (KJS::toJS):
+        (KJS::DOMUIEvent::getValueProperty):
+        (KJS::DOMMouseEvent::getValueProperty):
+        * khtml/ecma/kjs_events.h:
+        * khtml/ecma/kjs_html.cpp:
+        (KJS::HTMLDocFunction::callAsFunction):
+        (KJS::HTMLDocument::namedItemGetter):
+        (KJS::HTMLDocument::getValueProperty):
+        (KJS::HTMLDocument::put):
+        (KJS::HTMLDocument::putValueProperty):
+        (KJS::HTMLElement::classInfo):
+        (KJS::HTMLElement::formIndexGetter):
+        (KJS::HTMLElement::selectIndexGetter):
+        (KJS::HTMLElement::implementsCall):
+        (KJS::HTMLElement::callAsFunction):
+        (KJS::HTMLElement::linkGetter):
+        (KJS::HTMLElement::isIndexGetter):
+        (KJS::HTMLElement::styleGetter):
+        (KJS::HTMLElement::selectGetter):
+        (KJS::HTMLElement::optionGetter):
+        (KJS::HTMLElement::inputGetter):
+        (KJS::HTMLElement::textAreaGetter):
+        (KJS::HTMLElement::buttonGetter):
+        (KJS::HTMLElement::labelGetter):
+        (KJS::HTMLElement::fieldSetGetter):
+        (KJS::HTMLElement::legendGetter):
+        (KJS::HTMLElement::objectGetter):
+        (KJS::HTMLElement::tableGetter):
+        (KJS::HTMLElement::frameGetter):
+        (KJS::HTMLElement::iFrameGetter):
+        (KJS::HTMLElement::getValueProperty):
+        (KJS::HTMLElement::toString):
+        (KJS::HTMLElement::pushEventHandlerScope):
+        (KJS::toJS):
+        (KJS::HTMLElementFunction::callAsFunction):
+        (KJS::HTMLElement::put):
+        (KJS::HTMLCollection::indexGetter):
+        (KJS::HTMLCollection::callAsFunction):
+        (KJS::HTMLCollection::getNamedItems):
+        (KJS::HTMLCollectionProtoFunc::callAsFunction):
+        (KJS::HTMLSelectCollection::put):
+        (KJS::OptionConstructorImp::construct):
+        (KJS::ImageConstructorImp::construct):
+        * khtml/ecma/kjs_html.h:
+        * khtml/ecma/kjs_proxy.cpp: (WebCore::KJSProxyImpl::evaluate):
+        * khtml/ecma/kjs_range.cpp:
+        (KJS::DOMRange::getValueProperty):
+        (KJS::DOMRangeProtoFunc::callAsFunction):
+        (KJS::toJS):
+        * khtml/ecma/kjs_range.h:
+        * khtml/ecma/kjs_traversal.cpp:
+        (KJS::DOMNodeIterator::getValueProperty):
+        (KJS::DOMNodeIteratorProtoFunc::callAsFunction):
+        (KJS::toJS):
+        (KJS::DOMTreeWalker::getValueProperty):
+        (KJS::DOMTreeWalkerProtoFunc::callAsFunction):
+        (KJS::JSNodeFilterCondition::acceptNode):
+        * khtml/ecma/kjs_traversal.h:
+        * khtml/ecma/kjs_views.cpp:
+        (KJS::DOMAbstractView::getValueProperty):
+        (KJS::DOMAbstractViewProtoFunc::callAsFunction):
+        (KJS::toJS):
+        * khtml/ecma/kjs_views.h:
+        * khtml/ecma/kjs_window.cpp:
+        (KJS::Window::getValueProperty):
+        (KJS::Window::namedItemGetter):
+        (KJS::Selection::getValueProperty):
+        (KJS::SelectionFunc::callAsFunction):
+        Rename uses and definitions of all the various converstions to JavaScript
+        wrappers to the new common overloaded name: "toJS".
+
 2006-03-15  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by darin.
index 7950ff4..a67d956 100755 (executable)
@@ -151,5 +151,6 @@ if [ ../zlib/bin/zlib1.dll -nt "$WebKitOutputConfigDir/zlib1.dll" ]; then
 fi
 
 # Auto-generate bindings from .idl files
-echo "Auto-generating bindings from .idl files for the dom directory..."
+echo "Auto-generating bindings from .idl files"
 perl -I"$WebCoreSourceRoot/bindings/scripts" "$WebCoreSourceRoot/bindings/scripts/generate-bindings.pl" --generator JS --idldir "$WebCoreSourceRoot/dom" --outputdir "$DerivedSourcesDir"
+perl -I"$WebCoreSourceRoot/bindings/scripts" "$WebCoreSourceRoot/bindings/scripts/generate-bindings.pl" --generator JS --idldir "$WebCoreSourceRoot/html" --outputdir "$DerivedSourcesDir"
index d31f680..cf4149e 100644 (file)
                93032CC809AEC34300F82A18 /* PathCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93032CC709AEC34300F82A18 /* PathCG.cpp */; };
                93032CCA09AEC34B00F82A18 /* Path.h in Headers */ = {isa = PBXBuildFile; fileRef = 93032CC909AEC34B00F82A18 /* Path.h */; };
                9305B24D098F1B6B00C28855 /* Timer.h in Headers */ = {isa = PBXBuildFile; fileRef = 9305B24C098F1B6B00C28855 /* Timer.h */; };
+               930CAAD709C495B600229C04 /* CanvasRenderingContext2D.idl in Resources */ = {isa = PBXBuildFile; fileRef = 930CAAD609C495B600229C04 /* CanvasRenderingContext2D.idl */; };
+               930CAB8909C49EFA00229C04 /* CanvasGradient.idl in Resources */ = {isa = PBXBuildFile; fileRef = 930CAB8809C49EFA00229C04 /* CanvasGradient.idl */; };
+               930CAB9009C49F1B00229C04 /* CanvasPattern.idl in Resources */ = {isa = PBXBuildFile; fileRef = 930CAB8F09C49F1B00229C04 /* CanvasPattern.idl */; };
+               930CAB9709C49FAA00229C04 /* CodeGeneratorJS.pm in Resources */ = {isa = PBXBuildFile; fileRef = 930CAB9609C49FAA00229C04 /* CodeGeneratorJS.pm */; };
+               930CACBA09C4EE7700229C04 /* JSDOMHTML.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 930CACB909C4EE7700229C04 /* JSDOMHTML.cpp */; };
+               930CAD1509C4F3C300229C04 /* JSCanvasRenderingContext2DBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 930CAD1409C4F3C300229C04 /* JSCanvasRenderingContext2DBase.h */; };
+               930CAD2609C4F49100229C04 /* JSCanvasRenderingContext2DBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 930CAD2509C4F49100229C04 /* JSCanvasRenderingContext2DBase.cpp */; };
                9327A94209968D1A0068A546 /* HTMLOptionsCollectionImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9327A94109968D1A0068A546 /* HTMLOptionsCollectionImpl.cpp */; };
                93309DD6099E64920056E581 /* AppendNodeCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93309D87099E64910056E581 /* AppendNodeCommand.cpp */; };
                93309DD7099E64920056E581 /* AppendNodeCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 93309D88099E64910056E581 /* AppendNodeCommand.h */; };
                93CD4FE40995F9EA007ECC97 /* StringImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 93CD4FDD0995F9EA007ECC97 /* StringImpl.h */; };
                93CD4FEC0995FD2A007ECC97 /* PlatformString.h in Headers */ = {isa = PBXBuildFile; fileRef = 93CD4FEB0995FD2A007ECC97 /* PlatformString.h */; };
                93E62D9B0985F41600E1B5E3 /* SystemTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E62D990985F41600E1B5E3 /* SystemTime.h */; };
+               93EEC1F809C2877700C515D1 /* Attr.idl in Resources */ = {isa = PBXBuildFile; fileRef = 93EEC1E509C2877700C515D1 /* Attr.idl */; };
+               93EEC1F909C2877700C515D1 /* CharacterData.idl in Resources */ = {isa = PBXBuildFile; fileRef = 93EEC1E609C2877700C515D1 /* CharacterData.idl */; };
+               93EEC1FA09C2877700C515D1 /* DocPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EEC1E709C2877700C515D1 /* DocPtr.h */; };
+               93EEC1FB09C2877700C515D1 /* DocumentType.idl in Resources */ = {isa = PBXBuildFile; fileRef = 93EEC1E809C2877700C515D1 /* DocumentType.idl */; };
+               93EEC1FC09C2877700C515D1 /* DOMImplementation.idl in Resources */ = {isa = PBXBuildFile; fileRef = 93EEC1E909C2877700C515D1 /* DOMImplementation.idl */; };
+               93EEC1FD09C2877700C515D1 /* Element.idl in Resources */ = {isa = PBXBuildFile; fileRef = 93EEC1EA09C2877700C515D1 /* Element.idl */; };
+               93EEC1FE09C2877700C515D1 /* Entity.idl in Resources */ = {isa = PBXBuildFile; fileRef = 93EEC1EB09C2877700C515D1 /* Entity.idl */; };
+               93EEC1FF09C2877700C515D1 /* CanvasRenderingContext2D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93EEC1ED09C2877700C515D1 /* CanvasRenderingContext2D.cpp */; };
+               93EEC20009C2877700C515D1 /* CanvasRenderingContext2D.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EEC1EE09C2877700C515D1 /* CanvasRenderingContext2D.h */; };
+               93EEC20109C2877700C515D1 /* CanvasStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EEC1EF09C2877700C515D1 /* CanvasStyle.h */; };
+               93EEC20209C2877700C515D1 /* CanvasGradient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93EEC1F009C2877700C515D1 /* CanvasGradient.cpp */; };
+               93EEC20309C2877700C515D1 /* CanvasGradient.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EEC1F109C2877700C515D1 /* CanvasGradient.h */; };
+               93EEC20409C2877700C515D1 /* CanvasPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EEC1F209C2877700C515D1 /* CanvasPattern.h */; };
+               93EEC20509C2877700C515D1 /* MutationEvent.idl in Resources */ = {isa = PBXBuildFile; fileRef = 93EEC1F309C2877700C515D1 /* MutationEvent.idl */; };
+               93EEC20609C2877700C515D1 /* Notation.idl in Resources */ = {isa = PBXBuildFile; fileRef = 93EEC1F409C2877700C515D1 /* Notation.idl */; };
+               93EEC20709C2877700C515D1 /* ProcessingInstruction.idl in Resources */ = {isa = PBXBuildFile; fileRef = 93EEC1F509C2877700C515D1 /* ProcessingInstruction.idl */; };
+               93EEC20809C2877700C515D1 /* Text.idl in Resources */ = {isa = PBXBuildFile; fileRef = 93EEC1F609C2877700C515D1 /* Text.idl */; };
+               93EEC20909C2877700C515D1 /* WheelEvent.idl in Resources */ = {isa = PBXBuildFile; fileRef = 93EEC1F709C2877700C515D1 /* WheelEvent.idl */; };
+               93EEC26F09C3218000C515D1 /* CanvasPattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93EEC26E09C3218000C515D1 /* CanvasPattern.cpp */; };
+               93EEC27109C3218800C515D1 /* CanvasStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93EEC27009C3218800C515D1 /* CanvasStyle.cpp */; };
                93F198CE08245E59001E9ABC /* kjs_binding.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D1F502DE4369018635CA /* kjs_binding.h */; };
                93F198CF08245E59001E9ABC /* kjs_css.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D1F702DE4369018635CA /* kjs_css.h */; };
                93F198D108245E59001E9ABC /* kjs_dom.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D1FA02DE4369018635CA /* kjs_dom.h */; };
                93032CC709AEC34300F82A18 /* PathCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PathCG.cpp; sourceTree = "<group>"; };
                93032CC909AEC34B00F82A18 /* Path.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Path.h; path = platform/Path.h; sourceTree = "<group>"; };
                9305B24C098F1B6B00C28855 /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Timer.h; path = platform/Timer.h; sourceTree = "<group>"; };
+               930CAAD609C495B600229C04 /* CanvasRenderingContext2D.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CanvasRenderingContext2D.idl; sourceTree = "<group>"; };
+               930CAB8809C49EFA00229C04 /* CanvasGradient.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CanvasGradient.idl; sourceTree = "<group>"; };
+               930CAB8F09C49F1B00229C04 /* CanvasPattern.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CanvasPattern.idl; sourceTree = "<group>"; };
+               930CAB9609C49FAA00229C04 /* CodeGeneratorJS.pm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; name = CodeGeneratorJS.pm; path = bindings/scripts/CodeGeneratorJS.pm; sourceTree = "<group>"; };
+               930CACB909C4EE7700229C04 /* JSDOMHTML.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSDOMHTML.cpp; path = bindings/js/JSDOMHTML.cpp; sourceTree = "<group>"; };
+               930CAD1409C4F3C300229C04 /* JSCanvasRenderingContext2DBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSCanvasRenderingContext2DBase.h; path = bindings/js/JSCanvasRenderingContext2DBase.h; sourceTree = "<group>"; };
+               930CAD2509C4F49100229C04 /* JSCanvasRenderingContext2DBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSCanvasRenderingContext2DBase.cpp; path = bindings/js/JSCanvasRenderingContext2DBase.cpp; sourceTree = "<group>"; };
                9327A94109968D1A0068A546 /* HTMLOptionsCollectionImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLOptionsCollectionImpl.cpp; sourceTree = "<group>"; };
                93309D87099E64910056E581 /* AppendNodeCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppendNodeCommand.cpp; sourceTree = "<group>"; };
                93309D88099E64910056E581 /* AppendNodeCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppendNodeCommand.h; sourceTree = "<group>"; };
                93CD4FDD0995F9EA007ECC97 /* StringImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringImpl.h; path = platform/StringImpl.h; sourceTree = "<group>"; };
                93CD4FEB0995FD2A007ECC97 /* PlatformString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformString.h; path = platform/PlatformString.h; sourceTree = "<group>"; };
                93E62D990985F41600E1B5E3 /* SystemTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SystemTime.h; path = platform/SystemTime.h; sourceTree = "<group>"; };
+               93EEC1E509C2877700C515D1 /* Attr.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Attr.idl; sourceTree = "<group>"; };
+               93EEC1E609C2877700C515D1 /* CharacterData.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CharacterData.idl; sourceTree = "<group>"; };
+               93EEC1E709C2877700C515D1 /* DocPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocPtr.h; sourceTree = "<group>"; };
+               93EEC1E809C2877700C515D1 /* DocumentType.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DocumentType.idl; sourceTree = "<group>"; };
+               93EEC1E909C2877700C515D1 /* DOMImplementation.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMImplementation.idl; sourceTree = "<group>"; };
+               93EEC1EA09C2877700C515D1 /* Element.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Element.idl; sourceTree = "<group>"; };
+               93EEC1EB09C2877700C515D1 /* Entity.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Entity.idl; sourceTree = "<group>"; };
+               93EEC1ED09C2877700C515D1 /* CanvasRenderingContext2D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanvasRenderingContext2D.cpp; sourceTree = "<group>"; };
+               93EEC1EE09C2877700C515D1 /* CanvasRenderingContext2D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanvasRenderingContext2D.h; sourceTree = "<group>"; };
+               93EEC1EF09C2877700C515D1 /* CanvasStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanvasStyle.h; sourceTree = "<group>"; };
+               93EEC1F009C2877700C515D1 /* CanvasGradient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanvasGradient.cpp; sourceTree = "<group>"; };
+               93EEC1F109C2877700C515D1 /* CanvasGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanvasGradient.h; sourceTree = "<group>"; };
+               93EEC1F209C2877700C515D1 /* CanvasPattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanvasPattern.h; sourceTree = "<group>"; };
+               93EEC1F309C2877700C515D1 /* MutationEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MutationEvent.idl; sourceTree = "<group>"; };
+               93EEC1F409C2877700C515D1 /* Notation.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Notation.idl; sourceTree = "<group>"; };
+               93EEC1F509C2877700C515D1 /* ProcessingInstruction.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ProcessingInstruction.idl; sourceTree = "<group>"; };
+               93EEC1F609C2877700C515D1 /* Text.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Text.idl; sourceTree = "<group>"; };
+               93EEC1F709C2877700C515D1 /* WheelEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WheelEvent.idl; sourceTree = "<group>"; };
+               93EEC26E09C3218000C515D1 /* CanvasPattern.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanvasPattern.cpp; sourceTree = "<group>"; };
+               93EEC27009C3218800C515D1 /* CanvasStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanvasStyle.cpp; sourceTree = "<group>"; };
                93F19B1908245E59001E9ABC /* Info.plist */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                93F19B1A08245E5A001E9ABC /* WebCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WebCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                93F1D31A0558CC5C00821BC0 /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = /usr/lib/libicucore.dylib; sourceTree = "<absolute>"; };
                                F523D18402DE42E8018635CA /* css */,
                                F523D32402DE4478018635CA /* dom */,
                                93309D86099E64910056E581 /* editing */,
+                               93EEC1EC09C2877700C515D1 /* html */,
                                A8C0FB51089701F700BA5114 /* kcanvas */,
                                F523D16302DE42AE018635CA /* khtml */,
                                A8C0F6E9089701F100BA5114 /* ksvg2 */,
                        path = editing;
                        sourceTree = "<group>";
                };
+               93EEC1EC09C2877700C515D1 /* html */ = {
+                       isa = PBXGroup;
+                       children = (
+                               93EEC1F009C2877700C515D1 /* CanvasGradient.cpp */,
+                               93EEC1F109C2877700C515D1 /* CanvasGradient.h */,
+                               930CAB8809C49EFA00229C04 /* CanvasGradient.idl */,
+                               93EEC26E09C3218000C515D1 /* CanvasPattern.cpp */,
+                               93EEC1F209C2877700C515D1 /* CanvasPattern.h */,
+                               930CAB8F09C49F1B00229C04 /* CanvasPattern.idl */,
+                               93EEC1ED09C2877700C515D1 /* CanvasRenderingContext2D.cpp */,
+                               93EEC1EE09C2877700C515D1 /* CanvasRenderingContext2D.h */,
+                               930CAAD609C495B600229C04 /* CanvasRenderingContext2D.idl */,
+                               93EEC27009C3218800C515D1 /* CanvasStyle.cpp */,
+                               93EEC1EF09C2877700C515D1 /* CanvasStyle.h */,
+                       );
+                       path = html;
+                       sourceTree = "<group>";
+               };
                A8122C7B08D564B000844FA3 /* bindings */ = {
                        isa = PBXGroup;
                        children = (
                BC1A3793097C6FB10019F3D8 /* JavaScript */ = {
                        isa = PBXGroup;
                        children = (
+                               930CAB9609C49FAA00229C04 /* CodeGeneratorJS.pm */,
+                               930CAD2509C4F49100229C04 /* JSCanvasRenderingContext2DBase.cpp */,
+                               930CAD1409C4F3C300229C04 /* JSCanvasRenderingContext2DBase.h */,
                                1A2154EC099A11A800343DF8 /* JSDOMCore.cpp */,
                                1A2154ED099A11A800343DF8 /* JSDOMEvents.cpp */,
+                               930CACB909C4EE7700229C04 /* JSDOMHTML.cpp */,
                        );
                        name = JavaScript;
                        sourceTree = "<group>";
                        isa = PBXGroup;
                        children = (
                                BC3B364705C9D5E200E42902 /* AtomicStringList.h */,
+                               93EEC1E509C2877700C515D1 /* Attr.idl */,
                                AB23A32509BBA7D00067CC53 /* BeforeTextInsertedEventImpl.cpp */,
                                AB23A32609BBA7D00067CC53 /* BeforeTextInsertedEventImpl.h */,
                                6550B693099DF0270090D781 /* CDATASectionImpl.cpp */,
                                6550B694099DF0270090D781 /* CDATASectionImpl.h */,
+                               93EEC1E609C2877700C515D1 /* CharacterData.idl */,
                                6550B695099DF0270090D781 /* CharacterDataImpl.cpp */,
                                6550B696099DF0270090D781 /* CharacterDataImpl.h */,
                                A818721A0977D3C0005826D9 /* ChildNodeListImpl.cpp */,
                                6550B698099DF0270090D781 /* CommentImpl.h */,
                                A81872140977D3C0005826D9 /* ContainerNodeImpl.cpp */,
                                A81872110977D3C0005826D9 /* ContainerNodeImpl.h */,
+                               93EEC1E709C2877700C515D1 /* DocPtr.h */,
                                A8185F3709765765005826D9 /* DocumentFragmentImpl.cpp */,
                                A8185F3509765765005826D9 /* DocumentFragmentImpl.h */,
                                A8185F3409765765005826D9 /* DocumentImpl.cpp */,
                                A8185F3809765765005826D9 /* DocumentImpl.h */,
                                ED2BA83B09A24B91006C0AC4 /* DocumentMarker.h */,
+                               93EEC1E809C2877700C515D1 /* DocumentType.idl */,
                                A8185F3209765765005826D9 /* DocumentTypeImpl.cpp */,
                                A8185F3109765765005826D9 /* DocumentTypeImpl.h */,
                                F523D30102DE4476018635CA /* dom2_eventsimpl.cpp */,
                                BE91FC8B06133666005E3790 /* dom_position.h */,
                                F523D2FF02DE4476018635CA /* dom_xmlimpl.cpp */,
                                F523D30002DE4476018635CA /* dom_xmlimpl.h */,
+                               93EEC1E909C2877700C515D1 /* DOMImplementation.idl */,
                                A8185F3609765765005826D9 /* DOMImplementationImpl.cpp */,
                                A8185F3309765765005826D9 /* DOMImplementationImpl.h */,
                                6550B699099DF0270090D781 /* EditingTextImpl.cpp */,
                                6550B69A099DF0270090D781 /* EditingTextImpl.h */,
+                               93EEC1EA09C2877700C515D1 /* Element.idl */,
+                               93EEC1EB09C2877700C515D1 /* Entity.idl */,
                                935FBC4409BA00B900E230B1 /* EventListener.h */,
                                939885C108B7E3D100E707C4 /* EventNames.cpp */,
                                939885C208B7E3D100E707C4 /* EventNames.h */,
                                935FBCF109BA143B00E230B1 /* ExceptionCode.h */,
+                               93EEC1F309C2877700C515D1 /* MutationEvent.idl */,
                                A81872180977D3C0005826D9 /* NamedNodeMapImpl.h */,
                                A81872190977D3C0005826D9 /* NameNodeListImpl.cpp */,
                                A81872130977D3C0005826D9 /* NameNodeListImpl.h */,
                                A81872170977D3C0005826D9 /* NodeImpl.h */,
                                A81872160977D3C0005826D9 /* NodeListImpl.cpp */,
                                A81872100977D3C0005826D9 /* NodeListImpl.h */,
+                               93EEC1F409C2877700C515D1 /* Notation.idl */,
+                               93EEC1F509C2877700C515D1 /* ProcessingInstruction.idl */,
                                550A0BC7085F6039007353D6 /* QualifiedName.cpp */,
                                550A0BC8085F6039007353D6 /* QualifiedName.h */,
+                               93EEC1F609C2877700C515D1 /* Text.idl */,
                                6550B69B099DF0270090D781 /* TextImpl.cpp */,
                                6550B69C099DF0270090D781 /* TextImpl.h */,
+                               93EEC1F709C2877700C515D1 /* WheelEvent.idl */,
                                F523D30902DE4476018635CA /* xml_tokenizer.cpp */,
                                F523D30A02DE4476018635CA /* xml_tokenizer.h */,
                        );
                                9352071E09BD3BBB00F2038D /* WebCoreWidgetHolder.h in Headers */,
                                935207BE09BD410A00F2038D /* LocalizedStrings.h in Headers */,
                                9352088209BD45E900F2038D /* CookieJar.h in Headers */,
+                               93EEC1FA09C2877700C515D1 /* DocPtr.h in Headers */,
+                               93EEC20009C2877700C515D1 /* CanvasRenderingContext2D.h in Headers */,
+                               93EEC20109C2877700C515D1 /* CanvasStyle.h in Headers */,
+                               93EEC20309C2877700C515D1 /* CanvasGradient.h in Headers */,
+                               93EEC20409C2877700C515D1 /* CanvasPattern.h in Headers */,
+                               930CAD1509C4F3C300229C04 /* JSCanvasRenderingContext2DBase.h in Headers */,
                                D0B0556809C6700100307E43 /* CreateLinkCommand.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                                932FC0DA0824A337005B3C75 /* ColorData.c */,
                                932FC38F0824BA30005B3C75 /* tokenizer.cpp */,
                                932FC1710824A913005B3C75 /* JSXMLHttpRequest.lut.h */,
+                               930CAD7409C4F74A00229C04 /* JSCanvasRenderingContext2DBaseTable.cpp */,
                                932FC1730824A919005B3C75 /* xmlserializer.lut.h */,
                                A83C867D0911AA19009BF4A7 /* XSLTProcessor.lut.h */,
                                1A69D387085628650009880D /* domparser.lut.h */,
                                A88AD52509524A34001DD196 /* XLinkNames */,
                                A88AD52909524A4A001DD196 /* ksvgcssproperties.c/h */,
                                A88AD52B09524A52001DD196 /* ksvgcssvalues.c/h */,
-                               937A3651097E257B00E4EE2F /* User Agent Style Sheet */,
-                               1ADB56AF098828730032EEE2 /* Generate Javascript Bindings */,
+                               937A3651097E257B00E4EE2F /* Compile User Agent Style Sheet */,
+                               1ADB56AF098828730032EEE2 /* Generate JavaScript Bindings */,
                                93F198A608245E59001E9ABC /* Headers */,
                                93F199FD08245E59001E9ABC /* Resources */,
                                93F19A0C08245E59001E9ABC /* Sources */,
                                65F5382209B2B55700F3DC4A /* character-sets.txt in Resources */,
                                65F5382309B2B55700F3DC4A /* make-charset-table.pl in Resources */,
                                65F5382509B2B57500F3DC4A /* mac-encodings.txt in Resources */,
+                               93EEC1F809C2877700C515D1 /* Attr.idl in Resources */,
+                               93EEC1F909C2877700C515D1 /* CharacterData.idl in Resources */,
+                               93EEC1FB09C2877700C515D1 /* DocumentType.idl in Resources */,
+                               93EEC1FC09C2877700C515D1 /* DOMImplementation.idl in Resources */,
+                               93EEC1FD09C2877700C515D1 /* Element.idl in Resources */,
+                               93EEC1FE09C2877700C515D1 /* Entity.idl in Resources */,
+                               93EEC20509C2877700C515D1 /* MutationEvent.idl in Resources */,
+                               93EEC20609C2877700C515D1 /* Notation.idl in Resources */,
+                               93EEC20709C2877700C515D1 /* ProcessingInstruction.idl in Resources */,
+                               93EEC20809C2877700C515D1 /* Text.idl in Resources */,
+                               93EEC20909C2877700C515D1 /* WheelEvent.idl in Resources */,
+                               930CAAD709C495B600229C04 /* CanvasRenderingContext2D.idl in Resources */,
+                               930CAB8909C49EFA00229C04 /* CanvasGradient.idl in Resources */,
+                               930CAB9009C49F1B00229C04 /* CanvasPattern.idl in Resources */,
+                               930CAB9709C49FAA00229C04 /* CodeGeneratorJS.pm in Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        shellPath = /bin/sh;
                        shellScript = "\"$CREATE_HASH_TABLE\" khtml/ecma/domparser.cpp > \"$DERIVED_FILE_DIR/domparser.lut.h\"";
                };
-               1ADB56AF098828730032EEE2 /* Generate Javascript Bindings */ = {
+               1ADB56AF098828730032EEE2 /* Generate JavaScript Bindings */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       inputPaths = (
+                       );
+                       name = "Generate JavaScript Bindings";
+                       outputPaths = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/sh;
+                       shellScript = "/usr/bin/perl -I\"$SRCROOT/bindings/scripts\" \"$SRCROOT/bindings/scripts/generate-bindings.pl\" --generator JS --idldir \"$SRCROOT/dom\" --outputdir \"$DERIVED_FILE_DIR\"\n/usr/bin/perl -I\"$SRCROOT/bindings/scripts\" \"$SRCROOT/bindings/scripts/generate-bindings.pl\" --generator JS --idldir \"$SRCROOT/html\" --outputdir \"$DERIVED_FILE_DIR\"\n";
+               };
+               930CAD7409C4F74A00229C04 /* JSCanvasRenderingContext2DBaseTable.cpp */ = {
                        isa = PBXShellScriptBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
                        );
                        inputPaths = (
+                               "$(CREATE_HASH_TABLE)",
+                               bindings/js/JSCanvasRenderingContext2DBase.cpp,
                        );
-                       name = "Generate Javascript Bindings";
+                       name = JSCanvasRenderingContext2DBaseTable.cpp;
                        outputPaths = (
+                               "$(DERIVED_FILE_DIR)/JSCanvasRenderingContext2DBaseTable.cpp",
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "/usr/bin/perl -I\"$SRCROOT/bindings/scripts\" \"$SRCROOT/bindings/scripts/generate-bindings.pl\" --generator JS --idldir \"$SRCROOT/dom\" --outputdir \"$DERIVED_FILE_DIR\"\n";
+                       shellScript = "\"$CREATE_HASH_TABLE\" bindings/js/JSCanvasRenderingContext2DBase.cpp -n WebCore > \"$DERIVED_FILE_DIR/JSCanvasRenderingContext2DBaseTable.cpp\"";
                };
                932FC0B70824A175005B3C75 /* doctypes.cpp */ = {
                        isa = PBXShellScriptBuildPhase;
                        shellPath = /bin/sh;
                        shellScript = "flex -t css/tokenizer.flex | perl css/maketokenizer > \"$DERIVED_FILE_DIR/tokenizer.cpp\"";
                };
-               937A3651097E257B00E4EE2F /* User Agent Style Sheet */ = {
+               937A3651097E257B00E4EE2F /* Compile User Agent Style Sheet */ = {
                        isa = PBXShellScriptBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
                                "$(SRCROOT)/css/quirks.css",
                                "$(SRCROOT)/css/svg.css",
                        );
-                       name = "User Agent Style Sheet";
+                       name = "Compile User Agent Style Sheet";
                        outputPaths = (
                                "$(DERIVED_FILE_DIR)/UserAgentStyleSheets.h",
                                "$(DERIVED_FILE_DIR)/UserAgentStyleSheetsData.cpp",
                                935207C009BD412100F2038D /* LocalizedStringsMac.mm in Sources */,
                                9352084509BD43B900F2038D /* Language.mm in Sources */,
                                9352087709BD453400F2038D /* CookieJar.mm in Sources */,
+                               93EEC1FF09C2877700C515D1 /* CanvasRenderingContext2D.cpp in Sources */,
+                               93EEC20209C2877700C515D1 /* CanvasGradient.cpp in Sources */,
+                               93EEC26F09C3218000C515D1 /* CanvasPattern.cpp in Sources */,
+                               93EEC27109C3218800C515D1 /* CanvasStyle.cpp in Sources */,
+                               930CACBA09C4EE7700229C04 /* JSDOMHTML.cpp in Sources */,
+                               930CAD2609C4F49100229C04 /* JSCanvasRenderingContext2DBase.cpp in Sources */,
                                D0B0556909C6700100307E43 /* CreateLinkCommand.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
diff --git a/WebCore/bindings/js/JSCanvasRenderingContext2DBase.cpp b/WebCore/bindings/js/JSCanvasRenderingContext2DBase.cpp
new file mode 100644 (file)
index 0000000..e088487
--- /dev/null
@@ -0,0 +1,306 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+#include "JSCanvasRenderingContext2DBase.h"
+
+#include "CanvasGradient.h"
+#include "CanvasPattern.h"
+#include "CanvasRenderingContext2D.h"
+#include "CanvasStyle.h"
+#include "JSCanvasGradient.h"
+#include "JSCanvasPattern.h"
+#include "html_imageimpl.h"
+#include "kjs_html.h"
+
+#include "JSCanvasRenderingContext2DBaseTable.cpp"
+
+using namespace KJS;
+
+namespace WebCore {
+
+/*
+@begin JSCanvasRenderingContext2DBaseProtoTable 7
+  setStrokeColor           JSCanvasRenderingContext2DBase::SetStrokeColor              DontDelete|Function 1
+  setFillColor             JSCanvasRenderingContext2DBase::SetFillColor                DontDelete|Function 1
+  strokeRect               JSCanvasRenderingContext2DBase::StrokeRect                  DontDelete|Function 4
+  drawImage                JSCanvasRenderingContext2DBase::DrawImage                   DontDelete|Function 3
+  drawImageFromRect        JSCanvasRenderingContext2DBase::DrawImageFromRect           DontDelete|Function 10
+  setShadow                JSCanvasRenderingContext2DBase::SetShadow                   DontDelete|Function 3
+  createPattern            JSCanvasRenderingContext2DBase::CreatePattern               DontDelete|Function 2
+@end
+@begin JSCanvasRenderingContext2DBaseTable 2
+  strokeStyle              JSCanvasRenderingContext2DBase::StrokeStyle                 DontDelete
+  fillStyle                JSCanvasRenderingContext2DBase::FillStyle                   DontDelete
+@end
+*/
+
+KJS_IMPLEMENT_PROTOFUNC(JSCanvasRenderingContext2DBaseProtoFunc)
+KJS_IMPLEMENT_PROTOTYPE("CanvasRenderingContext2DBase", JSCanvasRenderingContext2DBaseProto, JSCanvasRenderingContext2DBaseProtoFunc)
+
+JSValue* JSCanvasRenderingContext2DBaseProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
+{
+    if (!thisObj->inherits(&JSCanvasRenderingContext2DBase::info))
+        return throwError(exec, TypeError);
+
+    CanvasRenderingContext2D* context = static_cast<JSCanvasRenderingContext2DBase*>(thisObj)->impl();
+    
+    switch (id) {
+        case JSCanvasRenderingContext2DBase::SetStrokeColor:
+            // string arg = named color
+            // number arg = gray color
+            // string arg, number arg = named color, alpha
+            // number arg, number arg = gray color, alpha
+            // 4 args = r, g, b, a
+            // 5 args = c, m, y, k, a
+            switch (args.size()) {
+                case 1:
+                    if (args[0]->isString())
+                        context->setStrokeColor(args[0]->toString(exec).domString());
+                    else
+                        context->setStrokeColor(args[0]->toNumber(exec));
+                    break;
+                case 2:
+                    if (args[0]->isString())
+                        context->setStrokeColor(args[0]->toString(exec).domString(), args[1]->toNumber(exec));
+                    else
+                        context->setStrokeColor(args[0]->toNumber(exec), args[1]->toNumber(exec));
+                    break;
+                case 4:
+                    context->setStrokeColor(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                        args[2]->toNumber(exec), args[3]->toNumber(exec));
+                    break;
+                case 5:
+                    context->setStrokeColor(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                        args[2]->toNumber(exec), args[3]->toNumber(exec), args[4]->toNumber(exec));
+                    break;
+                default:
+                    return throwError(exec, SyntaxError);
+            }
+            break;
+        case JSCanvasRenderingContext2DBase::SetFillColor:
+            // string arg = named color
+            // number arg = gray color
+            // string arg, number arg = named color, alpha
+            // number arg, number arg = gray color, alpha
+            // 4 args = r, g, b, a
+            // 5 args = c, m, y, k, a
+            switch (args.size()) {
+                case 1:
+                    if (args[0]->isString())
+                        context->setFillColor(args[0]->toString(exec).domString());
+                    else
+                        context->setFillColor(args[0]->toNumber(exec));
+                    break;
+                case 2:
+                    if (args[0]->isString())
+                        context->setFillColor(args[0]->toString(exec).domString(), args[1]->toNumber(exec));
+                    else
+                        context->setFillColor(args[0]->toNumber(exec), args[1]->toNumber(exec));
+                    break;
+                case 4:
+                    context->setFillColor(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                        args[2]->toNumber(exec), args[3]->toNumber(exec));
+                    break;
+                case 5:
+                    context->setFillColor(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                        args[2]->toNumber(exec), args[3]->toNumber(exec), args[4]->toNumber(exec));
+                    break;
+                default:
+                    return throwError(exec, SyntaxError);
+            }
+            break;
+        case JSCanvasRenderingContext2DBase::StrokeRect:
+            if (args.size() <= 4)
+                context->strokeRect(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                    args[2]->toNumber(exec), args[3]->toNumber(exec));
+            else
+                context->strokeRect(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                    args[2]->toNumber(exec), args[3]->toNumber(exec), args[4]->toNumber(exec));
+            break;
+        case JSCanvasRenderingContext2DBase::SetShadow:
+            switch (args.size()) {
+                case 3:
+                    context->setShadow(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                        args[2]->toNumber(exec));
+                    break;
+                case 4:
+                    if (args[3]->isString())
+                        context->setShadow(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                            args[2]->toNumber(exec), args[3]->toString(exec).domString());
+                    else
+                        context->setShadow(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                            args[2]->toNumber(exec), args[3]->toNumber(exec));
+                    break;
+                case 5:
+                    if (args[3]->isString())
+                        context->setShadow(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                            args[2]->toNumber(exec), args[3]->toString(exec).domString(),
+                            args[4]->toNumber(exec));
+                    else
+                        context->setShadow(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                            args[2]->toNumber(exec), args[3]->toNumber(exec),
+                            args[4]->toNumber(exec));
+                    break;
+                case 7:
+                    context->setShadow(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                        args[2]->toNumber(exec), args[3]->toNumber(exec),
+                        args[4]->toNumber(exec), args[5]->toNumber(exec),
+                        args[6]->toNumber(exec));
+                    break;
+                case 8:
+                    context->setShadow(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                        args[2]->toNumber(exec), args[3]->toNumber(exec),
+                        args[4]->toNumber(exec), args[5]->toNumber(exec),
+                        args[6]->toNumber(exec), args[7]->toNumber(exec));
+                    break;
+                default:
+                    return throwError(exec, SyntaxError);
+            }
+            break;
+        case JSCanvasRenderingContext2DBase::DrawImage: {
+            // DrawImage has three variants:
+            // drawImage(img, dx, dy)
+            // drawImage(img, dx, dy, dw, dh)
+            // drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh)
+            // composite operation is specified with globalCompositeOperation
+            // img parameter can be a JavaScript Image, <img>, or a <canvas>
+            JSObject* o = static_cast<JSObject*>(args[0]);
+            if (!o->isObject())
+                return throwError(exec, TypeError);
+            if (!(o->inherits(&HTMLElement::img_info) || o->inherits(&HTMLElement::canvas_info)))
+                return throwError(exec, TypeError);
+            HTMLImageElementImpl* imgElt = static_cast<HTMLImageElementImpl*>(static_cast<HTMLElement*>(args[0])->impl());
+            switch (args.size()) {
+                case 3:
+                    context->drawImage(imgElt, args[1]->toNumber(exec), args[2]->toNumber(exec));
+                    break;
+                case 5:
+                    context->drawImage(imgElt, args[1]->toNumber(exec), args[2]->toNumber(exec),
+                        args[3]->toNumber(exec), args[4]->toNumber(exec));
+                    break;
+                case 9:
+                    context->drawImage(imgElt, args[1]->toNumber(exec), args[2]->toNumber(exec),
+                        args[3]->toNumber(exec), args[4]->toNumber(exec),
+                        args[5]->toNumber(exec), args[6]->toNumber(exec),
+                        args[7]->toNumber(exec), args[8]->toNumber(exec));
+                    break;
+                default:
+                    return throwError(exec, SyntaxError);
+            }
+            break;
+        }
+        case JSCanvasRenderingContext2DBase::DrawImageFromRect: {
+            JSObject* o = static_cast<JSObject*>(args[0]);
+            if (!o->isObject())
+                return throwError(exec, TypeError);
+            if (!o->inherits(&HTMLElement::img_info))
+                return throwError(exec, TypeError);
+            context->drawImageFromRect(static_cast<HTMLImageElementImpl*>(static_cast<HTMLElement*>(args[0])->impl()),
+                args[1]->toNumber(exec), args[2]->toNumber(exec),
+                args[3]->toNumber(exec), args[4]->toNumber(exec),
+                args[5]->toNumber(exec), args[6]->toNumber(exec),
+                args[7]->toNumber(exec), args[8]->toNumber(exec),
+                args[9]->toString(exec).domString());
+            break;
+        }
+        case JSCanvasRenderingContext2DBase::CreatePattern:
+            JSObject* o = static_cast<JSObject*>(args[0]);
+            if (!o->isObject())
+                return throwError(exec, TypeError);
+            if (!o->inherits(&HTMLElement::img_info))
+                return throwError(exec, TypeError);
+            return toJS(exec,
+                context->createPattern(static_cast<HTMLImageElementImpl*>(static_cast<HTMLElement*>(args[0])->impl()),
+                args[1]->toString(exec).domString()).get());
+    }
+
+    return jsUndefined();
+}
+
+const ClassInfo JSCanvasRenderingContext2DBase::info = { "CanvasRenderingContext2DBase", 0, &JSCanvasRenderingContext2DBaseTable, 0 };
+
+bool JSCanvasRenderingContext2DBase::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+{
+    return getStaticValueSlot<JSCanvasRenderingContext2DBase, DOMObject>
+        (exec, &JSCanvasRenderingContext2DBaseTable, this, propertyName, slot);
+}
+
+static JSValue* toJS(ExecState* exec, CanvasStyle* style)
+{
+    if (style->gradient())
+        return toJS(exec, style->gradient());
+    if (style->pattern())
+        return toJS(exec, style->pattern());
+    return jsString(style->color());
+}
+
+static PassRefPtr<CanvasStyle> toHTMLCanvasStyle(ExecState* exec, JSValue* value)
+{
+    if (value->isString())
+        return new CanvasStyle(value->toString(exec).domString());
+    if (!value->isObject())
+        return 0;
+    JSObject* object = static_cast<JSObject*>(value);
+    if (object->inherits(&JSCanvasGradient::info))
+        return new CanvasStyle(static_cast<JSCanvasGradient*>(object)->impl());
+    if (object->inherits(&JSCanvasPattern::info))
+        return new CanvasStyle(static_cast<JSCanvasPattern*>(object)->impl());
+    return 0;
+}
+
+JSValue* JSCanvasRenderingContext2DBase::getValueProperty(ExecState* exec, int token) const
+{
+    switch (token) {
+        case StrokeStyle:
+            return toJS(exec, m_impl->strokeStyle());        
+        case FillStyle:
+            return toJS(exec, m_impl->fillStyle());        
+    }
+    return 0;
+}
+
+void JSCanvasRenderingContext2DBase::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
+{
+    lookupPut<JSCanvasRenderingContext2DBase, DOMObject>(exec, propertyName, value, attr, &JSCanvasRenderingContext2DBaseTable, this);
+}
+
+void JSCanvasRenderingContext2DBase::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
+{
+    switch (token) {
+        case StrokeStyle:
+            impl()->setStrokeStyle(toHTMLCanvasStyle(exec, value));
+            break;
+        case FillStyle:
+            impl()->setFillStyle(toHTMLCanvasStyle(exec, value));
+            break;
+    }
+}
+
+JSCanvasRenderingContext2DBase::JSCanvasRenderingContext2DBase(ExecState*, PassRefPtr<WebCore::CanvasRenderingContext2D> impl)
+    : m_impl(impl)
+{
+}
+
+JSCanvasRenderingContext2DBase::~JSCanvasRenderingContext2DBase()
+{
+    ScriptInterpreter::forgetDOMObject(m_impl.get());
+}
+
+}
diff --git a/WebCore/bindings/js/JSCanvasRenderingContext2DBase.h b/WebCore/bindings/js/JSCanvasRenderingContext2DBase.h
new file mode 100644 (file)
index 0000000..7c86277
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "kjs_binding.h"
+
+namespace WebCore {
+
+    class CanvasRenderingContext2D;
+
+    KJS_DEFINE_PROTOTYPE(JSCanvasRenderingContext2DBaseProto)
+
+    class JSCanvasRenderingContext2DBase : public KJS::DOMObject {
+    public:
+        JSCanvasRenderingContext2DBase(KJS::ExecState*, PassRefPtr<CanvasRenderingContext2D>);
+        virtual ~JSCanvasRenderingContext2DBase();
+        virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
+        KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;
+        virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr = KJS::None);
+        void putValueProperty(KJS::ExecState*, int token, KJS::JSValue*, int attr);
+        virtual const KJS::ClassInfo* classInfo() const { return &info; }
+        static const KJS::ClassInfo info;
+        enum { StrokeStyle, FillStyle };
+        enum { SetStrokeColor, SetFillColor, StrokeRect, DrawImage, DrawImageFromRect, SetShadow, CreatePattern };
+        CanvasRenderingContext2D* impl() const { return m_impl.get(); }
+    private:
+        RefPtr<CanvasRenderingContext2D> m_impl;
+    };
+
+}
index 1f95508..2ffaedd 100644 (file)
@@ -1,6 +1,6 @@
 #include "config.h"
 
-// The files below are generated by a script.
+// The files below are all generated by a script.
 
 #include "JSAttr.cpp"
 #include "JSCharacterData.cpp"
index 806d54e..2036d5e 100644 (file)
@@ -1,6 +1,6 @@
 #include "config.h"
 
-// The files named below are generated by a script.
+// The files below are all generated by a script.
 
 #include "JSMutationEvent.cpp"
 #include "JSWheelEvent.cpp"
diff --git a/WebCore/bindings/js/JSDOMHTML.cpp b/WebCore/bindings/js/JSDOMHTML.cpp
new file mode 100644 (file)
index 0000000..95057b9
--- /dev/null
@@ -0,0 +1,7 @@
+#include "config.h"
+
+// The files below are all generated by a script.
+
+#include "JSCanvasGradient.cpp"
+#include "JSCanvasPattern.cpp"
+#include "JSCanvasRenderingContext2D.cpp"
index cdff82d..8b800ad 100644 (file)
@@ -172,7 +172,7 @@ DOMString::DOMString(NSString *str)
     ExecState *exec = interpreter->globalExec();
     
     // Get (or create) a cached JS object for the DOM node.
-    JSObject *scriptImp = static_cast<JSObject *>(getDOMNode(exec, nodeImpl));
+    JSObject *scriptImp = static_cast<JSObject *>(toJS(exec, nodeImpl));
 
     const RootObject *executionContext = Mac(frame)->bindingRootObject();
 
index e7c862e..2d03030 100644 (file)
@@ -152,26 +152,22 @@ sub GenerateModule
 sub GetParentClassName
 {
   my $dataNode = shift;
-  
-  if (@{$dataNode->parents} eq 0) {
-    return "KJS::DOMObject";
-  }
-  
-  # Check if there's a legacy parent class set and
-  # use it.
-  if ($dataNode->extendedAttributes->{"LegacyParent"}) {
-    return $dataNode->extendedAttributes->{"LegacyParent"};
-  } else {
-    return "JS" . $dataNode->parents(0);
-  }
+  return $dataNode->extendedAttributes->{"LegacyParent"} if $dataNode->extendedAttributes->{"LegacyParent"};
+  return "KJS::DOMObject" if @{$dataNode->parents} eq 0;
+  return "JS" . $dataNode->parents(0);
 }
 
 sub GetLegacyHeaderIncludes
 {
-  if ($module eq "events") {
+  my $legacyParent = shift;
+  if ($legacyParent eq "JSCanvasRenderingContext2DBase") {
+    return "#include \"JSCanvasRenderingContext2DBase.h\"\n\n";
+  } elsif ($module eq "events") {
     return "#include \"kjs_events.h\"\n\n";
   } elsif ($module eq "core") {
     return "#include \"kjs_dom.h\"\n\n";
+  } elsif ($module eq "html") {
+    return "#include \"kjs_html.h\"\n\n";
   } else {
     die ("Don't know what headers to include for module $module");
   }
@@ -205,6 +201,16 @@ sub AddIncludesForType
            $type eq "Entity" or
            $type eq "Notation") {
     $implIncludes{"dom_xmlimpl.h"} = 1;
+  } elsif ($type eq "CanvasRenderingContext2D") {
+    $implIncludes{"CanvasGradient.h"} = 1;
+    $implIncludes{"CanvasPattern.h"} = 1;
+    $implIncludes{"CanvasRenderingContext2D.h"} = 1;
+    $implIncludes{"CanvasStyle.h"} = 1;
+  } elsif ($type eq "CanvasGradient") {
+    $implIncludes{"CanvasGradient.h"} = 1;
+    $implIncludes{"PlatformString.h"} = 1;
+  } elsif ($type eq "CanvasPattern") {
+    $implIncludes{"$type.h"} = 1;
   } elsif ($codeGenerator->IsPrimitiveType($type) or
            $type eq "DOMString") {
     # Do nothing
@@ -234,6 +240,8 @@ sub GenerateHeader
   my $interfaceName = $dataNode->name;
   my $className = "JS$interfaceName";
   my $implClassName = $interfaceName . "Impl";
+  # Canvas classes don't have Impl suffix (remove this when removing the Impl suffix elsewhere).
+  $implClassName = $interfaceName if $interfaceName =~ /^Canvas/;
   
   # FIXME: If we're sure that an interface can't have more than
   # one parent we can do the check in the parser instead
@@ -241,7 +249,9 @@ sub GenerateHeader
     die "A class can't have more than one parent";
   }
   
-  my $hasParent = @{$dataNode->parents} > 0;
+  my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"};
+  my $hasRealParent = @{$dataNode->parents} > 0;
+  my $hasParent = $hasLegacyParent || $hasRealParent;
   my $parentClassName = GetParentClassName($dataNode);
   
   # - Add default header template
@@ -252,7 +262,7 @@ sub GenerateHeader
   push(@headerContent, "\n#define $className" . "_H\n\n");
   
   if (exists $dataNode->extendedAttributes->{"LegacyParent"}) {
-    push(@headerContent, GetLegacyHeaderIncludes());
+    push(@headerContent, GetLegacyHeaderIncludes($dataNode->extendedAttributes->{"LegacyParent"}));
   } else {
     if ($hasParent) {
       push(@headerContent, "#include \"$parentClassName.h\"\n");
@@ -278,7 +288,6 @@ sub GenerateHeader
   push(@headerContent, "    $className(KJS::ExecState*, $implClassName*);\n");
     
   # Destructor
-  # FIXME: If we know that a class can't have subclasses, we don't need a virtual destructor
   if (!$hasParent) {
     push(@headerContent, "    virtual ~$className();\n");
   }
@@ -299,7 +308,7 @@ sub GenerateHeader
   
   if ($hasReadWriteProperties) {
     push(@headerContent, "    virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr = KJS::None);\n");
-    push(@headerContent, "    void putValueProperty(KJS::ExecState*, int, KJS::JSValue*, int);\n");
+    push(@headerContent, "    void putValueProperty(KJS::ExecState*, int, KJS::JSValue*, int attr);\n");
   }
   
   # Class info
@@ -361,13 +370,17 @@ sub GenerateHeader
   }
 
   if (!$hasParent) {
-    push(@headerContent, "    $implClassName* impl() { return m_impl.get(); }\n");
-    push(@headerContent, "protected:\n");
+    push(@headerContent, "    $implClassName* impl() const { return m_impl.get(); }\n");
+    push(@headerContent, "private:\n");
     push(@headerContent, "    RefPtr<$implClassName> m_impl;\n");
   }
   
   push(@headerContent, "};\n\n");
   
+  if (!$hasParent) {
+    push(@headerContent, "KJS::JSValue* toJS(KJS::ExecState*, $implClassName*);\n\n");
+  }
+
   # Add prototype declaration
   if ($numFunctions > 0) {
     if ($hasParent) {
@@ -388,8 +401,12 @@ sub GenerateImplementation
   my $interfaceName = $dataNode->name;
   my $className = "JS$interfaceName";
   my $implClassName = $interfaceName . "Impl";
+  # Canvas classes don't have Impl suffix (remove this when removing the Impl suffix elsewhere).
+  $implClassName = $interfaceName if $interfaceName =~ /^Canvas/;
   
-  my $hasParent = @{$dataNode->parents} > 0;
+  my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"};
+  my $hasRealParent = @{$dataNode->parents} > 0;
+  my $hasParent = $hasLegacyParent || $hasRealParent;
   my $parentClassName = GetParentClassName($dataNode);
   
   # - Add default header template
@@ -563,7 +580,7 @@ sub GenerateImplementation
                        "(exec, &${className}Table, this, propertyName, slot);\n}\n\n");
   
     push(@implContent, "JSValue* ${className}::getValueProperty(ExecState *exec, int token) const\n{\n");
-    push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(m_impl.get());\n\n");
+    push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(${className}::impl());\n\n");
     push(@implContent, "    switch (token) {\n");
 
     foreach my $attribute (@{$dataNode->attributes}) {
@@ -598,7 +615,7 @@ sub GenerateImplementation
       if ($raisesExceptions) {
         push(@implContent, "    DOMExceptionTranslator exception(exec);\n");
       }
-      push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(m_impl.get());\n\n");
+      push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(${className}::impl());\n\n");
       push(@implContent, "    switch (token) {\n");
       
       foreach my $attribute (@{$dataNode->attributes}) {
@@ -693,6 +710,13 @@ sub GenerateImplementation
     push(@implContent, "}\n")
   }
   
+  if (!$hasParent) {
+    push(@implContent, "KJS::JSValue* toJS(KJS::ExecState* exec, $implClassName* obj)\n");
+    push(@implContent, "{\n");
+    push(@implContent, "    return KJS::cacheDOMObject<$implClassName, $className>(exec, obj);\n");
+    push(@implContent, "}\n");
+  }
+
   push(@implContent, "\n}\n");
 }
 
@@ -716,10 +740,12 @@ sub GetNativeType
     return "int";
   } elsif ($type eq "unsigned short") {
     return "unsigned short";
+  } elsif ($type eq "float") {
+    return "float";
   } elsif ($type eq "AtomicString") {
     return "AtomicString";
   } elsif ($type eq "DOMString") {
-    return "DOMString";
+    return "String";
   } elsif ($type eq "views::AbstractView") {
     return "AbstractViewImpl*";
   } elsif ($type eq "Node" or $type eq "Attr" or
@@ -743,6 +769,8 @@ sub JSValueToNative
     return "$value->toInt32(exec)";
   } elsif ($type eq "unsigned short") {
     return "$value->toInt32(exec)";
+  } elsif ($type eq "float") {
+    return "$value->toNumber(exec)";
   } elsif ($type eq "AtomicString") {
     return "AtomicString($value->toString(exec).domString())";
   } elsif ($type eq "DOMString") {
@@ -778,7 +806,7 @@ sub NativeToJSValue
   if ($type eq "boolean") {
     return "jsBoolean($value)";
   } elsif ($type eq "long" or $type eq "unsigned long" or 
-           $type eq "unsigned short") {
+           $type eq "unsigned short" or $type eq "float") {
     return "jsNumber($value)";
   } elsif ($type eq "DOMString") {
     my $conv = $signature->extendedAttributes->{"ConvertNullStringTo"};
@@ -796,28 +824,30 @@ sub NativeToJSValue
            $type eq "HTMLDocument" or $type eq "Element" or
            $type eq "Attr") {
     # Add necessary includes
-    $implIncludes{"kjs_dom.h"} = 1;   
-    $implIncludes{"NodeImpl.h"} = 1;     
-    return "getDOMNode(exec, $value)";
-  } elsif ($type eq "NodeList") {
-    # Add necessary includes
-    $implIncludes{"kjs_dom.h"} = 1;    
-    return "getDOMNodeList(exec, $value)";    
-  } elsif ($type eq "NamedNodeMap") {
+    $implIncludes{"kjs_dom.h"} = 1;
+    $implIncludes{"NodeImpl.h"} = 1;
+    return "toJS(exec, $value)";
+  } elsif ($type eq "NodeList" or $type eq "NamedNodeMap") {
     # Add necessary includes
-    $implIncludes{"kjs_dom.h"} = 1;    
-    return "getDOMNamedNodeMap(exec, $value)";
-  } elsif ($type eq "CSSStyleSheet" or 
-           $type eq "StyleSheet") {
+    $implIncludes{"kjs_dom.h"} = 1;
+    return "toJS(exec, $value)";
+  } elsif ($type eq "CSSStyleSheet" or $type eq "StyleSheet") {
     # Add necessary includes
-    $implIncludes{"css_ruleimpl.h"} = 1;    
-    $implIncludes{"kjs_css.h"} = 1;        
-    return "getDOMStyleSheet(exec, $value)";    
+    $implIncludes{"css_ruleimpl.h"} = 1;
+    $implIncludes{"kjs_css.h"} = 1;
+    return "toJS(exec, $value)";    
   } elsif ($type eq "CSSStyleDeclaration") {
     # Add necessary includes
-    $implIncludes{"css_valueimpl.h"} = 1; 
-    $implIncludes{"kjs_css.h"} = 1;            
-    return "getDOMCSSStyleDeclaration(exec, $value)";
+    $implIncludes{"css_valueimpl.h"} = 1;
+    $implIncludes{"kjs_css.h"} = 1;
+    return "toJS(exec, $value)";
+  } elsif ($type eq "HTMLCanvasElement") {
+    $implIncludes{"kjs_dom.h"} = 1;
+    $implIncludes{"html_canvasimpl.h"} = 1;
+    return "toJS(exec, $value)";
+  } elsif ($type eq "CanvasGradient") {
+    $implIncludes{"kjs_html.h"} = 1;
+    return "toJS(exec, $value)";
   } else {
     die "Don't know how to convert a value of type $type to a JS Value";
   }
@@ -898,7 +928,7 @@ sub GenerateHashTable
   }
 
   # Dump the hash table...
-  push(@implContent, "\nstatic const struct HashEntry $nameEntries\[\] =\n\{\n");
+  push(@implContent, "\nstatic const HashEntry $nameEntries\[\] =\n\{\n");
 
   $i = 0;
   foreach $entry (@table) {
@@ -927,7 +957,7 @@ sub GenerateHashTable
   }
 
   push(@implContent, "};\n\n");
-  push(@implContent, "const struct HashTable $name = \n");
+  push(@implContent, "static const HashTable $name = \n");
   push(@implContent, "{\n    2, $size, $nameEntries, $savedSize\n};\n\n");
 }
 
index ad3f4c9..5c72ef3 100644 (file)
@@ -264,12 +264,12 @@ sub ParseInterface
         push(@$arrayRef, $newDataNode);
 
         print "  |  |>  Attribute; TYPE \"$attributeType\" DATA NAME \"$attributeDataName\" DATA TYPE \"$attributeDataType\" EXCEPTION? \"$attributeException\"" .
-              dumpExtendedAttributes("\n  |                 ", $newDataNode->extendedAttributes) . "\n" if(!$beQuiet);
+              dumpExtendedAttributes("\n  |                 ", $newDataNode->signature->extendedAttributes) . "\n" if(!$beQuiet);
 
         $attributeException =~ s/\s+//g;
         @{$newDataNode->raisesExceptions} = split(/,/, $attributeException);
       } elsif(($line !~ s/^\s*$//g) and ($line !~ /^\s+const/)) {
-        $line =~ /$IDLStructure::interfaceMethodSelector/;
+        $line =~ /$IDLStructure::interfaceMethodSelector/ or die "Parsing error!\nSource:\n$line\n)";
 
         my $methodExtendedAttributes = (defined($1) ? $1 : " "); chop($methodExtendedAttributes);
         my $methodType = (defined($2) ? $2 : die("Parsing error!\nSource:\n$line\n)"));
index 168b246..743493d 100644 (file)
 module core {
 
     interface [LegacyParent=KJS::DOMNode] Attr : Node {
+
+        // DOM Level 1
+
         readonly attribute [ConvertNullStringTo=Null] DOMString name;
         readonly attribute boolean specified;
                  attribute [ConvertNullStringTo=Null] DOMString value 
                      raises (DOMException);
+
+        // DOM Level 2
+
         readonly attribute Element ownerElement;
         
-        // Web inspector extension
+        // extensions
+
         readonly attribute CSSStyleDeclaration style;
     };
 
index e891cd8..a58cfa1 100644 (file)
 module core {
 
     interface DOMImplementation {
+
+        // DOM Level 1
+
         boolean hasFeature(in DOMString feature, 
                            in [ConvertNullToNullString] DOMString version);
 
+        // DOM Level 2
+
         DocumentType createDocumentType(in DOMString qualifiedName,
                                         in DOMString publicId,
                                         in DOMString systemId)
             raises(DOMException);
-
         Document createDocument(in [ConvertNullToNullString] DOMString namespaceURI, 
                                 in [ConvertNullToNullString] DOMString qualifiedName, 
                                 in [ConvertNullToNullString] DocumentType doctype)
             raises(DOMException);
 
+        // DOMImplementationCSS interface from DOM Level 2 CSS
+
         CSSStyleSheet createCSSStyleSheet(in DOMString title,
                                           in DOMString media)
             raises(DOMException);
 
+        // HTMLDOMImplementation interface from DOM Level 2 HTML
+
         HTMLDocument createHTMLDocument(in DOMString title);
     };
 
index d6b138e..5d7516a 100644 (file)
@@ -21,10 +21,14 @@ module core {
 
     interface [LegacyParent=KJS::DOMNode] DocumentType : Node {
 
+        // DOM Level 1
+
         readonly attribute DOMString name;
         readonly attribute NamedNodeMap entities;
         readonly attribute NamedNodeMap notations;
-        
+
+        // DOM Level 2
+
         readonly attribute [ConvertNullStringTo=Null] DOMString publicId;
         readonly attribute [ConvertNullStringTo=Null] DOMString systemId;
         readonly attribute [ConvertNullStringTo=Null] DOMString internalSubset;        
index f6ee0b8..fd27ac0 100644 (file)
@@ -21,6 +21,8 @@ module events {
 
     interface [LegacyParent=KJS::DOMEvent] MutationEvent : Event {
 
+        // DOM Level 2
+
         const unsigned short MODIFICATION = 1;
         const unsigned short ADDITION     = 2;
         const unsigned short REMOVAL      = 3;
index c80407a..94a60bb 100644 (file)
 module core {
 
     interface [LegacyParent=KJS::DOMNode] ProcessingInstruction : Node {
+
+        // DOM Level 1
+
         readonly attribute [ConvertNullStringTo=Null] DOMString target;
                  attribute [ConvertNullStringTo=Null] DOMString data
                      raises (DOMException);
+
+        // interface LinkStyle from DOM Level 2 Style Sheets
+
         readonly attribute StyleSheet sheet;
+
     };
 
 }
index 633a74c..d48f801 100644 (file)
@@ -20,7 +20,9 @@
 module core {
 
     interface Text : CharacterData {
-    
+
+        // DOM Level 1
+
         Text splitText(in [IsIndex] unsigned long offset)
             raises (DOMException);
 
index b41752a..05ff7c0 100644 (file)
@@ -99,7 +99,7 @@ JSValue* JSXMLHttpRequest::getValueProperty(ExecState *exec, int token) const
     return jsStringOrNull(m_impl->getResponseText());
   case ResponseXML:
     if (DocumentImpl* responseXML = m_impl->getResponseXML())
-      return getDOMNode(exec, responseXML);
+      return toJS(exec, responseXML);
     return jsUndefined();
   case Status: {
     int status = m_impl->getStatus();
index 849ecb5..b35a9cd 100644 (file)
@@ -91,7 +91,7 @@ JSValue *XSLTProcessorProtoFunc::callAsFunction(ExecState *exec, JSObject *thisO
             if (nodeVal->isObject(&DOMNode::info) && docVal->isObject(&DOMDocument::info)) {
                 NodeImpl* node = static_cast<DOMNode *>(nodeVal)->impl();
                 DocumentImpl* doc = static_cast<DocumentImpl*>(static_cast<DOMDocument *>(docVal)->impl());
-                return getDOMNode(exec, processor.transformToFragment(node, doc).get());
+                return toJS(exec, processor.transformToFragment(node, doc).get());
             }
             // Throw exception?
             break;
@@ -103,7 +103,7 @@ JSValue *XSLTProcessorProtoFunc::callAsFunction(ExecState *exec, JSObject *thisO
                 DOMNode *node = static_cast<DOMNode *>(nodeVal);
                 RefPtr<DocumentImpl> resultDocument = processor.transformToDocument(node->impl());
                 if (resultDocument)
-                    return getDOMDocumentNode(exec, resultDocument.get());
+                    return toJS(exec, resultDocument.get());
                 return jsUndefined();
             }
             // Throw exception?
index d04e461..232b5ee 100644 (file)
@@ -94,7 +94,7 @@ JSValue *DOMParserProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj,
         doc->finishParsing();
         doc->close();
 
-        return getDOMNode(exec, doc.get());
+        return toJS(exec, doc.get());
       }
     }
   }
index 4b4834b..67a63f3 100644 (file)
@@ -151,6 +151,8 @@ namespace KJS {
    *  Get a DOMString object or a null DOMString if the value is null
    */
   DOM::DOMString valueToStringWithNullCheck(ExecState* exec, JSValue *val);
+
+    template <typename T> inline JSValue* toJS(ExecState* exec, PassRefPtr<T> ptr) { return toJS(exec, ptr.get()); }
   
 } // namespace
 
index ca8aa3c..8169d1a 100644 (file)
@@ -172,7 +172,7 @@ JSValue *DOMCSSStyleDeclaration::getValueProperty(ExecState *exec, int token)
   case Length:
     return jsNumber(m_impl->length());
   case ParentRule:
-    return getDOMCSSRule(exec, m_impl->parentRule());
+    return toJS(exec, m_impl->parentRule());
   default:
     assert(0);
     return jsUndefined();
@@ -229,7 +229,7 @@ JSValue *DOMCSSStyleDeclarationProtoFunc::callAsFunction(ExecState *exec, JSObje
     case DOMCSSStyleDeclaration::GetPropertyValue:
       return jsStringOrNull(styleDecl.getPropertyValue(s));
     case DOMCSSStyleDeclaration::GetPropertyCSSValue:
-      return getDOMCSSValue(exec, styleDecl.getPropertyCSSValue(s).get());
+      return toJS(exec, styleDecl.getPropertyCSSValue(s).get());
     case DOMCSSStyleDeclaration::RemoveProperty:
       return jsStringOrNull(styleDecl.removeProperty(s, exception));
     case DOMCSSStyleDeclaration::GetPropertyPriority:
@@ -248,7 +248,7 @@ JSValue *DOMCSSStyleDeclarationProtoFunc::callAsFunction(ExecState *exec, JSObje
   }
 }
 
-JSValue *getDOMCSSStyleDeclaration(ExecState *exec, CSSStyleDeclarationImpl *s)
+JSValue *toJS(ExecState *exec, CSSStyleDeclarationImpl *s)
 {
   return cacheDOMObject<CSSStyleDeclarationImpl, DOMCSSStyleDeclaration>(exec, s);
 }
@@ -287,15 +287,15 @@ JSValue *DOMStyleSheet::getValueProperty(ExecState *exec, int token) const
   case Disabled:
     return jsBoolean(styleSheet.disabled());
   case OwnerNode:
-    return getDOMNode(exec,styleSheet.ownerNode());
+    return toJS(exec,styleSheet.ownerNode());
   case ParentStyleSheet:
-    return getDOMStyleSheet(exec,styleSheet.parentStyleSheet());
+    return toJS(exec,styleSheet.parentStyleSheet());
   case Href:
     return jsStringOrNull(styleSheet.href());
   case Title:
     return jsStringOrNull(styleSheet.title());
   case Media:
-    return getDOMMediaList(exec, styleSheet.media());
+    return toJS(exec, styleSheet.media());
   }
   return NULL;
 }
@@ -309,7 +309,7 @@ void DOMStyleSheet::put(ExecState *exec, const Identifier &propertyName, JSValue
     DOMObject::put(exec, propertyName, value, attr);
 }
 
-JSValue* getDOMStyleSheet(ExecState *exec, PassRefPtr<StyleSheetImpl> ss)
+JSValue* toJS(ExecState *exec, PassRefPtr<StyleSheetImpl> ss)
 {
   DOMObject *ret;
   if (!ss)
@@ -358,14 +358,14 @@ JSValue *DOMStyleSheetList::getValueProperty(ExecState *exec, int token) const
 JSValue *DOMStyleSheetList::indexGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 {
   DOMStyleSheetList *thisObj = static_cast<DOMStyleSheetList *>(slot.slotBase());
-  return getDOMStyleSheet(exec, thisObj->m_impl->item(slot.index()));
+  return toJS(exec, thisObj->m_impl->item(slot.index()));
 }
 
 JSValue *DOMStyleSheetList::nameGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 {
   DOMStyleSheetList *thisObj = static_cast<DOMStyleSheetList *>(slot.slotBase());
   ElementImpl *element = thisObj->m_doc->getElementById(propertyName.domString().impl());
-  return getDOMStyleSheet(exec, static_cast<HTMLStyleElementImpl *>(element)->sheet());
+  return toJS(exec, static_cast<HTMLStyleElementImpl *>(element)->sheet());
 }
 
 bool DOMStyleSheetList::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
@@ -429,7 +429,7 @@ JSValue *DOMStyleSheetListFunc::callAsFunction(ExecState *exec, JSObject *thisOb
     return throwError(exec, TypeError);
   StyleSheetListImpl &styleSheetList = *static_cast<DOMStyleSheetList *>(thisObj)->impl();
   if (id == DOMStyleSheetList::Item)
-    return getDOMStyleSheet(exec, styleSheetList.item(args[0]->toInt32(exec)));
+    return toJS(exec, styleSheetList.item(args[0]->toInt32(exec)));
   return jsUndefined();
 }
 
@@ -509,7 +509,7 @@ void DOMMediaList::put(ExecState *exec, const Identifier &propertyName, JSValue
     DOMObject::put(exec, propertyName, value, attr);
 }
 
-JSValue *getDOMMediaList(ExecState *exec, MediaListImpl *ml)
+JSValue *toJS(ExecState *exec, MediaListImpl *ml)
 {
   return cacheDOMObject<MediaListImpl, DOMMediaList>(exec, ml);
 }
@@ -570,10 +570,10 @@ JSValue *DOMCSSStyleSheet::getValueProperty(ExecState *exec, int token) const
 {
   switch (token) {
   case OwnerRule:
-    return getDOMCSSRule(exec, static_cast<CSSStyleSheetImpl *>(impl())->ownerRule());
+    return toJS(exec, static_cast<CSSStyleSheetImpl *>(impl())->ownerRule());
   case CssRules:
   case Rules:
-    return getDOMCSSRuleList(exec, static_cast<CSSStyleSheetImpl *>(impl())->cssRules());
+    return toJS(exec, static_cast<CSSStyleSheetImpl *>(impl())->cssRules());
   default:
     assert(0);
     return jsUndefined();
@@ -642,7 +642,7 @@ JSValue *DOMCSSRuleList::getValueProperty(ExecState *exec, int token) const
 JSValue *DOMCSSRuleList::indexGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 {
   DOMCSSRuleList *thisObj = static_cast<DOMCSSRuleList *>(slot.slotBase());
-  return getDOMCSSRule(exec, thisObj->m_impl->item(slot.index()));
+  return toJS(exec, thisObj->m_impl->item(slot.index()));
 }
 
 bool DOMCSSRuleList::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
@@ -676,13 +676,13 @@ JSValue *DOMCSSRuleListFunc::callAsFunction(ExecState *exec, JSObject *thisObj,
   CSSRuleListImpl &cssRuleList = *static_cast<DOMCSSRuleList *>(thisObj)->impl();
   switch (id) {
     case DOMCSSRuleList::Item:
-      return getDOMCSSRule(exec,cssRuleList.item(args[0]->toInt32(exec)));
+      return toJS(exec,cssRuleList.item(args[0]->toInt32(exec)));
     default:
       return jsUndefined();
   }
 }
 
-JSValue *getDOMCSSRuleList(ExecState *exec, CSSRuleListImpl *rl)
+JSValue *toJS(ExecState *exec, CSSRuleListImpl *rl)
 {
   return cacheDOMObject<CSSRuleListImpl, DOMCSSRuleList>(exec, rl);
 }
@@ -780,39 +780,39 @@ JSValue *DOMCSSRule::getValueProperty(ExecState *exec, int token) const
   case CssText:
     return jsStringOrNull(cssRule.cssText());
   case ParentStyleSheet:
-    return getDOMStyleSheet(exec,cssRule.parentStyleSheet());
+    return toJS(exec,cssRule.parentStyleSheet());
   case ParentRule:
-    return getDOMCSSRule(exec,cssRule.parentRule());
+    return toJS(exec,cssRule.parentRule());
 
   // for STYLE_RULE:
   case Style_SelectorText:
     return jsStringOrNull(static_cast<CSSStyleRuleImpl *>(m_impl.get())->selectorText());
   case Style_Style:
-    return getDOMCSSStyleDeclaration(exec, static_cast<CSSStyleRuleImpl *>(m_impl.get())->style());
+    return toJS(exec, static_cast<CSSStyleRuleImpl *>(m_impl.get())->style());
 
   // for MEDIA_RULE:
   case Media_Media:
-    return getDOMMediaList(exec, static_cast<CSSMediaRuleImpl *>(m_impl.get())->media());
+    return toJS(exec, static_cast<CSSMediaRuleImpl *>(m_impl.get())->media());
   case Media_CssRules:
-    return getDOMCSSRuleList(exec, static_cast<CSSMediaRuleImpl *>(m_impl.get())->cssRules());
+    return toJS(exec, static_cast<CSSMediaRuleImpl *>(m_impl.get())->cssRules());
 
   // for FONT_FACE_RULE:
   case FontFace_Style:
-    return getDOMCSSStyleDeclaration(exec, static_cast<CSSFontFaceRuleImpl *>(m_impl.get())->style());
+    return toJS(exec, static_cast<CSSFontFaceRuleImpl *>(m_impl.get())->style());
 
   // for PAGE_RULE:
   case Page_SelectorText:
     return jsStringOrNull(static_cast<CSSPageRuleImpl *>(m_impl.get())->selectorText());
   case Page_Style:
-    return getDOMCSSStyleDeclaration(exec, static_cast<CSSPageRuleImpl *>(m_impl.get())->style());
+    return toJS(exec, static_cast<CSSPageRuleImpl *>(m_impl.get())->style());
 
   // for IMPORT_RULE:
   case Import_Href:
     return jsStringOrNull(static_cast<CSSImportRuleImpl *>(m_impl.get())->href());
   case Import_Media:
-    return getDOMMediaList(exec, static_cast<CSSImportRuleImpl *>(m_impl.get())->media());
+    return toJS(exec, static_cast<CSSImportRuleImpl *>(m_impl.get())->media());
   case Import_StyleSheet:
-    return getDOMStyleSheet(exec, static_cast<CSSImportRuleImpl *>(m_impl.get())->styleSheet());
+    return toJS(exec, static_cast<CSSImportRuleImpl *>(m_impl.get())->styleSheet());
 
   // for CHARSET_RULE:
   case Charset_Encoding:
@@ -880,7 +880,7 @@ JSValue *DOMCSSRuleFunc::callAsFunction(ExecState *exec, JSObject *thisObj, cons
   return jsUndefined();
 }
 
-JSValue *getDOMCSSRule(ExecState *exec, CSSRuleImpl *r)
+JSValue *toJS(ExecState *exec, CSSRuleImpl *r)
 {
   return cacheDOMObject<CSSRuleImpl, DOMCSSRule>(exec, r);
 }
@@ -974,7 +974,7 @@ void DOMCSSValue::put(ExecState *exec, const Identifier &propertyName, JSValue *
     DOMObject::put(exec, propertyName, value, attr);
 }
 
-JSValue *getDOMCSSValue(ExecState *exec, CSSValueImpl *v)
+JSValue *toJS(ExecState *exec, CSSValueImpl *v)
 {
   DOMObject *ret;
   if (!v)
@@ -1086,9 +1086,9 @@ JSValue *DOMCSSPrimitiveValueProtoFunc::callAsFunction(ExecState *exec, JSObject
     case DOMCSSPrimitiveValue::GetStringValue:
       return jsStringOrNull(val.getStringValue());
     case DOMCSSPrimitiveValue::GetCounterValue:
-      return getDOMCounter(exec,val.getCounterValue());
+      return toJS(exec,val.getCounterValue());
     case DOMCSSPrimitiveValue::GetRectValue:
-      return getDOMRect(exec,val.getRectValue());
+      return toJS(exec,val.getRectValue());
     case DOMCSSPrimitiveValue::GetRGBColorValue:
       return getDOMRGBColor(exec,val.getRGBColorValue());
     default:
@@ -1173,7 +1173,7 @@ JSValue *DOMCSSValueList::getValueProperty(ExecState *exec, int token) const
 JSValue *DOMCSSValueList::indexGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 {
   DOMCSSValueList *thisObj = static_cast<DOMCSSValueList *>(slot.slotBase());
-  return getDOMCSSValue(exec, static_cast<CSSValueListImpl *>(thisObj->impl())->item(slot.index()));
+  return toJS(exec, static_cast<CSSValueListImpl *>(thisObj->impl())->item(slot.index()));
 }
 
 bool DOMCSSValueList::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
@@ -1204,7 +1204,7 @@ JSValue *DOMCSSValueListFunc::callAsFunction(ExecState *exec, JSObject *thisObj,
   CSSValueListImpl &valueList = *static_cast<CSSValueListImpl *>(static_cast<DOMCSSValueList *>(thisObj)->impl());
   switch (id) {
     case DOMCSSValueList::Item:
-      return getDOMCSSValue(exec,valueList.item(args[0]->toInt32(exec)));
+      return toJS(exec,valueList.item(args[0]->toInt32(exec)));
     default:
       return jsUndefined();
   }
@@ -1280,19 +1280,19 @@ JSValue *DOMRect::getValueProperty(ExecState *exec, int token) const
   RectImpl &rect = *m_rect;
   switch (token) {
   case Top:
-    return getDOMCSSValue(exec, rect.top());
+    return toJS(exec, rect.top());
   case Right:
-    return getDOMCSSValue(exec, rect.right());
+    return toJS(exec, rect.right());
   case Bottom:
-    return getDOMCSSValue(exec, rect.bottom());
+    return toJS(exec, rect.bottom());
   case Left:
-    return getDOMCSSValue(exec, rect.left());
+    return toJS(exec, rect.left());
   default:
     return NULL;
   }
 }
 
-JSValue *getDOMRect(ExecState *exec, RectImpl *r)
+JSValue *toJS(ExecState *exec, RectImpl *r)
 {
   return cacheDOMObject<RectImpl, DOMRect>(exec, r);
 }
@@ -1333,7 +1333,7 @@ JSValue *DOMCounter::getValueProperty(ExecState *, int token) const
   }
 }
 
-JSValue *getDOMCounter(ExecState *exec, CounterImpl *c)
+JSValue *toJS(ExecState *exec, CounterImpl *c)
 {
   return cacheDOMObject<CounterImpl, DOMCounter>(exec, c);
 }
index 83278ae..c3a6c71 100644 (file)
@@ -3,7 +3,7 @@
  *  This file is part of the KDE libraries
  *  Copyright (C) 2000 Harri Porten (porten@kde.org)
  *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
- *  Copyright (C) 2004 Apple Computer, Inc.
+ *  Copyright (C) 2004, 2006 Apple Computer, Inc.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#ifndef _KJS_CSS_H_
-#define _KJS_CSS_H_
-
-#include "kjs_binding.h"
+#ifndef KJS_CSS_H_
+#define KJS_CSS_H_
 
 #include "Color.h"
+#include "kjs_binding.h"
 
 namespace DOM {
     class CounterImpl;
@@ -65,7 +64,7 @@ namespace KJS {
     RefPtr<DOM::CSSStyleDeclarationImpl> m_impl;
   };
 
-  JSValue *getDOMCSSStyleDeclaration(ExecState *exec, DOM::CSSStyleDeclarationImpl *d);
+  JSValue* toJS(ExecState*, WebCore::CSSStyleDeclarationImpl*);
 
   class DOMStyleSheet : public DOMObject {
   public:
@@ -86,7 +85,7 @@ namespace KJS {
     RefPtr<DOM::StyleSheetImpl> m_impl;
   };
 
-  JSValue* getDOMStyleSheet(ExecState*, PassRefPtr<WebCore::StyleSheetImpl>);
+  JSValue* toJS(ExecState*, PassRefPtr<WebCore::StyleSheetImpl>);
 
   class DOMStyleSheetList : public DOMObject {
   public:
@@ -130,7 +129,7 @@ namespace KJS {
     RefPtr<DOM::MediaListImpl> m_impl;
   };
 
-  JSValue *getDOMMediaList(ExecState *exec, DOM::MediaListImpl *ml);
+  JSValue* toJS(ExecState*, WebCore::MediaListImpl*);
 
   class DOMCSSStyleSheet : public DOMStyleSheet {
   public:
@@ -161,7 +160,7 @@ namespace KJS {
     RefPtr<DOM::CSSRuleListImpl> m_impl;
   };
 
-  JSValue *getDOMCSSRuleList(ExecState *exec, DOM::CSSRuleListImpl *rl);
+  JSValue* toJS(ExecState*, WebCore::CSSRuleListImpl*);
 
   class DOMCSSRule : public DOMObject {
   public:
@@ -183,7 +182,7 @@ namespace KJS {
     RefPtr<DOM::CSSRuleImpl> m_impl;
   };
 
-  JSValue *getDOMCSSRule(ExecState *exec, DOM::CSSRuleImpl *r);
+  JSValue* toJS(ExecState*, WebCore::CSSRuleImpl*);
 
   // Constructor for CSSRule - currently only used for some global values
   class CSSRuleConstructor : public DOMObject {
@@ -217,7 +216,7 @@ namespace KJS {
     RefPtr<DOM::CSSValueImpl> m_impl;
   };
 
-  JSValue *getDOMCSSValue(ExecState *exec, DOM::CSSValueImpl *v);
+  JSValue* toJS(ExecState*, WebCore::CSSValueImpl*);
 
   // Constructor for CSSValue - currently only used for some global values
   class CSSValueConstructor : public DOMObject {
@@ -301,7 +300,7 @@ namespace KJS {
     RefPtr<DOM::RectImpl> m_rect;
   };
 
-  JSValue *getDOMRect(ExecState *exec, DOM::RectImpl *r);
+  JSValue* toJS(ExecState*, WebCore::RectImpl*);
 
   class DOMCounter : public DOMObject {
   public:
@@ -317,7 +316,7 @@ namespace KJS {
     RefPtr<DOM::CounterImpl> m_counter;
   };
 
-  JSValue *getDOMCounter(ExecState *exec, DOM::CounterImpl *c);
+  JSValue* toJS(ExecState*, WebCore::CounterImpl*);
 
 } // namespace
 
index e215e69..7ad5735 100644 (file)
@@ -270,19 +270,19 @@ JSValue *DOMNode::getValueProperty(ExecState *exec, int token) const
     return jsNumber(node.nodeType());
   case ParentNode:
   case ParentElement: // IE only apparently
-    return getDOMNode(exec,node.parentNode());
+    return toJS(exec,node.parentNode());
   case ChildNodes:
-    return getDOMNodeList(exec,node.childNodes().get());
+    return toJS(exec,node.childNodes().get());
   case FirstChild:
-    return getDOMNode(exec,node.firstChild());
+    return toJS(exec,node.firstChild());
   case LastChild:
-    return getDOMNode(exec,node.lastChild());
+    return toJS(exec,node.lastChild());
   case PreviousSibling:
-    return getDOMNode(exec,node.previousSibling());
+    return toJS(exec,node.previousSibling());
   case NextSibling:
-    return getDOMNode(exec,node.nextSibling());
+    return toJS(exec,node.nextSibling());
   case Attributes:
-    return getDOMNamedNodeMap(exec,node.attributes());
+    return toJS(exec,node.attributes());
   case NamespaceURI:
     return jsStringOrNull(node.namespaceURI());
   case Prefix:
@@ -290,7 +290,7 @@ JSValue *DOMNode::getValueProperty(ExecState *exec, int token) const
   case LocalName:
     return jsStringOrNull(node.localName());
   case OwnerDocument:
-    return getDOMNode(exec,node.ownerDocument());
+    return toJS(exec,node.ownerDocument());
   case TextContent:
     return jsStringOrNull(node.textContent());
   case OnAbort:
@@ -399,7 +399,7 @@ JSValue *DOMNode::getValueProperty(ExecState *exec, int token) const
       return rend ? jsNumber(rend->offsetHeight()) : static_cast<JSValue *>(jsUndefined());
     case OffsetParent: {
       RenderObject* par = rend ? rend->offsetParent() : 0;
-      return getDOMNode(exec, par ? par->element() : 0);
+      return toJS(exec, par ? par->element() : 0);
     }
     case ClientWidth:
       return rend ? jsNumber(rend->clientWidth()) : static_cast<JSValue *>(jsUndefined());
@@ -627,7 +627,7 @@ JSValue *DOMNodeProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, co
     case DOMNode::HasChildNodes:
       return jsBoolean(node.hasChildNodes());
     case DOMNode::CloneNode:
-      return getDOMNode(exec,node.cloneNode(args[0]->toBoolean(exec)));
+      return toJS(exec,node.cloneNode(args[0]->toBoolean(exec)));
     case DOMNode::Normalize:
       node.normalize();
       return jsUndefined();
@@ -730,13 +730,13 @@ JSValue *DOMNodeList::getValueProperty(ExecState *exec, int token) const
 JSValue *DOMNodeList::indexGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 {
   DOMNodeList *thisObj = static_cast<DOMNodeList *>(slot.slotBase());
-  return getDOMNode(exec, thisObj->m_impl->item(slot.index()));
+  return toJS(exec, thisObj->m_impl->item(slot.index()));
 }
 
 JSValue *DOMNodeList::nameGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 {
   DOMNodeList *thisObj = static_cast<DOMNodeList *>(slot.slotBase());
-  return getDOMNode(exec, thisObj->m_impl->itemById(propertyName.domString().impl()));
+  return toJS(exec, thisObj->m_impl->itemById(propertyName.domString().impl()));
 }
 
 bool DOMNodeList::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
@@ -775,7 +775,7 @@ JSValue *DOMNodeList::callAsFunction(ExecState *exec, JSObject *, const List &ar
   bool ok;
   unsigned int u = s.toUInt32(&ok);
   if (ok)
-    return getDOMNode(exec, m_impl->item(u));
+    return toJS(exec, m_impl->item(u));
 
   return jsUndefined();
 }
@@ -788,7 +788,7 @@ JSValue *DOMNodeListFunc::callAsFunction(ExecState *exec, JSObject *thisObj, con
   DOM::NodeListImpl &list = *static_cast<DOMNodeList *>(thisObj)->impl();
 
   if (id == DOMNodeList::Item)
-    return getDOMNode(exec, list.item(args[0]->toInt32(exec)));
+    return toJS(exec, list.item(args[0]->toInt32(exec)));
 
   return jsUndefined();
 }
@@ -884,11 +884,11 @@ JSValue *DOMDocument::getValueProperty(ExecState *exec, int token) const
 
   switch(token) {
   case DocType:
-    return getDOMNode(exec,doc.doctype());
+    return toJS(exec,doc.doctype());
   case Implementation:
-    return getDOMDOMImplementation(exec, doc.implementation());
+    return toJS(exec, doc.implementation());
   case DocumentElement:
-    return getDOMNode(exec,doc.documentElement());
+    return toJS(exec,doc.documentElement());
   case Charset:
   case CharacterSet:
   case ActualEncoding:
@@ -917,7 +917,7 @@ JSValue *DOMDocument::getValueProperty(ExecState *exec, int token) const
     }
     return jsUndefined();
   case DOMDocument::DefaultView: // DOM2
-    return getDOMAbstractView(exec,doc.defaultView());
+    return toJS(exec,doc.defaultView());
   default:
     return NULL;
   }
@@ -953,39 +953,39 @@ JSValue *DOMDocumentProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj
 
   switch(id) {
   case DOMDocument::AdoptNode:
-    return getDOMNode(exec,doc.adoptNode(toNode(args[0]),exception));
+    return toJS(exec,doc.adoptNode(toNode(args[0]),exception));
   case DOMDocument::CreateElement:
-    return getDOMNode(exec,doc.createElement(s, exception));
+    return toJS(exec,doc.createElement(s, exception));
   case DOMDocument::CreateDocumentFragment:
-    return getDOMNode(exec,doc.createDocumentFragment());
+    return toJS(exec,doc.createDocumentFragment());
   case DOMDocument::CreateTextNode:
-    return getDOMNode(exec,doc.createTextNode(s));
+    return toJS(exec,doc.createTextNode(s));
   case DOMDocument::CreateComment:
-    return getDOMNode(exec,doc.createComment(s));
+    return toJS(exec,doc.createComment(s));
   case DOMDocument::CreateCDATASection:
-    return getDOMNode(exec, doc.createCDATASection(s, exception));
+    return toJS(exec, doc.createCDATASection(s, exception));
   case DOMDocument::CreateProcessingInstruction:
-    return getDOMNode(exec, doc.createProcessingInstruction(args[0]->toString(exec).domString(), args[1]->toString(exec).domString(), exception));
+    return toJS(exec, doc.createProcessingInstruction(args[0]->toString(exec).domString(), args[1]->toString(exec).domString(), exception));
   case DOMDocument::CreateAttribute:
-    return getDOMNode(exec,doc.createAttribute(s, exception));
+    return toJS(exec,doc.createAttribute(s, exception));
   case DOMDocument::CreateEntityReference:
-    return getDOMNode(exec, doc.createEntityReference(s, exception));
+    return toJS(exec, doc.createEntityReference(s, exception));
   case DOMDocument::ElementFromPoint:
-    return getDOMNode(exec,doc.elementFromPoint((int)args[0]->toNumber(exec), (int)args[1]->toNumber(exec)));
+    return toJS(exec,doc.elementFromPoint((int)args[0]->toNumber(exec), (int)args[1]->toNumber(exec)));
   case DOMDocument::GetElementsByTagName:
-    return getDOMNodeList(exec,doc.getElementsByTagName(s).get());
+    return toJS(exec,doc.getElementsByTagName(s).get());
   case DOMDocument::ImportNode: // DOM2
-    return getDOMNode(exec,doc.importNode(toNode(args[0]), args[1]->toBoolean(exec), exception));
+    return toJS(exec,doc.importNode(toNode(args[0]), args[1]->toBoolean(exec), exception));
   case DOMDocument::CreateElementNS: // DOM2
-    return getDOMNode(exec,doc.createElementNS(s, args[1]->toString(exec).domString(), exception));
+    return toJS(exec,doc.createElementNS(s, args[1]->toString(exec).domString(), exception));
   case DOMDocument::CreateAttributeNS: // DOM2
-    return getDOMNode(exec,doc.createAttributeNS(s, args[1]->toString(exec).domString(), exception));
+    return toJS(exec,doc.createAttributeNS(s, args[1]->toString(exec).domString(), exception));
   case DOMDocument::GetElementsByTagNameNS: // DOM2
-    return getDOMNodeList(exec,doc.getElementsByTagNameNS(s, args[1]->toString(exec).domString()).get());
+    return toJS(exec,doc.getElementsByTagNameNS(s, args[1]->toString(exec).domString()).get());
   case DOMDocument::GetElementById:
-    return getDOMNode(exec,doc.getElementById(args[0]->toString(exec).domString().impl()));
+    return toJS(exec,doc.getElementById(args[0]->toString(exec).domString().impl()));
   case DOMDocument::CreateRange:
-    return getDOMRange(exec, doc.createRange().get());
+    return toJS(exec, doc.createRange().get());
   case DOMDocument::CreateNodeIterator: {
     RefPtr<NodeFilterImpl> filter;
     JSValue* arg2 = args[2];
@@ -993,7 +993,7 @@ JSValue *DOMDocumentProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj
       JSObject* o(static_cast<JSObject*>(arg2));
       filter = new NodeFilterImpl(new JSNodeFilterCondition(o));
     }
-    return getDOMNodeIterator(exec, doc.createNodeIterator(toNode(args[0]), args[1]->toUInt32(exec),
+    return toJS(exec, doc.createNodeIterator(toNode(args[0]), args[1]->toUInt32(exec),
         filter.release(), args[3]->toBoolean(exec), exception).get());
   }
   case DOMDocument::CreateTreeWalker: {
@@ -1003,14 +1003,14 @@ JSValue *DOMDocumentProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj
       JSObject* o(static_cast<JSObject *>(arg2));
       filter = new NodeFilterImpl(new JSNodeFilterCondition(o));
     }
-    return getDOMTreeWalker(exec, doc.createTreeWalker(toNode(args[0]), args[1]->toUInt32(exec),
+    return toJS(exec, doc.createTreeWalker(toNode(args[0]), args[1]->toUInt32(exec),
         filter.release(), args[3]->toBoolean(exec), exception).get());
   }
   case DOMDocument::CreateEvent:
-    return getDOMEvent(exec, doc.createEvent(s, exception).get());
+    return toJS(exec, doc.createEvent(s, exception).get());
   case DOMDocument::GetOverrideStyle:
     if (ElementImpl *element0 = toElement(args[0]))
-        return getDOMCSSStyleDeclaration(exec,doc.getOverrideStyle(element0, args[1]->toString(exec).domString()));
+        return toJS(exec,doc.getOverrideStyle(element0, args[1]->toString(exec).domString()));
     // FIXME: Is undefined right here, or should we raise an exception?
     return jsUndefined();
   case DOMDocument::ExecCommand: {
@@ -1221,13 +1221,13 @@ JSValue *DOMNamedNodeMap::lengthGetter(ExecState* exec, JSObject *originalObject
 JSValue *DOMNamedNodeMap::indexGetter(ExecState* exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 {
   DOMNamedNodeMap *thisObj = static_cast<DOMNamedNodeMap *>(slot.slotBase());
-  return getDOMNode(exec, thisObj->m_impl->item(slot.index()));
+  return toJS(exec, thisObj->m_impl->item(slot.index()));
 }
 
 JSValue *DOMNamedNodeMap::nameGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 {
   DOMNamedNodeMap *thisObj = static_cast<DOMNamedNodeMap *>(slot.slotBase());
-  return getDOMNode(exec, thisObj->m_impl->getNamedItem(propertyName.domString()));
+  return toJS(exec, thisObj->m_impl->getNamedItem(propertyName.domString()));
 }
 
 bool DOMNamedNodeMap::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
@@ -1264,33 +1264,32 @@ JSValue *DOMNamedNodeMapProtoFunc::callAsFunction(ExecState *exec, JSObject *thi
     return throwError(exec, TypeError);
   DOMExceptionTranslator exception(exec);
   NamedNodeMapImpl &map = *static_cast<DOMNamedNodeMap *>(thisObj)->impl();
-
-  switch(id) {
+  switch (id) {
     case DOMNamedNodeMap::GetNamedItem:
-      return getDOMNode(exec, map.getNamedItem(args[0]->toString(exec).domString()));
+      return toJS(exec, map.getNamedItem(args[0]->toString(exec).domString()));
     case DOMNamedNodeMap::SetNamedItem:
-      return getDOMNode(exec, map.setNamedItem(toNode(args[0]), exception).get());
+      return toJS(exec, map.setNamedItem(toNode(args[0]), exception).get());
     case DOMNamedNodeMap::RemoveNamedItem:
-      return getDOMNode(exec, map.removeNamedItem(args[0]->toString(exec).domString(), exception).get());
+      return toJS(exec, map.removeNamedItem(args[0]->toString(exec).domString(), exception).get());
     case DOMNamedNodeMap::Item:
-      return getDOMNode(exec, map.item(args[0]->toInt32(exec)));
+      return toJS(exec, map.item(args[0]->toInt32(exec)));
     case DOMNamedNodeMap::GetNamedItemNS: // DOM2
-      return getDOMNode(exec, map.getNamedItemNS(valueToStringWithNullCheck(exec, args[0]), args[1]->toString(exec).domString()));
+      return toJS(exec, map.getNamedItemNS(valueToStringWithNullCheck(exec, args[0]), args[1]->toString(exec).domString()));
     case DOMNamedNodeMap::SetNamedItemNS: // DOM2
-      return getDOMNode(exec, map.setNamedItemNS(toNode(args[0]), exception).get());
+      return toJS(exec, map.setNamedItemNS(toNode(args[0]), exception).get());
     case DOMNamedNodeMap::RemoveNamedItemNS: // DOM2
-      return getDOMNode(exec, map.removeNamedItemNS(valueToStringWithNullCheck(exec, args[0]), args[1]->toString(exec).domString(), exception).get());
-    default:
-      break;
+      return toJS(exec, map.removeNamedItemNS(valueToStringWithNullCheck(exec, args[0]), args[1]->toString(exec).domString(), exception).get());
   }
-
   return jsUndefined();
 }
 
 // -------------------------------------------------------------------------
 
-JSValue *getDOMDocumentNode(ExecState *exec, DocumentImpl *n)
+JSValue* toJS(ExecState *exec, DocumentImpl *n)
 {
+  if (!n)
+    return jsNull();
+
   DOMDocument *ret = 0;
   ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
 
@@ -1325,7 +1324,7 @@ bool checkNodeSecurity(ExecState *exec, NodeImpl *n)
   return win && win->isSafeScript(exec);
 }
 
-JSValue *getDOMNode(ExecState *exec, PassRefPtr<NodeImpl> node)
+JSValue *toJS(ExecState *exec, PassRefPtr<NodeImpl> node)
 {
   NodeImpl* n = node.get();
   DOMNode *ret = 0;
@@ -1362,7 +1361,7 @@ JSValue *getDOMNode(ExecState *exec, PassRefPtr<NodeImpl> node)
       break;
     case WebCore::NodeImpl::DOCUMENT_NODE:
       // we don't want to cache the document itself in the per-document dictionary
-      return getDOMDocumentNode(exec, static_cast<DocumentImpl *>(n));
+      return toJS(exec, static_cast<DocumentImpl *>(n));
     case WebCore::NodeImpl::DOCUMENT_TYPE_NODE:
       ret = new JSDocumentType(exec, static_cast<DocumentTypeImpl *>(n));
       break;
@@ -1380,7 +1379,7 @@ JSValue *getDOMNode(ExecState *exec, PassRefPtr<NodeImpl> node)
   return ret;
 }
 
-JSValue *getDOMNamedNodeMap(ExecState *exec, NamedNodeMapImpl *m)
+JSValue *toJS(ExecState *exec, NamedNodeMapImpl *m)
 {
   return cacheDOMObject<NamedNodeMapImpl, DOMNamedNodeMap>(exec, m);
 }
@@ -1413,16 +1412,11 @@ JSValue *getRuntimeObject(ExecState *exec, NodeImpl *n)
     return 0;
 }
 
-JSValue *getDOMNodeList(ExecState *exec, PassRefPtr<NodeListImpl> l)
+JSValue *toJS(ExecState *exec, PassRefPtr<NodeListImpl> l)
 {
   return cacheDOMObject<NodeListImpl, DOMNodeList>(exec, l.get());
 }
 
-JSValue *getDOMDOMImplementation(ExecState *exec, DOMImplementationImpl *i)
-{
-  return cacheDOMObject<DOMImplementationImpl, JSDOMImplementation>(exec, i);
-}
-
 // -------------------------------------------------------------------------
 
 const ClassInfo NodeConstructor::info = { "NodeConstructor", 0, &NodeConstructorTable, 0 };
@@ -1517,7 +1511,7 @@ JSValue *DOMNamedNodesCollection::lengthGetter(ExecState* exec, JSObject *origin
 JSValue *DOMNamedNodesCollection::indexGetter(ExecState* exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 {
   DOMNamedNodesCollection *thisObj = static_cast<DOMNamedNodesCollection *>(slot.slotBase());
-  return getDOMNode(exec, thisObj->m_nodes[slot.index()].get());
+  return toJS(exec, thisObj->m_nodes[slot.index()].get());
 }
 
 bool DOMNamedNodesCollection::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
index 2d80b0b..644f33d 100644 (file)
@@ -209,13 +209,12 @@ namespace KJS {
     static const ClassInfo info;
   };
 
-  JSValue *getDOMDocumentNode(ExecState *exec, DOM::DocumentImpl *n);
+  JSValue* toJS(ExecState*, WebCore::DocumentImpl*);
   bool checkNodeSecurity(ExecState *exec, DOM::NodeImpl *n);
   JSValue *getRuntimeObject(ExecState *exec, DOM::NodeImpl *n);
-  JSValue *getDOMNode(ExecState*, PassRefPtr<DOM::NodeImpl>);
-  JSValue *getDOMNamedNodeMap(ExecState *exec, DOM::NamedNodeMapImpl *m);
-  JSValue *getDOMNodeList(ExecState *exec, PassRefPtr<DOM::NodeListImpl>);
-  JSValue *getDOMDOMImplementation(ExecState *exec, DOM::DOMImplementationImpl *i);
+  JSValue* toJS(ExecState*, PassRefPtr<WebCore::NodeImpl>);
+  JSValue* toJS(ExecState*, WebCore::NamedNodeMapImpl *);
+  JSValue* toJS(ExecState*, PassRefPtr<WebCore::NodeListImpl>);
   JSObject *getNodeConstructor(ExecState *exec);
   JSObject *getDOMExceptionConstructor(ExecState *exec);
 
index a068f8f..e80e5aa 100644 (file)
@@ -87,7 +87,7 @@ void JSAbstractEventListener::handleEvent(EventImpl* ele, bool isWindowEvent)
         ref();
       
         List args;
-        args.append(getDOMEvent(exec, event));
+        args.append(toJS(exec, event));
       
         // Set the event we're handling in the Window object
         window->setCurrentEvent(event);
@@ -102,7 +102,7 @@ void JSAbstractEventListener::handleEvent(EventImpl* ele, bool isWindowEvent)
             if (isWindowEvent)
                 thisObj = window;
             else
-                thisObj = static_cast<JSObject*>(getDOMNode(exec, event->currentTarget()));
+                thisObj = static_cast<JSObject*>(toJS(exec, event->currentTarget()));
             retval = listener->call(exec, thisObj, args);
         }
 
@@ -272,7 +272,7 @@ void JSLazyEventListener::parseCode() const
             // (and the document, and the form - see HTMLElement::eventHandlerScope)
             ScopeChain scope = listener->scope();
 
-            JSValue* thisObj = getDOMNode(exec, originalNode);
+            JSValue* thisObj = toJS(exec, originalNode);
             if (thisObj->isObject()) {
                 static_cast<DOMNode*>(thisObj)->pushEventHandlerScope(exec, scope);
                 listener->setScope(scope);
@@ -398,9 +398,9 @@ JSValue *DOMEvent::getValueProperty(ExecState *exec, int token) const
     return jsString(event.type().domString());
   case Target:
   case SrcElement: /*MSIE extension - "the object that fired the event"*/
-    return getDOMNode(exec, event.target());
+    return toJS(exec, event.target());
   case CurrentTarget:
-    return getDOMNode(exec, event.currentTarget());
+    return toJS(exec, event.currentTarget());
   case EventPhase:
     return jsNumber(event.eventPhase());
   case Bubbles:
@@ -483,7 +483,7 @@ JSValue *DOMEventProtoFunc::callAsFunction(ExecState *exec, JSObject * thisObj,
   return jsUndefined();
 }
 
-JSValue *getDOMEvent(ExecState *exec, EventImpl *e)
+JSValue *toJS(ExecState *exec, EventImpl *e)
 {
   if (!e)
     return jsNull();
@@ -583,7 +583,7 @@ JSValue *DOMUIEvent::getValueProperty(ExecState *exec, int token) const
   UIEventImpl &event = *static_cast<UIEventImpl *>(impl());
   switch (token) {
   case View:
-    return getDOMAbstractView(exec, event.view());
+    return toJS(exec, event.view());
   case Detail:
     return jsNumber(event.detail());
   case KeyCode:
@@ -691,11 +691,11 @@ JSValue *DOMMouseEvent::getValueProperty(ExecState *exec, int token) const
   case Button:
     return jsNumber(event.button());
   case ToElement:
-    return getDOMNode(exec, event.toElement());
+    return toJS(exec, event.toElement());
   case FromElement:
-    return getDOMNode(exec, event.fromElement());
+    return toJS(exec, event.fromElement());
   case RelatedTarget:
-    return getDOMNode(exec, event.relatedTarget());
+    return toJS(exec, event.relatedTarget());
   case X:
     return jsNumber(event.x());
   case Y:
index 1e6939a..68ec1bd 100644 (file)
@@ -127,7 +127,7 @@ namespace KJS {
         mutable Clipboard* clipboard;
     };
 
-    JSValue* getDOMEvent(ExecState*, DOM::EventImpl*);
+    JSValue* toJS(ExecState*, WebCore::EventImpl*);
 
     DOM::EventImpl* toEvent(JSValue*); // returns 0 if value is not a DOMEvent object
 
index 22e0d2e..4a4c233 100644 (file)
 #include "kjs_html.h"
 
 #include "AtomicString.h"
-#include "Color.h"
 #include "DocLoader.h"
 #include "EventNames.h"
 #include "Frame.h"
 #include "FrameView.h"
-#include "GraphicsContext.h"
 #include "HTMLBaseFontElementImpl.h"
 #include "HTMLButtonElementImpl.h"
 #include "HTMLFieldSetElementImpl.h"
 #include "HTMLSelectElementImpl.h"
 #include "HTMLTextAreaElementImpl.h"
 #include "Image.h"
+#include "JSCanvasRenderingContext2D.h"
 #include "NameNodeListImpl.h"
 #include "TextImpl.h"
-#include "css/css_ruleimpl.h"
-#include "css/css_stylesheetimpl.h"
-#include "css/cssparser.h"
+#include "css_ruleimpl.h"
 #include "dom2_eventsimpl.h"
-#include "html/html_baseimpl.h"
-#include "html/html_blockimpl.h"
-#include "html/html_canvasimpl.h"
-#include "html/html_documentimpl.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 "html_baseimpl.h"
+#include "html_blockimpl.h"
+#include "html_canvasimpl.h"
+#include "html_documentimpl.h"
+#include "html_headimpl.h"
+#include "html_imageimpl.h"
+#include "html_inlineimpl.h"
+#include "html_listimpl.h"
+#include "html_objectimpl.h"
+#include "html_tableimpl.h"
 #include "kjs_css.h"
 #include "kjs_events.h"
 #include "kjs_proxy.h"
 #include "kjs_window.h"
-#include "rendering/render_canvasimage.h"
-#include "rendering/render_layer.h"
-#include "rendering/render_object.h"
-
-#if __APPLE__
-#include <ApplicationServices/ApplicationServices.h>
-using khtml::RenderCanvasImage;
-#endif
-
-using namespace DOM;
-using namespace DOM::HTMLNames;
-using namespace DOM::EventNames;
+#include "render_layer.h"
 
 #include "kjs_html.lut.h"
 
+using namespace WebCore;
+using namespace HTMLNames;
+using namespace EventNames;
+
 namespace KJS {
 
 class HTMLElementFunction : public InternalFunctionImp {
@@ -90,7 +80,7 @@ private:
 
 KJS_IMPLEMENT_PROTOFUNC(HTMLDocFunction)
 
-JSValue *KJS::HTMLDocFunction::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
+JSValue *HTMLDocFunction::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
 {
   if (!thisObj->inherits(&HTMLDocument::info))
     return throwError(exec, TypeError);
@@ -136,7 +126,7 @@ JSValue *KJS::HTMLDocFunction::callAsFunction(ExecState *exec, JSObject *thisObj
     return jsUndefined();
   }
   case HTMLDocument::GetElementsByName:
-    return getDOMNodeList(exec, doc.getElementsByName(args[0]->toString(exec).domString()).get());
+    return toJS(exec, doc.getElementsByName(args[0]->toString(exec).domString()).get());
   case HTMLDocument::CaptureEvents:
   case HTMLDocument::ReleaseEvents:
     // Do nothing for now. These are NS-specific legacy calls.
@@ -146,7 +136,7 @@ JSValue *KJS::HTMLDocFunction::callAsFunction(ExecState *exec, JSObject *thisObj
   return jsUndefined();
 }
 
-const ClassInfo KJS::HTMLDocument::info =
+const ClassInfo HTMLDocument::info =
   { "HTMLDocument", &DOMDocument::info, &HTMLDocumentTable, 0 };
 /* Source for HTMLDocumentTable. Use "make hashtables" to regenerate.
 @begin HTMLDocumentTable 30
@@ -212,7 +202,7 @@ JSValue *HTMLDocument::namedItemGetter(ExecState *exec, JSObject *originalObject
     Frame *frame;
     if (node->hasTagName(iframeTag) && (frame = static_cast<DOM::HTMLIFrameElementImpl *>(node)->contentFrame()))
       return Window::retrieve(frame);
-    return getDOMNode(exec, node);
+    return toJS(exec, node);
   }
 
   return getHTMLCollection(exec, collection.get());
@@ -238,7 +228,7 @@ JSValue *HTMLDocument::getValueProperty(ExecState *exec, int token) const
   case URL:
     return jsString(doc.URL());
   case Body:
-    return getDOMNode(exec, body);
+    return toJS(exec, body);
   case Location:
     if (Window* win = Window::retrieveWindow(frame))
       return win->location();
@@ -330,12 +320,12 @@ bool HTMLDocument::getOwnPropertySlot(ExecState *exec, const Identifier& propert
   return DOMDocument::getOwnPropertySlot(exec, propertyName, slot);
 }
 
-void KJS::HTMLDocument::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
+void HTMLDocument::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
 {
     lookupPut<HTMLDocument, DOMDocument>(exec, propertyName, value, attr, &HTMLDocumentTable, this);
 }
 
-void KJS::HTMLDocument::putValueProperty(ExecState *exec, int token, JSValue *value, int /*attr*/)
+void HTMLDocument::putValueProperty(ExecState *exec, int token, JSValue *value, int /*attr*/)
 {
   DOMExceptionTranslator exception(exec);
   HTMLDocumentImpl &doc = *static_cast<HTMLDocumentImpl *>(impl());
@@ -364,7 +354,7 @@ void KJS::HTMLDocument::putValueProperty(ExecState *exec, int token, JSValue *va
       // When assigning location, IE and Mozilla both resolve the URL
       // relative to the frame where the JavaScript is executing not
       // the target frame.
-      Frame *activePart = static_cast<KJS::ScriptInterpreter *>( exec->dynamicInterpreter() )->frame();
+      Frame *activePart = static_cast<ScriptInterpreter *>( exec->dynamicInterpreter() )->frame();
       if (activePart)
         str = activePart->document()->completeURL(str);
 
@@ -437,64 +427,64 @@ void KJS::HTMLDocument::putValueProperty(ExecState *exec, int token, JSValue *va
 
 // -------------------------------------------------------------------------
 
-const ClassInfo KJS::HTMLElement::a_info = { "HTMLAnchorElement", &KJS::HTMLElement::info, &HTMLAnchorElementTable, 0 };
-const ClassInfo KJS::HTMLElement::applet_info = { "HTMLAppletElement", &KJS::HTMLElement::info, &HTMLAppletElementTable, 0 };
-const ClassInfo KJS::HTMLElement::area_info = { "HTMLAreaElement", &KJS::HTMLElement::info, &HTMLAreaElementTable, 0 };
-const ClassInfo KJS::HTMLElement::baseFont_info = { "HTMLBaseFontElement", &KJS::HTMLElement::info, &HTMLBaseFontElementTable, 0 };
-const ClassInfo KJS::HTMLElement::base_info = { "HTMLBaseElement", &KJS::HTMLElement::info, &HTMLBaseElementTable, 0 };
-const ClassInfo KJS::HTMLElement::blockQuote_info = { "HTMLBlockQuoteElement", &KJS::HTMLElement::info, &HTMLBlockQuoteElementTable, 0 };
-const ClassInfo KJS::HTMLElement::body_info = { "HTMLBodyElement", &KJS::HTMLElement::info, &HTMLBodyElementTable, 0 };
-const ClassInfo KJS::HTMLElement::br_info = { "HTMLBRElement", &KJS::HTMLElement::info, &HTMLBRElementTable, 0 };
-const ClassInfo KJS::HTMLElement::button_info = { "HTMLButtonElement", &KJS::HTMLElement::info, &HTMLButtonElementTable, 0 };
-const ClassInfo KJS::HTMLElement::canvas_info = { "HTMLCanvasElement", &KJS::HTMLElement::info, &HTMLCanvasElementTable, 0 };
-const ClassInfo KJS::HTMLElement::caption_info = { "HTMLTableCaptionElement", &KJS::HTMLElement::info, &HTMLTableCaptionElementTable, 0 };
-const ClassInfo KJS::HTMLElement::col_info = { "HTMLTableColElement", &KJS::HTMLElement::info, &HTMLTableColElementTable, 0 };
-const ClassInfo KJS::HTMLElement::dir_info = { "HTMLDirectoryElement", &KJS::HTMLElement::info, &HTMLDirectoryElementTable, 0 };
-const ClassInfo KJS::HTMLElement::div_info = { "HTMLDivElement", &KJS::HTMLElement::info, &HTMLDivElementTable, 0 };
-const ClassInfo KJS::HTMLElement::dl_info = { "HTMLDListElement", &KJS::HTMLElement::info, &HTMLDListElementTable, 0 };
-const ClassInfo KJS::HTMLElement::fieldSet_info = { "HTMLFieldSetElement", &KJS::HTMLElement::info, &HTMLFieldSetElementTable, 0 };
-const ClassInfo KJS::HTMLElement::font_info = { "HTMLFontElement", &KJS::HTMLElement::info, &HTMLFontElementTable, 0 };
-const ClassInfo KJS::HTMLElement::form_info = { "HTMLFormElement", &KJS::HTMLElement::info, &HTMLFormElementTable, 0 };
-const ClassInfo KJS::HTMLElement::frameSet_info = { "HTMLFrameSetElement", &KJS::HTMLElement::info, &HTMLFrameSetElementTable, 0 };
-const ClassInfo KJS::HTMLElement::frame_info = { "HTMLFrameElement", &KJS::HTMLElement::info, &HTMLFrameElementTable, 0 };
-const ClassInfo KJS::HTMLElement::head_info = { "HTMLHeadElement", &KJS::HTMLElement::info, &HTMLHeadElementTable, 0 };
-const ClassInfo KJS::HTMLElement::heading_info = { "HTMLHeadingElement", &KJS::HTMLElement::info, &HTMLHeadingElementTable, 0 };
-const ClassInfo KJS::HTMLElement::hr_info = { "HTMLHRElement", &KJS::HTMLElement::info, &HTMLHRElementTable, 0 };
-const ClassInfo KJS::HTMLElement::html_info = { "HTMLHtmlElement", &KJS::HTMLElement::info, &HTMLHtmlElementTable, 0 };
-const ClassInfo KJS::HTMLElement::iFrame_info = { "HTMLIFrameElement", &KJS::HTMLElement::info, &HTMLIFrameElementTable, 0 };
-const ClassInfo KJS::HTMLElement::img_info = { "HTMLImageElement", &KJS::HTMLElement::info, &HTMLImageElementTable, 0 };
-const ClassInfo KJS::HTMLElement::info = { "HTMLElement", &JSElement::info, &HTMLElementTable, 0 };
-const ClassInfo KJS::HTMLElement::input_info = { "HTMLInputElement", &KJS::HTMLElement::info, &HTMLInputElementTable, 0 };
-const ClassInfo KJS::HTMLElement::isIndex_info = { "HTMLIsIndexElement", &KJS::HTMLElement::info, &HTMLIsIndexElementTable, 0 };
-const ClassInfo KJS::HTMLElement::label_info = { "HTMLLabelElement", &KJS::HTMLElement::info, &HTMLLabelElementTable, 0 };
-const ClassInfo KJS::HTMLElement::legend_info = { "HTMLLegendElement", &KJS::HTMLElement::info, &HTMLLegendElementTable, 0 };
-const ClassInfo KJS::HTMLElement::li_info = { "HTMLLIElement", &KJS::HTMLElement::info, &HTMLLIElementTable, 0 };
-const ClassInfo KJS::HTMLElement::link_info = { "HTMLLinkElement", &KJS::HTMLElement::info, &HTMLLinkElementTable, 0 };
-const ClassInfo KJS::HTMLElement::map_info = { "HTMLMapElement", &KJS::HTMLElement::info, &HTMLMapElementTable, 0 };
-const ClassInfo KJS::HTMLElement::marquee_info = { "HTMLMarqueeElement", &KJS::HTMLElement::info, &HTMLMarqueeElementTable, 0 };
-const ClassInfo KJS::HTMLElement::menu_info = { "HTMLMenuElement", &KJS::HTMLElement::info, &HTMLMenuElementTable, 0 };
-const ClassInfo KJS::HTMLElement::meta_info = { "HTMLMetaElement", &KJS::HTMLElement::info, &HTMLMetaElementTable, 0 };
-const ClassInfo KJS::HTMLElement::mod_info = { "HTMLModElement", &KJS::HTMLElement::info, &HTMLModElementTable, 0 };
-const ClassInfo KJS::HTMLElement::object_info = { "HTMLObjectElement", &KJS::HTMLElement::info, &HTMLObjectElementTable, 0 };
-const ClassInfo KJS::HTMLElement::ol_info = { "HTMLOListElement", &KJS::HTMLElement::info, &HTMLOListElementTable, 0 };
-const ClassInfo KJS::HTMLElement::optGroup_info = { "HTMLOptGroupElement", &KJS::HTMLElement::info, &HTMLOptGroupElementTable, 0 };
-const ClassInfo KJS::HTMLElement::option_info = { "HTMLOptionElement", &KJS::HTMLElement::info, &HTMLOptionElementTable, 0 };
-const ClassInfo KJS::HTMLElement::p_info = { "HTMLParagraphElement", &KJS::HTMLElement::info, &HTMLParagraphElementTable, 0 };
-const ClassInfo KJS::HTMLElement::param_info = { "HTMLParamElement", &KJS::HTMLElement::info, &HTMLParamElementTable, 0 };
-const ClassInfo KJS::HTMLElement::pre_info = { "HTMLPreElement", &KJS::HTMLElement::info, &HTMLPreElementTable, 0 };
-const ClassInfo KJS::HTMLElement::q_info = { "HTMLQuoteElement", &KJS::HTMLElement::info, &HTMLQuoteElementTable, 0 };
-const ClassInfo KJS::HTMLElement::script_info = { "HTMLScriptElement", &KJS::HTMLElement::info, &HTMLScriptElementTable, 0 };
-const ClassInfo KJS::HTMLElement::select_info = { "HTMLSelectElement", &KJS::HTMLElement::info, &HTMLSelectElementTable, 0 };
-const ClassInfo KJS::HTMLElement::style_info = { "HTMLStyleElement", &KJS::HTMLElement::info, &HTMLStyleElementTable, 0 };
-const ClassInfo KJS::HTMLElement::table_info = { "HTMLTableElement", &KJS::HTMLElement::info, &HTMLTableElementTable, 0 };
-const ClassInfo KJS::HTMLElement::tablecell_info = { "HTMLTableCellElement", &KJS::HTMLElement::info, &HTMLTableCellElementTable, 0 };
-const ClassInfo KJS::HTMLElement::tablesection_info = { "HTMLTableSectionElement", &KJS::HTMLElement::info, &HTMLTableSectionElementTable, 0 };
-const ClassInfo KJS::HTMLElement::textArea_info = { "HTMLTextAreaElement", &KJS::HTMLElement::info, &HTMLTextAreaElementTable, 0 };
-const ClassInfo KJS::HTMLElement::title_info = { "HTMLTitleElement", &KJS::HTMLElement::info, &HTMLTitleElementTable, 0 };
-const ClassInfo KJS::HTMLElement::tr_info = { "HTMLTableRowElement", &KJS::HTMLElement::info, &HTMLTableRowElementTable, 0 };
-const ClassInfo KJS::HTMLElement::ul_info = { "HTMLUListElement", &KJS::HTMLElement::info, &HTMLUListElementTable, 0 };
-
-const ClassInfo* KJS::HTMLElement::classInfo() const
+const ClassInfo HTMLElement::a_info = { "HTMLAnchorElement", &HTMLElement::info, &HTMLAnchorElementTable, 0 };
+const ClassInfo HTMLElement::applet_info = { "HTMLAppletElement", &HTMLElement::info, &HTMLAppletElementTable, 0 };
+const ClassInfo HTMLElement::area_info = { "HTMLAreaElement", &HTMLElement::info, &HTMLAreaElementTable, 0 };
+const ClassInfo HTMLElement::baseFont_info = { "HTMLBaseFontElement", &HTMLElement::info, &HTMLBaseFontElementTable, 0 };
+const ClassInfo HTMLElement::base_info = { "HTMLBaseElement", &HTMLElement::info, &HTMLBaseElementTable, 0 };
+const ClassInfo HTMLElement::blockQuote_info = { "HTMLBlockQuoteElement", &HTMLElement::info, &HTMLBlockQuoteElementTable, 0 };
+const ClassInfo HTMLElement::body_info = { "HTMLBodyElement", &HTMLElement::info, &HTMLBodyElementTable, 0 };
+const ClassInfo HTMLElement::br_info = { "HTMLBRElement", &HTMLElement::info, &HTMLBRElementTable, 0 };
+const ClassInfo HTMLElement::button_info = { "HTMLButtonElement", &HTMLElement::info, &HTMLButtonElementTable, 0 };
+const ClassInfo HTMLElement::canvas_info = { "HTMLCanvasElement", &HTMLElement::info, &HTMLCanvasElementTable, 0 };
+const ClassInfo HTMLElement::caption_info = { "HTMLTableCaptionElement", &HTMLElement::info, &HTMLTableCaptionElementTable, 0 };
+const ClassInfo HTMLElement::col_info = { "HTMLTableColElement", &HTMLElement::info, &HTMLTableColElementTable, 0 };
+const ClassInfo HTMLElement::dir_info = { "HTMLDirectoryElement", &HTMLElement::info, &HTMLDirectoryElementTable, 0 };
+const ClassInfo HTMLElement::div_info = { "HTMLDivElement", &HTMLElement::info, &HTMLDivElementTable, 0 };
+const ClassInfo HTMLElement::dl_info = { "HTMLDListElement", &HTMLElement::info, &HTMLDListElementTable, 0 };
+const ClassInfo HTMLElement::fieldSet_info = { "HTMLFieldSetElement", &HTMLElement::info, &HTMLFieldSetElementTable, 0 };
+const ClassInfo HTMLElement::font_info = { "HTMLFontElement", &HTMLElement::info, &HTMLFontElementTable, 0 };
+const ClassInfo HTMLElement::form_info = { "HTMLFormElement", &HTMLElement::info, &HTMLFormElementTable, 0 };
+const ClassInfo HTMLElement::frameSet_info = { "HTMLFrameSetElement", &HTMLElement::info, &HTMLFrameSetElementTable, 0 };
+const ClassInfo HTMLElement::frame_info = { "HTMLFrameElement", &HTMLElement::info, &HTMLFrameElementTable, 0 };
+const ClassInfo HTMLElement::head_info = { "HTMLHeadElement", &HTMLElement::info, &HTMLHeadElementTable, 0 };
+const ClassInfo HTMLElement::heading_info = { "HTMLHeadingElement", &HTMLElement::info, &HTMLHeadingElementTable, 0 };
+const ClassInfo HTMLElement::hr_info = { "HTMLHRElement", &HTMLElement::info, &HTMLHRElementTable, 0 };
+const ClassInfo HTMLElement::html_info = { "HTMLHtmlElement", &HTMLElement::info, &HTMLHtmlElementTable, 0 };
+const ClassInfo HTMLElement::iFrame_info = { "HTMLIFrameElement", &HTMLElement::info, &HTMLIFrameElementTable, 0 };
+const ClassInfo HTMLElement::img_info = { "HTMLImageElement", &HTMLElement::info, &HTMLImageElementTable, 0 };
+const ClassInfo HTMLElement::info = { "HTMLElement", &JSElement::info, &HTMLElementTable, 0 };
+const ClassInfo HTMLElement::input_info = { "HTMLInputElement", &HTMLElement::info, &HTMLInputElementTable, 0 };
+const ClassInfo HTMLElement::isIndex_info = { "HTMLIsIndexElement", &HTMLElement::info, &HTMLIsIndexElementTable, 0 };
+const ClassInfo HTMLElement::label_info = { "HTMLLabelElement", &HTMLElement::info, &HTMLLabelElementTable, 0 };
+const ClassInfo HTMLElement::legend_info = { "HTMLLegendElement", &HTMLElement::info, &HTMLLegendElementTable, 0 };
+const ClassInfo HTMLElement::li_info = { "HTMLLIElement", &HTMLElement::info, &HTMLLIElementTable, 0 };
+const ClassInfo HTMLElement::link_info = { "HTMLLinkElement", &HTMLElement::info, &HTMLLinkElementTable, 0 };
+const ClassInfo HTMLElement::map_info = { "HTMLMapElement", &HTMLElement::info, &HTMLMapElementTable, 0 };
+const ClassInfo HTMLElement::marquee_info = { "HTMLMarqueeElement", &HTMLElement::info, &HTMLMarqueeElementTable, 0 };
+const ClassInfo HTMLElement::menu_info = { "HTMLMenuElement", &HTMLElement::info, &HTMLMenuElementTable, 0 };
+const ClassInfo HTMLElement::meta_info = { "HTMLMetaElement", &HTMLElement::info, &HTMLMetaElementTable, 0 };
+const ClassInfo HTMLElement::mod_info = { "HTMLModElement", &HTMLElement::info, &HTMLModElementTable, 0 };
+const ClassInfo HTMLElement::object_info = { "HTMLObjectElement", &HTMLElement::info, &HTMLObjectElementTable, 0 };
+const ClassInfo HTMLElement::ol_info = { "HTMLOListElement", &HTMLElement::info, &HTMLOListElementTable, 0 };
+const ClassInfo HTMLElement::optGroup_info = { "HTMLOptGroupElement", &HTMLElement::info, &HTMLOptGroupElementTable, 0 };
+const ClassInfo HTMLElement::option_info = { "HTMLOptionElement", &HTMLElement::info, &HTMLOptionElementTable, 0 };
+const ClassInfo HTMLElement::p_info = { "HTMLParagraphElement", &HTMLElement::info, &HTMLParagraphElementTable, 0 };
+const ClassInfo HTMLElement::param_info = { "HTMLParamElement", &HTMLElement::info, &HTMLParamElementTable, 0 };
+const ClassInfo HTMLElement::pre_info = { "HTMLPreElement", &HTMLElement::info, &HTMLPreElementTable, 0 };
+const ClassInfo HTMLElement::q_info = { "HTMLQuoteElement", &HTMLElement::info, &HTMLQuoteElementTable, 0 };
+const ClassInfo HTMLElement::script_info = { "HTMLScriptElement", &HTMLElement::info, &HTMLScriptElementTable, 0 };
+const ClassInfo HTMLElement::select_info = { "HTMLSelectElement", &HTMLElement::info, &HTMLSelectElementTable, 0 };
+const ClassInfo HTMLElement::style_info = { "HTMLStyleElement", &HTMLElement::info, &HTMLStyleElementTable, 0 };
+const ClassInfo HTMLElement::table_info = { "HTMLTableElement", &HTMLElement::info, &HTMLTableElementTable, 0 };
+const ClassInfo HTMLElement::tablecell_info = { "HTMLTableCellElement", &HTMLElement::info, &HTMLTableCellElementTable, 0 };
+const ClassInfo HTMLElement::tablesection_info = { "HTMLTableSectionElement", &HTMLElement::info, &HTMLTableSectionElementTable, 0 };
+const ClassInfo HTMLElement::textArea_info = { "HTMLTextAreaElement", &HTMLElement::info, &HTMLTextAreaElementTable, 0 };
+const ClassInfo HTMLElement::title_info = { "HTMLTitleElement", &HTMLElement::info, &HTMLTitleElementTable, 0 };
+const ClassInfo HTMLElement::tr_info = { "HTMLTableRowElement", &HTMLElement::info, &HTMLTableRowElementTable, 0 };
+const ClassInfo HTMLElement::ul_info = { "HTMLUListElement", &HTMLElement::info, &HTMLUListElementTable, 0 };
+
+const ClassInfo* HTMLElement::classInfo() const
 {
     static HashMap<DOM::AtomicStringImpl*, const ClassInfo*> classInfoMap;
     if (classInfoMap.isEmpty()) {
@@ -1195,7 +1185,7 @@ JSValue *HTMLElement::formIndexGetter(ExecState *exec, JSObject *originalObject,
     HTMLElement *thisObj = static_cast<HTMLElement *>(slot.slotBase());
     HTMLFormElementImpl *form = static_cast<HTMLFormElementImpl *>(thisObj->impl());
 
-    return getDOMNode(exec, form->elements()->item(slot.index()));
+    return toJS(exec, form->elements()->item(slot.index()));
 }
 
 JSValue *HTMLElement::formNameGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
@@ -1211,7 +1201,7 @@ JSValue *HTMLElement::selectIndexGetter(ExecState *exec, JSObject *originalObjec
     HTMLElement *thisObj = static_cast<HTMLElement *>(slot.slotBase());
     HTMLSelectElementImpl *select = static_cast<HTMLSelectElementImpl *>(thisObj->impl());
 
-    return getDOMNode(exec, select->options()->item(slot.index()));
+    return toJS(exec, select->options()->item(slot.index()));
 }
 
 JSValue *HTMLElement::framesetNameGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
@@ -1325,7 +1315,7 @@ bool HTMLElement::getOwnPropertySlot(ExecState *exec, const Identifier& property
     return getStaticPropertySlot<HTMLElementFunction, HTMLElement, JSElement>(exec, &HTMLElementTable, this, propertyName, slot);
 }
 
-bool KJS::HTMLElement::implementsCall() const
+bool HTMLElement::implementsCall() const
 {
     HTMLElementImpl *element = static_cast<HTMLElementImpl *>(impl());
     if (element->hasTagName(embedTag) || element->hasTagName(objectTag) || element->hasTagName(appletTag)) {
@@ -1338,7 +1328,7 @@ bool KJS::HTMLElement::implementsCall() const
     return false;
 }
 
-JSValue *KJS::HTMLElement::callAsFunction(ExecState *exec, JSObject *thisObj, const List&args)
+JSValue *HTMLElement::callAsFunction(ExecState *exec, JSObject *thisObj, const List&args)
 {
     HTMLElementImpl *element = static_cast<HTMLElementImpl *>(impl());
     if (element->hasTagName(embedTag) || element->hasTagName(objectTag) || element->hasTagName(appletTag)) {
@@ -1387,7 +1377,7 @@ JSValue *HTMLElement::linkGetter(ExecState* exec, int token) const
         case LinkType:            
             return jsString(link.type());
         case LinkSheet:           
-            return getDOMStyleSheet(exec, link.sheet());
+            return toJS(exec, link.sheet());
     }
     return jsUndefined();
 }
@@ -1426,7 +1416,7 @@ JSValue *HTMLElement::isIndexGetter(ExecState* exec, int token) const
 {
     HTMLIsIndexElementImpl& isindex = *static_cast<HTMLIsIndexElementImpl*>(impl());
     switch (token) {
-        case IsIndexForm:            return getDOMNode(exec, isindex.form()); // type HTMLFormElement
+        case IsIndexForm:            return toJS(exec, isindex.form()); // type HTMLFormElement
         case IsIndexPrompt:          return jsString(isindex.prompt());
     }
     return jsUndefined();
@@ -1439,7 +1429,7 @@ JSValue *HTMLElement::styleGetter(ExecState* exec, int token) const
         case StyleDisabled:        return jsBoolean(style.disabled());
         case StyleMedia:           return jsString(style.media());
         case StyleType:            return jsString(style.type());
-        case StyleSheet:           return getDOMStyleSheet(exec, style.sheet());
+        case StyleSheet:           return toJS(exec, style.sheet());
     }
     return jsUndefined();
 }
@@ -1499,7 +1489,7 @@ JSValue *HTMLElement::selectGetter(ExecState* exec, int token) const
         case SelectSelectedIndex:   return jsNumber(select.selectedIndex());
         case SelectValue:           return jsString(select.value());
         case SelectLength:          return jsNumber(select.length());
-        case SelectForm:            return getDOMNode(exec, select.form()); // type HTMLFormElement
+        case SelectForm:            return toJS(exec, select.form()); // type HTMLFormElement
         case SelectOptions:         return getSelectHTMLCollection(exec, select.options().get(), &select); // type HTMLCollection
         case SelectDisabled:        return jsBoolean(select.disabled());
         case SelectMultiple:        return jsBoolean(select.multiple());
@@ -1524,7 +1514,7 @@ JSValue *HTMLElement::optionGetter(ExecState* exec, int token) const
 {
     HTMLOptionElementImpl& option = *static_cast<HTMLOptionElementImpl*>(impl());
     switch (token) {
-        case OptionForm:            return getDOMNode(exec,option.form()); // type HTMLFormElement
+        case OptionForm:            return toJS(exec,option.form()); // type HTMLFormElement
         case OptionDefaultSelected: return jsBoolean(option.defaultSelected());
         case OptionText:            return jsString(option.text());
         case OptionIndex:           return jsNumber(option.index());
@@ -1556,7 +1546,7 @@ JSValue *HTMLElement::inputGetter(ExecState* exec, int token) const
     switch (token) {
         case InputDefaultValue:    return jsString(input.defaultValue());
         case InputDefaultChecked:  return jsBoolean(input.defaultChecked());
-        case InputForm:            return getDOMNode(exec,input.form()); // type HTMLFormElement
+        case InputForm:            return toJS(exec,input.form()); // type HTMLFormElement
         case InputAccept:          return jsString(input.accept());
         case InputAccessKey:       return jsString(input.accessKey());
         case InputAlign:           return jsString(input.align());
@@ -1584,7 +1574,7 @@ JSValue *HTMLElement::textAreaGetter(ExecState* exec, int token) const
     HTMLTextAreaElementImpl& textarea = *static_cast<HTMLTextAreaElementImpl*>(impl());
     switch (token) {
         case TextAreaDefaultValue:    return jsString(textarea.defaultValue());
-        case TextAreaForm:            return getDOMNode(exec,textarea.form()); // type HTMLFormElement
+        case TextAreaForm:            return toJS(exec,textarea.form()); // type HTMLFormElement
         case TextAreaAccessKey:       return jsString(textarea.accessKey());
         case TextAreaCols:            return jsNumber(textarea.cols());
         case TextAreaDisabled:        return jsBoolean(textarea.disabled());
@@ -1604,7 +1594,7 @@ JSValue *HTMLElement::buttonGetter(ExecState* exec, int token) const
 {
     HTMLButtonElementImpl& button = *static_cast<HTMLButtonElementImpl*>(impl());
     switch (token) {
-        case ButtonForm:            return getDOMNode(exec,button.form()); // type HTMLFormElement
+        case ButtonForm:            return toJS(exec,button.form()); // type HTMLFormElement
         case ButtonAccessKey:       return jsString(button.accessKey());
         case ButtonDisabled:        return jsBoolean(button.disabled());
         case ButtonName:            return jsString(button.name());
@@ -1619,7 +1609,7 @@ JSValue *HTMLElement::labelGetter(ExecState* exec, int token) const
 {
     HTMLLabelElementImpl& label = *static_cast<HTMLLabelElementImpl*>(impl());
     switch (token) {
-        case LabelForm:            return getDOMNode(exec,label.form()); // type HTMLFormElement
+        case LabelForm:            return toJS(exec,label.form()); // type HTMLFormElement
         case LabelAccessKey:       return jsString(label.accessKey());
         case LabelHtmlFor:         return jsString(label.htmlFor());
     }
@@ -1630,7 +1620,7 @@ JSValue *HTMLElement::fieldSetGetter(ExecState* exec, int token) const
 {
     HTMLFieldSetElementImpl& fieldSet = *static_cast<HTMLFieldSetElementImpl*>(impl());
     if (token == FieldSetForm)
-        return getDOMNode(exec,fieldSet.form()); // type HTMLFormElement
+        return toJS(exec,fieldSet.form()); // type HTMLFormElement
     return jsUndefined();
 }
 
@@ -1638,7 +1628,7 @@ JSValue *HTMLElement::legendGetter(ExecState* exec, int token) const
 {
     HTMLLegendElementImpl& legend = *static_cast<HTMLLegendElementImpl*>(impl());
     switch (token) {
-        case LegendForm:            return getDOMNode(exec,legend.form()); // type HTMLFormElement
+        case LegendForm:            return toJS(exec,legend.form()); // type HTMLFormElement
         case LegendAccessKey:       return jsString(legend.accessKey());
         case LegendAlign:           return jsString(legend.align());
     }
@@ -1867,7 +1857,7 @@ JSValue *HTMLElement::objectGetter(ExecState* exec, int token) const
 {
     HTMLObjectElementImpl& object = *static_cast<HTMLObjectElementImpl*>(impl());
     switch (token) {
-        case ObjectForm:            return getDOMNode(exec,object.form()); // type HTMLFormElement
+        case ObjectForm:            return toJS(exec,object.form()); // type HTMLFormElement
         case ObjectCode:            return jsString(object.code());
         case ObjectAlign:           return jsString(object.align());
         case ObjectArchive:         return jsString(object.archive());
@@ -1875,7 +1865,7 @@ JSValue *HTMLElement::objectGetter(ExecState* exec, int token) const
         case ObjectCodeBase:        return jsString(object.codeBase());
         case ObjectCodeType:        return jsString(object.codeType());
         case ObjectContentDocument: return checkNodeSecurity(exec,object.contentDocument()) ? 
-                                           getDOMNode(exec, object.contentDocument()) : jsUndefined();
+                                           toJS(exec, object.contentDocument()) : jsUndefined();
         case ObjectData:            return jsString(object.data());
         case ObjectDeclare:         return jsBoolean(object.declare());
         case ObjectHeight:          return jsString(object.height());
@@ -1980,9 +1970,9 @@ JSValue *HTMLElement::tableGetter(ExecState* exec, int token) const
 {
     HTMLTableElementImpl& table = *static_cast<HTMLTableElementImpl*>(impl());
     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 TableCaption:         return toJS(exec,table.caption()); // type HTMLTableCaptionElement
+        case TableTHead:           return toJS(exec,table.tHead()); // type HTMLTableSectionElement
+        case TableTFoot:           return toJS(exec,table.tFoot()); // type HTMLTableSectionElement
         case TableRows:            return getHTMLCollection(exec, table.rows().get()); // type HTMLCollection
         case TableTBodies:         return getHTMLCollection(exec, table.tBodies().get()); // type HTMLCollection
         case TableAlign:           return jsString(table.align());
@@ -2087,7 +2077,7 @@ JSValue *HTMLElement::frameGetter(ExecState* exec, int token) const
     HTMLFrameElementImpl& frameElement = *static_cast<HTMLFrameElementImpl*>(impl());
     switch (token) {
         case FrameContentDocument: return checkNodeSecurity(exec,frameElement.contentDocument()) ? 
-                                          getDOMNode(exec, frameElement.contentDocument()) : jsUndefined();
+                                          toJS(exec, frameElement.contentDocument()) : jsUndefined();
         case FrameContentWindow:   return checkNodeSecurity(exec,frameElement.contentDocument())
                                         ? Window::retrieve(frameElement.contentFrame())
                                         : jsUndefined();
@@ -2114,7 +2104,7 @@ JSValue *HTMLElement::iFrameGetter(ExecState* exec, int token) const
           // ### security check ?
         case IFrameDocument: // non-standard, mapped to contentDocument
         case IFrameContentDocument: return checkNodeSecurity(exec,iFrame.contentDocument()) ? 
-                                      getDOMNode(exec, iFrame.contentDocument()) : jsUndefined();
+                                      toJS(exec, iFrame.contentDocument()) : jsUndefined();
         case IFrameContentWindow:   return checkNodeSecurity(exec,iFrame.contentDocument()) 
                                         ? Window::retrieve(iFrame.contentFrame())
                                         : jsUndefined();
@@ -2165,7 +2155,7 @@ JSValue *HTMLElement::getValueProperty(ExecState *exec, int token) const
         case ElementOuterText:
             return jsString(element.outerText());
         case ElementDocument:
-            return getDOMNode(exec,element.ownerDocument());
+            return toJS(exec,element.ownerDocument());
         case ElementChildren:
             return getHTMLCollection(exec, element.children().get());
         case ElementContentEditable:
@@ -2181,7 +2171,7 @@ JSValue *HTMLElement::getValueProperty(ExecState *exec, int token) const
     return jsUndefined();
 }
 
-UString KJS::HTMLElement::toString(ExecState *exec) const
+UString HTMLElement::toString(ExecState *exec) const
 {
     if (impl()->hasTagName(aTag))
         return UString(static_cast<const HTMLAnchorElementImpl *>(impl())->href());
@@ -2201,12 +2191,12 @@ static HTMLFormElementImpl *getForm(HTMLElementImpl *element)
     return 0;
 }
 
-void KJS::HTMLElement::pushEventHandlerScope(ExecState *exec, ScopeChain &scope) const
+void HTMLElement::pushEventHandlerScope(ExecState *exec, ScopeChain &scope) const
 {
   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<JSObject *>(getDOMNode(exec, element->ownerDocument())));
+  scope.push(static_cast<JSObject *>(toJS(exec, element->ownerDocument())));
 
   // The form is next, searched before the document, but after the element itself.
   
@@ -2215,18 +2205,18 @@ void KJS::HTMLElement::pushEventHandlerScope(ExecState *exec, ScopeChain &scope)
   // <table> or <tbody>.
   HTMLFormElementImpl *form = getForm(element);
   if (form)
-    scope.push(static_cast<JSObject *>(getDOMNode(exec, form)));
+    scope.push(static_cast<JSObject *>(toJS(exec, form)));
   else {
     NodeImpl *form = element->parentNode();
     while (form && !form->hasTagName(formTag))
       form = form->parentNode();
     
     if (form)
-      scope.push(static_cast<JSObject *>(getDOMNode(exec, form)));
+      scope.push(static_cast<JSObject *>(toJS(exec, form)));
   }
   
   // The element is on top, searched first.
-  scope.push(static_cast<JSObject *>(getDOMNode(exec, element)));
+  scope.push(static_cast<JSObject *>(toJS(exec, element)));
 }
 
 HTMLElementFunction::HTMLElementFunction(ExecState *exec, int i, int len, const Identifier& name)
@@ -2236,146 +2226,151 @@ HTMLElementFunction::HTMLElementFunction(ExecState *exec, int i, int len, const
   put(exec,lengthPropertyName,jsNumber(len),DontDelete|ReadOnly|DontEnum);
 }
 
-JSValue *KJS::HTMLElementFunction::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
+static JSValue* toJS(ExecState* exec, CanvasRenderingContext2D* context)
+{
+    return cacheDOMObject<CanvasRenderingContext2D, JSCanvasRenderingContext2D>(exec, context);
+}
+
+JSValue *HTMLElementFunction::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
 {
-    if (!thisObj->inherits(&KJS::HTMLElement::info))
+    if (!thisObj->inherits(&HTMLElement::info))
         return throwError(exec, TypeError);
     DOMExceptionTranslator exception(exec);
     HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(static_cast<HTMLElement *>(thisObj)->impl());
 
     if (element.hasLocalName(formTag)) {
         HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element);
-        if (id == KJS::HTMLElement::FormSubmit) {
+        if (id == HTMLElement::FormSubmit) {
             form.submit();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::FormReset) {
+        else if (id == HTMLElement::FormReset) {
             form.reset();
             return jsUndefined();
         }
     }
     else if (element.hasLocalName(selectTag)) {
         HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element);
-        if (id == KJS::HTMLElement::SelectAdd) {
+        if (id == HTMLElement::SelectAdd) {
             select.add(toHTMLElement(args[0]), toHTMLElement(args[1]), exception);
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::SelectRemove) {
+        else if (id == HTMLElement::SelectRemove) {
             select.remove(int(args[0]->toNumber(exec)));
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::SelectBlur) {
+        else if (id == HTMLElement::SelectBlur) {
             select.blur();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::SelectFocus) {
+        else if (id == HTMLElement::SelectFocus) {
             select.focus();
             return jsUndefined();
         }
     }
     else if (element.hasLocalName(inputTag)) {
         HTMLInputElementImpl &input = static_cast<HTMLInputElementImpl &>(element);
-        if (id == KJS::HTMLElement::InputBlur) {
+        if (id == HTMLElement::InputBlur) {
             input.blur();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::InputFocus) {
+        else if (id == HTMLElement::InputFocus) {
             input.focus();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::InputSelect) {
+        else if (id == HTMLElement::InputSelect) {
             input.select();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::InputClick) {
+        else if (id == HTMLElement::InputClick) {
             input.click();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::InputSetSelectionRange) {
+        else if (id == HTMLElement::InputSetSelectionRange) {
             input.setSelectionRange(args[0]->toInt32(exec), args[1]->toInt32(exec));
             return jsUndefined();
         }
     }
     else if (element.hasLocalName(buttonTag)) {
         HTMLButtonElementImpl &button = static_cast<HTMLButtonElementImpl &>(element);
-        if (id == KJS::HTMLElement::ButtonBlur) {
+        if (id == HTMLElement::ButtonBlur) {
             button.blur();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::ButtonFocus) {
+        else if (id == HTMLElement::ButtonFocus) {
             button.focus();
             return jsUndefined();
         }
     }
     else if (element.hasLocalName(labelTag)) {
         HTMLLabelElementImpl &label = static_cast<HTMLLabelElementImpl &>(element);
-        if (id == KJS::HTMLElement::LabelFocus) {
+        if (id == HTMLElement::LabelFocus) {
             label.focus();
             return jsUndefined();
         }
     }
     else if (element.hasLocalName(legendTag)) {
         HTMLLegendElementImpl &legend = static_cast<HTMLLegendElementImpl &>(element);
-        if (id == KJS::HTMLElement::LegendFocus) {
+        if (id == HTMLElement::LegendFocus) {
             legend.focus();
             return jsUndefined();
         }
     }
     else if (element.hasLocalName(textareaTag)) {
         HTMLTextAreaElementImpl &textarea = static_cast<HTMLTextAreaElementImpl &>(element);
-        if (id == KJS::HTMLElement::TextAreaBlur) {
+        if (id == HTMLElement::TextAreaBlur) {
             textarea.blur();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::TextAreaFocus) {
+        else if (id == HTMLElement::TextAreaFocus) {
             textarea.focus();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::TextAreaSelect) {
+        else if (id == HTMLElement::TextAreaSelect) {
             textarea.select();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::TextAreaSetSelectionRange) {
+        else if (id == HTMLElement::TextAreaSetSelectionRange) {
             textarea.setSelectionRange(args[0]->toInt32(exec), args[1]->toInt32(exec));
             return jsUndefined();
         }
     }
     else if (element.hasLocalName(aTag)) {
         HTMLAnchorElementImpl &anchor = static_cast<HTMLAnchorElementImpl &>(element);
-        if (id == KJS::HTMLElement::AnchorBlur) {
+        if (id == HTMLElement::AnchorBlur) {
             anchor.blur();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::AnchorFocus) {
+        else if (id == HTMLElement::AnchorFocus) {
             anchor.focus();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::AnchorToString)
+        else if (id == HTMLElement::AnchorToString)
             return jsString(thisObj->toString(exec));
     }
     else if (element.hasLocalName(tableTag)) {
         HTMLTableElementImpl &table = static_cast<HTMLTableElementImpl &>(element);
-        if (id == KJS::HTMLElement::TableCreateTHead)
-            return getDOMNode(exec,table.createTHead());
-        else if (id == KJS::HTMLElement::TableDeleteTHead) {
+        if (id == HTMLElement::TableCreateTHead)
+            return toJS(exec,table.createTHead());
+        else if (id == HTMLElement::TableDeleteTHead) {
             table.deleteTHead();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::TableCreateTFoot)
-            return getDOMNode(exec,table.createTFoot());
-        else if (id == KJS::HTMLElement::TableDeleteTFoot) {
+        else if (id == HTMLElement::TableCreateTFoot)
+            return toJS(exec,table.createTFoot());
+        else if (id == HTMLElement::TableDeleteTFoot) {
             table.deleteTFoot();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::TableCreateCaption)
-            return getDOMNode(exec,table.createCaption());
-        else if (id == KJS::HTMLElement::TableDeleteCaption) {
+        else if (id == HTMLElement::TableCreateCaption)
+            return toJS(exec,table.createCaption());
+        else if (id == HTMLElement::TableDeleteCaption) {
             table.deleteCaption();
             return jsUndefined();
         }
-        else if (id == KJS::HTMLElement::TableInsertRow)
-            return getDOMNode(exec,table.insertRow(args[0]->toInt32(exec), exception));
-        else if (id == KJS::HTMLElement::TableDeleteRow) {
+        else if (id == HTMLElement::TableInsertRow)
+            return toJS(exec,table.insertRow(args[0]->toInt32(exec), exception));
+        else if (id == HTMLElement::TableDeleteRow) {
             table.deleteRow(args[0]->toInt32(exec), exception);
             return jsUndefined();
         }
@@ -2384,30 +2379,30 @@ JSValue *KJS::HTMLElementFunction::callAsFunction(ExecState *exec, JSObject *thi
              element.hasLocalName(tbodyTag) ||
              element.hasLocalName(tfootTag)) {
         HTMLTableSectionElementImpl &tableSection = static_cast<HTMLTableSectionElementImpl &>(element);
-        if (id == KJS::HTMLElement::TableSectionInsertRow)
-            return getDOMNode(exec, tableSection.insertRow(args[0]->toInt32(exec), exception));
-        else if (id == KJS::HTMLElement::TableSectionDeleteRow) {
+        if (id == HTMLElement::TableSectionInsertRow)
+            return toJS(exec, tableSection.insertRow(args[0]->toInt32(exec), exception));
+        else if (id == HTMLElement::TableSectionDeleteRow) {
             tableSection.deleteRow(args[0]->toInt32(exec), exception);
             return jsUndefined();
         }
     }
     else if (element.hasLocalName(trTag)) {
         HTMLTableRowElementImpl &tableRow = static_cast<HTMLTableRowElementImpl &>(element);
-        if (id == KJS::HTMLElement::TableRowInsertCell)
-            return getDOMNode(exec,tableRow.insertCell(args[0]->toInt32(exec), exception));
-        else if (id == KJS::HTMLElement::TableRowDeleteCell) {
+        if (id == HTMLElement::TableRowInsertCell)
+            return toJS(exec,tableRow.insertCell(args[0]->toInt32(exec), exception));
+        else if (id == HTMLElement::TableRowDeleteCell) {
             tableRow.deleteCell(args[0]->toInt32(exec), exception);
             return jsUndefined();
         }
     }
     else if (element.hasLocalName(marqueeTag)) {
-        if (id == KJS::HTMLElement::MarqueeStart && element.renderer() && 
+        if (id == HTMLElement::MarqueeStart && element.renderer() && 
             element.renderer()->layer() &&
             element.renderer()->layer()->marquee()) {
             element.renderer()->layer()->marquee()->start();
             return jsUndefined();
         }
-        if (id == KJS::HTMLElement::MarqueeStop && element.renderer() && 
+        if (id == HTMLElement::MarqueeStop && element.renderer() && 
             element.renderer()->layer() &&
             element.renderer()->layer()->marquee()) {
             element.renderer()->layer()->marquee()->stop();
@@ -2415,18 +2410,14 @@ JSValue *KJS::HTMLElementFunction::callAsFunction(ExecState *exec, JSObject *thi
         }
     }
     else if (element.hasLocalName(canvasTag)) {
-        if (id == KJS::HTMLElement::GetContext) {
-            if (args.size() == 0 || (args.size() == 1 && args[0]->toString(exec).domString().lower() == "2d")) {
-                return new Context2D(&element);
-            }
-            return jsUndefined();
-        }
+        if (id == HTMLElement::GetContext)
+            return toJS(exec, static_cast<HTMLCanvasElementImpl*>(&element)->getContext(args[0]->toString(exec).domString()));
     }
 
     return jsUndefined();
 }
 
-void KJS::HTMLElement::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
+void HTMLElement::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
 {
     HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl());
     // First look at dynamic properties
@@ -2461,7 +2452,7 @@ void KJS::HTMLElement::put(ExecState *exec, const Identifier &propertyName, JSVa
         }
     }
 
-    lookupPut<KJS::HTMLElement, JSElement>(exec, propertyName, value, attr, &HTMLElementTable, this);
+    lookupPut<HTMLElement, JSElement>(exec, propertyName, value, attr, &HTMLElementTable, this);
 }
 
 void HTMLElement::htmlSetter(ExecState *exec, int token, JSValue *value, const DOM::DOMString& str)
@@ -3225,7 +3216,7 @@ JSValue *HTMLCollection::lengthGetter(ExecState *exec, JSObject *originalObject,
 JSValue *HTMLCollection::indexGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 {
     HTMLCollection *thisObj = static_cast<HTMLCollection *>(slot.slotBase());
-    return getDOMNode(exec, thisObj->m_impl->item(slot.index()));
+    return toJS(exec, thisObj->m_impl->item(slot.index()));
 }
 
 JSValue *HTMLCollection::nameGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
@@ -3264,7 +3255,7 @@ bool HTMLCollection::getOwnPropertySlot(ExecState *exec, const Identifier& prope
 
 // HTMLCollections are strange objects, they support both get and call,
 // so that document.forms.item(0) and document.forms(0) both work.
-JSValue *KJS::HTMLCollection::callAsFunction(ExecState *exec, JSObject *, const List &args)
+JSValue *HTMLCollection::callAsFunction(ExecState *exec, JSObject *, const List &args)
 {
   // Do not use thisObj here. It can be the HTMLDocument, in the document.forms(i) case.
   HTMLCollectionImpl &collection = *m_impl;
@@ -3277,7 +3268,7 @@ JSValue *KJS::HTMLCollection::callAsFunction(ExecState *exec, JSObject *, const
     UString s = args[0]->toString(exec);
     unsigned int u = s.toUInt32(&ok);
     if (ok)
-      return getDOMNode(exec, collection.item(u));
+      return toJS(exec, collection.item(u));
     // support for document.images('<name>') etc.
     return getNamedItems(exec, Identifier(s));
   }
@@ -3292,7 +3283,7 @@ JSValue *KJS::HTMLCollection::callAsFunction(ExecState *exec, JSObject *, const
       NodeImpl *node = collection.namedItem(pstr);
       while (node) {
         if (!u)
-          return getDOMNode(exec,node);
+          return toJS(exec,node);
         node = collection.nextNamedItem(pstr);
         --u;
       }
@@ -3301,7 +3292,7 @@ JSValue *KJS::HTMLCollection::callAsFunction(ExecState *exec, JSObject *, const
   return jsUndefined();
 }
 
-JSValue *KJS::HTMLCollection::getNamedItems(ExecState *exec, const Identifier &propertyName) const
+JSValue *HTMLCollection::getNamedItems(ExecState *exec, const Identifier &propertyName) const
 {
     QValueList< RefPtr<NodeImpl> > namedItems = m_impl->namedItems(AtomicString(propertyName.domString()));
 
@@ -3309,23 +3300,23 @@ JSValue *KJS::HTMLCollection::getNamedItems(ExecState *exec, const Identifier &p
         return jsUndefined();
 
     if (namedItems.count() == 1)
-        return getDOMNode(exec, namedItems[0].get());
+        return toJS(exec, namedItems[0].get());
 
     return new DOMNamedNodesCollection(exec, namedItems);
 }
 
-JSValue *KJS::HTMLCollectionProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
+JSValue *HTMLCollectionProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
 {
-  if (!thisObj->inherits(&KJS::HTMLCollection::info))
+  if (!thisObj->inherits(&HTMLCollection::info))
     return throwError(exec, TypeError);
   HTMLCollectionImpl &coll = *static_cast<HTMLCollection *>(thisObj)->impl();
 
   switch (id) {
-  case KJS::HTMLCollection::Item:
-    return getDOMNode(exec,coll.item(args[0]->toUInt32(exec)));
-  case KJS::HTMLCollection::Tags:
-    return getDOMNodeList(exec, coll.base()->getElementsByTagName(args[0]->toString(exec).domString()).get());
-  case KJS::HTMLCollection::NamedItem:
+  case HTMLCollection::Item:
+    return toJS(exec,coll.item(args[0]->toUInt32(exec)));
+  case HTMLCollection::Tags:
+    return toJS(exec, coll.base()->getElementsByTagName(args[0]->toString(exec).domString()).get());
+  case HTMLCollection::NamedItem:
     return static_cast<HTMLCollection *>(thisObj)->getNamedItems(exec, Identifier(args[0]->toString(exec)));
   default:
     return jsUndefined();
@@ -3356,10 +3347,10 @@ bool HTMLSelectCollection::getOwnPropertySlot(ExecState *exec, const Identifier&
   return HTMLCollection::getOwnPropertySlot(exec, propertyName, slot);
 }
 
-void KJS::HTMLSelectCollection::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int)
+void HTMLSelectCollection::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int)
 {
 #ifdef KJS_VERBOSE
-  kdDebug(6070) << "KJS::HTMLSelectCollection::put " << propertyName.qstring() << endl;
+  kdDebug(6070) << "HTMLSelectCollection::put " << propertyName.qstring() << endl;
 #endif
   if ( propertyName == "selectedIndex" ) {
     m_element->setSelectedIndex( value->toInt32( exec ) );
@@ -3475,7 +3466,7 @@ JSObject *OptionConstructorImp::construct(ExecState *exec, const List &args)
   }
 
   setDOMException(exec, exception);
-  return static_cast<JSObject *>(getDOMNode(exec,opt));
+  return static_cast<JSObject *>(toJS(exec,opt));
 }
 
 ////////////////////// Image Object ////////////////////////
@@ -3512,1600 +3503,7 @@ JSObject *ImageConstructorImp::construct(ExecState * exec, const List & list)
     if (heightSet)
         result->setHeight(height);
     
-    return static_cast<JSObject*>(getDOMNode(exec, result));
-}
-
-////////////////////// Context2D Object ////////////////////////
-
-KJS_IMPLEMENT_PROTOFUNC(Context2DFunction)
-
-static bool isGradient(JSValue *value)
-{
-    return value->isObject(&Gradient::info);
-}
-
-static bool isImagePattern(JSValue *value)
-{
-    return value->isObject(&ImagePattern::info);
-}
-
-#define BITS_PER_COMPONENT 8
-#define BYTES_PER_ROW(width,bitsPerComponent,numComponents) ((width * bitsPerComponent * numComponents + 7)/8)
-
-JSValue *KJS::Context2DFunction::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
-{
-    if (!thisObj->inherits(&Context2D::info))
-        return throwError(exec, TypeError);
-
-#if __APPLE__
-    Context2D *contextObject = static_cast<KJS::Context2D *>(thisObj);
-    khtml::RenderCanvasImage *renderer = static_cast<khtml::RenderCanvasImage*>(contextObject->_element->renderer());
-    if (!renderer)
-        return jsUndefined();
-
-    CGContextRef drawingContext = renderer->drawingContext();
-    if (!drawingContext)
-        return jsUndefined();
-    
-    switch (id) {
-        case Context2D::Save: {
-            if (args.size() != 0)
-                return throwError(exec, SyntaxError);
-            CGContextSaveGState(drawingContext);
-            
-            contextObject->save();
-            
-            break;
-        }
-        case Context2D::Restore: {
-            if (args.size() != 0)
-                return throwError(exec, SyntaxError);
-            CGContextRestoreGState(drawingContext);
-            
-            contextObject->restore();
-            
-            break;
-        }
-        case Context2D::BeginPath: {
-            if (args.size() != 0)
-                return throwError(exec, SyntaxError);
-            CGContextBeginPath(drawingContext);
-            break;
-        }
-        case Context2D::ClosePath: {
-            if (args.size() != 0)
-                return throwError(exec, SyntaxError);
-            CGContextClosePath(drawingContext);
-            break;
-        }
-        case Context2D::SetStrokeColor: {
-            // string arg = named color
-            // string arg, number arg = named color, alpha
-            // number arg = gray color
-            // number arg, number arg = gray color, alpha
-            // 4 args (string or number) = r, g, b, a
-            // 5 args (string or number) = c, m, y, k, a
-            int numArgs = args.size();
-            switch (numArgs) {
-                case 1: {
-                    if (args[0]->isString()) {                    
-                        RGBA32 color = DOM::CSSParser::parseColor(args[0]->toString(exec).domString());
-                        Color qc(color);
-                        CGContextSetRGBStrokeColor(drawingContext, qc.red()/255., qc.green()/255., qc.blue()/255., qc.alpha()/255.);
-
-                    }
-                    else {
-                        float g = (float)args[0]->toNumber(exec);
-                        CGContextSetGrayStrokeColor(drawingContext, g, 1.);
-                    }
-                }
-                break;
-                case 2: {
-                    float a = args[1]->toNumber(exec);
-                    if (args[0]->isString()) {
-                        RGBA32 color = DOM::CSSParser::parseColor(args[0]->toString(exec).domString());
-                        Color qc(color);
-                        CGContextSetRGBStrokeColor(drawingContext, qc.red()/255., qc.green()/255., qc.blue()/255., a);
-                    }
-                    else {
-                        float g = (float)args[0]->toNumber(exec);
-                        CGContextSetGrayStrokeColor(drawingContext, g, a);
-                    }
-                }
-                break;
-                case 4: {
-                    float r = (float)args[0]->toNumber(exec);
-                    float g = (float)args[1]->toNumber(exec);
-                    float b = (float)args[2]->toNumber(exec);
-                    float a = (float)args[3]->toNumber(exec);
-                    CGContextSetRGBStrokeColor(drawingContext, r, g, b, a);
-                }
-                break;
-                case 5: {
-                    float c = (float)args[0]->toNumber(exec);
-                    float m = (float)args[1]->toNumber(exec);
-                    float y = (float)args[2]->toNumber(exec);
-                    float k = (float)args[3]->toNumber(exec);
-                    float a = (float)args[4]->toNumber(exec);
-                    CGContextSetCMYKStrokeColor(drawingContext, c, m, y, k, a);
-                }
-                break;
-                default:
-                    return throwError(exec, SyntaxError);
-            }
-            break;
-        }
-        case Context2D::SetFillColor: {
-            // string arg = named color
-            // string arg, number arg = named color, alpha
-            // number arg = gray color
-            // number arg, number arg = gray color, alpha
-            // 4 args (string or number) = r, g, b, a
-            // 5 args (string or number) = c, m, y, k, a
-            int numArgs = args.size();
-            switch (numArgs) {
-                case 1: {
-                    if (args[0]->isString()) {
-                        RGBA32 color = DOM::CSSParser::parseColor(args[0]->toString(exec).domString());
-                        Color qc(color);
-                        CGContextSetRGBFillColor(drawingContext, qc.red()/255., qc.green()/255., qc.blue()/255., qc.alpha()/255.);
-                    }
-                    else {
-                        float g = (float)args[0]->toNumber(exec);
-                        CGContextSetGrayFillColor(drawingContext, g, 1.);
-                    }
-                }
-                break;
-                case 2: {
-                    float a = args[1]->toNumber(exec);
-                    if (args[0]->isString()) {
-                        RGBA32 color = DOM::CSSParser::parseColor(args[0]->toString(exec).domString());
-                        Color qc(color);
-                        CGContextSetRGBFillColor(drawingContext, qc.red()/255., qc.green()/255., qc.blue()/255., a);
-                    }
-                    else {
-                        float g = (float)args[0]->toNumber(exec);
-                        CGContextSetGrayFillColor(drawingContext, g, a);
-                    }
-                }
-                break;
-                case 4: {
-                    float r = (float)args[0]->toNumber(exec);
-                    float g = (float)args[1]->toNumber(exec);
-                    float b = (float)args[2]->toNumber(exec);
-                    float a = (float)args[3]->toNumber(exec);
-                    CGContextSetRGBFillColor(drawingContext, r, g, b, a);
-                }
-                break;
-                case 5: {
-                    float c = (float)args[0]->toNumber(exec);
-                    float m = (float)args[1]->toNumber(exec);
-                    float y = (float)args[2]->toNumber(exec);
-                    float k = (float)args[3]->toNumber(exec);
-                    float a = (float)args[4]->toNumber(exec);
-                    CGContextSetCMYKStrokeColor(drawingContext, c, m, y, k, a);
-                }
-                break;
-                default:
-                    return throwError(exec, SyntaxError);
-            }
-            break;
-        }
-        case Context2D::SetLineWidth: {
-            if (args.size() != 1)
-                return throwError(exec, SyntaxError);
-            float w = (float)args[0]->toNumber(exec);
-            CGContextSetLineWidth (drawingContext, w);
-            break;
-        }
-        case Context2D::SetLineCap: {
-            if (args.size() != 1)
-                return throwError(exec, SyntaxError);
-            CGLineCap cap = kCGLineCapButt;
-            DOMString capString = args[0]->toString(exec).domString().lower();
-            if (capString == "round")
-                cap = kCGLineCapRound;
-            else if (capString == "square")
-                cap = kCGLineCapSquare;
-            CGContextSetLineCap (drawingContext, cap);
-            break;
-        }
-        case Context2D::SetLineJoin: {
-            if (args.size() != 1)
-                return throwError(exec, SyntaxError);
-            CGLineJoin join = kCGLineJoinMiter;
-            DOMString joinString = args[0]->toString(exec).domString().lower();
-            if (joinString == "round")
-                join = kCGLineJoinRound;
-            else if (joinString == "bevel")
-                join = kCGLineJoinBevel;
-            CGContextSetLineJoin (drawingContext, join);
-            break;
-        }
-        case Context2D::SetMiterLimit: {
-            if (args.size() != 1)
-                return throwError(exec, SyntaxError);
-            float l = (float)args[0]->toNumber(exec);
-            CGContextSetMiterLimit (drawingContext, l);
-            break;
-        }
-        case Context2D::Fill: {
-            if (args.size() != 0)
-                return throwError(exec, SyntaxError);
-            
-            if (isGradient(contextObject->_fillStyle)) {
-                CGContextSaveGState(drawingContext);
-                
-                // Set the clip from the current path because shading only
-                // operates on clippin regions!  Odd, but true.
-                CGContextClip(drawingContext);
-
-                JSObject *o = static_cast<JSObject*>(contextObject->_fillStyle);
-                Gradient *gradient = static_cast<Gradient*>(o);
-                CGShadingRef shading = gradient->getShading();
-                CGContextDrawShading(drawingContext, shading);
-                
-                CGContextRestoreGState(drawingContext);
-            } else if (isImagePattern(contextObject->_fillStyle)) {
-                contextObject->updateFillImagePattern();
-                CGContextFillPath(drawingContext);
-            }
-            else
-                CGContextFillPath(drawingContext);
-                
-            renderer->setNeedsImageUpdate();
-            break;
-        }
-        case Context2D::Stroke: {
-            if (args.size() != 0)
-                return throwError(exec, SyntaxError);
-            if (isGradient(contextObject->_strokeStyle)) {
-                CGContextSaveGState(drawingContext);
-                
-                // Convert the stroke normally performed on the path
-                // into a path.  Then set the clip from that path 
-                // because shading only operates on clipping regions!  Odd, 
-                // but true.
-                CGContextReplacePathWithStrokedPath(drawingContext);
-                CGContextClip(drawingContext);
-
-                JSObject *o = static_cast<JSObject*>(contextObject->_strokeStyle);
-                Gradient *gradient = static_cast<Gradient*>(o);
-                CGShadingRef shading = gradient->getShading();
-                CGContextDrawShading(drawingContext, shading);
-                
-                CGContextRestoreGState(drawingContext);
-            } else if (isImagePattern(contextObject->_strokeStyle)) {
-                contextObject->updateStrokeImagePattern();
-                CGContextFillPath(drawingContext);
-            }
-            else
-                CGContextStrokePath (drawingContext);
-            renderer->setNeedsImageUpdate();
-            break;
-        }
-        case Context2D::Scale: {
-            if (args.size() != 2)
-                return throwError(exec, SyntaxError);
-            float sx = (float)args[0]->toNumber(exec);
-            float sy = (float)args[1]->toNumber(exec);
-            CGContextScaleCTM (drawingContext, sx, sy);
-            break;
-        }
-        case Context2D::Rotate: {
-            if (args.size() != 1)
-                return throwError(exec, SyntaxError);
-            float angle = (float)args[0]->toNumber(exec);
-            CGContextRotateCTM (drawingContext, angle);
-            break;
-        }
-        case Context2D::Translate: {
-            if (args.size() != 2)
-                return throwError(exec, SyntaxError);
-            float tx = (float)args[0]->toNumber(exec);
-            float ty = (float)args[1]->toNumber(exec);
-            CGContextTranslateCTM (drawingContext, tx, ty);
-            break;
-        }
-        case Context2D::MoveTo: {
-            if (args.size() != 2)
-                return throwError(exec, SyntaxError);
-            float x = (float)args[0]->toNumber(exec);
-            float y = (float)args[1]->toNumber(exec);
-            CGContextMoveToPoint (drawingContext, x, y);
-            renderer->setNeedsImageUpdate();
-            break;
-        }
-        case Context2D::LineTo: {
-            if (args.size() != 2)
-                return throwError(exec, SyntaxError);
-            float x = (float)args[0]->toNumber(exec);
-            float y = (float)args[1]->toNumber(exec);
-            CGContextAddLineToPoint (drawingContext, x, y);
-            renderer->setNeedsImageUpdate();
-            break;
-        }
-        case Context2D::QuadraticCurveTo: {
-            if (args.size() != 4)
-                return throwError(exec, SyntaxError);
-            float cpx = (float)args[0]->toNumber(exec);
-            float cpy = (float)args[1]->toNumber(exec);
-            float x = (float)args[2]->toNumber(exec);
-            float y = (float)args[3]->toNumber(exec);
-            CGContextAddQuadCurveToPoint (drawingContext, cpx, cpy, x, y);
-            renderer->setNeedsImageUpdate();
-            break;
-        }
-        case Context2D::BezierCurveTo: {
-            if (args.size() != 6)
-                return throwError(exec, SyntaxError);
-            float cp1x = (float)args[0]->toNumber(exec);
-            float cp1y = (float)args[1]->toNumber(exec);
-            float cp2x = (float)args[2]->toNumber(exec);
-            float cp2y = (float)args[3]->toNumber(exec);
-            float x = (float)args[4]->toNumber(exec);
-            float y = (float)args[5]->toNumber(exec);
-            CGContextAddCurveToPoint (drawingContext, cp1x, cp1y, cp2x, cp2y, x, y);
-            renderer->setNeedsImageUpdate();
-            break;
-        }
-        case Context2D::ArcTo: {
-            if (args.size() != 5)
-                return throwError(exec, SyntaxError);
-            float x1 = (float)args[0]->toNumber(exec);
-            float y1 = (float)args[1]->toNumber(exec);
-            float x2 = (float)args[2]->toNumber(exec);
-            float y2 = (float)args[3]->toNumber(exec);
-            float r = (float)args[4]->toNumber(exec);
-            CGContextAddArcToPoint (drawingContext, x1, y1, x2, y2, r);
-            break;
-        }
-        case Context2D::Arc: {
-            if (args.size() != 6)
-                return throwError(exec, SyntaxError);
-            float x = (float)args[0]->toNumber(exec);
-            float y = (float)args[1]->toNumber(exec);
-            float r = (float)args[2]->toNumber(exec);
-            float sa = (float)args[3]->toNumber(exec);
-            float ea = (float)args[4]->toNumber(exec);
-            bool clockwise = args[5]->toBoolean(exec);
-            CGContextAddArc (drawingContext, x, y, r, sa, ea, clockwise);
-            break;
-        }
-        case Context2D::Rect: {
-            if (args.size() != 4)
-                return throwError(exec, SyntaxError);
-            float x = (float)args[0]->toNumber(exec);
-            float y = (float)args[1]->toNumber(exec);
-            float w = (float)args[2]->toNumber(exec);
-            float h = (float)args[3]->toNumber(exec);
-            CGContextAddRect (drawingContext, CGRectMake(x,y,w,h));
-            break;
-        }
-        case Context2D::Clip: {
-            if (args.size() != 0)
-                return throwError(exec, SyntaxError);
-            CGContextClip (drawingContext);
-            break;
-        }
-
-        case Context2D::ClearRect: {
-            if (args.size() != 4)
-                return throwError(exec, SyntaxError);
-            float x = (float)args[0]->toNumber(exec);
-            float y = (float)args[1]->toNumber(exec);
-            float w = (float)args[2]->toNumber(exec);
-            float h = (float)args[3]->toNumber(exec);
-            CGContextClearRect (drawingContext, CGRectMake(x,y,w,h));
-            renderer->setNeedsImageUpdate();
-            break;
-        }
-        case Context2D::FillRect: {
-            if (args.size() != 4)
-                return throwError(exec, SyntaxError);
-            float x = (float)args[0]->toNumber(exec);
-            float y = (float)args[1]->toNumber(exec);
-            float w = (float)args[2]->toNumber(exec);
-            float h = (float)args[3]->toNumber(exec);
-            
-            if (isGradient(contextObject->_fillStyle)) {
-                CGContextSaveGState(drawingContext);
-                
-                // Can't use a gradient fill with a FillRect, must use a path.
-                CGContextBeginPath(drawingContext);
-                CGContextAddRect(drawingContext, CGRectMake(x, y, w, h));
-
-                // Set the clip from the current path because shading only
-                // operates on clippin regions!  Odd, but true.
-                CGContextClip(drawingContext);
-
-                JSObject *o = static_cast<JSObject*>(contextObject->_fillStyle);
-                Gradient *gradient = static_cast<Gradient*>(o);
-                CGShadingRef shading = gradient->getShading();
-                CGContextDrawShading(drawingContext, shading);
-                
-                CGContextRestoreGState(drawingContext);
-            } else {
-                if (isImagePattern(contextObject->_fillStyle))
-                    contextObject->updateFillImagePattern();
-                CGContextFillRect(drawingContext, CGRectMake(x, y, w, h));
-            }
-            renderer->setNeedsImageUpdate();
-            break;
-        }
-        case Context2D::StrokeRect: {
-            int size = args.size();
-            if (size < 4)
-                return throwError(exec, SyntaxError);
-            float x = (float)args[0]->toNumber(exec);
-            float y = (float)args[1]->toNumber(exec);
-            float w = (float)args[2]->toNumber(exec);
-            float h = (float)args[3]->toNumber(exec);
-            
-            if (isImagePattern(contextObject->_strokeStyle))
-                contextObject->updateStrokeImagePattern();
-            if (size > 4)
-                CGContextStrokeRectWithWidth (drawingContext, CGRectMake(x,y,w,h), (float)args[4]->toNumber(exec));
-            else
-                CGContextStrokeRect (drawingContext, CGRectMake(x,y,w,h));
-            renderer->setNeedsImageUpdate();
-            break;
-        }
-        case Context2D::SetShadow: {
-            int numArgs = args.size();
-            
-            if (numArgs < 3)
-                return throwError(exec, SyntaxError);
-            CGSize offset;
-            
-            offset.width = (float)args[0]->toNumber(exec);
-            offset.height = (float)args[1]->toNumber(exec);
-            float blur = (float)args[2]->toNumber(exec);
-            
-            Color color = Color(args[3]->toString(exec).ascii());
-
-             if (numArgs == 3) {
-                CGContextSetShadow (drawingContext, offset, blur);
-            } else {
-                CGColorSpaceRef colorSpace;
-                float components[5];
-                
-                switch (numArgs - 3) {
-                    case 1: {
-                        if (args[3]->isString()) {
-                            RGBA32 color = DOM::CSSParser::parseColor(args[3]->toString(exec).domString());
-                            Color qc(color);
-                            components[0] = qc.red()/255.;
-                            components[1] = qc.green()/255.;
-                            components[2] = qc.blue()/255.;
-                            components[3] = 1.0f;
-                            colorSpace = CGColorSpaceCreateDeviceRGB();
-                        }
-                        else {
-                            components[0] = (float)args[3]->toNumber(exec);
-                            components[1] = 1.0f;
-                            colorSpace = CGColorSpaceCreateDeviceGray();
-                        }
-                    }
-                    break;
-                    case 2: {
-                        float a = args[4]->toNumber(exec);
-                        if (args[3]->isString()) {
-                            RGBA32 color = DOM::CSSParser::parseColor(args[3]->toString(exec).domString());
-                            Color qc(color);
-                            components[0] = qc.red()/255.;
-                            components[1] = qc.green()/255.;
-                            components[2] = qc.blue()/255.;
-                            components[3] = a;
-                            colorSpace = CGColorSpaceCreateDeviceRGB();
-                        }
-                        else {
-                            components[0] = (float)args[3]->toNumber(exec);
-                            components[1] = a;
-                            colorSpace = CGColorSpaceCreateDeviceGray();
-                        }
-                    }
-                    break;
-                    case 4: {
-                        components[0] = (float)args[3]->toNumber(exec); // r
-                        components[1] = (float)args[4]->toNumber(exec); // g
-                        components[2] = (float)args[5]->toNumber(exec); // b
-                        components[3] = (float)args[6]->toNumber(exec); // a
-                        colorSpace = CGColorSpaceCreateDeviceRGB();
-                    }
-                    break;
-                    case 5: {
-                        components[0] = (float)args[3]->toNumber(exec); // c
-                        components[1] = (float)args[4]->toNumber(exec); // m
-                        components[2] = (float)args[5]->toNumber(exec); // y
-                        components[3] = (float)args[6]->toNumber(exec); // k
-                        components[4] = (float)args[7]->toNumber(exec); // a
-
-                        colorSpace = CGColorSpaceCreateDeviceCMYK();
-                    }
-                    break;
-                    default:
-                        return throwError(exec, SyntaxError);
-                }
-                
-                CGColorRef colorRef = CGColorCreate (colorSpace, components);
-                CGContextSetShadowWithColor (drawingContext, offset, blur, colorRef);
-                CFRelease (colorRef);
-                CFRelease (colorSpace);
-            }
-            break;
-        }
-        case Context2D::ClearShadow: {
-            if (args.size() != 0)
-                return throwError(exec, SyntaxError);
-            CGContextSetShadowWithColor (drawingContext, CGSizeMake(0, 0), 0, nil);
-            break;
-        }
-
-        // DrawImage has three variants:
-        // drawImage (img, dx, dy)
-        // drawImage (img, dx, dy, dw, dh)
-        // drawImage (img, sx, sy, sw, sh, dx, dy, dw, dh)
-        // composite operation is specified with globalCompositeOperation
-        // img parameter can be a JavaScript Image, <img>, or a <canvas>
-        case Context2D::DrawImage: {
-            if (args.size() < 3)
-                return throwError(exec, SyntaxError);
-            
-            // Make sure first argument is an object.
-            JSObject *o = static_cast<JSObject*>(args[0]);
-            if (!o->isObject())
-                return throwError(exec, TypeError);
-
-            float w = 0; // quiet incorrect gcc 4.0 warning
-            float h = 0; // quiet incorrect gcc 4.0 warning
-            CGContextRef sourceContext = 0;
-            
-            // Check for <img> or <canvas>.
-            HTMLImageElementImpl* imgElt = 0;
-            if (o->inherits(&KJS::HTMLElement::img_info)){
-                NodeImpl *n = static_cast<HTMLElement *>(args[0])->impl();
-                imgElt = static_cast<HTMLImageElementImpl*>(n);
-                if (imgElt->cachedImage()) {
-                    w = imgElt->cachedImage()->image()->width();
-                    h = imgElt->cachedImage()->image()->height();
-                }
-            }
-            else if (o->inherits(&KJS::HTMLElement::canvas_info)){
-                NodeImpl *n = static_cast<HTMLElement *>(args[0])->impl();
-                HTMLCanvasElementImpl *e = static_cast<HTMLCanvasElementImpl*>(n);
-                khtml::RenderCanvasImage *renderer = static_cast<khtml::RenderCanvasImage*>(e->renderer());
-                if (!renderer) {
-                    // No renderer, nothing to draw.
-                    return jsUndefined();
-                }
-
-                sourceContext = renderer->drawingContext();
-                w = (float)CGBitmapContextGetWidth(sourceContext);
-                h = (float)CGBitmapContextGetHeight(sourceContext);
-            }
-            else
-                return throwError(exec, TypeError);
-            
-            float dx, dy, dw = w, dh = h;
-            float sx = 0.f, sy = 0.f, sw = w, sh = h;
-            
-            if (args.size() == 3) {
-                dx = args[1]->toNumber(exec);
-                dy = args[2]->toNumber(exec);
-            }
-            else if (args.size() == 5) {
-                dx = args[1]->toNumber(exec);
-                dy = args[2]->toNumber(exec);
-                dw = args[3]->toNumber(exec);
-                dh = args[4]->toNumber(exec);
-            }
-            else if (args.size() == 9) {
-                sx = args[1]->toNumber(exec);
-                sy = args[2]->toNumber(exec);
-                sw = args[3]->toNumber(exec);
-                sh = args[4]->toNumber(exec);
-                dx = args[5]->toNumber(exec);
-                dy = args[6]->toNumber(exec);
-                dw = args[7]->toNumber(exec);
-                dh = args[8]->toNumber(exec);
-            }
-            else
-                return throwError(exec, SyntaxError);
-
-            if (!sourceContext && imgElt && imgElt->cachedImage()) {
-                GraphicsContext p;
-                p.drawFloatImage(imgElt->cachedImage()->image(), dx, dy, dw, dh, sx, sy, sw, sh, 
-                                 Image::compositeOperatorFromString(contextObject->_globalComposite->toString(exec).qstring().lower().ascii()), drawingContext);
-            }
-            else {
-                // Cheap, because the image is backed by copy-on-write memory, and we're
-                // guaranteed to release before doing any more drawing in the source context.
-                CGImageRef sourceImage = CGBitmapContextCreateImage(sourceContext);
-                if (sx == 0 && sy == 0 && sw == w && sh == h) {
-                    // Fast path, yay!
-                    CGContextDrawImage (drawingContext, CGRectMake(dx, dy, dw, dh), sourceImage);
-                }
-                else {
-                    // Create a new bitmap of the appropriate size and then draw that into our context.
-                    // Slow path, boo!
-                    CGContextRef clippedSourceContext;
-                    CGImageRef clippedSourceImage;
-                    size_t csw = (size_t)sw;
-                    size_t csh = (size_t)sh;
-                                        
-                    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-                    size_t numComponents = CGColorSpaceGetNumberOfComponents(colorSpace);
-                    size_t bytesPerRow = BYTES_PER_ROW(csw,BITS_PER_COMPONENT,(numComponents+1)); // + 1 for alpha
-                    void *_drawingContextData = fastMalloc(csh * bytesPerRow);
-                    
-                    clippedSourceContext = CGBitmapContextCreate(_drawingContextData, csw, csh, BITS_PER_COMPONENT, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast);
-                    CGContextTranslateCTM (clippedSourceContext, -sx, -sy);
-                    CGContextDrawImage (clippedSourceContext, CGRectMake(0,0,w,h), sourceImage);
-                    clippedSourceImage = CGBitmapContextCreateImage(clippedSourceContext);
-                    CGContextDrawImage (drawingContext, CGRectMake(dx, dy, dw, dh), clippedSourceImage);
-                    
-                    CGImageRelease (clippedSourceImage);
-                    CGContextRelease (clippedSourceContext);
-                    fastFree (_drawingContextData);
-                }
-                
-                CGImageRelease (sourceImage);
-            }
-
-            renderer->setNeedsImageUpdate();
-
-            break;
-        }
-        case Context2D::DrawImageFromRect: {
-            if (args.size() != 10)
-                return throwError(exec, SyntaxError);
-            JSObject *o = static_cast<JSObject*>(args[0]);
-            if (!o->inherits(&KJS::HTMLElement::img_info))
-                return throwError(exec, TypeError);
-            NodeImpl *n = static_cast<HTMLElement *>(args[0])->impl();
-            HTMLImageElementImpl *e = static_cast<HTMLImageElementImpl*>(n);
-            
-            float sx = args[1]->toNumber(exec);
-            float sy = args[2]->toNumber(exec);
-            float sw = args[3]->toNumber(exec);
-            float sh = args[4]->toNumber(exec);
-            float dx = args[5]->toNumber(exec);
-            float dy = args[6]->toNumber(exec);
-            float dw = args[7]->toNumber(exec);
-            float dh = args[8]->toNumber(exec);
-            QString compositeOperator = args[9]->toString(exec).qstring().lower();
-            
-            GraphicsContext p;
-
-            if (e->cachedImage())
-                p.drawFloatImage(e->cachedImage()->image(), dx, dy, dw, dh, sx, sy, sw, sh, Image::compositeOperatorFromString(compositeOperator.ascii()), drawingContext);
-          
-            renderer->setNeedsImageUpdate();
-            break;
-        }
-        case Context2D::SetAlpha: {
-            if (args.size() != 1)
-                return throwError(exec, SyntaxError);
-            float a =  (float)args[0]->toNumber(exec);
-            CGContextSetAlpha (drawingContext, a);
-            break;
-        }
-        case Context2D::SetCompositeOperation: {
-            if (args.size() != 1)
-                return throwError(exec, SyntaxError);
-            QString compositeOperator = args[0]->toString(exec).qstring().lower();
-            GraphicsContext::setCompositeOperation(drawingContext,compositeOperator);
-            break;
-        }
-        
-        case Context2D::CreateLinearGradient: {
-            if (args.size() != 4)
-                return throwError(exec, SyntaxError);
-            float x0 = args[0]->toNumber(exec);
-            float y0 = args[1]->toNumber(exec);
-            float x1 = args[2]->toNumber(exec);
-            float y1 = args[3]->toNumber(exec);
-
-            return new Gradient(x0, y0, x1, y1);
-        }
-        
-        case Context2D::CreateRadialGradient: {
-            if (args.size() != 6)
-                return throwError(exec, SyntaxError);
-            float x0 = args[0]->toNumber(exec);
-            float y0 = args[1]->toNumber(exec);
-            float r0 = args[2]->toNumber(exec);
-            float x1 = args[3]->toNumber(exec);
-            float y1 = args[4]->toNumber(exec);
-            float r1 = args[5]->toNumber(exec);
-
-            return new Gradient(x0, y0, r0, x1, y1, r1);
-        }
-        
-        case Context2D::CreatePattern: {
-            if (args.size() != 2)
-                return throwError(exec, SyntaxError);
-            JSObject *o = static_cast<JSObject*>(args[0]);
-            if (!o->inherits(&KJS::HTMLElement::img_info))
-                return throwError(exec, TypeError);
-            int repetitionType = ImagePattern::Repeat;
-            DOMString repetitionString = args[1]->toString(exec).domString().lower();
-            if (repetitionString == "repeat-x")
-                repetitionType = ImagePattern::RepeatX;
-            else if (repetitionString == "repeat-y")
-                repetitionType = ImagePattern::RepeatY;
-            else if (repetitionString == "no-repeat")
-                repetitionType = ImagePattern::NoRepeat;
-            NodeImpl *n = static_cast<HTMLElement *>(args[0])->impl();
-            return new ImagePattern(static_cast<HTMLImageElementImpl *>(n)->cachedImage(), repetitionType);
-        }
-    }
-#endif
-
-    return jsUndefined();
-}
-
-const ClassInfo Context2D::info = { "Context2D", 0, &Context2DTable, 0 };
-
-/* Source for Context2DTable. Use "make hashtables" to regenerate.
-@begin Context2DTable 48
-  strokeStyle              Context2D::StrokeStyle                 DontDelete
-  fillStyle                Context2D::FillStyle                   DontDelete
-  lineWidth                Context2D::LineWidth                   DontDelete
-  lineCap                  Context2D::LineCap                     DontDelete
-  lineJoin                 Context2D::LineJoin                    DontDelete
-  miterLimit               Context2D::MiterLimit                  DontDelete
-  shadowOffsetX            Context2D::ShadowOffsetX               DontDelete
-  shadowOffsetY            Context2D::ShadowOffsetY               DontDelete
-  shadowBlur               Context2D::ShadowBlur                  DontDelete
-  shadowColor              Context2D::ShadowColor                 DontDelete
-  globalAlpha              Context2D::GlobalAlpha                 DontDelete
-  globalCompositeOperation Context2D::GlobalCompositeOperation    DontDelete
-  save                     Context2D::Save                        DontDelete|Function 0
-  restore                  Context2D::Restore                     DontDelete|Function 0
-  scale                    Context2D::Scale                       DontDelete|Function 2
-  rotate                   Context2D::Rotate                      DontDelete|Function 2
-  translate                Context2D::Translate                   DontDelete|Function 1
-  beginPath                Context2D::BeginPath                   DontDelete|Function 0
-  closePath                Context2D::ClosePath                   DontDelete|Function 0
-  setStrokeColor           Context2D::SetStrokeColor              DontDelete|Function 1
-  setFillColor             Context2D::SetFillColor                DontDelete|Function 1
-  setLineWidth             Context2D::SetLineWidth                DontDelete|Function 1
-  setLineCap               Context2D::SetLineCap                  DontDelete|Function 1
-  setLineJoin              Context2D::SetLineJoin                 DontDelete|Function 1
-  setMiterLimit            Context2D::SetMiterLimit               DontDelete|Function 1
-  fill                     Context2D::Fill                        DontDelete|Function 0
-  stroke                   Context2D::Stroke                      DontDelete|Function 0
-  moveTo                   Context2D::MoveTo                      DontDelete|Function 2
-  lineTo                   Context2D::LineTo                      DontDelete|Function 2
-  quadraticCurveTo         Context2D::QuadraticCurveTo            DontDelete|Function 4
-  bezierCurveTo            Context2D::BezierCurveTo               DontDelete|Function 6
-  arcTo                    Context2D::ArcTo                       DontDelete|Function 5
-  arc                      Context2D::Arc                         DontDelete|Function 6
-  rect                     Context2D::Rect                        DontDelete|Function 4
-  clip                     Context2D::Clip                        DontDelete|Function 0
-  clearRect                Context2D::ClearRect                   DontDelete|Function 4
-  fillRect                 Context2D::FillRect                    DontDelete|Function 4
-  strokeRect               Context2D::StrokeRect                  DontDelete|Function 4
-  drawImage                Context2D::DrawImage                   DontDelete|Function 6
-  drawImageFromRect        Context2D::DrawImageFromRect           DontDelete|Function 10
-  setShadow                Context2D::SetShadow                   DontDelete|Function 3
-  clearShadow              Context2D::ClearShadow                 DontDelete|Function 0
-  setAlpha                 Context2D::SetAlpha                    DontDelete|Function 1
-  setCompositeOperation    Context2D::SetCompositeOperation       DontDelete|Function 1
-  createLinearGradient     Context2D::CreateLinearGradient        DontDelete|Function 4
-  createRadialGradient     Context2D::CreateRadialGradient        DontDelete|Function 6
-  createPattern            Context2D::CreatePattern               DontDelete|Function 2
-@end
-*/
-
-bool Context2D::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
-{
-    // FIXME: functions should be on the prototype, not in the object itself
-    return getStaticPropertySlot<Context2DFunction, Context2D, DOMObject>(exec, &Context2DTable, this, propertyName, slot);
-}
-
-JSValue *Context2D::getValueProperty(ExecState *, int token) const
-{
-    switch(token) {
-        case StrokeStyle: {
-            return _strokeStyle;
-        }
-        
-        case FillStyle: {
-            return _fillStyle;
-        }
-        
-        case LineWidth: {
-            return _lineWidth;
-        }
-        
-        case LineCap: {
-            return _lineCap;
-        }
-        
-        case LineJoin: {
-            return _lineJoin;
-        }
-        
-        case MiterLimit: {
-            return _miterLimit;
-        }
-        
-        case ShadowOffsetX: {
-            return _shadowOffsetX;
-        }
-        
-        case ShadowOffsetY: {
-            return _shadowOffsetY;
-        }
-        
-        case ShadowBlur: {
-            return _shadowBlur;
-        }
-        
-        case ShadowColor: {
-            return _shadowColor;
-        }
-        
-        case GlobalAlpha: {
-            return _globalAlpha;
-        }
-        
-        case GlobalCompositeOperation: {
-            return _globalComposite;
-        }
-        
-        default: {
-        }
-    }
-    
-    return jsUndefined();
-}
-
-void Context2D::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
-{
-    lookupPut<Context2D,DOMObject>(exec, propertyName, value, attr, &Context2DTable, this );
-}
-
-#if __APPLE__
-CGContextRef Context2D::drawingContext()
-{
-    khtml::RenderCanvasImage *renderer = static_cast<khtml::RenderCanvasImage*>(_element->renderer());
-    if (!renderer)
-        return 0;
-    
-    CGContextRef context = renderer->drawingContext();
-    if (!context)
-        return 0;
-        
-    return context;
-}
-
-
-CGColorRef colorRefFromValue(ExecState *exec, JSValue *value)
-{
-    CGColorSpaceRef colorSpace;
-    float components[4];
-    
-    if (value->isString()) {
-        RGBA32 color = DOM::CSSParser::parseColor(value->toString(exec).domString());
-        Color qc(color);
-        components[0] = qc.red()/255.;
-        components[1] = qc.green()/255.;
-        components[2] = qc.blue()/255.;
-        components[3] = qc.alpha();
-        colorSpace = CGColorSpaceCreateDeviceRGB();
-    }
-    else
-        return 0;
-    
-    CGColorRef colorRef = CGColorCreate (colorSpace, components);
-    CFRelease (colorSpace);
-    
-    return colorRef;
-}
-#endif
-
-Color colorFromValue(ExecState *exec, JSValue *value)
-{
-    RGBA32 color = DOM::CSSParser::parseColor(value->toString(exec).domString());
-    return Color(color);
-}
-
-void Context2D::setShadow(ExecState *exec)
-{
-#if __APPLE__
-    CGContextRef context = drawingContext();
-    if (!context)
-        return;
-    
-    CGSize offset;
-    offset.width = (float)_shadowOffsetX->toNumber(exec);
-    offset.height = (float)_shadowOffsetY->toNumber(exec);
-    float blur = (float)_shadowBlur->toNumber(exec);
-    CGColorRef colorRef = colorRefFromValue(exec, _shadowColor);
-    CGContextSetShadowWithColor (context, offset, blur, colorRef);
-    CFRelease (colorRef);
-#endif
-}
-
-void Context2D::updateFillImagePattern()
-{
-#if __APPLE__
-    CGContextRef context = drawingContext();
-    CGAffineTransform transform = CGContextGetCTM(context);
-    
-    if (!_validFillImagePattern || !CGAffineTransformEqualToTransform(transform, _lastFillImagePatternCTM)) {
-        ImagePattern *imagePattern = static_cast<ImagePattern *>(_fillStyle);
-        CGPatternRef pattern = imagePattern->createPattern(CGContextGetCTM(context));
-        float patternAlpha = 1;
-        CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(0);
-        CGContextSetFillColorSpace(context, patternSpace);
-        CGContextSetFillPattern(context, pattern, &patternAlpha);
-        CGColorSpaceRelease(patternSpace);
-        CGPatternRelease(pattern);
-        _validFillImagePattern = true;
-        _lastFillImagePatternCTM = transform;
-    }
-#endif
-}
-
-void Context2D::updateStrokeImagePattern()
-{
-#if __APPLE__
-    CGContextRef context = drawingContext();
-    CGAffineTransform transform = CGContextGetCTM(context);
-    
-    if (!_validStrokeImagePattern || !CGAffineTransformEqualToTransform(transform, _lastStrokeImagePatternCTM)) {
-        ImagePattern *imagePattern = static_cast<ImagePattern *>(_fillStyle);
-        CGPatternRef pattern = imagePattern->createPattern(CGContextGetCTM(context));
-        float patternAlpha = 1;
-        CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(0);
-        CGContextSetStrokeColorSpace(context, patternSpace);
-        CGContextSetStrokePattern(context, pattern, &patternAlpha);
-        CGColorSpaceRelease(patternSpace);
-        CGPatternRelease(pattern);
-        _validStrokeImagePattern = true;
-        _lastStrokeImagePatternCTM = transform;
-    }
-#endif
-}
-
-void Context2D::putValueProperty(ExecState *exec, int token, JSValue *value, int /*attr*/)
-{
-#if __APPLE__
-    CGContextRef context = drawingContext();
-    if (!context)
-        return;
-    
-    switch(token) {
-        case StrokeStyle: {
-            _strokeStyle = value;
-            if (value->isString()) {
-                Color qc = colorFromValue(exec, value);
-                CGContextSetRGBStrokeColor(context, qc.red()/255., qc.green()/255., qc.blue()/255., qc.alpha()/255.);
-            }
-            else {
-                // _strokeStyle is used when stroke() is called on the context.
-                // CG doesn't have the notion of a setting a stroke gradient.
-                JSObject *o = static_cast<JSObject*>(value);
-                
-                if (!o->isObject() || !(o->inherits(&Gradient::info) || o->inherits(&ImagePattern::info)))
-                    throwError(exec, TypeError);
-            }
-            break;
-        }
-        
-        case FillStyle: {
-            _fillStyle = value;
-            if (value->isString()) {
-                Color qc = colorFromValue(exec, value);
-                CGContextSetRGBFillColor(context, qc.red()/255., qc.green()/255., qc.blue()/255., qc.alpha()/255.);
-            }
-            else {
-                // _fillStyle is checked when fill() is called on the context.
-                // CG doesn't have the notion of setting a fill gradient.
-                JSObject *o = static_cast<JSObject*>(value);
-                
-                if (!o->isObject() || !(o->inherits(&Gradient::info) || o->inherits(&ImagePattern::info)))
-                    throwError(exec, TypeError);
-
-                // Gradients and image patterns are constructed when needed during fill and stroke operations.
-            }
-            break;
-        }
-        
-        case LineWidth: {
-            _lineWidth = value;
-            float w = (float)value->toNumber(exec);
-            CGContextSetLineWidth (context, w);
-            break;
-        }
-        
-        case LineCap: {
-            _lineCap = value;
-        
-            CGLineCap cap = kCGLineCapButt;
-            DOMString capString = value->toString(exec).domString().lower();
-            if (capString == "round")
-                cap = kCGLineCapRound;
-            else if (capString == "square")
-                cap = kCGLineCapSquare;
-            CGContextSetLineCap (context, cap);
-            break;
-        }
-        
-        case LineJoin: {
-            _lineJoin = value;
-            
-            CGLineJoin join = kCGLineJoinMiter;
-            DOMString joinString = value->toString(exec).domString().lower();
-            if (joinString == "round")
-                join = kCGLineJoinRound;
-            else if (joinString == "bevel")
-                join = kCGLineJoinBevel;
-            CGContextSetLineJoin (context, join);
-            break;
-        }
-        
-        case MiterLimit: {
-            _miterLimit = value;
-            
-            float l = (float)value->toNumber(exec);
-            CGContextSetMiterLimit (context, l);
-            break;
-        }
-        
-        case ShadowOffsetX: {
-            _shadowOffsetX = value;
-            setShadow(exec);
-            break;
-        }
-        
-        case ShadowOffsetY: {
-            _shadowOffsetY = value;
-            setShadow(exec);
-            break;
-        }
-        
-        case ShadowBlur: {
-            _shadowBlur = value;
-            setShadow(exec);
-            break;
-        }
-        
-        case ShadowColor: {
-            _shadowColor = value;
-            setShadow(exec);
-            break;
-        }
-        
-        case GlobalAlpha: {
-            _globalAlpha = value;
-            float a =  (float)value->toNumber(exec);
-            CGContextSetAlpha (context, a);
-            break;
-        }
-        
-        case GlobalCompositeOperation: {
-            _globalComposite = value;
-            QString compositeOperator = value->toString(exec).qstring().lower();
-            GraphicsContext::setCompositeOperation(context, compositeOperator);
-            break;
-        }
-        
-        default: {
-        }
-    }
-#endif
-}
-
-void Context2D::save()
-{
-    List *list = new List();
-    
-    list->append(_strokeStyle);
-    list->append(_fillStyle);
-    list->append(_lineWidth);
-    list->append(_lineCap);
-    list->append(_lineJoin);
-    list->append(_miterLimit);
-    list->append(_shadowOffsetX);
-    list->append(_shadowOffsetY);
-    list->append(_shadowBlur);
-    list->append(_shadowColor);
-    list->append(_globalAlpha);
-    list->append(_globalComposite);
-    
-    stateStack.append(list);
-}
-
-void Context2D::restore()
-{
-    if (stateStack.count() < 1) {
-        return;
-    }
-    
-    List *list = stateStack.last();
-    
-    int pos = 0;
-    _strokeStyle = list->at(pos++);
-    _fillStyle = list->at(pos++);
-    _lineWidth = list->at(pos++);
-    _lineCap = list->at(pos++);
-    _lineJoin = list->at(pos++);
-    _miterLimit = list->at(pos++);
-    _shadowOffsetX = list->at(pos++);
-    _shadowOffsetY = list->at(pos++);
-    _shadowBlur = list->at(pos++);
-    _shadowColor = list->at(pos++);
-    _globalAlpha = list->at(pos++);
-    _globalComposite = list->at(pos++);
-
-    // This will delete list.
-    stateStack.removeLast();
-}
-
-Context2D::Context2D(HTMLElementImpl *e)
-  : _validFillImagePattern(false), _validStrokeImagePattern(false),
-    _element(e),
-    _strokeStyle(jsUndefined()),
-    _fillStyle(jsUndefined()),
-    _lineWidth(jsUndefined()),
-    _lineCap(jsUndefined()),
-    _lineJoin(jsUndefined()),
-    _miterLimit(jsUndefined()),
-    _shadowOffsetX(jsUndefined()),
-    _shadowOffsetY(jsUndefined()),
-    _shadowBlur(jsUndefined()),
-    _shadowColor(jsUndefined()),
-    _globalAlpha(jsUndefined()),
-    _globalComposite(jsUndefined())
-{
-    _lineWidth = jsNumber(1);
-    _strokeStyle = jsString("black");
-    _fillStyle = jsString("black");
-    
-    _lineCap = jsString("butt");
-    _lineJoin = jsString("miter");
-    _miterLimit = jsNumber(10);
-    
-    _shadowOffsetX = jsNumber(0);
-    _shadowOffsetY = jsNumber(0);
-    _shadowBlur = jsNumber(0);
-    _shadowColor = jsString("black");
-        
-    _globalAlpha = jsNumber(1);
-    _globalComposite = jsString("source-over");
-    
-    stateStack.setAutoDelete(true);
-}
-
-Context2D::~Context2D()
-{
-}
-
-void Context2D::mark()
-{
-    JSValue *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;
-    }
-    
-    DOMObject::mark();
-}
-
-const ClassInfo KJS::Gradient::info = { "Gradient", 0, &GradientTable, 0 };
-
-/* Source for GradientTable. Use "make hashtables" to regenerate.
-@begin GradientTable 1
-  addColorStop             Gradient::AddColorStop                DontDelete|Function 2
-@end
-*/
-
-KJS_IMPLEMENT_PROTOFUNC(GradientFunction)
-
-JSValue *GradientFunction::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
-{
-    if (!thisObj->inherits(&Gradient::info))
-        return throwError(exec, TypeError);
-
-    Gradient *gradient = static_cast<KJS::Gradient *>(thisObj);
-
-    switch (id) {
-        case Gradient::AddColorStop: {
-            if (args.size() != 2)
-                return throwError(exec, SyntaxError);
-
-            Color 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 jsUndefined();
-}
-
-void gradientCallback (void *info, const float *in, float *out)
-{
-    Gradient *gradient = static_cast<Gradient*>(info);
-    int numStops;
-    const ColorStop *stops = gradient->colorStops(&numStops);
-    float current = *in;
-    
-    assert (numStops >= 2);
-    
-    if (current == 0) {
-        gradient->lastStop = 0;
-        gradient->nextStop = 1;
-
-        const ColorStop *thisStop = &stops[0];
-        *out++ = thisStop->red;
-        *out++ = thisStop->green;
-        *out++ = thisStop->blue;
-        *out = thisStop->alpha;
-    }
-    else if (current == 1) {
-        const ColorStop *thisStop = &stops[numStops-1];
-        *out++ = thisStop->red;
-        *out++ = thisStop->green;
-        *out++ = thisStop->blue;
-        *out = thisStop->alpha;
-    }
-    else {
-        if (current >= stops[gradient->nextStop].stop) {
-            gradient->lastStop = gradient->nextStop;
-            gradient->nextStop = gradient->lastStop+1;
-        }
-        
-        // Add an interpolation for each component between
-        // stops.
-        const ColorStop *nextStop = &stops[gradient->nextStop];
-        const ColorStop *lastStop = &stops[gradient->lastStop];
-        
-        float stopDelta = nextStop->stop - lastStop->stop;
-        float stopOffset = current - lastStop->stop;
-        float stopPercent = stopOffset/stopDelta;
-        
-        *out++ = lastStop->red + (nextStop->red - lastStop->red) * stopPercent;
-        *out++ = lastStop->green + (nextStop->green - lastStop->green) * stopPercent;
-        *out++ = lastStop->blue + (nextStop->blue - lastStop->blue) * stopPercent;
-        *out = lastStop->alpha + (nextStop->alpha - lastStop->alpha) * stopPercent;
-    }
-}
-
-static float intervalRangeDomin[] = { 0.f, 1.f };
-static float colorComponentRangeDomains[] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f };
-#if __APPLE__
-CGFunctionCallbacks gradientCallbacks = {
-    0, gradientCallback, NULL
-};
-#endif
-
-void Gradient::commonInit()
-{
-    stops = 0;
-    stopCount = 0;
-    maxStops = 0;
-    stopsNeedAdjusting = false;
-    adjustedStopCount = 0;
-    adjustedStops = 0;
-
-#if __APPLE__
-    _shadingRef = 0;
-#endif
-
-    regenerateShading = true;
-}
-
-Gradient::Gradient(float x0, float y0, float x1, float y1)
-{
-    _gradientType = Gradient::Linear;
-    _x0 = x0;
-    _y0 = y0;
-    _x1 = x1;
-    _y1 = y1;
-
-    commonInit();
-}
-
-Gradient::Gradient(float x0, float y0, float r0, float x1, float y1, float r1)
-{
-    _gradientType = Gradient::Radial;
-    _x0 = x0;
-    _y0 = y0;
-    _r0 = r0;
-    _x1 = x1;
-    _y1 = y1;
-    _r1 = r1;
-
-    commonInit();
-}
-
-bool Gradient::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
-{
-    return getStaticPropertySlot<GradientFunction, Gradient, DOMObject>(exec, &GradientTable, this, propertyName, slot);
-}
-
-JSValue *Gradient::getValueProperty(ExecState *, int token) const
-{
-    return jsUndefined();
-}
-
-void Gradient::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
-{
-    lookupPut<Gradient,DOMObject>(exec, propertyName, value, attr, &GradientTable, this );
-}
-
-void Gradient::putValueProperty(ExecState *exec, int token, JSValue *value, int /*attr*/)
-{
-}
-
-Gradient::~Gradient()
-{
-#if __APPLE__
-    if (_shadingRef) {
-        CGShadingRelease(_shadingRef);
-        _shadingRef = 0;
-    }
-#endif
-
-    fastFree(stops);
-    stops = 0;
-    
-    fastFree(adjustedStops);
-    adjustedStops = 0;
-}
-
-#if __APPLE__
-CGShadingRef Gradient::getShading()
-{
-    if (!regenerateShading)
-        return _shadingRef;
-    
-    if (_shadingRef)
-        CGShadingRelease (_shadingRef);
-        
-    CGFunctionRef _colorFunction = CGFunctionCreate((void *)this, 1, intervalRangeDomin, 4, colorComponentRangeDomains, &gradientCallbacks);
-    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-    
-    if (_gradientType == Gradient::Radial) {    
-        _shadingRef = CGShadingCreateRadial(colorSpace, CGPointMake(_x0,_y0), _r0, CGPointMake(_x1,_y1), _r1, _colorFunction, true, true);
-    }
-    else {    
-        _shadingRef = CGShadingCreateAxial(colorSpace, CGPointMake(_x0,_y0), CGPointMake(_x1,_y1), _colorFunction, true, true);
-    }
-    
-    CGColorSpaceRelease (colorSpace);
-    CGFunctionRelease (_colorFunction);
-    
-    regenerateShading = false;
-    
-    return _shadingRef;
-}
-#endif
-
-void Gradient::addColorStop (float s, float r, float g, float b, float a)
-{
-    if (stopCount == 0) {
-        maxStops = 4;
-        stops = (ColorStop *)fastMalloc(maxStops * sizeof(ColorStop));
-    }
-    else if (stopCount+1 > maxStops) {
-        maxStops *= 2;
-        stops = (ColorStop *)fastRealloc(stops, maxStops * sizeof(ColorStop));
-    }
-    stops[stopCount++] = ColorStop (s, r, g, b, a);
-    stopsNeedAdjusting = true;
-}
-
-static int sortStops(const ColorStop *a, const ColorStop *b)
-{
-    if (a->stop > b->stop)
-        return 1;
-    else if (a->stop < b->stop)
-        return -1;
-    return 0;
-}
-
-// Return a sorted array of stops guaranteed to contain a 0 and 1 stop.
-const ColorStop *Gradient::colorStops(int *count) const
-{
-    if (stopsNeedAdjusting || !stops) {
-        stopsNeedAdjusting = false;
-        
-        bool haveZeroStop = false;
-        bool haveOneStop = false;
-        if (stops) {
-            qsort (stops, stopCount, sizeof(ColorStop), (int (*)(const void*, const void*))sortStops);
-    
-            // Is there a zero stop?
-            haveZeroStop = (stops[0].stop == 0.f);
-
-            // Is there a one stop.  If not add one at the end.
-            haveOneStop = (stopCount > 0 && stops[stopCount-1].stop == 1.f);
-        }
-        
-        adjustedStopCount = stopCount;
-        if (!haveZeroStop)
-            adjustedStopCount++;
-        if (!haveOneStop)
-            adjustedStopCount++;
-            
-        if (adjustedStopCount != stopCount) {
-            adjustedStops = (ColorStop *)fastMalloc(adjustedStopCount * sizeof(ColorStop));
-            memcpy (haveZeroStop ? adjustedStops : adjustedStops+1,
-                stops, stopCount*sizeof(ColorStop));
-
-            // If not specified use default start (stop 0) and end (stop 1) colors.
-            // This color will be transparent black.
-            if (!haveZeroStop) {
-                adjustedStops[0] = ColorStop(0.f, 0.f, 0.f, 0.f, 1.f);
-            }
-            if (!haveOneStop) {
-                adjustedStops[adjustedStopCount-1] = ColorStop(1.f, 0.f, 0.f, 0.f, 1.f);
-            }
-        }
-        
-        regenerateShading = true;
-    }
-            
-    if (adjustedStops) {
-        *count = adjustedStopCount;
-        return adjustedStops;
-    }
-        
-    *count = stopCount;
-    return stops;
-}
-
-const ClassInfo ImagePattern::info = { "ImagePattern", 0, &ImagePatternTable, 0 };
-
-/* Source for ImagePatternTable. Use "make hashtables" to regenerate.
-@begin ImagePatternTable 0
-@end
-*/
-
-#if __APPLE__
-static void drawPattern (void * info, CGContextRef context)
-{
-    ImagePattern *pattern = static_cast<ImagePattern*>(info);
-    if (!pattern->cachedImage())
-        return;
-
-    GraphicsContext p;
-    float w = pattern->cachedImage()->image()->width();
-    float h = pattern->cachedImage()->image()->height();
-    
-    // Try and draw bitmap directly
-    CGImageRef ref = pattern->cachedImage()->image()->getCGImageRef();
-    if (ref)
-        CGContextDrawImage (context, CGRectMake(0, 0, w, h), ref);    
-    else
-        p.drawFloatImage(pattern->cachedImage()->image(), 0, 0, w, h, 0.f, 0.f, w, h, Image::CompositeSourceOver, context);
-}
-
-CGPatternCallbacks patternCallbacks = { 0, drawPattern, NULL };
-#endif
-
-ImagePattern::ImagePattern(CachedImage* cachedImage, int repetitionType)
-    :_rw(0), _rh(0)
-{
-    m_cachedImage = cachedImage;
-    if (!m_cachedImage)
-        return;
-
-    m_cachedImage->ref(this);
-    
-    float w = m_cachedImage->image()->width();
-    float h = m_cachedImage->image()->height();
-#if __APPLE__
-    _bounds = CGRectMake (0, 0, w, h);
-#endif
-    if (repetitionType == Repeat) {
-        _rw = w; _rh = h;
-    }
-    else if (repetitionType == RepeatX) {
-        _rw = w; _rh = 0;
-    }
-    else if (repetitionType == RepeatY) {
-        _rw = 0; _rh = h;
-    }
-    else if (repetitionType == NoRepeat) {
-        _rw = 0; _rh = 0;
-    }
-}
-
-ImagePattern::~ImagePattern()
-{
-    if (m_cachedImage)
-        m_cachedImage->deref(this);
-}
-
-#if __APPLE__
-CGPatternRef ImagePattern::createPattern(CGAffineTransform transform)
-{
-    if (!m_cachedImage || m_cachedImage->image()->isNull())
-        return 0;
-          
-    CGAffineTransform patternTransform = transform;
-    patternTransform = CGAffineTransformScale(patternTransform, 1, -1);
-    patternTransform = CGAffineTransformTranslate(patternTransform, 0, -m_cachedImage->image()->height());
-
-    return CGPatternCreate(this, _bounds, patternTransform, _rw, _rh, kCGPatternTilingConstantSpacing, true, &patternCallbacks);
-}
-#endif
-
-bool ImagePattern::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
-{
-    return getStaticValueSlot<ImagePattern, DOMObject>(exec, &ImagePatternTable, this, propertyName, slot);
-}
-
-JSValue *ImagePattern::getValueProperty(ExecState *, int token) const
-{
-    return jsUndefined();
-}
-
-void ImagePattern::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
-{
-    lookupPut<ImagePattern,DOMObject>(exec, propertyName, value, attr, &ImagePatternTable, this );
-}
-
-void ImagePattern::putValueProperty(ExecState *exec, int token, JSValue *value, int /*attr*/)
-{
+    return static_cast<JSObject*>(toJS(exec, result));
 }
 
 ////////////////////////////////////////////////////////////////
index 82b0c66..563f513 100644 (file)
@@ -2,7 +2,7 @@
 /*
  *  This file is part of the KDE libraries
  *  Copyright (C) 1999 Harri Porten (porten@kde.org)
- *  Copyright (C) 2004 Apple Computer, Inc.
+ *  Copyright (C) 2004, 2006 Apple Computer, Inc.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
 #ifndef KJS_HTML_H_
 #define KJS_HTML_H_
 
-#include "CachedObjectClient.h"
-#include "Color.h"
-#include "Image.h"
 #include "JSElement.h"
 #include "kjs_dom.h"
-#include <qptrlist.h>
 
-#if __APPLE__
-#include <ApplicationServices/ApplicationServices.h>
-#endif
-
-namespace DOM {
+namespace WebCore {
+    class CanvasRenderingContext2D;
     class HTMLCollectionImpl;
     class HTMLDocumentImpl;
     class HTMLElementImpl;
+    class CanvasGradient;
+    class CanvasPattern;
     class HTMLSelectElementImpl;
     class HTMLTableCaptionElementImpl;
     class HTMLTableSectionElementImpl;
-};
+}
 
 namespace KJS {
 
@@ -48,7 +43,7 @@ namespace KJS {
 
   class HTMLDocument : public DOMDocument {
   public:
-    HTMLDocument(ExecState *exec, DOM::HTMLDocumentImpl *d);
+    HTMLDocument(ExecState *exec, WebCore::HTMLDocumentImpl *d);
     virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
     JSValue *getValueProperty(ExecState *exec, int token) const;
     virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
@@ -364,187 +359,6 @@ namespace KJS {
     RefPtr<DOM::DocumentImpl> m_doc;
   };
 
-  ////////////////////// Context2D Object ////////////////////////
-  class Context2D : public DOMObject {
-  friend class Context2DFunction;
-  public:
-    Context2D(DOM::HTMLElementImpl *e);
-    ~Context2D();
-    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
-    JSValue *getValueProperty(ExecState *exec, int token) const;
-    virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
-    void putValueProperty(ExecState *exec, int token, JSValue *value, int /*attr*/);
-    virtual bool toBoolean(ExecState *) const { return true; }
-    virtual void mark();
-    virtual const ClassInfo* classInfo() const { return &info; }
-    static const ClassInfo info;
-
-    enum { 
-        StrokeStyle,
-        FillStyle,
-        LineWidth,
-        LineCap,
-        LineJoin,
-        MiterLimit,
-        ShadowOffsetX,
-        ShadowOffsetY,
-        ShadowBlur,
-        ShadowColor,
-        GlobalAlpha,
-        GlobalCompositeOperation,
-        Save, Restore,
-        Scale, Rotate, Translate,
-        BeginPath, ClosePath, 
-        SetStrokeColor, SetFillColor, SetLineWidth, SetLineCap, SetLineJoin, SetMiterLimit, 
-        Fill, Stroke, 
-        MoveTo, LineTo, QuadraticCurveTo, BezierCurveTo, ArcTo, Arc, Rect, Clip,
-        ClearRect, FillRect, StrokeRect,
-        DrawImage, DrawImageFromRect,
-        SetShadow, ClearShadow,
-        SetAlpha, SetCompositeOperation,
-        CreateLinearGradient,
-        CreateRadialGradient,
-        CreatePattern
-    };
-
-private:
-    void save();
-    void restore();
-
-#if __APPLE__
-    // FIXME: Macintosh specific, and should be abstracted by GraphicsContext.
-    CGContextRef drawingContext();
-    CGAffineTransform _lastFillImagePatternCTM;
-    CGAffineTransform _lastStrokeImagePatternCTM;
-#endif
-
-    bool _validFillImagePattern;
-    bool _validStrokeImagePattern;
-    void updateFillImagePattern();
-    void updateStrokeImagePattern();
-    
-    void setShadow(ExecState *exec);
-
-    RefPtr<DOM::HTMLElementImpl> _element;
-    
-    QPtrList<List> stateStack;
-    
-    JSValue *_strokeStyle;
-    JSValue *_fillStyle;
-    JSValue *_lineWidth;
-    JSValue *_lineCap;
-    JSValue *_lineJoin;
-    JSValue *_miterLimit;
-    JSValue *_shadowOffsetX;
-    JSValue *_shadowOffsetY;
-    JSValue *_shadowBlur;
-    JSValue *_shadowColor;
-    JSValue *_globalAlpha;
-    JSValue *_globalComposite;
-  };
-
-#if __APPLE__
-    // FIXME: Macintosh specific, and should be abstracted by GraphicsContext.
-    CGColorRef colorRefFromValue(ExecState *exec, JSValue *value);
-#endif
-
-    Color colorFromValue(ExecState *exec, JSValue *value);
-
-    struct ColorStop {
-        float stop;
-        float red;
-        float green;
-        float blue;
-        float alpha;
-        
-        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(float x0, float y0, float x1, float y1);
-    Gradient(float x0, float y0, float r0, float x1, float y1, float r1);
-    ~Gradient();
-    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
-    JSValue *getValueProperty(ExecState *exec, int token) const;
-    virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
-    void putValueProperty(ExecState *exec, int token, JSValue *value, int /*attr*/);
-    virtual bool toBoolean(ExecState *) const { return true; }
-    virtual const ClassInfo* classInfo() const { return &info; }
-    static const ClassInfo info;
-
-    enum { 
-        AddColorStop
-    };
-    
-    enum {
-        Radial, Linear
-    };
-
-#if __APPLE__
-    // FIXME: Macintosh specific, and should be abstracted by GraphicsContext.
-    CGShadingRef getShading();
-#endif
-
-    void addColorStop (float s, float r, float g, float b, float alpha);
-    const ColorStop *colorStops(int *count) const;
-    
-    int lastStop;
-    int nextStop;
-    
-private:    
-    void commonInit();
-    
-    int _gradientType;
-    float _x0, _y0, _r0, _x1, _y1, _r1;
-
-#if __APPLE__
-    // FIXME: Macintosh specific, and should be abstracted by GraphicsContext.
-    CGShadingRef _shadingRef;
-#endif
-
-    int maxStops;
-    int stopCount;
-    ColorStop *stops;
-    mutable int adjustedStopCount;
-    mutable ColorStop *adjustedStops;
-    mutable bool stopsNeedAdjusting : 1;
-    mutable bool regenerateShading : 1;
-  };
-
-  class ImagePattern : public DOMObject, public WebCore::CachedObjectClient {
-  public:
-    ImagePattern(WebCore::CachedImage* cachedImage, int repetitionType);
-    ~ImagePattern();
-    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
-    JSValue *getValueProperty(ExecState *exec, int token) const;
-    virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
-    void putValueProperty(ExecState *exec, int token, JSValue *value, int /*attr*/);
-    virtual bool toBoolean(ExecState *) const { return true; }
-    virtual const ClassInfo* classInfo() const { return &info; }
-    static const ClassInfo info;
-
-#if __APPLE__
-    // FIXME: Macintosh specific, and should be abstracted by GraphicsContext.
-    CGPatternRef createPattern(CGAffineTransform transform);
-#endif
-
-    WebCore::CachedImage* cachedImage() const { return m_cachedImage; }
-    
-    enum {
-        Repeat, RepeatX, RepeatY, NoRepeat
-    };
-    
-private:
-    float _rw, _rh;
-    WebCore::CachedImage* m_cachedImage;
-#if __APPLE__
-    // FIXME: Macintosh specific, and should be abstracted by GraphicsContext.
-    CGRect _bounds;
-#endif
-  };
-
   JSValue *getHTMLCollection(ExecState *exec, DOM::HTMLCollectionImpl *c);
   JSValue *getSelectHTMLCollection(ExecState *exec, DOM::HTMLCollectionImpl *c, DOM::HTMLSelectElementImpl *e);
   JSValue *getAllHTMLCollection(ExecState *exec, DOM::HTMLCollectionImpl *c);
index afb9947..0b4c229 100644 (file)
@@ -65,7 +65,7 @@ JSValue* KJSProxyImpl::evaluate(const DOMString& filename, int baseLine, const D
 
   JSLock lock;
 
-  JSValue* thisNode = n ? Window::retrieve(m_frame) : getDOMNode(m_script->globalExec(), n);
+  JSValue* thisNode = n ? Window::retrieve(m_frame) : toJS(m_script->globalExec(), n);
   Completion comp = m_script->evaluate(filename, baseLine, reinterpret_cast<KJS::UChar *>(str.unicode()), str.length(), thisNode);
 
   if (comp.complType() == Normal || comp.complType() == ReturnValue)
index 2a888bf..c4f6c29 100644 (file)
@@ -92,17 +92,17 @@ JSValue *DOMRange::getValueProperty(ExecState *exec, int token) const
   RangeImpl &range = *m_impl;
   switch (token) {
   case StartContainer:
-    return getDOMNode(exec, range.startContainer(exception));
+    return toJS(exec, range.startContainer(exception));
   case StartOffset:
     return jsNumber(range.startOffset(exception));
   case EndContainer:
-    return getDOMNode(exec, range.endContainer(exception));
+    return toJS(exec, range.endContainer(exception));
   case EndOffset:
     return jsNumber(range.endOffset(exception));
   case Collapsed:
     return jsBoolean(range.collapsed(exception));
   case CommonAncestorContainer:
-    return getDOMNode(exec, range.commonAncestorContainer(exception));
+    return toJS(exec, range.commonAncestorContainer(exception));
   default:
     return 0;
   }
@@ -151,10 +151,10 @@ JSValue *DOMRangeProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, c
       range.deleteContents(exception);
       break;
     case DOMRange::ExtractContents:
-      result = getDOMNode(exec, range.extractContents(exception));
+      result = toJS(exec, range.extractContents(exception));
       break;
     case DOMRange::CloneContents:
-      result = getDOMNode(exec, range.cloneContents(exception));
+      result = toJS(exec, range.cloneContents(exception));
       break;
     case DOMRange::InsertNode:
       range.insertNode(toNode(args[0]), exception);
@@ -163,7 +163,7 @@ JSValue *DOMRangeProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, c
       range.surroundContents(toNode(args[0]), exception);
       break;
     case DOMRange::CloneRange:
-      result = getDOMRange(exec, range.cloneRange(exception).get());
+      result = toJS(exec, range.cloneRange(exception).get());
       break;
     case DOMRange::ToString:
       result = jsStringOrNull(range.toString(exception));
@@ -172,7 +172,7 @@ JSValue *DOMRangeProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, c
       range.detach(exception);
       break;
     case DOMRange::CreateContextualFragment:
-      result = getDOMNode(exec, range.createContextualFragment(args[0]->toString(exec).domString(), exception));
+      result = toJS(exec, range.createContextualFragment(args[0]->toString(exec).domString(), exception));
       break;
   };
 
@@ -180,7 +180,7 @@ JSValue *DOMRangeProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, c
   return result;
 }
 
-JSValue *getDOMRange(ExecState *exec, RangeImpl *r)
+JSValue *toJS(ExecState *exec, RangeImpl *r)
 {
   return cacheDOMObject<RangeImpl, DOMRange>(exec, r);
 }
index c2a3d70..dc52a7c 100644 (file)
@@ -61,7 +61,7 @@ namespace KJS {
     static const ClassInfo info;
   };
 
-  JSValue *getDOMRange(ExecState *exec, DOM::RangeImpl *r);
+  JSValue* toJS(ExecState*, WebCore::RangeImpl*);
   JSValue *getRangeConstructor(ExecState *exec);
 
   DOM::RangeImpl *toRange(JSValue *); // returns 0 if the value is not a DOMRange object
index b3f8e92..5b184a7 100644 (file)
@@ -79,15 +79,15 @@ JSValue *DOMNodeIterator::getValueProperty(ExecState *exec, int token) const
   NodeIteratorImpl &ni = *m_impl;
   switch (token) {
   case Root:
-    return getDOMNode(exec,ni.root());
+    return toJS(exec,ni.root());
   case WhatToShow:
     return jsNumber(ni.whatToShow());
   case Filter:
-    return getDOMNodeFilter(exec,ni.filter());
+    return toJS(exec,ni.filter());
   case ExpandEntityReferences:
     return jsBoolean(ni.expandEntityReferences());
   case ReferenceNode:
-    return getDOMNode(exec,ni.referenceNode());
+    return toJS(exec,ni.referenceNode());
   case PointerBeforeReferenceNode:
     return jsBoolean(ni.pointerBeforeReferenceNode());
  default:
@@ -103,9 +103,9 @@ JSValue *DOMNodeIteratorProtoFunc::callAsFunction(ExecState *exec, JSObject *thi
   NodeIteratorImpl &nodeIterator = *static_cast<DOMNodeIterator *>(thisObj)->impl();
   switch (id) {
   case DOMNodeIterator::PreviousNode:
-    return getDOMNode(exec,nodeIterator.previousNode(exception));
+    return toJS(exec,nodeIterator.previousNode(exception));
   case DOMNodeIterator::NextNode:
-    return getDOMNode(exec,nodeIterator.nextNode(exception));
+    return toJS(exec,nodeIterator.nextNode(exception));
   case DOMNodeIterator::Detach:
     nodeIterator.detach(exception);
     return jsUndefined();
@@ -113,7 +113,7 @@ JSValue *DOMNodeIteratorProtoFunc::callAsFunction(ExecState *exec, JSObject *thi
   return jsUndefined();
 }
 
-JSValue *getDOMNodeIterator(ExecState *exec, NodeIteratorImpl *ni)
+JSValue *toJS(ExecState *exec, NodeIteratorImpl *ni)
 {
   return cacheDOMObject<NodeIteratorImpl, DOMNodeIterator>(exec, ni);
 }
@@ -199,7 +199,7 @@ JSValue *DOMNodeFilterProtoFunc::callAsFunction(ExecState *exec, JSObject *thisO
   return jsUndefined();
 }
 
-JSValue *getDOMNodeFilter(ExecState *exec, NodeFilterImpl *nf)
+JSValue *toJS(ExecState *exec, NodeFilterImpl *nf)
 {
     return cacheDOMObject<NodeFilterImpl, DOMNodeFilter>(exec, nf);
 }
@@ -263,15 +263,15 @@ JSValue *DOMTreeWalker::getValueProperty(ExecState *exec, int token) const
   TreeWalkerImpl &tw = *m_impl;
   switch (token) {
   case Root:
-    return getDOMNode(exec,tw.root());
+    return toJS(exec,tw.root());
   case WhatToShow:
     return jsNumber(tw.whatToShow());
   case Filter:
-    return getDOMNodeFilter(exec,tw.filter());
+    return toJS(exec,tw.filter());
   case ExpandEntityReferences:
     return jsBoolean(tw.expandEntityReferences());
   case CurrentNode:
-    return getDOMNode(exec,tw.currentNode());
+    return toJS(exec,tw.currentNode());
   default:
     return 0;
   }
@@ -295,24 +295,24 @@ JSValue *DOMTreeWalkerProtoFunc::callAsFunction(ExecState *exec, JSObject *thisO
   TreeWalkerImpl &treeWalker = *static_cast<DOMTreeWalker *>(thisObj)->impl();
   switch (id) {
     case DOMTreeWalker::ParentNode:
-      return getDOMNode(exec,treeWalker.parentNode());
+      return toJS(exec,treeWalker.parentNode());
     case DOMTreeWalker::FirstChild:
-      return getDOMNode(exec,treeWalker.firstChild());
+      return toJS(exec,treeWalker.firstChild());
     case DOMTreeWalker::LastChild:
-      return getDOMNode(exec,treeWalker.lastChild());
+      return toJS(exec,treeWalker.lastChild());
     case DOMTreeWalker::PreviousSibling:
-      return getDOMNode(exec,treeWalker.previousSibling());
+      return toJS(exec,treeWalker.previousSibling());
     case DOMTreeWalker::NextSibling:
-      return getDOMNode(exec,treeWalker.nextSibling());
+      return toJS(exec,treeWalker.nextSibling());
     case DOMTreeWalker::PreviousNode:
-      return getDOMNode(exec,treeWalker.previousNode());
+      return toJS(exec,treeWalker.previousNode());
     case DOMTreeWalker::NextNode:
-      return getDOMNode(exec,treeWalker.nextNode());
+      return toJS(exec,treeWalker.nextNode());
   }
   return jsUndefined();
 }
 
-JSValue *getDOMTreeWalker(ExecState *exec, TreeWalkerImpl *tw)
+JSValue *toJS(ExecState *exec, TreeWalkerImpl *tw)
 {
   return cacheDOMObject<TreeWalkerImpl, DOMTreeWalker>(exec, tw);
 }
@@ -338,7 +338,7 @@ short JSNodeFilterCondition::acceptNode(NodeImpl* filterNode) const
         JSLock lock;
         ExecState *exec = proxy->interpreter()->globalExec();
         List args;
-        args.append(getDOMNode(exec, node));
+        args.append(toJS(exec, node));
         JSObject *obj = filter;
         JSValue *result = obj->call(exec, obj, args);
         return result->toInt32(exec);
index 78cffea..c15c08a 100644 (file)
@@ -93,10 +93,10 @@ namespace KJS {
     RefPtr<WebCore::TreeWalkerImpl> m_impl;
   };
 
-  JSValue* getDOMNodeIterator(ExecState*, WebCore::NodeIteratorImpl*);
+  JSValue* toJS(ExecState*, WebCore::NodeIteratorImpl*);
   JSValue* getNodeFilterConstructor(ExecState*);
-  JSValue* getDOMNodeFilter(ExecState*, WebCore::NodeFilterImpl*);
-  JSValue* getDOMTreeWalker(ExecState*, WebCore::TreeWalkerImpl*);
+  JSValue* toJS(ExecState*, WebCore::NodeFilterImpl*);
+  JSValue* toJS(ExecState*, WebCore::TreeWalkerImpl*);
 
   WebCore::NodeFilterImpl* toNodeFilter(const JSValue*); // returns 0 if value is not a DOMNodeFilter
 
index 249c779..d996582 100644 (file)
@@ -69,7 +69,7 @@ DOMAbstractView::~DOMAbstractView()
 JSValue *DOMAbstractView::getValueProperty(ExecState *exec, int token)
 {
     assert(token == Document);
-    return getDOMNode(exec, impl()->document());
+    return toJS(exec, impl()->document());
 }
 
 bool DOMAbstractView::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
@@ -90,7 +90,7 @@ JSValue *DOMAbstractViewProtoFunc::callAsFunction(ExecState *exec, JSObject *thi
         else {
           if (DocumentImpl* doc = arg0->getDocument())
             doc->updateLayoutIgnorePendingStylesheets();
-          return getDOMCSSStyleDeclaration(exec, abstractView.getComputedStyle(arg0, args[1]->toString(exec).domString().impl()));
+          return toJS(exec, abstractView.getComputedStyle(arg0, args[1]->toString(exec).domString().impl()));
         }
       }
     case DOMAbstractView::GetMatchedCSSRules: {
@@ -99,7 +99,7 @@ JSValue *DOMAbstractViewProtoFunc::callAsFunction(ExecState *exec, JSObject *thi
             return jsUndefined(); // throw exception?
         else {
             // No need to update layout, since we just want the back-end rules.
-            return getDOMCSSRuleList(exec, abstractView.getMatchedCSSRules(arg0,
+            return toJS(exec, abstractView.getMatchedCSSRules(arg0,
                                      args[1]->toString(exec).domString().impl()).get());
         }
     }
@@ -107,7 +107,7 @@ JSValue *DOMAbstractViewProtoFunc::callAsFunction(ExecState *exec, JSObject *thi
   return jsUndefined();
 }
 
-JSValue *getDOMAbstractView(ExecState *exec, AbstractViewImpl *av)
+JSValue *toJS(ExecState *exec, AbstractViewImpl *av)
 {
   return cacheDOMObject<AbstractViewImpl, DOMAbstractView>(exec, av);
 }
index dca5e22..6429267 100644 (file)
@@ -18,8 +18,8 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#ifndef _KJS_VIEWS_H_
-#define _KJS_VIEWS_H_
+#ifndef KJS_VIEWS_H_
+#define KJS_VIEWS_H_
 
 #include "kjs_dom.h"
 
@@ -44,7 +44,7 @@ namespace KJS {
     RefPtr<DOM::AbstractViewImpl> m_impl;
   };
 
-  JSValue *getDOMAbstractView(ExecState *exec, DOM::AbstractViewImpl *av);
+  JSValue* toJS(ExecState*, WebCore::AbstractViewImpl*);
 
   DOM::AbstractViewImpl *toAbstractView(JSValue *);
 
index 80686f5..0b5821f 100644 (file)
@@ -689,7 +689,7 @@ JSValue *Window::getValueProperty(ExecState *exec, int token) const
     case Event:
       if (!m_evt)
         return jsUndefined();
-      return getDOMEvent(exec, m_evt);
+      return toJS(exec, m_evt);
     case InnerHeight:
       if (!m_frame->view())
         return jsUndefined();
@@ -814,7 +814,7 @@ JSValue *Window::getValueProperty(ExecState *exec, int token) const
       if (DocumentImpl *doc = m_frame->document())
         if (ElementImpl *fe = doc->ownerElement())
           if (checkNodeSecurity(exec, fe)) {
-            return getDOMNode(exec, fe);
+            return toJS(exec, fe);
           }
       return jsUndefined();
    }
@@ -830,7 +830,7 @@ JSValue *Window::getValueProperty(ExecState *exec, int token) const
        m_frame->write("<HTML><BODY>");
        m_frame->end();
      }
-     return getDOMNode(exec, m_frame->document());
+     return toJS(exec, m_frame->document());
    case Onabort:
      return getListener(exec, abortEvent);
    case Onblur:
@@ -918,7 +918,7 @@ JSValue *Window::namedItemGetter(ExecState *exec, JSObject *originalObject, cons
   DOMString name = propertyName.domString();
   RefPtr<DOM::HTMLCollectionImpl> collection = doc->windowNamedItems(name);
   if (collection->length() == 1)
-    return getDOMNode(exec, collection->firstItem());
+    return toJS(exec, collection->firstItem());
   else 
     return getHTMLCollection(exec, collection.get());
 }
@@ -2315,17 +2315,17 @@ JSValue *Selection::getValueProperty(ExecState *exec, int token) const
         
     switch (token) {
     case AnchorNode:
-        return getDOMNode(exec, s.anchorNode());
+        return toJS(exec, s.anchorNode());
     case BaseNode:
-        return getDOMNode(exec, s.baseNode());
+        return toJS(exec, s.baseNode());
     case AnchorOffset:
         return jsNumber(s.anchorOffset());
     case BaseOffset:
         return jsNumber(s.baseOffset());
     case FocusNode:
-        return getDOMNode(exec, s.focusNode());
+        return toJS(exec, s.focusNode());
     case ExtentNode:
-        return getDOMNode(exec, s.extentNode());
+        return toJS(exec, s.extentNode());
     case FocusOffset:
         return jsNumber(s.focusOffset());
     case ExtentOffset:
@@ -2390,7 +2390,7 @@ JSValue *SelectionFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const
                 s.modify(args[0]->toString(exec).domString(), args[1]->toString(exec).domString(), args[2]->toString(exec).domString());
                 break;
             case Selection::GetRangeAt:
-                return getDOMRange(exec, s.getRangeAt(args[0]->toInt32(exec)).get());
+                return toJS(exec, s.getRangeAt(args[0]->toInt32(exec)).get());
             case Selection::ToString:
                 return jsString(s.toString());
         }
index 6b2575d..e68dd4a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #include "config.h"
-#include "html/html_canvasimpl.h"
-#include "htmlnames.h"
+#include "html_canvasimpl.h"
 
+#include "CanvasGradient.h"
+#include "CanvasPattern.h"
+#include "CanvasRenderingContext2D.h"
+#include "CanvasStyle.h"
+#include "htmlnames.h"
 #include "render_canvasimage.h"
 
 namespace WebCore {
 
 using namespace HTMLNames;
 
-// -------------------------------------------------------------------------
-
 HTMLCanvasElementImpl::HTMLCanvasElementImpl(DocumentImpl *doc)
-    : HTMLImageElementImpl(canvasTag, doc)
+    : HTMLImageElementImpl(canvasTag, doc), m_2DContext(0)
+{
+}
+
+HTMLCanvasElementImpl::~HTMLCanvasElementImpl()
 {
+    if (m_2DContext)
+        m_2DContext->detachCanvas();
 }
 
 bool HTMLCanvasElementImpl::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
@@ -72,6 +80,9 @@ void HTMLCanvasElementImpl::detach()
 {
     // Don't want to call image's detach().
     HTMLElementImpl::detach();
+
+    if (m_2DContext)
+        m_2DContext->reset();
 }
 
 bool HTMLCanvasElementImpl::isURLAttribute(AttributeImpl *attr) const
@@ -79,4 +90,42 @@ bool HTMLCanvasElementImpl::isURLAttribute(AttributeImpl *attr) const
     return ((attr->name() == usemapAttr && attr->value().domString()[0] != '#'));
 }
 
+CanvasRenderingContext* HTMLCanvasElementImpl::getContext(const String& type)
+{
+    // FIXME: Web Applications 1.0 says "2d" only, but the code here matches historical behavior of WebKit.
+    if (type.isNull() || type == "2d" || type == "2D") {
+        if (!m_2DContext)
+            m_2DContext = new CanvasRenderingContext2D(this);
+        return m_2DContext.get();
+    }
+    return 0;
+}
+
+IntSize HTMLCanvasElementImpl::size() const
+{
+    RenderCanvasImage* canvasRenderer = static_cast<RenderCanvasImage*>(renderer());
+    if (!canvasRenderer)
+        return IntSize();
+#if __APPLE__
+    if (CGContextRef context = canvasRenderer->drawingContext())
+        return IntSize(CGBitmapContextGetWidth(context), CGBitmapContextGetHeight(context));
+#endif
+    return IntSize();
+}
+
+#if __APPLE__
+
+CGImageRef HTMLCanvasElementImpl::createPlatformImage() const
+{
+    RenderCanvasImage* canvasRenderer = static_cast<RenderCanvasImage*>(renderer());
+    if (!canvasRenderer)
+        return 0;
+    CGContextRef context = canvasRenderer->drawingContext();
+    if (!context)
+        return 0;
+    return CGBitmapContextCreateImage(context);
+}
+
+#endif
+
 }
index 595dba9..5748bca 100644 (file)
 
 #include "html_imageimpl.h"
 
+#if __APPLE__
+typedef struct CGImage* CGImageRef;
+#endif
+
 namespace WebCore {
 
-class HTMLCanvasElementImpl
-    : public HTMLImageElementImpl
-{
+class CanvasRenderingContext2D;
+typedef CanvasRenderingContext2D CanvasRenderingContext;
+
+// FIXME: Should inherit from HTMLElementImpl instead of HTMLImageElementImpl.
+class HTMLCanvasElementImpl : public HTMLImageElementImpl {
 public:
     HTMLCanvasElementImpl(DocumentImpl*);
+    ~HTMLCanvasElementImpl();
+
+    CanvasRenderingContext* getContext(const String&);
+
+    // FIXME: Web Applications 1.0 describes a toDataURL function.
 
     virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
     virtual void parseMappedAttribute(MappedAttributeImpl*);
@@ -44,6 +55,17 @@ public:
     virtual void detach();
     
     virtual bool isURLAttribute(AttributeImpl*) const;
+
+    IntSize size() const;
+
+#if __APPLE__
+    CGImageRef createPlatformImage() const;
+#endif
+
+private:
+    RefPtr<CanvasRenderingContext2D> m_2DContext;
+    // FIXME: Web Applications 1.0 describes a security feature where we track if we ever drew
+    // any images outside the domain.
 };
 
 } //namespace
index 7a81c76..c783387 100644 (file)
@@ -500,9 +500,9 @@ void HTMLMapElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
         HTMLElementImpl::parseMappedAttribute(attr);
 }
 
-RefPtr<HTMLCollectionImpl> HTMLMapElementImpl::areas()
+PassRefPtr<HTMLCollectionImpl> HTMLMapElementImpl::areas()
 {
-    return RefPtr<HTMLCollectionImpl>(new HTMLCollectionImpl(this, HTMLCollectionImpl::MAP_AREAS));
+    return new HTMLCollectionImpl(this, HTMLCollectionImpl::MAP_AREAS);
 }
 
 DOMString HTMLMapElementImpl::name() const
index 121cfc9..6dcbd68 100644 (file)
 
 namespace WebCore {
 
-class DOMString;
 class HTMLCollectionImpl;
 class HTMLFormElementImpl;
 class Image;
+class String;
 
 struct Length;
 
 class HTMLImageLoader : public CachedObjectClient {
 public:
-    HTMLImageLoader(ElementImpl* elt);
+    HTMLImageLoader(ElementImpl*);
     virtual ~HTMLImageLoader();
 
     virtual void updateFromElement();
@@ -54,11 +54,10 @@ public:
     CachedImage* image() const { return m_image; }
 
     // CachedObjectClient API
-    virtual void notifyFinished(CachedObject *finishedObj);
+    virtual void notifyFinished(CachedObject*);
 
 protected:
-
-    void setLoadingImage(CachedImage *loadingImage);
+    void setLoadingImage(CachedImage*);
 
 private:
     ElementImpl* m_element;
@@ -67,93 +66,90 @@ private:
     bool m_imageComplete : 1;
 };
 
-class HTMLImageElementImpl : public HTMLElementImpl
-{
+class HTMLImageElementImpl : public HTMLElementImpl {
     friend class HTMLFormElementImpl;
 public:
-    HTMLImageElementImpl(DocumentImpl *doc, HTMLFormElementImpl *f = 0);
-    HTMLImageElementImpl(const QualifiedName& tagName, DocumentImpl* doc);
+    HTMLImageElementImpl(DocumentImpl*, HTMLFormElementImpl* = 0);
+    HTMLImageElementImpl(const QualifiedName& tagName, DocumentImpl*);
     ~HTMLImageElementImpl();
 
     virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
     virtual int tagPriority() const { return 0; }
 
     virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
-    virtual void parseMappedAttribute(MappedAttributeImpl *);
+    virtual void parseMappedAttribute(MappedAttributeImpl*);
 
     virtual void attach();
-    virtual RenderObject *createRenderer(RenderArena *, RenderStyle *);
+    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     virtual void insertedIntoDocument();
     virtual void removedFromDocument();
 
     int width(bool ignorePendingStylesheets = false) const;
     int height(bool ignorePendingStylesheets = false) const;
 
-    bool isServerMap() const { return ( ismap && !usemap.length() );  }
+    bool isServerMap() const { return ismap && usemap.isEmpty(); }
 
-    DOMString altText() const;
+    String altText() const;
 
-    DOMString imageMap() const { return usemap; }
+    String imageMap() const { return usemap; }
     
-    virtual bool isURLAttribute(AttributeImpl *attr) const;
+    virtual bool isURLAttribute(AttributeImpl*) const;
 
     Image::CompositeOperator compositeOperator() const { return Image::compositeOperatorFromString(_compositeOperator.ascii()); }
 
-    CachedImage* cachedImage() { return m_imageLoader.image(); }
+    CachedImage* cachedImage() const { return m_imageLoader.image(); }
     
-    DOMString name() const;
-    void setName( const DOMString & );
+    String name() const;
+    void setName(const String&);
 
-    DOMString align() const;
-    void setAlign( const DOMString & );
+    String align() const;
+    void setAlign(const String&);
 
-    DOMString alt() const;
-    void setAlt( const DOMString & );
+    String alt() const;
+    void setAlt(const String&);
 
     int border() const;
-    void setBorder( int );
+    void setBorder(int);
 
-    void setHeight( int );
+    void setHeight(int);
 
     int hspace() const;
-    void setHspace( int );
+    void setHspace(int);
 
     bool isMap() const;
-    void setIsMap( bool );
+    void setIsMap(bool);
 
-    DOMString longDesc() const;
-    void setLongDesc( const DOMString & );
+    String longDesc() const;
+    void setLongDesc(const String&);
 
-    DOMString src() const;
-    void setSrc( const DOMString & );
+    String src() const;
+    void setSrc(const String&);
 
-    DOMString useMap() const;
-    void setUseMap( const DOMString & );
+    String useMap() const;
+    void setUseMap(const String&);
 
     int vspace() const;
-    void setVspace( int );
+    void setVspace(int);
 
-    void setWidth( int );
+    void setWidth(int);
 
     int x() const;
     int y() const;
 
     bool complete() const;
-    
+
 protected:
     HTMLImageLoader m_imageLoader;
-    DOMString usemap;
+    String usemap;
     bool ismap;
-    HTMLFormElementImpl *m_form;
-    DOMString oldNameAttr;
+    HTMLFormElementImplm_form;
+    String oldNameAttr;
     QString _compositeOperator;
 };
 
-
 //------------------------------------------------------------------
 
-class HTMLAreaElementImpl : public HTMLAnchorElementImpl
-{
+class HTMLAreaElementImpl : public HTMLAnchorElementImpl {
 public:
     enum Shape { Default, Poly, Rect, Circle, Unknown };
 
@@ -163,7 +159,7 @@ public:
     virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
     virtual int tagPriority() const { return 0; }
 
-    virtual void parseMappedAttribute(MappedAttributeImpl *attr);
+    virtual void parseMappedAttribute(MappedAttributeImpl*);
 
     bool isDefault() const { return m_shape == Default; }
 
@@ -171,29 +167,29 @@ public:
 
     virtual IntRect getRect(RenderObject*) const;
 
-    DOMString accessKey() const;
-    void setAccessKey( const DOMString & );
+    String accessKey() const;
+    void setAccessKey(const String&);
 
-    DOMString alt() const;
-    void setAlt( const DOMString & );
+    String alt() const;
+    void setAlt(const String&);
 
-    DOMString coords() const;
-    void setCoords( const DOMString & );
+    String coords() const;
+    void setCoords(const String&);
 
-    DOMString href() const;
-    void setHref( const DOMString & );
+    String href() const;
+    void setHref(const String&);
 
     bool noHref() const;
-    void setNoHref( bool );
+    void setNoHref(bool);
 
-    DOMString shape() const;
-    void setShape( const DOMString & );
+    String shape() const;
+    void setShape(const String&);
 
     int tabIndex() const;
-    void setTabIndex( int );
+    void setTabIndex(int);
 
-    DOMString target() const;
-    void setTarget( const DOMString & );
+    String target() const;
+    void setTarget(const String&);
 
 protected:
     Path getRegion(int width, int height) const;
@@ -204,13 +200,11 @@ protected:
     Shape m_shape;
 };
 
-
 // -------------------------------------------------------------------------
 
-class HTMLMapElementImpl : public HTMLElementImpl
-{
+class HTMLMapElementImpl : public HTMLElementImpl {
 public:
-    HTMLMapElementImpl(DocumentImpl *doc);
+    HTMLMapElementImpl(DocumentImpl*);
     ~HTMLMapElementImpl();
 
     virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
@@ -223,10 +217,10 @@ public:
 
     bool mapMouseEvent(int x, int y, int width, int height, RenderObject::NodeInfo&);
 
-    RefPtr<HTMLCollectionImpl> areas();
+    PassRefPtr<HTMLCollectionImpl> areas();
 
-    DOMString name() const;
-    void setName( const DOMString & );
+    String name() const;
+    void setName(const String&);
 
 private:
     AtomicString m_name;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 8212dcc..5f55b75 100644 (file)
 
 #include "config.h"
 #include "Image.h"
-#include <kxmlcore/Vector.h>
+
 #include "Array.h"
+#include "FloatRect.h"
 #include "Image.h"
+#include "ImageAnimationObserver.h"
 #include "ImageSource.h"
 #include "IntRect.h"
-#include "FloatRect.h"
-#include "ImageAnimationObserver.h"
+#include "PlatformString.h"
 #include "Timer.h"
+#include <kxmlcore/Vector.h>
 
 #if __APPLE__
 // FIXME: Will go away when we make PDF a subclass.
@@ -328,22 +330,13 @@ struct CompositeOperatorEntry compositeOperators[NUM_COMPOSITE_OPERATORS] = {
     { "lighter", Image::CompositePlusLighter }
 };
 
-Image::CompositeOperator Image::compositeOperatorFromString(const char* aString)
+Image::CompositeOperator Image::compositeOperatorFromString(const String& s)
 {
     CompositeOperator op = CompositeSourceOver;
-    
-    if (strlen(aString)) {
-        for (int i = 0; i < NUM_COMPOSITE_OPERATORS; i++) {
-#if WIN32
-            // FIXME: Use the new String class 
-            if (strcmp(aString, compositeOperators[i].name) == 0) {
-#else
-            if (strcasecmp(aString, compositeOperators[i].name) == 0) {
-#endif
+    if (!s.isEmpty())
+        for (int i = 0; i < NUM_COMPOSITE_OPERATORS; i++)
+            if (equalIgnoringCase(s, compositeOperators[i].name))
                 return compositeOperators[i].value;
-            }
-        }
-    }
     return op;
 }
 
index f0ac2d8..f59f627 100644 (file)
@@ -59,6 +59,7 @@ class FloatPoint;
 class FloatRect;
 class IntRect;
 class IntSize;
+class String;
 
 template <typename T> class Timer;
 
@@ -158,7 +159,7 @@ public:
 
     enum TileRule { StretchTile, RoundTile, RepeatTile };
 
-    static CompositeOperator compositeOperatorFromString(const char* compositeOperator);
+    static CompositeOperator compositeOperatorFromString(const String&);
 
     // Drawing routines.
     void drawInRect(const FloatRect& dstRect, const FloatRect& srcRect,
old mode 100755 (executable)
new mode 100644 (file)