Re: [whatwg] Canvas image to blob/dataurl within Worker

On Thu, Apr 9, 2015 at 6:25 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> On Thu, Apr 9, 2015 at 5:23 PM, Kenneth Russell <kbr@google.com> wrote:
>> 1. An image element that didn't have a width or height explicitly
>> specified in the markup has an ImageBitmap transferred in. Will its
>> width and height attributes change? Will layout have to occur on the
>> page?
>
> Its width and height *attributes* won't change, but its *intrinsic*
> width and height will, to match the bitmap and density.  (Btw, the
> ImageBitmap feature needs to have a notion of density.)

I think the idea of introducing "density" to ImageBitmap needs a
completely separate thread. I don't understand all the ramifications,
but it looks to me like the fact that ImageBitmap's width and height
are specified in CSS pixels makes it impossible for users' code to
compute the exact number of pixels in the ImageBitmap. This is still a
problem for developers using <canvas> and
https://wiki.whatwg.org/wiki/CanvasRenderedPixelSize is intended to
solve it.

> Yes, layout occurs, assuming the size changed.
>
>> 2. The same image element has another ImageBitmap transferred in which
>> has a different width and height. Do the image's width and height
>> change? Will layout have to occur on the page?
>
> Yes and yes, assuming the size changed.

This is problematic. It's essential that displaying a newly produced
ImageBitmap be a cheap operation. Layout is expensive.


>> When an image's src is set to a URL and its width and height
>> attributes aren't set, the page is laid out again when the image is
>> loaded. For acceptable performance it's important that this not happen
>> when displaying a new ImageBitmap. Using a new canvas context type
>> solves this problem. The OffscreenCanvas proposal defines the
>> ImageBitmap as being rendered at the upper left corner of the canvas's
>> box with no scaling applied, and clipped to the box. It's not as
>> flexible as having the object-fit and object-position CSS properties
>> available, but will give developers explicit control over when they
>> want layout to happen, and still let them display their content as
>> they wish.
>
> Why not just use object-fit/position?  I think we support those.  No
> need to make new weird behavior when you can just opt into the desired
> behavior with existing standardized stuff.

Can the right settings of object-fit and object-position avoid the
layouts in the abovementioned scenarios?

-Ken

Received on Saturday, 11 April 2015 01:41:14 UTC