Servo has had two implementations of `selectors::Element`, one used
during layout and one used for `Element#matches()` and
`Element#closest()`. The DOM APIs can trivially use the version that's
exposed to the layout interface, which allows removing the duplicated
implementation. This will eliminate code and prevent the two
implementations from drifting apart.
Testing: This should not change behavior in a testable way so should
be covered by existing tests.
Signed-off-by: Martin Robinson <mrobinson@fastmail.fm>
Co-authored-by: Martin Robinson <mrobinson@fastmail.fm>
This should be done for CopyTexImage2D, like it is already done for
TexImage2D and CompressedTexImage2D.
Testing: Regular testsuite. I was unable to add a dedicated case because
all I could think of it check the bound buffer's status before and after
copyTexImage2D, but I could not find a way to change it from say
complete to something else.
Fixes: #23264
---------
Signed-off-by: Simon Martin <simon@nasilyan.com>
Signed-off-by: Martin Robinson <martin@abandonedwig.info>
Co-authored-by: Martin Robinson <martin@abandonedwig.info>
Moved devtools_wants_updates from GlobalScope to Window
Testing: Compiles cleanly. ```./mach test-devtools``` gives different
results each time, ```./mach test-devtools
test_sources_list_with_data_inline_classic_script``` always pass though.
Fixes: #44106
Signed-off-by: Sabb <sarafaabbas@gmail.com>
Signed-off-by: Abbas Olanrewaju Sarafa <109840351+sabbCodes@users.noreply.github.com>
This change reworks the layout DOM wrappers so that they are simpler and
easier to reason about. The main changes here:
**Combine layout wrappers into one interface:**
- `LayoutNode`/`ThreadSafeLayoutNode` is combined into `LayoutNode`:
The idea here is that `LayoutNode` is always thread-safe when used in
layout as long as no `unsafe` calls are used. These interfaces
only expose what is necessary for layout.
- `LayoutElement`/`ThreadSafeLayoutElement` is combined into
`LayoutElement`: See above.
**Expose two new interfaces to be used *only* with `stylo` and
`selectors`:**
`DangerousStyleNode` and `DangerousStyleElement`. `stylo`
and `selectors` have a different way of ensuring safety that is
incompatible with Servo's layout (access all of the DOM tree anywhere,
but ensure that writing only happens from a single-thread). These types
only implement things like `TElement`, `TNode` and are not intended to
be used by layout at all.
All traits and implementations are moved to files that are named after
the struct or trait inside them, in order to better understand what one
is looking at.
The main goals here are:
- Make it easier to reason about the safe use of the DOM APIs.
- Remove the interdependencies between the `stylo` and `selectors`
interface implementations and the layout interface. This helps
with the first point as well and makes it simpler to know where
a method is implemented.
- Reduce the amount of code.
- Make it possible to eliminate `TrustedNodeAddress` in the future.
- Document and bring the method naming up to modern Rust conventions.
This is a lot of code changes, but is very well tested by the WPT tests.
Unfortunately, it is difficult to make a change like this iteratively.
In addition, this new design comes with new documentation at
servo/book#225.
Testing: This should not change behavior so should be covered by
existing
WPT tests.
Signed-off-by: Martin Robinson <mrobinson@fastmail.fm>
When building the devcontainer from source on arm macOS, we get arm
Ubuntu, for which we don't have a prebuild mozjs version. That triggers
a compilation from source, which fails, due to issues finding String.h.
I can't confirm this, but it might be because the mounted workspace is
case-insensitive. We definitly don't want that, so just make sure that
the cargo target directory is in a named volume. That also has the
advantage that we don't clobber the hosts target dir and still persist.
Testing: Manually tested on macOS.
Fixes: ./mach build in a devcontainer built from source on arm64 macOS.
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Fixes: #44105
moved member and initialization of crypto in Globlalscope to window and
workerGlobalScope
Testing: required tests passed
`
web-platform-test
Ran 80 checks (78 subtests, 2 tests)
Expected results: 80
Unexpected results: 0
OK
`
Signed-off-by: Rover track <rishan.pgowda@gmail.com>
cargo-about is only used in the ./mach release command, which will only
be used by very few people (when preparing a release). Hence it doesn't
make sense to install it for everyone, and instead we can just tell the
user how to install if it is missing, and save resources for everyone
else.
Testing: Not tested, but trivial
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Based on our linux-wpt.yml workflow update our bootstrap and
devcontainer package list.
This should make the local environment closer to our CI environment when
running WPT. We only purge the droid font in the devcontainer, since we
shouldn't purge packages for the user.
mesa-vulkan-drivers was added in
71e0372ac1, so it's probably required for
WebGPU.
fonts-noto-cjk was added in 2b0d2ecc73.
In both cases no reason was given why it can't be in bootstrap, so
presumably its just an oversight.
Testing: bootstrap is ran in CI, and the packages were already being
installed by the wpt workflow.
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This file was getting way too big and too cluttered. Instead, split it
up into multiple files in a dedicated folder.
Part of #25005
Part of #43709
Testing: It compiles
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Implementing Drop for DOM types is being forbidden. This change moves
the shader deletion logic into a separate DroppableWebGLShader struct,
allowing WebGLShader to comply with this restriction while still
ensuring GPU resources are released when the object is finalized.
Testing: Covered by existing WebGL tests.
Fixes: #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
The publish environment enforces additional restrictions, mainly that
the workflow can only be run from protected branches and additional
prevents access of the publish secrets from workflows which do not use
this environment.
Testing: Requires a manual workflow run on a protected branch. Given
that we already tested environments in previous PRs, I think this PR
might be safe to test after merging, instead of protecting the PR
branch.
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Many things are nodes, such as `CharacterData` and attributes. They
don't need style data at all. This saves 16 bytes on every attribute and
text node.
Testing: This should not change testable behavior (only save some
memory),
so it should be covered by existing tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Changes all the uses of `ServoUrl` to `ImmutableOrigin` in
`WebStorageThreadMsg`
Testing: Adds a test case as described in the issue.
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<main>
<h1>Tab and Program crashes!</h1>
<iframe srcdoc="
<body>
<p>Hello Web users! <br/> I am an iframe, <br /> I set a key and then retreive it. </p>
<script>
for (let i = 0; i < 1000; i++) {
window.localStorage.setItem('truth', 'Servo is awesome! 🌐')
const example = window.localStorage.getItem('truth')
console.log(example === 'Servo is awesome! 🌐')
}
</script>
</body>
"></iframe>
</main>
</body>
</html>
```
Fixes: #44001
---------
Signed-off-by: Niya Gupta <niyabits@disroot.org>
`dom_count` was used to determine whether it is worth it to run layout
parallel algorithm.
Now this is based on `layout_threads` pref.
Testing: Just removing dead code.
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Using the new yaml anchor feature, we can inline the upload_release
workflow file without duplicating code.
In combination with the matrix feature this allows us to remove quite a
bit of duplication. I'm not sure why we didn't use matrix to begin with.
This is also a preparation for a follow-up PR, that uses github
environments to improve secret protection, since reusable workflows
don't support environments.
Testing: [manually triggered nightly
release](https://github.com/servo/servo/actions/runs/24236862409)
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Adjust event targeting for keyboard events when a shadow host is
involved. This is needed to not interfere with keyboard default action
like tabindex focusing.
Testing: Updated WPT tests expectations
Fixes: #43809
---------
Signed-off-by: webbeef <me@webbeef.org>
Make Servo match the focus bits of the HTML specification a bit more by
storing a `FocusableArea` as the currently focused thing in a
`Document` instead of an optional `Element`. There is always a focused
area of a `Document`, defaulting to the viewport. This is important to
support the case of focused navigables and image maps parts in the
future.
Some focus chain debugging code has been removed as the focus chain
concept needs to be reworked to match the specification more closely.
Testing: This should not change behavior so existing tests should
suffice.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
I noticed that the transferFromImageBitmap() was running without errors
but the canvas stayed blank and this was becacuse of two issues:
The mark_as_dirty was empty meaning the canvas never knew it needed to
repaint
The BitmapRenderer context had no rendering pipeline as such no ImageKey
was allocated and update_rendering always returned false, so the way I
fixed it is by
1. Implemented mark_as_dirty to call self.canvas.mark_as_dirty()
2. Allocated an ImageKey for BitmapRenderer contexts
3.Implemented set_image_key and update_rendering that sends the bitmap's
pixel data to WebRender via the paint API
4, Calling mark_as_dirty after set_bitmap in TransferFromImageBitmap
Now the reason we are setting an ImageKey on the
ImageBitmaRenderingContext is because it needs one to render to the
screen and without it the canvas was always blank
Also I noticed that for some reasons I don't understand yet, the
createImageBitmap hangs or is slow to render but after loading servo on
an open tab, if I then go ahead and open another tab and paste the file
link there, the previous tab which had the bitmap image now renders
properly
Fixes: #43565
<img width="383" height="238" alt="Screenshot from 2026-04-06 13-44-28"
src="https://github.com/user-attachments/assets/4c5096ba-ee84-4e7a-a3c6-673cc12276c4"
/>
<img width="389" height="292" alt="Screenshot from 2026-04-06 15-38-55"
src="https://github.com/user-attachments/assets/43b45e60-61d8-48de-b53e-6da5ab988768"
/>
Signed-off-by: Messi002 <rostandmessi2@gmail.com>
Testing: We have no automated testing for the servoshell UI. Some quick
manual testing of servo.org seemed to work as expected.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Servo has lots of `LayoutXYZHelper` traits that are used to define
additional methods on `LayoutDom<XYZ>`. We can replace them with `impl
LayoutDom<XYZ>` blocks, reducing the number of LoC and making it easier
to add or modify methods.
Testing: These should be covered by existing tests
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This prevents issues for users that don't already have a lockfile, since
prerelease versions can have breaking changes.
This should also be backported to the release branch.
Testing: No changes, covered by existing tests.
Fixes: #44089
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This is another part of moving more operations safely to unrooted
iterators.
- Some uses of inclusively_*_siblings
- Some uses of children()
- Some uses of child_elements()
Testing: Compilation is the test as we only use previously made iterator
functions.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Adds a WPT test to make sure we do not share the storage thread between
any document that has an opaque URL.
The test is required for #43988
Testing: Adds a WPT test.
Fixes: #44001
---------
Signed-off-by: Niya Gupta <niyabits@disroot.org>
Calling `compressedTexSubImage2D` without a prior `compressedTexImage2D`
for the same texture target and level caused the panic at
`tex_image_2d.rs:633` because `image_info_for_target` returned `None`
and `.unwrap()` was called on it.
Per the WebGL spec, this should generate `GL_INVALID_OPERATION` instead
of panicking. So this PR replaces the unwrap with proper error handling.
And also includes a WPT crash test that reproduces the original panic.
Fixes#43527
---------
Signed-off-by: thebabalola <t.babalolajoseph@gmail.com>
When triggering the release action on a non-protected branch in this
repo, the job is rejected (as intended):
<img width="1484" height="304" alt="image"
src="https://github.com/user-attachments/assets/236d3a41-2765-4652-8709-93110e03c77b"
/>
When triggering the action on a protected branch in this repository, the
publish-crates-io job will be pending, until explicitly approved by one
of the required approvers (thanks to the `environment` settings).
This allows us to publish all of our packages in one go.
Testing: Tested by manually
[triggering](https://github.com/servo/servo/actions/runs/24119955943/job/70371705395)
a release for `0.1.0-rc2`, which got successfully published to
crates.io. This was also a resume-after-cancellation test, since the
first ~30 crates of the release had already been published via `cargo
publish --workspace`, before running into the issue that `cargo publish
--workspace` can't resume after intermediate failures. The last commit
"Fix buffering issue in CI" is untested, and was added after observing
the stdout log messages only appearing at the end of the script. That
commit is trivial though, and probably does not justify using crates.io
resources for another test release.
---------
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
Co-authored-by: Mukilan Thiyagarajan <mukilanthiagarajan@gmail.com>
Changes ```word-spacing``` to resolve percentages against the computed
```font-size```, instead of the size of a space.
Testing:
```tests/wpt/tests/css/css-text/word-spacing/word-spacing-percent-001.html```
is now passing
Fixes: #43997
---------
Signed-off-by: Sabb <sarafaabbas@gmail.com>
Several more TODO's are now implemented:
1. We correctly restore values for fontsize now
2. We implement relevant logic in wrap_node_list
3. We implement simple modifiable
4. We clear overrides whenever the selection changes
(which is triggered for both the selection itself and
any containing ranges).
Part of #25005
Testing: WPT
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
The macro `impl_from_pref!` would cause panic in this case.
Testing: Add more test cases to existing UT.
Fixes: #44078
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This change allows users to pass a mark like `"navigationStart"` to
`Performance.measure` and that will resolve to the value of
`navigationStart` on the `PerformanceTiming` interface.
Testing: New tests start to pass
Part of https://github.com/servo/servo/issues/43821 - we no longer throw
an exception in the case above.
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
If we make manual releases, e.g. for release candidate testing, then
they shouldn't appear on the nightly download page on servo.org, which
just displays the release that is marked as "latest".
Since the Github API documentation updated to a new API version, also
opt-in to the new version while we are at it.
There seem to be no changes affecting the usage in release.yml, but
probably the old API will be removed eventually, so why not switch to
the new version now.
See
https://docs.github.com/en/rest/releases/releases?apiVersion=2026-03-10#create-a-release
Testing: [Manual release workflow
run](https://github.com/servo/servo/actions/runs/24241705213). The
release should not be marked as latest after the run finishes.
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Indexeddb keys need to remain sorted in the database, so that key range
queries can be made via sql. This allows for key range querying without
having to load each key into memory. The solution is to serialize keys
with a custom encoding that sorts them according to the spec. The
implementation is taken from firefox.
Testing: WPT, and unit tests
Fixes: None
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
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>
This ensures that the selection after the move is as expected.
It mostly fixes tests that had fully passing implementation, but
the after fontsize was incorrect, since the selection wasn't
properly updated.
Some new regressions were false positives.
Part of #25005
Testing: WPT
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
Bumps libredox from 0.1.15 to 0.1.16.
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
</details>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Do not `cancel_animations_for_node` for this function.
We can then reuse it more often.
Testing: Just a refactor.
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Added a `register` method to `NodeActor` following the same pattern used
by other actors in the devtools codebase. Updated
`NodeInfoToProtocol::get_or_register_node_actor` to use it instead of
constructing `NodeActor` directly.
Testing:
Ran `./mach try linux-unit-tests` and `./mach test-devtools`. No new
failures introduced.
Fixes:part of #43800
---------
Signed-off-by: Emmanuel Paul Elom <elomemmanuel007@gmail.com>
font: Use `read_fonts` module to generate font list on OpenHarmony
platform. Specifically:
- `Family name` is obtained from the font's `name` table.
- `width` & `weight` is obtained from the font's `os2` table.
- `style` is obtained from the font's `postscript` table.
Additionally, I'd like to mention that I plan to add a caching mechanism
to store the font list in the near future (as mentioned in the related
issue)
Reference: [TrueType reference
manual](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6.html)
Testing: No behavior changes expected.
Fixes: Part of [#43596](https://github.com/servo/servo/issues/43596)
---------
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Added a `register` method to `PageStyleActor` following the same pattern
used by other actors in the devtools codebase. Updated
`InspectorActor::register` to use it instead of constructing
`PageStyleActor` directly.
Testing:
Ran `./mach try linux-unit-tests` and `./mach test-devtools`. No new
failures introduced.
Fixes:part of #43800
Signed-off-by: Emmanuel Paul Elom <elomemmanuel007@gmail.com>
Signed-off-by: eri <eri@igalia.com>
Co-authored-by: eri <eri@igalia.com>