Auto merge of #10255 - mbrubeck:box-unscanned, r=pcwalton

Reduce size of layout::fragment::Fragment struct

This reduces the size of the SpecificFragmentInfo enum from 48 to 24.

r? @pcwalton

<!-- 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/10255)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-03-30 07:49:25 +05:30
commit 44b2ba2547
11 changed files with 76 additions and 16 deletions

View file

@ -0,0 +1,12 @@
[package]
name = "layout_tests"
version = "0.0.1"
authors = ["The Servo Project Developers"]
[lib]
name = "layout_tests"
path = "lib.rs"
doctest = false
[dependencies.layout]
path = "../../../components/layout"

7
tests/unit/layout/lib.rs Normal file
View file

@ -0,0 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
extern crate layout;
#[cfg(all(test, target_pointer_width = "64"))] mod size_of;

View file

@ -0,0 +1,26 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
use layout::Fragment;
use std::mem::size_of;
#[test]
fn test_size_of_fragment() {
let expected = 160;
let actual = size_of::<Fragment>();
if actual < expected {
panic!("Your changes have decreased the stack size of layout::fragment::Fragment \
from {} to {}. Good work! Please update the size in tests/layout/size_of.rs",
expected, actual);
}
if actual > expected {
panic!("Your changes have increased the stack size of layout::fragment::Fragment \
from {} to {}. Please consider choosing a design which avoids this increase. \
If you feel that the increase is necessary, update the size in \
tests/layout/size_of.rs.",
expected, actual);
}
}

View file

@ -23,14 +23,14 @@ macro_rules! sizeof_checker (
let old = $known_size;
if new < old {
panic!("Your changes have decreased the stack size of commonly used DOM struct {} from {} to {}. \
Good work! Please update the size in script/tests.rs",
Good work! Please update the size in tests/unit/script/size_of.rs.",
stringify!($t), old, new)
} else if new > old {
panic!("Your changes have increased the stack size of commonly used DOM struct {} from {} to {}. \
These structs are present in large quantities in the DOM, and increasing the size \
may dramatically affect our memory footprint. Please consider choosing a design which \
avoids this increase. If you feel that the increase is necessary, \
update to the new size in script/tests.rs.",
update to the new size in tests/unit/script/size_of.rs.",
stringify!($t), old, new)
}
});