Refactoring of the algorithm normalization in #39431 introduces a new
algorithm normalization procedure to replace the existing one.
This patch migrates the `digest` operation from using existing
`normalize_algorithm_for_digest` function to using the new
`normalize_algorithm` function.
Note that the custom type `DigestAlgorithm` has not yet completely
removed since other operations like `get key length` (not migrated yet)
depend on it. It will be removed when those operations are also
migrated.
A minor bug (missing a step) in `normalize_algorithm` is also fixed.
Testing: Refactoring. Existing WPT tests are enough.
Fixes: Part of #39368
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Needed for #39526; stubs out all the necessary interface from
https://www.w3.org/TR/geolocation/.
Testing: WPT
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
This is an initial attempt at implementing synthetic bold face for font
families that lack actual bold faces. The overall approach borrowed
implementations from Chromium and FireFox. WPT expectations will be
updated after https://github.com/servo/stylo/pull/244 lands
Testing: There are existing WPT testcases for font synthesis
(`wpt/css/css-fonts/font-synthesis-*`)
Depends on: https://github.com/servo/stylo/pull/244
---------
Signed-off-by: Minghua Wu <michael.wu1107@gmail.com>
Signed-off-by: minghuaw <michael.wu1107@gmail.com>
Support `keyCode` and `charCode` fields in KeyboardEventInit for
Speedometer 3.0
Speedometer 3.0 fails because Servo's KeyboardEvent constructor ignores
keyCode and charCode parameters, hardcoding them to 0. This breaks
frameworks
that check `event.keyCode === 13` for Enter key detection. This is how
[Speedometer 3.0 dispatches key
events](8d67f28d02/resources/benchmark-runner.mjs (L166))
vs [Speedometer 2.0
triggerEnter](491acc2d64/resources/tests.mjs (L60)).
Speedometer 3.0 uses the modern KeyboardEvent constructor but passes
[legacy fields like keyCode and
charCode](https://w3c.github.io/uievents/#legacy-dictionary-KeyboardEventInit)
in the init dictionary for backwards
compatibility with older frameworks(for example: backbone.js)
This change uncomments the legacy KeyboardEventInit fields and updates
the constructor to read them from the init dictionary instead of
hardcoding to 0.
Testing: No new tests added.
Fixes: part of https://github.com/servo/servo/issues/16719
Servo running Speedometer3.0 successfully
<img width="1136" height="880" alt="speedometer 3 0"
src="https://github.com/user-attachments/assets/cf5199a5-d88d-4495-ae96-05fa6332b97e"
/>
---------
Signed-off-by: atbrakhi <atbrakhi@igalia.com>
WPT tests require us to reliably take screenshots when test pages are
fully loaded and testing is complete, and the WPT runner uses
[test-wait.js](a2f551eb2d/tests/wpt/tests/tools/wptrunner/wptrunner/executors/test-wait.js)
to do this in userland. when testing Servo with [--product
servo](a2f551eb2d/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py),
we use servoshell’s --output option, which backs that up with more
reliable waiting in Servo. but when testing Servo with [--product
servodriver](a2f551eb2d/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservodriver.py),
we use the WebDriver Take Screenshot action, which currently takes the
screenshot immediately. we think this might be a source of regressions.
this patch makes the WebDriver actions Take Screenshot and Take Element
Screenshot use the same new WebView::take_screenshot() API as
servoshell’s --output option, such that those actions now wait for [a
variety of
conditions](a2f551eb2d/components/servo/webview.rs (L596-L602))
that may affect test output. it’s not clear if this is
[conformant](https://w3c.github.io/webdriver/#screen-capture), so we may
want to refine this to only wait when running tests at some point. other
changes:
- we remove the retry loop where we try to take a screenshot every
second for up to 30 seconds
- we send the result as a image::RgbaImage over crossbeam without shared
memory (it’s not cross-process)
- we now handle the zero-sized element case directly in the WebDriver
server
Testing: This should fix some flaky tests.
Fixes: #36715.
Fixes: (partially) #39180.
Fixes: (partially) #34683.
Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
*Most* of the properties that were verified here were already verified
by the xpath parser before. I have not found any evidence that other
browsers do the remaining checks. There are web platform tests that
expect contradicting behavior (which pass in other browsers).
Additionally, this change switches `xpath` to use `markup5ever` instead
of `html5ever` - this is a drop-in replacement. I thought I did this as
part of https://github.com/servo/servo/pull/39546 but apparently the
change got lost in the rebasing.
Testing: A new web platform test starts to pass.
Fixes https://github.com/servo/servo/issues/39442
Part of #34527
cc @minghuaw
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Hoisted absolutes that are cached in IndependentFormattingContexts may
have their HoistedSharedFragment reused between layouts. This means
that the original value of the adjusted static positioning rectangles
need to be preserved in cache. This change makes it so that these values
are cloned when being retrieved from the cache. Further adjustments up
the tree will now no longer affected the version in teh cache.
Testing: This should cause `/_mozilla/css/stacked_layers.html` to no
longer
be flaky.
Fixes: #39548.
Fixes: #39439.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
XPath (and, in the future, XSLT) is only loosely coupled to `script`. As
`script` is already very large, I'd like to move the xpath parser and
evaluator into a seperate crate. Doing so allows us to iterate on it
more easily, without having to recompile `script`. Abstracting over the
concrete DOM implementation could also allow us to write some more
comprehensive unit tests.
Testing: Covered by existing web platform tests
Part of https://github.com/servo/servo/issues/34527
Fixes https://github.com/servo/servo/issues/39551
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
servoshell should not depend on internal Servo crates. Instead,
`libervo` should re-export any types that are used by embedders. This
change does that re-export for private types currently used by
servoshell.
Testing: This just changes the way types are imported, so curent tests
should suffice.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
When `block-size` was intrinsic and there was no block-end padding or
margin, we were allowing the block-end margin of the box to collapse
with the block-end margin of its contents.
However, due to `min-block-size` or `max-block-size`, the final size can
be different than the intrinsic size of the contents. In that case it
didn't make any sense to collapse end margins, only WebKit does it too.
This patch takes the final size into account, like Gecko and Blink. This
is under discussion in https://github.com/w3c/csswg-drafts/issues/12218,
but for now we will match Blink.
Testing: 2 tests are now passing. There is also 1 new failure, but that
test only passes in WebKit and I don't agree with it.
Fixes: #36321
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This allows measuring the size of these types conditionally rather than
ignoring them.
Testing: This modifies which things are measured by `MallocSizeOf` which
isn't covered by tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
`relative_path_expr` can only ever return `Expr::Path`. If we make it
return a `PathExpr` then callers can rely on this invariant.
Testing: There's only limited testing for this change due to
https://github.com/servo/servo/issues/39551. But I think that's okay,
since the change is fairly trivial.
Part of https://github.com/servo/servo/issues/34527
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This change adds a new API to the `WebView` for capturing screenshots.
This makes it possible to:
- use the reftest waiting infrastructure via the API
easily.
- take more than a single screenshot in one Servo run.
- take screenshots, but still paint the `WebView` normally prior
to the moment that the screenshot is ready, instead of preventing
all non-screenshot-ready paints while taking a screenshot.
In addition, the previous infrastructure, the `wait_for_stable_image`
option is removed completely.
Testing: This change is tested by the passing of the WPT tests,
as they commonly use the screenshot feature.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
The `border-radius` property provides the radii for the border box. For
the curvature of the padding and content boxes, we then subtract the
border and padding sizes. However, we weren't flooring the result by
zero, which could make the background completely disappear when using
`background-clip: padding-box` or `background-clip: content-box`.
Testing: Adding 4 new tests, but 2 of them fail in both Servo and
Firefox.
Fixes: #39540
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Move testbinding interfaces to it's own module, to avoid cluttering dom
folder.
Testing: A successful build is enough
Part of #38901
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
The first epoch is 0 as that is the one used in the initial transaction,
but the code was setting the first `Epoch` to `Epoch(1)`. This means
that
when layout advanced the epoch, the `Epoch` of the first produced
display list was `Epoch(2)`.
This change makes the value reflected in `current_epoch` actually match
the index of the display list produced. In addition, we always store
this epoch in `PipelineDetails` in the renderer. This will be important
when adding the `WebView::take_screenshot` API.
Testing: This should not change behavior, so is covered by existing
tests which
rely on proper `Epoch` advancement.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Script: added ```line_no``` as argument to both
```fetch_inline_module_script()``` & ```compile_module_script()``` to
fix the inline script reporting wrong line issue
([#39415](https://github.com/servo/servo/issues/39415)).
Originally, the function ```compile_module_script()``` hardwires the
value 1 when invoking ```CompileOptionsWrapper::new()```. This is fine
if the script is written in separate JS file, but for inline scripts, it
will cause confusion if the ```<script>``` tag doesn't start from line
#1.
```line_no``` is obtained from ```line_number```, a member variable from ```HTMLScriptElement```.
Credits to @jdm for actually pointing out which functions to fix.
Testing: Created a WPT test for this change, specifically: ```tests/wpt/tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-5.html```.
Fixes: issue [#39415](https://github.com/servo/servo/issues/39415)
---------
Signed-off-by: RichardTjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Rocketjumper <112361665+RichardTjokroutomo@users.noreply.github.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Create and store a cached object in `CryptoKey` for the `[[usages]]`
internal slot when the key is created or when its `[[usages]]` internal
slot is updated. The getter can then return the cached object as
specified in https://w3c.github.io/webcrypto/#dom-cryptokey-usages,
instead of creating a new object on each call.
Testing: Pass WPT tests that were expected to fail.
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This allows us to notify the embedder when navigating back and forth.
Testing: Manual testing following the steps in issue #39529
Fixes: https://github.com/servo/servo/issues/39529
Signed-off-by: webbeef <me@webbeef.org>
Add the prefix of "WebStorage" instead of "Storage" for all webstorage
spec related things. For example, a `struct` called `StorageManager`:
this could refer to either webstorage's thread manager or to the backend
for [the storage manager
interface](https://storage.spec.whatwg.org/#storagemanager). webstorage
is the full name of the spec, so I chose to keep that in the names of
files/structs to prevent confusion when storage manager is implemented.
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Empty the surrounding agent’s pending mutation observers when notifying
mutation observers according to the spec. Also, the code in the method
MutationObserver::queue_a_mutation_record and the corresponding
specification have diverged over the years. These changes bring the code
into conformity with the specification.
Testing: Added a new crash test
Fixes: #39434#39531
---------
Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
Motivation: The font cache currently has to store a cache of Keys which
need to be given by the webrender instance.
Having a cache for every WebViewId in the future when we have every
webview have the different webrender::DocumentId might be too wasteful
to store this key cache per DocumentId. This proposes to include in the
WebViewId another id, the RenderingGroupId. This id can be easily
changed
to be equivalent to the DocumentId when we support multiple DocumentIds
for a unique Webrender instance.
Additionally this will keep it easier to integrate the currently out of
tree patches for multiple rendering contexts with different webrenders.
Change:
We introduce the RenderingGroupId in the WebViewId and allow a method to
extract it. The font key cache uses this cache
and forwards it to the Compositor when requesting new changes. The
compositor currently ignores this id.
Additionally, the WebView can return the RenderingGroupId. The WebViewId
also has an appropiate constructor for specifying a RenderingGroupId.
Because there currently will be only one RenderingGroupId the
performance will be minimal.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: This should be covered by WPT tests and normal browsing
behavior works fine.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Moved more functions to fxhash. And provide comments about the choices
when necessary.
Testing: Hash functions shouldn't change functionality.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Split the window_proxies in script thread into its own struct with
appropiate methods. ScriptThread allows to get an Rc to it.
HtmlIFrameElement, Window and WindowProxy now get the Rc on construction
from ScriptThread.
Testing: Just a refactor so should not change any behavior.
Fixes: Addresses part of https://github.com/servo/servo/issues/37969
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Follow the HTML specification and take into account that state changes
of the <image> 'crossorigin' and 'referrerpolicy' content attributes
(not 'crossOrigin' and 'referrerPolicy' IDL attributes) should be
counted as relevant mutations.
See https://html.spec.whatwg.org/multipage/#relevant-mutations
Testing: Improvements in the following tests
- html/dom/reflection-embedded.html
-
html/semantics/embedded-content/the-img-element/relevant-mutations.html
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
We should also check closure bodies for unrooted expressions.
Testing: New crown tests
Fixes: #37331
Fixes (partial): #37330
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This PR moves storage related APIs (currently just webstorage and
indexeddb) into their own crate. This reduces the congestion in the net
thread.
Related Zulip thread:
https://servo.zulipchat.com/#narrow/channel/263398-general/topic/indexedDB.20location/with/535911631
Sub PRs:
- [x] Move shared storage/net stuff to base (`IpcSend` and
`CoreResourcePool`) #39419
---------
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
The Link HTTP header can do the same as link elements,
in that they can preload/prefetch/etc... This implements
the basics of header parsing and hooks it up for preload.
Note that we use a new nom-rfc8288 crate that implements
the parsing behavior. However, that crate is too strict
in that empty attributes (;; as part of the header) are
discarded and resulting in a parsing failure. Therefore,
we use its lenient parsing mode.
Part of #35035
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
When taking element screenshot, we need to convert y-coordinates to
comply with OpenGL. With dpi > 1, sometimes y can be -1 due to rounding,
resulting in panic when
660f90f687/components/shared/compositing/rendering_context.rs (L655)
This PR safely converts.
Testing: When running in headed mode with dpi > 1,
`/webdriver/tests/classic/take_element_screenshot/scroll_into_view.py`
always passes locally now without panic.
Fixes the panic:
https://github.com/servo/servo/issues/39306#issuecomment-3342204869
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Simple check to not send data urls to devtools.
Testing: Looked at reddit.com which sends data url and tested it with
this fix.
Fixes: Should fix https://github.com/servo/servo/issues/39127.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Adding an optional message to be attached to an InvalidStateError.
Testing: Only a refactor, no behavior change
Fixes: Partially #39053
Signed-off-by: Excitable Snowball <excitablesnowball@gmail.com>
Stylesheets loaded via the `<link>` element should block the rendering
of the page according to the HTML specification [1]. This change makes
it so that they do this and, in addition, we do not take reftest
screenshots until all no element is blocking the rendering.
This change does not add support for the `blocking` attribute of
`<link>`, but that can be added in a follow change. In addition to
fixing a few tests, this change likely makes other tests no longer
intermittent. We will need to watch CI runs after this lands in order to
verify that though.
Testing: This change fixes at least two WPT tests.
Fixes: #26424.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
According to spec, we should wait animation frame callbacks before
taking (element) screenshot. As "element screenshot" would automatically
scroll into view, this solves intermittency.
Testing: Manually tested on pages, and
`take_element_screenshot/scroll_into_view.py` passes stably now.
Fixes: #39306
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
`StylesheetLoader` implements the `StylesheetLoader` trait from Stylo.
This is pretty confusing as the names are the same. This change renames
the Servo version to `ElementStyleSheet` loader so that it's clearer
from reading the code what each of these things are.
Testing: This change just makes a few renames so shouldn't change test
results.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
It is possible that the bounding rectangle of an element has area 0.
This PR avoids panic in this case.
It is worth to mention that the panic itself won't kill the entire
program for interaction, but only the webdriver thread.
Testing: Manually tested on the case of #39495
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This aligns the implementation with the spec, where both input body and
init body are now set. In doing so, it fixes a fetch abort test, since
the stream was missing for the input body.
It also introduces the `unusable` method, as that's the one the spec
uses. The other two getters no longer exist in the spec.
Fixes#39448
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This removes the last instances of Deref<str> and DerefMut<str> used for
DOMString.
The goal is outlined in https://github.com/servo/servo/issues/39479.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: Compilation is the test as it just changes function names
essentially.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Calling `scrollIntoView()` on an element within an `<iframe>` will now
scroll scrolling boxes from the parent document(s), as long as they have
the same origin.
Testing: One existing subtest passes, and adding a new test.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
It is possible to pass in objects that are not trusted scripts into the
Function constructor. Rather than crashing, we now treat these as
untrusted. `can_compile_string_with_trusted_type` doesn't need to know
the contents of a string, as it always marks it as untrusted.
We can make the same optimization in the string case, where we no longer
need to convert the string.
Testing: This change adds a WPT crash test.
Fixes#39436
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
In the past, all scroll offsets were reset when navigating between
pages,
and layouts probably didn't preserve their scroll positions between back
and forward operations. Whatever the reason, the compositor was still
trying to
reset these positions right after a load.
This is an issue, because a page can request a scroll during a load, and
this
scroll might be requested from `<iframe>` content. In that case, the
scroll
positions should be the ones that layout reflects and not cleared from
the
Compositor. This reset operation had the potential to stomp on scroll
positions
set during load.
It's quite likely that the Compositor shouldn't be trying to reset them
at all,
so just stop doing that. This removes a source of intermittency when
running
tests that set scroll positions.
Testing: Once #39475 lands after this, its test should always pass.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This keyword is de-facto required for web compatibility, Firefox is also
enabling it (https://bugzil.la/1988938).
This patch just aliases it to `stretch`.
Stylo PR: https://github.com/servo/stylo/pull/243
Testing: Various tests pass
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
As resolved in https://github.com/w3c/csswg-drafts/issues/12220, when
resolving `align-content: normal` on a table cell, we will now use safe
alignment.
The difference only matters when the contents of the cell are taller
than the cell, which doesn't typically happen. But in Servo it's
observable when there are collapsed rows.
Testing: Adding new tests. Some fail because we don't support
`align-content` yet.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>