Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
style: Change StaticPrefs from a class to a namespace.
This doesn't change the way C++ code uses static prefs. But it does slightly
change how Rust code uses static prefs, specifically the name generated by
bindgen is slightly different.

The commit also improves some comments.

Differential Revision: https://phabricator.services.mozilla.com/D35764
  • Loading branch information
nnethercote authored and emilio committed Jul 8, 2019
1 parent 84a5ab2 commit 3232210
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions components/style/font_face.rs
Expand Up @@ -416,13 +416,13 @@ macro_rules! is_descriptor_enabled {
("font-display") => {
unsafe {
use crate::gecko_bindings::structs::mozilla;
mozilla::StaticPrefs_sVarCache_layout_css_font_display_enabled
mozilla::StaticPrefs::sVarCache_layout_css_font_display_enabled
}
};
("font-variation-settings") => {
unsafe {
use crate::gecko_bindings::structs::mozilla;
mozilla::StaticPrefs_sVarCache_layout_css_font_variations_enabled != 0
mozilla::StaticPrefs::sVarCache_layout_css_font_variations_enabled != 0
}
};
($name:tt) => {
Expand Down
2 changes: 1 addition & 1 deletion components/style/gecko/media_queries.rs
Expand Up @@ -271,7 +271,7 @@ impl Device {
return true;
}
let document_color_use =
unsafe { structs::StaticPrefs_sVarCache_browser_display_document_color_use };
unsafe { structs::StaticPrefs::sVarCache_browser_display_document_color_use };
let prefs = self.pref_sheet_prefs();
match document_color_use {
1 => true,
Expand Down
4 changes: 2 additions & 2 deletions components/style/gecko/pseudo_element_definition.mako.rs
Expand Up @@ -112,7 +112,7 @@ impl PseudoElement {
% for pseudo in PSEUDOS:
${pseudo_element_variant(pseudo)} =>
% if pseudo.is_tree_pseudo_element():
if unsafe { structs::StaticPrefs_sVarCache_layout_css_xul_tree_pseudos_content_enabled } {
if unsafe { structs::StaticPrefs::sVarCache_layout_css_xul_tree_pseudos_content_enabled } {
0
} else {
structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS_AND_CHROME
Expand Down Expand Up @@ -210,7 +210,7 @@ impl PseudoElement {
return PseudoElement::tree_pseudo_element(name, Box::new([]))
}
if unsafe {
structs::StaticPrefs_sVarCache_layout_css_unknown_webkit_pseudo_element
structs::StaticPrefs::sVarCache_layout_css_unknown_webkit_pseudo_element
} {
const WEBKIT_PREFIX: &str = "-webkit-";
if starts_with_ignore_ascii_case(name, WEBKIT_PREFIX) {
Expand Down
4 changes: 2 additions & 2 deletions components/style/gecko/selector_parser.rs
Expand Up @@ -175,7 +175,7 @@ impl NonTSPseudoClass {
// For pseudo-classes with pref, the availability in content
// depends on the pref.
NonTSPseudoClass::Fullscreen => unsafe {
mozilla::StaticPrefs_sVarCache_full_screen_api_unprefix_enabled
mozilla::StaticPrefs::sVarCache_full_screen_api_unprefix_enabled
},
// Otherwise, a pseudo-class is enabled in content when it
// doesn't have any enabled flag.
Expand Down Expand Up @@ -355,7 +355,7 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
#[inline]
fn parse_part(&self) -> bool {
self.chrome_rules_enabled() ||
unsafe { structs::StaticPrefs_sVarCache_layout_css_shadow_parts_enabled }
unsafe { structs::StaticPrefs::sVarCache_layout_css_shadow_parts_enabled }
}

fn parse_non_ts_pseudo_class(
Expand Down
2 changes: 1 addition & 1 deletion components/style/media_queries/media_feature_expression.rs
Expand Up @@ -302,7 +302,7 @@ impl MediaFeatureExpression {
feature_name = &feature_name[8..];
requirements.insert(ParsingRequirements::WEBKIT_PREFIX);
if unsafe {
structs::StaticPrefs_sVarCache_layout_css_prefixes_device_pixel_ratio_webkit
structs::StaticPrefs::sVarCache_layout_css_prefixes_device_pixel_ratio_webkit
} {
requirements.insert(
ParsingRequirements::WEBKIT_DEVICE_PIXEL_RATIO_PREF_ENABLED,
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/cascade.rs
Expand Up @@ -686,7 +686,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
return;
}

let use_document_fonts = unsafe { structs::StaticPrefs_sVarCache_browser_display_use_document_fonts != 0 };
let use_document_fonts = unsafe { structs::StaticPrefs::sVarCache_browser_display_use_document_fonts != 0 };
let builder = &mut self.context.builder;
let (default_font_type, prioritize_user_fonts) = {
let font = builder.get_font().gecko();
Expand Down
4 changes: 2 additions & 2 deletions components/style/stylesheets/document_rule.rs
Expand Up @@ -260,12 +260,12 @@ impl DocumentCondition {
return true;
}

if unsafe { structs::StaticPrefs_sVarCache_layout_css_moz_document_content_enabled } {
if unsafe { structs::StaticPrefs::sVarCache_layout_css_moz_document_content_enabled } {
return true;
}

if !unsafe {
structs::StaticPrefs_sVarCache_layout_css_moz_document_url_prefix_hack_enabled
structs::StaticPrefs::sVarCache_layout_css_moz_document_url_prefix_hack_enabled
} {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion components/style/stylesheets/supports_rule.rs
Expand Up @@ -324,7 +324,7 @@ impl RawSelector {
#[cfg(feature = "gecko")]
{
if unsafe {
!crate::gecko_bindings::structs::StaticPrefs_sVarCache_layout_css_supports_selector_enabled
!crate::gecko_bindings::structs::StaticPrefs::sVarCache_layout_css_supports_selector_enabled
} {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion components/style/values/generics/easing.rs
Expand Up @@ -70,7 +70,7 @@ pub enum TimingKeyword {
#[cfg(feature = "gecko")]
fn step_position_jump_enabled(_context: &ParserContext) -> bool {
use crate::gecko_bindings::structs;
unsafe { structs::StaticPrefs_sVarCache_layout_css_step_position_jump_enabled }
unsafe { structs::StaticPrefs::sVarCache_layout_css_step_position_jump_enabled }
}

#[cfg(feature = "servo")]
Expand Down
2 changes: 1 addition & 1 deletion components/style/values/generics/text.rs
Expand Up @@ -75,7 +75,7 @@ fn line_height_moz_block_height_enabled(context: &ParserContext) -> bool {
use crate::gecko_bindings::structs;
context.in_ua_sheet() ||
unsafe {
structs::StaticPrefs_sVarCache_layout_css_line_height_moz_block_height_content_enabled
structs::StaticPrefs::sVarCache_layout_css_line_height_moz_block_height_content_enabled
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/style/values/specified/basic_shape.rs
Expand Up @@ -60,7 +60,7 @@ pub type Polygon = generic::GenericPolygon<LengthPercentage>;
fn is_clip_path_path_enabled(context: &ParserContext) -> bool {
use crate::gecko_bindings::structs::mozilla;
context.chrome_rules_enabled() ||
unsafe { mozilla::StaticPrefs_sVarCache_layout_css_clip_path_path_enabled }
unsafe { mozilla::StaticPrefs::sVarCache_layout_css_clip_path_path_enabled }
}
#[cfg(feature = "servo")]
fn is_clip_path_path_enabled(_: &ParserContext) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions components/style/values/specified/box.rs
Expand Up @@ -25,15 +25,15 @@ use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss};
fn moz_display_values_enabled(context: &ParserContext) -> bool {
use crate::gecko_bindings::structs;
context.in_ua_or_chrome_sheet() ||
unsafe { structs::StaticPrefs_sVarCache_layout_css_xul_display_values_content_enabled }
unsafe { structs::StaticPrefs::sVarCache_layout_css_xul_display_values_content_enabled }
}

#[cfg(feature = "gecko")]
fn moz_box_display_values_enabled(context: &ParserContext) -> bool {
use crate::gecko_bindings::structs;
context.in_ua_or_chrome_sheet() ||
unsafe {
structs::StaticPrefs_sVarCache_layout_css_xul_box_display_values_content_enabled
structs::StaticPrefs::sVarCache_layout_css_xul_box_display_values_content_enabled
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/style/values/specified/grid.rs
Expand Up @@ -381,7 +381,7 @@ impl ToComputedValue for TrackList<LengthPercentage, Integer> {
#[inline]
fn allow_grid_template_subgrids() -> bool {
use crate::gecko_bindings::structs::mozilla;
unsafe { mozilla::StaticPrefs_sVarCache_layout_css_grid_template_subgrid_value_enabled }
unsafe { mozilla::StaticPrefs::sVarCache_layout_css_grid_template_subgrid_value_enabled }
}

#[cfg(feature = "servo")]
Expand Down
2 changes: 1 addition & 1 deletion components/style/values/specified/svg.rs
Expand Up @@ -36,7 +36,7 @@ pub type SVGStrokeDashArray = generic::SVGStrokeDashArray<NonNegativeLengthPerce
#[cfg(feature = "gecko")]
pub fn is_context_value_enabled() -> bool {
use crate::gecko_bindings::structs::mozilla;
unsafe { mozilla::StaticPrefs_sVarCache_gfx_font_rendering_opentype_svg_enabled }
unsafe { mozilla::StaticPrefs::sVarCache_gfx_font_rendering_opentype_svg_enabled }
}

/// Whether the `context-value` value is enabled.
Expand Down

0 comments on commit 3232210

Please sign in to comment.