This fixes the logic that computes sticky offset bounds in order to
correctly take margins into account.
Testing: One test passes
Fixes: #39389
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Serde_core was released which has all the traits and allows some crates
to have parallel compile times.
More information can be found here:
https://github.com/serde-rs/serde/tree/master/serde_core
serde_bytes already depends on on serde_core. Additionally added serde
and serde_core to dependabot group.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: Compilation is the test.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This is part of the future work of implementing LazyDOMString as
outlined in https://github.com/servo/servo/issues/39479.
We use str() method or direct implementations on DOMString for these
methods. We also change some types.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: This is essentially just renaming a method and a type and
should not change functionality.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This is part of the future work of implementing LazyDOMString as
outlined in issue #39479.
We use str() method or direct implementations on DOMString for these
methods. We also change some types.
This is independent of https://github.com/servo/servo/pull/39480
Signed-off-by: Narfinger Narfinger@users.noreply.github.com
Testing: This is essentially just renaming a method and a type and
should not change functionality.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Adding an optional message to be attached to a NotFoundError.
Testing: Just a refactor
Part of #39053
---------
Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
When an `<iframe>` cannot scroll because the size of the frame is
greater than or
equal to the size of page contents, chain up the keyboard scroll
operation to the parent frame.
Testing: A new Servo-only WPT tests is added, though needs to be
manually
run with `--product servodriver`.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
This undoes #35882 according to the last CSSWG resolution, since this is
required by web compat.
Testing: Modifying the relevant test
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
In our current implementation, we have multiple functions such as
`normalize_algoirthm_for_encrypt_or_decrypt` and
`normalize_algorithm_for_sign_or_verify` to normalize an algorithm, and
each of them works slightly differently. However, the spec defines a
single normalization procedure to handle all normalization.
This patch tries to consolidate our functions into a single
spec-compliant normalization function named `normalize_algorithm`.
The refactoring involves many existing code, so this patch only
introduces the new infrastructure without touching the existing. When
this patch gets approved and merged, we can then start migrating the
existing to the new infrastructure. (Note that SHA's digestion and
AES_CTR's encryption are also copied to the new infrastructure as
demonstration.)
More details about the refactoring can be found in the comment:
https://github.com/servo/servo/issues/39368#issuecomment-3316943206
Testing: The new code is not in used right now. No test is needed.
Fixes: Part of #39368
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Also includes a fix to not throw a type error in
`XPathResult.invalidIteratorState`.
Testing: Includes a new web platform test
Part of https://github.com/servo/servo/issues/34527
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
The Web Cryptography API has the "crypto task source"
(https://w3c.github.io/webcrypto/#dfn-crypto-task-source-0) to queue
tasks to resolve or reject promises created in response to calls to
methods of `SubtleCrypto`.
This patch enables this task source at the script task manager, and
queue tasks on this task source from existing steps.
A few WPT error expectations are also added to WPT meta. The related
cryptographic algorithms have not yet implemented, so the errors are
expected. I don't know why WPT test did not capture them before.
Testing: Existing tests suffice.
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
It is possible for viewport changes to be received before the
constellation adds a browsing context to its managed set when
navigating. When that happens, the viewport change is ignored, and eg.
the hidpi will keep the default 1.0 value.
On later page navigation, this value is not updated and leads to
incorrect display zooming. The initial page load is fine in the current
embedders because they update the compositor and webview renderer even
if the constellation is not fully ready.
Testing: Testing is difficult because it's device dependent, but I
reproduce 100% of the time running winit_minimal on a Pinephone Pro.
Signed-off-by: webbeef <me@webbeef.org>
Add the reflected 'sizes' IDL attribute for <image> element's DOM
interface which defines image sizes for different page layouts.
See https://html.spec.whatwg.org/multipage/#dom-img-sizes
Testing: Improvements in the following tests
- custom-elements/reactions/customized-builtins/HTMLImageElement.html
- html/dom/idlharness.https.html
-
html/semantics/embedded-content/the-img-element/relevant-mutations.html
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Regular shadow roots can never be detached once they are created.
However we were specifically detaching shadow roots from media elements
when they were disconnected. This is actually one of the very few
aspects of shadow roots that predate the implementation work I did
earlier this year.
I'm not sure why we ever did this. Maybe its for efficiency reasons,
because keeping the shadow tree around is not necessary when the media
element is not connected. But I can't imagine this yields any benefits,
especially since you would have to reconstruct the shadow tree when the
media element is re-connected (as is the case in the crash we observe).
For simplicities sake, I have completely removed this functionality.
Doing so ends up simplifying the code quite a bit.
Testing: This change adds a new crashtest
Fixes https://github.com/servo/servo/issues/36722
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
The test could intermittently fail if the second evaluate_javascript()
command was received in the script thread before the reloaded page
actually existed. By serializing the steps so that the page is
completely loaded after the reload command is issued, we avoid this
race.
Testing: Locally reproduced, could not reproduce after the changes.
Fixes: #38920
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
The existing `assert!(node.is_connected())` is wrong. What it *wants* to
assert is that the style element has an owner, which is either a
Document or a ShadowRoot that the element is a descendant of. However,
if the element is descendant of a ShadowRoot which is itself not
connected to a document then the assertion would fail.
Instead, we use `node.is_in_a_document_tree() ||
node.is_in_a_shadow_tree()`, which more accurately reflects the intent.
Testing: This change adds the test case from
https://github.com/servo/servo/issues/37781 as a crashtest
Fixes https://github.com/servo/servo/issues/39457
Fixes https://github.com/servo/servo/issues/37781
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Testing: Verified by the fact that the code still compiles, and existing
web platform tests of course
Part of https://github.com/servo/servo/issues/34527
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Instead of having every single embedder implement keyboard scrolling,
handle it in script in the default key event handler. This allows
properly targeting the scroll events to their scroll containers as well
as appropriately sizing "page up" and "page down" scroll deltas.
This change means that when you use the keyboard to scroll, the focused
or most recently clicked `<iframe>` or overflow scroll container is
scrolled, rather than the main frame.
In addition, when a particular scroll frame is larger than its content
in the axis of the scroll, the scrolling operation is chained to
the parent (as in other browsers). One exception is for `<iframe>`s,
which will be implemented in a followup change.
Testing: automated tests runnable locally with `mach test-wpt --product
servodriver`
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Follow the HTML specification and take into account that the HTML
`<image>/<source>` element inserting/removal steps should only be
counted as relevant mutations for `<image>` element if the parent of the
inclusive ancestor that was inserted/removed is the parent `<picture>`
element.
See <https://html.spec.whatwg.org/multipage/#relevant-mutations>.
Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/relevant-mutations.html
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
This isn't needed as the border box query already takes into account the
containing block chain. Instead, consistently calculate the new
scroll position for a scroller relative to its current scroll offset.
In addition, fix a small bug where the border of a scroll container was
considered part of scrollport.
Testing: A new WPT test is added.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Sticky positioning tries to keep an element visible within the nearest
scrollport. However, the element can't be offset to go beyond its
containing block. We implement this as offset bounds.
The problem was that, if the element would already be overflowing its
containing block before applying the sticky positioning, then we were
forcing it to move inside the containing block. That was wrong, and is
solved by flooring or ceiling the offset bounds by zero.
Testing: Adding new tests
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This change removes the `DebugOption` (`-Z`) for touch event simulation
and moves the implementation of the feature to servoshell. The resaoning
for this is:
- This is really a servoshell feature and can be implemented on top of
the API. This moves more code out of the already too-complicated
renderer.
- I would like to consolidate `DebugOptions` into a `ServoLogOptions`
to collect all options for configuring Servo logging. This requires
moving away all of the non-logging options.
- Eventually touch event simulation will be able to reuse the fling
implementation from servoshell as we are actually simulating touch
events sent to the `WebView`.
Testing: This changes a conditional feature that's used for manual
debugging.
It is difficult to write tests for this as there are no servoshell tests
that
verify input handling.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Part of #39418. See that PR for a full description.
Moves:
- `read_json_from_file`
- `write_json_to_file`
- `IpcSendResult`
- `IpcSend`
Renames:
- `CoreResourceThreadPool` to `ThreadPool` (shorter and more
descriptive, as we use it for more than the core resource thread now)
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
`cumulative_node_transform()` returns the cached value if present, and
otherwise calls `cumulative_node_transform_inner()` to compute it.
However, `cumulative_node_transform_inner()` was just calling itself
recursively to compute the ancestor transforms, ignoring the cache.
Therefore, this patch makes `cumulative_node_transform_inner()` call
`cumulative_node_transform()` for the parent. This requires merging
`AncestorStickyInfo` into `ScrollTreeNodeTransformationCache` in order
to cache that data too.
Testing: Not needed, no behavior change
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Also fixes several issues with code generation when a dom type is part
of a dictionary.
Part of #34866Fixes#39398
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Does not all tests pass because of a mismatch in microtask timing. The
promises are resolved/rejected in the wrong order.
Part of #34866
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Add specification quote for each steps, remove some irrelevant TODO, and
move function position closer to related function.
Testing: No behaviour change
---------
Signed-off-by: PotatoCP <kenzieradityatirtarahardja18@gmail.com>
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Co-authored-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Previously servo would allow whitespace in between components of an
xpath expression, but not around it.
Testing: New web platform tests start to pass
Part of https://github.com/servo/servo/issues/34527
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
- Expose a couple helpers on `ScrollingBox` that will also be used for
keyboard scrolling.
- Calculate `scrollIntoView` positions using points rather than doing
things by axis components. This greatly reduces the amount of code in
the implementation.
Testing: This is just a refactor so shouldn't change any tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Variables in xpath via the javascript bindings are a bit mysterious, as
there is no way that a variable can be specified. We currently panic
when encountering a variable, which is not good. Instead we now throw an
error.
We keep parsing the variables because the code is already there and it
seems realistic that their behaviour will be specified in the future.
I'm fine with removing them too if that is preferred.
Testing: This behaviour is unspecified and different browser produce
different results. There is no "correct" way to do this, but we should
not crash
Part of: https://github.com/servo/servo/issues/34527
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This file was missed in 07b2ff5d60
(#39325). See that commit for the motivation.
Testing: Covered by existing web platform tests.
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This reduces code duplication in the callers.
Testing: This is a just a refactor, so no tests are needed.
Fixes: #11280.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
I noticed that there are various dependencies that are listed
independently even though they are already in the Servo workspace. Is
there any issue with converting these to workspace dependencies?
Testing: No tests for Cargo.toml edits.
Signed-off-by: Alex Touchet <26315797+atouchet@users.noreply.github.com>
Taffy treats static and sticky positionings as relative. So the inset
properties shifted the element in the relpos way, which was no good.
It's better to just treat them as `auto` instead.
Testing: 3 existing tests pass, and adding a new one.
Fixes: #39399
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
We were returning null for all `<html>` elements, but now we will check
for the root element instead.
We were also returning null for "the body element", now we will return
null for all `<body>` elements even if they aren't "the body element".
This part diverges from the spec, but matches what all browsers do.
https://github.com/w3c/csswg-drafts/issues/12834
Testing: Adding new test
Fixes: #10521
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Follow the HTML specification and check if the source element's MIME
type
('type' attribute) is supported while updating the source set of the
image element (step 5.8)
https://html.spec.whatwg.org/multipage/#update-the-source-set
Also add the missing descriptions for steps for the old and new methods:
- selecting an image source
- creating a source set from attributes
- updating the source set
- normalizing the source densities
Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/update-the-source-set.html
- resource-timing/initiator-type/picture.html
Fixes: #36675
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
This behaviour is optional, but observable. Other browsers implement it,
so we should do it too.
Testing: There are no WPT tests for this, which is fair since the spec
explicitly states implementors may choose to not reuse the result.
Fixes: Part of https://github.com/servo/servo/issues/34527
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
`offsetLeft` and `offsetTop` were ignoring that sticky positioned boxes
can be shifted out of their normal position.
Testing: Various test improvements.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
#33426 only added support for relative positioning on captions with
`caption-side: top`, but forgot about `caption-side: bottom`. This
unifies the logic for both kinds of captions to avoid divergences.
Testing: Modifying an existing test to also cover this case.
Fixes: #39386
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Since IpcSender is now Sync (since `ipc_channel` 0.20.2), we can remove
locks that were added just to make structs containing the sender `Sync`
again.
There is another occurrence of `Arc<Mutex<IpcSender<>>>` in
`RequestBody`, however that sender is exchanged / updated, so cloning
the sender instead of the Arc would change behavior, hence this PR does
not touch it.
Testing: Covered by existing tests
---------
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Changes function signatures to accept `ClipId`, `ExternalScrollId` and
`ScrollTreeNodeId` instead of `&ClipId`, `&ExternalScrollId` and
`&ScrollTreeNodeId`. This avoids several `&` and `*`.
Testing: not needed, no behavior change.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>