Commit Graph

23 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
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
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
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
Tim van der Lippe
13472304a5 script: Support blocking attribute for style and link elements (#42096)
Testing: WPT

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
2026-01-26 09:12:38 +00:00
Oliver Medhurst
24fe746d3f script: Fix unfulfilled lint expectation in htmlstyleelement.rs (#42059)
Unfulfilled after #41986, causes lint warning in main.

Testing: `./mach build --use-crown`

Signed-off-by: Oliver Medhurst <honk@goose.icu>
2026-01-22 03:26:36 +00:00
Tim van der Lippe
6f9a0831bd script: Implement full logic for script-blocking stylesheets (#41988)
We only implemented the first part (parser_inserted), but
weren't checking any of the other cases.

Testing: WPT
Part of #22715

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-01-20 19:15:00 +00:00
Tim van der Lippe
3fedd1df53 script: Fix timing of update-a-style-block (#41986)
Updates it according to the spec and adds a big explanation why it
differs from the spec. It took me a while to figure out what's going on
here and why the code was actually correct.

Testing: WPT
Part of #22715
Fixes #42009

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2026-01-20 17:58:36 +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
WaterWhisperer
d57d422924 script: servoparser line number pass to CSP (#40597)
takes over the initial work from @zazabap in PR #38675 (Thanks
@zazabap!)

Testing: 
`./mach test-wpt
content-security-policy/securitypolicyviolation/blockeduri-inline.html`
`./mach test-wpt
/css/CSS2/abspos/abspos-containing-block-initial-001.xht`
Fixes #38167  
Closes #38675

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
Co-authored-by: zazabap <sweynan@icloud.com>
2025-11-13 09:48:17 +00:00
Oriol Brufau
cb906a6219 script: Pass the right base URI to inline sheets (#40554)
HTMLStyleElement was creating stylesheets using the URI of the document,
ignoring `<base>`.

To avoid having to create the UrlExtraData twice (or clone it), this
inlines the `stylesheetcontents_create_callback`.

Testing: 2 WPT are now passing
Fixes: #40550

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-11-11 09:59:22 +00:00
Oriol Brufau
1d0a8b05fb Upgrade Stylo to 2025-11-01 (#40522)
This continues #39612

Changelog:
- Upstream:
b98470a5cb...d71fd89b78
- Servo fixups:
4714bab122...7481d7f7af

Stylo tracking issue: https://github.com/servo/stylo/issues/264

---------

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-11-11 02:59:38 +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
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
WaterWhisperer
d5baab2bfc script: Move CSS DOM interfaces to script/dom/css/ (#40241)
Moves interfaces defined by the CSS spec to the `script/dom/css/` module
from `script/dom/`.

Testing: Just a refactor shouldn't need any testing
Fixes: Partially #38901

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-10-28 17:40:44 +00:00
Emilio Cobos Álvarez
87e397cd76 script: Don't use StyleSheet::update_from_str. (#40024)
I want to remove this stylo API and this is the only consumer. Instead
just parse a new style stylesheet.

Shouldn't change behavior.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2025-10-21 16:20:12 +00:00
Narfinger
423800eec4 Script: Lazily transform the DOMString into Rust String instead of immediately. (#39509)
This implements LazyDOMString (from now on DOMString) as outlined in
https://github.com/servo/servo/issues/39479.
Constructing from a *mut JSString we keep the in a
RootedTraceableBox<Heap<*mut JSString>> and transform
the string into a rust string if necessary via the `make_rust_string`
method.
Methods used in script are implemented on this string. Currently we
transform the string at all times.
But in the future more efficient implementations are possible.

We implement the safety critical sections in a separate module
DOMStringInner which allows simple constructors, `make_rust_string` and
the `bytes` method.
This method returns the new type `EncodedBytes` which contains the
reference to the underlying string in either format.

Testing: WPT tests still seem to work, so this should test this
functionality.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-10-09 18:18:03 +00:00
Martin Robinson
5f5f2abc0f script: Rename StylesheetLoader to ElementStylesheetLoader (#39537)
`StylesheetLoader` implements the `StylesheetLoader` trait from Stylo.
This is pretty confusing as the names are the same. This change renames
the Servo version to `ElementStyleSheet` loader so that it's clearer
from reading the code what each of these things are.

Testing: This change just makes a few renames so shouldn't change test
results.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-27 13:04:46 +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
Simon Wülker
206dcff080 Assert that style element has an owner in parse_own_css (#39458)
The existing `assert!(node.is_connected())` is wrong. What it *wants* to
assert is that the style element has an owner, which is either a
Document or a ShadowRoot that the element is a descendant of. However,
if the element is descendant of a ShadowRoot which is itself not
connected to a document then the assertion would fail.

Instead, we use `node.is_in_a_document_tree() ||
node.is_in_a_shadow_tree()`, which more accurately reflects the intent.

Testing: This change adds the test case from
https://github.com/servo/servo/issues/37781 as a crashtest
Fixes https://github.com/servo/servo/issues/39457
Fixes https://github.com/servo/servo/issues/37781

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-23 23:00:11 +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