It appears that this edge case in the canvas spec... "Shadows are only drawn if the opacity component of the alpha component of the color of shadowColor is non-zero and either the shadowBlur is non-zero, or the shadowOffsetX is non-zero, or the shadowOffsetY is non-zero." ...is modeled after a bug that CG had/has. In destination-atop, the shadow should be rendered atop the source. However, if you have a shadowBlur of 0 (or very close to 0), then CG will just not render the shadow. The philip canvas test suite has a test to check for this edge case at: http://philip.html5.org/tests/canvas/suite/tests/2d.shadow.enable.off.2.html Here's a testcase that jamesr constructed that shows the discontinuity of varying the shadow blur from 20 down to 0. Notice that it switches all of a sudden to all blue at the end, where it should instead have an all red shadow rect on top. http://webstuff.nfshost.com/shadowblur.html Looking around, it appears that the only browsers that support this faulty edge case are FireFox4 (not before 4 though), WebKit browsers that use CG (and also Skia, jamesr tells me). My proposal is to: 1) Change the spec by stripping out this edge case paragraph. 2) Notify Firefox team that they should strip out this hack in their code for the edge case. 3) Remove the hack also from Skia. 4) File a bug against CG on this faulty behavior (just did that) and hope that it can be fixed in future releases. 5) In GraphicsContextCG, "fix" this faulty behavior for all OSes that don't this possible future CG fix (via Gestalt). 6) Tell philip/W3C to update his/the test at http://philip.html5.org/tests/canvas/suite/tests/2d.shadow.enable.off.2.html / http://w3c-test.org/html/tests/approved/canvas/2d.shadow.enable.off.2.html 7) Remove the GraphicsContextCG "fix" in a few thousands years if/when we no longer need to support the broken CG.
(In reply to comment #0) > My proposal is to: > 1) Change the spec by stripping out this edge case paragraph. > 2) Notify Firefox team that they should strip out this hack in their code for the edge case. > 3) Remove the hack also from Skia. > 4) File a bug against CG on this faulty behavior (just did that) and hope that it can be fixed in future releases. > 5) In GraphicsContextCG, "fix" this faulty behavior for all OSes that don't this possible future CG fix (via Gestalt). > 6) Tell philip/W3C to update his/the test at http://philip.html5.org/tests/canvas/suite/tests/2d.shadow.enable.off.2.html / http://w3c-test.org/html/tests/approved/canvas/2d.shadow.enable.off.2.html > 7) Remove the GraphicsContextCG "fix" in a few thousands years if/when we no longer need to support the broken CG. Can you also start a thread on the WHATWG list explaining this proposal? Other vendors might have input that could alter this plan. This seems fine to me, however, unless we discover that there is some content that depends on the current behavior that we have to support.
For reference, here's the thread. The current stance is to keep the spec as-is. http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-May/031457.html
We do not have interoperable behavior here. Safari has a shadow at the beginning which disappears at the end. Same for Blink. Firefox just has an inset like shadow.
Ok, http://webstuff.nfshost.com/shadowblur.html definitely shows a weird behavior cross platform. It might better if the canvas spec describes better if the shadow is a separate drawing operation or belongs to the object that is drawn. Currently browsers are not interoperable on that. However, the initial bug report is invalid. WebKit behaves as specified and does not draw the shadow if opacity == 0. It does not seem that the spec will change.