Re: [whatwg] Default value of "complete" attribute on new Image objects

2010-08-10 Thread Philip Taylor
On Wed, Aug 11, 2010 at 1:06 AM, Jonas Sicking  wrote:
> On Tue, Aug 10, 2010 at 4:56 PM, Philip Taylor  
> wrote:
>> On Wed, Aug 11, 2010 at 12:23 AM, Ian Hickson  wrote:
>>> I've updated the spec to have complete return true if the src is the empty
>>> string.
>>
>> Some canvas methods (drawImage, createPattern) are defined in terms of
>> the complete attribute ("If the image argument is an HTMLImageElement
>> object whose complete attribute is false, [...] then the
>> implementation must return without drawing anything."). Now that it
>> can be true when the image doesn't have any image data, what should
>> they do when passed such an image?
>
> Isn't the image fully loaded, just empty?

Depends how you define the concept of "fully loaded", I guess. The
spec says an empty src is invalid and triggers an error event and
makes the image "not available" (but now also "complete"), so it's not
entirely the same as a normal non-empty image.

> Seems like drawing such an
> image should act "normal". It just so happens that "normal" for an
> empty image would be to draw nothing?
>
> Just have to avoid divide-by-zero errors when creating patterns :)

Probably should do the same as a 0-pixel canvas ("If the image
argument is an HTMLCanvasElement object with either a horizontal
dimension or a vertical dimension equal to zero, then the
implementation must raise an INVALID_STATE_ERR exception."). (The spec
currently assumes complete HTMLImageElements always have non-zero
size, so the dimension check isn't applied to them.)

-- 
Philip Taylor
exc...@gmail.com


Re: [whatwg] Default value of "complete" attribute on new Image objects

2010-08-10 Thread Jonas Sicking
On Tue, Aug 10, 2010 at 4:56 PM, Philip Taylor  wrote:
> On Wed, Aug 11, 2010 at 12:23 AM, Ian Hickson  wrote:
>> I've updated the spec to have complete return true if the src is the empty
>> string.
>
> Some canvas methods (drawImage, createPattern) are defined in terms of
> the complete attribute ("If the image argument is an HTMLImageElement
> object whose complete attribute is false, [...] then the
> implementation must return without drawing anything."). Now that it
> can be true when the image doesn't have any image data, what should
> they do when passed such an image?

Isn't the image fully loaded, just empty? Seems like drawing such an
image should act "normal". It just so happens that "normal" for an
empty image would be to draw nothing?

Just have to avoid divide-by-zero errors when creating patterns :)

/ Jonas


Re: [whatwg] Default value of "complete" attribute on new Image objects

2010-08-10 Thread Philip Taylor
On Wed, Aug 11, 2010 at 12:23 AM, Ian Hickson  wrote:
> I've updated the spec to have complete return true if the src is the empty
> string.

Some canvas methods (drawImage, createPattern) are defined in terms of
the complete attribute ("If the image argument is an HTMLImageElement
object whose complete attribute is false, [...] then the
implementation must return without drawing anything."). Now that it
can be true when the image doesn't have any image data, what should
they do when passed such an image?

-- 
Philip Taylor
exc...@gmail.com


Re: [whatwg] Default value of "complete" attribute on new Image objects

2010-08-10 Thread Ian Hickson
On Thu, 8 Jul 2010, Andreas Kling wrote:
>
> The current HTML5 specification says:
> 
> "The IDL attribute complete must return true if the user agent has 
> fetched the image specified in the src attribute, and it is in a 
> supported image type (i.e. it was decoded without fatal errors), even if 
> the final task queued by the networking task source for the fetching of 
> the image resource has not yet been processed. Otherwise, the attribute 
> must return false." [1]
> 
> This reads to me as if a "new Image()" should have complete=false
> 
> No browser currently does this AFAIK.

On Fri, 9 Jul 2010, Diego Perini wrote:
>
> Just to add that also by using DOM methods like:
> 
>document.createElement('img').complete; // true
> 
> the result is the same: "complete" is always true. Only tested on Firefox
> 3.5.10 and Opera 10.60.

I've updated the spec to have complete return true if the src is the empty 
string.

-- 
Ian Hickson   U+1047E)\._.,--,'``.fL
http://ln.hixie.ch/   U+263A/,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


Re: [whatwg] Default value of "complete" attribute on new Image objects

2010-07-09 Thread Diego Perini
On Fri, Jul 9, 2010 at 5:46 PM, Boris Zbarsky  wrote:

> On 7/9/10 3:23 AM, Diego Perini wrote:
>
>> On FF after setting src="" the "complete" property return true while on
>> Opera it return false.
>>
>
> We special-case src="" and don't do any loading; iirc the spec calls for
> that at this point.
>
>
>  On FF after setting src="/nonexisting.gif" the "complete" property
>> remains true
>>
>
> Were you testing this from a file:// URI or something?  That shouldn't
> happen over http.
>
> -Boris
>

No, I tested that using Firebug (and Opera Dragonfly) typing the commands
directly in the console.

Diego Perini


Re: [whatwg] Default value of "complete" attribute on new Image objects

2010-07-09 Thread Boris Zbarsky

On 7/9/10 3:23 AM, Diego Perini wrote:

On FF after setting src="" the "complete" property return true while on
Opera it return false.


We special-case src="" and don't do any loading; iirc the spec calls for 
that at this point.



On FF after setting src="/nonexisting.gif" the "complete" property
remains true


Were you testing this from a file:// URI or something?  That shouldn't 
happen over http.


-Boris


Re: [whatwg] Default value of "complete" attribute on new Image objects

2010-07-09 Thread Diego Perini
Just to add that also by using DOM methods like:

   document.createElement('img').complete; // true

the result is the same: "complete" is always true. Only tested on Firefox
3.5.10 and Opera 10.60.

On FF after setting src="" the "complete" property return true while on
Opera it return false.
On FF after setting src="/nonexisting.gif" the "complete" property remains
true like it does in Opera.

Ugh ! Quite an unreliable behaviour... I would expect false in all the above
cases.

Diego Perini


On Thu, Jul 8, 2010 at 11:27 PM, Andreas Kling wrote:

> The current HTML5 specification says:
>
> "The IDL attribute complete must return true if the user agent has fetched
> the image specified in the src attribute, and it is in a supported image
> type (i.e. it was decoded without fatal errors), even if the final task
> queued by the networking task source for the fetching of the image resource
> has not yet been processed. Otherwise, the attribute must return false." [1]
>
> This reads to me as if a "new Image()" should have complete=false
>
> No browser currently does this AFAIK. I've posted a patch to implement this
> behavior in WebKit here:
>
> https://bugs.webkit.org/show_bug.cgi?id=41898
>
> Does anyone have thoughts on this?
> Anything that might break?
> Reasons it's currently defaulting to true?
>
> -Kling
>
> [1] http://www.whatwg.org/specs/web-apps/current-work/#dom-img-complete
>


[whatwg] Default value of "complete" attribute on new Image objects

2010-07-08 Thread Andreas Kling

The current HTML5 specification says:

"The IDL attribute complete must return true if the user agent has 
fetched the image specified in the src attribute, and it is in a 
supported image type (i.e. it was decoded without fatal errors), even if 
the final task queued by the networking task source for the fetching of 
the image resource has not yet been processed. Otherwise, the attribute 
must return false." [1]


This reads to me as if a "new Image()" should have complete=false

No browser currently does this AFAIK. I've posted a patch to implement 
this behavior in WebKit here:


https://bugs.webkit.org/show_bug.cgi?id=41898

Does anyone have thoughts on this?
Anything that might break?
Reasons it's currently defaulting to true?

-Kling

[1] http://www.whatwg.org/specs/web-apps/current-work/#dom-img-complete