Revert #16517 for Gecko heap write hazard failures.

This commit is contained in:
Cameron McCormack 2017-04-19 16:34:06 +10:00
parent 2f8d9013a0
commit 408100818d
11 changed files with 192 additions and 858 deletions

View file

@ -95,8 +95,6 @@ pub struct ComputedValues {
/// When this is Some, we compute font sizes by computing the keyword against
/// the generic font, and then multiplying it by the ratio.
pub font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
/// The cached system font. See longhand/font.mako.rs
pub cached_system_font: Option<longhands::system_font::ComputedSystemFont>,
}
impl ComputedValues {
@ -106,7 +104,6 @@ impl ComputedValues {
writing_mode: parent.writing_mode,
root_font_size: parent.root_font_size,
font_size_keyword: parent.font_size_keyword,
cached_system_font: None,
% for style_struct in data.style_structs:
% if style_struct.inherited:
${style_struct.ident}: parent.${style_struct.ident}.clone(),
@ -129,7 +126,6 @@ impl ComputedValues {
custom_properties: custom_properties,
writing_mode: writing_mode,
root_font_size: root_font_size,
cached_system_font: None,
font_size_keyword: font_size_keyword,
% for style_struct in data.style_structs:
${style_struct.ident}: ${style_struct.ident},
@ -143,7 +139,6 @@ impl ComputedValues {
writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious
root_font_size: longhands::font_size::get_initial_value(), // FIXME(bz): Also seems dubious?
font_size_keyword: Some((Default::default(), 1.)),
cached_system_font: None,
% for style_struct in data.style_structs:
${style_struct.ident}: style_structs::${style_struct.name}::default(pres_context),
% endfor
@ -299,6 +294,27 @@ def set_gecko_property(ffi_name, expr):
}
</%def>
<%def name="impl_bitflags_setter(ident, gecko_ffi_name, bit_map, gecko_bit_prefix, cast_type='u8')">
#[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
% for gecko_bit in bit_map.values():
use gecko_bindings::structs::${gecko_bit_prefix}${gecko_bit};
% endfor
let mut bits: ${cast_type} = 0;
// FIXME: if we ensure that the Servo bitflags storage is the same
// as Gecko's one, we can just copy it.
% for servo_bit, gecko_bit in bit_map.iteritems():
if v.contains(longhands::${ident}::${servo_bit}) {
bits |= ${gecko_bit_prefix}${gecko_bit} as ${cast_type};
}
% endfor
self.gecko.${gecko_ffi_name} = bits as ${cast_type};
}
</%def>
/// Convert a Servo color into an nscolor; with currentColor as 0
///
/// Call sites will need to be updated after https://bugzilla.mozilla.org/show_bug.cgi?id=760345
@ -1415,10 +1431,20 @@ fn static_assert() {
}
${impl_simple_copy('font_language_override', 'mFont.languageOverride')}
pub fn set_font_variant_alternates(&mut self, v: longhands::font_variant_alternates::computed_value::T) {
self.gecko.mFont.variantAlternates = v.to_gecko_keyword()
}
<% font_variant_alternates_map = { "HISTORICAL_FORMS": "HISTORICAL",
"STYLISTIC": "STYLISTIC",
"STYLESET": "STYLESET",
"CHARACTER_VARIANT": "CHARACTER_VARIANT",
"SWASH": "SWASH",
"ORNAMENTS": "ORNAMENTS",
"ANNOTATION": "ANNOTATION" } %>
// FIXME: Set alternateValues as well.
// self.gecko.mFont.alternateValues = xxx;
${impl_bitflags_setter('font_variant_alternates',
'mFont.variantAlternates',
font_variant_alternates_map,
'NS_FONT_VARIANT_ALTERNATES_',
cast_type='u16')}
#[allow(non_snake_case)]
pub fn copy_font_variant_alternates_from(&mut self, other: &Self) {
self.gecko.mFont.variantAlternates = other.gecko.mFont.variantAlternates;
@ -1426,22 +1452,53 @@ fn static_assert() {
// self.gecko.mFont.alternateValues = other.gecko.mFont.alternateValues;
}
pub fn set_font_variant_ligatures(&mut self, v: longhands::font_variant_ligatures::computed_value::T) {
self.gecko.mFont.variantLigatures = v.to_gecko_keyword()
}
// servo_bit: gecko_bit
<% font_variant_ligatures_map = { "NONE": "NONE",
"COMMON_LIGATURES": "COMMON",
"NO_COMMON_LIGATURES": "NO_COMMON",
"DISCRETIONARY_LIGATURES": "DISCRETIONARY",
"NO_DISCRETIONARY_LIGATURES": "NO_DISCRETIONARY",
"HISTORICAL_LIGATURES": "HISTORICAL",
"NO_HISTORICAL_LIGATURES": "NO_HISTORICAL",
"CONTEXTUAL": "CONTEXTUAL",
"NO_CONTEXTUAL": "NO_CONTEXTUAL" } %>
${impl_bitflags_setter('font_variant_ligatures',
'mFont.variantLigatures',
font_variant_ligatures_map,
'NS_FONT_VARIANT_LIGATURES_',
cast_type='u16')}
${impl_simple_copy('font_variant_ligatures', 'mFont.variantLigatures')}
pub fn set_font_variant_east_asian(&mut self, v: longhands::font_variant_east_asian::computed_value::T) {
self.gecko.mFont.variantEastAsian = v.to_gecko_keyword()
}
// servo_bit: gecko_bit
<% font_variant_east_asian_map = { "JIS78": "JIS78",
"JIS83": "JIS83",
"JIS90": "JIS90",
"JIS04": "JIS04",
"SIMPLIFIED": "SIMPLIFIED",
"TRADITIONAL": "TRADITIONAL",
"FULL_WIDTH": "FULL_WIDTH",
"PROPORTIONAL_WIDTH": "PROP_WIDTH",
"RUBY": "RUBY" } %>
${impl_bitflags_setter('font_variant_east_asian',
'mFont.variantEastAsian',
font_variant_east_asian_map,
'NS_FONT_VARIANT_EAST_ASIAN_',
cast_type='u16')}
${impl_simple_copy('font_variant_east_asian', 'mFont.variantEastAsian')}
pub fn set_font_variant_numeric(&mut self, v: longhands::font_variant_numeric::computed_value::T) {
self.gecko.mFont.variantNumeric = v.to_gecko_keyword()
}
// servo_bit: gecko_bit
<% font_variant_numeric_map = { "LINING_NUMS": "LINING",
"OLDSTYLE_NUMS": "OLDSTYLE",
"PROPORTIONAL_NUMS": "PROPORTIONAL",
"TABULAR_NUMS": "TABULAR",
"DIAGONAL_FRACTIONS": "DIAGONAL_FRACTIONS",
"STACKED_FRACTIONS": "STACKED_FRACTIONS",
"SLASHED_ZERO": "SLASHZERO",
"ORDINAL": "ORDINAL" } %>
${impl_bitflags_setter('font_variant_numeric',
'mFont.variantNumeric',
font_variant_numeric_map,
'NS_FONT_VARIANT_NUMERIC_')}
${impl_simple_copy('font_variant_numeric', 'mFont.variantNumeric')}
</%self:impl_trait>