mirror of
https://github.com/servo/servo.git
synced 2025-09-16 09:58:23 +01:00
fixup: Enable viewport <meta> tag support for mobile platforms only (#39207)
1. Adds a pref viewport_meta_enabled. 2. Enable pref for mobile platforms. Testing: Tested Manually Fixes: #39157 Fixes: #39002 --------- Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
This commit is contained in:
parent
e6d46fb9f3
commit
dfdcba88d4
4 changed files with 17 additions and 6 deletions
|
@ -264,7 +264,8 @@ pub struct Preferences {
|
||||||
/// The user-agent to use for Servo. This can also be set via [`UserAgentPlatform`] in
|
/// The user-agent to use for Servo. This can also be set via [`UserAgentPlatform`] in
|
||||||
/// order to set the value to the default value for the given platform.
|
/// order to set the value to the default value for the given platform.
|
||||||
pub user_agent: String,
|
pub user_agent: String,
|
||||||
|
/// Whether or not the viewport meta tag is enabled.
|
||||||
|
pub viewport_meta_enabled: bool,
|
||||||
pub log_filter: String,
|
pub log_filter: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,6 +432,7 @@ impl Preferences {
|
||||||
threadpools_webrender_workers_max: 4,
|
threadpools_webrender_workers_max: 4,
|
||||||
webgl_testing_context_creation_error: false,
|
webgl_testing_context_creation_error: false,
|
||||||
user_agent: String::new(),
|
user_agent: String::new(),
|
||||||
|
viewport_meta_enabled: false,
|
||||||
log_filter: String::new(),
|
log_filter: String::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ use compositing_traits::viewport_description::ViewportDescription;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use html5ever::{LocalName, Prefix, local_name, ns};
|
use html5ever::{LocalName, Prefix, local_name, ns};
|
||||||
use js::rust::HandleObject;
|
use js::rust::HandleObject;
|
||||||
|
use servo_config::pref;
|
||||||
use style::str::HTML_SPACE_CHARACTERS;
|
use style::str::HTML_SPACE_CHARACTERS;
|
||||||
|
|
||||||
use crate::dom::attr::Attr;
|
use crate::dom::attr::Attr;
|
||||||
|
@ -64,9 +65,7 @@ impl HTMLMetaElement {
|
||||||
if name == "referrer" {
|
if name == "referrer" {
|
||||||
self.apply_referrer();
|
self.apply_referrer();
|
||||||
}
|
}
|
||||||
if (cfg!(target_os = "android") || cfg!(target_os = "ios") || cfg!(target_env = "ohos")) &&
|
if name == "viewport" {
|
||||||
name == "viewport"
|
|
||||||
{
|
|
||||||
self.parse_and_send_viewport_if_necessary();
|
self.parse_and_send_viewport_if_necessary();
|
||||||
}
|
}
|
||||||
// https://html.spec.whatwg.org/multipage/#attr-meta-http-equiv
|
// https://html.spec.whatwg.org/multipage/#attr-meta-http-equiv
|
||||||
|
@ -125,6 +124,10 @@ impl HTMLMetaElement {
|
||||||
|
|
||||||
/// <https://drafts.csswg.org/css-viewport/#parsing-algorithm>
|
/// <https://drafts.csswg.org/css-viewport/#parsing-algorithm>
|
||||||
fn parse_and_send_viewport_if_necessary(&self) {
|
fn parse_and_send_viewport_if_necessary(&self) {
|
||||||
|
if !pref!(viewport_meta_enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Skip processing if this isn't the top level frame
|
// Skip processing if this isn't the top level frame
|
||||||
if !self.owner_window().is_top_level() {
|
if !self.owner_window().is_top_level() {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -51,7 +51,7 @@ pub fn init(
|
||||||
let mut args = mem::take(&mut init_opts.args);
|
let mut args = mem::take(&mut init_opts.args);
|
||||||
args.insert(0, "servo".to_string());
|
args.insert(0, "servo".to_string());
|
||||||
|
|
||||||
let (opts, preferences, servoshell_preferences) = match parse_command_line_arguments(args) {
|
let (opts, mut preferences, servoshell_preferences) = match parse_command_line_arguments(args) {
|
||||||
ArgumentParsingResult::ContentProcess(..) => {
|
ArgumentParsingResult::ContentProcess(..) => {
|
||||||
unreachable!("Android does not have support for multiprocess yet.")
|
unreachable!("Android does not have support for multiprocess yet.")
|
||||||
},
|
},
|
||||||
|
@ -64,6 +64,8 @@ pub fn init(
|
||||||
ArgumentParsingResult::ErrorParsing => std::process::exit(1),
|
ArgumentParsingResult::ErrorParsing => std::process::exit(1),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
preferences.set_value("viewport_meta_enabled", servo::PrefValue::Bool(true));
|
||||||
|
|
||||||
crate::init_tracing(servoshell_preferences.tracing_filter.as_deref());
|
crate::init_tracing(servoshell_preferences.tracing_filter.as_deref());
|
||||||
|
|
||||||
let (display_handle, window_handle) = unsafe {
|
let (display_handle, window_handle) = unsafe {
|
||||||
|
|
|
@ -146,7 +146,7 @@ pub fn init(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let (opts, preferences, servoshell_preferences) = match parse_command_line_arguments(args) {
|
let (opts, mut preferences, servoshell_preferences) = match parse_command_line_arguments(args) {
|
||||||
ArgumentParsingResult::ContentProcess(..) => {
|
ArgumentParsingResult::ContentProcess(..) => {
|
||||||
unreachable!("OHOS does not have support for multiprocess yet.")
|
unreachable!("OHOS does not have support for multiprocess yet.")
|
||||||
},
|
},
|
||||||
|
@ -157,6 +157,10 @@ pub fn init(
|
||||||
ArgumentParsingResult::ErrorParsing => std::process::exit(1),
|
ArgumentParsingResult::ErrorParsing => std::process::exit(1),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if native_values.device_type == ohos_deviceinfo::OhosDeviceType::Phone {
|
||||||
|
preferences.set_value("viewport_meta_enabled", servo::PrefValue::Bool(true));
|
||||||
|
}
|
||||||
|
|
||||||
if servoshell_preferences.log_to_file {
|
if servoshell_preferences.log_to_file {
|
||||||
let mut servo_log = PathBuf::from(&native_values.cache_dir);
|
let mut servo_log = PathBuf::from(&native_values.cache_dir);
|
||||||
servo_log.push("servo.log");
|
servo_log.push("servo.log");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue