mirror of
https://github.com/servo/servo.git
synced 2025-07-03 05:23:38 +01:00
Auto merge of #10324 - perlun:rename-style-structs, r=bholley
Renamed the style structs Renamed style structs. The idea is to rename all style structs from Foo to ServoFoo, as described out in #10185. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10324) <!-- Reviewable:end -->
This commit is contained in:
commit
4da38cdd7c
7 changed files with 110 additions and 100 deletions
|
@ -16,7 +16,7 @@ use std::str;
|
|||
use std::sync::Arc;
|
||||
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
|
||||
use style::computed_values::{font_stretch, font_variant, font_weight};
|
||||
use style::properties::style_structs::Font as FontStyle;
|
||||
use style::properties::style_structs::ServoFont;
|
||||
use text::Shaper;
|
||||
use text::glyph::{GlyphId, GlyphStore};
|
||||
use text::shaping::ShaperMethods;
|
||||
|
@ -88,7 +88,7 @@ pub struct FontMetrics {
|
|||
pub line_gap: Au,
|
||||
}
|
||||
|
||||
pub type SpecifiedFontStyle = FontStyle;
|
||||
pub type SpecifiedFontStyle = ServoFont;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Font {
|
||||
|
@ -266,4 +266,3 @@ pub fn get_and_reset_text_shaping_performance_counter() -> usize {
|
|||
TEXT_SHAPING_PERFORMANCE_COUNTER.store(0, Ordering::SeqCst);
|
||||
value
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ use style::computed_values::{background_repeat, background_size};
|
|||
use style::computed_values::{border_style, image_rendering, overflow_x, position};
|
||||
use style::computed_values::{transform, transform_style, visibility};
|
||||
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::style_structs::Border;
|
||||
use style::properties::style_structs::ServoBorder;
|
||||
use style::properties::{self, ComputedValues, ServoComputedValues};
|
||||
use style::values::RGBA;
|
||||
use style::values::computed;
|
||||
|
@ -306,7 +306,7 @@ fn handle_overlapping_radii(size: &Size2D<Au>, radii: &BorderRadii<Au>) -> Borde
|
|||
}
|
||||
}
|
||||
|
||||
fn build_border_radius(abs_bounds: &Rect<Au>, border_style: &Border) -> BorderRadii<Au> {
|
||||
fn build_border_radius(abs_bounds: &Rect<Au>, border_style: &ServoBorder) -> BorderRadii<Au> {
|
||||
// TODO(cgaebel): Support border radii even in the case of multiple border widths.
|
||||
// This is an extension of supporting elliptical radii. For now, all percentage
|
||||
// radii will be relative to the width.
|
||||
|
|
|
@ -388,7 +388,7 @@ impl ParentOffsetBorderBoxIterator {
|
|||
|
||||
impl FragmentBorderBoxIterator for FragmentLocatingFragmentIterator {
|
||||
fn process(&mut self, fragment: &Fragment, _: i32, border_box: &Rect<Au>) {
|
||||
let style_structs::Border {
|
||||
let style_structs::ServoBorder {
|
||||
border_top_width: top_width,
|
||||
border_right_width: right_width,
|
||||
border_bottom_width: bottom_width,
|
||||
|
@ -414,7 +414,7 @@ impl FragmentBorderBoxIterator for UnioningFragmentScrollAreaIterator {
|
|||
// increase in size. To work around this, we store the original elements padding
|
||||
// rectangle as `origin_rect` and the union of all child elements padding and
|
||||
// margin rectangles as `union_rect`.
|
||||
let style_structs::Border {
|
||||
let style_structs::ServoBorder {
|
||||
border_top_width: top_border,
|
||||
border_right_width: right_border,
|
||||
border_bottom_width: bottom_border,
|
||||
|
|
|
@ -24,7 +24,7 @@ use std::sync::Arc;
|
|||
use style::computed_values::{line_height, text_orientation, text_rendering, text_transform};
|
||||
use style::computed_values::{white_space};
|
||||
use style::logical_geometry::{LogicalSize, WritingMode};
|
||||
use style::properties::style_structs::Font as FontStyle;
|
||||
use style::properties::style_structs::ServoFont;
|
||||
use style::properties::{ComputedValues, ServoComputedValues};
|
||||
use unicode_bidi::{is_rtl, process_text};
|
||||
use unicode_script::{get_script, Script};
|
||||
|
@ -409,11 +409,11 @@ fn bounding_box_for_run_metrics(metrics: &RunMetrics, writing_mode: WritingMode)
|
|||
|
||||
}
|
||||
|
||||
/// Returns the metrics of the font represented by the given `FontStyle`, respectively.
|
||||
/// Returns the metrics of the font represented by the given `ServoFont`, respectively.
|
||||
///
|
||||
/// `#[inline]` because often the caller only needs a few fields from the font metrics.
|
||||
#[inline]
|
||||
pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: Arc<FontStyle>)
|
||||
pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: Arc<ServoFont>)
|
||||
-> FontMetrics {
|
||||
let fontgroup = font_context.layout_font_group_for_style(font_style);
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
|
|
|
@ -112,12 +112,15 @@ class Method(object):
|
|||
return self.signature() + "{ unimplemented!() }"
|
||||
|
||||
class StyleStruct(object):
|
||||
def __init__(self, name, inherited, gecko_name, additional_methods):
|
||||
self.name = name
|
||||
self.ident = to_rust_ident(name.lower())
|
||||
def __init__(self, name, inherited, gecko_ffi_name, additional_methods):
|
||||
self.servo_struct_name = "Servo" + name
|
||||
self.gecko_struct_name = "Gecko" + name
|
||||
self.trait_name = name
|
||||
self.trait_name_lower = name.lower()
|
||||
self.ident = to_rust_ident(self.trait_name_lower)
|
||||
self.longhands = []
|
||||
self.inherited = inherited
|
||||
self.gecko_name = gecko_name
|
||||
self.gecko_ffi_name = gecko_ffi_name
|
||||
self.additional_methods = additional_methods or []
|
||||
|
||||
STYLE_STRUCTS = []
|
||||
|
@ -144,10 +147,10 @@ def switch_to_style_struct(name):
|
|||
global THIS_STYLE_STRUCT
|
||||
|
||||
for style_struct in STYLE_STRUCTS:
|
||||
if style_struct.name == name:
|
||||
if style_struct.trait_name == name:
|
||||
THIS_STYLE_STRUCT = style_struct
|
||||
return ""
|
||||
fail()
|
||||
raise Exception("Failed to find the struct named " + name)
|
||||
%>
|
||||
|
||||
// Work around Mako's really annoying namespacing setup.
|
||||
|
@ -199,7 +202,7 @@ pub mod longhands {
|
|||
use properties::longhands;
|
||||
use properties::property_bit_field::PropertyBitField;
|
||||
use properties::{ComputedValues, ServoComputedValues, PropertyDeclaration};
|
||||
use properties::style_struct_traits::T${THIS_STYLE_STRUCT.name};
|
||||
use properties::style_struct_traits::T${THIS_STYLE_STRUCT.trait_name};
|
||||
use properties::style_structs;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
@ -232,15 +235,16 @@ pub mod longhands {
|
|||
declared_value, &custom_props, |value| match *value {
|
||||
DeclaredValue::Value(ref specified_value) => {
|
||||
let computed = specified_value.to_computed_value(context);
|
||||
context.mutate_style().mutate_${THIS_STYLE_STRUCT.name.lower()}()
|
||||
context.mutate_style().mutate_${THIS_STYLE_STRUCT.trait_name_lower}()
|
||||
.set_${property.ident}(computed);
|
||||
}
|
||||
DeclaredValue::WithVariables { .. } => unreachable!(),
|
||||
DeclaredValue::Initial => {
|
||||
// We assume that it's faster to use copy_*_from rather than
|
||||
// set_*(get_initial_value());
|
||||
let initial_struct = C::initial_values().get_${THIS_STYLE_STRUCT.name.lower()}();
|
||||
context.mutate_style().mutate_${THIS_STYLE_STRUCT.name.lower()}()
|
||||
let initial_struct = C::initial_values()
|
||||
.get_${THIS_STYLE_STRUCT.trait_name_lower}();
|
||||
context.mutate_style().mutate_${THIS_STYLE_STRUCT.trait_name_lower}()
|
||||
.copy_${property.ident}_from(initial_struct);
|
||||
},
|
||||
DeclaredValue::Inherit => {
|
||||
|
@ -249,8 +253,8 @@ pub mod longhands {
|
|||
//
|
||||
// FIXME: is it still?
|
||||
*cacheable = false;
|
||||
let inherited_struct = inherited_style.get_${THIS_STYLE_STRUCT.name.lower()}();
|
||||
context.mutate_style().mutate_${THIS_STYLE_STRUCT.name.lower()}()
|
||||
let inherited_struct = inherited_style.get_${THIS_STYLE_STRUCT.trait_name_lower}();
|
||||
context.mutate_style().mutate_${THIS_STYLE_STRUCT.trait_name_lower}()
|
||||
.copy_${property.ident}_from(inherited_struct);
|
||||
}
|
||||
}, error_reporter
|
||||
|
@ -6163,7 +6167,7 @@ pub mod style_struct_traits {
|
|||
use super::longhands;
|
||||
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
pub trait T${style_struct.name}: Clone {
|
||||
pub trait T${style_struct.trait_name}: Clone {
|
||||
% for longhand in style_struct.longhands:
|
||||
#[allow(non_snake_case)]
|
||||
fn set_${longhand.ident}(&mut self, v: longhands::${longhand.ident}::computed_value::T);
|
||||
|
@ -6184,23 +6188,23 @@ pub mod style_structs {
|
|||
use std::hash::{Hash, Hasher};
|
||||
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
% if style_struct.name == "Font":
|
||||
% if style_struct.trait_name == "Font":
|
||||
#[derive(Clone, HeapSizeOf, Debug)]
|
||||
% else:
|
||||
#[derive(PartialEq, Clone, HeapSizeOf)]
|
||||
% endif
|
||||
pub struct ${style_struct.name} {
|
||||
pub struct ${style_struct.servo_struct_name} {
|
||||
% for longhand in style_struct.longhands:
|
||||
pub ${longhand.ident}: longhands::${longhand.ident}::computed_value::T,
|
||||
% endfor
|
||||
% if style_struct.name == "Font":
|
||||
% if style_struct.trait_name == "Font":
|
||||
pub hash: u64,
|
||||
% endif
|
||||
}
|
||||
% if style_struct.name == "Font":
|
||||
% if style_struct.trait_name == "Font":
|
||||
|
||||
impl PartialEq for ${style_struct.name} {
|
||||
fn eq(&self, other: &${style_struct.name}) -> bool {
|
||||
impl PartialEq for ${style_struct.servo_struct_name} {
|
||||
fn eq(&self, other: &${style_struct.servo_struct_name}) -> bool {
|
||||
self.hash == other.hash
|
||||
% for longhand in style_struct.longhands:
|
||||
&& self.${longhand.ident} == other.${longhand.ident}
|
||||
|
@ -6209,7 +6213,7 @@ pub mod style_structs {
|
|||
}
|
||||
% endif
|
||||
|
||||
impl super::style_struct_traits::T${style_struct.name} for ${style_struct.name} {
|
||||
impl super::style_struct_traits::T${style_struct.trait_name} for ${style_struct.servo_struct_name} {
|
||||
% for longhand in style_struct.longhands:
|
||||
fn set_${longhand.ident}(&mut self, v: longhands::${longhand.ident}::computed_value::T) {
|
||||
self.${longhand.ident} = v;
|
||||
|
@ -6218,14 +6222,14 @@ pub mod style_structs {
|
|||
self.${longhand.ident} = other.${longhand.ident}.clone();
|
||||
}
|
||||
% endfor
|
||||
% if style_struct.name == "Border":
|
||||
% if style_struct.trait_name == "Border":
|
||||
% for side in ["top", "right", "bottom", "left"]:
|
||||
fn border_${side}_is_none_or_hidden_and_has_nonzero_width(&self) -> bool {
|
||||
self.border_${side}_style.none_or_hidden() &&
|
||||
self.border_${side}_width != ::app_units::Au(0)
|
||||
}
|
||||
% endfor
|
||||
% elif style_struct.name == "Box":
|
||||
% elif style_struct.trait_name == "Box":
|
||||
fn clone_display(&self) -> longhands::display::computed_value::T {
|
||||
self.display.clone()
|
||||
}
|
||||
|
@ -6244,11 +6248,11 @@ pub mod style_structs {
|
|||
fn transition_count(&self) -> usize {
|
||||
self.transition_property.0.len()
|
||||
}
|
||||
% elif style_struct.name == "Color":
|
||||
% elif style_struct.trait_name == "Color":
|
||||
fn clone_color(&self) -> longhands::color::computed_value::T {
|
||||
self.color.clone()
|
||||
}
|
||||
% elif style_struct.name == "Font":
|
||||
% elif style_struct.trait_name == "Font":
|
||||
fn clone_font_size(&self) -> longhands::font_size::computed_value::T {
|
||||
self.font_size.clone()
|
||||
}
|
||||
|
@ -6263,7 +6267,7 @@ pub mod style_structs {
|
|||
self.font_family.hash(&mut hasher);
|
||||
self.hash = hasher.finish()
|
||||
}
|
||||
% elif style_struct.name == "InheritedBox":
|
||||
% elif style_struct.trait_name == "InheritedBox":
|
||||
fn clone_direction(&self) -> longhands::direction::computed_value::T {
|
||||
self.direction.clone()
|
||||
}
|
||||
|
@ -6273,16 +6277,16 @@ pub mod style_structs {
|
|||
fn clone_text_orientation(&self) -> longhands::text_orientation::computed_value::T {
|
||||
self.text_orientation.clone()
|
||||
}
|
||||
% elif style_struct.name == "InheritedText":
|
||||
% elif style_struct.trait_name == "InheritedText":
|
||||
fn clone__servo_text_decorations_in_effect(&self) ->
|
||||
longhands::_servo_text_decorations_in_effect::computed_value::T {
|
||||
self._servo_text_decorations_in_effect.clone()
|
||||
}
|
||||
% elif style_struct.name == "Outline":
|
||||
% elif style_struct.trait_name == "Outline":
|
||||
fn outline_is_none_or_hidden_and_has_nonzero_width(&self) -> bool {
|
||||
self.outline_style.none_or_hidden() && self.outline_width != ::app_units::Au(0)
|
||||
}
|
||||
% elif style_struct.name == "Text":
|
||||
% elif style_struct.trait_name == "Text":
|
||||
fn has_underline(&self) -> bool {
|
||||
self.text_decoration.underline
|
||||
}
|
||||
|
@ -6300,7 +6304,7 @@ pub mod style_structs {
|
|||
|
||||
pub trait ComputedValues : Clone + Send + Sync + 'static {
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
type Concrete${style_struct.name}: style_struct_traits::T${style_struct.name};
|
||||
type Concrete${style_struct.trait_name}: style_struct_traits::T${style_struct.trait_name};
|
||||
% endfor
|
||||
|
||||
// Temporary bailout case for stuff we haven't made work with the trait
|
||||
|
@ -6315,7 +6319,7 @@ pub trait ComputedValues : Clone + Send + Sync + 'static {
|
|||
writing_mode: WritingMode,
|
||||
root_font_size: Au,
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
${style_struct.ident}: Arc<Self::Concrete${style_struct.name}>,
|
||||
${style_struct.ident}: Arc<Self::Concrete${style_struct.trait_name}>,
|
||||
% endfor
|
||||
) -> Self;
|
||||
|
||||
|
@ -6324,9 +6328,12 @@ pub trait ComputedValues : Clone + Send + Sync + 'static {
|
|||
fn do_cascade_property<F: FnOnce(&Vec<Option<CascadePropertyFn<Self>>>)>(f: F);
|
||||
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
fn clone_${style_struct.name.lower()}(&self) -> Arc<Self::Concrete${style_struct.name}>;
|
||||
fn get_${style_struct.name.lower()}<'a>(&'a self) -> &'a Self::Concrete${style_struct.name};
|
||||
fn mutate_${style_struct.name.lower()}<'a>(&'a mut self) -> &'a mut Self::Concrete${style_struct.name};
|
||||
fn clone_${style_struct.trait_name_lower}(&self) ->
|
||||
Arc<Self::Concrete${style_struct.trait_name}>;
|
||||
fn get_${style_struct.trait_name_lower}<'a>(&'a self) ->
|
||||
&'a Self::Concrete${style_struct.trait_name};
|
||||
fn mutate_${style_struct.trait_name_lower}<'a>(&'a mut self) ->
|
||||
&'a mut Self::Concrete${style_struct.trait_name};
|
||||
% endfor
|
||||
|
||||
fn custom_properties(&self) -> Option<Arc<::custom_properties::ComputedValuesMap>>;
|
||||
|
@ -6339,7 +6346,7 @@ pub trait ComputedValues : Clone + Send + Sync + 'static {
|
|||
#[derive(Clone, HeapSizeOf)]
|
||||
pub struct ServoComputedValues {
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
|
||||
${style_struct.ident}: Arc<style_structs::${style_struct.servo_struct_name}>,
|
||||
% endfor
|
||||
custom_properties: Option<Arc<::custom_properties::ComputedValuesMap>>,
|
||||
shareable: bool,
|
||||
|
@ -6349,7 +6356,7 @@ pub struct ServoComputedValues {
|
|||
|
||||
impl ComputedValues for ServoComputedValues {
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
type Concrete${style_struct.name} = style_structs::${style_struct.name};
|
||||
type Concrete${style_struct.trait_name} = style_structs::${style_struct.servo_struct_name};
|
||||
% endfor
|
||||
|
||||
fn as_servo<'a>(&'a self) -> &'a ServoComputedValues { self }
|
||||
|
@ -6360,7 +6367,7 @@ impl ComputedValues for ServoComputedValues {
|
|||
writing_mode: WritingMode,
|
||||
root_font_size: Au,
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
|
||||
${style_struct.ident}: Arc<style_structs::${style_struct.servo_struct_name}>,
|
||||
% endfor
|
||||
) -> Self {
|
||||
ServoComputedValues {
|
||||
|
@ -6382,17 +6389,20 @@ impl ComputedValues for ServoComputedValues {
|
|||
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
#[inline]
|
||||
fn clone_${style_struct.name.lower()}(&self) -> Arc<Self::Concrete${style_struct.name}> {
|
||||
self.${style_struct.ident}.clone()
|
||||
}
|
||||
fn clone_${style_struct.trait_name_lower}(&self) ->
|
||||
Arc<Self::Concrete${style_struct.trait_name}> {
|
||||
self.${style_struct.ident}.clone()
|
||||
}
|
||||
#[inline]
|
||||
fn get_${style_struct.name.lower()}<'a>(&'a self) -> &'a Self::Concrete${style_struct.name} {
|
||||
&self.${style_struct.ident}
|
||||
}
|
||||
fn get_${style_struct.trait_name_lower}<'a>(&'a self) ->
|
||||
&'a Self::Concrete${style_struct.trait_name} {
|
||||
&self.${style_struct.ident}
|
||||
}
|
||||
#[inline]
|
||||
fn mutate_${style_struct.name.lower()}<'a>(&'a mut self) -> &'a mut Self::Concrete${style_struct.name} {
|
||||
Arc::make_mut(&mut self.${style_struct.ident})
|
||||
}
|
||||
fn mutate_${style_struct.trait_name_lower}<'a>(&'a mut self) ->
|
||||
&'a mut Self::Concrete${style_struct.trait_name} {
|
||||
Arc::make_mut(&mut self.${style_struct.ident})
|
||||
}
|
||||
% endfor
|
||||
|
||||
// Cloning the Arc here is fine because it only happens in the case where we have custom
|
||||
|
@ -6513,7 +6523,7 @@ impl ServoComputedValues {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_font_arc(&self) -> Arc<style_structs::Font> {
|
||||
pub fn get_font_arc(&self) -> Arc<style_structs::ServoFont> {
|
||||
self.font.clone()
|
||||
}
|
||||
|
||||
|
@ -6634,11 +6644,11 @@ pub fn get_writing_mode<S: style_struct_traits::TInheritedBox>(inheritedbox_styl
|
|||
lazy_static! {
|
||||
pub static ref INITIAL_SERVO_VALUES: ServoComputedValues = ServoComputedValues {
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
${style_struct.ident}: Arc::new(style_structs::${style_struct.name} {
|
||||
${style_struct.ident}: Arc::new(style_structs::${style_struct.servo_struct_name} {
|
||||
% for longhand in style_struct.longhands:
|
||||
${longhand.ident}: longhands::${longhand.ident}::get_initial_value(),
|
||||
% endfor
|
||||
% if style_struct.name == "Font":
|
||||
% if style_struct.trait_name == "Font":
|
||||
hash: 0,
|
||||
% endif
|
||||
}),
|
||||
|
@ -6677,7 +6687,7 @@ fn cascade_with_cached_declarations<C: ComputedValues>(
|
|||
% else:
|
||||
cached_style
|
||||
% endif
|
||||
.clone_${style_struct.name.lower()}(),
|
||||
.clone_${style_struct.trait_name_lower}(),
|
||||
% endfor
|
||||
),
|
||||
};
|
||||
|
@ -6694,7 +6704,7 @@ fn cascade_with_cached_declarations<C: ComputedValues>(
|
|||
PropertyDeclaration::${property.camel_case}(ref
|
||||
${'_' if not style_struct.inherited else ''}declared_value)
|
||||
=> {
|
||||
use properties::style_struct_traits::T${style_struct.name};
|
||||
use properties::style_struct_traits::T${style_struct.trait_name};
|
||||
% if style_struct.inherited:
|
||||
if seen.get_${property.ident}() {
|
||||
continue
|
||||
|
@ -6707,14 +6717,14 @@ fn cascade_with_cached_declarations<C: ComputedValues>(
|
|||
DeclaredValue::Value(ref specified_value)
|
||||
=> {
|
||||
let computed = specified_value.to_computed_value(&context);
|
||||
context.mutate_style().mutate_${style_struct.name.lower()}()
|
||||
context.mutate_style().mutate_${style_struct.trait_name_lower}()
|
||||
.set_${property.ident}(computed);
|
||||
},
|
||||
DeclaredValue::Initial
|
||||
=> {
|
||||
// FIXME(bholley): We may want set_X_to_initial_value() here.
|
||||
let initial = longhands::${property.ident}::get_initial_value();
|
||||
context.mutate_style().mutate_${style_struct.name.lower()}()
|
||||
context.mutate_style().mutate_${style_struct.trait_name_lower}()
|
||||
.set_${property.ident}(initial);
|
||||
},
|
||||
DeclaredValue::Inherit => {
|
||||
|
@ -6723,7 +6733,7 @@ fn cascade_with_cached_declarations<C: ComputedValues>(
|
|||
//
|
||||
// FIXME: is it still?
|
||||
let inherited_struct = parent_style.get_${style_struct.ident}();
|
||||
context.mutate_style().mutate_${style_struct.name.lower()}()
|
||||
context.mutate_style().mutate_${style_struct.trait_name_lower}()
|
||||
.copy_${property.ident}_from(inherited_struct);
|
||||
}
|
||||
DeclaredValue::WithVariables { .. } => unreachable!()
|
||||
|
@ -6870,7 +6880,7 @@ pub fn cascade<C: ComputedValues>(
|
|||
% else:
|
||||
initial_values
|
||||
% endif
|
||||
.clone_${style_struct.name.lower()}(),
|
||||
.clone_${style_struct.trait_name_lower}(),
|
||||
% endfor
|
||||
),
|
||||
};
|
||||
|
|
|
@ -62,8 +62,7 @@ try:
|
|||
style_template.render(PRODUCT='gecko')
|
||||
|
||||
geckolib_template = Template(filename=os.environ['GECKOLIB_TEMPLATE'], input_encoding='utf8')
|
||||
output = geckolib_template.render(STYLE_STRUCTS = style_template.module.STYLE_STRUCTS,
|
||||
LONGHANDS = style_template.module.LONGHANDS)
|
||||
output = geckolib_template.render(STYLE_STRUCTS = style_template.module.STYLE_STRUCTS)
|
||||
print(output.encode('utf8'))
|
||||
except:
|
||||
sys.stderr.write(exceptions.text_error_template().render().encode('utf8'))
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// STYLE_STRUCTS comes from components/style/properties.mako.rs; see build.rs for more details.
|
||||
|
||||
use app_units::Au;
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
%if style_struct.gecko_name:
|
||||
use gecko_style_structs::${style_struct.gecko_name};
|
||||
use bindings::Gecko_Construct_${style_struct.gecko_name};
|
||||
use bindings::Gecko_CopyConstruct_${style_struct.gecko_name};
|
||||
use bindings::Gecko_Destroy_${style_struct.gecko_name};
|
||||
%if style_struct.gecko_ffi_name:
|
||||
use gecko_style_structs::${style_struct.gecko_ffi_name};
|
||||
use bindings::Gecko_Construct_${style_struct.gecko_ffi_name};
|
||||
use bindings::Gecko_CopyConstruct_${style_struct.gecko_ffi_name};
|
||||
use bindings::Gecko_Destroy_${style_struct.gecko_ffi_name};
|
||||
% endif
|
||||
% endfor
|
||||
use heapsize::HeapSizeOf;
|
||||
|
@ -25,7 +27,7 @@ use style::properties::style_struct_traits::*;
|
|||
#[derive(Clone)]
|
||||
pub struct GeckoComputedValues {
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
${style_struct.ident}: Arc<Gecko${style_struct.name}>,
|
||||
${style_struct.ident}: Arc<${style_struct.gecko_struct_name}>,
|
||||
% endfor
|
||||
|
||||
custom_properties: Option<Arc<ComputedValuesMap>>,
|
||||
|
@ -36,7 +38,7 @@ pub struct GeckoComputedValues {
|
|||
|
||||
impl ComputedValues for GeckoComputedValues {
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
type Concrete${style_struct.name} = Gecko${style_struct.name};
|
||||
type Concrete${style_struct.trait_name} = ${style_struct.gecko_struct_name};
|
||||
% endfor
|
||||
|
||||
// These will go away, and we will never implement them.
|
||||
|
@ -48,7 +50,7 @@ impl ComputedValues for GeckoComputedValues {
|
|||
writing_mode: WritingMode,
|
||||
root_font_size: Au,
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
${style_struct.ident}: Arc<Gecko${style_struct.name}>,
|
||||
${style_struct.ident}: Arc<${style_struct.gecko_struct_name}>,
|
||||
% endfor
|
||||
) -> Self {
|
||||
GeckoComputedValues {
|
||||
|
@ -70,15 +72,15 @@ impl ComputedValues for GeckoComputedValues {
|
|||
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
#[inline]
|
||||
fn clone_${style_struct.name.lower()}(&self) -> Arc<Self::Concrete${style_struct.name}> {
|
||||
fn clone_${style_struct.trait_name_lower}(&self) -> Arc<Self::Concrete${style_struct.trait_name}> {
|
||||
self.${style_struct.ident}.clone()
|
||||
}
|
||||
#[inline]
|
||||
fn get_${style_struct.name.lower()}<'a>(&'a self) -> &'a Self::Concrete${style_struct.name} {
|
||||
fn get_${style_struct.trait_name_lower}<'a>(&'a self) -> &'a Self::Concrete${style_struct.trait_name} {
|
||||
&self.${style_struct.ident}
|
||||
}
|
||||
#[inline]
|
||||
fn mutate_${style_struct.name.lower()}<'a>(&'a mut self) -> &'a mut Self::Concrete${style_struct.name} {
|
||||
fn mutate_${style_struct.trait_name_lower}<'a>(&'a mut self) -> &'a mut Self::Concrete${style_struct.trait_name} {
|
||||
Arc::make_mut(&mut self.${style_struct.ident})
|
||||
}
|
||||
% endfor
|
||||
|
@ -94,54 +96,54 @@ impl ComputedValues for GeckoComputedValues {
|
|||
|
||||
<%def name="declare_style_struct(style_struct)">
|
||||
#[derive(Clone, HeapSizeOf, Debug)]
|
||||
% if style_struct.gecko_name:
|
||||
pub struct Gecko${style_struct.name} {
|
||||
gecko: ${style_struct.gecko_name},
|
||||
% if style_struct.gecko_ffi_name:
|
||||
pub struct ${style_struct.gecko_struct_name} {
|
||||
gecko: ${style_struct.gecko_ffi_name},
|
||||
}
|
||||
% else:
|
||||
pub struct Gecko${style_struct.name};
|
||||
pub struct ${style_struct.gecko_struct_name};
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
<%def name="impl_style_struct(style_struct)">
|
||||
impl Gecko${style_struct.name} {
|
||||
impl ${style_struct.gecko_struct_name} {
|
||||
#[allow(dead_code, unused_variables)]
|
||||
fn initial() -> Self {
|
||||
% if style_struct.gecko_name:
|
||||
let mut result = Gecko${style_struct.name} { gecko: unsafe { zeroed() } };
|
||||
% if style_struct.gecko_ffi_name:
|
||||
let mut result = ${style_struct.gecko_struct_name} { gecko: unsafe { zeroed() } };
|
||||
unsafe {
|
||||
Gecko_Construct_${style_struct.gecko_name}(&mut result.gecko);
|
||||
Gecko_Construct_${style_struct.gecko_ffi_name}(&mut result.gecko);
|
||||
}
|
||||
result
|
||||
% else:
|
||||
Gecko${style_struct.name}
|
||||
${style_struct.gecko_struct_name}
|
||||
% endif
|
||||
}
|
||||
}
|
||||
%if style_struct.gecko_name:
|
||||
impl Drop for Gecko${style_struct.name} {
|
||||
%if style_struct.gecko_ffi_name:
|
||||
impl Drop for ${style_struct.gecko_struct_name} {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
Gecko_Destroy_${style_struct.gecko_name}(&mut self.gecko);
|
||||
Gecko_Destroy_${style_struct.gecko_ffi_name}(&mut self.gecko);
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Clone for ${style_struct.gecko_name} {
|
||||
impl Clone for ${style_struct.gecko_ffi_name} {
|
||||
fn clone(&self) -> Self {
|
||||
unsafe {
|
||||
let mut result: Self = zeroed();
|
||||
Gecko_CopyConstruct_${style_struct.gecko_name}(&mut result, self);
|
||||
Gecko_CopyConstruct_${style_struct.gecko_ffi_name}(&mut result, self);
|
||||
result
|
||||
}
|
||||
}
|
||||
}
|
||||
unsafe impl Send for ${style_struct.gecko_name} {}
|
||||
unsafe impl Sync for ${style_struct.gecko_name} {}
|
||||
impl HeapSizeOf for ${style_struct.gecko_name} {
|
||||
unsafe impl Send for ${style_struct.gecko_ffi_name} {}
|
||||
unsafe impl Sync for ${style_struct.gecko_ffi_name} {}
|
||||
impl HeapSizeOf for ${style_struct.gecko_ffi_name} {
|
||||
// Not entirely accurate, but good enough for now.
|
||||
fn heap_size_of_children(&self) -> usize { 0 }
|
||||
}
|
||||
impl Debug for ${style_struct.gecko_name} {
|
||||
impl Debug for ${style_struct.gecko_ffi_name} {
|
||||
// FIXME(bholley): Generate this.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "GECKO STYLE STRUCT")
|
||||
|
@ -151,7 +153,7 @@ impl Debug for ${style_struct.gecko_name} {
|
|||
</%def>
|
||||
|
||||
<%def name="raw_impl_trait(style_struct, skip_longhands=None, skip_additionals=None)">
|
||||
impl T${style_struct.name} for Gecko${style_struct.name} {
|
||||
impl T${style_struct.trait_name} for ${style_struct.gecko_struct_name} {
|
||||
/*
|
||||
* Manually-Implemented Methods.
|
||||
*/
|
||||
|
@ -180,8 +182,8 @@ impl T${style_struct.name} for Gecko${style_struct.name} {
|
|||
|
||||
<%! MANUAL_STYLE_STRUCTS = [] %>
|
||||
<%def name="impl_trait(style_struct_name, skip_longhands=None, skip_additionals=None)">
|
||||
<%self:raw_impl_trait style_struct="${next(x for x in STYLE_STRUCTS if x.name == style_struct_name)}"
|
||||
skip_longhands="${skip_longhands}" skip_additionals="${skip_additionals}">
|
||||
<%self:raw_impl_trait style_struct="${next(x for x in STYLE_STRUCTS if x.trait_name == style_struct_name)}"
|
||||
skip_longhands="${skip_longhands}" skip_additionals="${skip_additionals}">
|
||||
${caller.body()}
|
||||
</%self:raw_impl_trait>
|
||||
<% MANUAL_STYLE_STRUCTS.append(style_struct_name) %>
|
||||
|
@ -214,7 +216,7 @@ ${caller.body()}
|
|||
% for style_struct in STYLE_STRUCTS:
|
||||
${declare_style_struct(style_struct)}
|
||||
${impl_style_struct(style_struct)}
|
||||
% if not style_struct.name in MANUAL_STYLE_STRUCTS:
|
||||
% if not style_struct.trait_name in MANUAL_STYLE_STRUCTS:
|
||||
<%self:raw_impl_trait style_struct="${style_struct}"></%self:raw_impl_trait>
|
||||
% endif
|
||||
% endfor
|
||||
|
@ -222,7 +224,7 @@ ${impl_style_struct(style_struct)}
|
|||
lazy_static! {
|
||||
pub static ref INITIAL_GECKO_VALUES: GeckoComputedValues = GeckoComputedValues {
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
${style_struct.ident}: Arc::new(Gecko${style_struct.name}::initial()),
|
||||
${style_struct.ident}: Arc::new(${style_struct.gecko_struct_name}::initial()),
|
||||
% endfor
|
||||
custom_properties: None,
|
||||
shareable: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue