diff options
author | Jonathan Schwender <55576758+jschwe@users.noreply.github.com> | 2024-05-02 20:32:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 18:32:51 +0000 |
commit | ca064eaa518f407988751ce51834eff3d65b681c (patch) | |
tree | bec3b09c5992c7baffbde66f3ad01572b06d4f4f /components/servo/lib.rs | |
parent | 9acf2182cd440d4080bb0eb2a2fbc7238d71e953 (diff) | |
download | servo-ca064eaa518f407988751ce51834eff3d65b681c.tar.gz servo-ca064eaa518f407988751ce51834eff3d65b681c.zip |
Add font-fallback on OpenHarmony and fix several compilation issues (#32141)
* Add OpenHarmony support for allocator / profile
Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
* gfx: Build harfbuzz from source on OHOS
Updates `freetype-sys` to v0.20.1, which includes a build
fix for OpenHarmony.
Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
* gfx: Don't depend on fontconfig on OpenHarmony
Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
* gfx: Add ohos font fallback
Hardcode HarmonyOS_Sans_SC_Regular for Chinese
Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
* libservo: OHOS useragent, and explicitly opt out of sandboxing
Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
* libservo: Disable get_native_media_display_and_gl_context on ohos
Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
---------
Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
Diffstat (limited to 'components/servo/lib.rs')
-rw-r--r-- | components/servo/lib.rs | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/components/servo/lib.rs b/components/servo/lib.rs index a638c2942ab..28ae62f1fec 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -42,7 +42,8 @@ use compositing_traits::{ not(target_os = "ios"), not(target_os = "android"), not(target_arch = "arm"), - not(target_arch = "aarch64") + not(target_arch = "aarch64"), + not(target_env = "ohos"), ))] use constellation::content_process_sandbox_profile; use constellation::{ @@ -58,7 +59,8 @@ use euclid::Scale; not(target_os = "ios"), not(target_os = "android"), not(target_arch = "arm"), - not(target_arch = "aarch64") + not(target_arch = "aarch64"), + not(target_env = "ohos"), ))] use gaol::sandbox::{ChildSandbox, ChildSandboxMethods}; use gfx::font_cache_thread::FontCacheThread; @@ -81,12 +83,12 @@ use script_traits::{ScriptToConstellationChan, WindowSizeData}; use servo_config::{opts, pref, prefs}; use servo_media::player::context::GlContext; use servo_media::ServoMedia; -#[cfg(target_os = "linux")] +#[cfg(all(target_os = "linux", not(target_env = "ohos")))] use surfman::platform::generic::multi::connection::NativeConnection as LinuxNativeConnection; -#[cfg(target_os = "linux")] +#[cfg(all(target_os = "linux", not(target_env = "ohos")))] use surfman::platform::generic::multi::context::NativeContext as LinuxNativeContext; use surfman::{GLApi, GLVersion}; -#[cfg(target_os = "linux")] +#[cfg(all(target_os = "linux", not(target_env = "ohos")))] use surfman::{NativeConnection, NativeContext}; use webrender::{RenderApiSender, ShaderPrecacheFlags}; use webrender_api::{ @@ -253,6 +255,9 @@ where 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() @@ -492,7 +497,7 @@ where } } - #[cfg(target_os = "linux")] + #[cfg(all(target_os = "linux", not(target_env = "ohos")))] fn get_native_media_display_and_gl_context( rendering_context: &RenderingContext, ) -> Option<(NativeDisplay, GlContext)> { @@ -529,7 +534,10 @@ where Some((native_display, gl_context)) } - #[cfg(not(any(target_os = "windows", target_os = "linux")))] + #[cfg(not(any( + target_os = "windows", + all(target_os = "linux", not(target_env = "ohos")) + )))] fn get_native_media_display_and_gl_context( _rendering_context: &RenderingContext, ) -> Option<(NativeDisplay, GlContext)> { @@ -1196,7 +1204,8 @@ pub fn run_content_process(token: String) { not(target_os = "ios"), not(target_os = "android"), not(target_arch = "arm"), - not(target_arch = "aarch64") + not(target_arch = "aarch64"), + not(target_env = "ohos"), ))] fn create_sandbox() { ChildSandbox::new(content_process_sandbox_profile()) @@ -1209,7 +1218,8 @@ fn create_sandbox() { target_os = "ios", target_os = "android", target_arch = "arm", - target_arch = "aarch64" + target_arch = "aarch64", + target_env = "ohos", ))] fn create_sandbox() { panic!("Sandboxing is not supported on Windows, iOS, ARM targets and android."); @@ -1218,15 +1228,20 @@ fn create_sandbox() { enum UserAgent { Desktop, Android, + OpenHarmony, #[allow(non_camel_case_types)] iOS, } fn default_user_agent_string_for(agent: UserAgent) -> &'static str { - #[cfg(all(target_os = "linux", target_arch = "x86_64"))] + #[cfg(all(target_os = "linux", target_arch = "x86_64", not(target_env = "ohos")))] const DESKTOP_UA_STRING: &'static str = "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Servo/1.0 Firefox/111.0"; - #[cfg(all(target_os = "linux", not(target_arch = "x86_64")))] + #[cfg(all( + target_os = "linux", + not(target_arch = "x86_64"), + not(target_env = "ohos") + ))] const DESKTOP_UA_STRING: &'static str = "Mozilla/5.0 (X11; Linux i686; rv:109.0) Servo/1.0 Firefox/111.0"; @@ -1241,12 +1256,13 @@ fn default_user_agent_string_for(agent: UserAgent) -> &'static str { const DESKTOP_UA_STRING: &'static str = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Servo/1.0 Firefox/111.0"; - #[cfg(target_os = "android")] + #[cfg(any(target_os = "android", target_env = "ohos"))] const DESKTOP_UA_STRING: &'static str = ""; match agent { UserAgent::Desktop => DESKTOP_UA_STRING, UserAgent::Android => "Mozilla/5.0 (Android; Mobile; rv:109.0) Servo/1.0 Firefox/111.0", + UserAgent::OpenHarmony => "Mozilla/5.0 (OpenHarmony; Mobile; rv:109.0) Servo/1.0 Firefox/111.0", UserAgent::iOS => { "Mozilla/5.0 (iPhone; CPU iPhone OS 16_4 like Mac OS X; rv:109.0) Servo/1.0 Firefox/111.0" }, @@ -1256,8 +1272,11 @@ fn default_user_agent_string_for(agent: UserAgent) -> &'static str { #[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")))] +#[cfg(not(any(target_os = "android", target_os = "ios", target_env = "ohos")))] const DEFAULT_USER_AGENT: UserAgent = UserAgent::Desktop; |