Commit graph

50193 commits

Author SHA1 Message Date
Lucas CHOLLET 9389177e5f LibGfx/JPEG: Make generate_huffman_codes be a method of HuffmanTable
And call it when reading the table definition instead of when starting
to decode the stream.
2023-05-07 09:08:56 +02:00
Lucas CHOLLET 8cba8ed25a LibGfx/JPEG: Rename HuffmanTableSpec => HuffmanTable 2023-05-07 09:08:56 +02:00
Lucas CHOLLET 011fe0d9ba LibGfx/JPEG: Ensure capacity of vector instead of blindly appending 2023-05-07 09:08:56 +02:00
Lucas CHOLLET f4014f898d LibGfx/JPEG: Use peek_bits in next_symbol
This allows us to read all bits in a single shot instead of one by one.
2023-05-07 09:08:56 +02:00
Lucas CHOLLET 5ec2aa4dcc LibGfx/JPEG: Introduce peek_bits and use it in read_bits
While already providing a performance improvement by removing the loop
in `read_bits`, this method was introduced to optimize `next_symbol`.
2023-05-07 09:08:56 +02:00
Lucas CHOLLET 86ce9cc30f LibGfx/JPEG: Encapsulate operations on HuffmanStream
Advantages of encapsulation are really obvious here:
- Put related code together
- Prevent external functions to modify the object
- Abstract the implementation

No functional changes intended.
2023-05-07 09:08:56 +02:00
Lucas CHOLLET 66108d102e LibGfx/JPEG: Store previous DC values in i16
Forgotten child of cfaa5120.
2023-05-07 09:08:56 +02:00
Lucas CHOLLET a08b91e63e LibGfx/JPEG: Rename HuffmanStreamState => HuffmanStream 2023-05-07 09:08:56 +02:00
Andreas Kling af5d892a7e Ladybird: Don't ask Qt to decode SVG images for us
While it's nice to see <img src="foo.svg"> suddenly work in Ladybird
after linking with the Qt SVG module, this is cheating.

We should implement SVG-as-image ourselves instead of relying on 3rd
party code to do it. :^)
2023-05-07 09:06:48 +02:00
Cubic Love eadef3e5c3 Base: Add web server tip to Tips-and-Tricks(7)
Add the very useful tip of how to transfer files from QEMU to your host
machine via the built-in web server.
2023-05-07 07:08:58 +02:00
Nico Weber 0d2e6162db LibGfx/WebP: Implement compressed ALPH chunk reading
A compressed ALPH chunk is a lossless webp bitstream, but without
the 5 byte "header" that stores width, height, is-alpha-channel-used
(it never is for an ALPH chunk since the ALPH chunk gets the alpha
data out of the lossless webp's green channel), and version fields.

For that reason, this cuts decode_webp_chunk_VP8L() into the
header-reading part and the remaining part, so that the remaining
part can be called by the ALPH reading routine.

Lossy webp files with a (losslessly) compressed alpha channel can
be found in the wild. Since we can't decode lossy webp data yet,
change the `#if 0` in decode_webp_chunk_VP8() to `#if 1` to test this.
2023-05-07 07:08:05 +02:00
Nico Weber fab6a3915e LibGfx/WebP: Implement uncompressed ALPH chunk reading
ALPH chunks are only used to give lossy webp frames an alpha channel,
and lossy decompression isn't implemented yet. So this can currently
never be hit in practice -- but for debugging and testing, I put in
some code behind `#if 0` for now that fake-decompresses a lossy webp
frame by returning an empty bitmap.

But this also doesn't implement compressed ALPH chunks yet, and I
couldn't find any lossy-webp-with-alpha files that use uncompressed
alpha channels. So the code here isn't really tested.
2023-05-07 07:08:05 +02:00
Nico Weber e9f5c9ab9d Tests/LibGfx: More preparation for lossy and alpha handling
If someone comes along who wants to implement lossy webp decoding,
they now only need to implement decode_webp_chunk_VP8() and everything
might Just Work.

It also makes it possible to implement alpha chunk decoding before
implementing lossy decoding (by making decode_webp_chunk_VP8()
return an empty black bitmap for testing).
2023-05-07 07:08:05 +02:00
Nico Weber 23386ac73a LibGfx/WebP: Extract a decode_webp_image_data() function
That way, animated and non-animated webp files use the same code path
to decode images. That will make it easier to add handling for lossy
decompression and for alpha chunk handling.

No behavior change.
2023-05-07 07:08:05 +02:00
Nico Weber ae7e26e095 Tests/LibGfx: Add some test coverage for animated webp decoding
Also add two FIXME comments for lossy decoding.
2023-05-07 07:08:05 +02:00
Cubic Love 18d527fce1 Base: Improve Assistant App Icon (16px)
I've been unsatisfied with the current Assistant app icon (16px).
After trying many variations, I have ended-up with this. The changes
may be slight, but the bow tie now has a more natural shape including
a more prominent knot, bringing it more inline with the 32px version.
Plus the shading has been tweaked.
2023-05-07 06:33:13 +02:00
Aliaksandr Kalenik 038283f3fc LibWeb: Rename function to find table box width inside table wrapper
compute_table_box_width_inside_table_wrapper should be a better name
considering what this function does.
2023-05-07 06:31:53 +02:00
Aliaksandr Kalenik 3a605d8c19 LibWeb: Set width in compute_width_for_table_wrapper()
Width of table wrapper need to be set to to calculate width of table
box inside. Otherwise TFC will set wrong width assuming width of
containing block is 0.
2023-05-07 06:31:53 +02:00
Timothy Flynn 88e060907b LibWeb: Implement IDL overload resolution steps to clamp argument counts
There is a NOTE in our implementation of these steps which states that
the effective overload set only contains overloads with the correct
number of arguments. While this is true, we should not skip the steps to
clamp the inspected argument count to that correct number. Otherwise, we
will dereference past the end of the overload set's type list as we
blindly iterate over the user-provided arguments.

Fixes #18670.
2023-05-07 06:30:27 +02:00
Andreas Kling fc3c3aef22 LibWeb: Enforce min/max height constraints on abspos replaced boxes
Fixes #18658
2023-05-07 06:28:47 +02:00
Ben Wiederhake 36ff6187f6 Everywhere: Change spelling of 'behaviour' to 'behavior'
"The official project language is American English […]."
5d2e915623/CONTRIBUTING.md?plain=1#L30

Here's a short statistic of the occurrences of the word "behavio(u)r":

$ git grep -IPioh 'behaviou?r' | sort | uniq -c | sort -n
      2 BEHAVIOR
     24 Behaviour
     32 behaviour
    407 Behavior
    992 behavior

Therefore, it is clear that "behaviour" (56 occurrences) should be
regarded a typo, and "behavior" (1401 occurrences) should be preferred.

Note that The occurrences in LibJS are intentionally NOT changed,
because there are taken verbatim from the specification. Hence:

$ git grep -IPioh 'behaviou?r' | sort | uniq -c | sort -n
      2 BEHAVIOR
     10 behaviour
     24 Behaviour
    407 Behavior
   1014 behavior
2023-05-07 01:05:09 +02:00
Ben Wiederhake d5f8dac2bd dungeonrush: Fix typo in patches 2023-05-07 01:05:09 +02:00
Ben Wiederhake ee47c0275e Everywhere: Run spellcheck on all documentation 2023-05-07 01:05:09 +02:00
Cubic Love a7600caea1 Base+Snake: Capitalize snake skin names
In Snake, the menu for choosing a skin looked messy due to
inconsistent capitalization. Two skins names were entirely lowercase.
For the sprite-based skins, the menu takes the name of each skin's
directory, so I have capitalized these.

Capitalizing the original snake skin required more change than simply
renaming a directory.
2023-05-06 22:19:41 +02:00
Ben Wiederhake 4b7639c3b5 LibGfx+WindowServer: Ensure constrain-to-rect ends up inside the rect 2023-05-06 22:04:46 +02:00
MacDue 4c2ad70066 Toolchain: Use ninja to bootstrap CMake
For some reason (for me) on Ubuntu 22.04 the standard make generator
fails:

  ---------------------------------------------
  CMake has bootstrapped.  Now run gmake.
  make: make: Permission denied
  make: *** [Makefile:166: all] Error 127

This seems to be because Source/kwsys/CMakeFiles/cmsys.dir/depend is
missing or not generated. Using ninja works fine though, and as it is
already the default for Serenity proper, it seems reasonable to switch
it here too.
2023-05-06 22:04:12 +02:00
Nico Weber 36c8c1129b LibGfx/WebP: Use context.error() in animation frame decoding function
That also sets the error state on the context.
2023-05-06 21:17:18 +02:00
Nico Weber 40e839fd7e image: Add a --frame-index option 2023-05-06 21:17:18 +02:00
Nico Weber ce45ad6112 LibGfx/WebP: Implement decoding of animation frame bitmaps
With this, lossless animated webp files work :^)

(Missing: Loop count handling is not yet implemented, and alpha blending
between frames isn't done in linear space.)
2023-05-06 21:17:18 +02:00
Nico Weber 23ce1f641c LibGfx/WebP: Check that animation frame dimensions are in bounds 2023-05-06 21:17:18 +02:00
Nico Weber 0b70ecb7e6 LibGfx/WebP: Make decode_webp_chunk_VP8L() return a Bitmap
...instead of setting it on the context. We'll need this to decode
animation frames.
2023-05-06 21:17:18 +02:00
Nico Weber 1334bac548 LibGfx/WebP: Extract an ImageData struct
We'll need the same struct for animation frames.
2023-05-06 21:17:18 +02:00
Nico Weber 03b04ed66a LibGfx/WebP: Check ICCP chunk precedes alpha and animation frame chunks 2023-05-06 21:17:18 +02:00
Andreas Kling 41d518669e LibWeb: Remove weird CSS::Length::resolved() API
This API is no longer used by anyone so let's remove it.
2023-05-06 21:14:38 +02:00
Andreas Kling c6309bce0b LibWeb: Stop using weird resolved() in FilterValueListStyleValue 2023-05-06 21:14:38 +02:00
Andreas Kling 6ccb77a9b8 LibWeb: Stop using weird Length::resolved() in {Block,}FormattingContext 2023-05-06 21:14:38 +02:00
Andreas Kling 07815dacf8 LibWeb: Don't use weird resolved() when calculating abspos box height 2023-05-06 21:14:38 +02:00
Andreas Kling 7eb9e730e0 LibWeb: Remove unused variable in FormattingContext 2023-05-06 21:14:38 +02:00
Andreas Kling 4699365a64 LibWeb: Stop using weird resolved() in calculate_inner_{width,height}() 2023-05-06 21:14:38 +02:00
Andreas Kling 452a527ff3 LibWeb: Don't use weird resolved() for insets in FormattingContext 2023-05-06 21:14:38 +02:00
Andreas Kling 1d76126abe LibWeb: Don't use weird Length::resolved() for padding in BFC 2023-05-06 21:14:38 +02:00
Andreas Kling c9223528a0 LibWeb: Get rid of weird Length::resolved() usage in LayoutState
The second call to resolved() turns non-finite lengths into "auto".
This is a very strange ad-hoc behavior that we need to get rid of.
2023-05-06 21:14:38 +02:00
Andreas Kling ca1fa5f748 LibWeb: Use the new to_px() helpers in CSS, SVG and layout code
There should be no behavior change from this, only slightly less
verbosity. :^)
2023-05-06 18:41:34 +02:00
Andreas Kling cdf0d3e905 LibWeb: Add to_px() helpers to CSS::Size and CSS::PercentageOr<T>
Old pattern:

    foo.resolved(node, reference_value).to_px(node)

New pattern:

    foo.to_px(node, reference_value)

Also, the reference value for to_px() is a CSSPixels, which means we
don't have to synthesize a CSS::Length just for this call.
2023-05-06 18:41:34 +02:00
Andreas Kling 3e62ab996d LibWeb: Put debug spam about unimplemented calc() expansion behind flag 2023-05-06 18:41:34 +02:00
Andreas Kling f09391dd7f LibWeb: Remove debug spam when creating a dummy formatting context
This will go away when we get rid of the dummy context. There's no value
in spamming the debug console about it.
2023-05-06 18:41:34 +02:00
Andreas Kling ecd3d0935a LibWeb: Re-lookup the intrinsic sizing cache slot after doing the layout
It's not safe to hold on to a pointer to the cache slot across layout
work, since the nested layout may end up causing new entries to get
added to the cache, potentially invalidating a cache slot pointer.
2023-05-06 18:41:34 +02:00
Andreas Kling 134717ec8f LibWeb: VERIFY that nobody tries to hash a non-finite CSSPixels value
Non-finite CSSPixels quantities should never make their way into hash
tables. If this ever happens, let's catch it closer to the source
instead of letting things cascade into confusion.
2023-05-06 18:41:34 +02:00
Karol Kosek 7e4db556eb ThemeEditor: Remove one usage of DeprecatedString
Up until 3d53dc8228, to_string(ColorRole)
returned char*, which prevented us from directly creating a String
class.
2023-05-06 16:12:11 +01:00
Maciej 5d2e915623 LibJS: Guard against stack overflow in ProxyObject set_property()
For similar reason as in the previous commit.
2023-05-06 06:46:02 -07:00