Commit graph

58277 commits

Author SHA1 Message Date
Andrew Kaster 3441b37de5 LibWeb: Store Promise::wait_for_all state in a JS-heap allocated object
The one current caller of this function always defers microtask
checkpoints before calling wait_for_all, ensuring that the promise
accept/reject handlers will always be called later in the Web event loop
processing. We need to store all the state for the closures in a heap
allocated object with HeapFunctions to keep it around while there are
still promises to resolve.
2024-01-19 11:47:59 +01:00
Andrew Kaster 346eb02659 LibWeb: Remove last substantial FIXMEs from Navigation API 2024-01-19 11:47:59 +01:00
Andrew Kaster 52a9a8146b LibWeb: Remove old FIXMEs about not setting up the navigation API's NHEs 2024-01-19 11:47:59 +01:00
Andrew Kaster 6c1944ee61 LibWeb: Flesh out apply the history step to setup the navigation API
We now populate the navigation history entries in the navigation API and
fire more navigation events as appropriate.
2024-01-19 11:47:59 +01:00
Andrew Kaster a8091c009b LibWeb: Add assorted AOs related to populating the navigation API's SHEs 2024-01-19 11:47:59 +01:00
Andrew Kaster 49e0466a3d LibWeb: Add state field to History
This is the "classic history API state" referenced in the current HTML
spec.
2024-01-19 11:47:59 +01:00
Andrew Kaster 2c27b4e63c LibWeb: Ensure an ESO is pushed before doing structured deserialization
We need to make sure that the given target realm is at the top of the
VM's execution context stack before doing any JS object construction
based on the data in our serialized buffer.
2024-01-19 11:47:59 +01:00
Andreas Kling 9f6841a65c LibWeb: Update layout before looking at overflow in window.scroll()
Fixes a crash seen on https://www.ekioh.com/
2024-01-19 09:16:54 +01:00
Tim Ledbetter 0d8a013ee1 SoundPlayer: Don't drop the unix pledge
Without it, `SoundPlayer` crashes as soon as you try to open a file.
2024-01-19 09:08:37 +01:00
Andrew Kaster 2505cecc0f LibWeb: Exclude [Global] interfaces from legacy platform object methods
Window and other global objects are not technically legacy platform
objects, and have other ways to override their setters and getters.

However, Window does need to share some code with the legacy platform
object paths, and simply adding another bool check to the mix seems
the shortest putt.
2024-01-19 09:02:00 +01:00
Timothy Flynn 2b22402c6a LibWeb: Correctly categorize Fetch responses as network errors
The condition here is flipped. From the spec:

     A network error is a response whose ... body is null ...
2024-01-18 23:10:56 +01:00
Aliaksandr Kalenik b317620486 LibWeb: Resolve relpos fragment offsets only for inline paintables
Prior to this change, we iterated through all fragments within each
PaintableWithLines to resolve the relative position offset. This
happened before transferring the fragments to their corresponding
inline paintables.

With this change, we significantly reduce amount of work by attempting
to resolve relative position offsets only for those contained within
inline paintables.

Performance improvement on https://html.spec.whatwg.org/
2024-01-18 19:41:34 +01:00
implicitfield de9fa25e11 cksum: Use the POSIX cksum algorithm rather than vanilla CRC32 2024-01-18 18:01:26 +03:30
implicitfield 05ee5ffa36 LibCrypto: Add support for the POSIX cksum algorithm 2024-01-18 18:01:26 +03:30
Tim Ledbetter 459fa8b840 LibPDF: Ensure that xref subsection numbers are u32
Previously, parsing an xref entry with a floating point subsection
number would cause a crash.
2024-01-18 15:11:42 +01:00
Nico Weber d2f3288666 LibPDF: Apply text matrix to each glyph's position
We still don't apply it to the glyph itself, so they don't show up
scaled or rotated, but they're at the right spot now.

One big thing this here hsa going for it is that the final glyph
position is now calculated with just
`ext_rendering_matrix.map(glyph_position)`.

Also, character_spacing and word_spacing are now used unmodified
in the SimpleFont::draw_string() loop. This also means we no longer
have to undo a scale when updating the position in
`Renderer::show_text()`.

Most of the rest stays pretty yucky though. The root cause of many
problems is that ScaledFont has its rendering sized baked into the
object. We want to render fonts at size font_size times scale from
text matrix times scale from current transformation matrix (but
not size from hotizontal_scaling). So we have to make that the
font_size, but then we have to undo that in a bunch of places to
get the actualy font size.

This will eventually get better when LibPDF moves off ScaledFont.
2024-01-18 14:01:30 +01:00
Nico Weber 09a91e54c0 Tests: Add a pdf with text rotation
As usual, lovingly hand-written, with offsets fixed up with

    mutool clean Tests/LibPDF/rotate.pdf  Tests/LibPDF/rotate.pdf
2024-01-18 14:01:30 +01:00
Nico Weber f54b0e7c22 LibPDF: Don't accidentally put horizontal_scaling in places
Fonts should have size font_size times total scaling. We tried to
get that by computing text_rendering_matrix.x_scale() * font_size,
but text_rendering_matrix.x_scale() also includes
horizontal_scaling, which shouldn't be part of font size.

Same for character_spacing and word_spacing.

This is all a big mess that's caused by LibPDF using ScaledFont,
which requires scaling to be aprt of the text type. I have an
in-progress local branch that moves LibPDF to directly use VectorFont,
which will hopefully make this (and other things) nicer. But first,
let's get this right, and then make sure we don't regress it when
things change :^)
2024-01-18 14:01:30 +01:00
Nico Weber abda5e66f6 LibPDF: Scale delta_x by horizontal_scaling in Renderer::show_text()
While PDFFont::draw_string() already returns a position scaled by
horizontal_scaling, the division by text_rendering_matrix.x_scale()
(which also contains the scaling factor) undid it. Reapply it.

Fixes the horizontal layout of the line
"should be the same on all lines: super" in Tests/LibPDF/text.pdf.
2024-01-18 14:01:30 +01:00
Nico Weber 470d1d8dcf LibPDF: Fix order of parameter, text, and current transform matrix
PDF spec 1.7 5.3.3 Text Space Details gives the correct multiplication
order: parameters * textmatrix * ctm.

We used to do text * ctm * parameters
(AffineTransform::multiply() does left-multiplication).

This only matters if `text_state().rise` is non-zero. In practice,
it's almost always zero, in which case the paramter matrix is a
diagonal matrix that commutes.

Fixes the horizontal offset of "super" in Tests/LibPDF/text.pdf.
2024-01-18 14:01:30 +01:00
Nico Weber 6c65c18c40 LibPDF: Add spec ref to Renderer::calculate_text_rendering_matrix() 2024-01-18 14:01:30 +01:00
Nico Weber 8507151850 Tests/LibPDF: Make text.pdf also use Tz, Tc, Tw, Ts operators
These set the horizontal scale factor, character spacing, word
spacing, and text rise respectively.

Also add a global scale transform, and set a text transform matrix
with a scale for some of the text.
2024-01-18 14:01:30 +01:00
Lucas CHOLLET 75d87ccf5f LibGfx/TIFF+CCITT: Start to decode CCITT Group 3 images
We currently only support 1D Group 3, but that's a start.

The test case was generated with GIMP (it happens to be 1D by chance).
2024-01-18 14:00:56 +01:00
Lucas CHOLLET 1cc10a6245 LibGfx/CCITT: Extract the code to decode a single CCITT3 1D line
This will be handy for the pure CCITT Group 3 decoder too :^)
2024-01-18 14:00:56 +01:00
Lucas CHOLLET 6a94b09029 LibGfx/TIFF: Make strip decoders take the strip height
While most decoders do not require it, it is necessary for the CCITT
Group 3 decoder.
2024-01-18 14:00:56 +01:00
Lucas CHOLLET 26494600c4 LibGfx/TIFF: Parse the T4Options CCITT field
This field is described in: Section 11: CCITT Bilevel Encodings.
2024-01-18 14:00:56 +01:00
Lucas CHOLLET edffdc35a9 LibGfx/TIFF+CCITT: Clarify naming of compression type 2
Type 2 <=> One-dimensional Group3, customized for TIFF
Type 3 <=> Two-dimensional Group3, uses the original 1D internally
Type 4 <=> Two-dimensional Group4

So let's clarify that this is not Group3 1D but the TIFF variant, which
is called `CCITTRLE` in libtiff. So let's stick with this name to avoid
confusion.
2024-01-18 14:00:56 +01:00
Lucas CHOLLET 9b50b5793b LibGfx/TIFF: Factorize code to verify that CCITT images are correct 2024-01-18 14:00:56 +01:00
Lucas CHOLLET a9a5ca6754 LibGfx/TIFF: Expose default value for numerical tags too
Due to the integer -> bool conversion rule, the condition was wrong. We
actually want to test for a not `None` state.
2024-01-18 14:00:56 +01:00
Bastiaan van der Plaat 5f5ac48908 LibWeb: Format all .idl files to use four space indentation 2024-01-18 14:00:06 +01:00
ronak69 d720fb8845 CMake: Set CMAKE_COLOR_DIAGNOSTICS to ON for colored diagnostics
This patch removes the explicit compile flag that only works for g++
(`-fdiagnostics-color=always`; clang++ needs `-fcolor-diagnostics`) and
uses CMake's built in variable that can control color output.

Now both compilers should output colored diagnostics.
2024-01-18 13:59:35 +01:00
Nicolas Ramz 534eeb6c4b LibGfx/ILBMLoader: Properly display images with a bitplane mask
Images with a display mask ("stencil" as it's called in DPaint) add
an extra bitplane which acts as a mask. For now, at least skip it
properly. Later we should render masked pixels as transparent, but
this requires some refactoring.
2024-01-18 13:59:17 +01:00
Tim Ledbetter 45181e8eaf Fuzzers: Continue if frame is malformed in GIF fuzzer 2024-01-18 13:59:04 +01:00
Tim Ledbetter 4173a9880f Fuzzers: Don't disable debug logging in GIF fuzzer if GIF_DEBUG is set 2024-01-18 13:59:04 +01:00
Tim Ledbetter d186582d30 LibAudio: Avoid UAF when loading WAV metadata 2024-01-17 16:09:59 -05:00
Bastiaan van der Plaat dc2233ef7a Ladybird+WebContent: Add chrome command line and exe path passing 2024-01-17 17:32:05 +01:00
Bastiaan van der Plaat c94fc7d3b0 Ladybird: Change default new tab URL to about:newtab 2024-01-17 17:32:05 +01:00
Aliaksandr Kalenik a22ef086f5 LibWeb/CSS: Support calc() in grid placement values
Fixes reduction in https://github.com/SerenityOS/serenity/issues/22802
but does not result in visual improvement on https://kotlinlang.org/
2024-01-17 17:26:55 +01:00
Aliaksandr Kalenik c254de3509 LibWeb: Remove duplicated code in grid auto track counting
This refactoring simplifies the resolution of minimum and maximum sizes
during the counting of auto tracks.

No changes in behavior are intended.
2024-01-17 17:25:58 +01:00
Andreas Kling 954c4496b1 LibWeb: Avoid more UsedValues hash lookups in BFC and IFC 2024-01-17 17:25:48 +01:00
Andreas Kling 7a34f1a4e2 LibWeb: Add pointer from BFC::FloatingBox to its UsedValues
This will allow us to skip a lot more hash lookups.
2024-01-17 17:25:48 +01:00
Andreas Kling 57fd494195 LibWeb: Use UsedValues containing block pointer in float layout 2024-01-17 17:25:48 +01:00
Andreas Kling 80ccfc51c2 LibWeb: Use UsedValues containing block pointer in many FC helpers 2024-01-17 17:25:48 +01:00
Andreas Kling 8e31bfb83c LibWeb: Give UsedValues a pointer to containing block UsedValues
This will allow us to skip hash lookups when traversing the containing
block chain and looking at everyone's UsedValues.
2024-01-17 17:25:48 +01:00
Aliaksandr Kalenik 0a09ff698f LibWeb: Fix accounting for gaps in auto-fit count calculation in GFC
Fixes a bug where gaps between repeated tracks were accounted for only
once instead of multiple times, corresponding to the repeat count.

Fixes https://github.com/SerenityOS/serenity/issues/22823
2024-01-17 15:15:06 +01:00
Nico Weber 13f007aadb LibPDF: Tweak vertical position of truetype fonts
The vertical coordinates for truetype fonts are different somehow.
We compensated a bit for that; now we compensate some more.

This is still not 100% perfect, but much better than before.
2024-01-17 08:44:07 +00:00
Nico Weber b5aef8e404 MacPDF: Add Debug menu items to hook up Clip Images/Paths settings 2024-01-17 08:42:56 +00:00
Nico Weber 1845a406ea LibPDF: Add debug settings for clipping paths and images 2024-01-17 08:42:56 +00:00
Nico Weber 2d8a22f4b4 LibPDF: Clip images too
Since we can't clip against a general path yet, this clips images
against the bounding box of the current clip path as well.

Clips for images are often rectangular, so this works out well.

(We wastefully still decode and color-convert the entire image.
In a follow-up, we could consider only converting the unclipped
part.)
2024-01-17 08:42:56 +00:00
Nico Weber 5615a2691a LibPDF: Extract activate_clip() / deactivate_clip() functions
No behavior change.
2024-01-17 08:42:56 +00:00