Commit graph

474 commits

Author SHA1 Message Date
Sam Atkins
1bd73184da LibWeb/HTML: Update get_an_elements_noopener() to current spec
Note that this preemptively includes this fix to step 3:
https://github.com/whatwg/html/pull/10962
2025-01-31 17:27:03 +00:00
Sam Atkins
6bc38832af LibWeb/HTML: Update follow_the_hyperlink() to current spec 2025-01-31 17:27:03 +00:00
Sam Atkins
7fcd8df49b LibWeb/HTML: Update submit_form() to current spec 2025-01-31 17:27:03 +00:00
Sam Atkins
9254994687 LibWeb/HTML: Update get_an_elements_target() to current spec 2025-01-31 17:27:03 +00:00
Tim Ledbetter
8dfd382e12 LibWeb: Use as_if instead of dynamic_cast in a few places 2025-01-31 14:29:48 +01:00
Jelle Raaijmakers
342cb7addf LibGfx+LibWeb: Reuse DisplayListPlayer and PaintingSurface when possible
Previously, we were reinstantiating the DisplayListPlayer and
PaintingSurface on every paint.
2025-01-31 13:28:09 +01:00
Jelle Raaijmakers
7b3d4a9edb LibWeb: Cache Skia backend context in TraversableNavigable
We just need to create the backend context once and let Skia handle the
context's state.

On my machine, this reduces the load time for https://tweakers.net from
7.5s to 3.5s.
2025-01-31 13:28:09 +01:00
Jelle Raaijmakers
1d81c4d8eb LibGfx: Use same order for macOS and Vulkan specific code
No functional changes.
2025-01-31 13:28:09 +01:00
Jelle Raaijmakers
4fbeea6482 LibWeb+Services: Remove unused #includes
No functional changes.
2025-01-31 13:28:09 +01:00
Jelle Raaijmakers
20fbd38b77 LibWeb: Remove MetalContext from TraversableNavigable
There's no need for TraversableNavigable to keep track of the
MetalContext; our SkiaBackendContext keeps a reference to it.
2025-01-31 13:28:09 +01:00
Luke Warlow
dd37d1c536 LibWeb: Implement dialog.requestClose() 2025-01-30 15:50:06 -07:00
Gingeh
b056e27afd LibWeb: Hide visible popover when type is changed 2025-01-30 15:46:52 -07:00
Gingeh
e670caeb0c LibWeb: Ignore DOM state when hiding removed popovers
Using https://github.com/whatwg/html/pull/9457
(with some changes made to catch up with the current spec)
to fix a spec bug and a crash when removing a visible popover.
2025-01-30 15:46:52 -07:00
Gingeh
108f3a9aac LibWeb: Implement popovertarget buttons 2025-01-30 15:46:52 -07:00
Feng Yu
37e1d6ece1 LibWeb: Implement nagivator.serviceWorker.getRegistration() 2025-01-30 15:18:43 -07:00
Shannon Booth
ebd6d49415 LibWeb/HTML: Add fastpath to skip selectedness update on option insert
This extends the optimization introduced in the previous commit to
also apply to the inserted steps for an option element. This makes
the test:

https://wpt.live/html/select/options-length-too-large.html

Go from not ever completing due to how slow it was to running, to
finishing in 800ms on my PC :^)
2025-01-30 13:55:40 -07:00
Shannon Booth
075c7ea63e LibWeb/HTML: Add fastpath to skip selectedness update on children change
We can definitely expand on this a bunch more, but using the metadata
provided in the children change notification we are able to skip
runnning the expensive selectedness algorithm on the <select> element.

This removes children changed from appearing in the profile of:

https://wpt.live/html/select/options-length-too-large.html
2025-01-30 13:55:40 -07:00
Shannon Booth
903c8860f8 LibWeb: Add metadata to children update steps invocation
Currently, this metadata is only provided on the insertion steps,
though I believe it would be useful to extend to the other cases
as well. This metadata can aid in making optimizations for these
steps by providing extra context into the type of change which
was made on the child.
2025-01-30 13:55:40 -07:00
Shannon Booth
6c1470994b LibWeb/HTML: Add a helper for getting parent <select> for <option> 2025-01-30 13:55:40 -07:00
Shannon Booth
5b6b4d93a3 LibWeb/HTML: Add a cache for the list of Options for HTMLSelectElement
This is still called _way_ too often, and we need to be much smarter
about when this needs to run. But we get two wins from this very
naive implementation:

  1. There is a inner text setter nested within the selectedness
     steps uses this list of elements. This saves us building
     up a list of elements again within these steps.
  2. More importantly, it caches the number of selected elements.
     This already allows us to skip a minor amount of work iterating
     over the children again. But in future commits, this will serve
     as one of the criteria for skipping running the selectedness
     algorithm altogether for certain cases, which is a very big win.

A example future idea might be to append to this list directly when
something like appendChild is run instead of iterating over all of
the children again. But that's left as future work.
2025-01-30 13:55:40 -07:00
Shannon Booth
c647ac407d LibWeb/HTML: Avoid double lookup of size attribute 2025-01-30 13:55:40 -07:00
Shannon Booth
319b447fdd LibWeb/HTML: Remove uneeded FIXMEs about global being a Window
The spec only refers to this property as something that is on a
Window object, and as far as I can tell this API is only ever
exposed on a Window object anyhow.
2025-01-30 13:55:40 -07:00
Shannon Booth
1db568d06f LibWeb/HTML: Remove microtask invocation of update selectedness
This is fundametally broken. A microtask only finishes after all
javascript has finished running. The selectedness of a select element
is observable by javascript, so any changes which are made as a result
of children changing associated with a select element should be made
through the children update steps and friends.
2025-01-30 13:55:40 -07:00
Sam Atkins
385c3d273a LibWeb/CSS: Update CalculatedOr API to use CalculationResolutionContext
To be properly compatible with calc(), the resolved() methods all need:
- A length resolution context
- To return an Optional, as the calculation might not be resolvable

A bonus of this is that we can get rid of the overloads of `resolved()`
as they now all behave the same way.

A downside is a scattering of `value_or()` wherever these are used. It
might be the case that all unresolvable calculations have been rejected
before this point, but I'm not confident, and so I'll leave it like
this for now.
2025-01-30 19:31:54 +01:00
Luke Wilde
bf34b63439 LibWeb: Don't compare the focus chain's GC::Root contents by reference
The focus chain always consists of newly created GC::Root objects, so
the condition always produced `false`. The fix is to use GC::Root's
overloaded operator== method, which compares the pointers of the stored
type.

This fixes Figma dropdowns and context menus instantly disappearing
upon opening them. This is because they become focused when they insert
them. Because of this bug, it would fire blur events all the way up to
and including the window. Figma listens for the blur event on the
window, and when received, it will instantly hide dropdowns and context
menus. The intention behind this seems to be hiding them when the user
clicks off the browser window, or switches tab.
2025-01-30 19:30:44 +01:00
Tim Ledbetter
11acd54463 LibWeb: Change default window ESO crossOriginIsolated value to false
This is a safer default value for this property since we don't
currently implement the mechanisms required for this value to be true.
2025-01-30 18:37:53 +01:00
Sam Atkins
3775f3399c LibWeb: Fix various typos
Corresponds to:
- https://github.com/whatwg/html/pull/10934
- https://github.com/whatwg/html/pull/10950
2025-01-30 15:00:16 +00:00
Sam Atkins
c5d793c4a9 LibWeb: Split out CanvasSettings IDL interface mixin
Corresponds to https://github.com/whatwg/html/pull/10904

However, we don't implement most of what is changed in that PR, so this
simply moves the FIXME'd getContextAttributes() method from one place
to another.
2025-01-30 15:00:16 +00:00
Sam Atkins
3e4b1056b5 LibWeb: Consistently use navigables for WebDriver BiDi
Corresponds to https://github.com/whatwg/html/pull/10909
2025-01-30 15:00:16 +00:00
Sam Atkins
f0c597a446 LibWeb/HTML: Use WorkerGlobalScope as Trusted Type sink global name
Corresponds to https://github.com/whatwg/html/pull/10913
2025-01-30 15:00:16 +00:00
Luke Wilde
3295ed17ea LibWeb: Use application/octet-stream for unknown FormData file types
Required by web.whatsapp.com, which uses fetch() to send FormData
bodies containing Files with empty types.
Ref https://github.com/LadybirdBrowser/ladybird/issues/2941
2025-01-29 09:25:40 +01:00
Tim Ledbetter
8b5a25e47f LibWeb: Generate correct timestamp values when updating animations
Previously, we were generating timestamps relative to the current time
of the monotonic clock. We now generate timestamps relative to the
event loop's last render opportunity time, per the spec.
2025-01-28 11:31:46 +00:00
Psychpsyo
67ed676831 LibWeb: Implement CSS 'contain' property 2025-01-28 11:24:40 +00:00
Tim Ledbetter
8963e62a5e LibWeb: Add a time origin property for all ESOs
This acts as a baseline for performance related timestamps.
2025-01-27 14:53:33 +01:00
Shannon Booth
802529bafc LibWeb/HTML: Iterate over select options in tree order
This also saves us from iterating twice over the children, and
instead do it in a single pass.
2025-01-27 00:10:14 +00:00
Shannon Booth
31dc1fa662 LibWeb/HTML: Only get list of options once in 'update selectedness'
It is not cheap to do this, so only do it once within this function.
There is definitely some caching that we can do here, but this will
require some smart invalidation to detect _relevant_ changes in
the children.
2025-01-27 00:10:14 +00:00
Shannon Booth
14eb081af8 LibWeb: Add missing calls to Base::children_changed
Also making sure that it is called at the top of the implementation
for consistency.
2025-01-27 00:10:14 +00:00
Shannon Booth
22a7cd9700 LibWeb: Port Document encoding_parse_url and parse_url to Optional<URL>
This ports two more APIs away from URL::is_valid.
2025-01-27 00:03:07 +00:00
Luke Warlow
391a08bf17 LibWeb: Update spec comments for dialog, popover and close watcher 2025-01-25 03:40:08 +00:00
Sam Atkins
d7ea949d2f LibWeb/HTML: Convert drop-shadow() lengths to pixels
Using the raw value meant that 1em would be incorrectly treated as 1px,
for example.

I've updated our canvas-filters test to demonstrate this - without the
code change this would instead have an x-offset of 2px.
2025-01-24 13:55:52 +01:00
Luke Warlow
f5860a3b7d LibWeb: Implement hidden="until-found" IDL support
Follow-ups will implement the actual behaviour.
2025-01-24 09:08:37 +01:00
Andreas Kling
adc25af8e2 LibWeb: Make "assign slottables for a tree" fast when there are no slots
We achieve this by keeping track of the number of HTMLSlotElements
inside each ShadowRoot (do via ad-hoc insertion and removal steps.)

This allows slottables assignment to skip over entire shadow roots when
we know they have no slots anyway.

Massive speedup on https://wpt.fyi/ which no longer takes minutes/hours
to load, but instead a "mere" 19 seconds. :^)
2025-01-23 21:38:31 +01:00
Andreas Kling
003c045589 LibWeb: Add missing base class upcalls in Node::inserted() overrides 2025-01-23 21:38:31 +01:00
Andreas Kling
7269fc3e52 LibWeb: Pass old parent's root to Node::removed_from()
This will allow nodes to access the root they've just been removed from.
2025-01-23 21:38:31 +01:00
Jelle Raaijmakers
336684bc5c LibWeb: Support inserting non-inline elements into inline elements
Our layout tree requires that all containers either have inline or
non-inline children. In order to support the layout of non-inline
elements inside inline elements, we need to do a bit of tree
restructuring. It effectively simulates temporarily closing all inline
nodes, appending the block element, and resumes appending to the last
open inline node.

The acid1.txt expectation needed to be updated to reflect the fact that
we now hoist its <p> elements out of the inline <form> they were in.
Visually, the before and after situations for acid1.html are identical.
2025-01-23 09:33:10 +01:00
Shannon Booth
fd27eef0d1 LibWeb: Return OptionalNone from DOMURL::parse on failure
This ports one more function away from needing to use the awkward
valid state of the URL class.
2025-01-22 12:33:55 +00:00
Psychpsyo
d5c21301db LibWeb: Fix context menu and select dropdown position in iframe 2025-01-22 12:25:48 +00:00
Shannon Booth
ca3d9d9ee0 LibURL+LibWeb+LibIPC: Represent blob URL entry's object using structs
Instead of just putting in members directly, wrap them up in structs
which represent what a URL blob entry is meant to hold per the spec.
This makes more obvious what this is meant to represent, such as the
ByteBuffer being used to represent the bytes behind a Blob.

This also allows us to use a stronger type for a function that needs
to return a Blob URL entry's object.
2025-01-21 19:22:07 +00:00
Sam Atkins
d40ccb97ec LibWeb/HTML: Update Navigable::choose_a_navigable() to latest spec
This corresponds to part of https://github.com/whatwg/html/pull/10818
2025-01-21 18:17:18 +01:00
Timothy Flynn
85b424464a AK+Everywhere: Rename verify_cast to as
Follow-up to fc20e61e72.
2025-01-21 11:34:06 -05:00