This stylesheet was being included both in quirks mode and in limited
quirks mode. It should only be the former.
Testing: adding new test.
Part of #37813
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This implementation is quite confusing as it makes it harder to tell
that we are just looking for the case that `Contents` contains
`NonReplacedContents`.
Testing: This shouldn't have any functional change, so is covered by
existing tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
While raqote does already passes this test, but small line is still
visible and this PR will fix this. Vello will not work correctly without
this.

Testing: `/html/canvas/element/path-objects/2d.path.arc.twopie.1.html`
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
1. Remove the unnecessary new thread which use GetWindowRect command and
blocks for 500ms. Previously this is necessary because constellation
forward "resize" to embedder, and WebDriver wait for a constant
sufficient time to `GetWindowRect` in the new thread. This caused long
delay because there are many subtests and SetWindowRect is called
between each.
2. Remove `resize_timeout`
3. Return current dimension instead of 0 from embedder when it fails to
resize.
4. Do resizing as long as one of width/height is `Some`, according to
spec.
Testing: All Conformance test with new passing cases.
Fixes: https://github.com/servo/servo/pull/37663#issuecomment-2999120615
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
1. Implement XPath Locator Strategy
2. Use it for "Find Element(s)", "Find Element(s) from Element", "Find
Element(s) from Shadow Root"
Testing: `tests\wpt\tests\webdriver\tests\classic\find_element*\find.py`
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This enables `background_hang_monitor` to work on Android. Relevant
Zulip thread: [#general > Android stack walking questions @
💬](https://servo.zulipchat.com/#narrow/channel/263398-general/topic/Android.20stack.20walking.20questions/near/526369883)
Testing: Manually tested on a Pixel 6a with Android 16 with following
page:
```html
<!DOCTYPE html>
<html>
<head>
<title>Infinite Loop Test</title>
</head>
<body>
Will it print? That is the question.
</body>
<script>
console.log("hello. you're about to loop infinitely.");
while (true) {
//do nothing, just block the thread
}
</script>
</html>
```
Fixes: #23136
---------
Signed-off-by: CarePackage17 <5157010+CarePackage17@users.noreply.github.com>
Set the placeholder canvas element of offscreenCanvas to a weak
reference in transferControlToOffscreen()
Testing: I do not understand how to test it, suggestions appreciated
Fixes: https://github.com/servo/servo/issues/35626
---------
Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
#37433 didn't handle intrinsic contributions. This patch computes the
correct SizeConstraint to be used as the ConstraintSpace's block size
when computing intrinsic inline sizes.
Testing: Adding new test
Fixes: #37478
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Add methods to retrieve the natural, default and fallback sizes per each
axis (inline or block), rather than computing both simultaneously.
Sometimes we only want one size, and I think it's clearer this way.
Testing: Unnecessary (no behavior change)
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
`FlexContainer::layout()` was forcing `depends_on_block_constraints` to
true for `flex-direction: column`. However, it doesn't make sense to do
that only for `column` but not for `column-reverse`. Also no test is
complaining, so I'm just removing that logic.
Testing: no behavior change is intended, so just existing test coverage
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Cloned nodes were re-parsing already-parsed style attributes. As such,
they were also checking CSP, which shouldn't happen as the original node
already was checked for it.
Testing: The existing WPT test now mostly passes. It had two cases which
were passing in no browsers.
Fixes: Part of #4577
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This PR moves canvas paint thread initialization to constellation. This
allows us to lazily initialize it on first create canvas request (like
we do for webgpu). If we didn't started canvas paint thread we also do
not need to wait for it's teardown.
Per https://chromestatus.com/metrics/webfeature/timeline/popularity/201
~30% of websites still use 2d canvas.
Testing: Existing WPT tests
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
The creation of `LayoutContext` does more work than necessary if layout
just needs to do something like make a display list and not restyle and
relayout. This change makes it so that these kind of non-restyle layouts
do not need to create a display list. In addition, the creation of
`LayoutContext` is better encapsulate
Testing: This should not change observable behavior and is thus covered
by existing WPT tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
- Move some of the image handling code to a separate function.
- Move reflow event debugging into layout itself and use the `Debug`
implementation to print the event.
- A few other small cleanups
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: Oriol Brufau <obrufau@igalia.com>
This PR removes `unwind-sys` usage from background_hang_monitor on
Linux, replacing it with the [backtrace
crate](https://crates.io/crates/backtrace).
Testing: `hang_monitor-tests.rs` still pass after the change (on Ubuntu
24.04).
Fixes: https://github.com/servo/servo/issues/35063
---------
Signed-off-by: CarePackage17 <5157010+CarePackage17@users.noreply.github.com>
All "Find Element ..." in
[spec](https://w3c.github.io/webdriver/#find-element-from-element) has
exactly same step has "Find Elements ...", except they extract the first
element if there is any. We now reuse the handler instead of running
numerous repetitive steps, same as what we did for ["Find Element from
Shadow
Root"](https://w3c.github.io/webdriver/#find-element-from-shadow-root)
in #37578.
This reduces binary size by 98KB for Release profile in Windows and
improves maintainability.
Testing: `./mach test-wpt -r
.\tests\wpt\tests\webdriver\tests\classic\find_element* --product
servodriver`
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This reduces the amount of work necessary when running layout, by making
restyle information optional in the `ReflowRequest`. When restyling
isn't
necessary, the option is `None`.
Testing: This shouldn't change any observable behavior and thus is
covered
by existing WPT tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
When parsing a html fragment, the initial parser state depends on
whether or not scripting is enabled. So far we've used the scripting
flag of the parser, but that is wrong - the parser's scripting flag is
always false, because the fragment document has no browsing context.
Instead we should use the scripting flag of the context element.
Testing: A new web platform test passes
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Before we only offered helper to add single image (no update or delete)
that got special IPC message, now we simplify this by offering all ops
helpers for dealing with single image (that happens most of the time),
that simply uses `update_images` under the hood. We also optimize for
this use case by using `SmallVec<[ImageUpdate; 1]>` to avoid alloc.
Testing: Just refactor, but code is covered by WPT tests
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Follow the HTML canvas specification and add missing
'setTransform(transform)' method to CanvasPattern interface.
https://html.spec.whatwg.org/multipage/#dom-canvaspattern-settransform
Testing: Improvements in the tests
- html/canvas/element/fill-and-stroke-styles/2d.pattern.transform*
- html/canvas/offscreen/fill-and-stroke-styles/2d.pattern.transform*
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
This will allow Servo to add custom types of damage in the near future
which correspond to minor phases layout. The damage exposed by Stylo
only corresponds to the major layout phses. In the future, both phases
will likely be managed by Servo itself and implementors will need to
provide their own damage system entirely.
Testing: This shouldn't change behavior and thus is covered by existing
tests.
Stylo PR: https://github.com/servo/stylo/pull/207
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
- Make feature flag of smallvec global.
- Removed unused dependency of thinvec.
- Removed unused flag of hyper-util.
Reduces the binary size by an astonishing 3.352k.
Testing: Compilation 'tests' this change.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
webgpu currently sends updates WebRender directly via WebRender API
(same as webgl that I also plan to reform). 2D canvas uses Compositor
API for that and with this PR so does webgpu. This will be helpful for
#35733, where compositor must know state of image updates.
Testing: WebGPU CTS run:
https://github.com/sagudev/servo/actions/runs/15895299748
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This is a legacy message used only by WebDriver to focus the webview,
when session just created. Right now this is just dead_code which is not
detected by Lint.
Testing: No behaviour change.
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This is used to capture information about what layout phases are
necessary for a given `ReflowGoal`. It's moved closer to where these
decisions are made and it should be easier to understand what the values
mean. They had gotten a bit out of sync with how queries and layout were
implemented.
Testing: This shouldn't change observable behavior and thus should be
covered
by existing WPT tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Like in #37713, instead of updating images directly with webrender api
we use the compositor api. We still keep webrender api available in
webgl, because that's where we do shutdown, due to GL.
Testing: Existing WPT tests
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Instead of doing a restyle whenever layout is requested, only do one if
script believes that the `Document` has changed in a way that needs a
restyle. In addition, track the different reasons this might be the
case. This will be used later to provide better debugging output.
In layout, when a restyle isn't requested, provide:
- an early return if layout is up-to-date enough for the reflow goal.
- skipping restyle and reflow if it isn't necessary.
Testing: This should not change observable behavior, and thus is covered
by existing tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
1. Separate the handling of ["switch to parent
frame"](https://w3c.github.io/webdriver/#switch-to-parent-frame) from
the rest as the processing is a bit different
2. Implement "Select frame by 16-bits numbered ID" for ["switch to
frame"](https://w3c.github.io/webdriver/#switch-to-frame)
3. Implement other missing steps
Testing: All WebDriver Conformance test with new passing cases
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
- Add a `resource_id` field to `EventActor` and `NetworkEventActor`
- Store a `next_resource_id` field in DevtoolsInstance
- Add `resource_id` parameter to `NetworkEventActor::new`
- Increment `next_resource_id` when
`DevtoolsInstance::find_network_event_actor` is called so each network
event has a unique id
Testing: Ran servo in devtools mode and can see the data showing in
`status`,`type`, `transferred` ,`size` and `timeline` columns of each
request, also logged the devtools instance and can see unique
`resourceId` for each request.
Fixes: https://github.com/servo/servo/issues/37661
Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
The parts of step 22 were a bit scattered throughout the codebase, so
this
change moves them all to a single method which does three things:
1. Update all animating images
2. Flush all dirty canvases (2D, WebGL, and WebGPU)
3. Calls reflow on the `Document`
Testing: This shouldn't change behavior in any major way so it should
be covered by existing WPT tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
- Remove request/response fields in `NetworkEventActor` which now stores
minimal request metadata needed : `URL`, `method`, `timestamps`, `raw
headers`, `body`.
- Refactor add_request and add_response: `add_request` takes the
incoming DevtoolsHttpRequest and populates
`request_url`, `request_method`, `request_started`,
`request_time_stamp`, `request_body`, `request_headers_raw`
`request_cookies`, `request_headers`,`total_time` and `event_timing`
(via a new helper that computes Timings)
While `add_response` takes the incoming DevtoolsHttpResponse and
populates `response_headers_raw`, `response_body` ,`response_cookies`,
`response_headers`, `response_start`, `response_content`
- Add a call to `resources_updated` to push initial request info in
`handle_network_event`
Testing: Run and logged servo in devtools mode and now, the request
header info isavailable as soon as the request gets initiated
Fixes: https://github.com/servo/servo/issues/37566
---------
Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
I updated webidl, and all changes that bring, currently we still not
support float16array (there is no support in FF either). Most notable
change is refactored new_*/Constructors methods, that should now handle
HeapBufferSource more properly (with less unsafe).
Testing: Existing WPT tests
try run: https://github.com/sagudev/servo/actions/runs/15806083404Fixes: #37618 (although not tested)
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Follow the HTML canvas specification and add missing
'setTransform(transform)' method to CanvasTransform interface.
https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform-matrix
The third-party WebIDL doesn't support different extended attributes
on different overloads of methods, so 'Throws' attribute was added
to another 'setTransform(...)' method.
https://bugzilla.mozilla.org/show_bug.cgi?id=1020975
Testing: Improvements in the tests
- css/geometry/DOMMatrix*
-
html/canvas/element/transformations/2d.transformation.setTransform.multiple.html
-
html/canvas/offscreen/transformations/2d.transformation.setTransform.multiple
New failing tests due to disabled 'paint worklet' feature
- css/css-paint-api/setTransform-00*.https.html
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Removes a GC cleanup step on exit pipeline that took half a second at
the end
of the Speedmometer benchmark. As layout and script are now run serially
this
does not seem to be needed anymore. See also the very short discussion
on Zulip:
[#performance > GC in
handle_exit_pipeline](https://servo.zulipchat.com/#narrow/channel/416779-performance/topic/GC.20in.20handle_exit_pipeline/with/525697861).
Testing: Tested with Speedometer and the WPT tests should still work.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This change fixes an issue and makes a few more minor improvements to
the `ImageAnimationState`:
1. Image rooting and unrooted now happens in one step from
`Window::update_animations_post_reflow`.
2. The `node_to_animating_image_map` is now stored as a shared `RwLock`
so that it doesn't need to be taken and then replaced in the
`ImageAnimationState` during reflow. This should prevent a hypothetical
issue
where image animations are restarted during empty reflows.
3. General naming and idiomatic Rust usage improvements.
Testing: This doesn't really have any obvious behavioral changes,
because all
reflows currently trigger a restyle. It becomes a serious problem with
#37677
and this change fixes the failing test there.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
- Move webdriver `GetViewportSize`, `LoadURL` and `Refresh` to
servoshell.
- Add `GoBack` and `GoFoward` commands.
Testing: Need to finish moving webdriver to servoshell then evaluate
again
Fixes: https://github.com/servo/servo/issues/37370
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
- Instead of eagerly computing `pageX` and `pageY`, collect the offset
from the content's initial containing block in the compositor and pass
that information through to `MouseEvent`. This prevents a layout flush
that was happening when eagerly trying to fetch `Document` scroll
offsets.
- Pass keyboard modifiers properly to `MouseEvent`.
- Now all this information is stored and passed as `Point2D` (typed) and
`Modifiers` which greatly reduces the amount of arguments that need to
be passed around.
Testing: It is difficult to test input events as they require WebDriver
which
isn't completely working yet. I have manually run Speedometer 2.1 and I
have
verified that this fixes the regression from #37601.
Fixes: #37601.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
With Rust 1.85 it is possible to const initialize Hashmaps if the hash
algorithm does not rely on a random seed.
Testing: No functional changes, covered by existing tests
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
cd30b78 improved the memory efficiency of write_json_to_file, but this
causes visible (when profiling) perf regression on my mac, which can
easily be fixed by wrapping the file in a `BufWriter`. This still bounds
peak memory usage, but keeps writing efficient.
Testing: Manual profiling with samply.
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
The 'none' image orientation option was temporarily deprecated (in 2022)
according to HTML specification with the remark about going to be reused
with
a different meaning in future as the same semantics as CSS 'none'
image-orientation.
https://html.spec.whatwg.org/multipage/#dom-imagebitmapoptions-imageorientation-nonehttps://www.w3.org/TR/css-images-3/#valdef-image-orientation-none
Official MDN documentation added it back with new meaning (in 2024),
but it wasn't added back to HTML specification (still pending).
https://developer.mozilla.org/en-US/docs/Web/API/Window/createImageBitmap#none
At current moment this option is poor supported on all major browsers,
but there are some
existed WPT tests (ImageBitmap/WebGL) which are actively use it in
createImageBitmap() options.
Chromium (supported):
- stable: same as 'from-image' (but with deprecation warning)
- experimental: ignoring any orientation metadata
Firefox (supported as default option):
- stable: ignoring any orientation metadata ('from-image' do the same)
Testing: Improvements and fails (expects 'from-image' behaviour from
'none' option) in the following tests
-
html/canvas/element/manual/imagebitmap/createImageBitmap-exif-orientation_none.html
- webgl/tests/conformance/textures/misc/exif-orientation.html
Fixes (partialy): #34112
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
These maps are keyed on pointers, so using FnvHashMap should be faster
and we don't need the collision resistance properties of the default
hasher.
These maps showed up as hot when profiling the testcase from
https://github.com/servo/servo/issues/37223#issuecomment-3000705438.
Switching the hashing algorithm reduces the time spent hashing, but
overall that is still only a fractional part of the testcase.
Testing: Functionality unchanged. Overall the performance change is to
small to show up in any of our automated performance tests. When
comparing the perf profile of the above linked testcase, one should see
a reduction of time spent hashing (inverse call stack)
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Allows indexeddb backends to return errors on certain operations.
Currently the errors are not demarcated, as the result type is
`Result<(), ()>`. If this is not appropriate then perhaps having a
string error might be better.
Testing: Some tests might perhaps move from PANIC to FAIL
Fixes: Partially fixes a bit of #37647, more work needs to be done
however
---------
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This causes wrong rendering on vello. Current backends already handle
one dim zero correctly by themself (this was probably needed for azure),
but if we ever needed this, it should be implemented inside faulty
backend.
Testing: Existing WPT tests
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This makes it easier to add variants, I also added some spec links and
reordered enum variants to match the spec.
Testing: Just refactor, but the code is covered by WPT tests.
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Follow the WebGL specification and ignore the values of UNPACK_FLIP_Y,
UNPACK_PREMULTIPLY_ALPHA, and UNPACK_COLORSPACE_CONVERSION
if the TexImageSource is an ImageBitmap.
https://registry.khronos.org/webgl/specs/latest/1.0/#6.10
Testing: There are no dedicated test results changes without the PR
#37634
which unblocks new testing scenarios with premultiplied ImageBitmap from
Blob/Canvas/Image sources.
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>