Commit Graph

60154 Commits

Author SHA1 Message Date
Tim Ledbetter
eebdc7bc88 LibWeb: Allow the Performance object to be used by workers 2024-04-02 07:46:16 +02:00
Shannon Booth
adf061a29c LibWeb: Avoid copying cached elements in HTMLCollection
Once we have built up a cache, we can use that internally for operations
on the collection, instead of copying over the list of elements every
time.

On a synthentic benchmark of a page with ~500 link elements, this
results in a 45% percent speedup on my machine.

```html
<body>
    <ul>
        <li><a href="#">Link 1</a></li>
        ...
        <li><a href="#">Link N</a></li>
    </ul>

    <script>
        window.onload = function() {
            const startTime = performance.now();
            for (let i = 0; i < 1_000_000; ++i) {
                const numLinks = document.links.length;
            }
            const endTime = performance.now();
            const timeTaken = endTime - startTime;
            console.log(timeTaken);
        };
    </script>
</body>
</html>
```
2024-04-02 07:33:40 +02:00
Shannon Booth
094ab8b4d2 LibWeb: Remove some uneeded const_casts from HTMLCollection
Correcting a variable name while we're at it.
2024-04-02 07:33:40 +02:00
Shannon Booth
b1be8bd826 LibWeb: Implement is_supported_property_index in terms of length() 2024-04-02 07:33:40 +02:00
Shannon Booth
b9b264e97a LibWeb: Remove redundant is_empty check from is_supported_property_index
An empty list of elements will not return true for any unsigned number,
so we can simply remove this check.
2024-04-02 07:33:40 +02:00
Shannon Booth
cdd0038c9e LibWeb: Factor out a method to update the cached elements
This is useful for any function which is needing to read the from the
cache, instead of onl using `collect_matching_elements`.
2024-04-02 07:33:40 +02:00
Timothy Flynn
b6501adef8 LibWeb: Use the proper in-flight request to check if a stream is closing 2024-04-01 21:11:01 +02:00
MacDue
59cd086199 LibWeb: Stub (and implement) SVGSVGElement methods and attributes
This implements trivial functions and stubs out the rest.

Implemented:

```
[SameObject] readonly attribute SVGAnimatedLength x;
[SameObject] readonly attribute SVGAnimatedLength y;
[SameObject] readonly attribute SVGAnimatedLength width;
[SameObject] readonly attribute SVGAnimatedLength height;

undefined deselectAll();

SVGLength createSVGLength();
DOMPoint createSVGPoint();
DOMMatrix createSVGMatrix();
DOMRect createSVGRect();
SVGTransform createSVGTransform();

Element getElementById(DOMString elementId);

unsigned long suspendRedraw(unsigned long maxWaitMilliseconds);
undefined unsuspendRedraw(unsigned long suspendHandleID);
undefined unsuspendRedrawAll();
undefined forceRedraw();
```

Stubbed:

```
attribute float currentScale;
[SameObject] readonly attribute DOMPointReadOnly currentTranslate;

NodeList getIntersectionList(
  DOMRectReadOnly rect, SVGElement? referenceElement);
NodeList getEnclosureList(
  DOMRectReadOnly rect, SVGElement? referenceElement);
boolean checkIntersection(SVGElement element, DOMRectReadOnly rect);
boolean checkEnclosure(SVGElement element, DOMRectReadOnly rect);
```
2024-04-01 21:10:35 +02:00
MacDue
5739ea9ba1 LibWeb: Stub SVGGraphicsElement methods/attributes
This stubs the `SVGGraphicsElement.getBBox()` method and the
`.transform` attribute.
2024-04-01 21:10:35 +02:00
MacDue
329262d54f LibWeb: Stub SVGTextContentElement.getStartPositionOfChar() 2024-04-01 21:10:35 +02:00
MacDue
bafb6bd059 LibWeb: Move SVGLength unit constants to header
No behaviour change.
2024-04-01 21:10:35 +02:00
MacDue
d2918b8204 LibWeb: Add (and use) CSS property to SVGAnimatedLength helper
No behaviour change.
2024-04-01 21:10:35 +02:00
MacDue
6d72f40d8d LibWeb: Stub out SVGAnimatedTransformList 2024-04-01 21:10:35 +02:00
MacDue
3bab4fbae9 LibWeb: Stub out SVGTransformList 2024-04-01 21:10:35 +02:00
MacDue
a6a40a5bc6 LibWeb: Stub out SVGTransform 2024-04-01 21:10:35 +02:00
Nico Weber
ce11a34fc6 Tests/LibGfx: Add a jbig2 test for transposed text segments
See the PR adding this test for local changes to `jbig2`.
I used the shell script mentioned in #23659, except I added the line
`-txt -Param -Transposed 1` at the very end of the .ini file.

As with all the symbol test cases, after running

    Meta/jbig2_to_pdf.py -o foo.pdf foo.jb2 399 400

the file opens up ok in Chrome and Firefox (but not Safari), so
maybe it's not completely broken.
2024-04-01 14:41:17 +02:00
Nico Weber
b04569c1da LibGfx/JBIG2: Implement support for transposed text regions
Only the coordinates get transposed -- the bitmaps apparently don't.
And all the prose amounts to "if the transposed bit is set, swap
instance s and t coordinates before painting", as far as I can tell.

Makes pages 3/4 and 7/8 in 0001346.pdf render. (But here the feature
isn't used to render transposed text -- it just has stripes that keep s
roughy constant, which would normally produce vertical runs but here
produces regular horizontal runs. It's not clear to me why this feature
is used for these pages!)
2024-04-01 14:41:17 +02:00
Nico Weber
ca6ebedf58 LibGfx/JBIG2: Simplify non-transposed text region coordinate math
If the origin is on the right, we need to subtract width - 1 from s,
if it's on top bottom, we need to subtract height - 1 from t.

No behavior change.
2024-04-01 14:41:17 +02:00
Shannon Booth
851114e462 LibWeb/Tests: Add a basic set of tests for document.all 2024-04-01 14:41:00 +02:00
Shannon Booth
249ee0a30e LbiWeb: Return an HTMLAllCollection from document.all 2024-04-01 14:41:00 +02:00
Shannon Booth
1f59e21829 LibWeb: Implement HTMLAllCollection
This collection has some pretty strange behaviour, particularly with the
IsHTMLDDA slot which is defined in the javascript spec specifically for
this object.

This commit implements pretty much all of this interface, besides from
the custom [[Call]].

There is also no caching over this collection. Since it is a live
collection over the entire document, the performance is never going to
be great, and I am not convinced any speedup for this legacy interface
is worth a massive cache.
2024-04-01 14:41:00 +02:00
Shannon Booth
897f55ca8a LibWeb: Use NonnullGCPtr for HTMLCollection::collect_matching_elements
The pointers here can never be null, so lets engrain that into the type
for clarity.
2024-04-01 14:41:00 +02:00
Shannon Booth
e590e92399 LibWeb: Add HTMLCollection as a platform object
It is returned by the IDL of HTMLAllCollection.
2024-04-01 14:41:00 +02:00
Shannon Booth
713d8dc0f8 LibJS: Add support for constructing a PropertyKey from a FlyString 2024-04-01 14:41:00 +02:00
Shannon Booth
8fa0730b84 LibWeb: Remove resolved FIXME about caching in HTMLCollection 2024-04-01 14:41:00 +02:00
Aliaksandr Kalenik
9098fa23a2 LibWeb: Catch up with the spec on document destroy, abort and unload
These changes do not solve hanging `location.reload()` and
`location.go()` but only align implementation with the latest edits in
the specification.

`WindowProxy-Get-after-detaching-from-browsing-context` test output is
affected because `iframe.remove();` no longer synchronously does
destruction of a document, but queues a task on event loop.

Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2024-04-01 13:23:58 +02:00
Nico Weber
43752a1ff8 LibGfx/JBIG2: Remove a now-unneeded void cast
We've been reading `segment_page_association_size_is_32_bits` a bit
further down for a while now.

No behavior change.
2024-04-01 08:27:10 +01:00
Timothy Flynn
9af8c61b29 Ports: Update ports that depend on LibCore to depend on LibCoreMinimal
Looks like we need to be explicit for make-based ports.
2024-03-31 19:22:32 +02:00
Timothy Flynn
dd54780d5e Ladybird/Qt: Place the tab audio state button on the right on macOS
On macOS, the "close tab" button is on the left, so we should place the
audio state button on the right to avoid conflict. Rather than an OS
ifdef, we do this by detecting if the left side is occupied.
2024-03-31 14:29:17 +02:00
Timothy Flynn
3e659b10f0 Ladybird/Qt: Reference the correct tab when handling the audio icon
We were errantly always referring to the active tab when the audio play
state changed, and when clicking a tab's audio state button, by way of
BrowserWindow::view().

It turns out we also can't copy / rely on the tab index provided to the
signal in any asynchronous context. If the tabs are rearranged, so are
their indices. Instead, capture a pointer to the tab of interest - this
should be safe as we wouldn't be able to click a tab's audio button if
that tab no longer exists.

With this change, we can click the audio button from any tab in the Qt
chrome, and re-arrange tabs at will. The AppKit and Serenity chromes do
not have this issue.
2024-03-31 14:29:17 +02:00
MacDue
06ed56f4f6 LibWeb: Paint SVGDecodedImageData via Navigable::paint()
Going via the `ViewportPaintable` missed some steps (in particular
computing clip rects), which meant nested SVGs within SVGs-as-images
were completely clipped.
2024-03-30 21:35:22 +01:00
Kenneth Myhra
4b66f5662b LibWeb: Correct spec steps for serializable objects
This aligns us with the current spec steps for serializable objects in
StructuredSerializeInternal.
2024-03-30 21:26:37 +01:00
Shannon Booth
9dc2b0bba3 LibWeb: Add a basic test for [EnforceRange]
This is a basic test - but does cover the two bugs in the previous
two commits.
2024-03-30 21:21:23 +01:00
Shannon Booth
7abedd2fed LibWasm: Fix reference-to-stack-local from {Memory,Table}Instance
Allocating a MemoryInstance or TableInstance from Store would result in
a reference to a stack allocated {Memory,Table}Type that would
immediately fall out of scope.

The MemoryInstance case was causing ASAN issues for a LibWeb based test
- I don't have a reproducer for TableInstance, but it looks like it
suffers from the exact same problem.
2024-03-30 21:21:23 +01:00
Shannon Booth
d725076c7f LibWeb: Fix a silly mistake for bitLength 64 in conversion to int
Which was resulting in 32 bit numbers getting the max array like
index instead of 64 bit numbers!
2024-03-30 21:21:23 +01:00
Shannon Booth
a09849072e LibWeb: Pass through [EnforceRange] and [Clamp] extended attributes
To the 'convert to int' AO. Nothing actually makes use of the [Clamp]
attribute yet in our implementation, but we may as well add support for
it now since it is trivial to do do.
2024-03-30 21:21:23 +01:00
Idan Horowitz
56b0066485 Meta: Remove explicit default library type for lagom libraries
This partially reverts d1e2d2a4, which made us explicitly specify the
library type for lagom libraries. This broke the fuzzer build, which
relies on the BUILD_SHARED_LIBS cmake variable to enable static builds.
2024-03-30 14:42:15 -04:00
Kenneth Myhra
40d62a4365 LibWeb: Add missing spec link for ImageData constructor 2024-03-30 19:29:14 +01:00
Kenneth Myhra
c17171b86c LibWeb: Add ImageData constructor with data 2024-03-30 19:29:14 +01:00
Kenneth Myhra
900a889eb1 LibWeb+LibIDL: Add support for overloading constructors 2024-03-30 19:29:14 +01:00
Kenneth Myhra
09779ab4a6 LibWeb: Add Uint8ClampedArray as supported parameter type
Adds Uint8ClampedArray as supported parameter type to our
BindingsGenerator.
2024-03-30 19:29:14 +01:00
Timothy Flynn
f374e64dfc Ladybird/AppKit: Display a tool tip on the tab mute button 2024-03-30 19:28:20 +01:00
Timothy Flynn
9e4ffbcf70 Ladybird/AppKit: Support muting an entire page
We already display a speaker icon on tabs which are playing audio. This
allows the user to click that icon to mute the tab, at which point the
icon is replaced with a muted speaker icon.

We would previously hide the icon when audio stopped playing. We now do
this only if the tab isn't muted. If it is muted, the muted speaker icon
remains on the tab so that the page isn't stuck in a muted state.
2024-03-30 19:28:20 +01:00
Timothy Flynn
0da5d5a0d0 Ladybird/Qt: Display a tool tip on the tab mute button 2024-03-30 19:28:20 +01:00
Timothy Flynn
45b03bf75d Ladybird/Qt: Support muting an entire page
We already display a speaker icon on tabs which are playing audio. This
allows the user to click that icon to mute the tab, at which point the
icon is replaced with a muted speaker icon.

We would previously hide the icon when audio stopped playing. We now do
this only if the tab isn't muted. If it is muted, the muted speaker icon
remains on the tab so that the page isn't stuck in a muted state.
2024-03-30 19:28:20 +01:00
Timothy Flynn
f61f55d397 LibWeb+LibWebView+WebContent: Support muting an entire page
This adds an IPC for chromes to mute a tab. When muted, we trigger an
internal volume change notification and indicate that the user agent has
overriden the media volume.
2024-03-30 19:28:20 +01:00
Timothy Flynn
7c31343df0 LibWeb: Store the ID of all media elements on a page
This will be used to inform the media elements when the user has muted
the page.
2024-03-30 19:28:20 +01:00
Timothy Flynn
9fc8c37414 LibWebView: Handle mutliple audio tracks when audio play state changes
For example, if a page has multiple audio elements all actively playing
audio, we don't want to broadcast a play state change when only one of
them stop playing.
2024-03-30 19:28:20 +01:00
Matthew Olsson
c7c7ed780b LibWeb: Make request-animation-frame-order test async
Even though this test worked fine, it does use requestAnimationFrame
callbacks, so lets make it async to ensure it doesn't timeout.
2024-03-30 19:26:58 +01:00
Matthew Olsson
328ad9a2f0 LibWeb: Use InternalAnimationTimeline in existing tests 2024-03-30 19:26:58 +01:00