Auto merge of #18404 - nnethercote:measure-PropertyDeclaration, r=heycam

Measure PropertyDeclaration better.

This increases the style-sheets counts for gmail by about 30 MiB.

<!-- Please describe your changes on the following line: -->

r? @heycam

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because code is tested on the Gecko side.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18404)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-09-08 00:22:05 -05:00 committed by GitHub
commit dfc38fabdc

View file

@ -38,7 +38,8 @@ use selectors::parser::SelectorParseError;
use shared_lock::StylesheetGuards;
use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError};
use style_traits::{PropertyDeclarationParseError, StyleParseError, ValueParseError};
use stylesheets::{CssRuleType, MallocSizeOf, MallocSizeOfFn, Origin, UrlExtraData};
use stylesheets::{CssRuleType, MallocSizeOf, MallocSizeOfBox, MallocSizeOfFn, MallocSizeOfVec};
use stylesheets::{Origin, UrlExtraData};
#[cfg(feature = "servo")] use values::Either;
use values::generics::text::LineHeight;
use values::computed;
@ -1328,10 +1329,26 @@ impl ToCss for PropertyDeclaration {
}
impl MallocSizeOf for PropertyDeclaration {
fn malloc_size_of_children(&self, _malloc_size_of: MallocSizeOfFn) -> usize {
// The variants of PropertyDeclaration mostly (entirely?) contain
// scalars, so this is reasonable.
0
fn malloc_size_of_children(&self, malloc_size_of: MallocSizeOfFn) -> 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) => {
sv_box.malloc_shallow_size_of_box(malloc_size_of)
}
% elif property.is_vector:
PropertyDeclaration::${property.camel_case}(ref sv_vec) => {
sv_vec.0.malloc_shallow_size_of_vec(malloc_size_of)
}
% endif
% endfor
PropertyDeclaration::CSSWideKeyword(..) => 0,
PropertyDeclaration::WithVariables(..) => 0,
PropertyDeclaration::Custom(..) => 0,
_ => 0,
}
}
}