Commit graph

36 commits

Author SHA1 Message Date
Andreas Kling
a6dfc74e93 LibWeb: Only set prototype once for object with IDL interface
Before this change, we were going through the chain of base classes for
each IDL interface object and having them set the prototype to their
prototype.

Instead of doing that, reorder things so that we set the right prototype
immediately in Foo::initialize(), and then don't bother in all the base
class overrides.

This knocks off a ~1% profile item on Speedometer 3.
2025-04-20 18:43:11 +02:00
Andreas Kling
f0abf5a43b LibWeb: Avoid allocating DOMRect objects for internal engine use
Some checks failed
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Build Dev Container Image / build (push) Has been cancelled
Instead of bothering the GC heap with a bunch of DOMRect allocations,
we can just pass around CSSPixelRect internally in many cases.

Before this change, we were generating so much DOMRect garbage that
we had to do a garbage collection *every frame* on the Immich demo.
This was due to the large number of intersection observers checked.

We still need to relax way more when idle, but for comparison, before
this change, when doing nothing for 10 seconds on Immich, we'd spend
2.5 seconds updating intersection observers. After this change, we now
spend 600 ms.
2025-03-22 14:33:59 -05:00
Timothy Flynn
206ec6694c LibWeb: Update the select element's text when setting the selected index
We were updating the IDL values, but the rendered text would remain on
the previously selected value.
2025-03-22 17:27:45 +01:00
Sam Atkins
3dd079b308 LibWeb/HTML: Add stub for WebDriver BiDi to intercept file dialogs
Corresponds to 09ad1b9894
2025-03-17 09:34:48 +00:00
sideshowbarker
db7aa68340 LibWeb: Implement checkValidity() for HTMLSelectElement
This change adds an implementation of the checkValidity() method for
HTMLSelectElement.
2025-02-26 14:07:39 +00:00
sideshowbarker
e79319ad85 LibWeb: Implement the form-control willValidate property
This change — part of the HTML constraint-validation API (aka
“client-side form validation”) — implements the willValidate IDL/DOM
attribute/property for all form controls that support it.
2025-02-26 05:45:06 +00:00
InvalidUsernameException
f7276bfab3 LibWeb: Reduced number of recompiled files for CSS property headers
Some checks are pending
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This reduces the number of `.cpp` files that need to be recompiled when
one of the below header files changes as follows:

CSS/ComputedProperties.h: 1113 -> 49
CSS/ComputedValues.h: 1120 -> 209
2025-02-23 10:14:39 -05:00
Psychpsyo
3fbbe9d6a5 LibWeb: Make SelectElement arrow use text color 2025-02-20 14:06:23 -05:00
Psychpsyo
86859b77a2 LibWeb: Hide hidden select children from dropdown 2025-02-12 13:44:50 +00:00
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