mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Implement MallocSizeOf for PropertyDeclaration by hand
We merge arms with identical field types.
This commit is contained in:
parent
456c18f767
commit
1f0a1267bb
1 changed files with 18 additions and 1 deletions
|
@ -33,6 +33,7 @@ use font_metrics::FontMetricsProvider;
|
|||
#[cfg(feature = "servo")] use logical_geometry::LogicalMargin;
|
||||
#[cfg(feature = "servo")] use computed_values;
|
||||
use logical_geometry::WritingMode;
|
||||
#[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
use media_queries::Device;
|
||||
use parser::ParserContext;
|
||||
#[cfg(feature = "gecko")] use properties::longhands::system_font::SystemFont;
|
||||
|
@ -267,7 +268,6 @@ pub mod animated_properties {
|
|||
%>
|
||||
|
||||
/// Servo's representation for a property declaration.
|
||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
#[repr(u16)]
|
||||
pub enum PropertyDeclaration {
|
||||
% for variant in variants:
|
||||
|
@ -339,6 +339,23 @@ impl PartialEq for PropertyDeclaration {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl MallocSizeOf for PropertyDeclaration {
|
||||
#[inline]
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
use self::PropertyDeclaration::*;
|
||||
|
||||
match *self {
|
||||
% for ty, variants in groups.iteritems():
|
||||
${" | ".join("{}(ref value)".format(v) for v in variants)} => {
|
||||
value.size_of(ops)
|
||||
}
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl PropertyDeclaration {
|
||||
/// Like the method on ToCss, but without the type parameter to avoid
|
||||
/// accidentally monomorphizing this large function multiple times for
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue