mirror of
https://github.com/servo/servo.git
synced 2025-08-10 16:05:43 +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
|
@ -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