Recently added WPT tests for this are now mostly passing. The remaining
tests fail on importmap support.
Part of #36258
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This change aligns Servo with both Blink and WebKit in common cases.
When the `aspect-ratio` property is set to a different value than the
natural ratio, then Blink and WebKit disagree, we match Blink.
Gecko doesn't support intrinsic min/max block sizes at all.
Note this patch doesn't fix the intrinsic contributions, they will need
to be addressed in a follow-up patch.
Testing: Covered by WPT
Fixes: #37433
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
There are currently five places that scroll offsets are stored:
- DOM: A set of scroll offsets used for script.
- Layout: An array of scroll offsets that is used for tracking
layout-side scroll offsets.
- Layout: The scroll offsets stored in the `ScrollTree`. These are
currently unset and unused.
- Compositor: The scroll offsets stored in the `ScrollTree` mirrored
from layout.
- WebRender: The scrolled offsets stored in the WebRender spatial tree.
This change is the first step in combining the first three into the
layout `ScrollTree`. It eliminates the extra array of scroll offsets
stored in layout in favor of the storing them in the `ScrollTree`. A
followup change will eliminate the ones stored in the DOM.
- In addition the `ScrollState` data structure is eliminated as these
are
now stored in a `HashMap` everywhere when passing them via IPC.
- The offsests stored in layout can now never scroll past the boundaries
of the scrolled content.
Testing: This should not change behavior and is thus covered by existing
WPT tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: stevennovaryo <steven.novaryo@gmail.com>
This patch adds support for showing source_content in `Debugger >
Source` panel. This works by handling the clients `source` messages in
the source actor. These source actors are already advertised as resource
via the watcher, populating the source list. We also update the
`sources` handler in thread actor for future work in thread debugging.
Note: while this PR also adds support for showing worker script
source_content, worker has been broken (See
https://github.com/servo/servo/issues/37012). I was able to confirm the
`content_type` and `source_content` for worker script in logs.

Fixes: part of https://github.com/servo/servo/issues/36027
---------
Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Refactor the box tree update logic to improve readability and facilitate
the addition of incremental update logic in the following PRs.
Testing: No logic changed, just covered by existing WPT tests
Fixes: Nothing to fix
Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
SwitchToParentFrame webdriver commands do not handle the case where the
current top-level browsing context has been closed.
Tests:
`./tests/wpt/tests/webdriver/tests/classic/switch_to_parent_frame/switch.py`
`./tests/wpt/tests/webdriver/tests/classic/switch_to_frame/switch.py`
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
The callback can be used instead, since `Size::resolve()` already takes
care of creating a `LazyCell`.
Testing: Unnecessary, no behavior change
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This change has two parts which depend on each other:
1. An early exit in the layout process, which allows for skipping
display list construction entirely when nothing would change.
2. A simplification and unification of the way that "fake" animation
frames are triggered. Now this happens on an entire ScriptThread at
once and is based on whether or not any Pipeline triggered a display
list update.
Animations are never canceled in the compositor when the Pipeline
isn't updating, instead the fake animation frame is triggered far
enough in the future that an unexpected compositor tick will cancel
it. This could happen, for instance, if some other Pipeline in some
other ScriptThread produced a new display list for a tick. This makes
everything simpler about these ticks.
The goal is that in a future change the ScriptThread-based animation
ticks will be made more generic so that they can throttle the number of
"update the rendering" calls triggered by script.
This should make Servo do a lot less work when moving the cursor over a
page. Before it would constantly produce new display lists.
Fixes: #17029.
Testing: This should not cause any web observable changes. The fact that
all WPT tests keep passing is the test for this change.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
The compositor was accepting scroll offsets from the ScriptThread
without checking their boundaries. In some cases this could cause a
temporary discrepancy with the rendered scroll offset. This change makes
it so that all offset updates for scroll ayers in the compositor do not
scroll past the scroll boundaries of the node.
Testing: Two new tests pass with this change:
- `/css/css-position/sticky/position-sticky-left-003.html`
- `/css/css-position/sticky/position-sticky-top-003.html`
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Implement `MicrotaskRunnable` for `DefaultTeeReadRequestMicrotask` to
run the microtask, instead of using its own ad-hoc mechanism via
`DefaultTeeReadRequestMicrotask::microtask_chunk_steps`.
Testing: No need for this refactoring.
Fixes: #37246
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Improve some session/window handling according to spec.
Testing:`./mach test-wpt -r --log-raw "D:\servo test log\all.txt"
.\tests\wpt\tests\webdriver\tests\classic\ --product servodriver`
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
*Replaces NetworkEventUpdateMsg with ResourcesUpdatedArray in
HttpResponse case of handle_network_event *
- Adds ResourcesUpdatedArray and UpdateEntry structs in
`devtools/network_handler.rs` to hold an array of updates
(requestHeaders, responseCookies). Updates handle_network_event to use
BrowsingContextActor::resource_available for sending
"resources-updated-array").
- Adds browsing_context_actor_name parameter to handle_network_event to
resolve borrow checker issues and enable BrowsingContextActor lookup.
- Ensures borrow safety by scoping mutable actor access.
Testing: *Does not require test*
Fixes: part of https://github.com/servo/servo/issues/33556
---------
Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
1. Tidy up some WebDriver handling with browsing context
2. Enable more wpt-test which no longer panic
Testing: `./mach test-wpt -r --log-raw "D:\servo test log\all.txt"
.\tests\wpt\tests\webdriver\tests\classic\ --product servodriver`
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This value was used when rendering was not done by WebRender. Nowadays,
we do not need this page clip rect concept and it is completely
unused.
Testing: This just remove dead code, so should be covered by existing
tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This is a minor cleanup that simplifies the construct of
`StackingContextTree`. The two arguments removed are derived from the
`FragmentTree` which is already passed as an argument.
Testing: This should not change behavior and is thus covered by existing
tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
The default of `enum-variant-name-threshold` is 3, so adding any new
variants will lead to the lint being triggered, reference:
[enum_variant_names](https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names).
This PR fix this potential clippy lint warning for facilitate the
addition of new variant in following PR about incremental box tree
update.
Testing: No logic changed, just covered by existing WPT tests
Fixes: None
Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
As titled. This is what
[spec](https://w3c.github.io/webdriver/#dfn-dispatch-actions-inner)
requires. The motivation is that the previous action might have changed
the browsing context.
Testing: `./mach test-wpt -r --log-raw "D:\servo test log\all.txt"
.\tests\wpt\tests\webdriver\tests\classic\ --product servodriver`
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Instead of receiving message in the compositor during a spin of the
Servo event loop, receive them in libservo and then send them to the
compositor. This is preparation for allowing libservo to wait for
messages without spinning the main application event loop. This is
useful for two situations:
1. Allowing a blocking shutdown mode, which can be used to ensure clean
shutdown, regardless of how the API is used.
2. Allowing unit tests to wait until message are received instead of
using a timer like they do now.
Testing: This should not change behavior and is thus covered by existing
tests.
Fixes: This is part of #37371.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Implement action synchronization for wheel event. Previously only done
for pointer here https://github.com/servo/servo/pull/36932.
Testing:
`tests/wpt/meta/webdriver/tests/classic/perform_actions/wheel.py`
---------
Signed-off-by: PotatoCP <kenzieradityatirtarahardja18@gmail.com>
Use own `ViewportDescription` to `clamp()` initial_scale.
If use `self` it will use current module `ViewportDescription`, which is
old one because new `ViewportDescription` is not set yet.
Testing: Tested Locally
Fixes: #37338
Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
I can't find any historical motivation for the use of UnsafeCell in the
implementation of WeakRangeVec from #8506. We can replace all the uses
of unsafe in this code by using RefCell, and the resulting code is
easier to understand.
Testing: Existing WPT tests using Ranges show no behaviour changes.
Fixes: #37276
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
For WebDriver, return "No Such Window" properly according to spec.
Testing: `./mach test-wpt -r --log-raw "D:\servo test log\all.txt"
.\tests\wpt\tests\webdriver\tests\classic\ --product servodriver`
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
- Add browsing_context_actor_name parameter to handle_network_event
- Replace NetworkEventMsg in HttpRequest case with
BrowsingContextActor::resource_available
- Update DevTools caller in lib.rs to pass browsing_context_actor_name
Testing:
Fixes:
https://github.com/servo/servo/issues/33556#issuecomment-2756544430
---------
Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
`PlacementAmongFloats` should guarantee that the inline size of the
placement rect is at least as big as the inline size of the box,
resulting in a non-negative free space.
However, that may fail when dealing with huge sizes that need to be
saturated to MAX_AU, so this floors the free space by zero.
Testing: New crashtest
Fixes: #37312
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
adding `resolve_url_like_module_specifier` method to `ModuleTree`.
Testing: Existing WPT test for script element should pass.
Fixes: https://github.com/servo/servo/issues/37316, resolving a URL-like
module specifier
Signed-off-by: Jason Tsai <git@pews.dev>
For Desktop port of `request_open_auxiliary_webview`, stay on the
original WebView if the request originates WebDriver.
This is to make sure `webdriver_server::handle_new_window` does not
focus the new window, according to spec. See
c7eba2dbba/tests/wpt/tests/webdriver/tests/classic/new_window/new_window.py (L31-L37)
**To clarify**: this won't change the behaviour when user interacts, but
only affects WebDriver [New
Window](https://w3c.github.io/webdriver/#new-window).
Testing: `./mach test-wpt -r --log-raw "D:/servo log/all.txt"
./tests/wpt/tests/webdriver/tests/classic --product servodriver` based
on 96b0973037
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This is pretty much just wiring up the necessary stylo methods. Note
that the `exportparts` attribute is not yet supported, I'll do that in a
followup change
Testing: Covered by existing web platform tests.
This is the first half of https://github.com/servo/servo/issues/35349
Fixes https://github.com/servo/servo/issues/37325
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
#37021 exposed that our tests are trying to load a local file path for
Ahem.ttf, but this stops working when we implement the specified CORS
protections for our font requests. Luckily, the WPT suite already
provides a same-origin version of the same font, so we can just update
our CSS to use that font face instead.
Testing: Existing WPT coverage.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Remove `embedder/webdriver.rs::WebDriverCookieError` and use universal
`ErrorStatus` from webdriver crate. This is needed as we might need to
send back more universal error such as `NoSuchWindow`.
Testing: No behaviour change.
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This change upgrades some dependencies that required some manual
intervention due to duplicate packages and breaking API changes. These
changes also allow us to upgrade to ipc-channel 0.20
(https://github.com/servo/ipc-channel/pull/390#discussion_r2070677101),
and allow us to upgrade other dependencies that have migrated to rand
0.9 while the ecosystem remains split.
Testing: Existing WPT tests.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This applies some fixes for CSS Grid percentage sizing. These fixes are
mostly within Taffy, but there are some changes in Servo to allow it to
communicate whether an item is replaced to Taffy.
It also updates Taffy to v0.8.0. Taffy has switched to a tagged pointer
representation of length/size styles. Much of the diff here is updating
Servo's type conversion code to use the new representation.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] There are tests for these changes OR
---------
Signed-off-by: Nico Burns <nico@nicoburns.com>
Implement Get Element Shadow Root
https://www.w3.org/TR/webdriver2/#dfn-get-element-shadow-root
cc: @xiaochengh, @yezhizhen, @PotatoCP
Testing:
`\tests\wpt\tests\webdriver\tests\classic\get_element_shadow_root\get.py`
is blocked by `no_browsing_context` and `closed_window`
pass for other sub-tests.
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
While working on #37209 I discovered that the header was computed
incorrectly. After carefully reading the specification, I realized that
the link in the spec was wrong and we were missing the fact that for
host-domains, we should operate on the registrable domain.
Additionally, the same-site call was missing the negation.
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Replaces uses of `euclid::default::Size2D<u64>` with
`euclid::default::Size2D<u32>` for the canvas/context/snapshot.
This PR includes changes to the following components:
- canvas
- pixels
- script
- script_bindings
- shared/canvas
- shared/snapshot
Testing: https://github.com/hashcatHitman/servo/actions/runs/15426115391
(as of 892edc0048)
Fixes: #36706
---------
Signed-off-by: hashcatHitman <155700084+hashcatHitman@users.noreply.github.com>
Add static method `Supports` to `HTMLScriptElement`.
Part of #37262
Testing: relative WPT tests should become `PASS`
Signed-off-by: Jason Tsai <git@pews.dev>
Even though we were continuing the parent BFC, we weren't updating the
SequentialLayoutState to have the correct containing block info. That
caused problem in the presence of floats.
This patch establishes an independent BFC, which avoids the problem.
This seems reasonable since outside markers are out-of-flow-ish, and it
matches Firefox. Blink implements them as inline-blocks, so they should
also establish a BFC.
Testing: Adding new tests. Some still fail because of a different issue.
Also, adding an expectation for several existing tests that were missing
it.
Fixes: #37222
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This reverts commit 5580704438.
Let's re-land that fix when a working solution is found. Keeping that
regression makes it hard to evaluate other potential improvements.
Signed-off-by: webbeef <me@webbeef.org>
The correct way to run Python when building Servo is `uv run python`,
unless we are running as a descendant of `uv run python`. In that case,
we can use either `uv run python` or `python` (uv does not provide a
`python3` on Windows \*).
\* for the astute reader, yes, this causes problems for mozjs, which
only tries `python3` unless PYTHON3=python :)))
Testing: tested manually on macOS 13 (see below), and will be tested in
CI
Fixes: #37289

Signed-off-by: Delan Azabani <dazabani@igalia.com>