- From: Charles Pritchard <chuck@jumis.com>
- Date: Fri, 22 Mar 2013 01:18:25 -0700
- To: Rik Cabanier <cabanier@gmail.com>
- CC: "Kang-Hao (Kenny) Lu" <kanghaol@oupeng.com>, W3C Canvas Spec <public-canvas-api@w3.org>, HTML-related tests <public-html-testsuite@w3.org>, Tietao Wang <tietaow@opera.com>
- Message-ID: <514C13D1.8000000@jumis.com>
As an aside -- Seems like most drawImage calls ought to be in try blocks. I don't know that there's a real guarantee that the image is available (even after onload). On 3/21/2013 12:45 PM, Rik Cabanier wrote: > The spec was changed at the last minute by the WhatWG and it was > actually done by accident. (Cameron did a global replace for WebIDL.) > The W3C version reversed that change since the change was > unintentional and there were already 2 independent implementations. > Ian decided that the new prose made more sense and just left it in. > > As a developer you should try to catch the exception since both > Firefox and IE will throw. This will make your code work everywhere. > If those browser change their behavior, we will update the spec > accordingly (but you will still have to account for old browsers) > > Rik > > On Thu, Mar 21, 2013 at 1:28 AM, Kang-Hao (Kenny) Lu > <kanghaol@oupeng.com <mailto:kanghaol@oupeng.com>> wrote: > > There is a discrepancy between the W3C spec and the WHATWG spec in > handing this case > > ctx.drawImage(img, 0, 0, sw, wh, ...) > > where one of sw and sh is zero. The relevant proses are > > # If one of the sw or sh arguments is zero, the implementation must > # throw an IndexSizeError exception. > > of W3C and > > # 3. If one of the sw or sh arguments is zero, abort these steps. > # Nothing is painted. > > of WHATWG. The change happened at WHATWG r7589[1], which unfortunately > was around the time when the W3C version transitioned to CR. The > relevant case is 2d.drawImage.zerosource.html, which is again quite > unfortunately, approved. > > > Our team unfortunately falls into the dilemma as which to follow, and, > you know, it's very difficult to explain why there's a difference > between the two specs, the W3C process and such. So... I guess my > question is why isn't r7589 applied to W3C Canvas Level2 when it's > applied in HTML5.1[2] and what's the process here? (That is, if the > changed in at least applied in Level2, we can be more convinced that > it's the way to go.) > > > == Technical Arguments == > > Not sure if this helps the process but here are the reasons why not > throwing is better: > > 1. It's just the better behavior > > It's not at all clear to me why the spec asked UA to throw at the > beginning. There are many situations where it's very natural to have > either sw or sh be zero here. For example, a straightforward > implementation of the background of a side-scrolling game would divide > the background image into two and one of which, at times, would have a > sw of zero. > > If the error here is to help Web developers spot logical flaws in the > game then I think it makes more sense to make drawImage throw only > when > sw is zero *but dw is not*. > > > 2. Compatibility > > Currently only WebKit implements the WHATWG behavior (not throwing). > However, it seems very likely that this part of the Web (the > WebKit Web > :( ) is already depending on drawImage not throwing. Google > "IndexSizeError" gives [3][4][5], and I bet there are much more. Also, > it is known that getting the Android WebView to change is hard, and > therefore not throwing seems like the way to converge. > > > Anyway, the baseline is that we shouldn't have a difference > between the > two specs. > > > == Rant == > > Having discrepancy in these two versions of the spec is no fun. > Really. > > > [1] http://html5.org/tools/web-apps-tracker?from=7588&to=7589 > [2] http://lists.w3.org/Archives/Public/public-html/2013Jan/0022 > [3] https://github.com/Animatron/player/pull/70 > [4] https://github.com/aduros/flambe/issues/55 > [5] http://groups.google.com/group/melonjs/msg/571b36150fd2760b > > > Cheers, > Kenny > -- > Web Specialist, Opera Sphinx Game Force, Oupeng Browser, Beijing > Try Oupeng: http://www.oupeng.com/ > >
Received on Friday, 22 March 2013 08:18:53 UTC