Bug 39962 - Remove hand-rolled JSC bindings for CanvasRenderingContext2D
Summary: Remove hand-rolled JSC bindings for CanvasRenderingContext2D
Status: RESOLVED DUPLICATE of bug 39243
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 39960 40057
Blocks:
  Show dependency treegraph
 
Reported: 2010-05-31 10:28 PDT by Andreas Kling
Modified: 2010-06-29 04:51 PDT (History)
8 users (show)

See Also:


Attachments
Proposed patch (21.15 KB, patch)
2010-05-31 10:33 PDT, Andreas Kling
darin: review-
Details | Formatted Diff | Diff
Proposed patch v2 (35.26 KB, patch)
2010-06-12 14:56 PDT, Andreas Kling
no flags Details | Formatted Diff | Diff
Patch to replace hand-rolled overloads with autogenerated ones (19.24 KB, patch)
2010-06-13 08:18 PDT, Andreas Kling
no flags Details | Formatted Diff | Diff
Patch to ignore superfluous arguments to IDL overloads (5.95 KB, patch)
2010-06-13 12:22 PDT, Andreas Kling
no flags Details | Formatted Diff | Diff
Patch that just adds the LayoutTest (15.57 KB, patch)
2010-06-13 12:43 PDT, Andreas Kling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kling 2010-05-31 10:28:56 PDT
CodeGeneratorJS.pm supports overloading now, so we can get rid of most of JSCanvasRenderingContext2DCustom.cpp
Comment 1 Andreas Kling 2010-05-31 10:33:07 PDT
Created attachment 57479 [details]
Proposed patch
Comment 2 Andreas Kling 2010-05-31 10:33:57 PDT
Note that this won't compile until bug 39960 is fixed.
Comment 3 Early Warning System Bot 2010-05-31 10:45:18 PDT
Attachment 57479 [details] did not build on qt:
Build output: http://webkit-commit-queue.appspot.com/results/2777014
Comment 4 Darin Adler 2010-05-31 10:58:33 PDT
Comment on attachment 57479 [details]
Proposed patch

Great change!

> +        No new tests as there is no new functionality.

Are there tests for each of these overload cases? If not, then I think we do need tests, even though these code paths are not new. It looks to me like some of these hand-written bindings have different handling for things like too many arguments. It would be straightforward to write some tests that cover all these cases, and I'd like to see that to provde that the hand-rolled code did not behave any differently.
Comment 5 WebKit Review Bot 2010-05-31 11:31:16 PDT
Attachment 57479 [details] did not build on gtk:
Build output: http://webkit-commit-queue.appspot.com/results/2752009
Comment 6 WebKit Review Bot 2010-05-31 11:38:09 PDT
Attachment 57479 [details] did not build on win:
Build output: http://webkit-commit-queue.appspot.com/results/2825014
Comment 7 Andreas Kling 2010-06-02 07:29:59 PDT
I looked into how functions should behave when called with the wrong number of arguments, and opened bug 40057 to make WebKit do the right thing bottom-up.
Comment 8 Darin Adler 2010-06-02 10:38:12 PDT

*** This bug has been marked as a duplicate of bug 21257 ***
Comment 9 Darin Adler 2010-06-02 10:38:37 PDT
Oops, did this to the wrong bug.
Comment 10 Andreas Kling 2010-06-12 14:56:46 PDT
Created attachment 58566 [details]
Proposed patch v2

I wasn't sure what to do with this, so I test for the previous behavior, and expect the new behavior which won't match in many cases.
That said, the discrepancies look fairly harmless to me.
Comment 11 Darin Adler 2010-06-12 17:48:19 PDT
Comment on attachment 58566 [details]
Proposed patch v2

The way I see it we have two separate issues:

    1) Hand-generation vs. auto-generation.

    2) Handling of missing arguments.

I would like to see a patch that only changes use from hand-generation to auto-generation, and then a separate patch to change handling of missing arguments. The former patch should be done right away! The latter, requires some though about how to keep existing code working. I believe there is quite a bit of code that depends on the current behavior, although mainly in Apple-specific products. Longer term it would be best to match other browsers, but the path from here to there may require some sort of compatibility mode.

I can’t tell from this patch whether it does or does not change the handling of missing arguments.
Comment 12 Andreas Kling 2010-06-12 18:00:53 PDT
(In reply to comment #11)
> I would like to see a patch that only changes use from hand-generation to auto-generation, and then a separate patch to change handling of missing arguments.

And how should we do this without custom bindings? I doubt we'd want to specialize CodeGeneratorJS.pm for the idiosyncratic behaviors formerly found in  JSCanvasRenderingContext2DCustom.cpp

> The former patch should be done right away!

So you'd be OK with an intermediate state (auto-generated code that behaves slightly differently) while we think up a better solution for missing arguments?

> Longer term it would be best to match other browsers, but the path from here to there may require some sort of compatibility mode.

I like the sound of that. And count bug 21257 in as well, please ;-)

> I can’t tell from this patch whether it does or does not change the handling of missing arguments.

It does, implicitly, since generated bindings handle things differently than the hand-rolled code.
Comment 13 Darin Adler 2010-06-12 18:48:57 PDT
(In reply to comment #12)
> (In reply to comment #11)
> > I would like to see a patch that only changes use from hand-generation to auto-generation, and then a separate patch to change handling of missing arguments.
> 
> And how should we do this without custom bindings? I doubt we'd want to specialize CodeGeneratorJS.pm for the idiosyncratic behaviors formerly found in  JSCanvasRenderingContext2DCustom.cpp

I think we can get 99% of the behavior by having many arguments optional. Maybe you can give me examples of old behavior we can't reproduce with that alone. Those may be changes we can live with.

> > The former patch should be done right away!
> 
> So you'd be OK with an intermediate state (auto-generated code that behaves slightly differently) while we think up a better solution for missing arguments?

No.

> > Longer term it would be best to match other browsers, but the path from here to there may require some sort of compatibility mode.
> 
> I like the sound of that. And count bug 21257 in as well, please ;-)

I wish we could just wave a magic wad and do it the way that seems cleanest now. But keeping compatible does end up being hard work.
Comment 14 Andreas Kling 2010-06-12 19:11:10 PDT
(In reply to comment #13)
> I think we can get 99% of the behavior by having many arguments optional. Maybe you can give me examples of old behavior we can't reproduce with that alone. Those may be changes we can live with.

Right, I'll sort this tomorrow (4AM here..) Thanks for your input thus far.

> I wish we could just wave a magic wad and do it the way that seems cleanest now. But keeping compatible does end up being hard work.

Absolutely. A compatibility mode is a fair compromise IMO. And I'm not at all opposed to doing said work myself, though I may need some spiritual guidance.
Comment 15 Andreas Kling 2010-06-13 08:18:24 PDT
Created attachment 58593 [details]
Patch to replace hand-rolled overloads with autogenerated ones

Part 1 of 2 - handling of missing arguments coming soon..
Comment 16 Andreas Kling 2010-06-13 12:22:25 PDT
Created attachment 58601 [details]
Patch to ignore superfluous arguments to IDL overloads

Part 2 of X (!) - make auto-generated overloads behave as the current custom code - ignore any extra arguments.
Comment 17 Andreas Kling 2010-06-13 12:35:32 PDT
Remaining failures from original test:

> ctx.fillText() should throw SyntaxError: Syntax error. Was undefined.
> ctx.fillText('moo') should throw SyntaxError: Syntax error. Was undefined.
> ctx.fillText('moo',0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.fillText('moo',0,0,0,0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.strokeText() should throw SyntaxError: Syntax error. Was undefined.
> ctx.strokeText('moo') should throw SyntaxError: Syntax error. Was undefined.
> ctx.strokeText('moo',0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.strokeText('moo',0,0,0,0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.setStrokeColor(0, 0, 0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.setStrokeColor(0, 0, 0, 0, 0, 0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.setFillColor(0, 0, 0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.setFillColor(0, 0, 0, 0, 0, 0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.drawImage(imageElement, 0, 0) should be undefined. Threw exception Error: INDEX_SIZE_ERR: DOM Exception 1
> ctx.drawImage(canvasElement, 0, 0, 0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.drawImage(canvasElement, 0, 0, 0, 0, 0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0) should throw Error: INDEX_SIZE_ERR: DOM Exception 1. Was undefined.
> ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) should throw SyntaxError: Syntax error. Was undefined.
> ctx.createImageData(0, 0, 0) should be null. Threw exception Error: INDEX_SIZE_ERR: DOM Exception 1

Auto-generated code is more permissive than custom bindings.

> ctx.setStrokeColor() should throw SyntaxError: Syntax error. Threw exception TypeError: Type error.
> ctx.setFillColor() should throw SyntaxError: Syntax error. Threw exception TypeError: Type error.
> ctx.createImageData(0) should throw Error: NOT_SUPPORTED_ERR: DOM Exception 9. Threw exception TypeError: Type error.
> ctx.drawImage(imageElement) should throw SyntaxError: Syntax error. Threw exception TypeError: Type error.
> ctx.drawImage(imageElement, 0) should throw SyntaxError: Syntax error. Threw exception TypeError: Type error.
> ctx.drawImage(imageElement, 0, 0, 0) should throw SyntaxError: Syntax error. Threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
> ctx.drawImage(imageElement, 0, 0, 0, 0, 0) should throw SyntaxError: Syntax error. Threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
> ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0) should throw SyntaxError: Syntax error. Threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
> ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0) should throw SyntaxError: Syntax error. Threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
> ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0) should throw SyntaxError: Syntax error. Threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
> ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) should throw SyntaxError: Syntax error. Threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
> ctx.drawImage(canvasElement) should throw SyntaxError: Syntax error. Threw exception TypeError: Type error.
> ctx.drawImage(canvasElement, 0) should throw SyntaxError: Syntax error. Threw exception TypeError: Type error.
> ctx.createPattern(imageElement) should throw Error: SYNTAX_ERR: DOM Exception 12. Threw exception TypeError: Type error.
> ctx.createPattern(canvasElement) should throw Error: SYNTAX_ERR: DOM Exception 12. Threw exception TypeError: Type error.

Auto-generated and custom bindings both throw, but different exceptions.

> ctx.createImageData() should be null. Threw exception TypeError: Type error

This one would need some finagling with making the first argument optional etc.

> ctx.putImageData(imageData, 0, 0, 0) should be undefined. Threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9
> ctx.putImageData(imageData, 0, 0, 0, 0) should be undefined. Threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9
> ctx.putImageData(imageData, 0, 0, 0, 0, 0) should be undefined. Threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9

Missing arguments become NaN instead of 0, hence the NOT_SUPPORTED_ERR.
I guess we could add some custom IDL attribute like [PassZeroForMissingArguments].
Comment 18 Andreas Kling 2010-06-13 12:43:29 PDT
Created attachment 58602 [details]
Patch that just adds the LayoutTest

Part 3 of X - The LayoutTest. should*() values are the old behavior, -expected.txt is the new behavior.
Comment 19 Andreas Kling 2010-06-29 04:51:09 PDT

*** This bug has been marked as a duplicate of bug 39243 ***