Bug 17952 - The type of fillStyle/strokeStyle should probably be |(DOMString or CanvasGradient or CanvasPattern)|
The type of fillStyle/strokeStyle should probably be |(DOMString or CanvasGra...
Status: RESOLVED FIXED
Product: WHATWG
Classification: Unclassified
Component: HTML
unspecified
Other other
: P3 normal
: Unsorted
Assigned To: Ian 'Hixie' Hickson
contributor
http://www.whatwg.org/specs/web-apps/...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-18 07:22 UTC by contributor
Modified: 2012-09-28 04:17 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description contributor 2012-07-18 07:22:37 UTC
This was was cloned from bug 17284 as part of operation convergence.
Originally filed: 2012-06-01 12:36:00 +0000

================================================================================
 #0   contributor@whatwg.org                          2012-06-01 12:36:07 +0000 
--------------------------------------------------------------------------------
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html
Multipage: http://www.whatwg.org/C#2dcontext
Complete: http://www.whatwg.org/c#2dcontext

Comment:
The type of fillStyle/strokeStyle should probably be |(DOMString or
CanvasGradient or CanvasPattern)|

Posted from: 91.181.38.75 by ms2ger@gmail.com
User agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0a1) Gecko/20120108 Firefox/12.0a1
================================================================================
 #1   Ms2ger                                          2012-06-01 12:37:28 +0000 
--------------------------------------------------------------------------------
Currently the spec isn't terribly clear on what should happen for, for example, ctx.fillStyle = { valueOf: function() { return "blue" } }. Deferring to WebIDL would fix that.
================================================================================
Comment 1 contributor 2012-08-23 22:11:43 UTC
Checked in as WHATWG revision r7260.
Check-in comment: Clean up some IDLs that use 'any' to specify the exact type instead, and clean up some surrounding markup
http://html5.org/tools/web-apps-tracker?from=7259&to=7260
Comment 2 Ms2ger 2012-08-24 07:03:30 UTC
The prose still stays:

> If the value is a string but cannot be parsed as a CSS <color> value,
> or is neither a string, a CanvasGradient, nor a CanvasPattern, then
> it must be ignored, and the attribute must retain its previous value.

"or is neither a string, a CanvasGradient, nor a CanvasPattern," is now handled in WebIDL, and should be dropped.
Comment 3 Ian 'Hixie' Hickson 2012-08-27 22:19:56 UTC
Oops.
Comment 4 contributor 2012-08-27 22:21:48 UTC
Checked in as WHATWG revision r7287.
Check-in comment: Remove redundant text.
http://html5.org/tools/web-apps-tracker?from=7286&to=7287
Comment 5 Ms2ger 2012-08-28 06:45:02 UTC
Thanks!
Comment 6 rcabanie 2012-09-02 02:32:36 UTC
(In reply to comment #1)
> Checked in as WHATWG revision r7260.
> Check-in comment: Clean up some IDLs that use 'any' to specify the exact type
> instead, and clean up some surrounding markup
> http://html5.org/tools/web-apps-tracker?from=7259&to=7260

This change modifies the behavior that all browsers have.
Currently "ctx.fillStyle = { valueOf: function() { return "blue" } }" is ignored because it is not a string, canvaspattern or a gradient.
No browser will cast the object to a string.

Current behavior is to accept 'any'
Comment 7 Ms2ger 2012-09-02 07:51:15 UTC
First of all, ToString({ valueOf: function() { return "blue" } }) is "[object Object]". Second, why would you want this to be inconsistent with the sensible WebIDL behaviour?
Comment 8 rcabanie 2012-09-02 21:47:13 UTC
(In reply to comment #7)
> First of all, ToString({ valueOf: function() { return "blue" } }) is "[object
> Object]". Second, why would you want this to be inconsistent with the sensible
> WebIDL behaviour?

sorry, copy/paste error.
What is working with the IDL and not before is if you pass this:

fillStyle = { toString():  { return "blue"; } }

I don't disagree that this might make more sense, but it is a change of behavior (which was an IDL that took 'any').
Comment 9 Ian 'Hixie' Hickson 2012-09-28 04:12:16 UTC
Changing behaviour is fine if it's an edge case and the new behaviour is saner. It's an issue if it isn't compatible with legacy content, but do we have any reason to believe that is the case?

Marking FIXED again, in the absence of such information.
Comment 10 rcabanie 2012-09-28 04:17:30 UTC
(In reply to comment #9)
> Changing behaviour is fine if it's an edge case and the new behaviour is saner.
> It's an issue if it isn't compatible with legacy content, but do we have any
> reason to believe that is the case?
> 
> Marking FIXED again, in the absence of such information.

I agree.
We did some more tests and this matches behavior on some browsers.

This will be changed in the W3 version of the spec as well.