Commit graph

59149 commits

Author SHA1 Message Date
Nico Weber
0dee94ef40 LibPDF+LibGfx: Do not try to read "hmtx" table for PDFs
It is sometimes truncated in fonts embedded in PDFs, and the data
is not needed to render PDFs. 26 of my 1000 test files complained
"Could not load Hmtx: Not enough data" before.

Increases number of PDFs that render without diagnostics from
743 to 764.
2024-02-21 13:38:33 +01:00
Nico Weber
5efe80af7f LibPDF+LibGfx: Do not try to read "name" table for PDFs
It is often missing in fonts embedded in PDFs. 75 of my 1000 test
files complained "Font is missing Name" when trying to read fonts
before.

Increases number of PDFs that render without diagnostics from
682 to 743.
2024-02-21 13:38:33 +01:00
Nico Weber
41eca52b50 LibGfx/OpenType: Tweak Font::try_load_from_externally_owned_memory()
It now takes an Options object instead of passing several default
parameters.

No behavior change.
2024-02-21 13:38:33 +01:00
Nico Weber
3b616b6af8 LibPDF: Use original error for failing ICC load 2024-02-21 13:37:08 +01:00
Nico Weber
275542aaf8 LibGfx/ICC: Add another version of the Apple P3 profile to quirks list
Improves appearance of page 6 of
https://fredrikbk.com/publications/copy-and-patch.pdf
2024-02-21 13:37:08 +01:00
Nico Weber
0160f737e2 LibGfx/ICC+icc: Be lenient about invalid profile creation datetimes
Before, we used to reject profiles where the creation datetime was
invalid per spec. But invalid dates happen in practice (most commonly,
all fields set to 0). They don't affect profile conversion at all,
so be lenient about this, in exchange for slightly more wordy code
in the places that want to show the creation datetime.

Fixes a crash rendering page 2 of
https://fredrikbk.com/publications/copy-and-patch.pdf
2024-02-21 13:37:08 +01:00
Tim Ledbetter
3b7c252175 LibWeb: Implement AbortSignal.abort()
This returns an AbortSignal that is already set as aborted.
2024-02-21 10:34:44 +01:00
Nico Weber
fa95e5ec0e LibPDF: Fix line drawing when line_width is 0
We used to skip lines with width 0. The correct behavior per spec
is to draw them one pixel wide instead.
2024-02-21 10:30:57 +01:00
Andrew Kaster
0dde88d714 LibWeb: Treat global as EventTarget in notify_about_rejected_promises
We only need to know that the Global Object of the environment is an
event target in order to dispatch an event on it. This resolves a FIXME
where we assumed that the only type of Global in LibWeb is HTML::Window.
2024-02-21 10:11:59 +01:00
Andrew Kaster
9d7e234439 Tests/WPT: Update expectations metadata for new passing tests 2024-02-21 10:10:44 +01:00
Andrew Kaster
cb68c6eaf1 LibWeb: Set size of canvas used to take WebDriver screenshots explicitly
The default canvas size is 300x150 pixels. If the element or document
we are trying to screenshot for the WebDriver is not at least that size,
then we will create a canvas that is wider or taller than the actual
element we are painting, resulting in a bunch of transparent pixels
falling off the end.

This fixes 14 WPT css/CSS2/floats tests that we run in CI, and
presumably a ton of other reftests in the WPT test suite.
2024-02-21 10:10:44 +01:00
Aliaksandr Kalenik
aee5120078 LibWeb: Fix infinite recursion when grid has "max-width: max-content"
With this change "max-width: max-content" is treated as "none" when
the available width is also "max-content". This fix prevents a stack
overflow in the grid track size maximization algorithm by avoiding
recursive calls to calculate_max_width() when determining the maximum
grid container size.
2024-02-21 10:06:19 +01:00
Lucas CHOLLET
8e2102fb73 ImageViewer: Transform the image's dimension accordingly to the metadata
Exif metadata have two tags to store the pixel density along each axis.
If both values are different and no action is taken, the resulting image
will appear deformed. This commit scales the displayed bitmap
accordingly to these tags in order to show the image in its intended
shape. This unfortunately includes a lot of plumbing to get this
information through IPC.
2024-02-21 08:31:17 +00:00
Lucas CHOLLET
8dd887b3c8 LibGfx: Make FloatPoint compatible with IPC 2024-02-21 08:31:17 +00:00
Lucas CHOLLET
41c76e6ba6 LibGfx/TIFF: Add Rational::as_double() 2024-02-21 08:31:17 +00:00
Andreas Kling
660d6d0c85 Meta: Add Polar to FUNDING.yml
Let's advertise the fact that we allow sponsoring work on specific
issues via Polar rewards. :^)
2024-02-21 07:36:55 +01:00
Timothy Flynn
e52c30cbd5 LibWeb: Allow bypassing transient activation checks for tests
We have a 5 second timeout between a user-activated event occurring and
an activation-gated API being invoked in order for that API to succeed.
This is quite fine in normal circumstances, but the machines used in CI
often exceed that limit (we see upwards of 10 seconds passing between
generating the user-activated event and the API call running).

So instead of generating a user-activated event, add a hook to allow
tests to bypass the very next activation check.
2024-02-20 18:53:59 -05:00
Timothy Flynn
4bdcf9a4b7 LibJS: Revert the free stack limit back to 32 KiB 2024-02-20 16:24:09 -05:00
Timothy Flynn
8eaf48888e LibJS: Remove FLATTEN attribute from Interpreter::run_bytecode
This is what caused stack usage to increase so much with the new BC.
Revert it for now so we can restore our old stack limit.
2024-02-20 16:24:09 -05:00
Andreas Kling
9a0a5a79f4 LibJS/Bytecode: Put arguments directly in the Call instruction
Instead of having Call refer to a range of VM registers, it now has
a trailing list of argument operands as part of the instruction.

This means we no longer have to shuffle every argument value into
a register before making a call, making bytecode smaller & faster. :^)
2024-02-20 21:25:18 +01:00
Andreas Kling
da107ec9fb LibJS/Bytecode: Add fast paths for many binary expression instructions
By handling common cases like Int32 arithmetic directly in the
instruction handler, we can avoid the cost of calling the generic helper
functions in Value.cpp.
2024-02-20 21:25:18 +01:00
Andreas Kling
9d9b737a58 LibJS/Bytecode: Dedicated instructions for postfix increment/decrement
Instead of splitting the postfix variants into ToNumeric + Inc/Dec,
we now have dedicated PostfixIncrement and PostfixDecrement instructions
that handle both outputs in one go.
2024-02-20 21:25:18 +01:00
Aliaksandr Kalenik
c4f49e343a LibWeb: Fix division by zero in solve_replaced_size_constraint()
Fixes crashes that occur in Discord after clicking on a direct messages
conversation.
2024-02-20 20:35:34 +01:00
Timothy Flynn
3ac4b02604 LibJS: Further increase the free stack limit to 256 KiB
128 KiB seems to not be enough for CI.
2024-02-20 12:29:27 -05:00
Timothy Flynn
af57bd5cca LibWeb: Stop parsing after document.write at the insertion point
If a call to `document.write` inserts an incomplete HTML tag, e.g.:

    document.write("<p");

we would previously continue parsing the document until we reached a
closing angle bracket. However, the spec states we should stop once we
reach the new insertion point.
2024-02-20 17:04:36 +01:00
Timothy Flynn
64dcd3f1f4 LibWeb: Restore the previous tokenizer iterator after inserting input
Otherwise, m_prev_utf8_iterator still points at the old source.
2024-02-20 17:04:36 +01:00
Timothy Flynn
fcf83a8ed0 LibWeb: Allocate fewer strings during document.write 2024-02-20 17:04:36 +01:00
Timothy Flynn
338f0382d3 LibWebView: Escape HTML within attribute values in the Inspector HTML
If an attribute value contains HTML, let's make sure we render it as
text, instead of injecting HTML in the middle of an Inspector field.
2024-02-20 17:04:36 +01:00
Timothy Flynn
fd558a012b LibWebView: Do not embed text as data in the Inspector HTML
We were previously embedding the original text to handle the special
case where the text is empty. We generate an extra span to hold the
string "#text" as a placeholder, so that we don't generate a 0px-wide,
unclickable (and therefore uneditable) node. Instead, we can just detect
when this is the case in the Inspector JS.

This further reduces the generated HTML for the Inspector on
https://github.com/SerenityOS/serenity from 1.9MB to 1.8MB (about 94KB,
or 4.7%).
2024-02-20 17:04:36 +01:00
Timothy Flynn
f07f5a2622 LibWeb+WebContent: Do not embed attributes as data in the Inspector HTML
Attribute values may contain HTML, and may contain invalid HTML at that.
If the latter occurs, let's not generate invalid Inspector HTML when we
embed the attribute values as data attributes. Instead, cache the values
in the InspectorClient, and embed just a lookup index into the HTML.

This also nicely reduces the size of the generated HTML. The Inspector
on https://github.com/SerenityOS/serenity reduces from 2.3MB to 1.9MB
(about 318KB, or 13.8%).
2024-02-20 17:04:36 +01:00
Timothy Flynn
939779cad3 LibWeb: Support nullable integral IDL types
We currently support optional integral types, but not nullable types. So
if an IDL contains e.g. "long?", passing null will be coerced to 0.

This will be used by the Inspector, but will also eventually be used by
real IDL interfaces (e.g. HTMLInputElement's selectionStart).
2024-02-20 17:04:36 +01:00
Nico Weber
1cb450e9a3 LibPDF: Give CFF Glyph 0 the name .notdef
This is required by the CFF spec, and is consistent with what we do for
the encoding 24 lines down.

As far as I can tell, nothing in `Type1FontProgram::rasterize_glyph()`
or in Type1Font.cpp implements the "If an encoding maps to a character
name that does not exist in the Type 1 font pro- gram, the .notdef glyph
is substituted." line from the PDF 1.7 spec (in 5.5.5 Character
Encoding, Encodings for Type 1 Fonts) yet, so this does yet have an
effect.
2024-02-20 06:54:50 -05:00
Shannon Booth
0b457f90e0 LibJS: Fix copy paste errors in Temporal's Calendar Methods Record
This adapts our implementation to the editorial change in the temporal
proposal: https://github.com/tc39/proposal-temporal/commit/737baf2d

The changes to CalendarMethodsRecordLookup had already been implemented,
but we had followed the typo in the spec for CalendarMethodsRecordCall.
The issue in CalendarMethodsRecordCall hasn't surfaced yet, as the AOs
using Calendar Methods Record are currently not passing through a String
to represent a Calendar builtin.

No change to test-262.
2024-02-20 06:54:32 -05:00
Ali Mohammad Pur
99f8ac84ef Tests/LibWeb: Make the WPT runner grab only the one commit it needs 2024-02-20 11:11:19 +01:00
Aliaksandr Kalenik
036cd9b2dd LibWeb: Null layout and paintable pointers of removed DOM::Node
When a node is removed from the DOM tree, its paintable needs to be
removed to ensure that it is not used to obtain sizes that are no
longer valid.

This change enables the ResizeObserver to send a notification if a node
is removed, as it should, because a removed node now has a size of zero

It should be okay to nullify pointers without concerning
parent/sibling/child relationships because the layout and paintable
trees will be rebuilt following any DOM mutation anyway.
2024-02-20 10:55:10 +01:00
Aliaksandr Kalenik
2b7e7cc1ad LibWeb: Implement ResizeObserver::disconnect() 2024-02-20 10:55:10 +01:00
Aliaksandr Kalenik
70a0f07732 LibWeb: Implement ResizeObserver::unobserve() 2024-02-20 10:55:10 +01:00
Aliaksandr Kalenik
fcf293a8df LibWeb: Implement gathering and broadcasting of resize observations
Extends event loop processing steps to include gathering and
broadcasting resize observations.

Moves layout updates from Navigable::paint() to event loop processing
steps. This ensures resize observation processing occurs between layout
updates and painting.
2024-02-20 10:55:10 +01:00
Aliaksandr Kalenik
8ba18dfd40 LibWeb: Schedule repainting from EventLoop::process()
In this change, updating layout and painting are moved to the EventLoop
processing steps. This modification allows the addition of resize
observation dispatching that needs to happen in event loop processing
steps and must occur in the following order relative to layout and
painting:

1. Update layout.
2. Gather and broadcast resize observations.
3. Paint.
2024-02-20 10:55:10 +01:00
Aliaksandr Kalenik
fb8edcea00 LibWeb: Flesh out implementation of ResizeObserver interfaces
Adds the initial implementation for interfaces defined in the
ResizeObserver specification. These interfaces will be used to
construct and send observation events in the upcoming changes.
2024-02-20 10:55:10 +01:00
Andreas Kling
fb4c632309 LibJS: Throw "call stack size exceeded" exception a bit earlier
This number is pure guesswork but it appears to fix GCC builds with
both ASAN and UBSAN hitting a native stack overflow before we have
a chance to catch it on our Azure CI.
2024-02-20 10:54:52 +01:00
Timothy Flynn
13ed003be1 LibWeb: Extract common integral IDL generators to a helper
We currently repeat the same generator code for all 7 integral types
that we generate C++ for. Extract it to a helper.
2024-02-20 10:20:29 +01:00
Nico Weber
05a7482118 LibPDF/CFF: Add dbgln() when failing encoding bounds check 2024-02-20 08:43:10 +00:00
Nico Weber
4705d38fa7 LibPDF/CFF: Fix off-by-one when reading internal encoding
We use `i - 1` to index these arrays, so that's what we should use
for the bounds check as well.
2024-02-20 08:43:10 +00:00
Timothy Flynn
abaca60f9a Tests/LibWeb: Move LibWeb test SVGs to their own directory 2024-02-19 22:11:59 -05:00
Timothy Flynn
e030193e5f Tests/LibWeb: Move LibWeb test frames to their own directory
We currently have a handful of iframe tests whose sources are in the
"input" directory. This means they get run as their own tests, when they
are really just helper files. We've had to add empty test expectation
files for these "tests", and invoke a dummy test() method just to keep
the test runner happy.

Instead, move them to their own directory so the test runner does not
see them at all.
2024-02-19 22:11:59 -05:00
Refrag
f77e91e0f0 Ports: Remove SRB2 mouse hacks
This patch builds off the previous commit and removes the mouse hacks
entirely as they are not needed anymore.

With this, Sonic Robo Blast 2 now correctly locks the mouse inside the
game and makes for a much better playing experience! :^)
2024-02-20 00:20:18 +01:00
Refrag
33b772a7fa Ports: Implement SDL2 mouse warping
This patch implements the mouse warping functionality of SDL2.
This adds a WarpMouse function implementation to the SDL2 port.
SDL2 will then be able to use this for it's relative mouse mode
implementation.

With this, multiple ports depending on SDL2 now correctly lock the
mouse inside the window and it improves the experience significantly.

Note that as of now, you may need to pass the kernel argument
'vmmouse=off' in order to test these changes properly.
2024-02-20 00:20:18 +01:00
Jelle Raaijmakers
aa3a6767f6 LibGL+LibGPU+LibSoftGPU: Implement blend equations
This implements support for `glBlendEquation` and
`glBlendEquationSeparate`. These functions modify the calculation of the
resulting color in blending mode.
2024-02-19 23:23:40 +01:00
Jelle Raaijmakers
55668c3e48 LibGfx: Implement AK::min/max for Gfx::VectorN
These return a new `Gfx::VectorN` with the minimum or maximum value of
each element.
2024-02-19 23:23:40 +01:00