Commit graph

58035 commits

Author SHA1 Message Date
Nico Weber d8ada20bae LibGfx: Allow images to report that they are originally grayscale
...and implement it in JPEGLoader.

Since it's easy to get the grayscale data off a Bitmap, don't
add a grayscale_frame() accessor.
2024-01-10 09:39:00 +01:00
Nico Weber 239da5132d LibGfx/JPEG: Make it possible to obtain raw CMYK data from JPEGs
frame() still returns a regular RGB Bitmap (now lazily converted
from internal CMYK data), but JPEGImageDecoderPlugin now also
implements cmyk_frame().
2024-01-10 09:39:00 +01:00
Nico Weber 51d5397e92 LibGfx: Give ImageDecoder an API for getting raw CMYK data
frame() still returns a regular RGB Bitmap, but it's possible to also
get at raw CMYK data instead if desired, for image formats that can
store that.
2024-01-10 09:39:00 +01:00
Nico Weber bc6eebb1d7 LibGfx: Add CMYKBitmap
This is a simple container for 2d CMYK data.

This is a new class instead of a new format in Bitmap because:
* Almost all clients of Bitmap will want to deal with RGB data
* It keeps the ARGB32 typedef working
* Bitmap already does a lot of things

The idea is that a few select places will be able to use
CMYKBitmap and a color profile to do a better CMYK -> RGB conversion
than an image decoder could do, and then store the result in a Bitmap
for later display then.

CMYKBitmap misses some of Bitmap's features, such as shared
memory support, high-dpi scaling capability, etc.
2024-01-10 09:39:00 +01:00
Nico Weber c997ee7b9d LibGfx+ImageViewer: Replace ImageDecoder::is_vector() with an enum
That makes it easier to extend to other special frame formats.
2024-01-10 09:39:00 +01:00
Bastiaan van der Plaat a47edb4ed1 LibWeb: Refactor unsigned to u32 in WebContentServer.ipc
The type u32 is already used almost everywhere in
WebContentServer.ipc except for the mouse and key
events so let's fix that.
2024-01-10 09:38:41 +01:00
Bastiaan van der Plaat 5c00e2bb7f LibWeb: Remove refusing to run script debug line
Many sites load application/json and application/ld+json
content with script elements, so this debug line shows
up on a lot of sites and is not informative.
2024-01-10 09:38:41 +01:00
Nico Weber 7fb32b6682 LibGfx: Fix off-by-some in Painter::draw_scaled_bitmap_with_transform()
Before this, drawing a 1x1 bitmap scaled up to MxN would only fill
M/2 x N/2 pixel, due to source_point going outside (0, 0).
2024-01-10 09:38:13 +01:00
Nico Weber 822b7720e1 Meta: Let test_pdf.py be less dramatic about issue counts
For every issue string, json['issues'][issue_string] contains a list
of (page, count_of_issue_on_this_page) tuples.

To get the total number the issue appears in the current document,
we need to add up all the count_of_issue_on_this_page, not multiply the
page number with count_of_issue_on_this_page and add those (-‸ლ)
2024-01-10 09:36:33 +01:00
Idan Horowitz 0befa77b99 CI: Update comment-on-pr version
The newer version installs a specific version of octokit, since the
latest version no longer supports the ruby installation in github
actions vms. This should resolve the CI issues.
2024-01-10 09:34:55 +01:00
Mr.UNIX 9507157f04 Escalator: Port Escalator to GML Compiler 2024-01-10 00:03:27 +01:00
Bastian Neumann 7d63b8b95f LibWeb/CSS: Remove nullpointer dereference in Parser
On platinenmacher.tech there is a document without a window. During
size attribute parsing the window pointer is dereferenced which
causes a crash. This checks for the window to be actually there
before dereferencing.
2024-01-09 18:38:16 +00:00
Sanil 343d6b001f Hearts: Port to GML compiler 2024-01-09 17:23:39 +01:00
Rawley 27339fe6e7 Ports: Bump perl5 to 5.38.2 2024-01-09 14:48:53 +01:00
Shannon Booth 72d0257a19 LibWeb: Add ref-test cases for reordered keywords in CSS positions
Where if 'center' is present the horizontal or vertical values must be
used to infer whether center is X or Y.
2024-01-09 13:37:35 +00:00
Shannon Booth 5b9a0e3fe7 LibWeb: Allow reordering of keywords in CSS positions
As the spec points out:
> Note that a pair of keywords can be reordered while a combination of
> keyword and length or percentage cannot. So center left is valid while
> 50% left is not.

This was a bug in our implementation of alternative 2 of css-values-3,
resulting in the following CSS failing to be parsed:

`background-position: center right;`

This commit fixes the issue as part of an update of the parsing to
css-values-4. As far as I can tell, the grammar is equivalent - but
simpler to implement due to the lack of optional values.

The fix for this issue is also as part of alternative 2 parsing in the
new grammar.

Progress towards: #22401
2024-01-09 13:37:35 +00:00
Andreas Kling 5b7a8891a6 LibWeb: Implement calc() value equality check in a more efficient way
Instead of serializing two calc() values to String and then comparing
those strings, we can now compare calc() values by actually traversing
their internal CalculationNode tree.

This makes style recomputation faster on pages with lots of calc()
values since it's now much cheaper to check whether a property with
some calc() value actually changed.
2024-01-09 14:15:27 +01:00
implicitfield c994326d5a LibWeb/CSS: Improve parsing of length percentage values for transforms 2024-01-09 14:15:05 +01:00
Andrew Kaster 480cbd9126 Meta: Update Fuzzili instructions and dockerfile since patch is upstream 2024-01-09 13:29:43 +01:00
MacDue 00b24a55b1 LibWeb: Fix drawing axis-aligned lines
Previously, these were clipped by the RecordingPainter, which used the
path's bounding box (which in this case is zero width or height). The
fix is to expand the bounding box by the stroke width.

Fixes #22661

Note: This is unrelated to any recent LibGfx changes :^)
2024-01-09 00:03:09 +01:00
MacDue fc41c282ec LibWeb: Fix utf16-be check in HTMLEncodingDetection
The utf-16be check mistakenly skipped index 3, so was not checking the
correct bytes. This meant UTF16-BE files could fail to decode.
2024-01-08 23:35:09 +01:00
MacDue 5e973fca0b LibWeb: Prevent OOB access in HTMLEncodingDetection for input of '</'
Previously, this never checked if `position + 2` was valid. This
slightly reorders the loop so all indices are checked.

Fixes #22163
2024-01-08 23:35:09 +01:00
Aliaksandr Kalenik 3f52d6045a LibWeb/CSS: Resolve percentages in NumericCalculationNode
Percentages should be resolved against the provided percentage basis
instead of just returning the underlying value.

Fixes https://github.com/SerenityOS/serenity/issues/22654
2024-01-08 15:57:42 +00:00
Nicolas Ramz 5e7e98cd3c LibGfx/ILBMLoader: Add support for transparent color 2024-01-08 07:21:27 -07:00
Nicolas Ramz fc5b6e4dda LiGfx/ILBMLoader: Don't throw if malformed bitplane can be decoded
Some apps seem to generate malformed images that are accepted
by most readers. We now only throw if malformed data would lead to
a write outside the chunky buffer.
2024-01-08 07:21:27 -07:00
Lee Hanken 7e3249ad4c LibAudio: Test reading and writing of wav files
Includes a set of wav files of different frequencies, these are
each loaded and then written to a temporary file, checking that
the meta-data is correctly read and that the output matches the input.
2024-01-08 07:20:11 -07:00
Lee Hanken 01930a7043 LibAudio: Correctly output mono wav files
Prevent two channels of data being written when the wav file is mono.
2024-01-08 07:20:11 -07:00
Andreas Kling aa245f9f18 LibWeb: Fix reverse flex layout with justify-content: normal
Before this change, we used the wrong insertion point for flex items
in reverse layouts with `justify-content: normal`. This caused flex
items to overflow the flex containers "backwards" from the start edge.
2024-01-08 14:42:19 +01:00
Aliaksandr Kalenik 6480ed20b8 LibWeb: Add support for implicit grid lines formed by grid areas in GFC
According to spec each grid area implicitly defines 4 additional named
lines that could be used to specify items position.
2024-01-08 09:28:37 +01:00
Aliaksandr Kalenik 92bf7d3ba7 LibWeb: Always add "ending" line during lines init in GFC
This moves us a bit toward correctly representing two separate concepts
from the spec: lines and tracks. Lines divide the grid into tracks, so
there should always be a line concluding the last track.
2024-01-08 09:28:37 +01:00
MacDue 9c3bb94d14 LibGfx: Trim scanline to right clip in path rasterizer
There's no need to accumulate past the right clip, so we also don't need
to store it.
2024-01-08 09:26:43 +01:00
MacDue ec93973158 LibGfx: Sprinkle some FLATTEN/hot attributes in the path rasterizer
This seems to actually improve performance to the tune of about +5 fps.
2024-01-08 09:26:43 +01:00
MacDue e2152a5b3d LibGfx: Clip path rasterizer scanlines sooner
This moves the clipping from per-pixel/draw command to a step before
the main drawing/plotting loop.
2024-01-08 09:26:43 +01:00
MacDue b1adabdac4 LibGfx: Fix off-by-one in path rasterizer
The start/end is inclusive so it's + 1 to the start to fill
`full_converage_count` pixels.
2024-01-08 09:26:43 +01:00
MacDue 13a4fb0325 LibGfx: Increase bezier splitting tolerance to 0.5
No noticeable difference a bit faster. This is still arbitrary and
should be somehow derived from the curve.
2024-01-08 09:26:43 +01:00
MacDue 65b87bace9 LibGfx: Move Gfx::color_for_format() to header 2024-01-08 09:26:43 +01:00
MacDue a1bafafd78 LibGfx: Slightly simplify Color::blend()
No behaviour change.
2024-01-08 09:26:43 +01:00
Aliaksandr Kalenik 5c02b960ab LibGfx: Take into account unicode ranges to find font for space glyph
Instead of assuming that the first font in the cascade font list will
have a glyph for space, we need to find it in the list taking into
account unicode ranges.
2024-01-08 01:00:24 +01:00
Timothy Flynn 8b32f4ae7a LibWebView+WebContent: Let the WebView client broadcast when it painted
When the WebContent process has painted to its shared bitmaps, it sends
a synchronous IPC to the browser process to let the chrome paint. It is
synchronous to ensure the WC process doesn't paint onto the backing
bitmap again while it is being displayed.

However, this can cause a crash at exit if the browser process quits
while the WC process is waiting for a response to this IPC.

This patch makes the painting logic asynchronous by letting the browser
process broadcast when it has finished handling the paint IPC. The WC
process will not paint anything again until it receives that message. If
it had tried to repaint while waiting for that message, that paint will
be deferred until it arrives.
2024-01-08 00:51:59 +01:00
Lucas CHOLLET 335097e446 LibGfx/TIFF: Modify the image according to the Orientation tag
Let's use the already existing logic (ExifOrientedBitmap) to modify the
bitmap to honor the orientation tag.
2024-01-08 00:07:44 +01:00
Lucas CHOLLET 367882ae23 LibGfx: Make ExifOrientedBitmap::oriented_size be public
This will be useful for image decoders to expose the image size while
considering the orientation. A rotated image might have different
dimensions.
2024-01-08 00:07:44 +01:00
Lucas CHOLLET 34e9059ae8 LibGfx/TIFF: Honor the default value for single count tags
Some tags have a default value, we should return this value in
Metadata's getters when no value has been read from the input file.

Note that we don't support default values for tags with a count bigger
than one.
2024-01-08 00:07:44 +01:00
Lucas CHOLLET ef10a58522 LibGfx: Remove ExifOrientedBitmap::Orientation in favor of TIFF's enum
ExifOrientedBitmap was implemented before the introduction of the TIFF
decoder. So we had to provide a definition of the Orientation enum. Now
that we have a TIFF implementation that comes with some enum
definitions, we should prefer this source.
2024-01-08 00:07:44 +01:00
Lucas CHOLLET e9ebe59081 LibGUI: Render thumbnails out of process
Process separation is a great way to prevent malicious users from
getting the GUI down with image files that make one of our decoder
crash.

It also makes life easier when developing image decoders.
2024-01-07 20:10:22 +01:00
Lucas CHOLLET 4e9e340d21 IPCCompiler: Make the connection shut down if the peer disconnected
If we know that the peer disconnected while receiving a message in the
generated code, let's shutdown the connection from here instead of
forcing each client to do so.
2024-01-07 20:10:22 +01:00
Lucas CHOLLET e56eb11dee ImageDecoder: Add plumbing to allow a client to request an ideal size
This is only used for vector graphics format where requesting the true
displayed size leads to visual enhancement.
2024-01-07 20:10:22 +01:00
Lucas CHOLLET 4c23f0e142 LibCore: Log a message before failure in EventLoop::current()
If no EventLoop is present in the stack (like when you forget to create
one), a message is nicer than letting the developer go through the
stacktrace to figure out what went wrong.
2024-01-07 20:10:22 +01:00
Andreas Kling ca57e40350 LibWeb: Take padding into account when resolving border radii
Before this change, we were resolving border radii values based on
content box + border widths only, ignoring padding.
2024-01-07 19:28:38 +01:00
Lucas CHOLLET 402de2985d LibGfx/ICO: Do not try to decode a mask if we already reached EOF
When using the BMP encoding, ICO images are expected to contain a 1-bit
mask for transparency. Regardless an alpha channel is already included
in the image, the mask is always required. As stated here[1], the
mask is used to provide shadow around the image.

Unfortunately, it seems that some encoder do not include that second
transparency mask. So let's read that mask only if some data is still
remaining after decoding the image.

The test case has been generated by truncating the 64 last bytes
(originally dedicated to the mask) from the `serenity.ico` file and
changing the declared size of the image in the ICO header. The size
value is stored at the offset 0x0E in the file and I changed the value
from 0x0468 to 0x0428.

[1]: https://devblogs.microsoft.com/oldnewthing/20101021-00/?p=12483
2024-01-07 12:32:02 -05:00
Lucas CHOLLET 9c54c13744 Tests/LibGfx: Move the ICO test file to the ico directory
And add more tests on the image than just "we are able to decode it".
2024-01-07 12:32:02 -05:00