Commit graph

8 commits

Author SHA1 Message Date
Andreas Kling
305e2ef69c LibWeb: Until an image has loaded or failed, don't occupy layout size
This patch makes images have an implicit zero intrinsic size before
they have either loaded or failed to load. This is tracked by the
ImageLoader object.

This fixes a long-standing issue with images occupying empty 150x150
rectangles of space.
2020-08-12 13:49:43 +02:00
Andreas Kling
fbd760379a LibWeb: Remove Gfx::ImageDecoder from ImageLoader
We still use a Gfx::ImageDecoder for GIF images, but there's no need
for the ImageLoader object to have its own pointer to it. Just grab
the ImageDecoder from the ImageResource when needed.
2020-06-23 14:28:45 +02:00
Andreas Kling
805123ab3d LibWeb: Give ImageResource::bitmap(frame_index) default frame_index = 0 2020-06-23 14:28:45 +02:00
Andreas Kling
10255bc5c6 LibWeb+Browser: Decode non-animated images out-of-process :^)
We now use the ImageDecoder service in LibWeb for everything except
GIF images (we'll have to deal with them later, ofc.)

This has a little bit of overhead but we should be able to optimize
it until it becomes negligible.
2020-06-22 21:47:01 +02:00
Andreas Kling
0072370459 LibWeb: Don't animate images outside the visible viewport :^) 2020-06-14 19:35:10 +02:00
Andreas Kling
73c9f7ebf4 LibWeb: Move "visible in viewport" state tracking to ImageLoader
This should technically apply to any LayoutImage, so let's just move
it to ImageLoader.
2020-06-14 19:32:23 +02:00
Andreas Kling
c45615128b LibWeb: Move bitmap animation from HTMLImageElement to ImageLoader
Since ImageLoader manages the image decoder anyway, let it manage
animation as well.
2020-06-14 19:26:25 +02:00
Andreas Kling
95d70addd8 LibWeb: Split out image loading logic from HTMLImageElement
Since more DOM nodes are going to want to load images (<object>, ...)
this patch splits out the image loading logic into an ImageLoader class
and then HTMLImageElement simply has an ImageLoader.

LayoutImage is then given a const ImageLoader& at construction and can
then provide layout and rendering for many kinds of DOM nodes.
2020-06-13 22:22:54 +02:00