mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Add a static_prefs
implementation (#31351)
This will eventually be part of the stylo crate and reduces the diff between our verson of style and upstream's.
This commit is contained in:
parent
31596eb10a
commit
61e778c8e8
20 changed files with 200 additions and 147 deletions
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -5625,6 +5625,10 @@ version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "static_prefs"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "str-buf"
|
name = "str-buf"
|
||||||
version = "1.0.6"
|
version = "1.0.6"
|
||||||
|
@ -5707,6 +5711,7 @@ dependencies = [
|
||||||
"smallbitvec",
|
"smallbitvec",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
|
"static_prefs",
|
||||||
"string_cache",
|
"string_cache",
|
||||||
"style_derive",
|
"style_derive",
|
||||||
"style_traits",
|
"style_traits",
|
||||||
|
|
|
@ -73,6 +73,7 @@ servo_url = { path = "../url", optional = true }
|
||||||
smallbitvec = "2.3.0"
|
smallbitvec = "2.3.0"
|
||||||
smallvec = "1.0"
|
smallvec = "1.0"
|
||||||
static_assertions = "1.1"
|
static_assertions = "1.1"
|
||||||
|
static_prefs = { path = "../style_static_prefs" }
|
||||||
string_cache = { version = "0.8", optional = true }
|
string_cache = { version = "0.8", optional = true }
|
||||||
style_derive = { path = "../style_derive" }
|
style_derive = { path = "../style_derive" }
|
||||||
style_traits = { workspace = true }
|
style_traits = { workspace = true }
|
||||||
|
|
|
@ -63,10 +63,7 @@ fn with_pool_in_place_scope<'scope, R>(
|
||||||
|
|
||||||
/// See documentation of the pref for performance characteristics.
|
/// See documentation of the pref for performance characteristics.
|
||||||
fn work_unit_max() -> usize {
|
fn work_unit_max() -> usize {
|
||||||
#[cfg(feature = "gecko")]
|
static_prefs::pref!("layout.css.stylo-work-unit-size") as usize
|
||||||
return static_prefs::pref!("layout.css.stylo-work-unit-size") as usize;
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return 16;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do a DOM traversal for top-down and (optionally) bottom-up processing, generic over `D`.
|
/// Do a DOM traversal for top-down and (optionally) bottom-up processing, generic over `D`.
|
||||||
|
@ -127,12 +124,7 @@ where
|
||||||
discovered,
|
discovered,
|
||||||
root.as_node().opaque(),
|
root.as_node().opaque(),
|
||||||
work_unit_max,
|
work_unit_max,
|
||||||
(|| {
|
static_prefs::pref!("layout.css.stylo-local-work-queue.in-main-thread") as usize,
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
return static_prefs::pref!("layout.css.stylo-local-work-queue.in-main-thread") as usize;
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return 32;
|
|
||||||
})(),
|
|
||||||
PerLevelTraversalData { current_dom_depth: root.depth() },
|
PerLevelTraversalData { current_dom_depth: root.depth() },
|
||||||
maybe_scope,
|
maybe_scope,
|
||||||
traversal,
|
traversal,
|
||||||
|
|
|
@ -577,13 +577,6 @@ impl<'a, 'b, 'i> RuleBodyItemParser<'i, (), StyleParseErrorKind<'i>>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn font_tech_enabled() -> bool {
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
return static_prefs::pref!("layout.css.font-tech.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for Source {
|
impl Parse for Source {
|
||||||
fn parse<'i, 't>(
|
fn parse<'i, 't>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
|
@ -618,7 +611,8 @@ impl Parse for Source {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Parse optional tech()
|
// Parse optional tech()
|
||||||
let tech_flags = if font_tech_enabled() && input
|
let tech_flags = if static_prefs::pref!("layout.css.font-tech.enabled") &&
|
||||||
|
input
|
||||||
.try_parse(|input| input.expect_function_matching("tech"))
|
.try_parse(|input| input.expect_function_matching("tech"))
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,12 +93,7 @@ fn distribute_one_chunk<'a, 'scope, E, D>(
|
||||||
items,
|
items,
|
||||||
traversal_root,
|
traversal_root,
|
||||||
work_unit_max,
|
work_unit_max,
|
||||||
(|| {
|
static_prefs::pref!("layout.css.stylo-local-work-queue.in-worker") as usize,
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
return static_prefs::pref!("layout.css.stylo-local-work-queue.in-worker") as usize;
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return 0;
|
|
||||||
})(),
|
|
||||||
traversal_data,
|
traversal_data,
|
||||||
Some(scope),
|
Some(scope),
|
||||||
traversal,
|
traversal,
|
||||||
|
|
|
@ -190,13 +190,6 @@ macro_rules! try_parse_one {
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scroll_driven_animations_enabled() -> bool {
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
return static_prefs::pref!("layout.css.scroll-driven-animations.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_one_animation<'i, 't>(
|
fn parse_one_animation<'i, 't>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, 't>,
|
||||||
|
@ -221,7 +214,7 @@ macro_rules! try_parse_one {
|
||||||
try_parse_one!(context, input, fill_mode, animation_fill_mode);
|
try_parse_one!(context, input, fill_mode, animation_fill_mode);
|
||||||
try_parse_one!(context, input, play_state, animation_play_state);
|
try_parse_one!(context, input, play_state, animation_play_state);
|
||||||
try_parse_one!(context, input, name, animation_name);
|
try_parse_one!(context, input, name, animation_name);
|
||||||
if scroll_driven_animations_enabled() {
|
if static_prefs::pref!("layout.css.scroll-driven-animations.enabled") {
|
||||||
try_parse_one!(context, input, timeline, animation_timeline);
|
try_parse_one!(context, input, timeline, animation_timeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,10 +153,7 @@ impl<T> SelectorMap<T> {
|
||||||
namespace_hash: HashMap::default(),
|
namespace_hash: HashMap::default(),
|
||||||
rare_pseudo_classes: SmallVec::new(),
|
rare_pseudo_classes: SmallVec::new(),
|
||||||
other: SmallVec::new(),
|
other: SmallVec::new(),
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
bucket_attributes: static_prefs::pref!("layout.css.bucket-attribute-names.enabled"),
|
bucket_attributes: static_prefs::pref!("layout.css.bucket-attribute-names.enabled"),
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
bucket_attributes: false,
|
|
||||||
count: 0,
|
count: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,12 +262,7 @@ impl ImportRule {
|
||||||
.unwrap_or(ImportLayer::None)
|
.unwrap_or(ImportLayer::None)
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
let supports = if !static_prefs::pref!("layout.css.import-supports.enabled") {
|
||||||
let supports_enabled = static_prefs::pref!("layout.css.import-supports.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
let supports_enabled = false;
|
|
||||||
|
|
||||||
let supports = if !supports_enabled {
|
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
input
|
input
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
//! Parsing of the stylesheet contents.
|
//! Parsing of the stylesheet contents.
|
||||||
|
|
||||||
use crate::counter_style::{parse_counter_style_body, parse_counter_style_name_definition};
|
use crate::counter_style::{parse_counter_style_body, parse_counter_style_name_definition};
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
use crate::custom_properties::parse_name as parse_custom_property_name;
|
use crate::custom_properties::parse_name as parse_custom_property_name;
|
||||||
use crate::error_reporting::ContextualParseError;
|
use crate::error_reporting::ContextualParseError;
|
||||||
use crate::font_face::parse_font_face_block;
|
use crate::font_face::parse_font_face_block;
|
||||||
|
@ -32,7 +31,6 @@ use crate::stylesheets::{
|
||||||
};
|
};
|
||||||
use crate::values::computed::font::FamilyName;
|
use crate::values::computed::font::FamilyName;
|
||||||
use crate::values::{CssUrl, CustomIdent, DashedIdent, KeyframesName};
|
use crate::values::{CssUrl, CustomIdent, DashedIdent, KeyframesName};
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
use crate::Atom;
|
use crate::Atom;
|
||||||
use crate::{Namespace, Prefix};
|
use crate::{Namespace, Prefix};
|
||||||
use cssparser::{
|
use cssparser::{
|
||||||
|
@ -455,10 +453,7 @@ impl<'a, 'b, 'i> NestedRuleParser<'a, 'b, 'i> {
|
||||||
if !self.context.rule_types.contains(CssRuleType::Style) {
|
if !self.context.rule_types.contains(CssRuleType::Style) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#[cfg(feature = "gecko")]
|
static_prefs::pref!("layout.css.nesting.enabled")
|
||||||
return static_prefs::pref!("layout.css.nesting.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn nest_for_rule<R>(&mut self, rule_type: CssRuleType, cb: impl FnOnce(&mut Self) -> R) -> R {
|
fn nest_for_rule<R>(&mut self, rule_type: CssRuleType, cb: impl FnOnce(&mut Self) -> R) -> R {
|
||||||
|
@ -520,16 +515,6 @@ impl<'a, 'b, 'i> NestedRuleParser<'a, 'b, 'i> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn container_queries_enabled() -> bool {
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
return static_prefs::pref!("layout.css.container-queries.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return servo_config::prefs::pref_map()
|
|
||||||
.get("layout.container-queries.enabled")
|
|
||||||
.as_bool()
|
|
||||||
.unwrap_or(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
|
impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
|
||||||
type Prelude = AtRulePrelude;
|
type Prelude = AtRulePrelude;
|
||||||
type AtRule = ();
|
type AtRule = ();
|
||||||
|
@ -556,7 +541,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
|
||||||
"font-face" => {
|
"font-face" => {
|
||||||
AtRulePrelude::FontFace
|
AtRulePrelude::FontFace
|
||||||
},
|
},
|
||||||
"container" if container_queries_enabled() => {
|
"container" if static_prefs::pref!("layout.css.container-queries.enabled") => {
|
||||||
let condition = Arc::new(ContainerCondition::parse(self.context, input)?);
|
let condition = Arc::new(ContainerCondition::parse(self.context, input)?);
|
||||||
AtRulePrelude::Container(condition)
|
AtRulePrelude::Container(condition)
|
||||||
},
|
},
|
||||||
|
@ -572,7 +557,6 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
|
||||||
let family_names = parse_family_name_list(self.context, input)?;
|
let family_names = parse_family_name_list(self.context, input)?;
|
||||||
AtRulePrelude::FontFeatureValues(family_names)
|
AtRulePrelude::FontFeatureValues(family_names)
|
||||||
},
|
},
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
"font-palette-values" if static_prefs::pref!("layout.css.font-palette.enabled") => {
|
"font-palette-values" if static_prefs::pref!("layout.css.font-palette.enabled") => {
|
||||||
let name = DashedIdent::parse(self.context, input)?;
|
let name = DashedIdent::parse(self.context, input)?;
|
||||||
AtRulePrelude::FontPaletteValues(name)
|
AtRulePrelude::FontPaletteValues(name)
|
||||||
|
@ -602,7 +586,6 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
|
||||||
input.try_parse(|i| PageSelectors::parse(self.context, i)).unwrap_or_default()
|
input.try_parse(|i| PageSelectors::parse(self.context, i)).unwrap_or_default()
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
"property" if static_prefs::pref!("layout.css.properties-and-values.enabled") => {
|
"property" if static_prefs::pref!("layout.css.properties-and-values.enabled") => {
|
||||||
let name = input.expect_ident_cloned()?;
|
let name = input.expect_ident_cloned()?;
|
||||||
let name = parse_custom_property_name(&name).map_err(|_| {
|
let name = parse_custom_property_name(&name).map_err(|_| {
|
||||||
|
|
|
@ -170,12 +170,10 @@ impl SupportsCondition {
|
||||||
input.slice_from(pos).to_owned()
|
input.slice_from(pos).to_owned()
|
||||||
)))
|
)))
|
||||||
},
|
},
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
"font-format" if static_prefs::pref!("layout.css.font-tech.enabled") => {
|
"font-format" if static_prefs::pref!("layout.css.font-tech.enabled") => {
|
||||||
let kw = FontFaceSourceFormatKeyword::parse(input)?;
|
let kw = FontFaceSourceFormatKeyword::parse(input)?;
|
||||||
Ok(SupportsCondition::FontFormat(kw))
|
Ok(SupportsCondition::FontFormat(kw))
|
||||||
},
|
},
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
"font-tech" if static_prefs::pref!("layout.css.font-tech.enabled") => {
|
"font-tech" if static_prefs::pref!("layout.css.font-tech.enabled") => {
|
||||||
let flag = FontFaceSourceTechFlags::parse_one(input)?;
|
let flag = FontFaceSourceTechFlags::parse_one(input)?;
|
||||||
Ok(SupportsCondition::FontTech(flag))
|
Ok(SupportsCondition::FontTech(flag))
|
||||||
|
|
|
@ -517,10 +517,7 @@ pub enum SingleFontFamily {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn system_ui_enabled(_: &ParserContext) -> bool {
|
fn system_ui_enabled(_: &ParserContext) -> bool {
|
||||||
#[cfg(feature = "gecko")]
|
static_prefs::pref!("layout.css.system-ui.enabled")
|
||||||
return static_prefs::pref!("layout.css.system-ui.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A generic font-family name.
|
/// A generic font-family name.
|
||||||
|
|
|
@ -93,10 +93,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn nan_inf_enabled() -> bool {
|
fn nan_inf_enabled() -> bool {
|
||||||
#[cfg(feature = "gecko")]
|
static_prefs::pref!("layout.css.nan-inf.enabled")
|
||||||
return static_prefs::pref!("layout.css.nan-inf.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Serialize a number with calc, and NaN/infinity handling (if enabled)
|
/// Serialize a number with calc, and NaN/infinity handling (if enabled)
|
||||||
|
|
|
@ -7,14 +7,6 @@
|
||||||
use super::{Context, ToResolvedValue};
|
use super::{Context, ToResolvedValue};
|
||||||
use crate::values::computed;
|
use crate::values::computed;
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn allow_element_content_none() -> bool {
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
return static_prefs::pref!("layout.css.element-content-none.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-content/#content-property
|
/// https://drafts.csswg.org/css-content/#content-property
|
||||||
///
|
///
|
||||||
/// We implement this at resolved value time because otherwise it causes us to
|
/// We implement this at resolved value time because otherwise it causes us to
|
||||||
|
@ -43,7 +35,8 @@ impl ToResolvedValue for computed::Content {
|
||||||
// Ditto for non-pseudo elements if the pref is disabled.
|
// Ditto for non-pseudo elements if the pref is disabled.
|
||||||
Self::None
|
Self::None
|
||||||
if (is_pseudo && !is_before_or_after && !is_marker) ||
|
if (is_pseudo && !is_before_or_after && !is_marker) ||
|
||||||
(!is_pseudo && !allow_element_content_none()) =>
|
(!is_pseudo &&
|
||||||
|
!static_prefs::pref!("layout.css.element-content-none.enabled")) =>
|
||||||
{
|
{
|
||||||
Self::Normal
|
Self::Normal
|
||||||
},
|
},
|
||||||
|
|
|
@ -1832,7 +1832,6 @@ impl Parse for Overflow {
|
||||||
"-moz-hidden-unscrollable" if static_prefs::pref!("layout.css.overflow-moz-hidden-unscrollable.enabled") => {
|
"-moz-hidden-unscrollable" if static_prefs::pref!("layout.css.overflow-moz-hidden-unscrollable.enabled") => {
|
||||||
Overflow::Clip
|
Overflow::Clip
|
||||||
},
|
},
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
"overlay" if static_prefs::pref!("layout.css.overflow-overlay.enabled") => {
|
"overlay" if static_prefs::pref!("layout.css.overflow-overlay.enabled") => {
|
||||||
Overflow::Auto
|
Overflow::Auto
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,38 +21,11 @@ use style_traits::values::specified::AllowedNumericType;
|
||||||
use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss};
|
use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss};
|
||||||
|
|
||||||
fn trig_enabled() -> bool {
|
fn trig_enabled() -> bool {
|
||||||
#[cfg(feature = "gecko")]
|
static_prefs::pref!("layout.css.trig.enabled")
|
||||||
return static_prefs::pref!("layout.css.trig.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn nan_inf_enabled() -> bool {
|
fn nan_inf_enabled() -> bool {
|
||||||
#[cfg(feature = "gecko")]
|
static_prefs::pref!("layout.css.nan-inf.enabled")
|
||||||
return static_prefs::pref!("layout.css.nan-inf.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn round_enabled() -> bool {
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
return static_prefs::pref!("layout.css.round.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mod_rem_enabled() -> bool {
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
return static_prefs::pref!("layout.css.mod-rem.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn exp_enabled() -> bool {
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
return static_prefs::pref!("layout.css.exp.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The name of the mathematical function that we're parsing.
|
/// The name of the mathematical function that we're parsing.
|
||||||
|
@ -929,11 +902,11 @@ impl CalcNode {
|
||||||
} else if matches!(function, Sin | Cos | Tan | Asin | Acos | Atan | Atan2) {
|
} else if matches!(function, Sin | Cos | Tan | Asin | Acos | Atan | Atan2) {
|
||||||
trig_enabled()
|
trig_enabled()
|
||||||
} else if matches!(function, Round) {
|
} else if matches!(function, Round) {
|
||||||
round_enabled()
|
static_prefs::pref!("layout.css.round.enabled")
|
||||||
} else if matches!(function, Mod | Rem) {
|
} else if matches!(function, Mod | Rem) {
|
||||||
mod_rem_enabled()
|
static_prefs::pref!("layout.css.mod-rem.enabled")
|
||||||
} else if matches!(function, Pow | Sqrt | Hypot | Log | Exp) {
|
} else if matches!(function, Pow | Sqrt | Hypot | Log | Exp) {
|
||||||
exp_enabled()
|
static_prefs::pref!("layout.css.exp.enabled")
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,22 +25,6 @@ use style_traits::{SpecifiedValueInfo, ToCss, ValueParseErrorKind};
|
||||||
/// A specified color-mix().
|
/// A specified color-mix().
|
||||||
pub type ColorMix = GenericColorMix<Color, Percentage>;
|
pub type ColorMix = GenericColorMix<Color, Percentage>;
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn allow_color_mix() -> bool {
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
return static_prefs::pref!("layout.css.color-mix.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn allow_more_color_4() -> bool {
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
return static_prefs::pref!("layout.css.more_color_4.enabled");
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ColorMix {
|
impl ColorMix {
|
||||||
fn parse<'i, 't>(
|
fn parse<'i, 't>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
|
@ -48,7 +32,7 @@ impl ColorMix {
|
||||||
preserve_authored: PreserveAuthored,
|
preserve_authored: PreserveAuthored,
|
||||||
) -> Result<Self, ParseError<'i>> {
|
) -> Result<Self, ParseError<'i>> {
|
||||||
let enabled =
|
let enabled =
|
||||||
context.chrome_rules_enabled() || allow_color_mix();
|
context.chrome_rules_enabled() || static_prefs::pref!("layout.css.color-mix.enabled");
|
||||||
|
|
||||||
if !enabled {
|
if !enabled {
|
||||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||||
|
@ -639,7 +623,7 @@ impl Color {
|
||||||
);
|
);
|
||||||
let is_color_function =
|
let is_color_function =
|
||||||
absolute.color.flags.contains(ColorFlags::AS_COLOR_FUNCTION);
|
absolute.color.flags.contains(ColorFlags::AS_COLOR_FUNCTION);
|
||||||
let pref_enabled = allow_more_color_4();
|
let pref_enabled = static_prefs::pref!("layout.css.more_color_4.enabled");
|
||||||
|
|
||||||
(is_legacy_color && !is_color_function) || pref_enabled
|
(is_legacy_color && !is_color_function) || pref_enabled
|
||||||
};
|
};
|
||||||
|
@ -971,10 +955,10 @@ impl SpecifiedValueInfo for Color {
|
||||||
"currentColor",
|
"currentColor",
|
||||||
"transparent",
|
"transparent",
|
||||||
]);
|
]);
|
||||||
if allow_color_mix() {
|
if static_prefs::pref!("layout.css.color-mix.enabled") {
|
||||||
f(&["color-mix"]);
|
f(&["color-mix"]);
|
||||||
}
|
}
|
||||||
if allow_more_color_4() {
|
if static_prefs::pref!("layout.css.more_color_4.enabled") {
|
||||||
f(&["color", "lab", "lch", "oklab", "oklch"]);
|
f(&["color", "lab", "lch", "oklab", "oklch"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -720,10 +720,7 @@ impl Parse for FontSizeAdjust {
|
||||||
) -> Result<Self, ParseError<'i>> {
|
) -> Result<Self, ParseError<'i>> {
|
||||||
let location = input.current_source_location();
|
let location = input.current_source_location();
|
||||||
if let Ok(ident) = input.try_parse(|i| i.expect_ident_cloned()) {
|
if let Ok(ident) = input.try_parse(|i| i.expect_ident_cloned()) {
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
let basis_enabled = static_prefs::pref!("layout.css.font-size-adjust.basis.enabled");
|
let basis_enabled = static_prefs::pref!("layout.css.font-size-adjust.basis.enabled");
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
let basis_enabled = false;
|
|
||||||
let basis = match_ignore_ascii_case! { &ident,
|
let basis = match_ignore_ascii_case! { &ident,
|
||||||
"none" => return Ok(Self::None),
|
"none" => return Ok(Self::None),
|
||||||
// Check for size adjustment basis keywords if enabled.
|
// Check for size adjustment basis keywords if enabled.
|
||||||
|
|
|
@ -23,15 +23,6 @@ pub type OffsetPath = generics::GenericOffsetPath<RayFunction>;
|
||||||
/// The specified value of `offset-position`.
|
/// The specified value of `offset-position`.
|
||||||
pub type OffsetPosition = generics::GenericOffsetPosition<HorizontalPosition, VerticalPosition>;
|
pub type OffsetPosition = generics::GenericOffsetPosition<HorizontalPosition, VerticalPosition>;
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
fn is_ray_enabled() -> bool {
|
|
||||||
static_prefs::pref!("layout.css.motion-path-ray.enabled")
|
|
||||||
}
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
fn is_ray_enabled() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for RayFunction {
|
impl Parse for RayFunction {
|
||||||
fn parse<'i, 't>(
|
fn parse<'i, 't>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
|
@ -39,7 +30,7 @@ impl Parse for RayFunction {
|
||||||
) -> Result<Self, ParseError<'i>> {
|
) -> Result<Self, ParseError<'i>> {
|
||||||
use crate::values::specified::PositionOrAuto;
|
use crate::values::specified::PositionOrAuto;
|
||||||
|
|
||||||
if !is_ray_enabled() {
|
if !static_prefs::pref!("layout.css.motion-path-ray.enabled") {
|
||||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
7
components/style_static_prefs/Cargo.toml
Normal file
7
components/style_static_prefs/Cargo.toml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[package]
|
||||||
|
name = "static_prefs"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
authors = ["The Servo Project Developers"]
|
||||||
|
license = "MPL-2.0"
|
||||||
|
publish = false
|
162
components/style_static_prefs/src/lib.rs
Normal file
162
components/style_static_prefs/src/lib.rs
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* 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/. */
|
||||||
|
|
||||||
|
//! A list of static preferences exposed to the style crate. These should
|
||||||
|
//! be kept sync with the preferences used by the style.
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! pref {
|
||||||
|
("browser.display.permit_backplate") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("browser.display.use_document_fonts") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("dom.customHighlightAPI.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("dom.element.popover.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("gfx.font_rendering.opentype_svg.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.color-mix.enabled") => {
|
||||||
|
true
|
||||||
|
};
|
||||||
|
("layout.css.contain-intrinsic-size.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.container-queries.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.content-visibility.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.control-characters.visible") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.cross-fade.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.element-content-none.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.fit-content-function.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.font-palette.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.font-tech.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.font-variant-emoji.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.font-variations.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.forced-color-adjust.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.forced-colors.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.grid-template-masonry-value.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.has-selector.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.import-supports.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.inverted-colors.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.marker.restricted") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.math-depth.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.math-style.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.more_color_4.enabled") => {
|
||||||
|
true
|
||||||
|
};
|
||||||
|
("layout.css.motion-path-offset-position.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.motion-path-ray.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.moz-control-character-visibility.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.nesting.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.overflow-moz-hidden-unscrollable.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.overflow-overlay.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.page-orientation.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.prefers-contrast.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.prefers-reduced-transparency.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.properties-and-values.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.scroll-driven-animations.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.size-adjust.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.stylo-local-work-queue.in-main-thread") => {
|
||||||
|
32
|
||||||
|
};
|
||||||
|
("layout.css.stylo-local-work-queue.in-worker") => {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
("layout.css.stylo-threads") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.stylo-work-unit-size") => {
|
||||||
|
16
|
||||||
|
};
|
||||||
|
("layout.css.system-ui.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.nan-inf.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.trig.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.round.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.mod-rem.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.exp.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.bucket-attribute-names.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
("layout.css.font-size-adjust.basis.enabled") => {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue