Auto merge of #16802 - emilio:slim-down-slc, r=bholley

style: Slim down SharedStyleContext, and do various other cleanups around the style crate.

This slims down SharedStyleContext, in preparation for a few things.

First, I would like to eventually move the stylist to the document in Servo, in
order for it to hold the StyleSheetSet.

Also, this gets rid of a fair amount of overhead while creating it in stylo.

Fixes bug 1363245.

<!-- 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/16802)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-05-12 08:56:47 -05:00 committed by GitHub
commit eeb1ee9723
11 changed files with 171 additions and 141 deletions

View file

@ -25,7 +25,7 @@ macro_rules! stylesheet {
stylesheet!($css, $origin, $error_reporter, SharedRwLock::new())
};
($css:expr, $origin:ident, $error_reporter:expr, $shared_lock:expr) => {
Box::new(Stylesheet::from_str(
Arc::new(Stylesheet::from_str(
$css,
ServoUrl::parse("http://localhost").unwrap(),
Origin::$origin,
@ -269,7 +269,7 @@ fn multiple_stylesheets_cascading() {
Author, error_reporter, shared_lock.clone())
];
let declarations = Cascade::from_stylesheets(&stylesheets, &shared_lock.read(), &device).finish();
let declarations = Cascade::from_stylesheets(stylesheets.iter(), &shared_lock.read(), &device).finish();
assert_decl_len!(declarations == 3);
assert_decl_eq!(&declarations[0], UserAgent, Zoom: Zoom::Number(1.));
assert_decl_eq!(&declarations[1], User, MinHeight: viewport_length!(200., px));
@ -283,7 +283,7 @@ fn multiple_stylesheets_cascading() {
stylesheet!("@viewport { min-width: 300px !important; min-height: 300px !important; zoom: 3 !important; }",
Author, error_reporter, shared_lock.clone())
];
let declarations = Cascade::from_stylesheets(&stylesheets, &shared_lock.read(), &device).finish();
let declarations = Cascade::from_stylesheets(stylesheets.iter(), &shared_lock.read(), &device).finish();
assert_decl_len!(declarations == 3);
assert_decl_eq!(&declarations[0], UserAgent, MinWidth: viewport_length!(100., px), !important);
assert_decl_eq!(&declarations[1], User, MinHeight: viewport_length!(200., px), !important);