Bug 23809 - Return CanvasRenderingContext2D instead of DOMObject in IDL to avoid V8 #ifdefs
Summary: Return CanvasRenderingContext2D instead of DOMObject in IDL to avoid V8 #ifdefs
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Darin Fisher (:fishd, Google)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-06 16:35 PST by Darin Fisher (:fishd, Google)
Modified: 2009-03-02 20:04 PST (History)
3 users (show)

See Also:


Attachments
v1 patch (2.11 KB, patch)
2009-02-06 16:44 PST, Darin Fisher (:fishd, Google)
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Fisher (:fishd, Google) 2009-02-06 16:35:55 PST
Return CanvasRenderingContext2D instead of DOMObject in IDL to avoid V8 #ifdefs

The code generator for JSC and V8 is a bit simpler when the return type of a method matches the actual type in the code.  I know that getContext and getCSSCanvasContext are both spec'd to return DOMObject, but presently our code generators go through some extra steps to force that to mean CanvasRenderingContext2D.  We might as well just change the IDL.
Comment 1 Darin Fisher (:fishd, Google) 2009-02-06 16:44:48 PST
Created attachment 27432 [details]
v1 patch
Comment 2 Darin Adler 2009-02-06 16:47:57 PST
Comment on attachment 27432 [details]
v1 patch

Long term, this is wrong. The context could be other classes depending on the passed-in context ID. So we may want to make a different type of change here.
Comment 3 Eric Seidel (no email) 2009-02-06 16:49:53 PST
Comment on attachment 27432 [details]
v1 patch

Agreed.  This would make it impossible to implement Context3D for example (which I figure we'll eventually do to match moz and opera)
Comment 4 Darin Fisher (:fishd, Google) 2009-02-06 19:16:18 PST
Yeah, that's correct, but we don't have any Context3D yet.  When we do, we can figure out how to abstract this return value.  Why figure that out now?  Seems like premature effort to me.

My change just moves "hard coded logic" from the code generator into the IDL.  That doesn't seem like a step back to me :-)
Comment 5 Darin Fisher (:fishd, Google) 2009-02-06 19:21:54 PST
Would you guys prefer if the getContext return type were changed to CanvasRenderingContext instead of CanvasRenderingContext2D?  I could then add a CanvasRenderingContext header that includes the typedef that currently lives in CanvasRenderingContext2D.h.  Would that be better?  I'm striving for avoiding hacks in the code generator :)
Comment 6 Eric Seidel (no email) 2009-02-07 02:11:32 PST
Comment on attachment 27432 [details]
v1 patch

I agree, it's overkill.  The header with a separate CanvasRenderingContext would be cleanest, but we can solve that when we get a Context3d.
Comment 7 Darin Fisher (:fishd, Google) 2009-02-09 14:34:02 PST
http://trac.webkit.org/changeset/40797

I left the patch as-is.  It turns out that toString() currently returns "[object CanvasRenderingContext2D]", so the v1 patch also has the property of making the IDL match the JS better.
Comment 8 Darin Fisher (:fishd, Google) 2009-02-10 00:17:40 PST
Re-opening since Sam didn't like this fix.

Reverted as:
http://trac.webkit.org/changeset/40810
Comment 9 Darin Fisher (:fishd, Google) 2009-03-02 20:04:18 PST
Closing this out in favor of the solution in bug 24311.