Commit graph

59136 commits

Author SHA1 Message Date
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
Andreas Kling
e46b217e42 LibJS/Bytecode: Move to a new bytecode format
This patch moves us away from the accumulator-based bytecode format to
one with explicit source and destination registers.

The new format has multiple benefits:

- ~25% faster on the Kraken and Octane benchmarks :^)
- Fewer instructions to accomplish the same thing
- Much easier for humans to read(!)

Because this change requires a fundamental shift in how bytecode is
generated, it is quite comprehensive.

Main implementation mechanism: generate_bytecode() virtual function now
takes an optional "preferred dst" operand, which allows callers to
communicate when they have an operand that would be optimal for the
result to go into. It also returns an optional "actual dst" operand,
which is where the completion value (if any) of the AST node is stored
after the node has "executed".

One thing of note that's new: because instructions can now take locals
as operands, this means we got rid of the GetLocal instruction.
A side-effect of that is we have to think about the temporal deadzone
(TDZ) a bit differently for locals (GetLocal would previously check
for empty values and interpret that as a TDZ access and throw).
We now insert special ThrowIfTDZ instructions in places where a local
access may be in the TDZ, to maintain the correct behavior.

There are a number of progressions and regressions from this test:

A number of async generator tests have been accidentally fixed while
converting the implementation to the new bytecode format. It didn't
seem useful to preserve bugs in the original code when converting it.

Some "does eval() return the correct completion value" tests have
regressed, in particular ones related to propagating the appropriate
completion after control flow statements like continue and break.
These are all fairly obscure issues, and I believe we can continue
working on them separately.

The net test262 result is a progression though. :^)
2024-02-19 21:45:27 +01:00
Andreas Kling
7f1a62a1d3 LibJS/Bytecode: Add Operand in/out to all the bytecode codegen helpers
This is pure prep work for refactoring the bytecode to use more operands
instead of only registers.

generate_bytecode() virtuals now return an Optional<Operand>, and the
idea is to return an Operand referring to the value produced by this
AST node.

They also take an Optional<Operand> "preferred_dst" input. This is
intended to communicate the caller's preference for an output operand,
if any. This will be used to elide temporaries when we can store the
result directly in a local, for example.
2024-02-19 21:45:27 +01:00
Andreas Kling
e46de4eb59 LibJS/Bytecode: Add constants table to Bytecode::Executable 2024-02-19 21:45:27 +01:00
Andreas Kling
3466771492 LibJS/Bytecode: Add Bytecode::Operand
An Operand is either a register, a local, or a constant (index into the
executable's constant table)
2024-02-19 21:45:27 +01:00
Andreas Kling
c0ec924dc9 LibJS/Bytecode: Exclude extra tables from bytecode executable dumps 2024-02-19 21:45:27 +01:00
Andreas Kling
aada76d0fb LibJS: Don't dump variables multiple times in AST dumps 2024-02-19 21:45:27 +01:00
Andreas Kling
1d29f9081f LibJS: Remove JIT compiler
The JIT compiler was an interesting experiment, but ultimately the
security & complexity cost of doing arbitrary code generation at runtime
is far too high.

In subsequent commits, the bytecode format will change drastically, and
instead of rewriting the JIT to fit the new bytecode, this patch simply
removes the JIT instead.

Other engines, JavaScriptCore in particular, have already proven that
it's possible to handle the vast majority of contemporary web content
with an interpreter. They are currently ~5x faster than us on benchmarks
when running without a JIT. We need to catch up to them before
considering performance techniques with a heavy security cost.
2024-02-19 21:45:27 +01:00
Matthew Olsson
cac11ac891 LibWeb: Use [ExplicitNull] in Animation.idl 2024-02-19 14:51:56 -05:00
Matthew Olsson
39f5e32ee9 IDLGenerators: Add support for custom attribute [ExplicitNull]
This can apply to optional, nullable parameters of platform types. This
will cause the generator to generate the type as
Optional<JS::GCPtr<T>> rather than JS::GCPtr<T>, allowing the
implementation to differentiate between the case where the argument was
not passed, and the case where null or undefined was passed.

Needing to differentiate these two cases is quite niche, hence why it is
an opt-in behavior.
2024-02-19 14:51:56 -05:00
Aliaksandr Kalenik
591c8d2b68 LibWeb: Return overflow rect height from Element::scroll_height()
Spec says that this function has to return "height of the element
scrolling area" which is height of "scrolling overflow rect" in our
model.
2024-02-19 20:07:12 +01:00
Aliaksandr Kalenik
9f581d0bc9 LibWeb: Return overflow rect width from Element::scroll_width()
Spec says that this function has to return "width of the element
scrolling area" which is width of "scrolling overflow rect" in our
model.
2024-02-19 20:07:12 +01:00
Aliaksandr Kalenik
89319cd0c9 LibWeb: Make sure layout is up to date in Element::scroll_height() 2024-02-19 20:07:12 +01:00
Aliaksandr Kalenik
639e9b5012 LibWeb: Make sure layout is up to date in Element::scroll_width() 2024-02-19 20:07:12 +01:00