aboutsummaryrefslogtreecommitdiffstats
path: root/components/servo
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2025-04-02 00:59:50 +0200
committerGitHub <noreply@github.com>2025-04-01 22:59:50 +0000
commit4402b7cf8f56aa6e62a13dd1997b570e7331b72e (patch)
treefa68aa51981c263fd3ee66e816fd600322b35b19 /components/servo
parent0d38d6239a4356928c2a7ec0a3cd53ecc32096b0 (diff)
downloadservo-4402b7cf8f56aa6e62a13dd1997b570e7331b72e.tar.gz
servo-4402b7cf8f56aa6e62a13dd1997b570e7331b72e.zip
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>
Diffstat (limited to 'components/servo')
-rw-r--r--components/servo/examples/winit_minimal.rs1
-rw-r--r--components/servo/lib.rs93
2 files changed, 0 insertions, 94 deletions
diff --git a/components/servo/examples/winit_minimal.rs b/components/servo/examples/winit_minimal.rs
index 49d0c96f806..c4995a54224 100644
--- a/components/servo/examples/winit_minimal.rs
+++ b/components/servo/examples/winit_minimal.rs
@@ -102,7 +102,6 @@ impl ApplicationHandler<WakerEvent> for App {
}),
window_delegate.clone(),
Default::default(),
- Default::default(),
);
servo.setup_logging();
diff --git a/components/servo/lib.rs b/components/servo/lib.rs
index 7027fa77972..e61a08fff89 100644
--- a/components/servo/lib.rs
+++ b/components/servo/lib.rs
@@ -24,7 +24,6 @@ mod servo_delegate;
mod webview;
mod webview_delegate;
-use std::borrow::Cow;
use std::cell::{Cell, RefCell};
use std::cmp::max;
use std::collections::HashMap;
@@ -264,7 +263,6 @@ impl Servo {
rendering_context: Rc<dyn RenderingContext>,
mut embedder: Box<dyn EmbedderMethods>,
window: Rc<dyn WindowMethods>,
- user_agent: Option<String>,
user_content_manager: UserContentManager,
) -> Self {
// Global configuration options, parsed from the command line.
@@ -288,24 +286,6 @@ impl Servo {
media_platform::init();
}
- let user_agent = match user_agent {
- Some(ref ua) if ua == "ios" => default_user_agent_string_for(UserAgent::iOS).into(),
- Some(ref ua) if ua == "android" => {
- default_user_agent_string_for(UserAgent::Android).into()
- },
- Some(ref ua) if ua == "desktop" => {
- default_user_agent_string_for(UserAgent::Desktop).into()
- },
- Some(ref ua) if ua == "ohos" => {
- default_user_agent_string_for(UserAgent::OpenHarmony).into()
- },
- Some(ua) => ua.into(),
- None => embedder
- .get_user_agent_string()
- .map(Into::into)
- .unwrap_or(default_user_agent_string_for(DEFAULT_USER_AGENT).into()),
- };
-
// Get GL bindings
let webrender_gl = rendering_context.gleam_gl_api();
@@ -486,7 +466,6 @@ impl Servo {
protocols.merge(embedder.get_protocol_handlers());
let constellation_chan = create_constellation(
- user_agent,
opts.config_dir.clone(),
embedder_proxy,
compositor_proxy.clone(),
@@ -533,7 +512,6 @@ impl Servo {
shutdown_state: shutdown_state.clone(),
},
opts.debug.convert_mouse_to_touch,
- embedder.get_version_string().unwrap_or_default(),
);
Self {
@@ -1041,7 +1019,6 @@ fn create_compositor_channel(
#[allow(clippy::too_many_arguments)]
fn create_constellation(
- user_agent: Cow<'static, str>,
config_dir: Option<PathBuf>,
embedder_proxy: EmbedderProxy,
compositor_proxy: CompositorProxy,
@@ -1066,7 +1043,6 @@ fn create_constellation(
BluetoothThreadFactory::new(embedder_proxy.clone());
let (public_resource_threads, private_resource_threads) = new_resource_threads(
- user_agent.clone(),
devtools_sender.clone(),
time_profiler_chan.clone(),
mem_profiler_chan.clone(),
@@ -1105,7 +1081,6 @@ fn create_constellation(
#[cfg(not(feature = "webxr"))]
webxr_registry: None,
webgl_threads,
- user_agent,
webrender_external_images: external_images,
#[cfg(feature = "webgpu")]
wgpu_image_map,
@@ -1229,71 +1204,3 @@ fn create_sandbox() {
fn create_sandbox() {
panic!("Sandboxing is not supported on Windows, iOS, ARM targets and android.");
}
-
-enum UserAgent {
- Desktop,
- Android,
- OpenHarmony,
- #[allow(non_camel_case_types)]
- iOS,
-}
-
-fn get_servo_version() -> &'static str {
- env!("CARGO_PKG_VERSION")
-}
-
-fn default_user_agent_string_for(agent: UserAgent) -> String {
- let servo_version = get_servo_version();
-
- #[cfg(all(target_os = "linux", target_arch = "x86_64", not(target_env = "ohos")))]
- let desktop_ua_string =
- format!("Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Servo/{servo_version} Firefox/128.0");
- #[cfg(all(
- target_os = "linux",
- not(target_arch = "x86_64"),
- not(target_env = "ohos")
- ))]
- let desktop_ua_string =
- format!("Mozilla/5.0 (X11; Linux i686; rv:128.0) Servo/{servo_version} Firefox/128.0");
-
- #[cfg(all(target_os = "windows", target_arch = "x86_64"))]
- let desktop_ua_string = format!(
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Servo/{servo_version} Firefox/128.0"
- );
- #[cfg(all(target_os = "windows", not(target_arch = "x86_64")))]
- let desktop_ua_string =
- format!("Mozilla/5.0 (Windows NT 10.0; rv:128.0) Servo/{servo_version} Firefox/128.0");
-
- #[cfg(target_os = "macos")]
- let desktop_ua_string = format!(
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Servo/{servo_version} Firefox/128.0"
- );
-
- #[cfg(any(target_os = "android", target_env = "ohos"))]
- let desktop_ua_string = "".to_string();
-
- match agent {
- UserAgent::Desktop => desktop_ua_string,
- UserAgent::Android => {
- format!("Mozilla/5.0 (Android; Mobile; rv:128.0) Servo/{servo_version} Firefox/128.0")
- },
- UserAgent::OpenHarmony => format!(
- "Mozilla/5.0 (OpenHarmony; Mobile; rv:128.0) Servo/{servo_version} Firefox/128.0"
- ),
- UserAgent::iOS => format!(
- "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X; rv:128.0) Servo/{servo_version} Firefox/128.0"
- ),
- }
-}
-
-#[cfg(target_os = "android")]
-const DEFAULT_USER_AGENT: UserAgent = UserAgent::Android;
-
-#[cfg(target_env = "ohos")]
-const DEFAULT_USER_AGENT: UserAgent = UserAgent::OpenHarmony;
-
-#[cfg(target_os = "ios")]
-const DEFAULT_USER_AGENT: UserAgent = UserAgent::iOS;
-
-#[cfg(not(any(target_os = "android", target_os = "ios", target_env = "ohos")))]
-const DEFAULT_USER_AGENT: UserAgent = UserAgent::Desktop;