Commit Graph

56544 Commits

Author SHA1 Message Date
Shannon Booth
25f8b80eab LibWeb: Use move on ByteBuffer in TransferArrayBuffer 2023-11-19 18:53:17 +01:00
Shannon Booth
446a78f30e LibWeb: Implement Streams AO ReadableStreamAddReadIntoRequest
This is effectively identical to ReadableStreamAddReadRequest besides
from the fact that it takes a ReadIntoRequest instead of a ReadRequest,
and is instead intended to be used for BYOB readers.
2023-11-19 18:53:17 +01:00
Shannon Booth
f27e76b0b7 LibWeb: Make ReadableStreamAddReadRequest take a NonnullGCPtr
Make it more obvious in the function signature that this function will
be taking a GC ref to a ReadRequest by appending it to the
ReadableStreams pending read requests.
2023-11-19 18:53:17 +01:00
Shannon Booth
5ef41dca53 LibWeb: Implement Streams AO ReadableStreamFulfillReadIntoRequest 2023-11-19 18:53:17 +01:00
Shannon Booth
0880ea3e1c LibWeb: Add missing initialize override for ReadableStreamBYOBReader
This hasn't really come up as of yet because not enough of this class
has been implemented yet to actually do anything with it.
2023-11-19 18:53:17 +01:00
Shannon Booth
746526ca29 LibWeb: Add ReadIntoRequest to forwarding header 2023-11-19 18:53:17 +01:00
Andreas Kling
3c74dc9f4d LibJS: Segregate GC-allocated objects by type
This patch adds two macros to declare per-type allocators:

- JS_DECLARE_ALLOCATOR(TypeName)
- JS_DEFINE_ALLOCATOR(TypeName)

When used, they add a type-specific CellAllocator that the Heap will
delegate allocation requests to.

The result of this is that GC objects of the same type always end up
within the same HeapBlock, drastically reducing the ability to perform
type confusion attacks.

It also improves HeapBlock utilization, since each block now has cells
sized exactly to the type used within that block. (Previously we only
had a handful of block sizes available, and most GC allocations ended
up with a large amount of slack in their tails.)

There is a small performance hit from this, but I'm sure we can make
up for it elsewhere.

Note that the old size-based allocators still exist, and we fall back
to them for any type that doesn't have its own CellAllocator.
2023-11-19 12:10:31 +01:00
Andreas Kling
84a8ee01e1 LibJS: Lower HeapBlock size to 4 KiB
This is to prepare for making per-type allocators, since we'll have a
*lot* more HeapBlocks in that world.
2023-11-19 12:10:31 +01:00
Shannon Booth
eca9874e56 LibWeb: Port Element::attribute_changed from DeprecatedString to String
Which as you would expect has a bunch of fallout, but also results in a
whole lot of awkward conversions falling away.
2023-11-19 08:16:34 +00:00
Shannon Booth
6a2a7cad61 LibWeb/LibJS: Avoid GC visit of raw pointers where possible
This is mostly motivated for aesthetics, but also helps avoid some null
checks when we have a NonnullGCPtr<T> or in some cases a T&.
2023-11-19 08:05:45 +00:00
MacDue
4e04f81626 LibWeb: Don't encode painting limitations in RecordingPainter API
The current set of stacking context commands do not encode the
information needed to correctly paint the stacking context, instead,
they're based on the limitations of the current CPU renderer.

Stacking contexts should be able to be transformed by an arbitrary
3D transformation matrix, not just scaled from a source to a destination
rect. The `_with_mask()` stacking context also should not be separate
from the regular stacking context.

```c++
push_stacking_context(
	bool semitransparent_or_has_non_identity_transform,
	float opacity, Gfx::FloatRect const& source_rect,
	Gfx::FloatRect const& transformed_destination_rect,
	Gfx::IntPoint const& painter_location);

pop_stacking_context(
	bool semitransparent_or_has_non_identity_transform,
	Gfx::Painter::ScalingMode scaling_mode);

push_stacking_context_with_mask(
	Gfx::IntRect const& paint_rect);

pop_stacking_context_with_mask(
	Gfx::IntRect const& paint_rect,
	RefPtr<Gfx::Bitmap> const& mask_bitmap,
	Gfx::Bitmap::MaskKind mask_kind, float opacity);
```

This patch replaces this APIs with just:

```c++
push_stacking_context(
	float opacity,
        bool is_fixed_position,
        Gfx::IntRect const& source_paintable_rect,
	Gfx::IntPoint post_transform_translation,
	CSS::ImageRendering image_rendering,
	StackingContextTransform transform,
	Optional<StackingContextMask> mask);

pop_stacking_context()
```

And moves the implementation details into the executor, this should
allow future backends to implement stacking contexts without these
limitations.
2023-11-18 19:32:31 +01:00
MacDue
848b0d9c81 LibGfx: Add Gfx::extract_2d_affine_transform(Matrix4x4) helper 2023-11-18 19:32:31 +01:00
MacDue
da00a5cdb5 AK: Add is_owned() method to MaybeOwned 2023-11-18 19:32:31 +01:00
Sam Atkins
69afb43922 LibWeb: Add ref test for background-repeat
This is adapted from one of our existing test pages.
2023-11-18 15:08:21 +00:00
Sam Atkins
d10f4a8590 LibWeb: Add ref test for general CSS background properties
This is an adaptation of the "misc/backgrounds.html" file in the
Serenity image. It tests a lot of background-related properties that we
otherwise have no tests for.
2023-11-18 15:08:21 +00:00
hanaa12G
1f0149e5a6 LibLine: Reset state after invalid character in DSR response
While parsing DSR response, we might encounter invalid characters, for
example, when we `cat` a binary file. Previously, we just pushed those
characters in `m_incomplete_data` buffer, which worked fine until we
didn't get a terminating character. We kept increasing coordinate value
and crashed in following assertion.
2023-11-18 18:33:00 +03:30
Aliaksandr Kalenik
7b3559f1c2 LibWeb: Remove navigate() in EventHandler::handle_mouseup()
Before this change `navigate()` was always invoked twice when a link
is clicked:
- From `activation_behavior` callback of `HTMLAnchorElement` during
  event dispatch.
- Directly from `handle_mouseup`.
2023-11-18 15:27:10 +01:00
Aliaksandr Kalenik
4f2a0a3d56 LibWeb: Remove ongoing navigation id check in navigate_to_a_fragment()
It is a mistake to add this early return in fragment navigation because
"ongoing navigation id" is not used during this kind of navigation.

With this change we no longer crash in Acid2 test after reload button
is pressed.
2023-11-18 15:27:10 +01:00
Ali Mohammad Pur
aa73a7c961 Shell: Accept null heredocs in POSIX mode
Fixes #21837.
2023-11-18 16:50:01 +03:30
Ali Mohammad Pur
2eb0a8f3d2 Shell: Expand for loop's iterated expr before iterating over it
This only applies to the POSIX mode.
Fixes #21715.
2023-11-18 16:50:01 +03:30
Sam Atkins
b74f5b1ca1 Meta: Publish dumped ref-test images as an Azure CI artifact
Whenever the tests produce a `test-dumps` directory, publish the files
in it as an artifact. This lets us peek at the screenshots and see
what's mismatched, instead of just having to guess.
2023-11-18 07:49:59 -05:00
Sam Atkins
edaa5061c4 headless-browser: Add flag to dump screenshots of failing ref-tests
When the `--dump-failed-ref-tests` flag is provided, screenshots of the
actual and reference pages will be placed in
`Build/lagom/ladbybird/test-dumps`. This makes it a lot easier to spot
what's wrong with a failing test. :^)
2023-11-18 07:49:59 -05:00
Lachlan Jowett
4f5824cbd0 DisplaySettings: Desktop crash when non-image file type is used
If the user selects an non-image file
as their background, then at next
startup the desktop crashes.
2023-11-18 11:21:32 +00:00
Lucas CHOLLET
1afdf7f3c7 LibGfx/TIFF: Take the TIFF value by rvalue reference in handle_tag() 2023-11-18 11:14:37 +00:00
Lucas CHOLLET
4ab2903e25 LibGfx/TIFF: Make TIFFLoadingContext::handle_tag be a free function
And move it to another file. This code is going to be generated soon, so
let's put it in another file.
2023-11-18 11:14:37 +00:00
Lucas CHOLLET
34d91dec5b LibGfx/TIFF: Extract metadata-related definition to their own file 2023-11-18 11:14:37 +00:00
Lucas CHOLLET
1d1e7abba7 LibGfx/TIFF: Put the TIFFLoadingContext class in a TIFF namespace 2023-11-18 11:14:37 +00:00
Lucas CHOLLET
b78f93d0b5 LibGfx/TIFF: Put metadata fields in their own struct 2023-11-18 11:14:37 +00:00
Martin Janiczek
864e83079c AK: Add randomized tests for BuiltinWrappers 2023-11-18 10:01:29 +01:00
Martin Janiczek
8942041eee AK: Test is_ascii, to_ascii_*case over random Unicode samples 2023-11-18 10:01:29 +01:00
Martin Janiczek
65df1cd22c AK: Add randomized tests for Bitmap
These tests found the issue fixed in #21409 (but randomized test runner
wasn't merged yet).
2023-11-18 10:01:29 +01:00
Martin Janiczek
a00b4a5c1f AK: Add roundtrip tests for BitStream 2023-11-18 10:01:29 +01:00
Martin Janiczek
c802971f93 AK: Add liveness tests for BinarySearch 2023-11-18 10:01:29 +01:00
Martin Janiczek
1452693183 AK: Add randomized tests for BinaryHeap 2023-11-18 10:01:29 +01:00
Martin Janiczek
b56e022ce8 AK: Add roundtrip fuzzer for Base64 2023-11-18 10:01:29 +01:00
Martin Janiczek
6c1626e83b AK: Add tests for AllOf and AnyOf 2023-11-18 10:01:29 +01:00
Martin Janiczek
0465ba242b LibCompress: Upgrade compression fuzzer into a roundtrip fuzzer 2023-11-18 10:01:29 +01:00
Martin Janiczek
70ac6918d1 LibTest: Fix integer overflow in Gen::unsigned_int(u32)
NumericLimits<u32>::max + 1 overflowing to 0 caused us to call
AK::get_random_uniform(0) which doesn't make sense (the argument is an
_exclusive_ bound).
2023-11-18 10:01:29 +01:00
Timothy Flynn
6e928e426a Meta: Add test-js to the GN build 2023-11-18 01:16:05 -07:00
Timothy Flynn
3c5909f47e Meta: Update GN build to use CLDR version 44.0.1
See: 38dd284915
2023-11-18 01:16:05 -07:00
Timothy Flynn
19d50ee2c2 Meta: Extract .zip file directories in an encoding-agnostic manner
The current implementation fails if a file in the archive is not valid
UTF-8. The CLDR 44.0.1 package unfortunately contains such files (it
errantly has .DS_Store files).
2023-11-18 01:16:05 -07:00
Timothy Flynn
b65c07082b Meta: Properly handle GN unit tests which define their own deps
If a unit tests defines a `deps` array, the unit test template would
have tried to overwrite it (and it is actually an error to overwrite
a non-empty list with another non-empty list).
2023-11-18 01:16:05 -07:00
Timothy Flynn
6a73e027a0 Meta: Remove explicit setting of output_dir in GN unit test template
This is causing unit tests to be linked in //Build/obj/Tests rather than
//Build/bin. Note that object files are not affected by this change.
2023-11-18 01:16:05 -07:00
Timothy Flynn
392d9d080d Meta: Port recent changes to GN build
80071b1d48face038a60b98fc8c3414de1cb9633
3f6a26d07d1536eb5e4e39eedfd4e0135eabf536
2023-11-18 01:16:05 -07:00
Idan Horowitz
f19349e1b6 LibJS: Instantiate primitive array expressions using a single operation
This will not meaningfully affect short array literals, but it does
give us a bit of extra perf when evaluating huge array expressions like
in Kraken/imaging-darkroom.js
2023-11-18 08:37:34 +01:00
Idan Horowitz
5e3a799e97 LibJS: Remove unused Literal AST node sub-type 2023-11-18 08:37:34 +01:00
Nico Weber
4440452f92 LibPDF: Support images with 1, 2, 4 bits per pixel
They just get upsampled to 8 bits per pixel images.
2023-11-18 07:33:15 +00:00
Nico Weber
bfe27228a3 LibPDF+LibGfx: Don't invert CMYK channels in JPEG data in PDFs
This is a hack: Ideally we'd have a CMYK Bitmap pixel format,
and we'd convert to rgb at blit time. Then we could also apply color
profiles (which for CMYK images are CMYK-based).

Also, the colors for our CMYK->RGB conversion are off for PDFs,
and we have distinct codepaths for this in Gfx::Color (for paths)
and JPEGs. So when we fix that, we'll have to fix it in two places.

But this doesn't require a lot of code and it's a huge visual
progression, so let's go with it for now.
2023-11-17 22:32:40 +00:00
Nico Weber
bd7ae7f91e LibPDF: Consistently asciibetize CommonNames.h
The file wasn't quite decided if it wanted to sort by ascii value
or by case folding. Now it uses ascii value, thanks to vim's
`:'<,'>sort`.

No behavior change.
2023-11-17 20:27:42 +00:00
Nico Weber
29396415d5 LibPDF: Add an initial implementation of type 3 glyph rendering
This is a very inefficient implementation: Every time a type 3 font
glyph is drawn, we parse its operator stream and execute all the
operators therein.

We'll want to instead cache the glyphs in bitmaps (at least in most
cases), like we do for other fonts. But it's a good first step, and
all the coordinate math seems to work in the files I've tested.

Good test files from pdfa dataset 0000.zip:

- 0000559.pdf page 1 (and 2): Has a non-default font matrix;
  text appears mirrored if the font matrix isn't handled correctly

- 0000425.pdf, page 1: Draws several glyphs in a single run;
  glyphs overlap if Renderer::render_type3_glyph() ignores the
  passed-in point

- 0000211.pdf, any page: Uses type 3 glyphs for all text.
  Good perf test (already "reasonably fast")

- 0000521.pdf, page 5 (or 7 or or 16): The little red flag in the
  purple box is a type 3 font glyph, and it's colored (which in part
  means the first operator is `d0`, while all the other documents above
  use `d1`)
2023-11-17 19:47:53 +00:00