Moves interfaces defined by the webaudio spec (27 files) to the new
`script/dom/audio/` module from the `script/dom/` module.
Testing: Just a refactor shouldn't need any testing
Fixes: N/A
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
These changes fix a large number of panics that can manifest as
intermittent test failures. They also add more specification text to
various IDBObjectStore methods and implement missing steps that check
for whether an object store is deleted.
Testing: Existing test coverage.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
We wouldn't handle the AttributeMutation::Removed for
attribute event listeners and wouldn't remove the
corresponding event listener. Added the necessary
logic (using the newly EventTarget::is_content_event_handler
to correctly only do this for known event handlers) and
added links to the relevant parts of the spec.
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This is an implementation of the `prevent_scroll` feature in the focus
transaction system. It allows to control whether focusing an element
should prevent scrolling or not.
Spec:
https://html.spec.whatwg.org/multipage/interaction.html#dom-focusoptions-preventscroll
Testing: Existing WPT tests
Signed-off-by: abdelrahman1234567 <abdelrahman.hossameldin.awadalla@huawei.com>
This changes makes a variety of changes to ensure that the cursor is set
back to the default cursor when it leaves the `WebView`:
1. Display list updates can come after a mouse leaves the `WebView`, so
when refreshing the cursor after the update, base the updated cursor
on the last hovered location in the `DocumentEventHandler`, rather
than the compositor. This allows us to catch when the last hovered
position is `None` (ie the cursor has left the `WebView`).
2. When handling `MouseLeftViewport` events for the cursor leaving the
entire WebView, properly set the
MouseLeftViewport::focus_moving_to_another_iframe` on the input event
passed to the script thread.
3. When moving out of the `WebView` entirely, explicitly ask the
embedder to set the cursor back to the default.
Testing: This change adds a unit test verifying this behavior.
Fixes: #38710.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
In the `IDBObjectStore::new` constructor, the `transaction` field is
initialized to null, but when using this constructor, we always execute
`set_transaction` immediately afterward. Therefore, we refactored to
require the `transaction` field to be specified during construction and
thereby also removed some no longer necessary assertions.
We also updated the `transaction` field in WebIDL to remove the nullable
capability.
Testing: WPT
Fixes: #38814
---------
Signed-off-by: criskell <96352451+criskell@users.noreply.github.com>
Servo shows a behavior unlike FF and Safari(I don't have Chrome), where
stopping a window does not cancel planned form navigation, resulting in
an infinite navigation loop. The current behavior of Servo does seem to
follow the wording of the spec, so I will open a [companion issue at the
spec](https://github.com/whatwg/html/issues/11562), and I have also
written a WPT tests for the non-standard but widely followed behavior.
This PR also adds a beginning of an implementation of the "ongoing
navigation" concept, which is used by the spec to cancel navigations,
and which is used in this PR only to cancel planned form navigations.
The generation id concept, which corresponds to the planned navigation
concept in the spec, is turned into a simple struct private cell, and is
documented per the spec.
Testing: A new WPT test is added
Fixes: Only one part of https://github.com/servo/servo/issues/36747
---------
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
Signed-off-by: Gregory Terzian <2792687+gterzian@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Following #37527, every textual input is constructing the containers for
value and placeholder. However not all of textual `<input>` element
require the initialization of such placeholder container. This is
apparent with JS UI framework that defines its own placeholder
management.
This PR add lazy initialization for placeholder which construct the
relevant HTML elements for placeholder container whenever it is
necessary.
Testing: Existing WPT coverage
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
Additionally, several methods were updated with
spec comments. That's because the "adopt the document
from the element document" step was missing.
By adding these spec comments, I also restructured
some code to avoid duplication of mutation records
and custom element reaction queueing.
Node.textContent doesn't propagate the error yet,
as that method has a lot of separate callers of
elements that wouldn't fail. I will refactor those
in a follow-up PR to keep things manageable.
This implements part of the DOM integration from
https://github.com/whatwg/dom/pull/1268
Part of #36258
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
This is a first draft at implementing the required infrastructure for
CookieStore, which requires setting up IPC between script and the
resource thread to allow for async/"in parallel" handling of cookie
changes that have a promise API.
Cookie Store also will need to receive change events when cookies for a
url are changed so the architecture needs to support that.
Expect this PR to be reworked once the architecture becomes more
settled, cookie change events will be implemented in follow up PRs
Testing: WPT tests exist for this API
Part of #37674
---------
Signed-off-by: Sebastian C <sebsebmc@gmail.com>
Adds the `matrixTransform` function for `DOMPointReadOnly`.
Testing: Covered by WPT tests (`css/geometry`)
---------
Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
For duplicate style sheets with identical content, `StylesheetContents`
can be reused to avoid redundant parsing of the inline style sheets.
Since duplicate stylesheets is a common case with web components, this
change will significantly improve performance. Additionally, the cache
hit rate of stylo's `CascadeDataCache` can now be significantly
improved.
When shared `StylesheetContents` is modified, copy-on-write will occur
to avoid affecting other sharers. And then updates the references to
`CssRule` or `PropertyDeclarationBlock` stored in the CSSOMs to ensure
that modifications are made only on the new copy.
Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
These changes allow using MallocSizeOf/`#[conditional_malloc_size_of]`
on WebIDL callback values, and then fix a grab bag of places in the
script crate that previously ignored those values. There are also some
commits removing ignored fields that involved Arc/Rc that are not WebIDL
callbacks, since they are now easier to support with the
`#[conditional_malloc_size_of]` attribute.
Testing: Manual testing on about:memory for servo.org.
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Fix a large number of backend issues that were masking everything else.
There probably is still more, but it'll take more integration/unit
testing to find it.
Testing: WPT
Fixes: #38743
---------
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Motivation:
Using our GenericChannel abstraction allows us to optimize IPC in
single-process mode to just use cross-beam channel.
To keep the diff low, and get early feedback, this PR only tackles a
single channel, but the intention is to port all ipc channels to the
generic channel, which allows us to skip serializing and deserializing
messages in single process mode.
Based on:
- https://github.com/servo/servo/pull/38638
- https://github.com/servo/servo/pull/38636
Testing: Covered by existing tests
---------
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This change fix this bugs: modify stylesheet of shadow tree does not
take effect if there is no other Dom change within the shadow tree
happens.
Fixes: This change fix some bugs reported by this issue #38211.
Testing: This fixes some subtests in
`/css/cssom/CSSStyleSheet-constructable.html` and
`/css/cssom/CSSStyleSheet-constructable-disallow-import.tentative.html`,
and make some subtest failed in
`/css/cssom/CSSStyleSheet-constructable-baseURL.html`, because the
`BaseUrl` is not yet supported for `CSSStylesheet`.
Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
This shows up sometimes in code reviews, so it makes sense that tidy
enforces it. `rustfmt` supports this via comment normalization, but it
does many other things and is still an unstable feature (with bugs).
Testing: There are new tidy tests for this change.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
I had a difficult time figuring out where the relevant steps had to be
added. Therefore, I aggressively commented the spec steps so eventually
I discovered where I should add them.
Part of #36258
---------
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>
This only covers the global event handlers for now, while I figure out
which others we are missing. We don't seem to be missing the
WindowEventHandlers, but not sure where the others coming from.
Part of #36258
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
IDBKeyRange::Bound doesn't check if the lower bound is greater than the
upper bound. When this happens, it should throw DataError.
Reference: Step 5 of
<https://www.w3.org/TR/IndexedDB-2/#dom-idbkeyrange-bound>
Testing: Passing WPT tests that were expected to fail before.
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Implements (de)serialization behavior for QuotaExceededError and enables
the annotation on the WebIDL spec.
Testing: Adds its own WPT tests
Fixes: https://github.com/servo/servo/issues/38685
---------
Signed-off-by: Rahul Menon <menonrahul02@gmail.com>
- Use sqlite instead of heed. (one indexed database = one sqlite
database)
- Implement the backend for indexes
- Use keyranges where needed (as specified by the spec)
- Implement `getKey`
- Fix channel error messaging (led to a bunch of changes to how async
requests are handled)
Note: `components/net/indexeddb/engines/sqlite/serialize.rs` is unused;
I can delete it if needed.
Testing: Switching to sqlite eliminated many panics (exposing some new
failures).
Fixes: #38040
---------
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Callers now call `set_attribute` directly, to avoid the trusted types
machinery, as well as skip validation. That's not required by spec as
well.
This implements part of the DOM integration from
https://github.com/whatwg/dom/pull/1268
Part of #36258
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Instead of making a block for each attribute, use a single block as
described in a `FIXME` comment by @emilio. This also switch to using
`map` and `and_then` in more places to make the code a bit more concise.
Testing: This should not change behavior other than to incraese
efficiency a
bit and is thus covered by existing tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This change supplements the missing stylesheet invalidation
notifications to fix some bugs that the modification of stylesheet does
not take effect. Additionally, this PR add a RAII thing to mark the
modification scope of stylesheet rules, which will facilitate to add
extra logic before the modification happens.
Fixes: there is relevant issue #38211 , but it can't be fixed by this
PR.
Testing: This fixes some subtests in
`/css/cssom/CSSStyleSheet-constructable.html`.
Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
This implements the `TextEncoderStream` WebIDL interface.
Testing: Existing WPT tests should be sufficient
Fixes: #37724
---------
Signed-off-by: minghuaw <wuminghua7@huawei.com>
According to spec of
[hit-test](https://w3c.github.io/uievents/#hit-test) for native mouse
event, mousedown/mouseup should also be excluded when interacting with
disabled element, even tho it may be the frontmost of
[elementFromPoint](https://drafts.csswg.org/cssom-view/#dom-document-elementfrompoint).
Testing: Now it matches the behaviour of other browsers in #38670 for
disabled element. Also testdriver test:
`tests\wpt\tests\html\semantics\disabled-elements\disabled-event-dispatch.tentative.html`
has 4 more passing tests.
Fixes: Part of #38670.
Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
Implements the new WebIDL interface for QuotaExceededError and uses it
in appropriate places.
Testing: WPT tests. Now passing many more in
`tests/wpt/tests/WebCryptoAPI/getRandomValues.any.js` and
`tests/wpt/tests/webstorage/storage_session_setitem_quotaexceedederr.window.js`.
Fixes: #38489
---------
Signed-off-by: Rahul Menon <menonrahul02@gmail.com>
Previously,
[`SetProperty`](https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty)
implemented step 3 before calling into the inner `set_property` method,
which implements step 1. Therefore if step 3 returned then step 1 never
runs, and can't throw an exception.
Testing: A new web platform test starts to pass
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
#38584 moves input event handling to new `DocumentEventHandler`, but
probably reintroduced some removed code when resolving conflict with
#38589.
Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
In single process mode, there is a race condition on the initialization
of the global fetch thread: once initialized the global fetch thread
will always use a given core resource thread, and this will be
determined by the component who first initializes it. For example, if
the canvas paint thread first does an async fetch, then this will set
the public core resource as used for all future fetches, including those
coming from a pipeline in private mode.
In multi-process mode, there is a race condition per window event-loop:
the first pipeline to use the fetch will set the core resource thread
for all others.
To ensure the fetch thread uses the correct core resource thread(private
vs public), we need to
pass the core resource thread to each fetch thread operation for which
is it needed.
Testing: It should not break existing fetch WPT tests. The race
condition is not something that can be tested reliably, but it seems to
be based on solid logic.
Fixes: follow-up from
https://github.com/servo/servo/pull/38421/files#r2248950924
---------
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
This moves the majority of the input event handler code to the
`DocumentEventHandler` helper structure. It better encapsulates event
handling, hiding most of the details from both `ScriptThread` and
`Document`. The benefit here is that the majority of the functions can
become private and `Document` is over 1000 lines shorter.
Testing: This should not change any behavior so is covered by existing
WPT tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
These changes add compile-time assertions that:
* any type that implements the Serializable/Transferable trait has a
`[Serializable]` or `[Transferable]` annotation in the interface WebIDL
* any WebIDL interface with the `[Serializable]` or `[Transferable]`
annotation implements the corresponding trait
This is useful because it means that WebIDL definitions will be less
confusing if you're trying to figure out whether Servo supports
serializing/transferring a particular interface type. It also makes
fixing #21715 in the future a little bit easier, because the annotations
will remain up to date.
Testing: compile-time only; no point in writing tests for this since it
involves webidl codegen.
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
The `Arc<Mutex<>>` wrapper around the IpcSender does not appear to be
needed anymore.
Testing: No functional changes. Covered by existing tests
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
The metadata provided by usvg has unreliable sizes. Ignore it, and rely
on the `width`, `height` and `viewBox` attributes instead.
Note that inline SVG with a natural aspect ratio but no natural sizes
should stretch to the containing block. This is left for a follow-up.
Bumps Stylo to https://github.com/servo/stylo/pull/229
Testing: Improves several WPT.
---------
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
- Focus on mousedown instead of mouse click according to
[spec](https://w3c.github.io/uievents/#handle-native-mouse-down)
- Refactor to follow spec closer and make things more clear.
- Add some spec link.
- Remove some dead spec link.
Still some preparation before implementing #38435.
Testing: No regression in WebDriver & WPT. But update some outdated
test.
Fixes: #38588
---------
Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
Also make TrustedHTML work the same as TrustedScript by
only taking 1 `&str` to make things easier.
Part of #36258
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Properly send `mouseleave` events when the cursor moves between
`<iframe>`s. This allows a better handling of cursor changes and status
text updates. Specifically, we do not need to continuously update the
cursor and the value can be cached in the `Document`. In addition,
status updates can now be sent properly when moving focus between
`<iframe>`s.
Note that style updates for `:hover` values are still broken, but less
so than before. Now the hover state on the `Node` is updated, but for
some
reason the restyle isn't taking place properly. This maintains the
status quo as far as behavior goes when hover moves between `<iframe>`s.
This change also adds a helper data structure to `Document` which will
eventually be responsible for event handling.
Testing: Cursor and status change are currently very hard to test as
the API test harness makes this difficult at the moment.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>