Measure PropertyDeclaration more thoroughly.

This patch replaces the handwritten MallocSizeOf implementation for
PropertyDeclaration with a derived one, which gives much more thorough
measurement.

This requires (a) deriving MallocSizeOf for a *lot* of additional types (most
of which already have `derive(HeapSizeOf)` in Servo builds), and (b)
implementing MallocSizeOf for a few more types in the `malloc_size_of` crate.

These changes would significantly improve the reporting coverage for gmail if
it weren't for the fact that SpecifiedUrl isn't measured due to a lack of
clarity about its fields; that can be fixed as a follow-up once bug 1397971 has
landed.
This commit is contained in:
Nicholas Nethercote 2017-09-14 13:18:03 +10:00
parent 1aa8be392b
commit c5aa2cb986
66 changed files with 302 additions and 59 deletions

View file

@ -117,6 +117,7 @@
use values::computed::ComputedVecIter;
/// The computed value, effectively a list of single values.
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq)]
% if need_animatable or animation_value_type == "ComputedValue":
@ -178,6 +179,7 @@
/// The specified value of ${name}.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue(pub Vec<single_value::SpecifiedValue>);
@ -443,6 +445,7 @@
${gecko_keyword_conversion(keyword, keyword.values_for(product), type="T", cast_to="i32")}
}
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss)]
pub enum SpecifiedValue {
Keyword(computed_value::T),
@ -941,6 +944,7 @@
pub type T = ::values::computed::${length_type};
}
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub struct SpecifiedValue(pub ${length_type});

View file

@ -202,6 +202,7 @@ pub fn nscsspropertyid_is_animatable(property: nsCSSPropertyID) -> bool {
/// a shorthand with at least one transitionable longhand component, or an unsupported property.
// NB: This needs to be here because it needs all the longhands generated
// beforehand.
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, Eq, Hash, PartialEq, ToCss, ToComputedValue)]
pub enum TransitionProperty {

View file

@ -53,6 +53,7 @@ ${helpers.predefined_type("background-image", "ImageLayer",
"round" => Round,
"no-repeat" => NoRepeat);
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub enum SpecifiedValue {
@ -65,6 +66,7 @@ ${helpers.predefined_type("background-image", "ImageLayer",
pub use super::RepeatKeyword;
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub RepeatKeyword, pub RepeatKeyword);
}

View file

@ -82,11 +82,13 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
pub mod computed_value {
use cssparser::RGBA;
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub Option<Vec<RGBA>>);
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue {
None,
@ -233,11 +235,13 @@ ${helpers.predefined_type("border-image-outset", "LengthOrNumberRect",
pub mod computed_value {
pub use super::RepeatKeyword;
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub struct T(pub RepeatKeyword, pub RepeatKeyword);
}
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub struct SpecifiedValue(pub RepeatKeyword,

View file

@ -137,6 +137,7 @@
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
pub enum SpecifiedValue {
% for value in values:
@ -407,6 +408,7 @@ ${helpers.predefined_type("transition-delay",
}
#[derive(Clone, Debug, Eq, Hash, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue(pub Option<KeyframesName>);
@ -500,6 +502,7 @@ ${helpers.predefined_type("animation-timing-function",
}
// https://drafts.csswg.org/css-animations/#animation-iteration-count
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss, ToComputedValue)]
pub enum SpecifiedValue {
@ -635,6 +638,7 @@ ${helpers.predefined_type(
use values::computed::{Length, LengthOrPercentage};
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct ComputedMatrix {
pub m11: CSSFloat, pub m12: CSSFloat, pub m13: CSSFloat, pub m14: CSSFloat,
@ -644,6 +648,7 @@ ${helpers.predefined_type(
}
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct ComputedMatrixWithPercents {
pub m11: CSSFloat, pub m12: CSSFloat, pub m13: CSSFloat, pub m14: CSSFloat,
@ -677,6 +682,7 @@ ${helpers.predefined_type(
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum ComputedOperation {
Matrix(ComputedMatrix),
@ -710,6 +716,7 @@ ${helpers.predefined_type(
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub Option<Vec<ComputedOperation>>);
}
@ -721,6 +728,7 @@ ${helpers.predefined_type(
///
/// Some transformations can be expressed by other more general functions.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedOperation {
/// Represents a 2D 2x3 matrix.
@ -911,6 +919,7 @@ ${helpers.predefined_type(
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue(Vec<SpecifiedOperation>);
@ -1628,6 +1637,7 @@ ${helpers.predefined_type("transform-origin",
bitflags! {
#[derive(ToComputedValue)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub flags SpecifiedValue: u8 {
const LAYOUT = 0x01,
@ -1769,6 +1779,7 @@ ${helpers.single_keyword("-moz-orient",
}
#[derive(Clone, Debug, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue {
Auto,
@ -1840,6 +1851,7 @@ ${helpers.predefined_type(
bitflags! {
/// These constants match Gecko's `NS_STYLE_TOUCH_ACTION_*` constants.
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(ToComputedValue)]
pub flags SpecifiedValue: u8 {
const TOUCH_ACTION_NONE = structs::NS_STYLE_TOUCH_ACTION_NONE as u8,

View file

@ -67,6 +67,10 @@ pub mod system_colors {
pub type SystemColor = LookAndFeel_ColorID;
// It's hard to implement MallocSizeOf for LookAndFeel_ColorID because it
// is a bindgen type. So we implement it on the typedef instead.
size_of_is_0!(SystemColor);
impl ToCss for SystemColor {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
let s = match *self {

View file

@ -37,6 +37,7 @@
use values::specified::Attr;
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Debug, Eq, PartialEq, ToComputedValue)]
pub enum ContentItem {
/// Literal string content.
@ -97,6 +98,7 @@
}
}
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, Eq, PartialEq, ToComputedValue)]
pub enum T {
@ -236,6 +238,7 @@
use style_traits::ToCss;
use values::CustomIdent;
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Debug, PartialEq)]
pub struct SpecifiedValue(pub Vec<(CustomIdent, specified::Integer)>);
@ -245,6 +248,7 @@
use values::CustomIdent;
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub Vec<(CustomIdent, i32)>);

View file

@ -85,6 +85,7 @@ macro_rules! impl_gecko_keyword_conversions {
pub use self::FontFamily as SingleComputedValue;
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
pub enum FontFamily {
FamilyName(FamilyName),
@ -92,6 +93,7 @@ macro_rules! impl_gecko_keyword_conversions {
}
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
pub struct FamilyName {
pub name: Atom,
@ -99,6 +101,7 @@ macro_rules! impl_gecko_keyword_conversions {
}
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
pub enum FamilyNameSyntax {
/// The family name was specified in a quoted form, e.g. "Font Name"
@ -296,6 +299,7 @@ macro_rules! impl_gecko_keyword_conversions {
}
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub Vec<FontFamily>);
}
@ -313,6 +317,7 @@ macro_rules! impl_gecko_keyword_conversions {
SpecifiedValue::parse(input)
}
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum SpecifiedValue {
Values(Vec<FontFamily>),
@ -430,6 +435,7 @@ ${helpers.single_keyword_system("font-variant-caps",
use properties::longhands::system_font::SystemFont;
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss)]
pub enum SpecifiedValue {
@ -484,6 +490,7 @@ ${helpers.single_keyword_system("font-variant-caps",
/// However, system fonts may provide other values. Pango
/// may provide 350, 380, and 1000 (on top of the existing values), for example.
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, Eq, Hash, PartialEq, ToCss)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
pub struct T(pub u16);
@ -614,6 +621,7 @@ ${helpers.single_keyword_system("font-variant-caps",
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue {
Length(specified::LengthOrPercentage),
@ -646,6 +654,7 @@ ${helpers.single_keyword_system("font-variant-caps",
/// CSS font keywords
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum KeywordSize {
XXSmall = 1, // This is to enable the NonZero optimization
@ -1080,6 +1089,7 @@ ${helpers.single_keyword_system("font-variant-caps",
#[derive(Clone, Copy, Debug, PartialEq, ToCss)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue {
None,
@ -1127,6 +1137,7 @@ ${helpers.single_keyword_system("font-variant-caps",
use values::CSSFloat;
use values::animated::{ToAnimatedValue, ToAnimatedZero};
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, PartialEq, ToCss)]
pub enum T {
@ -1202,6 +1213,7 @@ ${helpers.single_keyword_system("font-variant-caps",
}
#[derive(Clone, Debug, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue {
pub weight: bool,
@ -1309,6 +1321,7 @@ ${helpers.single_keyword_system("font-kerning",
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum VariantAlternates {
Stylistic(CustomIdent),
@ -1321,10 +1334,12 @@ ${helpers.single_keyword_system("font-kerning",
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct VariantAlternatesList(pub Box<[VariantAlternates]>);
#[derive(Clone, Debug, PartialEq, ToCss)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue {
Value(VariantAlternatesList),
@ -1518,6 +1533,7 @@ macro_rules! exclusive_value {
bitflags! {
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub flags VariantEastAsian: u16 {
const NORMAL = 0,
@ -1533,7 +1549,7 @@ macro_rules! exclusive_value {
}
}
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub enum SpecifiedValue {
Value(VariantEastAsian),
@ -1663,6 +1679,7 @@ macro_rules! exclusive_value {
bitflags! {
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub flags VariantLigatures: u16 {
const NORMAL = 0,
@ -1678,7 +1695,7 @@ macro_rules! exclusive_value {
}
}
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub enum SpecifiedValue {
Value(VariantLigatures),
@ -1822,6 +1839,7 @@ macro_rules! exclusive_value {
bitflags! {
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub flags VariantNumeric: u8 {
const NORMAL = 0,
@ -1836,8 +1854,7 @@ macro_rules! exclusive_value {
}
}
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub enum SpecifiedValue {
Value(VariantNumeric),
@ -1977,6 +1994,7 @@ ${helpers.single_keyword_system("font-variant-position",
use properties::longhands::system_font::SystemFont;
use values::generics::FontSettings;
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub enum SpecifiedValue {
Value(computed_value::T),
@ -2048,6 +2066,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
use byteorder::{BigEndian, ByteOrder};
#[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue {
Normal,
@ -2105,6 +2124,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
// it and store it as a 32-bit integer
// (see http://www.microsoft.com/typography/otspec/languagetags.htm).
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub u32);
}
@ -2213,6 +2233,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
}
#[derive(Clone, Debug, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub Atom);
}
@ -2269,6 +2290,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
0
}
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum SpecifiedValue {
Relative(i32),
@ -2358,6 +2380,7 @@ ${helpers.single_keyword("-moz-math-variant",
use values::computed::Length;
use values::specified::length::{AU_PER_PT, AU_PER_PX, FontBaseSize, NoCalcLength};
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub struct SpecifiedValue(pub NoCalcLength);
@ -2416,6 +2439,7 @@ ${helpers.single_keyword("-moz-math-variant",
}
#[derive(Clone, Debug, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
/// text-zoom. Enable if true, disable if false
pub struct T(pub bool);
@ -2470,7 +2494,7 @@ ${helpers.single_keyword("-moz-math-variant",
kw_cast = """font_style font_variant_caps font_stretch
font_kerning font_variant_position""".split()
%>
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ToCss)]
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToCss)]
pub enum SystemFont {
% for font in system_fonts:
${to_camel_case(font)},

View file

@ -71,6 +71,7 @@ ${helpers.single_keyword("image-rendering",
const TWO_PI: f64 = 2.0 * PI;
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue {
pub angle: Option<Angle>,
@ -102,6 +103,7 @@ ${helpers.single_keyword("image-rendering",
use values::specified::Angle;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum Orientation {
Angle0 = 0,
@ -134,6 +136,7 @@ ${helpers.single_keyword("image-rendering",
}
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum T {
FromImage,
@ -257,6 +260,7 @@ ${helpers.single_keyword("image-rendering",
use std::fmt;
use style_traits::ToCss;
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
#[derive(Clone, Copy, Debug, Eq, PartialEq, ToComputedValue)]
pub struct SpecifiedValue(pub bool);

View file

@ -162,6 +162,7 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
///
/// Higher priority values, i.e. the values specified first,
/// will be painted first (and may be covered by paintings of lower priority)
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)]
pub struct SpecifiedValue(pub u8);

View file

@ -29,6 +29,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
use values::animated::{ToAnimatedValue, ToAnimatedZero};
use values::computed::NonNegativeLength;
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, PartialEq, ToCss)]
pub struct T {
@ -59,6 +60,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
}
}
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub struct SpecifiedValue {

View file

@ -175,6 +175,7 @@ ${helpers.single_keyword("text-align-last",
use std::fmt;
use style_traits::ToCss;
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum SpecifiedValue {
Keyword(computed_value::T),
@ -288,6 +289,7 @@ ${helpers.predefined_type("word-spacing",
use style_traits::ToCss;
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue {
pub underline: Option<RGBA>,
@ -430,6 +432,7 @@ ${helpers.predefined_type(
pub mod computed_value {
#[derive(Clone, Debug, PartialEq, ToCss)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf, ToComputedValue))]
pub enum T {
Keyword(KeywordValue),
@ -438,6 +441,7 @@ ${helpers.predefined_type(
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct KeywordValue {
pub fill: bool,
@ -446,6 +450,7 @@ ${helpers.predefined_type(
}
#[derive(Clone, Debug, PartialEq, ToCss)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue {
Keyword(KeywordValue),
@ -454,6 +459,7 @@ ${helpers.predefined_type(
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum KeywordValue {
Fill(bool),
@ -621,6 +627,7 @@ ${helpers.predefined_type(
"left" => Left);
add_impls_for_keyword_enum!(HorizontalWritingModeValue);
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToComputedValue, ToCss)]
pub struct SpecifiedValue(pub HorizontalWritingModeValue, pub VerticalWritingModeValue);

View file

@ -41,7 +41,7 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
use values::generics::CounterStyleOrNone;
/// <counter-style> | <string> | none
#[derive(Clone, Debug, Eq, PartialEq, ToComputedValue, ToCss)]
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
pub enum T {
CounterStyle(CounterStyleOrNone),
String(String),
@ -104,6 +104,7 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
pub mod computed_value {
use values::specified::UrlOrNone;
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub struct T(pub UrlOrNone);
@ -145,6 +146,7 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
pub use self::computed_value::T as SpecifiedValue;
pub mod computed_value {
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToComputedValue)]
pub struct T(pub Vec<(String, String)>);

View file

@ -21,6 +21,7 @@
#[cfg(feature = "gecko")]
use values::specified::url::SpecifiedUrl;
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)]
pub enum Keyword {
@ -32,14 +33,14 @@
pub type T = Keyword;
#[cfg(feature = "gecko")]
#[derive(Clone, Debug, PartialEq, ToComputedValue)]
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
pub struct Image {
pub url: SpecifiedUrl,
pub hotspot: Option<(f32, f32)>,
}
#[cfg(feature = "gecko")]
#[derive(Clone, Debug, PartialEq, ToComputedValue)]
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
pub struct T {
pub images: Vec<Image>,
pub keyword: Keyword,

View file

@ -296,6 +296,7 @@ ${helpers.predefined_type("object-position",
pub mod computed_value {
#[derive(Clone, Copy, Debug, Eq, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum AutoFlow {
Row,
@ -303,6 +304,7 @@ ${helpers.predefined_type("object-position",
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T {
pub autoflow: AutoFlow,
@ -435,6 +437,7 @@ ${helpers.predefined_type("object-position",
SpecifiedValue::parse(context, input)
}
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Debug, PartialEq)]
pub struct TemplateAreas {
pub areas: Box<[NamedArea]>,
@ -442,6 +445,7 @@ ${helpers.predefined_type("object-position",
pub width: u32,
}
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Debug, PartialEq)]
pub struct NamedArea {
pub name: Box<str>,

View file

@ -20,6 +20,7 @@ ${helpers.single_keyword("table-layout", "auto fixed",
use style_traits::ToCss;
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub i32);

View file

@ -19,6 +19,7 @@
use style_traits::ToCss;
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, Eq, PartialEq, ToCss)]
pub enum Side {
@ -27,6 +28,7 @@
String(Box<str>),
}
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, Eq, PartialEq, ToCss)]
pub struct SpecifiedValue {
@ -38,6 +40,7 @@
pub use super::Side;
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T {
// When the specified value only has one side, that's the "second"
@ -148,6 +151,7 @@ ${helpers.single_keyword("unicode-bidi",
use style_traits::ToCss;
bitflags! {
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(ToComputedValue)]
pub flags SpecifiedValue: u8 {

View file

@ -51,6 +51,7 @@ ${helpers.single_keyword("-moz-window-shadow", "none default menu tooltip sheet"
use style_traits::ToCss;
pub mod computed_value {
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)]
pub struct T(pub bool);

View file

@ -29,7 +29,6 @@ use font_metrics::FontMetricsProvider;
#[cfg(feature = "gecko")] use gecko_bindings::structs::{self, nsCSSPropertyID};
#[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide};
use logical_geometry::WritingMode;
#[cfg(feature = "gecko")] use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps};
use media_queries::Device;
use parser::ParserContext;
use properties::animated_properties::AnimatableLonghand;
@ -380,6 +379,7 @@ impl PropertyDeclarationIdSet {
}
/// An enum to represent a CSS Wide keyword.
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss)]
pub enum CSSWideKeyword {
@ -445,6 +445,7 @@ bitflags! {
/// An identifier for a given longhand property.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum LonghandId {
% for i, property in enumerate(data.longhands):
@ -783,12 +784,16 @@ pub enum DeclaredValue<'a, T: 'a> {
/// that PropertyDeclaration can avoid embedding a DeclaredValue (and its
/// extra discriminant word) and synthesize dependent DeclaredValues for
/// PropertyDeclaration instances as needed.
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum DeclaredValueOwned<T> {
/// A known specified value from the stylesheet.
Value(T),
/// An unparsed value that contains `var()` functions.
WithVariables(Arc<UnparsedValue>),
WithVariables(
#[cfg_attr(feature = "gecko", ignore_malloc_size_of = "XXX: how to handle this?")]
Arc<UnparsedValue>
),
/// An CSS-wide keyword.
CSSWideKeyword(CSSWideKeyword),
}
@ -1267,6 +1272,7 @@ impl PropertyParserContext {
}
/// Servo's representation for a property declaration.
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, PartialEq)]
pub enum PropertyDeclaration {
% for property in data.longhands:
@ -1280,7 +1286,11 @@ pub enum PropertyDeclaration {
/// A css-wide keyword.
CSSWideKeyword(LonghandId, CSSWideKeyword),
/// An unparsed value that contains `var()` functions.
WithVariables(LonghandId, Arc<UnparsedValue>),
WithVariables(
LonghandId,
#[cfg_attr(feature = "gecko", ignore_malloc_size_of = "XXX: how to handle this?")]
Arc<UnparsedValue>
),
/// A custom property declaration, with the property name and the declared
/// value.
Custom(::custom_properties::Name, DeclaredValueOwned<Box<::custom_properties::SpecifiedValue>>),
@ -1327,31 +1337,6 @@ impl ToCss for PropertyDeclaration {
}
}
#[cfg(feature = "gecko")]
impl MallocSizeOf for PropertyDeclaration {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
match *self {
% for property in data.longhands:
% if property.boxed and property.is_vector:
<% raise Exception("this should not happen! not smart to box a vector here") %>
% elif property.boxed:
PropertyDeclaration::${property.camel_case}(ref sv_box) => {
<Box<_> as MallocShallowSizeOf>::shallow_size_of(sv_box, ops)
}
% elif property.is_vector:
PropertyDeclaration::${property.camel_case}(ref sv_vec) => {
sv_vec.0.shallow_size_of(ops)
}
% endif
% endfor
PropertyDeclaration::CSSWideKeyword(..) => 0,
PropertyDeclaration::WithVariables(..) => 0,
PropertyDeclaration::Custom(..) => 0,
_ => 0,
}
}
}
impl PropertyDeclaration {
/// Given a property declaration, return the property declaration id.
pub fn id(&self) -> PropertyDeclarationId {
@ -1711,6 +1696,7 @@ pub mod style_structs {
% else:
#[derive(Clone, Debug, PartialEq)]
% endif
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
/// The ${style_struct.name} style struct.
pub struct ${style_struct.name} {