Commit Graph

57401 Commits

Author SHA1 Message Date
Shannon Booth
020839ad7a LibWeb: Remove ByteString usage in NamedNodeMap
We now have a FlyString version of get_attribute_ns, so this conversion
is no longer needed any more.
2023-12-24 13:26:50 +01:00
Shannon Booth
c63d30ce67 LibWeb: Port HTML Environments from ByteString 2023-12-24 13:26:50 +01:00
Shannon Booth
562e0d710c LibWeb: Port ProcessingInstruction from ByteString 2023-12-24 13:26:50 +01:00
Shannon Booth
7ce3e113fa LibWeb: Port HTMLOutputElement from ByteString 2023-12-24 13:26:50 +01:00
Shannon Booth
7909475b14 LibWeb: Port SVGUseElement from ByteString 2023-12-24 13:26:50 +01:00
MacDue
64411127cb LibGfx: Clip edges above or below the visible area in the rasterizer
This avoids doing pointless plotting for scanlines that will never be
seen.

Note: This currently can only clip edges vertically. Horizontal clipping
is more tricky, since edges that are not visible can still change how
things accumulate across the scanline.

Fixes #22382

Sadly, this causes a bunch of LibWeb test churn as this change
imperceptibly changes the final rasterized output.
2023-12-24 13:25:40 +01:00
Andreas Kling
fe04d83ef5 LibWeb: Process all pending lazy loading intersection observations
This fixes an issue where images outside the viewport could prevent
loading of images inside the viewport, depending on DOM order.
2023-12-24 13:23:40 +01:00
Andreas Kling
b344d39014 headless-browser: Use run_dump_test() for single-test runs as well
This avoids having two separate ways to set up the finish callbacks.
It also makes it possible to run a single async test on its own.
2023-12-24 13:23:40 +01:00
Aliaksandr Kalenik
32a6bf908a LibWeb/CSS: Fix stack use after scope in matches_attribute()
If a short string is used for the attribute value, then the result of:
```cpp
auto const view = element.attribute(attribute_name).value_or({})
    .bytes_as_string_view().split_view(' ');
```
is an array of string views pointing into a temporarily allocated
string.

With this change we keep string on stack until the end of scope.

Page that allows to reproduce the problem.
```html
<!DOCTYPE html><style>
    div[data-info~="a"] {
        background-color: yellow;
    }
</style><div data-info="a">a</div>
```
2023-12-24 08:03:58 +00:00
Shannon Booth
95e9c89a15 LibJS: Update spec comments in Array.fromAsync
This was a normative change in the Array.fromAsync spec which we already
implemented :^). See:

https://github.com/tc39/proposal-array-from-async/commit/689d0d

I've left an existing FIXME in there for some other bug which we have
which is causing some test262 test cases to fail.
2023-12-23 20:22:42 -05:00
Andreas Kling
41941aeb10 LibWeb: Don't access SharedImageRequest::m_document in destructor
It's not safe to access m_document here since GC may have deleted it
by the time we're being deleted. Instead, move this to a finalize()
override, since those are guaranteed to be called while both objects
are still alive.
2023-12-23 23:02:10 +01:00
Andreas Kling
6c1fcc5f7e LibJS: Actually invoke the type-isolating cell allocators
Due to a `requires` mistake, we were always using the fallback
size-based cell allocators.

Also, now that we start using them, make them NeverDestroyed so
we don't try to deallocate them on program exit.
2023-12-23 23:02:10 +01:00
Andreas Kling
f953a70965 LibWeb: Make ListOfAvailableImages actually visit images during GC
Instead of making the "Entry" inner struct GC-allocated and marking
*that*, we now mark the image instead.

This fixes an issue found by ASAN on https://mozilla.com/
2023-12-23 23:02:10 +01:00
Andreas Kling
f4fa37afd2 LibJS+LibWeb: Add missing JS_DEFINE_ALLOCATOR() for a bunch of classes 2023-12-23 23:02:10 +01:00
Andreas Kling
11c968fa1f LibJS: Make Heap aware of all CellAllocators
Also add a link from HeapBlock to their owning CellAllocator.
This fixes an issue where the Heap would skip over non-size-based
cell allocators.
2023-12-23 23:02:10 +01:00
Lucas CHOLLET
a31b988473 LibGfx/TIFF: Ensure baseline tags presence before decoding
This allows us to reject invalid images before trying to decode them.
The spec requires more tag to be present[1] but as we don't use them for
decoding I don't see the point.

[1] - XResolution, YResolution and ResolutionUnit
2023-12-23 20:54:07 +01:00
Shannon Booth
ec2b4c271f LibWeb: Support RadioNodeList named items in HTMLFormControlsCollection
We would previously not return a RadioNodeList in the curious case where
a named item resolves to two different elements within the form.

This was not a problem when calling namedItem directly in the IDL as
named_item_or_radio_node_list shadows named_item but is exposed when
calling the property through array bracket notation (as an example).

Fix this, and add a bunch more tests to cover
HTMLFormControlsCollection.
2023-12-23 20:53:11 +01:00
Shannon Booth
1defc4595b LibWeb: Make LiveNodeList store a NonnullGCPtr<Node const> root
This allows us to improve the const-correctness in RadioNodeList, which
has been made possible as of: 5f0ccfb499 now that a GC-visit accepts a
const GC pointer.
2023-12-23 20:53:11 +01:00
Aliaksandr Kalenik
0a7e4a0d22 LibWeb: Ignore "display: contents" boxes while inserting inline nodes
With this change "display: contents" ancestors are not considered as
insertion point for inline nodes similar to how we already ignore them
for non-inline nodes.

Fixes https://github.com/SerenityOS/serenity/issues/22396
2023-12-23 20:52:42 +01:00
Lucas CHOLLET
67522fab2e LibGfx/TIFF: Add support for RGBPalette images
TIFF images with the PhotometricInterpretation tag set to RGBPalette are
based on indexed colors instead of explicitly describing the color for
each pixel. Let's add support for them.

The test case was generated with GIMP using the Indexed image mode after
adding an alpha layer. Not all decoders are able to open this image, but
GIMP can.
2023-12-23 20:41:48 +01:00
Shannon Booth
d8759d9656 LibWeb: Use UTF-16 code unit offsets and lengths in CharacterData
We were previously assuming that the input offsets and lengths were all
in raw byte offsets into a UTF-8 string. While internally our String
representation may be in UTF-8 from the external world it is seen as
UTF-16, with code unit offsets passed through, and used as the returned
length.

Beforehand, the included test included in this commit would crash
ladybird (and otherwise return wrong values).

The implementation here is very inefficient, I am sure there is a
much smarter way to write it so that we would not need a conversion
from UTF-8 to a UTF-16 string (and then back again).

Fixes: #20971
2023-12-23 20:41:41 +01:00
Shannon Booth
d51f84501a AK: Remove now unused to_{int,uint,float,double} String functions 2023-12-23 20:41:07 +01:00
Shannon Booth
e2e7c4d574 Everywhere: Use to_number<T> instead of to_{int,uint,float,double}
In a bunch of cases, this actually ends up simplifying the code as
to_number will handle something such as:

```
Optional<I> opt;
if constexpr (IsSigned<I>)
    opt = view.to_int<I>();
else
    opt = view.to_uint<I>();
```

For us.

The main goal here however is to have a single generic number conversion
API between all of the String classes.
2023-12-23 20:41:07 +01:00
Shannon Booth
a4ecc65398 AK: Add DeprecatedFlyString::to_number<T> 2023-12-23 20:41:07 +01:00
Shannon Booth
159eda5c6d AK: Add ByteString::to_number<T>
To mirror the API with StringView and String.
2023-12-23 20:41:07 +01:00
Shannon Booth
cdf84a3e36 AK: Implement StringView::to_number<T> from String::to_number<T>
Do exactly what String does, then use StringView's implementation as
String's new one. This should allow us to call to_number on a
StringView.
2023-12-23 20:41:07 +01:00
Nico Weber
b63eb4a4dd LibPDF: Implement /Mask support with stream object argument 2023-12-23 20:39:11 +01:00
Nico Weber
a3507ef65b LibPDF: Move error for /ImageMask out of load_image()
...and tweak load_image() to support loading mask images
(which don't have a color space and are always 1 bit per pixel).
2023-12-23 20:39:11 +01:00
Nico Weber
3ad9782e25 LibPDF: Extract a apply_alpha_channel() function
No behavior change.
2023-12-23 20:39:11 +01:00
Nico Weber
4bd11c8eb4 LibPDF: Show a 'rendering unsupported' error for images with /Mask key 2023-12-23 20:39:11 +01:00
Timothy Flynn
7d2172ff3d LibLocale: Update to CLDR version 44.1.0
https://cldr.unicode.org/index/downloads/cldr-44#h.nvqx283jwsx
2023-12-23 20:05:36 +01:00
Timothy Flynn
ef6d1dbd4d Meta: Port recent changes to the GN build
5e1499d104
36f0499cc8
64912d4d02
809c5b0b03
2023-12-23 20:05:36 +01:00
Timothy Flynn
7233d5ed3e Meta: Alphabetically sort IDL files in the GN build 2023-12-23 20:05:36 +01:00
Timothy Flynn
697bb27c97 LibTimeZone: Update to TZDB version 2023d
https://mm.icann.org/pipermail/tz-announce/2023-December/000080.html
2023-12-23 20:05:16 +01:00
Nico Weber
80359517bd LibGfx: Do not use double negation in TIFFGenerator.py
No behavior change.
2023-12-23 12:25:08 -05:00
Bastiaan van der Plaat
c30911ab10 LibWeb: Hide select chevron icon when appearance: none; 2023-12-23 10:12:36 +01:00
Bastiaan van der Plaat
29ee576345 LibWeb: Fix select dropdown position when scrolled on a page 2023-12-23 10:12:36 +01:00
Bastiaan van der Plaat
44ff957784 LibWeb: Make -webkit-appearance an alias for the appearance css property 2023-12-23 10:12:36 +01:00
Nico Weber
387fecea7f LibPDF: Fix typo in a variable name
No behavior change.
2023-12-23 10:10:24 +01:00
Aliaksandr Kalenik
02936f6944 LibWebView+WebContent: Drive repainting from WebContent process
With this change, chrome no longer has to ask the WebContent process
to paint the next frame into a specified bitmap. Instead, it allocates
bitmaps and sends them to WebContent, which then lets chrome know when
the painting is done.

This work is a preparation to move the execution of painting commands
into a separate thread. Now, it is much easier to start working on the
next frame while the current one is still rendering. This is because
WebContent does not have to inform chrome that the current frame is
ready before it can request the next frame.

Additionally, as a side bonus, we can now eliminate the
did_invalidate_content_rect and did_change_selection IPC calls. These
were used solely for the purpose of informing chrome that it needed to
request a repaint.
2023-12-22 17:47:34 +01:00
Sam Atkins
ac63d1e59d headless-browser: Clear document and callbacks between tests
While it would be more hygienic to get a fresh Navigable each time,
loading `about:blank` still means we discard the current Document.

This does noticeably increase the duration of running the LibWeb test
suite. On my machine, we go from ~5.5 seconds to ~7.7.
2023-12-22 16:49:06 +01:00
Sam Atkins
1e6cd19b28 LibWeb: Prevent calling test() twice
Calling test() multiple times in the same test file is not actually
valid, and can cause the following test to hang forever. So let's stop
doing that in the one test that did so, and also prevent the same
mistake happening again. :^)

Throwing an exception on subsequent test() calls means that we don't
hang, the test will fail with missing output, and we get a log message
explaining why.
2023-12-22 16:49:06 +01:00
Sam Atkins
99fc3c7551 LibWeb: Stop shadowing location_url
This is a bug. The value set here needs to be visible to later steps.
2023-12-22 15:48:40 +00:00
Ali Mohammad Pur
db34ee357d LibLine: Avoid returning reference to cached suggestion
This caused a dangling reference down the line, which lead to funny
things like the following:
    > cd Bui[tab]
    > cd Bui^@^@

By returning a direct reference to the suggestion in question, we can be
sure that the referenced object is alive until the next suggestion
cycle.
2023-12-22 10:59:56 +01:00
Ali Mohammad Pur
64616d3997 AK: Completely disable rich debug formats on Windows
Half the functions used are not readily available on windows, instead of
creating more ifdef soup, this commit simply disables the rich debug
stuff on windows.
2023-12-22 10:59:21 +01:00
Nico Weber
6723552e95 LibPDF: Add a spec comment and remove a FIXME
I think the ASCIIHexDecode / ASCII85Decode unfilter functions handle
what this FIXME was about already.
2023-12-22 10:58:54 +01:00
Nico Weber
3d07684891 LibPDF: Extract Parser::parse_inline_image()
Pure code move, no intended behavior change.

The motivation is just to make Parser::parse_operators() less nested
and more focused.
2023-12-22 10:58:54 +01:00
Idan Horowitz
f972eda7ed Kernel: Mark cloned volatile purgeable AnonymousVMOjects as purged
Our existing AnonymousVMObject cloning flow contains an optimization
wherein purgeable VMObjects which are marked volatile during the clone
are created as a new zero-filled VMObject (as if it was purged), which
lets us skip the expensive COW process.

Unfortunately, one crucial part was missing: Marking the cloned region
as purged, (which is the value returned from madvise when unmarking the
region as volatile) so the userland logic was left unaware of the
effective zero-ing of their memory region, resulting in odd behaviour
and crashes in places like our malloc's large allocation support.
2023-12-22 10:57:59 +01:00
Shannon Booth
1f88046bb2 LibWeb: Add a test for setting and getting Text data
This is a pretty straightforward test, but I managed to make this crash
on real sites while trying to fix #20971 without any other test in the
existing suite failing.
2023-12-22 08:19:51 +00:00
Lucas CHOLLET
2cfca633ca LibGfx/TIFF: Add support for images with UnassociatedAlpha
UnassociatedAlpha is the one used by GIMP when generating TIFF images
with transparency. Support is added for Grayscale and RGB images as it's
the two that we support right now but managing transparency should be
really straightforward for other types as well.
2023-12-22 08:08:47 +00:00