style: Parameterize the update and rebuild methods to take an iterator.

In preparation to avoid cloning the stylesheets while rebuilding in Gecko.
This commit is contained in:
Emilio Cobos Álvarez 2017-05-11 01:45:00 +02:00
parent 50e0c67e2c
commit 677daaabc5
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 39 additions and 30 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);