The spec expects us to check for render blocking (among some other
state) before we start procesing a document. Therefore, add those checks
and also check in the
stylesheet loader that we should only do so when we are allowed to do
so.
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This option controls whether progressive web metrics are printed to the
system console, which is essentially the purpose of
`DiagnosticsLogging`. This makes the API a bit more uniform.
Testing: We do not really have automated testing for this kind of
feature of the API.
Fixes: This is part of #34967.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Implementing `Drop` for DOM types is being forbidden. This moves the
resource cleanup logic for `GPUSampler` to a separate
`DroppableGPUSampler` struct and removes the `allowDropImpl` flag from
the bindings configuration.
Testing: WebGpu tests just cover its cases
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
This is a hot path. This way we free the unused memory earlier.
Didn't realize the difference in #43202.
Testing: This is a memory optimization that does not change visible
behaviour.
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Move from CanGc to &mut js::context:JSContext. `ArrayBuffer` and `Bytes`
require many changes in `dom/stream` for which I'm going to create a
seperate pull request before porting the two methods.
Testing: Just a refactor, `./mach test-unit` still passes.
Fixes: Part of #42638
---------
Signed-off-by: Uiniel <174327181+uiniel@users.noreply.github.com>
This setting is used to control whether or not incremental legacy layout
was enabled. Nowadays incremental layout is always enabled as it is a
fundamental feature of how layout works. The setting also controls
whether or not nodes are traversed in Style, but that's also something
that's much less interesting today. This change just removes this
setting as it just controls the Stylo setting. A corresponding change in
Stylo will also remove the setting there.
Testing: This just removes a setting so existing tests should suffice.
Fixes: This is part of #34967.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Initial work to support scopes in the debugger. They don't show at the
moment since we are not processing variables yet. Depends on #43166.
Testing: Ran `mach test-devtools` and manual testing.
Part of: #36027
Signed-off-by: eri <eri@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
Notify embedder the coalesced wheel/mousemove event.
We also stop cloning every single entry in `pending_input_event`.
Testing: This should unblock the potential WebDriver thread deadlock
when receiving simultaneous wheel or pointer inputs from multiple
sources.
We added a new test that stably deadlock on
74c16ffd8a.
Firefox/Safari/Chrome all pass the new test.
Fixes:
https://github.com/servo/servo/issues/43136#issuecomment-4031702204
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Remove command invokers preference
This now passes most of the relevant tests. Most of the remaining
failures are due to missing functionality such as the popover API,
element reflection properties (see
https://github.com/servo/servo/issues/42884), and issues with the event
retargeting code that doesn't handle shadow dom correctly.
Signed-off-by: Luke Warlow <lwarlow@igalia.com>
The script execution code has changed a bit in the last months so some
things that used to work don't anymore.
This change ensures that when an exception is thrown it is logged to the
console.
Testing: Regressions are covered by wpt, but we can't run tests for the
presence of `log::error!` calls
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Simplify the `KeyboardEvent` constructor by taking the actual
`keyboard_types` `KeyboardEvetnt` as an argument. This means that we do
not have to repeat the logic for extracting all the data from the
platform event.
Testing: This should not change behavior and is thus covered by existing
tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
For the longest time we've had a `dispatch_event` boolean flag in our
error reporting code that determines whether or not to fire an `error`
event. It was only set to `false` in the event handler code due to a
double borrow that would occur otherwise. It seems that this is no
longer a problem, so we can remove the flag and correctly fire the event
in that case too.
Testing: A new test starts to pass and
`html/webappapis/scripting/processing-model-2/runtime-error-in-body-onerror.html`
does not crash
Fixes: https://github.com/servo/servo/issues/13152
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This functionality will be used in a follow up patch to implement the
getEnvironment message.
Testing: Check `mach test-devtools` and manual test
Part of: #36027
Signed-off-by: eri <eri@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
We send back input events handling results in batch. This reduces IPC,
and make the following **TODO** possible in a follow-up.
Testing: I hope existing tests results won't change.
Part of
https://github.com/servo/servo/issues/43136#issuecomment-4031915873
**TODO**: We have not done
> collect ids and send back a reply for each of them once the coalesced
event has been handled.
yet.
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
While we are not there yet, this is the majority of the implementation
of the delete command.
What's missing:
1. Handling of style attributes (most of the test failures)
2. Handling of lists
Since these are quite complicated on their own, deferring that to their
own PR.
Also added more assertions regarding parent nodes, which should always
exist in the spec. By adding those, discovered that the logic for
`is_visible` was wrong where its display value wasn't checked for
`"none"`.
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
The equality check used to detect whether an element has an access key
assigned was reversed. This meant that access keys did not work on
non-form control elements. This change fixes the equality sign and adds
a test for this behavior.
Testing: A new Servo-specific test is added. Access key behavior
activation
behavior is very lightly specified so the way we deal with it is
Servo-specific at the moment.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
We should measure the time it takes to fire the `DOMContentLoaded`
event, but we were including the time it takes for the task on the
relevant task source to be run.
Testing: The timing should be slightly more accurate but that is hard to
measure or test for. Therefore this PR does not include a test.
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Continuation of #43108, two new `temp_cx()` calls were required:
- inside `maybe_clone_an_option_into_selectedcontent` since it's part of
a markup5ever trait
- inside `serialize_and_cache_subtree` replacing a `CanGc::note()` call,
propagating it inside reflow code will require even more effort.
Testing: No behaviour change, a successful build is enough.
Part of #40600
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
We should only send previews of ordinary objects[^1] (i think that's the
correct term) objects to the devtools. The code is not designed to
handle other objects, which currently causes crashes.
Testing: This change adds a devtools test that crashes without this
change.
[^1]: https://tc39.es/ecma262/#ordinary-object
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Implement node.moveBefore()
This implements the atomic move method for DOM nodes. This allows moving
elements within the DOM without running the full remove and insertion
steps, allowing more seamless behaviour such as CSS transitions
continuing from where they are rather than restarting.
Spec: https://dom.spec.whatwg.org/#dom-parentnode-movebefore
Testing: Existing WPTs
---------
Signed-off-by: Luke Warlow <lwarlow@igalia.com>
Implement "getPublicKey" operations of ECDSA and ECDH. The steps are
implemented at the new submodule `ec_common` shared by ECDSA and ECDH.
To make the operations functioning, they are also registered at
`GetPublicKeyAlgorithm`.
Specification:
https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-getPublicKey
Testing: Pass WPT tests that were expected to fail.
Fixes: Part of #43072
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Servo side of https://github.com/servo/stylo/pull/322.
Update the WPT expectation following the changes to make `::placeholder`
public and adding property restriction to `::placeholder` and
`::marker`. Additionally ensure that `getComputedStyle` works for
`::placeholder`.
Testing: Existing WPTs
Fixes: #43034Fixes: #43035Fixes: #19808
Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
Implement "getPublicKey" operations of RSASSA-PKCS1-v1_5, RSA-PSS and
RSA-OAEP. The steps are implemented at `rsa_common.rs` shared by the
three RSA algorithms.
To make the operations functioning, they are also registered at
`GetPublicKeyAlgorithm`.
Specification:
https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-getPublicKey
Testing: Pass WPT tests that were expected to fail.
Fixes: Part of #43072
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This method is the same as `DOMString::from` with a `String` argument
and `From` and `Into` are preferred when writing modern Rust.
Testing: This should not change behavior and is thus covered by existing
tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Implement the `getPublicKey` method of the `SubtleCrypto` interface.
This patch includes:
- Implementing the steps of the `getPublicKey` method.
- Adding the new "getPublicKey" operation to the internal object
`supportedAlgorithms`, for registering cryptographic algorithms that
support "getPublicKey" operation, and used by the `getPublicKey` method
to check whether the cryptographic algorithm supports "getPublicKey"
operation and perform the operation if it is supported.
- Implementing the "getPublicKey" operation of X25519 for demonstrating
and testing the functionality of the `getPublicKey` method.
Specification:
<https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-getPublicKey>
Testing: Pass WPT tests that were expected to fail.
Fixes: Part of #43072
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Moves the `Drop` logic for `GPURenderPipeline` into a dedicated helper
struct, `DroppableGPURenderPipeline`.
The associated `Bindings.conf` entry is
removed as direct `Drop` is no longer needed for this type.
Testing: WebGpu tests just cover its cases
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
This introduces a `CollectionSource` trait as an alternative to
`CollectionFilter` in `HTMLCollection`, allowing collections to provide
elements directly via a custom iterator rather than filtering a full
subtree traversal, which would otherwise be rather inefficient for
smaller iterable sequences of options that can be determined without
traversing the whole subtree again.
The newly implemented `selectedOptions` attribute on the `<select>`
element uses this to iterate only the element's list of options that are
marked as selected.
Testing: 14 assertions in the existing WPT went from failing to passing.
Fixes#15522.
---------
Signed-off-by: Jacob Adam <software@jacobadam.net>
- Use modern Rust conveniences such as `unwrap_or_default`
- Unabbreviate `attr`
- Unify the lowercase ASCII name assertion and make it a debug assertion
- Use `unreachable!` instead of panic
- Expose two attribute getters that follow the behavior of two
specification concepts and what we expect internally in Servo:
- One that takes a namespace, but does not require lowercase attribute
names. ([specification
concept](https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace>))
- One that does not take a namespace, but does require lowercase
attribute names. ([specification
concept](https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name))
Testing: This should not really change behavior so should be covered by
existing tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Accepting the name of the event as a `DOMString` means that when events
are constructed from within Servo (for instance via input event
handling), the static strings are converted to an owned `String`
wrapped in a `DOMString` and then finally converted to an `Atom` in
`Event`. This makes it so that all non-generated `Event` constructors
accept `Atom`, which can avoid a conversion entirely when the atom
already exists on the Stylo atoms list and eliminate one in-memory copy
in the case that it isn't on the atom list.
Eventually, all event names can be on the atom list and we can eliminate
all copies. This is a tiny optimization, but also makes the code much
friendlier everywhere.
Testing: This should not change behavior so should be covered by
existing test.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This change makes it possible to focus boxes with overflow via the
keyboard. These boxes should be focusable areas, yet are not focusable
via the mouse. Instead they can be focused via sequential tab
navigation.
Testing: This fixes a WPT test.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
These two commands are intertwined with the delete command. By
implementing them now, it becomes easier to triage actual
implementation issues in the delete command.
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Rather than overwriting the CSP list from a fetch header response, we
should add a policy from a meta element to the global CSP list (if it
exists).
Fixes#36822
Supersedes and closes#36828
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Co-authored-by: Emmanuel Paul Elom <elomemmanuel007@gmail.com>
This abstracts out a common helper to determine focusable area kind
which is used by `Element::is_click_focusable`,
`Element::is_sequentially_focusable`, and `Element::is_focusable_area`.
This avoid having the latter depend on the former two, which was the
reverse of what the specification said. The helper is necessary because
the specification defines click and sequential focusability as subsets
of focusable elements, but going from "This is a focusable element" to
determining what kind of focusable element something is requires
duplicating a lot of the logic that was used to determine that something
is a focusable area.
It's likely that the specification needs more work here to improve the
definition (and indeed to unify all of the places that talk about what
elements are focusable areas). For now, this just tries to make our code
more similar to the text.
See: whatwg/html#4607
Testing: This shouldn't change behavior, so should be tested by existing
tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>