RESOLVED DUPLICATE of bug 39243 39962
Remove hand-rolled JSC bindings for CanvasRenderingContext2D
https://bugs.webkit.org/show_bug.cgi?id=39962
Summary Remove hand-rolled JSC bindings for CanvasRenderingContext2D
Andreas Kling
Reported 2010-05-31 10:28:56 PDT
CodeGeneratorJS.pm supports overloading now, so we can get rid of most of JSCanvasRenderingContext2DCustom.cpp
Attachments
Proposed patch (21.15 KB, patch)
2010-05-31 10:33 PDT, Andreas Kling
darin: review-
Proposed patch v2 (35.26 KB, patch)
2010-06-12 14:56 PDT, Andreas Kling
no flags
Patch to replace hand-rolled overloads with autogenerated ones (19.24 KB, patch)
2010-06-13 08:18 PDT, Andreas Kling
no flags
Patch to ignore superfluous arguments to IDL overloads (5.95 KB, patch)
2010-06-13 12:22 PDT, Andreas Kling
no flags
Patch that just adds the LayoutTest (15.57 KB, patch)
2010-06-13 12:43 PDT, Andreas Kling
no flags
Andreas Kling
Comment 1 2010-05-31 10:33:07 PDT
Created attachment 57479 [details] Proposed patch
Andreas Kling
Comment 2 2010-05-31 10:33:57 PDT
Note that this won't compile until bug 39960 is fixed.
Early Warning System Bot
Comment 3 2010-05-31 10:45:18 PDT
Darin Adler
Comment 4 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.
WebKit Review Bot
Comment 5 2010-05-31 11:31:16 PDT
WebKit Review Bot
Comment 6 2010-05-31 11:38:09 PDT
Andreas Kling
Comment 7 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.
Darin Adler
Comment 8 2010-06-02 10:38:12 PDT
*** This bug has been marked as a duplicate of bug 21257 ***
Darin Adler
Comment 9 2010-06-02 10:38:37 PDT
Oops, did this to the wrong bug.
Andreas Kling
Comment 10 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.
Darin Adler
Comment 11 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.
Andreas Kling
Comment 12 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.
Darin Adler
Comment 13 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.
Andreas Kling
Comment 14 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.
Andreas Kling
Comment 15 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..
Andreas Kling
Comment 16 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.
Andreas Kling
Comment 17 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].
Andreas Kling
Comment 18 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.
Andreas Kling
Comment 19 2010-06-29 04:51:09 PDT
*** This bug has been marked as a duplicate of bug 39243 ***
Note You need to log in before you can comment on or make changes to this bug.