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

@ -14,11 +14,12 @@ use values::computed::{Context, ToComputedValue};
use values::specified;
use values::specified::grid::parse_line_names;
#[derive(Clone, Debug, Default, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
/// A `<grid-line>` type.
///
/// https://drafts.csswg.org/css-grid/#typedef-grid-row-start-grid-line
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, Default, PartialEq, ToComputedValue)]
pub struct GridLine<Integer> {
/// Flag to check whether it's a `span` keyword.
pub is_span: bool,
@ -143,6 +144,7 @@ add_impls_for_keyword_enum!(TrackKeyword);
/// avoid re-implementing it for the computed type.
///
/// https://drafts.csswg.org/css-grid/#typedef-track-breadth
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToComputedValue)]
pub enum TrackBreadth<L> {
@ -181,6 +183,7 @@ impl<L: ToCss> ToCss for TrackBreadth<L> {
/// generic only to avoid code bloat. It only takes `<length-percentage>`
///
/// https://drafts.csswg.org/css-grid/#typedef-track-size
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq)]
pub enum TrackSize<L> {
@ -344,6 +347,7 @@ where
/// The initial argument of the `repeat` function.
///
/// https://drafts.csswg.org/css-grid/#typedef-track-repeat
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)]
pub enum RepeatCount<Integer> {
@ -377,6 +381,7 @@ impl Parse for RepeatCount<specified::Integer> {
///
/// It can also hold `repeat()` function parameters, which expands into the respective
/// values in its computed form.
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToComputedValue)]
pub struct TrackRepeat<L, I> {
@ -460,6 +465,7 @@ impl<L: Clone> TrackRepeat<L, specified::Integer> {
/// Track list values. Can be <track-size> or <track-repeat>
#[derive(Clone, Debug, PartialEq, ToComputedValue, ToCss)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum TrackListValue<LengthOrPercentage, Integer> {
/// A <track-size> value.
@ -472,6 +478,7 @@ pub enum TrackListValue<LengthOrPercentage, Integer> {
///
/// https://drafts.csswg.org/css-grid/#typedef-track-list
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum TrackListType {
/// [`<auto-track-list>`](https://drafts.csswg.org/css-grid/#typedef-auto-track-list)
@ -494,6 +501,7 @@ pub enum TrackListType {
/// A grid `<track-list>` type.
///
/// https://drafts.csswg.org/css-grid/#typedef-track-list
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq)]
pub struct TrackList<LengthOrPercentage, Integer> {
@ -563,6 +571,7 @@ impl<L: ToCss, I: ToCss> ToCss for TrackList<L, I> {
/// `subgrid [ <line-names> | repeat(<positive-integer> | auto-fill, <line-names>+) ]+`
/// Old spec: https://www.w3.org/TR/2015/WD-css-grid-1-20150917/#typedef-line-name-list
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct LineNameList {
/// The optional `<line-name-list>`
@ -658,6 +667,7 @@ impl ToCss for LineNameList {
/// Variants for `<grid-template-rows> | <grid-template-columns>`
/// Subgrid deferred to Level 2 spec due to lack of implementation.
/// But it's implemented in gecko, so we have to as well.
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToComputedValue, ToCss)]
pub enum GridTemplateComponent<L, I> {