Commit graph

28475 commits

Author SHA1 Message Date
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
Ashwin Naren
1d9204b4b1
Return the proper texture format for GetPreferredCanvasFormat (#37073)
This follows firefox's implementation:
24d49101ce/dom/webgpu/Instance.h (L68)

It changes the default on most systems to `Bgra8Unorm` but leaves it as
`Rgba8Unorm` on android.

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-05-21 20:07:00 +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
Ashwin Naren
cebb1619ae
chore: fix warnings for Windows-specific fonts code (#37063)
Fix warnings from `components/fonts/platform/windows/font.rs` and
`components/fonts/platform/windows/font_list.rs` due to deprecations
from dwrote.

Testing: none, should behave as it did before

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-05-21 16:30:43 +00:00
Martin Robinson
856ffa6ecb
layout: When there is no restyle damage, do not re-layout (#37048)
When the computed restyle damage is empty, do not do a layout. Instead,
just rebuild the display list. In the future, even that can be omitted,
but that requires changes to the compositor.

These kind of relayouts commonly happen when the cursor is moving around
the page and no style rules cause changes to :hover.

Testing: This is covered existing WPT tests and should only have
performance
impacts. Unfortunately there are currently no performance tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-05-21 15:52:11 +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
batu_hoang
f52fa9b672
Synchronize dispatch_actions in WebDriver (#36932)
Implement missing synchronization in `dispatch_actions` of `WebDriver`.
https://w3c.github.io/webdriver/#dispatching-actions

> The user agent event loop has spun enough times to process the DOM
events generated by the last invocation of the >[dispatch tick
actions](https://w3c.github.io/webdriver/#dfn-dispatch-tick-actions)
steps.

- Add a way for `ScriptThread` to notify `WebDriver` about the
completion of input commands.
- Add a `webdriver_id` field for `InputEvent`. `ScriptThread` uses it to
distinguish WebDriver events and sends notification.

Tests:
`./mach test-wpt --product servodriver -r
tests\wpt\tests\webdriver\tests\classic\element_click\events.py` pass if
`hit_testing` pass. Check
[issue](https://github.com/servo/servo/issues/36676#issuecomment-2882917136)

cc: @xiaochengh

---------

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-05-21 11:03:04 +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
Simon Wülker
384d8f1ff8
Coalesce animated image frame data into a single shared memory region (#37058)
This makes servo use less file descriptors for animated images and
avoids the crash described in
https://github.com/servo/servo/issues/36792.

Doing this also forces the end users to be more explicit about whether
they want to deal with all image frames or just the first one.
Previously, `Image::bytes` silently returned only the data for the first
frame. With this change there's now a `frames` method which returns an
iterator over all frames in the image.

Testing: No tests - this simply reduces the number of fds used. Servo
doesn't currently display animated gifs anyways.
Fixes: https://github.com/servo/servo/issues/36792

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-20 20:40:46 +00:00
Josh Matthews
603ae44bcd
net: Measure memory usage of storage thread. (#37053)
Our persistent localstorage data can be meaningfully large after testing
real world sites. This change ensures it shows up in about:memory.

Testing: Opened about:memory after launching the browser with a
persistent config
Fixes: Part of #11559

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-05-20 14:50:02 +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
Martin Robinson
d8294fa423
layout: Split stacking context and display list construction (#37047)
Previously, after a layout was finished (or skipped in the case of
repaint-only layout), both the stacking context tree and display list
were built. In the case of repaint-only layout, we should be able to
skip the reconstruction of the stacking context tree and only do display
list building.

This change does that, also generally cleaning and up and clarifying the
data structure used during this phase of layout. This opens up the
possibility of a new kind of incremental layout that does both repaint
and a rebuild of the stacking context tree.

On the blaster.html test case[^1], this reduces tightly-measured layout
time from ~45-50 milliseconds to ~25-30 milliseconds on my M3.

[^1]: https://gist.github.com/mrobinson/44ec87d028c0198917a7715a06dd98a0

Testing: There are currently no performance tests for layout. :( This
should
not modify the results of WPT tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-05-20 13:42:39 +00:00
Sebastian C
27c8a899ea
Replace hsts preload list hashmap with an FST (#37015)
This reduces the memory used by the preload list to just 1.9MB. The
total memory savings in HSTS from
pre-103cbed928
is now 62MB, or 96%. And in terms of total resident memory is a 7.5%
reduction. The DAFSA/DAWG used by Firefox is 1.1MB so there could be
additional gains available but this seems like the best option based on
maintained libraries available (I could not find a good maintained
library for DAFSAs in Rust).

The main trick is this: the FST map API is currently designed to map
byte sequences to u64 values. Because we only need to determine if a
preloaded domain has the `includeSubdomains` flag set, we encode that
into the lowest bit of the ids in the map. This way finding an entry in
the map directly provides us with the `includeSubdomains` flag and we
don't need to keep another mapping in memory or on disk.

Updated the `./mach update-hsts-preload` command to generate the new FST
map file. (Not sure if I need to update any dev-dependencies anywhere
for this change)

This change also replaces the use of "mozilla.org" with "example.com" in
the HSTS unit tests to make sure that entries in the preload list do not
influence the tests (since example.com should not ever end up on the
preload list)

Testing: Updated unit tests
Fixes: #25929

---------

Signed-off-by: Sebastian C <sebsebmc@gmail.com>
2025-05-20 04:26:55 +00:00
Sebastian C
e7432cda09
Add memory reporting for public suffix list (#37049)
Plumbs in the memory reporting into resource_thread since that's where
the other user of the public suffix list (HSTS) reports.

Testing: Checked about:memory on servo.org

Signed-off-by: Sebastian C <sebsebmc@gmail.com>
2025-05-19 18:50:22 +00:00
Kousuke Takaki
ec448b1423
script: Make Blob.ArrayBuffer() more specification-compliant (#35748)
I have modified the Blob.ArrayBuffer implementation to comply with the
specification part of #25209.
See also: #35151.

Testing: This does not seem to affect tested behavior, so no new tests.

Signed-off-by: yoseio <98276492+yoseio@users.noreply.github.com>
2025-05-19 11:55:06 +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
Martin Robinson
573663d502
layout: Correct damage propagation and style repair for repaint-only layout (#37004)
When making last-minute changes to the repaint-only layout pass, damage
propagation was broken, meaning that full layout was always done. This
change fixes that, meaning that times in the `blaster.html` test case
now reflect those described in the original commit message from #36978.

In addition, some style repair is now fixed:
- `InlineFormattingContext`s now keep a `SharedInlineStyles` for the
root of the IFC
    which is updated during style repair.
 - `BlockFormattingContext`s now properly update their style.

These changes are verified by turning on repaint only layout for more
properties
in Stylo via servo/stylo#183.

Testing: Manual performance testing via `blaster.html`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-05-19 10:17:49 +00:00
Euclid Ye
7ac302f255
Fix WebDriverSession::input_cancel_list related logic (#37010)
- Remove incorrect addition to `input_cancel_list` in
`dispatch_keyup_action`
- For `KeyDown` and `PointerDown`, delay the addition to
`input_cancel_list` until "Dispatching action algorithm" is done to
match the spec. Previously the addition is done before notifying
constellation. Moreover, this makes sure that `pointerUp` is appended
even if `dispatch_pointerdown_action` returns early, so that [Release
Actions](https://w3c.github.io/webdriver/#release-actions) always have
the correct order.
- Remove incorrect addition to `input_cancel_list` in
`dispatch_pointerup_action`. This wrongly added "pointerdown" in
[Release Actions](https://w3c.github.io/webdriver/#release-actions)
- Reduce code duplication
- Add TODO for PointerInputState::subtype and pointerID

Testing: `./mach test-wpt -r --log-raw "D:\servo test
log\perform-actions.txt"
tests\wpt\tests\webdriver\tests\classic\perform_actions --product
servodriver` has no new failures so no regression. There are a lot more
passing tests, but I think mostly are because there is no CI for
webdriver.

cc @xiaochengh @jdm @PotatoCP @longvatrong111

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-05-19 08:34:04 +00:00
Simon Wülker
e2424fcec7
Remove the dom_shadowdom_enabled preference (#37043)
The preference was enabled by default in early march 2025, but was kept
around in case something major breaks
(https://github.com/servo/servo/pull/35899#discussion_r1988222297).

In the time since, no major bugs have been reported:
* https://github.com/servo/servo/issues/36722 is a bug in the UA shadow
tree, not the shadow dom itself. It's also independent of the
preference.
* https://github.com/servo/servo/issues/36273 looks like it *might* be
related to the shadow DOM, but it also requires experimental features so
it might be caused by something else entirely.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-18 17:42:21 +00:00
Kingsley Yung
1271dbf6ec
Remove ref_filter_map dependency (#36857)
Instead, use the `filter_map` functions of `std::cell::Ref` and
`accountable_refcell::Ref`, which provide the same functionality as
`ref_filter_map`.

Testing: Refactoring for removing dependency. No extra test is needed.
Fixes: #36851

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-05-18 14:00:58 +00:00
Simon Wülker
edea2caec1
Make getAllTypes unwrap IDL record<K, V> types (#37039)
IDL `record` types can themselves contain types that are not described
anywhere else. An example is in
https://github.com/servo/servo/issues/37038, where the `record` contains
a definition of a union. These inner types must be returned from
`getAllTypes`, otherwise we won't generate code for them.

This PR also adds a few type annotations. I can remove them if
requested, but I think they're helpful.

Testing:  Includes a regression test
Fixes: https://github.com/servo/servo/issues/37038

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-18 09:30:20 +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
Martin Robinson
c1a70f4eb2
compositor: Batch all pending scroll event updates into a single transaction (#36974)
When multiple WebViews are updating scroll events, instead of taking the
list of `WebView`s to avoid a double-borrow, batch scroll events into a
single transaction. This should make processing slightly more efficient
and avoids having to take the vector of WebViews.

Testing: No behavior change here and this aspect of WebView interaction
is untestable currently.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-05-16 18:26:59 +00:00
Martin Robinson
639eb7bc55
fonts: Fix calculation of font underline thickness on macOS (#37029)
There was a typo in how underline thickness (in pixels) was converted
to app units. It was interpreting the pixel value as an f64 app unit
value, which meant that the resulting thickness was 1/60 of the value
expected.

Testing: macOS does not currently run WPT tests, so it is difficult to
test
this one. I have manually confirmed that underlines now show up and are
the
expected thickness.
Fixes: #36945

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-05-16 18:23:02 +00:00
Simon Wülker
33a68eb2d5
Remove CoreResourceMsg::Synchronize (#37019)
This message is unused.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-15 20:20:55 +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
Simon Wülker
f9382fcaa0
Remove layout-2013 profiling categories (#37014)
This change also removes the ProfilingCategory::variant_name function,
because strum_macros::IntoStaticStr is already being used and does the
same thing.

Testing: This change compiles and that's good enough

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-05-15 16:54:02 +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
Sebastian C
103cbed928
HSTS list memory reduction and fixes (#37000)
Combines the 2 time values in the HSTS entry with a single timestamp for
expiration. (9MB savings per list)

The previous time representations were based on system boot time which
meant that the `hsts_list.json` round trip across boots resulted in
completely erroneous expiration times.

The preload list is now initialized separately from the public and
private lists and shared by both, cutting memory use in half.

Overall takes memory use from 64MB for HSTS to 24MB.

Expired HSTS entries are now removed from the list when updating an
entry and subdomains can be added to a list if the superdomain does not
already include them.

Testing: New unit tests added
Related to #25929 but the next step would be to attempt to use
https://github.com/BurntSushi/fst Which will be explored in a follow-up.

---------

Signed-off-by: Sebastian C <sebsebmc@gmail.com>
2025-05-15 04:06:57 +00:00
Oriol Brufau
1cceb5f6a0
layout: Inform child layout about final block size (#36980)
Before this patch it wasn't possibly to simultaneously support intrinsic
min/max sizes and content alignment in the block axis. For example,
block containers only support the former, and flex containers only the
latter.

The reason is that the final block size was decided by the parent
formatting context *after* performing layout, while content alignment is
performed *during* layout.

To address the problem, this introduces the struct `LazySize`, which
contains the data to resolve the final size, except for the intrinsic
size. Thus the parent formatting context can first create a `LazySize`,
then pass it to the child layout so that (if necessary) it can compute
the final size once the intrinsic one is known, and after layout the
parent formatting context uses it to actually size the child.

This PR just provides the functionality that will be used by follow-ups,
but at this point no layout is using the `LazySize` provided by the
parent, so there shouldn't be any behavior change yet.

Testing: Unnecessary (no behavior change)
This is part of #36981 and #36982

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-05-14 20:35:49 +00:00
Oriol Brufau
1499e2a874
Remove some references to layout 2013 vs layout 2020 (#37007)
We no longer have both layout systems.

Testing: not needed (no behavior change)

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-05-14 19:53:48 +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
webbeef
3aff272e14
chore: update webdriver to 0.53 (#37001)
Updates webdriver to the current version.

Testing: No breakage of CI tests

Signed-off-by: webbeef <me@webbeef.org>
2025-05-14 08:22:40 +00:00
sagudev
fdb9c0af12
canvas: Move generic implementations into GenericPathBuilder trait (#36999)
There is no reason to require this impls, because we already have
written them in generic way.

Testing: Just refactoring, but there are WPT tests

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-05-14 03:51:56 +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
Narfinger
991be359a3
libservo: Allow embedders to execute JavaScript scripts via the API (#35720)
This change adds a new `WebView` API `evaluate_javascript()`, which
allows embedders to
execute JavaScript code and wait for a reply asynchronously. Ongoing
script execution is
tracked by a libservo `JavaScriptEvaluator` struct, which maps an id to
the callback passed
to the `evaluate_javascript()` method. The id is used to track the
script and its execution
through the other parts of Servo.

Testing: This changes includes `WebView` unit tests.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-05-13 12:54:18 +00:00
Kenzie Raditya Tirtarahardja
91c4c7b998
Fix origin relative coordinate for wheel scroll and refactoring (#36985)
- Wheel scroll action can get coordinates relative to an element origin
([previously](https://github.com/servo/servo/pull/36744) only
implemented for viewport).
- Extract the element coordinate into a function

Testing: Partially
`tests/wpt/tests/infrastructure/testdriver/actions/wheelScroll.html`,
but we still have synchronization problem. You can try to add sleep in
the test to see OK result.

cc: @xiaochengh @longvatrong111 @yezhizhen

Signed-off-by: PotatoCP <kenzieradityatirtarahardja.18@gmail.com>
Co-authored-by: PotatoCP <kenzieradityatirtarahardja.18@gmail.com>
2025-05-13 10:46:27 +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
Euclid Ye
e4f62d5c16
Remove duplicate click event in simulate_mouse_click (#36957)
After `InputEvent::Touch` processed by Script, it sends
`TouchEventProcessed` back to Constellation, which goes through hit-test
etc. and loops back to Script again. However,
`WebViewRenderer::simulate_mouse_click` should not send
`MouseButtonAction::Click` due to #36413

Testing: Manually tested by converting mouse to touch

cc @jdm @xiaochengh

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-05-13 10:25:09 +00:00
Martin Robinson
8808f9a468
layout: Add a repaint-only incremental layout mode (#36978)
This change adds the simplest kind of incremental layout. When Servo
detects that all style changes only require a repaint, only run stacking
context tree and WebRender display list generation. This means that
these kind of restyles do not need a re-layout. Instead, the existing
box and fragment trees will be used and the styles of damaged nodes will
be updated in their box and fragment tree nodes.

This requires a new style repair DOM traversal for nodes that have had
their style damaged. In addition, careful accounting of all the places
where we store style must happen in order ot update those styles.

Testing: This is covered by existing WPT tests as it should not change
observable behavior.

We have created a test case which shows a 50% speedup when run
in Servo, even though there still a long way to go to match the speed
of other browsers:
https://gist.github.com/mrobinson/44ec87d028c0198917a7715a06dd98a0

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-05-12 17:03:50 +00:00
Oriol Brufau
51fa6cdcb6
layout: Split AbsoluteAxisSolver::solve() into different methods (#36970)
Abspos layout used to solve sizing and margins simultaneously. This
patch refactors the logic to solve them separately, resulting in simpler
code.

Testing: Unneeded (no change in behavior)

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-05-12 16:30:53 +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
Ngo Iok Ui (Wu Yu Wei)
aa4ad0f2be
fix: ReadableStream::get_in_memory_bytes too large (#36914)
Fix a IPC hang due to `ReadableStream::get_in_memory_bytes` could return
really huge chunk.

Testing: WPT on ReadableStream should pass
Fixes: IPC hang when transferring huge chunk bytes from `ReadableStream`


cc @gterzian @Taym95 since this is also related to ReadableStream.

---------

Signed-off-by: Yu Wei Wu <yuweiwu@YunoMacBook-Air.local>
Co-authored-by: Yu Wei Wu <yuweiwu@YunoMacBook-Air.local>
2025-05-12 16:00:14 +00:00
Gae24
c37d5572fd
codegen: use FromJSValConvertible trait for Promise (#36966)
Before it was only used when converting to a `Record`, using it all the
times allow us to remove two methods.
Plus added a helper method in CodegenRust.py to avoid repeated code.

Testing: a successful build and existing tests should cover the changes.
Fixes: #36410

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2025-05-12 11:05:46 +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