libservo: Remove a couple EmbedderMethods (#36276)

- Remove `EmbedderMethods::get_user_agent_string`. This is now part of
  the `Preferences` data structure, which should allow it to be
  per-`WebView` in the future.
- Remove `EmbedderMethods::get_version_string`. This was used to include
  some data along with WebRender captures about the Servo version. This
  isn't really necessary and it was done to replace code in the past
  that output the WebRender version, so also isn't what the original
  code did. I think we can just remove this entirely.

The idea with these changes is that `EmbedderMethods` can be removed
in a followup and the rest of the methods can be added to
`ServoDelegate`. These two methods are ones that cannot be added to a
delegate as they are used during `Servo` initialization.

Testing: There is currently no testing for libservo. These changes are
meant
as preparation for adding a suite of `WebView` unit tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-04-02 00:59:50 +02:00 committed by GitHub
parent 0d38d6239a
commit 4402b7cf8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 95 additions and 206 deletions

View file

@ -64,7 +64,6 @@ impl DissimilarOriginWindow {
// FIXME(nox): The microtask queue is probably not important
// here, but this whole DOM interface is a hack anyway.
global_to_clone_from.microtask_queue().clone(),
global_to_clone_from.get_user_agent(),
#[cfg(feature = "webgpu")]
global_to_clone_from.wgpu_id_hub(),
Some(global_to_clone_from.is_secure_context()),

View file

@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::borrow::Cow;
use std::cell::{Cell, OnceCell};
use std::collections::hash_map::Entry;
use std::collections::{HashMap, VecDeque};
@ -319,9 +318,6 @@ pub(crate) struct GlobalScope {
#[allow(clippy::vec_box)]
consumed_rejections: DomRefCell<Vec<Box<Heap<*mut JSObject>>>>,
/// An optional string allowing the user agent to be set for testing.
user_agent: Cow<'static, str>,
/// Identity Manager for WebGPU resources
#[ignore_malloc_size_of = "defined in wgpu"]
#[no_trace]
@ -720,7 +716,6 @@ impl GlobalScope {
origin: MutableOrigin,
creation_url: Option<ServoUrl>,
microtask_queue: Rc<MicrotaskQueue>,
user_agent: Cow<'static, str>,
#[cfg(feature = "webgpu")] gpu_id_hub: Arc<IdentityHub>,
inherited_secure_context: Option<bool>,
unminify_js: bool,
@ -754,7 +749,6 @@ impl GlobalScope {
event_source_tracker: DOMTracker::new(),
uncaught_rejections: Default::default(),
consumed_rejections: Default::default(),
user_agent,
#[cfg(feature = "webgpu")]
gpu_id_hub,
#[cfg(feature = "webgpu")]
@ -2920,10 +2914,6 @@ impl GlobalScope {
);
}
pub(crate) fn get_user_agent(&self) -> Cow<'static, str> {
self.user_agent.clone()
}
pub(crate) fn get_https_state(&self) -> HttpsState {
self.https_state.get()
}

View file

@ -8,6 +8,7 @@ use std::sync::LazyLock;
use dom_struct::dom_struct;
use js::rust::MutableHandleValue;
use servo_config::pref;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
@ -192,7 +193,7 @@ impl NavigatorMethods<crate::DomTypeHolder> for Navigator {
// https://html.spec.whatwg.org/multipage/#dom-navigator-useragent
fn UserAgent(&self) -> DOMString {
navigatorinfo::UserAgent(self.global().get_user_agent())
navigatorinfo::UserAgent(&pref!(user_agent))
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-appversion

View file

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::borrow::Cow;
use crate::dom::bindings::str::DOMString;
#[allow(non_snake_case)]
@ -66,8 +64,8 @@ pub(crate) fn Platform() -> DOMString {
}
#[allow(non_snake_case)]
pub(crate) fn UserAgent(user_agent: Cow<'static, str>) -> DOMString {
DOMString::from(&*user_agent)
pub(crate) fn UserAgent(user_agent: &str) -> DOMString {
DOMString::from(user_agent)
}
#[allow(non_snake_case)]

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::borrow::{Cow, ToOwned};
use std::borrow::ToOwned;
use std::cell::{Cell, RefCell, RefMut};
use std::cmp;
use std::collections::hash_map::Entry;
@ -2804,7 +2804,6 @@ impl Window {
unminify_css: bool,
local_script_source: Option<String>,
user_content_manager: UserContentManager,
user_agent: Cow<'static, str>,
player_context: WindowGLContext,
#[cfg(feature = "webgpu")] gpu_id_hub: Arc<IdentityHub>,
inherited_secure_context: Option<bool>,
@ -2831,7 +2830,6 @@ impl Window {
origin,
Some(creator_url),
microtask_queue,
user_agent,
#[cfg(feature = "webgpu")]
gpu_id_hub,
inherited_secure_context,

View file

@ -79,7 +79,6 @@ pub(crate) fn prepare_workerscope_init(
pipeline_id: global.pipeline_id(),
origin: global.origin().immutable().clone(),
creation_url: global.creation_url().clone(),
user_agent: global.get_user_agent(),
inherited_secure_context: Some(global.is_secure_context()),
};
@ -164,7 +163,6 @@ impl WorkerGlobalScope {
MutableOrigin::new(init.origin),
init.creation_url,
runtime.microtask_queue.clone(),
init.user_agent,
#[cfg(feature = "webgpu")]
gpu_id_hub,
init.inherited_secure_context,

View file

@ -4,6 +4,7 @@
use dom_struct::dom_struct;
use js::rust::MutableHandleValue;
use servo_config::pref;
use crate::dom::bindings::codegen::Bindings::WorkerNavigatorBinding::WorkerNavigatorMethods;
use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object};
@ -85,7 +86,7 @@ impl WorkerNavigatorMethods<crate::DomTypeHolder> for WorkerNavigator {
// https://html.spec.whatwg.org/multipage/#dom-navigator-useragent
fn UserAgent(&self) -> DOMString {
navigatorinfo::UserAgent(self.global().get_user_agent())
navigatorinfo::UserAgent(&pref!(user_agent))
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-appversion

View file

@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::borrow::Cow;
use std::sync::Arc;
use base::id::PipelineId;
@ -96,7 +95,6 @@ impl WorkletGlobalScope {
MutableOrigin::new(ImmutableOrigin::new_opaque()),
None,
Default::default(),
init.user_agent.clone(),
#[cfg(feature = "webgpu")]
init.gpu_id_hub.clone(),
init.inherited_secure_context,
@ -185,8 +183,6 @@ pub(crate) struct WorkletGlobalScopeInit {
pub(crate) to_constellation_sender: IpcSender<(PipelineId, ScriptMsg)>,
/// The image cache
pub(crate) image_cache: Arc<dyn ImageCache>,
/// An optional string allowing the user agent to be set for testing
pub(crate) user_agent: Cow<'static, str>,
/// Identity manager for WebGPU resources
#[cfg(feature = "webgpu")]
pub(crate) gpu_id_hub: Arc<IdentityHub>,