Laying out a block-level box that establishes an independent formatting
context may require multiple attempts because it needs to avoid floats.
We were previously recomputing the automatic inline size every time,
even if it was always the same. Now we will only compute it once.
Testing: Not needed, no behavior change
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Replace DomRefCell<bool> with Cell<bool> for Response::redirected field.
Changed redirected field from DomRefCell<bool> to Cell<bool> and updated
all related methods:
- Struct field: redirected: DomRefCell<bool> → redirected: Cell<bool>
- Constructor: DomRefCell::new(false) → Cell::new(false)
- Getter method: *self.redirected.borrow() → self.redirected.get()
- Setter method: *self.redirected.borrow_mut() = value →
self.redirected.set(value)
Testing: As noted in the issue, compilation is sufficient for this
change.
Fixes: #39288
Signed-off-by: ritoban23 <ankudutt101@gmail.com>
Sometimes, the computed scrolling area of window is larger than
viewport. This causes panics in `Window.scroll` with `f32::clamp(0.0,
some negative number)`.
Eventually, we should find out why "computed scrolling area of window is
larger than viewport". But let's avoid the panics first.
Testing: This avoids panic, so definitely not covered by existing tests.
But it would be hard to write a automated test for this in headless
mode.
Fixes: #39346
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This changes removes the integration with Instruments.app "Points of
Interest" track for a variety of reasons:
- This functionality is made somewhat redundant by Servo's support for
Perfetto traces.
- This functionality depends on the `signpost` crate which hasn't seen
activity for 9 years and only supports macOS.
Testing: This removes some functionality that is only observable via
Instruments.app, so testing it is difficult.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Additionally also improve the warning message if the routed receiver
disconnects and exit the thread.
If the routed receiver disconnects, we can't receive any canvas messages
anymore, and any control messages can't remedy that, so we might as well
exit.
Testing: Channel changes are covered by existing tests. Exiting the
canvas thread if the routed thread disconnects is not tested, and needs
reviewer attention.
Part of https://github.com/servo/servo/issues/38912
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
The command-line help output for `-Z` and `DebugOptions were out of sync
again. This change makes sure they match again.
Testing: No tests necessary as this mainly just updates the help output.
Fixes: #39311
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This option is supported via the WebView API now and you can enable it
in servoshell by pressing `Ctrl` + `F12`. The command-line argument and
`Opts` field are older and I believe are no longer necessary.
Testing: This just removes a redundant command-line option, so no tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Testing: No functional changes. Covered by existing wpt tests.
Part of https://github.com/servo/servo/issues/38912
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Refactor the background hang monitor channels to use GenericChannel.
Deserialization errors of `BackgroundHangMonitorControlMsg` are now
logged and ignored instead of causing a panic.
Testing: No major functional changes. Covered by BHM tests.
GenericChannel is also already widely used in servo.
Part of #38912
---------
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
The first step for aborting fetch calls. It only
has the case where the signal was already aborted
prior to fetch starting.
Part of #34866
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Some WebIDL methods, attributes and dictionary members are named with
Rust keywords such as `type`, `use` and `continue`. Using those
identifiers directly in the generated Rust code would cause compilation
errors.
The code generator already addresses this issue for attributes and
dictionary members by adding a `_` suffix to the conflicting
identifiers, but does not yet apply the same treatment to methods. This
patch extends the handling to methods as well.
Fixes: #39286
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Previously, when we click any element, it would trigger "scroll into
view". What's worse, for an anchor `<a>`, clicking it would "scroll into
view" instead of navigating to the url until you retry the click. The
reason is that we built `scrollIntoView` into the focus transaction
system with default option. However, the default `preventScroll` for
`FocusOption` is false according to spec, which triggers "scroll into
view" by default with focus triggered by interaction.
This PR
1. Adds spec document for those which really expects "scroll into view",
i.e. `<form>` when validating data.
2. Make sure when we begin focus transaction, we prevent "scroll into
view".
3. `Focus` method of element/document stays unchanged, which by default
scroll into view if no parameter provided according to spec.
Testing: Manually tested on `servo.org` and other websites, and examples
with `<form>` still correctly scroll into view when validation fails.
Fixes: #38616
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
According to https://drafts.csswg.org/css-inline/#invisible-line-boxes,
if a line box contains non-zero inline-axis margins, padding or borders,
then it can't be phantom.
Therefore, this patch makes adds a `has_inline_pbm` flag to the line.
Note that we can't use the `has_content` flag, because that would add a
soft wrap opportunity between the padding/border/margin and the first
content of the line.
The patch also renames `InlineFormattingContext::had_inflow_content` to
`has_line_boxes`, which is what we care about for collapsing margins
through.
Testing: Adding new tests
Fixes: #39057
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This patch refactors the logic for propagating overflow to the viewport,
fixing various issues:
- Now we won't propagate from the root element if it has no box. Note
the fix isn't observable in Servo because we lack scrollbars.
- If the first `<body>` element has no box, we won't keep searching for
other `<body>` elements. This deviates from the spec, but aligns us with
other browsers.
- We won't propagate from the `<body>` if it has no box. We were already
handling `display: none` but not `display: contents`. This deviates from
the spec, but aligns us with other browsers.
Also, when we flag the root or `<body>` as having propagated `overflow`
to the viewport, we retrieve the `LayoutBoxBase`. Therefore, now we get
the computed style from the `LayoutBoxBase` in a single operation,
instead of first retrieving the style from the DOM element and then
getting the `LayoutBoxBase` from the box.
Testing: Adding more tests. We were only failing one of them, but it's
hard to test the fixes given that we don't show scrollbars. The tests
that were already passing are useful too, e.g. Firefox fails one of
them.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
The signal taken from the requestinit is now passed into
the request object with the relevant steps. I added all
spec comments to this method, as I had trouble figuring
out which steps I had to add.
This required implementing the algorithm to create
dependent signals, which is used in the `any()` method.
So that's now implemented as well.
All of that required the machinery to have dependent and
source signals on an AbortSignal. It uses an IndexSet
as the spec requires it to be an ordered set.
Part of #34866
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
The xpath resolver is a function provided by the user to resolve
namespace prefixes. Previously, we were ignoring the argument.
Testing: New web platform tests start to pass
Part of https://github.com/servo/servo/issues/34527
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
The WebCryptoAPI spec requires that when we generate crypto keys by the
generateKey method of SubtleCrypto interface we have to check whether
the usages is empty. If the usages is empty, throw a SyntaxError.
FYI, Step 9 of
https://w3c.github.io/webcrypto/#SubtleCrypto-method-generateKey
We have not yet implemented this logic, and this patch implements it.
Testing: Pass WPT tests that were expected to fail.
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This is currently unused, so it can be removed.
Testing: This just removes an unused field, so does not require tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
In Step 15, we are given the unwrapped key as bytes. If the format is
"jwk", we execute parse-a-JWK algorithm to parse it (and deserialize it
to a JsonWebKey dictionary).
In next step, we perform the import key operation on the unwrapped key.
In our current implementation, we serialize the JsonWebKey dictionary
(when format is "jwk") back to bytes, in order to perform the import key
operation.
In fact, this serialization step is redundant since we have already been
given the unwrapped key as bytes in Step 15. We can directly use it for
perform the import key operation. This patch remove this redundant step
of re-serializing the JsonWebKey dictionary.
Testing: Refactoring only. No change in tests.
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Creating elements by directly calling their interface constructors leads
to some state not being intialized correctly (see #39285). It is also
not in line with the specifications as many of them refer to the
[`create an element`][1] algorithm when an element needs to be created,
which directly maps to `Element::create` in the script crate.
So, switch all such places where elements are created by script to use
`Element::create`.
[1]: https://dom.spec.whatwg.org/#concept-create-element
Testing: Existing WPT tests.
Fixes: #39285
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Replace the `unwrap()` call with `log::error!()` in the
`send_request_to_devtools()` function to enhance error handling.
---
Before:
```
╰─❯ ./servo --devtools=1
[2025-09-15T14:35:07Z ERROR servoshell::desktop::app_state] Saw Servo error: DevtoolsFailedToStart!
called `Result::unwrap()` on an `Err` value: "SendError(..)" (thread tokio-runtime-5, at components/net/http_loader.rs:435)
[2025-09-15T14:35:07Z ERROR servoshell::panic_hook] called `Result::unwrap()` on an `Err` value: "SendError(..)"
```
After:
```
╰─❯ ./servo --devtools=1
[2025-09-16T01:24:59Z ERROR servoshell::desktop::app_state] Saw Servo error: DevtoolsFailedToStart!
[2025-09-16T01:24:59Z ERROR net::http_loader] DevTools send failed: sending on a disconnected channel
[2025-09-16T01:24:59Z ERROR net::http_loader] DevTools send failed: sending on a disconnected channel
...
```
Signed-off-by: Integral <integral@member.fsf.org>
This uses the ScriptThread::custom_element_reaction_stack to call the
enqueue_callback_reaction on the Rc instead of in the loop.
Potentially saving access to thread_local variables.
Testing: Should not change functionality and should be covered by wpt
tests.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Follow the specification and validate tokens of the "x/w/h" descriptors
before applying the rules for parsing float-pointing numbers or
non-negative integers.
https://html.spec.whatwg.org/multipage/#parsing-a-srcset-attribute (step
13)
Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Following the definition of `TouchEvent` in
https://w3c.github.io/touch-events/#list-of-touchevent-types, all
`TouchEvent` should have its `composed` flag set to be able to propagate
past a shadow root layer.
Part of #35997
Testing: Would require a testdriver.
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
Vello has updated to wgpu v26 recently. It might be a good time for
servo to update as well. This PR should wait for #39015 and #38717
Testing: WebGPU CTS
Fixes: None
---------
Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>
While trying to figure out what the status of this implementation was, I
added steps and comments to
see what we are missing. Also updated some links,
since I couldn't find an implementation of
`window.fetch`, since the spec URL was pointing
to the chapter instead of the algorithm.
Part of #34866
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Everything related to Trusted Types has been implemented. Failing WPT
tests are related to other features such as SVG scripts.
Fixes#36258
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
The min-content and max-content inline sizes of an inline formatting
contentext need to take `text-indent` into account. Note it can be set
to a negative amount, so the `ContentSizesComputation` logic needs some
tweaks to handle it well.
Testing: Fixes various WPT tests
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Also bumps mozjs to the latest version that has support for
`GStackVector` which is what this callback uses.
Part of #36258Fixes#38877
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Both places where we access signals_slots already have a reference to
ScriptMutationObserver. This saves us another access to
with_script_thread.
Testing: This does not change functionality.
Fixes: Part of addressing: https://github.com/servo/servo/issues/37969
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
There is a recent spec change which adds instant as default scroll
behaviour: https://github.com/w3c/webdriver/pull/1924. This PR reflects
the change.
Testing: No behaviour change as `ScrollBehavior` is ignored right now.
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
From IndexedDB spec, when we check whether a key path is valid, we have
to check whether it is an ECMAScript identifier name. We have not yet
implemented this logic, and always return true.
This patch uses the function `js::rust::wrappers::JS_IsIdentifier` to
achieve this checking.
Testing: Pass WPT tests that were expected to fail.
Fixes: #25324
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Previously, each ScriptThread was creating a new image cache with a
separate thread pool. These changes add an image cache to the
constellation and create new image caches by calling the
`create_new_image_cache` method. It reuses the original image cache's
thread pool and reduces the number of spawned threads in the
single-process mode.
Testing: Tested manually, using `ps -M` to see the number of spawned
threads with multiple tabs open in servoshell before and after these
changes.
Fixes: #37770
Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
Parsing the 'srcset' attribute of an image element may result in a parse
error
indicating a non-fatal mismatch between the input and the requirements.
https://html.spec.whatwg.org/multipage/#concept-microsyntax-parse-errorhttps://html.spec.whatwg.org/multipage/#parse-a-srcset-attribute
This error should not be a reason to stop parsing and may be used by the
user agent to signal a syntax error.
Other browsers generally ignore this error, and we do the same.
Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Implement scroll into view steps for all WebDriver command that requires
it (element click, element send keys, element clear, and take element
screenshot).
Testing: `element_send_keys/scroll_into_view.py`,
`element_click/scroll_into_view.py`, `element_clear/clear.py`
---------
Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
They only had the writing mode, now they will have the entire computed
style.
This is needed for #39230.
Testing: Not needed, no behavior change
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
`convert_value_to_key` returns a `ConversionResult` now, so keys can be
considered "Invalid" rather than throwing an exception.
Testing: WPT
Unblocks: #38288
---------
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
This combines some access to the thread local variable for script
thread.
- We introduce a new UserInteractingScriptGuard which on drop handles
the resetting of was_interacting to the previous value. Sometimes
throughout the code `ScriptThread::is_user_interacting` was reset to the
previous value while sometimes just set to false. This should
remove this footgun.
- This also reduces the amount of thread local access for
MutationObservers and task queue.
Testing: WPT tests should cover this.
Fixes: This addresses part of
https://github.com/servo/servo/issues/37969 but there is probably still
stuff to be done.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
In our current implementation, the `importKey` method and `unwrapKey`
method of `SubtleCrypto` interface unwrap JsonWebKey before running the
normalized algorithms. Therefore, all cryptography algorithms share the
same unwrapping mechanism. Our current unwrapping mechanism is not
compatible with some cryptography algorithms, which we have not yet
implemented such as Ed25519.
Following the WebCrypto API spec, this patch moves the JsonWebKey
unwrapping mechanism to normalized algorithms so that each cryptography
algorithm can unwrap JsonWebKey in its own way.
This does not introduce behavioral changes, but makes implementing the
unwrap operation for new cryptography algorithms easier in the future.
Remark: Step 8 and 13 of `SubtleCrypto::ImportKey` require the crypto
task source in the script task manager, but we don't have it yet. So,
they're marked as TODO.
Testing: Existing tests should suffice.
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Previously, the correct autoincremented and keypath parameters were only
being passed if the object store is being created. This PR queries this
info from the backend and passes it onto the constructor in
IDBTransaction. Furthermore it exposes keypath and index_names from
IDBObjectStore, mainly for WPT.
Testing: WPT
Fixes: None
---------
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
I added these comments while debugging `cors/request-headers.htm`.
Ultimately the bug turned out to be outside of servo, so we have to wait
for https://github.com/hyperium/headers/pull/219.
Since that PR might take a while to merge I'd like to add these on their
own.
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Uses the `zstd` support from `async-compression` to support zstd
Content-Encoding.
Testing: Covered by wpt tests.
Signed-off-by: webbeef <me@webbeef.org>
This should be the final PR for the Hash Function series that is
trivial.
Of note: I decided to transform `HashMapTracedValues<Atom,..>` to use
FxBuildHasher. This is likely not going to improve performance as Atom's
already have a unique u32 that is used as the Hash but it safes a few
bytes for the RandomState that is normally in the HashMap.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: Hash function changes should not change functionality, we
slightly decrease the size and unit tests still work.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>