Commit graph

27 commits

Author SHA1 Message Date
Tim Ledbetter
8b2de413ae LibWeb: Ensure selected options collection is created prior to access 2025-02-08 07:32:24 -05:00
Sam Atkins
4cb2063577 LibWeb/CSS: Stop returning Optional for enum properties
While keyword_to_foo() does return Optional<Foo>, in practice the
invalid keywords get rejected at parse-time, so we don't have to worry
about them here. This simplifies the user code quite a bit.
2025-02-05 18:12:36 +01:00
Psychpsyo
bad7324307 LibWeb: Implement CSS validity pseudo-classes 2025-02-05 12:38:55 +00: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
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
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
Timothy Flynn
85b424464a AK+Everywhere: Rename verify_cast to as
Follow-up to fc20e61e72.
2025-01-21 11:34:06 -05:00
Psychpsyo
5b9d18b462 LibWeb: Improve <select> dropdown position 2025-01-14 07:34:51 +00:00
Psychpsyo
8f11dfc08a LibWeb: Make select element use option's label, not text content 2025-01-04 11:44:03 +00:00
Andreas Kling
74469a0c1f LibWeb: Make CSS::ComputedProperties GC-allocated 2024-12-22 10:12:49 +01:00
Andreas Kling
c1cad8fa0e LibWeb: Rename CSS::StyleProperties => CSS::ComputedProperties
Now that StyleProperties is only used to hold computed properties, let's
name it ComputedProperties.
2024-12-22 10:12:49 +01:00
Tim Ledbetter
6218f1a609 LibWeb: Limit HTMLSelectElement.size to allowed values
This change ensures that the correct default value of 0 is used and
that values greater than 2147483647 will fall back to the default value.

It also splits the display size concept into a separate method, as
this isn't supposed to be used when getting the IDL property.
2024-11-29 13:30:57 +01:00
Shannon Booth
f87041bf3a LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
2024-11-15 14:49:20 +01:00
Andreas Kling
dc9179bb1b LibWeb: Keep track of the order in which option elements are selected
This allows us to locate the most-recently-selected when running the
selectedness update algorithm.
2024-11-14 23:06:30 +01:00
Shannon Booth
9b79a686eb LibJS+LibWeb: Use realm.create<T> instead of heap.allocate<T>
The main motivation behind this is to remove JS specifics of the Realm
from the implementation of the Heap.

As a side effect of this change, this is a bit nicer to read than the
previous approach, and in my opinion, also makes it a little more clear
that this method is specific to a JavaScript Realm.
2024-11-13 16:51:44 -05:00
Michael Watt
3b1d1d4582 LibWeb: Compute display: contents as none for unusual elements
https://drafts.csswg.org/css-display-3/#unbox-html specifies certain
elements that have their `display` style computed as `none` when
specified as `contents`.

This fixes at least one WPT test:
http://wpt.live/css/css-display/display-contents-suppression-dynamic-001.html
2024-11-13 11:11:07 +01:00
Pavel Shliak
1bdc41faa1 LibWeb: Reduce SelectItemOption struct from 40 to 32 bytes 2024-11-11 17:06:20 +01:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Luke
e8a9e8aed5 LibWeb: Add namespace to Element 2020-10-22 15:24:42 +02:00
Luke
be5a62d5d7 LibWeb: Add all HTML elements between S and V 2020-08-09 21:14:51 +02:00