Commit Graph

30 Commits

Author SHA1 Message Date
elomscansio
aa7eca43b7 script: propagate VirtualMethods::unbind_from_tree with &mut JSContext (#44422)
Propagate `&mut JSContext` in `VirtualMethods::unbind_from_tree`

Testing: Successful build is enough
Fixes: #42837

---------

Signed-off-by: Emmanuel Paul Elom <elomemmanuel007@gmail.com>
2026-04-23 14:09:11 +00:00
Tim van der Lippe
c8029ea092 script: Rename CanGc::note() to CanGc::deprecated_note() (#44081)
Per the suggestion in

https://servo.zulipchat.com/#narrow/channel/263398-general/topic/PSA.3A.20avoid.20new.20usages.20of.20CanGc.20whenever.20possible/near/583995807
to mark this method as deprecated and make clear it shouldn't be used
anymore, as alternatives exist.

Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-04-10 06:07:52 +00:00
Luke Warlow
55e586737b script: Implement drop-down select multiple (#43189)
Implement drop-down select multiple: 
 - Updates the embedder API to support multi-selects.
- Updates the select element to correctly reset when multiple attribute
is removed.
- Select now renders "n selected" as button text when more than 1, or 0
options are selected.

Note that listbox selects are not yet supported, once they are these new
features will be for `<select multiple size=1>`.

Testing: WPTs and also manually using
https://demo.lukewarlow.dev/css-forms.html. The two test regressions are
due to the lack of listbox support rather than an issue with this PR.
Fixes: #38509

---------

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
Signed-off-by: Martin Robinson <martin@abandonedwig.info>
Co-authored-by: Martin Robinson <martin@abandonedwig.info>
2026-04-10 05:47:21 +00:00
Tim van der Lippe
a1c8896eda script: Pass &mut JSContext to reflect_node_with_proto (#43952)
A lot (and I mean, really a lot) depends on these constructors.
Therefore, this is the one spaghetti ball that I could extract and
convert all `can_gc` to `cx`. There are some new introductions of
`temp_cx` in the callbacks of the servo parser, but we already had some
in other callbacks.

Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-04-05 18:07:30 +00:00
Sharan Poojari
9cbdf9d8b1 Gate picker on trusted click (#43485)
Fixes: #43360 
This PR makes `<select>` behave like other browsers by only opening the
picker for trusted user clicks, and adds a regression test to ensure
synthetic `.click()/dispatchEvent('click')` won’t open it.

---------

Signed-off-by: SharanRP <z8903830@gmail.com>
2026-03-22 12:18:20 +00:00
Tim van der Lippe
479a9b6be3 script: Pass &mut JSContext to attribute_mutated (#43383)
It pushes the `temp_cx` 1 level up to `element.rs` where the calling
chain begins. Other than that this was purely a mechanical change where
I used regexes to replace all patterns with the new ones.

Part of #42812

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-18 11:03:54 +00:00
Gae24
026d679783 script: Pass &mut JSContext to Element::create (#43348)
Pass `&mut JSContext` to `Element::create` and `create_html_element`

Testing: No functionality changes, covered by existing tests.
Part of #40600

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-17 13:03:33 +00:00
Gae24
e8b581aaf0 script: Pass &mut JSContext in more places (#43252)
Continuation of #43220, removes many `temp_cx` calls introduced by that.

Testing: No behaviour change, a successful build is enough.
Fixes: #43241 #43240

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-14 10:03:48 +00:00
Gae24
ef97d7e199 script: Pass &mut JSContext to VirtualMethods::bind_to_tree (#43220)
Testing: No behaviour change, a successful build is enough.
Fixes: #42838 #43239

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-14 07:37:47 +00:00
Gae24
048612fe84 script: Pass &mut JSContext to children_changed and adopting_steps (#43219)
Switch `VirtualMethods::children_changed` and
`VirtualMethods::adopting_steps` to `&mut JSContext`.

Testing: No behaviour change, a successful build is enough.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-13 13:40:40 +00:00
Luke Warlow
307ee6a1c5 layout: Paint the <select> chevon using an SVG (#43175)
Previously there were two issues:

1. The select chevron had a 4px margin which should have just applied to
the inline axis.
2. The chevron character had odd font metrics, so even once the margin
is fixed the select is still too tall.

This is fixed by using an SVG as a background-image instead of using the
▾ character.

Testing: Tested with https://demo.lukewarlow.dev/css-forms.html (and the
test case added in https://github.com/servo/servo/pull/42085).

| Before | After |
| ------|------|
| <img width="522" height="267" alt="image"
src="https://github.com/user-attachments/assets/7cc2d840-3384-4a6c-8945-0277cfb4096d"
/> | <img width="509" height="250" alt="image"
src="https://github.com/user-attachments/assets/99742dca-3ce6-4964-98bd-0cdbf3e14937"
/> |

---------

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
2026-03-11 13:56:32 +00:00
Gae24
fa86bbedbe script: Pass &mut JSContext to DOM apis that call Element::create (#43108)
Testing: No behaviour change, a successful build is enough.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-09 10:07:13 +00:00
Jacob Adam W.
d6fdd30c19 script: Implement HTMLSelectElement.selectedOptions (#43017)
This introduces a `CollectionSource` trait as an alternative to
`CollectionFilter` in `HTMLCollection`, allowing collections to provide
elements directly via a custom iterator rather than filtering a full
subtree traversal, which would otherwise be rather inefficient for
smaller iterable sequences of options that can be determined without
traversing the whole subtree again.

The newly implemented `selectedOptions` attribute on the `<select>`
element uses this to iterate only the element's list of options that are
marked as selected.

Testing: 14 assertions in the existing WPT went from failing to passing.

Fixes #15522.

---------

Signed-off-by: Jacob Adam <software@jacobadam.net>
2026-03-07 06:16:33 +00:00
Narfinger
a122bde4b1 Script: Use &mut JSContext in CheckValidity and ReportValidity Methods (#42820)
This is part of replacing can_gc with the new &JSContext/&mut JSContext
method.
We modify CheckValidity and ReportValidity in various HTML Elements to
use the context instead of CanGc.

Testing: Compilation is the test as this is mostly mechanical.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-02-25 10:34:21 +00:00
Luke Warlow
bd779d141a script: Add support for :open pseudo-class (#42195)
Add support for `:open` pseudo-class. This is supported on dialog,
details and select elements.


Stylo PR: servo/stylo#297
Testing: WPTs but also
`data:text/html,<select><option>123</option></select><style>:open {
background-color: red; }</style>`. There are some tests that now error,
these previously failed due to missing `:open` and now make it further
along hitting test_driver.send_keys() which causes them to error
Fixes: #41277.

---------

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
2026-01-29 17:08:51 +00:00
Simon Wülker
c023d8edc7 script: Prevent activation of disabled select elements (#42079)
This change also adjusts the styles of disabled select elements such
that the text appears grayed out, like in firefox:
<img width="480" height="84" alt="image"
src="https://github.com/user-attachments/assets/d36325f5-c811-492b-9510-7a32efd5fd7b"
/>


Testing: No tests. I think it would be possible to write a webdriver
test for this? It didn't seem worth the effort, if someone can point me
to the relevant resources then I'm happy to write one ^^

Fixes: https://github.com/servo/servo/issues/42075

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-01-23 00:40:28 +00:00
Simon Wülker
94e71e7ec0 Implement html5ever hooks for customizable <select> elements (#42036)
Do not merge yet - we need to create a new html5ever release.
The html5ever bump also includes encoding indicators, which we handle in
the most minimal way possible here. They will be handled properly by
https://github.com/servo/servo/pull/41730

Companion PR for https://github.com/servo/html5ever/pull/719

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-01-22 13:34:12 +00:00
WaterWhisperer
2a759ed6de Replace allow(crown::unrooted_must_root) with expect(crown::unrooted_must_root) (#41815)
Testing: `./mach build -d --use-crown` with no warnings
Fixes: #41761

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2026-01-10 08:05:49 +00:00
Andrei Volykhin
9efe79065e dom: Add the attribute mutation reason (#40527)
For some specific cases (one of them see below) where are requirement to
identify the reason of the attribute mutation (by whom/why it was
changed - by cloning, parser or directly), so the following `reason`
parameter was added to `AttributeMutation::Set` option.

Note that for the HTMLMediaElement the internal `muted` state should be
set to true when the element is created and the element has a `muted`
content attribute specified (should be done once on the first attribute
mutation caused by parser or cloning).

See https://html.spec.whatwg.org/multipage/#dom-media-muted

Testing: Improvements in the following tests
-
html/semantics/embedded-content/media-elements/user-interface/muted.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-10 10:09:03 +00:00
atbrakhi
ad8c81d634 servoshell: Implement context menu in servoshell (#40434)
This PR adds context menu support with clickable menu items in the
Minibrowser. The menu appears on right click and supports basic
navigation actions (Back, Forward, Reload).


Testing: We already have tests for ContextMenu in WebView API test.

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-11-08 11:11:09 +00:00
Simon Wülker
c4ae451612 Turn all commented links before functions into doccomments (#40331)
Servo has a lot of comments like this:
```rust
// https://example-spec.com/#do-the-thing
fn do_the_thing() {}
```
and I keep turning these into doc comments whenever I'm working close to
one of them. Doing so allows me to hover over a function call in an IDE
and open its specification without having to jump to the function
definition first. This change fixes all of these comments at once.

This was done using `find components -name '*.rs' -exec perl -i -0777
-pe 's|^([ \t]*)// (https?://.*)\n\1(fn )|\1/// <$2>\n\1$3|mg' {} +`.

Note that these comments should be doc comments even within trait `impl`
blocks, because rustdoc will use them as fallback documentation when the
method definition on the trait does not have documentation.

Testing: Comments only, no testing required
Preparation for https://github.com/servo/servo/pull/39552

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-01 05:32:45 +00:00
Yerkebulan Tulibergenov
5cc786a98e script: add CanGc as argument to VirtualMethods::children_changed (#40325)
script: add CanGc as argument to VirtualMethods::children_changed

Testing: These changes do not require tests because they are a refactor.
Addresses part of https://github.com/servo/servo/issues/34573

Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
2025-11-01 00:20:25 +00:00
Yerkebulan Tulibergenov
132bd24c6d add CanGc as argument to Validatable.validity_state (#40155)
add CanGc as argument to Validatable.validity_state

Testing: These changes do not require tests because they are a refactor.
Addresses part of https://github.com/servo/servo/issues/34573.

Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
2025-10-25 06:06:32 +00:00
shuppy
3fd9ebb849 script: Make file picker selection flow asynchronous (#39893)
Previously the `<input type=file>` would wait synchronously for file
selection
results from the embedder. This change moves that synchronous wait to
the
`FileManager` worker thread. The main benefit is that script is not
blocked waiting
for the embedder. The synchronous wait on the worker thread is not a
large issue
because it is run from a thread pool, though a later change could also
remove
that synchronous wait.

In addition, the API surface for file selection changes a bit as there
is now a `dismiss`
method which differentiates between selecting no file and not making a
choice at
all.

Testing: Covered by exiting WPT, WebDriver conformance, and unit tests.

---------

Signed-off-by: delan azabani <dazabani@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-10-20 07:33:11 +00:00
shuppy
0d57fcb3e6 libservo: Merge file selection dialog into EmbedderControls (#39859)
in #39709, we introduced a single “form control” or “embedder control”
delegate that requests the embedder’s input for &lt;select> and
&lt;input type="color"> elements.

this patch partially merges &lt;input type="file"> elements into that
new system, and renames “form controls” to “embedder controls” for
consistency.

internally we continue to use a separate code path where the embedder
directly communicates with the file manager thread. subsequent work will
make the messages asynchronous via the constellation and script thread,
like other embedder controls.

Testing: this is currently tricky to write an automated test for; we
expect to write a WebDriver test for this once we make the communication
asynchronous

---------

Signed-off-by: delan azabani <dazabani@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-10-15 06:12:19 +00:00
shuppy
b88007c14b libservo: Allow Servo to hide embedder controls (#39763)
In some situations, web content may need to hide embedder controls. For
example, when focus shifts when a `<select>` box is open or when the
element showing the control is removed from the DOM. This change adds a
new API to hide embedder controls when that happens.

Testing: This change adds a new API test.

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-10-14 07:56:33 +00:00
Martin Robinson
89dfb3ee49 libservo: Make FormControl responses completely asynchronous (#39709)
Before responses to `FormControl` requests were handled synchronous in
script (ie they would block the page). This change makes it so that they
are handled asynchronously, with their responses filtering back through
the Constellation. This should fix many WPT tests when run with
WebDriver.

Testing: There are some WebDriver-based test for this, but they do
not quite pass yet. More investigation is required, but this is
necessary to get them to pass.
Fixes: #39652
Fixes: #37013

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
2025-10-08 09:06:17 +00:00
Narfinger
a4c8ffe753 Script: Change script/dom/{bluetooth,canvas,html} to not rely on Deref<str> for DOMString (#39480)
This is part of the future work of implementing LazyDOMString as
outlined in https://github.com/servo/servo/issues/39479.

We use str() method or direct implementations on DOMString for these
methods. We also change some types.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>


Testing: This is essentially just renaming a method and a type and
should not change functionality.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-25 15:53:21 +00:00
Mukilan Thiyagarajan
e2241a93fe script: switch to Element::create in HTMLSelectElement (#39390)
This file was missed in 07b2ff5d60
(#39325). See that commit for the motivation.

Testing: Covered by existing web platform tests.

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-09-20 11:51:31 +00:00
Ashwin Naren
c92cd9e624 script: Move HTML DOM interfaces to script/dom/html/ (#39046)
See #38901.

Testing: Refactor
Fixes: Partially #38901

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-08-31 01:00:09 +00:00