Commit graph

10524 commits

Author SHA1 Message Date
Andrei Volykhin
644138c1da
canvas: Add HTMLVideoElement to CanvasImageSource union type (#37135)
Follow to the specification and add HTMLVideoElement to
CanvasImageSource union type
to allow use it as image source for createPattern/drawImage operations.
https://html.spec.whatwg.org/multipage/#canvasimagesource

https://html.spec.whatwg.org/multipage/#dom-context-2d-createpattern
https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage

The HTMLVideoElement media resource has an associated origin:
- media provider object (MediaStream/MediaSource/Blob): CORS-same-origin
 - URL record: CORS-cross-origin/CORS-same-origin

https://html.spec.whatwg.org/multipage/media.html#media-resource

Testing:
 - html/canvas/element/*
 - html/semantics/embedded-content/the-canvas-element/*

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-05-28 12:04:01 +00:00
Oriol Brufau
ac06b1cfcf
layout: Fix logic for transforms with non-invertible matrix (#37147)
When the the current transformation matrix of a box isn't invertible,
the box and its content shouldn't be displayed.

However, the logic was broken:
- It was only checking the `transform` property, but not individual
transform properties like `scale`.
- It was treating matrices with m₁₁=0 or m₂₂=0 and non-invertible, even
when they can still be invertible and have a visible outcome.
- When m₁₁=0 or m₂₂=0 weren't caused by `transform`, it was replacing
the matrix with the identity.

Testing: Adding new WPT
Fixes: #37146

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-05-27 18:36:33 +00:00
Mukilan Thiyagarajan
8a20e42de4
Add support for static SVG images using resvg crate (#36721)
This change adds support for rendering static SVG images using the
`resvg` crate, allowing svg sources in the `img` tag and in CSS
`background` and `content` properties. There are some limitations in
using resvg:

1. There is no support for animations or interactivity as these would
require implementing the full DOM layer of SVG specification.
2. Only system fonts can be used for text rendering. There is some
mechanism to provide a custom font resolver to usvg, but that is not
explored in this change.
3. resvg's handling of certain edge cases involving lack of explicit
`width` and `height` on the root svg element deviates from what the
specification expects from browsers. For example, resvg uses the values
in `viewBox` to derive the missing width or height dimension, but
without scaling that dimension to preserve the aspect ratio. It also
doesn't allow overriding this behavior.

Demo screenshot:
![servo - resvg
img](https://github.com/user-attachments/assets/8ecb2de2-ab7c-48e2-9f08-2d09d2cb8791)

<details>
<summary>Source</summary>

```
<style>
 #svg1 {
   border: 1px solid red;
 }

 #svg2 {
   border: 1px solid red;
   width: 300px;
 }
 #svg3 {
   border: 1px solid red;
   width: 300px;
   height: 200px;
   object-fit: contain;
 }
 #svg4 {
   border: 1px solid red;
   width: 300px;
   height: 200px;
   object-fit: cover;
 }
 #svg5 {
   border: 1px solid red;
   width: 300px;
   height: 200px;
   object-fit: fill;
 }
 #svg6 {
   border: 1px solid red;
   width: 300px;
   height: 200px;
   object-fit: none;
 }
</style>
</head>
<body>
        <div>
          <img id="svg1" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo">
        </div>
        <div>
          <img id="svg2" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo">
          <img id="svg3" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo">
          <img id="svg4" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo">
        </div>
        <div>
          <img id="svg5" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo">
          <img id="svg6" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo">
        </div>
</body>
```

</details>

---------

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-05-27 11:02:40 +00:00
Gregory Terzian
324196351e
script: stub AbortSignal (#37033)
This is a stub for `AbortSignal`, which we would like to merge first in
order to work in parallel on
https://github.com/servo/servo/issues/34866, and perhaps also
https://github.com/servo/servo/issues/36936

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
Co-authored-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-05-27 09:53:43 +00:00
Simon Wülker
41ecfb53a1
Rename Stylesheet::Type_ to Stylesheet::Type (#37126)
I'm not sure if `CodegenRust.py` was supposed to remove the underscore,
but we end up exposing `type_` to javascript which is obviously wrong.
There's no need to rename the method in the first place, because `Type`
(with a capital T) is not a rust keyword.

Testing: Covered by existing web platform tests

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-25 17:36:16 +00:00
Simon Wülker
2af1225e4f
Forward manager_number to NullBrowser constructor (#37125)
Testing: No tests, if `test-wpt` broke again then we would notice pretty
quickly.
Fixes: https://github.com/servo/servo/issues/37124

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-25 15:12:55 +00:00
Servo WPT Sync
0d44ca8ddc
Sync WPT with upstream (25-05-2025) (#37123)
Automated downstream sync of changes from upstream as of 25-05-2025
[no-wpt-sync]

Signed-off-by: WPT Sync Bot <ghbot+wpt-sync@servo.org>
2025-05-25 01:27:24 +00:00
Simon Wülker
2b840a4d9a
Don't set a prototype for unscopable objects (#37122)
Testing: Covered by existing web platform tests
Fixes: https://github.com/servo/servo/issues/25022

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-25 00:16:31 +00:00
Simon Wülker
4ae72ecb8e
Make unscopable objects writable and enumerable (#37119)
Testing: Covered by existing web platform tests
Fixes: https://github.com/servo/servo/issues/37118

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-24 16:02:08 +00:00
Simon Wülker
88fd2e43c8
Unconditionally enable the URLPattern API (#37116)
We fail only a couple of the URLPattern tests and I think that's mostly
due to bugs in the `urlpattern` crate.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-24 13:20:45 +00:00
Simon Wülker
7fd0c81f55
Implement URLPattern::{text, exec} (#37044)
With this change the URLPattern API is fully implemented. I'll look into
the remaining failures and then enable the preference by default.

Testing: Covered by web platform tests

Depends on https://github.com/servo/servo/pull/37042

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-24 11:12:11 +00:00
Ashwin Naren
0ed2c4816c
script: Add support for polygons in HtmlAreaElement::hit_test (#37064)
Uses raycasting to determine whether point is in polygon

Testing: Added unittest
Fixes: None to my knowledge

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-05-24 09:53:27 +00:00
Martin Robinson
57b99d641e
layout: Use the viewport size as the background-attachment: fixed positioning area (#37097)
This fixes the combination of `background-attachment: fixed` and
`no-repeat`. The positioning of the background should be relative to the
viewport, so using an infinite rectangle breaks things like `center`.

I'm not sure what the original motivation of using an infinite rectangle
here
and it doesn't seem to break any tests to stop using it.

Testing: This fixes `/css/CSS2/backgrounds/background-bg-pos-206.xht`.
Fixes #37082.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-05-24 09:45:53 +00:00
Oriol Brufau
d18000fee8
Add another incremental layout that starts at stacking tree construction (#37088)
This allows to skip rebuilding the box tree when it's only necessary to
rebuild the stacking context tree.
Bumps Stylo to https://github.com/servo/stylo/pull/187

Testing: Unneeded (no behavior change). Just improving performance.
However, this adds a new test for dynamic changes of `z-index`, which we
were breaking in an earlier iteration of this patch.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-05-23 23:40:02 +00:00
Andrei Volykhin
1f5087d773
imagebitmap: Make ImageBitmap serializable and transferable (#37101)
According to specification ImageBitmap objects are serializable objects
and transferable objects.

https://html.spec.whatwg.org/multipage/#the-imagebitmap-interface:imagebitmap-11

Testing:
 - html/canvas/element/manual/imagebitmap/*
 - html/infrastructure/safe-passing-of-structured-data/*
 - html/webappapis/structured-clone/*
 - workers/semantics/structured-clone/*

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-05-23 20:40:25 +00:00
Martin Robinson
cd36c35cf2
Enable all remaining disabled intermittent tests (#37094)
These were disabled long ago, but nowadays the intermittent filter can
ignore them when they flake. In addition, running them will allow us to
know if they are still intermittent or not since all intermittent
failures are tracked in GitHub via mentions on issues.

Testing: This is a change to test configuration.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-05-23 18:33:56 +00:00
TIN TUN AUNG
23ce7b31ac
Animation: update image active frame when update the rendering (#36286)
When no CSS animation exist, register timer for image animation, update
animated image active image frame as part of update_the_rendering, mark
node as dirty if the corresponding image need update. Added unit test to
test ImageAnimationState.

Part of https://github.com/servo/servo/issues/36057, the last step to
let the Animated Image "Move".

Testing: Introduced new WPT RefTest for animated image, but fail because
of https://github.com/servo/servo/issues/36931. New unit test for
`ImageAnimationState`.
Fixes: https://github.com/servo/servo/issues/22903
https://github.com/servo/servo/issues/36057

[Try](1472472966)

---------

Signed-off-by: rayguo17 <rayguo17@gmail.com>
2025-05-23 03:13:35 +00:00
Martin Robinson
7f0cebd442
layout: Support wavy and double for text-decoration-line (#37079)
- Add support for `text-decoration-line: double`: Line drawing is done
similar to how it works in Firefox and Chromium. A gap of half of line
thickness is added between each line.
- Fix support for `text-decoration-line: wavy`: Wavy lines rectangles
were not calcualted properly, which meant they were rendered as solid
lines. Now the amplitude of the wave is 1.5 times line thickness.

Testing: A manual test is updated `tests/html/text_deco_simple.html`
to cover more cases. In general, rendering of text-decorations is
difficult
to test via reftesting.
Fixes #17887.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-05-22 17:42:50 +00:00
Sebastian C
cdf5fdd2b4
script: Refactor dom/headers to match spec better (#36943)
This includes removing an implementation of normalize for `ByteString`,
because it is effectively duplicated in net under
`trim_http_whitespace`. This is part of an attempt to cleanup and
centralize code for header parsing and manipulation.

Testing: Covered by existing WPT tests

Signed-off-by: Sebastian C <sebsebmc@gmail.com>
2025-05-21 19:07:32 +00:00
Martin Robinson
9781f1241a
layout: Move text decoration propagation to stacking context tree construction (#37069)
Text decorations have a special kind of propagation. Instead of
propating these during box tree construction, move propagation to
stacking context tree construction. This will allow for using a very
easy type of incremental layout when text decorations change. For
instance, when a link changes color during hovering over it, we can skip
all of box and fragment tree construction.

In addition, propagation works a bit better now and color and style
properly move down from their originating `Fragment`s.

This introduces three new failures, because now we are drawing the
text-decoration with the correct color in more places, which exposes an
issue we have with text-decorations not being drawn in relation to the
baseline (taking into account `vertical-align`).

Testing: There are tests for these changes.
Fixes #31736.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-05-21 16:38:29 +00:00
Andrei Volykhin
859a0ffbd5
htmlmediaelement: Make dirty element on any intrinsic size changes (#37056)
To properly compute (the video) element's content size for
layout requires to dirty the element on any intrinstic size changes.

Full list of the operations which cause layout invalidation:
- media metadata update (NEW)
- removing "src" attribute
- video frame update
- show poster image

Testing:
html/semantics/embedded-content/the-video-element/intrinsic_sizes.htm
Fixes: https://github.com/servo/servo/issues/34434

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-05-21 11:18:24 +00:00
Oriol Brufau
3a527d784b
layout: Fix min-content inline size of multi-line row flex container (#37011)
`min_content_main_size_for_multiline_container` was initialized to an
outer size, but then it could be clamped by inner sizes.

This patch ensures that it's clamped by outer sizes, and refactors
`FlexItemBoxInlineContentSizesInfo`.

Testing: Covered by WPT
Fixes: #37008

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-05-21 06:57:50 +00:00
Taym Haddadi
5b2305784a
Stream implement pipeThrough (#36977)
Part of https://github.com/servo/servo/issues/34676

https://github.com/servo/servo/pull/36905 needs to be merged first.

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-05-20 14:33:22 +00:00
Vincent Ricard
6e97fc0bc4
Use spec compliant content-type extraction in more places and enable a <stylesheet> quirk (#28321)
This changes includes two semi-related things:

1. Fixes some specification compliance issues when parsing mime
   types and charsets for `XMLHttpRequest`.
2. Implements a `<stylesheet>` parsing quirk involving mime types.

Testing: There are tests for these changes.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-05-19 11:38:01 +00:00
Servo WPT Sync
070a8cf937
Sync WPT with upstream (18-05-2025) (#37040)
Automated downstream sync of changes from upstream as of 18-05-2025
[no-wpt-sync]

Signed-off-by: WPT Sync Bot <ghbot+wpt-sync@servo.org>
2025-05-18 01:43:27 +00:00
Tim van der Lippe
ed469fe72f
Propagate destination through load_data (#37020)
This way, we don't always set the destination to Document (which is as
the spec is written today). Instead, we set it it in the load_data,
depending on which context we load it from.

Doing so allows us to set the `Destination::IFrame` for navigations in
iframes, enabling all frame-related CSP checks.

While we currently block iframes when `frame-src` or `child-src` is set,
their respective tests don't pass yet. That's because we don't yet
handle the cases
where we fire the correct `load` event.

Also update one WPT test to correctly fail, rather than erroring. That's
because it was using the wrong JS test variable.

Part of #4577

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-05-17 08:22:11 +00:00
Josh Matthews
a028291466
Don't build testbinding-related code by default (#37034)
Disabling the TestBinding-related bindings and implementations saves 2mb
in a release build. Also, we lost the related test preferences when we
turned the layout-2020 tests on, so the tests have all been failing for
a long time.

Testing: Existing tests in CI.

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-05-17 08:14:19 +00:00
Oriol Brufau
78f3f455dc
layout: Fix align-content on stretched row flex containers (#37024)
Fixes a regression from #36973, which didn't take into account that
stretching flex items affects their final block size when the cross axis
is the block axis.

Testing: Adding new test
Fixes: #37023

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-05-16 19:15:16 +00:00
Simon Wülker
b100a98e1d
Fully support <input type=color> (#36992)
This change adds a shadow-tree widget for `<input type=color>` elements.
It also involves some changes to the way layout interacts with the DOM,
because currently all `input` and `textarea` elements are rendered as
plain text and their descendants are ignored. This obviously doesn't
work for `<input type={color, date, range, etc}>`.


![image](https://github.com/user-attachments/assets/4f16c3b0-1f79-4095-b19d-1153f5853dd5)

<details><summary>HTML used for the screenshot above</summary>

```html
<input type=color>
```

</details>



Testing: I doubt that this affects WPT tests, because the appearance and
behaviour of the widget is almost entirely unspecified.

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-15 17:30:38 +00:00
Oriol Brufau
cd0dbb9afb
layout: Obey intrinsic min/max block sizes on flex containers (#36973)
Intrinsic sizing keywords weren't working correctly on the min and max
block sizes of a flex container, because we weren't setting the
`CacheableLayoutResult::content_block_size` to the right value. This
also ensures that `align-content` aligns within the final size of the
container.

Note it's not very clear what to do for single-line containers, they are
being discussed in https://github.com/w3c/csswg-drafts/issues/12123

Testing: Adding new WPT tests. There are still some failures, but most
subtests would fail without this change.
Fixes: #36981

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-05-15 07:57:07 +00:00
Tim van der Lippe
a24fce3ae7
Implement inner slot for cryptographic nonce (#36965)
Also update the `html/dom/reflection-metadata.html` test
to handle the case where `nonce` does not reflect back
to the attribute after an IDL change.

Part of https://github.com/servo/servo/issues/4577
Fixes https://github.com/web-platform-tests/wpt/issues/43286

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-05-14 10:21:21 +00:00
Steven Novaryo
a572bf1191
layout: Propagate specified info for flex item (#36993)
We should propagate specified info for flex items. This will prevent the
loss of it for boxes that have this info (e.g. table or grid).

Testing: Adding new WPT tests

---------

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-05-13 21:10:40 +00:00
Tim van der Lippe
c985c08737
Implement iframe.srcdoc trusted type sink (#36960)
Part of https://github.com/servo/servo/issues/36258

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-05-13 21:07:13 +00:00
Andrei Volykhin
6468734aea
svg: Add mock SVGImageElement interface (#36975)
Add mock SVGImageElement interface to fix TIMEOUT WPT tests
which are related to ImageBitmap (html/canvas/*).
https://svgwg.org/svg2-draft/embedded.html#InterfaceSVGImageElement

Rationality of this change to fire event "error" on any attempt to fetch
image resource on href attribute change to not block WPT tests
execution.

Some WPT tests use the legacy namespace attribute "xlink:href", so
support for it was added to source code.
https://svgwg.org/svg2-draft/linking.html#XLinkHrefAttribute
 - setAttributeNS("http://www.w3.org/1999/xlink", 'xlink:href', src);

Testing: Covered by existed WPT tests
 - fetch/metadata/generated/svg-image*
 - html/canvas/element/manual/*
 - html/dom/idlharness.https.html
 - html/semantics/embedded-content/the-canvas-element/*
 - html/webappapis/scripting/events/event-handler-all-global-events.html
 - mozilla/interfaces.https.html

Fixes: https://github.com/servo/servo/issues/35881

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-05-13 10:43:10 +00:00
Taym Haddadi
62569979ff
Make transform stream transferrable (#36905)
Part of https://github.com/servo/servo/issues/34676

#36739 needs to be merged first.

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-05-12 16:02:06 +00:00
Tim van der Lippe
d780fb7695
Implement trusted HTML sinks for Element (#36941)
Also implements a conversion for `TrustedHTMLOrNullIsEmptyString`
to `TrustedHTMLOrString` to avoid introducing a separate
`get_trusted_script_compliant_string` for the new type.

Part of #36258

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-05-12 10:53:03 +00:00
Martin Robinson
a0dd2c1beb
layout: Share styles to inline box children via SharedInlineStyles (#36896)
`TextRun`s use their parent style to render. Previously, these styles
were cloned and stored directly in the box tree `TextRun` and resulting
`TextFragment`s. This presents a problem for incremental layout.
Wrapping the style in another layer of shared ownership and mutability
will allow updating all `TextFragment`s during repaint-only incremental
layout by simply updating the box tree styles of the original text
parents.

This adds a new set of borrows when accessing text styles, but also
makes it so that during box tree block construction
`InlineFormattingContext`s are created lazily and now
`InlineFormattingContextBuilder::finish` consumes the builder, making
the API make a bit more sense. This should also improve performance of
box tree block construction slightly.

Testing: This should not change 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>
2025-05-12 09:38:50 +00:00
Tim van der Lippe
b8fb985170
Fix integrity matching (#36963)
It was missing the ShA case in content-security-policy.

Part of #36437

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-05-11 17:10:09 +00:00
Simon Wülker
41283220dd
Update select shadow tree when contents of selected option change (#36958)
The label that is displayed inside a `<select>` element is that of the
selected option, or it's text contents if the option does not have a
label. Therefore, we need to update the `<select>` shadow tree when the
contents of the selected option change.

Testing: Covered by existing web platform tests
Fixes https://github.com/servo/servo/issues/36926
Fixes https://github.com/servo/servo/issues/36925

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-11 16:21:56 +00:00
Tim van der Lippe
fec6778eaa
Fix hash algorithm case-insensitiveness (#36962)
Part of #4577

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-05-11 15:59:43 +00:00
Tim van der Lippe
4821bc0ab0
Implement is-element-nonceable (#36961)
Unfortunately while it now passes almost all cases in
`tests/wpt/tests/content-security-policy/script-src/nonce-enforce-blocked.html`,
the test in question doesn't pass yet as it requires all cases to be
correct. Here, we still miss the "check for duplicate attributes during
parsing". Since we don't have this information available yet from the
parser, skip this for now.

Part of #36437

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-05-11 15:38:13 +00:00
Simon Wülker
dc0e7587bf
Don't attempt to resize Offscreencanvas without a rendering context (#36855)
When the canvas context mode is a placeholder then we shouldn't resize
the context.

Testing: Includes a new test
Fixes: https://github.com/servo/servo/issues/36846

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-11 15:27:33 +00:00
Servo WPT Sync
6cd44061d7
Sync WPT with upstream (11-05-2025) (#36954)
Automated downstream sync of changes from upstream as of 11-05-2025
[no-wpt-sync]

Signed-off-by: WPT Sync Bot <ghbot+wpt-sync@servo.org>
2025-05-11 01:41:53 +00:00
Keith Yeung
da1c49299b
Update the list of global and window event handlers (#36894)
There's an expanded list of event handlers content attributes that need
to be forwarded to the corresponding window of the body element, and
this PR adds the remaining ones. The full list can be seen in [this
link](https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers-on-elements%2C-document-objects%2C-and-window-objects%3Aevent-handlers-6).

Testing: Covered by various WPT tests

---------

Signed-off-by: Keith Yeung <kungfukeith11@gmail.com>
2025-05-10 15:54:13 +00:00
Tim van der Lippe
d0de4e64d2
Add CSP check for inline style attribute (#36923)
To be able to abort the update, extract the functionality into a
separate method. Otherwise, we don't run the `node.rev_version` at the
end, which according to the comment is probably important.

Not all `style-src` tests pass and I don't fully understand why yet, but
I presume it has to do with some special quirks of stylesheets that
other CSP checks don't have. All `style-src-attr-elem` tests pass
though.

Part of #4577

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-05-09 17:36:55 +00:00
Taym Haddadi
e5347eceac
WebIDL Fix ImageData constructor to take a Uint8ClampedArray instead of js_object (#31398)
<!-- Please describe your changes on the following line: -->

Fix ImageData constructor to take a Uint8ClampedArray instead of
js_object

---
<!-- 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] These changes fix #31320

<!-- Either: -->
- [x] These changes do not require tests because there is not behavior
change.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox
is checked, so that we can help you if you get stuck somewhere along the
way.-->

<!-- Pull requests that do not address these steps are welcome, but they
will require additional verification as part of the review process. -->

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-05-09 11:05:56 +00:00
Martin Robinson
53be79a5b5
layout: Resolve canvas background properties during painting (#36917)
Instead of resolving the canvas background properties (essentially
keeping a possible reference to the `<body>`'s style) during fragment
tree construction, wait until painting to possibly find the style on an
appropriate `<body>` fragment. This is possible now because `Fragment`
keeps a list of flags with relevant information about the root and
`<body>` elements.

A benefit of this approach is that styles aren't cached in the fragment
tree, which would be problematic for incremental layout. In addition,
the old code was making an effort to transform the `<body>`'s background
by the root element's transform. Only Safari does this and there was
a resolution the WG that this should not happen in
https://github.com/w3c/csswg-drafts/issues/6683.

Testing:
 - `/css/css-transforms/transform-translate-background-001.html`
 - `/css/css-transforms/transform-translate-background-002.html`
 - `/css/CSS2/floats/float-root.html`
 
Fixes: #30475.
Closes: #30569.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-05-09 10:36:53 +00:00
Euclid Ye
f58b0c6ad4
rework webdriver deserialization to avoid false-positive cycle error (#36908)
1. Avoid false-positive cycle error when deserilizing
 - Only detect cycle for Objects
  - Remove last element of seen when success
2. Cite spec

Testing: `./mach test-wpt --product servodriver -r
tests\wpt\tests\webdriver\tests\classic\element_click\events.py`
Fixes: #36890 
cc @jdm @xiaochengh

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-05-08 13:54:58 +00:00
Tim van der Lippe
b6b80d4f6f
Correct event_target for CSP violations (#36887)
All logic is implemented in `report_csp_violations` to avoid
pulling in various element-logic into SecurityManager.

Update the `icon-blocked.sub.html` WPT test to ensure that
the document is the correct target (verified in Firefox and Chrome).

Fixes #36806

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-05-08 10:46:31 +00:00
Taym Haddadi
f3f4cc5500
Script implement TransformStream and TransformStreamDefaultController (#36739)
Part of https://github.com/servo/servo/issues/34676

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
Signed-off-by: Taym <haddadi.taym@gmail.com>
Co-authored-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-05-08 08:45:57 +00:00