mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Use static_prefs::pref!
.
It's much nicer. One nice thing about this is that the new code is subject to the existing threadedness checking, which identified that several of these should be atomic because they're accessed off the main thread. Differential Revision: https://phabricator.services.mozilla.com/D40792
This commit is contained in:
parent
ad1d028e40
commit
bb032c1ddc
17 changed files with 26 additions and 60 deletions
|
@ -66,6 +66,7 @@ servo_atoms = {path = "../atoms", optional = true}
|
||||||
servo_config = {path = "../config", optional = true}
|
servo_config = {path = "../config", optional = true}
|
||||||
smallbitvec = "2.3.0"
|
smallbitvec = "2.3.0"
|
||||||
smallvec = "0.6.6"
|
smallvec = "0.6.6"
|
||||||
|
static_prefs = { path = "../../../modules/libpref/init/static_prefs" }
|
||||||
string_cache = { version = "0.7", optional = true }
|
string_cache = { version = "0.7", optional = true }
|
||||||
style_derive = {path = "../style_derive"}
|
style_derive = {path = "../style_derive"}
|
||||||
style_traits = {path = "../style_traits"}
|
style_traits = {path = "../style_traits"}
|
||||||
|
|
|
@ -414,16 +414,10 @@ impl Parse for Source {
|
||||||
|
|
||||||
macro_rules! is_descriptor_enabled {
|
macro_rules! is_descriptor_enabled {
|
||||||
("font-display") => {
|
("font-display") => {
|
||||||
unsafe {
|
static_prefs::pref!("layout.css.font-display.enabled")
|
||||||
use crate::gecko_bindings::structs::mozilla;
|
|
||||||
mozilla::StaticPrefs::sVarCache_layout_css_font_display_enabled
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
("font-variation-settings") => {
|
("font-variation-settings") => {
|
||||||
unsafe {
|
static_prefs::pref!("layout.css.font-variations.enabled")
|
||||||
use crate::gecko_bindings::structs::mozilla;
|
|
||||||
mozilla::StaticPrefs::sVarCache_layout_css_font_variations_enabled != 0
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
($name:tt) => {
|
($name:tt) => {
|
||||||
true
|
true
|
||||||
|
|
|
@ -268,8 +268,7 @@ impl Device {
|
||||||
if doc.mIsBeingUsedAsImage() {
|
if doc.mIsBeingUsedAsImage() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let document_color_use =
|
let document_color_use = static_prefs::pref!("browser.display.document_color_use");
|
||||||
unsafe { structs::StaticPrefs::sVarCache_browser_display_document_color_use };
|
|
||||||
let prefs = self.pref_sheet_prefs();
|
let prefs = self.pref_sheet_prefs();
|
||||||
match document_color_use {
|
match document_color_use {
|
||||||
1 => true,
|
1 => true,
|
||||||
|
|
|
@ -187,11 +187,8 @@ impl PseudoElement {
|
||||||
PseudoElement::FirstLine => PropertyFlags::APPLIES_TO_FIRST_LINE,
|
PseudoElement::FirstLine => PropertyFlags::APPLIES_TO_FIRST_LINE,
|
||||||
PseudoElement::Placeholder => PropertyFlags::APPLIES_TO_PLACEHOLDER,
|
PseudoElement::Placeholder => PropertyFlags::APPLIES_TO_PLACEHOLDER,
|
||||||
PseudoElement::Cue => PropertyFlags::APPLIES_TO_CUE,
|
PseudoElement::Cue => PropertyFlags::APPLIES_TO_CUE,
|
||||||
PseudoElement::Marker
|
PseudoElement::Marker if static_prefs::pref!("layout.css.marker.restricted") =>
|
||||||
if unsafe { structs::StaticPrefs::sVarCache_layout_css_marker_restricted } =>
|
PropertyFlags::APPLIES_TO_MARKER,
|
||||||
{
|
|
||||||
PropertyFlags::APPLIES_TO_MARKER
|
|
||||||
},
|
|
||||||
_ => return None,
|
_ => return None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl PseudoElement {
|
||||||
% for pseudo in PSEUDOS:
|
% for pseudo in PSEUDOS:
|
||||||
${pseudo_element_variant(pseudo)} =>
|
${pseudo_element_variant(pseudo)} =>
|
||||||
% if pseudo.is_tree_pseudo_element():
|
% if pseudo.is_tree_pseudo_element():
|
||||||
if unsafe { structs::StaticPrefs::sVarCache_layout_css_xul_tree_pseudos_content_enabled } {
|
if static_prefs::pref!("layout.css.xul-tree-pseudos.content.enabled") {
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS_AND_CHROME
|
structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS_AND_CHROME
|
||||||
|
@ -209,9 +209,7 @@ impl PseudoElement {
|
||||||
if starts_with_ignore_ascii_case(name, "-moz-tree-") {
|
if starts_with_ignore_ascii_case(name, "-moz-tree-") {
|
||||||
return PseudoElement::tree_pseudo_element(name, Box::new([]))
|
return PseudoElement::tree_pseudo_element(name, Box::new([]))
|
||||||
}
|
}
|
||||||
if unsafe {
|
if static_prefs::pref!("layout.css.unknown-webkit-pseudo-element") {
|
||||||
structs::StaticPrefs::sVarCache_layout_css_unknown_webkit_pseudo_element
|
|
||||||
} {
|
|
||||||
const WEBKIT_PREFIX: &str = "-webkit-";
|
const WEBKIT_PREFIX: &str = "-webkit-";
|
||||||
if starts_with_ignore_ascii_case(name, WEBKIT_PREFIX) {
|
if starts_with_ignore_ascii_case(name, WEBKIT_PREFIX) {
|
||||||
let part = string_as_ascii_lowercase(&name[WEBKIT_PREFIX.len()..]);
|
let part = string_as_ascii_lowercase(&name[WEBKIT_PREFIX.len()..]);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
//! Gecko-specific bits for selector-parsing.
|
//! Gecko-specific bits for selector-parsing.
|
||||||
|
|
||||||
use crate::element_state::{DocumentState, ElementState};
|
use crate::element_state::{DocumentState, ElementState};
|
||||||
use crate::gecko_bindings::structs::{self, RawServoSelectorList};
|
use crate::gecko_bindings::structs::RawServoSelectorList;
|
||||||
use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
||||||
use crate::invalidation::element::document_state::InvalidationMatchingData;
|
use crate::invalidation::element::document_state::InvalidationMatchingData;
|
||||||
use crate::selector_parser::{Direction, SelectorParser};
|
use crate::selector_parser::{Direction, SelectorParser};
|
||||||
|
@ -170,13 +170,10 @@ impl NonTSPseudoClass {
|
||||||
|
|
||||||
/// Returns whether the pseudo-class is enabled in content sheets.
|
/// Returns whether the pseudo-class is enabled in content sheets.
|
||||||
fn is_enabled_in_content(&self) -> bool {
|
fn is_enabled_in_content(&self) -> bool {
|
||||||
use crate::gecko_bindings::structs::mozilla;
|
|
||||||
match *self {
|
match *self {
|
||||||
// For pseudo-classes with pref, the availability in content
|
// For pseudo-classes with pref, the availability in content
|
||||||
// depends on the pref.
|
// depends on the pref.
|
||||||
NonTSPseudoClass::Fullscreen => unsafe {
|
NonTSPseudoClass::Fullscreen => static_prefs::pref!("full-screen-api.unprefix.enabled"),
|
||||||
mozilla::StaticPrefs::sVarCache_full_screen_api_unprefix_enabled
|
|
||||||
},
|
|
||||||
// Otherwise, a pseudo-class is enabled in content when it
|
// Otherwise, a pseudo-class is enabled in content when it
|
||||||
// doesn't have any enabled flag.
|
// doesn't have any enabled flag.
|
||||||
_ => !self
|
_ => !self
|
||||||
|
@ -354,8 +351,7 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn parse_part(&self) -> bool {
|
fn parse_part(&self) -> bool {
|
||||||
self.chrome_rules_enabled() ||
|
self.chrome_rules_enabled() || static_prefs::pref!("layout.css.shadow-parts.enabled")
|
||||||
unsafe { structs::StaticPrefs::sVarCache_layout_css_shadow_parts_enabled }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_non_ts_pseudo_class(
|
fn parse_non_ts_pseudo_class(
|
||||||
|
|
|
@ -91,6 +91,7 @@ extern crate servo_config;
|
||||||
extern crate servo_url;
|
extern crate servo_url;
|
||||||
extern crate smallbitvec;
|
extern crate smallbitvec;
|
||||||
extern crate smallvec;
|
extern crate smallvec;
|
||||||
|
extern crate static_prefs;
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
extern crate string_cache;
|
extern crate string_cache;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
@ -11,8 +11,6 @@ use super::Device;
|
||||||
use crate::context::QuirksMode;
|
use crate::context::QuirksMode;
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use crate::gecko::media_features::MEDIA_FEATURES;
|
use crate::gecko::media_features::MEDIA_FEATURES;
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
use crate::gecko_bindings::structs;
|
|
||||||
use crate::parser::{Parse, ParserContext};
|
use crate::parser::{Parse, ParserContext};
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
use crate::servo::media_queries::MEDIA_FEATURES;
|
use crate::servo::media_queries::MEDIA_FEATURES;
|
||||||
|
@ -301,9 +299,7 @@ impl MediaFeatureExpression {
|
||||||
if starts_with_ignore_ascii_case(feature_name, "-webkit-") {
|
if starts_with_ignore_ascii_case(feature_name, "-webkit-") {
|
||||||
feature_name = &feature_name[8..];
|
feature_name = &feature_name[8..];
|
||||||
requirements.insert(ParsingRequirements::WEBKIT_PREFIX);
|
requirements.insert(ParsingRequirements::WEBKIT_PREFIX);
|
||||||
if unsafe {
|
if static_prefs::pref!("layout.css.prefixes.device-pixel-ratio-webkit") {
|
||||||
structs::StaticPrefs::sVarCache_layout_css_prefixes_device_pixel_ratio_webkit
|
|
||||||
} {
|
|
||||||
requirements.insert(
|
requirements.insert(
|
||||||
ParsingRequirements::WEBKIT_DEVICE_PIXEL_RATIO_PREF_ENABLED,
|
ParsingRequirements::WEBKIT_DEVICE_PIXEL_RATIO_PREF_ENABLED,
|
||||||
);
|
);
|
||||||
|
|
|
@ -673,7 +673,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn recompute_default_font_family_type_if_needed(&mut self) {
|
fn recompute_default_font_family_type_if_needed(&mut self) {
|
||||||
use crate::gecko_bindings::{bindings, structs};
|
use crate::gecko_bindings::bindings;
|
||||||
use crate::values::computed::font::GenericFontFamily;
|
use crate::values::computed::font::GenericFontFamily;
|
||||||
|
|
||||||
if !self.seen.contains(LonghandId::XLang) &&
|
if !self.seen.contains(LonghandId::XLang) &&
|
||||||
|
@ -681,7 +681,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let use_document_fonts = unsafe { structs::StaticPrefs::sVarCache_browser_display_use_document_fonts != 0 };
|
let use_document_fonts = static_prefs::pref!("browser.display.use_document_fonts") != 0;
|
||||||
let builder = &mut self.context.builder;
|
let builder = &mut self.context.builder;
|
||||||
let (default_font_type, prioritize_user_fonts) = {
|
let (default_font_type, prioritize_user_fonts) = {
|
||||||
let font = builder.get_font().gecko();
|
let font = builder.get_font().gecko();
|
||||||
|
|
|
@ -253,20 +253,18 @@ impl DocumentCondition {
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn allowed_in(&self, context: &ParserContext) -> bool {
|
fn allowed_in(&self, context: &ParserContext) -> bool {
|
||||||
use crate::gecko_bindings::structs;
|
|
||||||
use crate::stylesheets::Origin;
|
use crate::stylesheets::Origin;
|
||||||
|
use static_prefs::pref;
|
||||||
|
|
||||||
if context.stylesheet_origin != Origin::Author {
|
if context.stylesheet_origin != Origin::Author {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if unsafe { structs::StaticPrefs::sVarCache_layout_css_moz_document_content_enabled } {
|
if pref!("layout.css.moz-document.content.enabled") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !unsafe {
|
if !pref!("layout.css.moz-document.url-prefix-hack.enabled") {
|
||||||
structs::StaticPrefs::sVarCache_layout_css_moz_document_url_prefix_hack_enabled
|
|
||||||
} {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -323,9 +323,7 @@ impl RawSelector {
|
||||||
pub fn eval(&self, context: &ParserContext, namespaces: &Namespaces) -> bool {
|
pub fn eval(&self, context: &ParserContext, namespaces: &Namespaces) -> bool {
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
{
|
{
|
||||||
if unsafe {
|
if !static_prefs::pref!("layout.css.supports-selector.enabled") {
|
||||||
!crate::gecko_bindings::structs::StaticPrefs::sVarCache_layout_css_supports_selector_enabled
|
|
||||||
} {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,7 @@ pub enum TimingKeyword {
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn step_position_jump_enabled(_context: &ParserContext) -> bool {
|
fn step_position_jump_enabled(_context: &ParserContext) -> bool {
|
||||||
use crate::gecko_bindings::structs;
|
static_prefs::pref!("layout.css.step-position-jump.enabled")
|
||||||
unsafe { structs::StaticPrefs::sVarCache_layout_css_step_position_jump_enabled }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
|
|
|
@ -72,11 +72,8 @@ impl<Value> Spacing<Value> {
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn line_height_moz_block_height_enabled(context: &ParserContext) -> bool {
|
fn line_height_moz_block_height_enabled(context: &ParserContext) -> bool {
|
||||||
use crate::gecko_bindings::structs;
|
|
||||||
context.in_ua_sheet() ||
|
context.in_ua_sheet() ||
|
||||||
unsafe {
|
static_prefs::pref!("layout.css.line-height-moz-block-height.content.enabled")
|
||||||
structs::StaticPrefs::sVarCache_layout_css_line_height_moz_block_height_content_enabled
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A generic value for the `line-height` property.
|
/// A generic value for the `line-height` property.
|
||||||
|
|
|
@ -58,9 +58,7 @@ pub type Polygon = generic::GenericPolygon<LengthPercentage>;
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn is_clip_path_path_enabled(context: &ParserContext) -> bool {
|
fn is_clip_path_path_enabled(context: &ParserContext) -> bool {
|
||||||
use crate::gecko_bindings::structs::mozilla;
|
context.chrome_rules_enabled() || static_prefs::pref!("layout.css.clip-path-path.enabled")
|
||||||
context.chrome_rules_enabled() ||
|
|
||||||
unsafe { mozilla::StaticPrefs::sVarCache_layout_css_clip_path_path_enabled }
|
|
||||||
}
|
}
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
fn is_clip_path_path_enabled(_: &ParserContext) -> bool {
|
fn is_clip_path_path_enabled(_: &ParserContext) -> bool {
|
||||||
|
|
|
@ -23,18 +23,14 @@ use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss};
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn moz_display_values_enabled(context: &ParserContext) -> bool {
|
fn moz_display_values_enabled(context: &ParserContext) -> bool {
|
||||||
use crate::gecko_bindings::structs;
|
|
||||||
context.in_ua_or_chrome_sheet() ||
|
context.in_ua_or_chrome_sheet() ||
|
||||||
unsafe { structs::StaticPrefs::sVarCache_layout_css_xul_display_values_content_enabled }
|
static_prefs::pref!("layout.css.xul-display-values.content.enabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn moz_box_display_values_enabled(context: &ParserContext) -> bool {
|
fn moz_box_display_values_enabled(context: &ParserContext) -> bool {
|
||||||
use crate::gecko_bindings::structs;
|
|
||||||
context.in_ua_or_chrome_sheet() ||
|
context.in_ua_or_chrome_sheet() ||
|
||||||
unsafe {
|
static_prefs::pref!("layout.css.xul-box-display-values.content.enabled")
|
||||||
structs::StaticPrefs::sVarCache_layout_css_xul_box_display_values_content_enabled
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "gecko", feature = "servo-layout-2013"))]
|
#[cfg(any(feature = "gecko", feature = "servo-layout-2013"))]
|
||||||
|
|
|
@ -305,8 +305,7 @@ impl Parse for TrackList<LengthPercentage, Integer> {
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn allow_grid_template_subgrids() -> bool {
|
fn allow_grid_template_subgrids() -> bool {
|
||||||
use crate::gecko_bindings::structs::mozilla;
|
static_prefs::pref!("layout.css.grid-template-subgrid-value.enabled")
|
||||||
unsafe { mozilla::StaticPrefs::sVarCache_layout_css_grid_template_subgrid_value_enabled }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
|
|
|
@ -32,8 +32,7 @@ pub type SVGStrokeDashArray = generic::SVGStrokeDashArray<NonNegativeLengthPerce
|
||||||
/// Whether the `context-value` value is enabled.
|
/// Whether the `context-value` value is enabled.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub fn is_context_value_enabled() -> bool {
|
pub fn is_context_value_enabled() -> bool {
|
||||||
use crate::gecko_bindings::structs::mozilla;
|
static_prefs::pref!("gfx.font_rendering.opentype_svg.enabled")
|
||||||
unsafe { mozilla::StaticPrefs::sVarCache_gfx_font_rendering_opentype_svg_enabled }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the `context-value` value is enabled.
|
/// Whether the `context-value` value is enabled.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue