2006-05-17 Anders Carlsson <acarlsson@apple.com>
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 May 2006 21:10:02 +0000 (21:10 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 May 2006 21:10:02 +0000 (21:10 +0000)
        Reviewed by Maciej.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=8958
        Should be able to have custom implementations for JS methods

        * DerivedSources.make:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/JSCanvasRenderingContext2DBase.cpp: Removed.
        * bindings/js/JSCanvasRenderingContext2DBase.h: Removed.
        * bindings/js/JSCanvasRenderingContext2DCustom.cpp: Added.
        Remove JSCanvasRenderingContext2DBase and add
        JSCanvasRenderingContext2DCustom with custom implementations.

        (WebCore::toJS):
        (WebCore::toHTMLCanvasStyle):
        (WebCore::JSCanvasRenderingContext2D::strokeStyle):
        (WebCore::JSCanvasRenderingContext2D::setStrokeStyle):
        (WebCore::JSCanvasRenderingContext2D::fillStyle):
        (WebCore::JSCanvasRenderingContext2D::setFillStyle):
        (WebCore::JSCanvasRenderingContext2D::setFillColor):
        (WebCore::JSCanvasRenderingContext2D::setStrokeColor):
        (WebCore::JSCanvasRenderingContext2D::strokeRect):
        (WebCore::JSCanvasRenderingContext2D::drawImage):
        (WebCore::JSCanvasRenderingContext2D::drawImageFromRect):
        (WebCore::JSCanvasRenderingContext2D::setShadow):
        (WebCore::JSCanvasRenderingContext2D::createPattern):
        Move implementations from JSCanvasRenderingContext2DBase.

        * bindings/scripts/CodeGeneratorJS.pm:
        Add new "Custom" extended attribute for functions and attributes. When a function or
        attribute has this attribute, a custom implementation is called instead of calling down to
        the DOM object.

        * html/CanvasRenderingContext2D.idl:
        Add bunch of custom attributes and functions.

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

WebCore/ChangeLog
WebCore/DerivedSources.make
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSCanvasRenderingContext2DBase.cpp [deleted file]
WebCore/bindings/js/JSCanvasRenderingContext2DBase.h [deleted file]
WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp [new file with mode: 0644]
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/html/CanvasRenderingContext2D.idl

index 6d4d3d9..c4485ff 100644 (file)
@@ -1,3 +1,41 @@
+2006-05-17  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=8958
+        Should be able to have custom implementations for JS methods
+        
+        * DerivedSources.make:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSCanvasRenderingContext2DBase.cpp: Removed.
+        * bindings/js/JSCanvasRenderingContext2DBase.h: Removed.
+        * bindings/js/JSCanvasRenderingContext2DCustom.cpp: Added.
+        Remove JSCanvasRenderingContext2DBase and add 
+        JSCanvasRenderingContext2DCustom with custom implementations.
+        
+        (WebCore::toJS):
+        (WebCore::toHTMLCanvasStyle):
+        (WebCore::JSCanvasRenderingContext2D::strokeStyle):
+        (WebCore::JSCanvasRenderingContext2D::setStrokeStyle):
+        (WebCore::JSCanvasRenderingContext2D::fillStyle):
+        (WebCore::JSCanvasRenderingContext2D::setFillStyle):
+        (WebCore::JSCanvasRenderingContext2D::setFillColor):
+        (WebCore::JSCanvasRenderingContext2D::setStrokeColor):
+        (WebCore::JSCanvasRenderingContext2D::strokeRect):
+        (WebCore::JSCanvasRenderingContext2D::drawImage):
+        (WebCore::JSCanvasRenderingContext2D::drawImageFromRect):
+        (WebCore::JSCanvasRenderingContext2D::setShadow):
+        (WebCore::JSCanvasRenderingContext2D::createPattern):
+        Move implementations from JSCanvasRenderingContext2DBase.
+        
+        * bindings/scripts/CodeGeneratorJS.pm:
+        Add new "Custom" extended attribute for functions and attributes. When a function or 
+        attribute has this attribute, a custom implementation is called instead of calling down to
+        the DOM object.
+        
+        * html/CanvasRenderingContext2D.idl:
+        Add bunch of custom attributes and functions.
+
 2006-05-17  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Maciej.
index 72d694c..da67ed9 100644 (file)
@@ -50,7 +50,6 @@ all : \
     JSCanvasGradient.h \
     JSCanvasPattern.h \
     JSCanvasRenderingContext2D.h \
-    JSCanvasRenderingContext2DBaseTable.cpp \
     JSCharacterData.h \
     JSCounter.h \
     JSCSSStyleDeclaration.h \
index 0c68b10..2438b06 100644 (file)
@@ -99,6 +99,7 @@
                1A762C7A0A074F2600989F5B /* JSXPathResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A762C720A074F2600989F5B /* JSXPathResult.h */; };
                1A820D910A13EBA600AF843C /* ImageDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A820D8F0A13EBA600AF843C /* ImageDocument.cpp */; settings = {COMPILER_FLAGS = "-xobjective-c++"; }; };
                1A820D920A13EBA600AF843C /* ImageDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A820D900A13EBA600AF843C /* ImageDocument.h */; };
+               1A9EF4570A1B957D00332B63 /* JSCanvasRenderingContext2DCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9EF4560A1B957D00332B63 /* JSCanvasRenderingContext2DCustom.cpp */; };
                550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
                550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; };
                550A0BCD085F604D007353D6 /* HTMLNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BCB085F604D007353D6 /* HTMLNames.cpp */; };
                930705DA09E0C9BF00B17FE4 /* JSCounter.h in Headers */ = {isa = PBXBuildFile; fileRef = 930705D909E0C9BF00B17FE4 /* JSCounter.h */; };
                930705E909E0C9F000B17FE4 /* JSCSSPrimitiveValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 930705E809E0C9F000B17FE4 /* JSCSSPrimitiveValue.cpp */; };
                930705EB09E0C9F600B17FE4 /* JSCSSPrimitiveValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 930705EA09E0C9F600B17FE4 /* JSCSSPrimitiveValue.h */; };
-               930CAD1509C4F3C300229C04 /* JSCanvasRenderingContext2DBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 930CAD1409C4F3C300229C04 /* JSCanvasRenderingContext2DBase.h */; };
-               930CAD2609C4F49100229C04 /* JSCanvasRenderingContext2DBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 930CAD2509C4F49100229C04 /* JSCanvasRenderingContext2DBase.cpp */; };
                93126F6109D7A736008D9626 /* StringHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 93126F6009D7A736008D9626 /* StringHash.h */; };
                9326DC0B09DAD5BE00AFC847 /* CharsetData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9326DC0A09DAD5BE00AFC847 /* CharsetData.h */; };
                9326DC0C09DAD5D600AFC847 /* CharsetData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 656581AC09D14EE6000E61D7 /* CharsetData.cpp */; };
                1A762C720A074F2600989F5B /* JSXPathResult.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSXPathResult.h; sourceTree = "<group>"; };
                1A820D8F0A13EBA600AF843C /* ImageDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDocument.cpp; sourceTree = "<group>"; };
                1A820D900A13EBA600AF843C /* ImageDocument.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ImageDocument.h; sourceTree = "<group>"; };
+               1A9EF4560A1B957D00332B63 /* JSCanvasRenderingContext2DCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCanvasRenderingContext2DCustom.cpp; sourceTree = "<group>"; };
                2D90660B0665D937006B6F1A /* ClipboardMac.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ClipboardMac.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                2D90660C0665D937006B6F1A /* ClipboardMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ClipboardMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                4758C44308C5F217009BAF05 /* KCanvasPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasPath.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                656581AD09D14EE6000E61D7 /* ColorData.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = ColorData.c; sourceTree = "<group>"; };
                656581AE09D14EE6000E61D7 /* UserAgentStyleSheets.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = UserAgentStyleSheets.h; sourceTree = "<group>"; };
                656581AF09D14EE6000E61D7 /* UserAgentStyleSheetsData.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = UserAgentStyleSheetsData.cpp; sourceTree = "<group>"; };
-               656581D509D1508D000E61D7 /* JSCanvasRenderingContext2DBaseTable.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSCanvasRenderingContext2DBaseTable.cpp; sourceTree = "<group>"; };
                656581D609D1508D000E61D7 /* JSDOMParser.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSDOMParser.lut.h; sourceTree = "<group>"; };
                656581D709D1508D000E61D7 /* JSXMLHttpRequest.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSXMLHttpRequest.lut.h; sourceTree = "<group>"; };
                656581D809D1508D000E61D7 /* JSXMLSerializer.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSXMLSerializer.lut.h; 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 = ../scripts/CodeGeneratorJS.pm; sourceTree = "<group>"; };
-               930CAD1409C4F3C300229C04 /* JSCanvasRenderingContext2DBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCanvasRenderingContext2DBase.h; sourceTree = "<group>"; };
-               930CAD2509C4F49100229C04 /* JSCanvasRenderingContext2DBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCanvasRenderingContext2DBase.cpp; sourceTree = "<group>"; };
                93126F6009D7A736008D9626 /* StringHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringHash.h; sourceTree = "<group>"; };
                9326DC0A09DAD5BE00AFC847 /* CharsetData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CharsetData.h; sourceTree = "<group>"; };
                9327A94109968D1A0068A546 /* HTMLOptionsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLOptionsCollection.cpp; sourceTree = "<group>"; };
                                65DF323609D1DE65000BE325 /* JSCanvasPattern.h */,
                                65DF323709D1DE65000BE325 /* JSCanvasRenderingContext2D.cpp */,
                                65DF323809D1DE65000BE325 /* JSCanvasRenderingContext2D.h */,
-                               656581D509D1508D000E61D7 /* JSCanvasRenderingContext2DBaseTable.cpp */,
                                65DF31DF09D1CC60000BE325 /* JSCharacterData.cpp */,
                                65DF31E009D1CC60000BE325 /* JSCharacterData.h */,
                                930705D709E0C9B700B17FE4 /* JSCounter.cpp */,
                        isa = PBXGroup;
                        children = (
                                930CAB9609C49FAA00229C04 /* CodeGeneratorJS.pm */,
-                               930CAD2509C4F49100229C04 /* JSCanvasRenderingContext2DBase.cpp */,
-                               930CAD1409C4F3C300229C04 /* JSCanvasRenderingContext2DBase.h */,
+                               1A9EF4560A1B957D00332B63 /* JSCanvasRenderingContext2DCustom.cpp */,
                                93B70D3F09EB0C7C009D8468 /* JSDOMParser.cpp */,
                                93B70D4009EB0C7C009D8468 /* JSDOMParser.h */,
                                938E65F609F0985D008A48EC /* JSHTMLElementWrapperFactory.cpp */,
                                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 */,
                                6522BCDF09C9DAA800C9BA7A /* ResourceRequest.h in Headers */,
                                93C841F809CE855C00DFF5E5 /* DOMImplementationFront.h in Headers */,
                                93EEC20209C2877700C515D1 /* CanvasGradient.cpp in Sources */,
                                93EEC26F09C3218000C515D1 /* CanvasPattern.cpp in Sources */,
                                93EEC27109C3218800C515D1 /* CanvasStyle.cpp in Sources */,
-                               930CAD2609C4F49100229C04 /* JSCanvasRenderingContext2DBase.cpp in Sources */,
                                D0B0556909C6700100307E43 /* CreateLinkCommand.cpp in Sources */,
                                93C841FF09CE858300DFF5E5 /* DOMImplementationFront.cpp in Sources */,
                                650F53DD09D15DDF00C9B0C8 /* CSSGrammar.cpp in Sources */,
                                A80E7B120A19D606007FB8C5 /* JSHTMLBaseElement.cpp in Sources */,
                                A80E7B130A19D606007FB8C5 /* JSHTMLTitleElement.cpp in Sources */,
                                A80E7B140A19D606007FB8C5 /* JSHTMLHeadElement.cpp in Sources */,
+                               1A9EF4570A1B957D00332B63 /* JSCanvasRenderingContext2DCustom.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/WebCore/bindings/js/JSCanvasRenderingContext2DBase.cpp b/WebCore/bindings/js/JSCanvasRenderingContext2DBase.cpp
deleted file mode 100644 (file)
index 0818aa4..0000000
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * 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 "ExceptionCode.h"
-#include "HTMLCanvasElement.h"
-#include "HTMLImageElement.h"
-#include "JSCanvasGradient.h"
-#include "JSCanvasPattern.h"
-#include "JSCanvasRenderingContext2D.h"
-#include "JSHTMLCanvasElement.h"
-
-#include "kjs_html.h"
-
-#include "JSCanvasRenderingContext2DBaseTable.cpp"
-
-using namespace KJS;
-
-namespace WebCore {
-
-/*
-@begin JSCanvasRenderingContext2DBaseProtoTable 7
-  setStrokeColor           WebCore::JSCanvasRenderingContext2DBase::SetStrokeColor              DontDelete|Function 1
-  setFillColor             WebCore::JSCanvasRenderingContext2DBase::SetFillColor                DontDelete|Function 1
-  strokeRect               WebCore::JSCanvasRenderingContext2DBase::StrokeRect                  DontDelete|Function 4
-  drawImage                WebCore::JSCanvasRenderingContext2DBase::DrawImage                   DontDelete|Function 3
-  drawImageFromRect        WebCore::JSCanvasRenderingContext2DBase::DrawImageFromRect           DontDelete|Function 10
-  setShadow                WebCore::JSCanvasRenderingContext2DBase::SetShadow                   DontDelete|Function 3
-  createPattern            WebCore::JSCanvasRenderingContext2DBase::CreatePattern               DontDelete|Function 2
-@end
-@begin JSCanvasRenderingContext2DBaseTable 2
-  strokeStyle              WebCore::JSCanvasRenderingContext2DBase::StrokeStyle                 DontDelete
-  fillStyle                WebCore::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));
-                    else
-                        context->setStrokeColor(args[0]->toNumber(exec));
-                    break;
-                case 2:
-                    if (args[0]->isString())
-                        context->setStrokeColor(args[0]->toString(exec), 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));
-                    else
-                        context->setFillColor(args[0]->toNumber(exec));
-                    break;
-                case 2:
-                    if (args[0]->isString())
-                        context->setFillColor(args[0]->toString(exec), 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: {
-            ExceptionCode ec;
-            if (args.size() <= 4)
-                context->strokeRect(args[0]->toNumber(exec), args[1]->toNumber(exec),
-                    args[2]->toNumber(exec), args[3]->toNumber(exec), ec);
-            else
-                context->strokeRect(args[0]->toNumber(exec), args[1]->toNumber(exec),
-                    args[2]->toNumber(exec), args[3]->toNumber(exec), args[4]->toNumber(exec), ec);
-            setDOMException(exec, ec);
-            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));
-                    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),
-                            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.
-            // The img parameter can be a <img> or <canvas> element.
-            JSObject* o = static_cast<JSObject*>(args[0]);
-            if (!o->isObject())
-                return throwError(exec, TypeError);
-            ExceptionCode ec;
-            if (o->inherits(&KJS::JSHTMLElement::img_info)) {
-                HTMLImageElement* imgElt = static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(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), ec);
-                        setDOMException(exec, ec);
-                        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), ec);
-                        setDOMException(exec, ec);
-                        break;
-                    default:
-                        return throwError(exec, SyntaxError);
-                }
-                break;
-            }
-            if (o->inherits(&JSHTMLCanvasElement::info)) {
-                HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(static_cast<JSHTMLElement*>(args[0])->impl());
-                switch (args.size()) {
-                    case 3:
-                        context->drawImage(canvas, args[1]->toNumber(exec), args[2]->toNumber(exec));
-                        break;
-                    case 5:
-                        context->drawImage(canvas, args[1]->toNumber(exec), args[2]->toNumber(exec),
-                            args[3]->toNumber(exec), args[4]->toNumber(exec), ec);
-                        setDOMException(exec, ec);
-                        break;
-                    case 9:
-                        context->drawImage(canvas, 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), ec);
-                        setDOMException(exec, ec);
-                        break;
-                    default:
-                        return throwError(exec, SyntaxError);
-                }
-                break;
-            }
-            setDOMException(exec, TYPE_MISMATCH_ERR);
-            return 0;
-        }
-        case JSCanvasRenderingContext2DBase::DrawImageFromRect: {
-            JSObject* o = static_cast<JSObject*>(args[0]);
-            if (!o->isObject())
-                return throwError(exec, TypeError);
-            if (!o->inherits(&KJS::JSHTMLElement::img_info))
-                return throwError(exec, TypeError);
-            context->drawImageFromRect(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(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));
-            break;
-        }
-        case JSCanvasRenderingContext2DBase::CreatePattern:
-            JSObject* o = static_cast<JSObject*>(args[0]);
-            if (!o->isObject())
-                return throwError(exec, TypeError);
-            if (o->inherits(&KJS::JSHTMLElement::img_info)) {
-                ExceptionCode ec;
-                JSValue* pattern = toJS(exec,
-                    context->createPattern(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(args[0])->impl()),
-                        args[1]->toString(exec), ec).get());
-                setDOMException(exec, ec);
-                return pattern;
-            }
-            if (o->inherits(&JSHTMLCanvasElement::info)) {
-                ExceptionCode ec;
-                JSValue* pattern = toJS(exec,
-                    context->createPattern(static_cast<HTMLCanvasElement*>(static_cast<JSHTMLElement*>(args[0])->impl()),
-                        args[1]->toString(exec), ec).get());
-                setDOMException(exec, ec);
-                return pattern;
-            }
-            setDOMException(exec, TYPE_MISMATCH_ERR);
-            return 0;
-    }
-
-    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));
-    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<CanvasRenderingContext2D> impl)
-    : m_impl(impl)
-{
-}
-
-JSCanvasRenderingContext2DBase::~JSCanvasRenderingContext2DBase()
-{
-    ScriptInterpreter::forgetDOMObject(m_impl.get());
-}
-
-JSValue* toJS(ExecState* exec, CanvasRenderingContext2D* context)
-{
-    return cacheDOMObject<CanvasRenderingContext2D, JSCanvasRenderingContext2D>(exec, context);
-}
-
-}
diff --git a/WebCore/bindings/js/JSCanvasRenderingContext2DBase.h b/WebCore/bindings/js/JSCanvasRenderingContext2DBase.h
deleted file mode 100644 (file)
index 4da17ea..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef JSCanvasRenderingContext2DBase_h
-#define JSCanvasRenderingContext2DBase_h
-
-#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;
-    };
-
-    KJS::JSValue* toJS(KJS::ExecState*, CanvasRenderingContext2D*);
-
-}
-
-#endif
diff --git a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp
new file mode 100644 (file)
index 0000000..d194dda
--- /dev/null
@@ -0,0 +1,327 @@
+/*
+ * 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 "CanvasGradient.h"
+#include "CanvasPattern.h"
+#include "CanvasRenderingContext2D.h"
+#include "CanvasStyle.h"
+#include "ExceptionCode.h"
+#include "HTMLCanvasElement.h"
+#include "HTMLImageElement.h"
+#include "JSCanvasGradient.h"
+#include "JSCanvasPattern.h"
+#include "JSCanvasRenderingContext2D.h"
+#include "JSHTMLCanvasElement.h"
+#include "kjs_html.h"
+
+using namespace KJS;
+
+namespace WebCore {
+
+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));
+    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* JSCanvasRenderingContext2D::strokeStyle(ExecState* exec) const
+{
+    return toJS(exec, impl()->strokeStyle());        
+}
+
+void JSCanvasRenderingContext2D::setStrokeStyle(ExecState* exec, JSValue* value)
+{
+    impl()->setStrokeStyle(toHTMLCanvasStyle(exec, value));
+}
+
+JSValue* JSCanvasRenderingContext2D::fillStyle(ExecState* exec) const
+{
+    return toJS(exec, impl()->fillStyle());
+}
+
+void JSCanvasRenderingContext2D::setFillStyle(ExecState* exec, JSValue* value)
+{
+    impl()->setFillStyle(toHTMLCanvasStyle(exec, value));
+}
+
+JSValue* JSCanvasRenderingContext2D::setFillColor(ExecState* exec, const List& args)
+{
+    CanvasRenderingContext2D* context = impl();
+
+    // 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));
+            else
+                context->setFillColor(args[0]->toNumber(exec));
+            break;
+        case 2:
+            if (args[0]->isString())
+                context->setFillColor(args[0]->toString(exec), 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);
+    }
+    return jsUndefined();
+}    
+
+JSValue* JSCanvasRenderingContext2D::setStrokeColor(ExecState* exec, const List& args)
+{ 
+    CanvasRenderingContext2D* context = impl();
+
+    // 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));
+            else
+                context->setStrokeColor(args[0]->toNumber(exec));
+            break;
+        case 2:
+            if (args[0]->isString())
+                context->setStrokeColor(args[0]->toString(exec), 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);
+    }
+    
+    return jsUndefined();
+}
+
+JSValue* JSCanvasRenderingContext2D::strokeRect(ExecState* exec, const List& args)
+{ 
+    CanvasRenderingContext2D* context = impl();    
+    ExceptionCode ec;
+    
+    if (args.size() <= 4)
+        context->strokeRect(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                            args[2]->toNumber(exec), args[3]->toNumber(exec), ec);
+    else
+        context->strokeRect(args[0]->toNumber(exec), args[1]->toNumber(exec),
+                            args[2]->toNumber(exec), args[3]->toNumber(exec), args[4]->toNumber(exec), ec);
+    setDOMException(exec, ec);
+    
+    return jsUndefined();    
+}
+
+JSValue* JSCanvasRenderingContext2D::drawImage(ExecState* exec, const List& args)
+{ 
+    CanvasRenderingContext2D* context = impl();
+
+    // 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.
+    // The img parameter can be a <img> or <canvas> element.
+    JSObject* o = static_cast<JSObject*>(args[0]);
+    if (!o->isObject())
+        return throwError(exec, TypeError);
+    ExceptionCode ec;
+    if (o->inherits(&KJS::JSHTMLElement::img_info)) {
+        HTMLImageElement* imgElt = static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(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), ec);
+                setDOMException(exec, ec);
+                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), ec);
+                setDOMException(exec, ec);
+                break;
+            default:
+                return throwError(exec, SyntaxError);
+        }
+    } else if (o->inherits(&JSHTMLCanvasElement::info)) {
+        HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(static_cast<JSHTMLElement*>(args[0])->impl());
+        switch (args.size()) {
+            case 3:
+                context->drawImage(canvas, args[1]->toNumber(exec), args[2]->toNumber(exec));
+                break;
+            case 5:
+                context->drawImage(canvas, args[1]->toNumber(exec), args[2]->toNumber(exec),
+                                   args[3]->toNumber(exec), args[4]->toNumber(exec), ec);
+                setDOMException(exec, ec);
+                break;
+            case 9:
+                context->drawImage(canvas, 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), ec);
+                setDOMException(exec, ec);
+                break;
+            default:
+                return throwError(exec, SyntaxError);
+        }
+    } else {
+        setDOMException(exec, TYPE_MISMATCH_ERR);
+        return 0;
+    }
+    
+    return jsUndefined();    
+}
+
+JSValue* JSCanvasRenderingContext2D::drawImageFromRect(ExecState* exec, const List& args)
+{ 
+    CanvasRenderingContext2D* context = impl();
+
+    JSObject* o = static_cast<JSObject*>(args[0]);
+    if (!o->isObject())
+        return throwError(exec, TypeError);
+    if (!o->inherits(&KJS::JSHTMLElement::img_info))
+        return throwError(exec, TypeError);
+    context->drawImageFromRect(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(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));    
+    return jsUndefined();    
+}
+
+JSValue* JSCanvasRenderingContext2D::setShadow(ExecState* exec, const List& args)
+{ 
+    CanvasRenderingContext2D* context = impl();
+
+    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));
+            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),
+                                   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);
+    }
+    
+    return jsUndefined();    
+}
+
+JSValue* JSCanvasRenderingContext2D::createPattern(ExecState* exec, const List& args)
+{ 
+    CanvasRenderingContext2D* context = impl();
+
+    JSObject* o = static_cast<JSObject*>(args[0]);
+    if (!o->isObject())
+        return throwError(exec, TypeError);
+    if (o->inherits(&KJS::JSHTMLElement::img_info)) {
+        ExceptionCode ec;
+        JSValue* pattern = toJS(exec,
+            context->createPattern(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(args[0])->impl()),
+                args[1]->toString(exec), ec).get());
+        setDOMException(exec, ec);
+        return pattern;
+    }
+    if (o->inherits(&JSHTMLCanvasElement::info)) {
+        ExceptionCode ec;
+        JSValue* pattern = toJS(exec,
+            context->createPattern(static_cast<HTMLCanvasElement*>(static_cast<JSHTMLElement*>(args[0])->impl()),
+                args[1]->toString(exec), ec).get());
+        setDOMException(exec, ec);
+        return pattern;
+    }
+    setDOMException(exec, TYPE_MISMATCH_ERR);
+    return 0;
+}
+
+}
\ No newline at end of file
index 9010ea1..fda9ded 100644 (file)
@@ -118,9 +118,7 @@ sub GetParentClassName
 sub GetLegacyHeaderIncludes
 {
   my $legacyParent = shift;
-  if ($legacyParent eq "JSCanvasRenderingContext2DBase") {
-    return "#include \"JSCanvasRenderingContext2DBase.h\"\n\n";
-  } elsif ($legacyParent eq "KJS::Window") {
+  if ($legacyParent eq "KJS::Window") {
       return "#include \"kjs_window.h\"\n\n";
   } elsif ($legacyParent eq "KJS::DOMNode") {
       return "#include \"kjs_domnode.h\"\n\n";
@@ -266,6 +264,9 @@ sub GenerateHeader
     push(@headerContent, "    static KJS::JSValue* getConstructor(KJS::ExecState*);\n")
   }
 
+  my $numCustomFunctions = 0;
+  my $numCustomAttributes = 0;
+  
   # Attribute and function enums
   if ($numAttributes + $numFunctions > 0) {
     push(@headerContent, "    enum {\n")
@@ -278,6 +279,8 @@ sub GenerateHeader
     foreach(@{$dataNode->attributes}) {
       my $attribute = $_;
 
+      $numCustomAttributes++ if $attribute->signature->extendedAttributes->{"Custom"};
+
       $i++;
       if((($i % 4) eq 0) and ($i ne 0)) {
         push(@headerContent, "\n        ");
@@ -307,6 +310,8 @@ sub GenerateHeader
         push(@headerContent, "\n        ");
       }
 
+      $numCustomFunctions++ if $function->signature->extendedAttributes->{"Custom"};
+      
       my $value = ucfirst($function->signature->name) . "FuncNum";
       $value .= ", " if ($i < $numFunctions - 1);
       push(@headerContent, $value);
@@ -317,6 +322,32 @@ sub GenerateHeader
     push(@headerContent, "\n    };\n");
   }
 
+  if ($numCustomAttributes > 0) {
+    push(@headerContent, "\n    // Custom attributes\n");
+    
+    foreach(@{$dataNode->attributes}) {
+      my $attribute = $_;
+          
+      if ($attribute->signature->extendedAttributes->{"Custom"}) {
+        push(@headerContent, "    KJS::JSValue* " . $attribute->signature->name . "(KJS::ExecState*) const;\n");
+        if ($attribute->type !~ /^readonly/) {
+          push(@headerContent, "    void set" . ucfirst($attribute->signature->name) . "(KJS::ExecState*, KJS::JSValue*);\n");        
+        }
+      }
+    }
+  }
+  
+  if ($numCustomFunctions > 0) {      
+    push(@headerContent, "\n    // Custom functions\n");
+    foreach(@{$dataNode->functions}) {
+      my $function = $_;
+          
+      if ($function->signature->extendedAttributes->{"Custom"}) {
+        push(@headerContent, "    KJS::JSValue* " . $function->signature->name . "(KJS::ExecState*, const KJS::List&);\n");
+      }
+    }
+  }            
+  
   if (!$hasParent) {
     push(@headerContent, "    $implClassName* impl() const { return m_impl.get(); }\n");
     push(@headerContent, "private:\n");
@@ -360,6 +391,7 @@ sub GenerateHeader
           push(@headerContent, "        : KJS::JSObject(exec->lexicalInterpreter()->builtinObjectPrototype()) { }\n");
       }
   }
+  
   push(@headerContent, "};\n\n");
   
   push(@headerContent, "}\n\n");
@@ -611,7 +643,10 @@ sub GenerateImplementation
     foreach my $attribute (@{$dataNode->attributes}) {
       my $name = $attribute->signature->name;
         
-      if ($attribute->signature->type =~ /Constructor$/) {
+      if ($attribute->signature->extendedAttributes->{"Custom"}) {
+        push(@implContent, "    case " . ucfirst($name) . "AttrNum:\n");
+        push(@implContent, "        return $name(exec);\n");
+      } elsif ($attribute->signature->type =~ /Constructor$/) {
         my $constructorType = $attribute->signature->type;
         $constructorType =~ s/Constructor$//;
 
@@ -650,7 +685,11 @@ sub GenerateImplementation
       foreach my $attribute (@{$dataNode->attributes}) {
         if ($attribute->type !~ /^readonly/) {
           my $name = $attribute->signature->name;
-          if ($attribute->signature->type =~ /Constructor$/) {
+          if ($attribute->signature->extendedAttributes->{"Custom"}) {
+              push(@implContent, "    case " . ucfirst($name) . "AttrNum: {\n");
+              push(@implContent, "        set" . ucfirst($name) . "(exec, value);\n");
+          } elsif ($attribute->signature->type =~ /Constructor$/) {
               my $constructorType = $attribute->signature->type;
               $constructorType =~ s/Constructor$//;
 
@@ -702,6 +741,11 @@ sub GenerateImplementation
     foreach my $function (@{$dataNode->functions}) {      
       push(@implContent, "    case ${className}::" . ucfirst($function->signature->name) . "FuncNum: {\n");
       
+      if ($function->signature->extendedAttributes->{"Custom"}) {
+        push(@implContent, "        return static_cast<${className}*>(thisObj)->" . $function->signature->name . "(exec, args);\n    }\n");
+        next;
+      }
+      
       AddIncludesForType($function->signature->type);
       
       my $paramIndex = 0;
@@ -1010,7 +1054,7 @@ sub NativeToJSValue
     $implIncludes{"kjs_window.h"} = 1;
     return "toJS(exec, $value)";
   } elsif ($type eq "DOMObject") {
-    $implIncludes{"JSCanvasRenderingContext2DBase.h"} = 1;
+    $implIncludes{"JSCanvasRenderingContext2D.h"} = 1;
     return "toJS(exec, $value)";
   } else {
     $implIncludes{"JS$type.h"} = 1;
index eb7949e..d206261 100644 (file)
@@ -19,7 +19,7 @@
 
 module html {
 
-    interface [LegacyParent=JSCanvasRenderingContext2DBase] CanvasRenderingContext2D {
+    interface CanvasRenderingContext2D {
 
         // Web Applications 1.0 draft
 
@@ -81,6 +81,16 @@ module html {
 
         void clearShadow();
 
+        [Custom] void setStrokeColor(/* 1  */);
+        [Custom] void setFillColor(/* 1 */);
+        [Custom] void strokeRect(/* 4 */);
+        [Custom] void drawImage(/* 3 */);
+        [Custom] void drawImageFromRect(/* 10 */);
+        [Custom] void setShadow(/* 3 */);
+        [Custom] void createPattern(/* 2 */);
+        
+        attribute [Custom] custom strokeStyle;
+        attribute [Custom] custom fillStyle;        
     };
 
 }