This is a preparation for publishing to crates.io. Changes include:
- Add `servo-` prefixes to avoid name collisions on crates.io
- Use `-` instead of `_` in package names.
- Rename the crates to their original names in Cargo.toml,
to keep the diff minimal
- Rename `media` to `servo-media-thread` to avoid name collision with
`servo-media` (originally from the media repository).
This is an outcome of the previous discussion at [#general > Switch
remaining git dependencies to
crates.io](https://servo.zulipchat.com/#narrow/channel/263398-general/topic/Switch.20remaining.20git.20dependencies.20to.20crates.2Eio/with/576336288)
Testing: This should be mostly covered by our CI, but some amount of
breakage is to be expected, since some package names could still be
referenced from scripts which are not tested or run in CI. [mach try
run](https://github.com/jschwe/servo/actions/runs/22502945949)
---------
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Remove embedder defined `ScrollEvent` and merge the payload of it to the
`SetScrollStates` message which tell the `ScriptThread` to update the
scroll state.
In the past, `ScrollEvent` is defined as a embedder's `InputEvent` and
being used only to forward the external scroll node id for a node that
is considered scrolled. This make us sends an additional message to
constellation and additionally, `ScrollEvent` went through lengthy
pipelines as it was deemed as an embedder input event, albeit being a
synthetic input fired by `WebviewRenderer`.
Subsequently, we could introduce a flag to detect whether the scrolling
is still ongoing or not (like whether it is still flinging) for
`scrollend` event.
Testing: No WPT changes
---------
Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Following the convention of other major UAs of gating the virtual
keyboard by certain user activation, adding a flags to let the embedder
knows about the user activation. This would be used to determine whether
the virtual keyboard needs to be shown or not in android and ohos.
Testing: Manual testing.
---------
Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This implements MallocSizeOf for DevtoolsInstance. Major changes:
- Newtype for ActorRegistry because AtomicRefCell<HashMap<String,
Arc<dyn Actor>>> did not like mallocsizeof (even with trait bound on
Actor)
- Implement MallocSizeOf for BTreeSet.
- Implement MallocSizeOf of 0 for AtomicU32 and TcpStream
- Ignore a couple of MallocSizeof for http::Method, http::HeaderMap and
json::Value
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: Compilation is the test.
Fixes: Part of addressing https://github.com/servo/servo/issues/42453
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
We implemented many more MallocSizeOf tests (even if some such as
channels are zero).
Meaning we can not ignore more of it making the code cleaner.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: Compilation is the test.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
As you can tell from branch name, the initial goal is to add multi-touch
support for touchmove.
But things get too messy, so I decide to split into two PRs.
This PR
- Track `TouchId` in `PendingTouchInputEvent`
- Rename `id` to `touch_id` for `TouchId`. This is to make distinction
from `id: InputEventId`,
which became very confusing while implementing the initial goal.
Testing: No behaviour change.
Part of #41923
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
The patch adds the following functionality to the per-WebView
`UserContentManager` API.
- Removing a `UserScript` at that was previously added.
- Adding a new `UserStyleSheet` representing a user-origin style sheet.
allow removing user script
- Removing a previously added `UserStyleSheet`.
There might be scope for some improvements in the API:
- `UserScript` and `UserStyleSheet` have different ways of representing
the source location - a `PathBuf` and `Url` respectively. This is due to
how those values are used by the underlying evaluation APIs in script
and stylo. More investigation is needed here and could be addressed in
future patches.
Testing: New unit tests are added for the user stylesheet APIs. Existing
tests have been updated to test the removal of user scripts.
This moves WebGL component from IpcChannel to GenericChannel. Of note
are the following changes:
- Removal of WebGlSender and WebGlReceiver type alias. As we removed
them in a similar component earlier.
- Moving from IpcByteSender to IpcSender over serde_bytes::ByteBuf. I
think the tradeoff for easier reading is worth it.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: Compilation and unit tests.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Co-authored-by: Sam <16504129+sagudev@users.noreply.github.com>
#41857 exposed some more code in the net crate that performed blocking
communication with the embedder and could prevent other networking tasks
from running. To address that, we need the net code to perform async
receive operations, which requires passing tokio channels to the
embedder.
However, the current embedding message design puts all messages in the
same enum and requires that they are serializable. Embedder messages
from the network do not require this property, since they run in the
same process as the embedder. Therefore, this PR creates a new
EmbedderProxy structure that is generic over the message, allowing each
component of Servo to use a embedder message type that is specific to
that component.
The final benefit of this set of changes is that the embedder messages
for a particular crate can now live in the crate itself (since the only
crate that depends on it is the servo crate), not in the shared
`embedding_traits` crate. This hugely reduces the amount of code that
needs to be rebuilt when changing these messages, enabling much faster
incremental builds for those changes.
Testing: Strictly refactoring; existing test coverage is sufficient.
Fixes: #41958
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Retrieving the origin from the document's URL means the wrong origin can
be returned for documents like about:blank or about:srcdoc.
Testing: Newly-passing test involving a srcdoc and blob.
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Fix caching before the console is opened and stop sending messages
prematurely.
Fix line numbers not showing in console messages because of a missing
`rename_all`.
Remove `getCachedMessages` in favour of sending a list of messages as a
reply to the `watchResources` for `console-message`/`error-message` in
the watcher.
Remove `startListeners` and `stopListeners`. These are legacy methods of
watching properties before the watcher actor. It is preferred to enable
properties in `supported_resources` in the watcher than to use these
messages.
Remove `clearMessagesCache`, only `clearMessagesCacheAsync` seems to be
used now. Add a reply to `clearMessagesCacheAsync`.
Simplify a bit the structs for console messages and prefer serde's
annotations to manual serialization. Merge `handle_console_message` and
`handle_page_error`, and improve the usability of `ConsoleResource`.
Fix some fields in console messages. We are missing `source_id` for now.
This will be easier to add after better support for source actors. We
are also missing stack traces.
| Before | After |
| --- | --- |
| 
| 
|
Testing: Manual testing
Fixes: #26666
---------
Signed-off-by: eri <eri@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This change improves the counting of clicks for mouse button events by
ensuring that `detail` property of those events includes the click
count. This `detail` differs from that of `dblclick` events where the
`detail` is always 2. In addition, it ensures that the click count can
increase for mouse buttons that do not cause `click` and `dblclick`
events (such as the right mouse button).
Testing: This change adds two Servo-specific WPT-style tests. While this
behavior is specified a bit, the details are implementation specific.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Follow-up to #41823.
Now that we always execute JS with callback, we can safely remove the
obsolete sync script handler.
- Rename `ExecuteAsyncScript` to `ExecuteScriptWithCallback`
- Remove `ExecuteScript` related logic.
- Rewrite async callback wrapper to simplify things.
Testing: I expect no change in behaviour. See if WPT tests agree with
it.
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This changes routed_promise to use the GenericCallback functionality.
This mostly effected WebGPU but also Clipboard and Memory Reporting.
We also added a GenericCallback::new_blocking() functionality which
produces a callback and a channel
which then can be blocked on. This was used a couple of times in the
code.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: This should not change functionality.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
With this we stop exporting ipc-channel in libservo and switch to
GenericChannel/GenericCallback.
Testing: Generic Channels are tested all over the place.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Changed most #[allow]s to #[expect]s, mainly for
clippy::too_many_arguments
Removed unfulfilled expectations
This is my first opensource contribution, so please let me know if
anything should
be done differently.
Testing: Refactor
Part of: #40838
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: TimurBora <timurborisov5561@gmail.com>
Co-authored-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
In the future, servo components should depend on the generic channels in
base instead of IpcChannels to correctly optimize for multiprocess vs
non-multiprocess mode.
This reexports IpcSharedMemory as GenericSharedMemory in GenericChannel
and changes all dependencies on it.
Currently this is only a type/name change and does not change
functionality. But in the future we would want want to use non-ipc
things for the data.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: This changes types and does not need testing.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This change moves the `UserContentManager` abstraction from the
`ServoBuilder` to `WebViewBuilder` so that embedders can inject content
for each `WebView` independently. It also adds basic support for runtime
mutations to the `UserContentManager` API. Only adding new scripts is
currently supported, but future changes will add support for both other
mutations such as removal of scripts and addition & removal of
stylesheets. Future changes could also optimize the way mutations are
propagated to `ScriptThread`s by sending just the "delta" rather than
the whole `UserContents` structure for each mutation.
The `UserContentManager` now becomes just a convenient handle for the
embedders to invoke the mutation API while the actual management of the
manager's content is handled by the Constellation. The mutations are
relayed to the constellation via messages. The change also separates the
serialized version containg the user contents into a new `UserContent`
structure so that the API cannot be misused.
Testing: New unit tests have been added for the different scenarios
involving UserContentManager.
---------
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Put the Gamepad API and its supporting infrastructure behind a `gamepad`
feature flag. This allows embedders to opt-out of gamepad support at
compile time to save on binary size and reduce dependencies.
Testing:
1. `./mach build -d` (Gamepad enabled by default)
2. `cargo build -p servoshell --no-default-features --features
"libservo/clipboard,js_jit,max_log_level,webgpu"` (Gamepad Disabled)
3. `cargo build -p servoshell --features "gamepad,webxr,..."` (Gamepad &
WebXR Enabled)
Fixes: #40897
Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
- Use the generic channel for webdriver.
- Implement try_receive_timeout for GenericReceiver.
Testing: WPT should still work.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Route console messages through the embedding API instead of printing
directly, giving embedders control over console output handling.
Testing: Should be covered by exsisting tests
Fixes: #41145
Signed-off-by: atbrakhi <atbrakhi@igalia.com>
This change makes it is that WebDriver can create whole new windows for
each new `WebView` in servoshell. The motivation for this is:
1. This is how the WebDriver specification is written. The command that
create a new WebView is actually called "New Window" [^1], so this
increases compliance with the specification and now we obey the
type hint sent with that command.
2. This change allows testing multi-window support via the WPT.
3. This will allow adding optimizations (#39923) that are otherwise
impossible because the WPT expects all open `WebView` to be live and
visible.
This does not make the change yet for windows opened via `window.open()`
(popups), as that requires #41220 to fix. In order to make this possible
a few changes to the code had to take place:
1. The new `PlatformWindow` creation function has to be passed down to
the WebDriver handler, which normally doesn't know how to make
`PlatformWindow`s.
2. This allows moving the UI command code back to the shared part of
servoshell, meaning that the embedded ports can use it as well
eventually.
3. Headless windows need a real id to differeniate them now intead of
just 0.
4. When dropping the headless `PlatformWindow` we need to make it
current. I'm not sure why surfman doesn't do this, but this is now
necessary as there are multiple contexts. This is also true when
resizing the `RenderingContext`.
Finally, errors when making the context current are upgraded to
`error!`s as they typically break the entire execution of the program.
[^1]: https://w3c.github.io/webdriver/#new-window
Testing: This is tested by the entire WPT suite.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
For a long time, the "Compositor" hasn't done any compositing. This is
handled by WebRender. In addition the "Compositor" does many other
tasks. This change renames `IOCompositor` to `Paint`.
`Paint` is Servo's paint subsystem and contains multiple `Painter`s.
This change does not rename the crate; that will be done in a
followup change.
Testing: This just renames types and updates comments, so no new tests
are necessary.
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This implements a GenericOneshot channel. The size in the crossbeam
channel is restricted while in the Ipc case we use the same
IpcChannel(for now).
We also use these channels in WebDriver to prove they work.
Testing: Unit Tests and compilation still works.
Fixes: https://github.com/servo/servo/issues/39019
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Finish exposing the `SimpleDialog` API in libservo, abstracting away the
response senders into structures with methods. In addition, add a
default behavior so that embedders do not have to explicitly send a
reponse when dialogs are ignored. This makes the API much harder to
misuse.
Finally, the WebDriver API for setting the prompt dialog entry
field is corrected to actually set that value rather than the message.
This makes sense as part of this change as the type safety of the
structures makes setting the message (the old, wrong behavior) harder
to implement.
Testing: This causes a WebDriver conformance test to start passing.
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
To ensure that tests that modify cookies but don't finish cleanly don't
leave cookie values that interfere with subsequent tests, we need to
clear the cookie storage in between each test that's run.
Testing: Can't test the test runner, just have to watch the patterns in
our test runs.
Fixes: #40668Fixes: #40672Fixes: #40673Fixes: #40674Fixes: #40695Fixes: #40697
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This change is a major re-architecture of servoshell to support multiple
windows. Unfortunately it was not possible to do this incrementally, but
@mukilan and I did this together so we feel more confident about these
changes.
The main change here is that now the `HashMap` of windows that `App`
has can be filled with more than one `ServoShellWindow`.
`ServoShellWindow` is a wrapper around a `PlatformWindow` which can
either be headed, headless, or for embedded platforms. Embedded
platforms (Android and OHOS) are only expected to have a single window,
but there is no reason that more windows cannot be added.
There is still a little bit more work to be done in order to fully
enable
mulitple windows, so this change is just the architectural preparation.
This change enables the embedded and desktop versions of servoshell to
start to be fully integrated so that the entire `RunningAppState` is
shared between them.
Testing: servoshell is the test harness so these changes are covered
by the WPT tests.
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
The `scripts_traits` crate was the only crate depending on `strum` with
the
`derive` feature. This accidentally allowed other crates to import strum
macros via `strum::` without declaring their own dependency on
`strum_macros`,
causing compilation issues when running `./mach test-unit -p net`.
This PR makes the imports consistent across the code base by:
- replacing all `strum_macro::` imports with `strum::` imports
- removing strum_macro dependencies
- adding derive feature to the strum workspace
Testing: Unit tests continue to pass
Signed-off-by: Jan Varga <jvarga@igalia.com>
This implements step 2 of the web-facing API's.
Now, the embedder receives a notification whether
a webpage wants to register/unregister a protocol
handler. They can't do anything with it yet, that's for a follow-up PR.
But locally testing shows the
following debug log:
```
pid:35180 Requesting to Register for scheme web+test with url https://web-platform.test:8443/html/webappapis/system-state-and-capabilities/the-navigator-object/%s
```
Part of #40615
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Instead of having a global `RefreshDriver` for all of Servo, let each
`RenderingContext` have its own `RefreshDriver`. This allows for things
like per-monitor `RefreshDriver`s and helps to ensure that multiple
`BaseRefreshDriver`s can be created for the same `RefreshDriver`.
Testing: This shouldn't change behavior and thus is covered by existing
tests.
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
The tests now start running rather than erroring, but they aren't
working yet as we don't currently use protocol handlers yet. That's for
follow-up PRs, as that requires more plumbing.
Part of #40615
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Every time a touchmove event is added, it updates the cursor, causing
frequent hit testing and affecting the performance of scrolling. Adding
a flag to mark the current touchmove is done for compatibility with
touch events. In this case, the last_mouse_move_position will not be
updated.
Testing: No new use cases will be approved; it's just for performance
optimization.
Fixes: A solution for #39433
Signed-off-by: kongbai1996 <1782765876@qq.com>
This new data structure allows passing more information when popping up
context menus. It's possible in the future that it will be adapted into
a more generic "hit test result" type API ala WebKit, but for now, this
is probably
enough.
Testing: This change includes new API test assertions.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Add context menu options for images, links, and editable text areas. In
addition add the ability to show menu options that are disabled. This
also improves the visual style of the context menu in egui as part of
supporting disabled options.
Testing: This has been manually tested, but we could we should be able
to
easily add unit tests when enriching the API with information about the
active element under context menus.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
This PR adds context menu support with clickable menu items in the
Minibrowser. The menu appears on right click and supports basic
navigation actions (Back, Forward, Reload).
Testing: We already have tests for ContextMenu in WebView API test.
Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
RasterImage is now not seralizeable and backed by Vec<u8> storage. Add a
new struct `SharedRasterImage` that allows serializeing. This can be
constructed from RasterImage. This introduces some more copying but I
think the tradeoff is ok. Newly introduced copies are for favicon
response to the embedder and EmbedderNotifications.
Testing: Should not change functionality, so covered by existing tests.
Fixes: https://github.com/servo/servo/issues/39626 and related issues.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Instead of having the `ImageCache` return the broken image icon for
failed loads, have `HTMLImageElement` explicitly request it. This means
that the image is loaded on demand (reducing the usage of resources) and
also simplifying the interface of the `ImageCache` greatly.
In addition, the display of the broken image icon is improved, more
closely matching other browsers. A test for this display (which was
falsely passing before) is updated to reflect the new display of the
broken image icon.
Testing: There is a Servo-specific test for this change. Some WPT tests
start to fail as well. Before these were not properly loading the broken
image icon so they were failing before, just in a hidden way.
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This PR integrates showing context menus into the
`WebViewDelegate::show_embedder_control` API. In addition,
`ContextMenuItem` and `ContextMenuAction` data types are exposed which
abstract away the different components of the context menu. Later
changes will implement this API for servoshell as well as add
element-specific actions such as "Select All" and "Copy Image URL".
Testing: This change adds a WebView API test.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
- Reduces unnecessary type conversion between `ServoUrl`, `Url`, string
slice
- Share `WebDriverCommandMsg::LoadUrl` handler across platform
Testing: Covered by existing test. Manually tested for OHOS.
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This change allows the embedder to pass scroll deltas in either page
pixels or device pixels. In addition, it makes it so that device pixels
are never stored in LayoutVector2D when processing scroll events, which
was very confusing.
Testing: Current tests should cover these changes
Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>