Commit graph

58906 commits

Author SHA1 Message Date
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
Bastiaan van der Plaat
656f764b1b Ladybird/AppKit: Convert select dropdown position to correct scale 2024-02-19 13:36:58 -05:00
Timothy Flynn
b2104361cf Meta: Increase default VM RAM size to 2GiB
With 1GiB, we hit OOM loading GitHub in the browser. Increase the RAM
size to support normal use.
2024-02-19 10:41:03 -05:00
Matthew Olsson
1d98f812af LibWeb: Generate KeyframeSet in KeyframeEffect::set_keyframes
This is similar to the logic used in StyleComputer (except a bit closer
to the spec), and will eventually be shared between the two.
2024-02-19 12:21:48 +01:00
Matthew Olsson
1735f3d9aa LibWeb: Add keyframe state to KeyframeEffect
This was taken from StyleComputer, and will eventually be removed from
StyleComputer once we transition to using Web animations.
2024-02-19 12:21:48 +01:00
Matthew Olsson
7d5e17eddd LibWeb: Implement Animatable::animate() 2024-02-19 12:21:48 +01:00
Matthew Olsson
dd1fd5fe47 LibWeb: Add Animatable interface to Element 2024-02-19 12:21:48 +01:00
Matthew Olsson
bb527c4351 LibWeb: Add Animations::Animation to IDLGenerators 2024-02-19 12:21:48 +01:00
Timothy Flynn
94c67c364d LibWeb: Implement HTMLInputElement's selected coordinates
When an <input type=image> button is clicked, we now send the (x,y)
coordinates of the click event (relative to the image) along with the
form submission data.

Regarding the text test, we can currently only test this feature with
dialogs. The headless-browser test infrastructure cannot yet handle the
resulting navigation that would occur if we were to test with normal
form submission.
2024-02-19 11:07:30 +01:00
Timothy Flynn
36302388a3 LibWeb: Allow submitting forms whose submission URL is a file:// URL
In particular, this will allow us to test form submission on such URLs.
2024-02-19 11:07:30 +01:00
Timothy Flynn
986811d2aa LibWeb: Do not use HTMLFormElement::elements to get submittable elements
HTMLFormElement::elements is not the correct filter for submittable
elements. It includes non-submittable elements (HTMLObjectElement) and
also excludes submittable elements (HTMLInputElements in the "image"
type state, "for historical reasons").
2024-02-19 11:07:30 +01:00
Timothy Flynn
debb5690ce LibWeb: Begin implementing the HTMLInputElement 'image' type state
This implements enough to represent <input type=image> with its loaded
source image (or fallback to its alt text, if applicable). This does not
implement acquring coordinates from user-activated click events on the
image.
2024-02-19 11:07:30 +01:00
Timothy Flynn
45a47cb32b LibWeb: Generalize ImageBox and ImagePaintable for any ImageProvider
They currently assume the DOM node is an HTMLImageElement with respect
to handling the alt attribute. The HTMLInputElement will require the
same behavior.
2024-02-19 11:07:30 +01:00
Timothy Flynn
c4295edc81 LibWeb: Add ImageBox to forwarding header 2024-02-19 11:07:30 +01:00
Tim Ledbetter
02c2b1e67e LibWeb: Implement document.createCDATASection() 2024-02-19 10:42:56 +01:00
Tim Ledbetter
ee6b0e144a LibWeb: Make the default XML namespace an empty Optional
Previously, when constructing an XML document, the default namespace
was the empty string. This led to XML documents having empty xmlns
attributes when serialized.
2024-02-19 10:42:56 +01:00
Tim Ledbetter
1a249f9d85 LibWeb: Add ad-hoc method for serializing CDATASection nodes to string
Previously, CDATASection nodes were being serialized as if they were
text, which meant they were missing their start and end delimiters.
Occurrences of the '&', '<' and '>' characters were also being replaced
with their entity names.
2024-02-19 10:42:56 +01:00
Tim Ledbetter
70b9cddc48 LibWeb: Align Document::document_type() default with the specification
The DOM specification states that: "Unless stated otherwise, a
document’s [...] type is 'xml'".

Previously, calls to `Document::document_type()` were returning the
incorrect value for non-HTML documents.
2024-02-19 10:42:56 +01:00
Tim Ledbetter
f18ea096e0 LibWeb: Set correct document type when parsing XML with DOMParser 2024-02-19 10:42:56 +01:00
Nico Weber
27e369cd19 LibGfx/ICC: Add a one-element cache for CLUT conversions
Our current CLUT code is pretty slow. A one-element cache can make
it quite a bit faster for images that have long runs of a single
color, such as illustrations.

It also seems to help with photos some (in `0000711.pdf` page 1) --
I suppose even them have enough repeating pixels for it to be worth
it.

Some numbers, with `pdf --render-bench`:

`0000711.pdf --page 1` (high-res photo)
before: 2.9s
after: 2.43s

`0000277.pdf --page 19` (my nemesis PDF, large-ish illustration)
before: 2.17s
after: 0.58s (!)

`0000502.pdf --page 2` (wat hoe dat)
before: 0.66s
after: 0.27s

`0000521.pdf --page 10 ` (japanese)
before: 0.52s
after: 0.29s

`0000364.pdf --page 1` (4 min test case)
before: 0.48s
after: 0.19s

Thanks to that last one, reduces the time for
`time Meta/test_pdf.py ~/Downloads/0000` from 4m22s to 1m28s.

Helps quite a bit with #23157 (but high-res photos are still too
slow).
2024-02-19 07:16:05 +00:00
Nico Weber
6a8e418e40 pdf: Add a --render-bench option
It's similar to `--render <filename>.png`, but skips the "save to
file" step. Useful for benchmarking, in part because our png codec
is so slow.
2024-02-19 07:16:05 +00:00
Lucas CHOLLET
be9ec591e7 LibGfx/CCITT: Add support for Group3 2D
The two test images were created with:
tiffcp ccit3.tiff -c g3:2d ccit3_2d.tiff
tiffcp ccit3.tiff -c g3:2d:fill ccit3_2d_fill.tiff
2024-02-19 01:40:04 +01:00
Lucas CHOLLET
9116cc3f45 LibGfx/CCITT: Put the code to read the run length in its own function
This is already nice to do for the sole purpose of the readability but
that will also become handy for the 2D decoder.
2024-02-19 01:40:04 +01:00
Lucas CHOLLET
3d63dd5c53 LibGfx/CCITT: Make get_code_from_table take a generic Array 2024-02-19 01:40:04 +01:00
Lucas CHOLLET
d54dbdae5e LibGfx/CCITT: Introduce the invert helper
This function turns Black into White and White into Black.
2024-02-19 01:40:04 +01:00
Lucas CHOLLET
ce0ac70416 LibGfx/CCITT: Declare reference colors as static variables 2024-02-19 01:40:04 +01:00
Lucas CHOLLET
45b37010b5 Revert "LibGfx/CCITT: Don't overrun the image width"
This reverts commit a4b2e5b27b.

This was just plain wrong, I remember it making sense and fixing
something but that was probably due to local changes. It should never
have landed on master, my bad.
2024-02-19 01:40:04 +01:00
Sönke Holz
227818de9b Kernel/riscv64: Don't use the memory before .text as the initial stack
This new stack has the same size as the x86_64 prekernel stack (32K).
2024-02-19 00:41:17 +01:00
Tom Finet
3b6a300ed7 Kernel: Resolve FIXME relating to the gate type arg for x86 Interrupts
According to the Intel Software Developer's Manual Volume 3A section
6.12.1.3, the interrupt gate type means the IF flag is cleared to
prevent nested interruption. The trap gate type does not modify the
IF flag. Thus the gate type argument is important when constructing
an IDTEntry.
2024-02-19 00:16:05 +01:00
Tom Finet
9e8e93d91d Kernel: Remove storage_segment from IDTEntry constructor
On x86_64 and x86, storage_segment (bit 12 counting from 0)
is always 0 according to the Intel Software Developer's Manual,
volume 3A, section 6.11 and section 6.14.1. It has therefore
been removed as a parameter from IDTEntry's constructor and
hardwired to 0.
2024-02-19 00:16:05 +01:00
Hugh Davenport
8740a8c056 FlappyBug: Allow shortcuts for quitting and help
As the menus show that ALT-F4 quit and F1 brings up help, we should
make the application do that instead of just undocumented ESC
2024-02-19 00:09:34 +01:00