aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/layout_thread/lib.rs2
-rw-r--r--components/style/gecko/data.rs2
-rw-r--r--components/style/stylist.rs46
-rw-r--r--components/style/viewport.rs13
-rw-r--r--tests/unit/style/viewport.rs6
5 files changed, 39 insertions, 30 deletions
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 6e1be94deca..d67b1c8d23e 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -1091,7 +1091,7 @@ impl LayoutThread {
marker: PhantomData,
};
let needs_dirtying = self.stylist.update(
- &data.document_stylesheets,
+ data.document_stylesheets.iter(),
&guards,
Some(ua_stylesheets),
data.stylesheets_changed,
diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs
index 65fbe6b39fb..d51b1795bce 100644
--- a/components/style/gecko/data.rs
+++ b/components/style/gecko/data.rs
@@ -105,7 +105,7 @@ impl PerDocumentStyleDataImpl {
let mut stylesheets = Vec::<Arc<Stylesheet>>::new();
self.stylesheets.flush(&mut stylesheets);
self.stylist.clear();
- self.stylist.rebuild(stylesheets.as_slice(),
+ self.stylist.rebuild(stylesheets.iter(),
&StylesheetGuards::same(guard),
/* ua_sheets = */ None,
/* stylesheets_changed = */ true,
diff --git a/components/style/stylist.rs b/components/style/stylist.rs
index 2bdcfbb31b3..a05b2cfdd00 100644
--- a/components/style/stylist.rs
+++ b/components/style/stylist.rs
@@ -268,13 +268,15 @@ impl Stylist {
/// This method resets all the style data each time the stylesheets change
/// (which is indicated by the `stylesheets_changed` parameter), or the
/// device is dirty, which means we need to re-evaluate media queries.
- pub fn rebuild<'a>(&mut self,
- doc_stylesheets: &[Arc<Stylesheet>],
- guards: &StylesheetGuards,
- ua_stylesheets: Option<&UserAgentStylesheets>,
- stylesheets_changed: bool,
- author_style_disabled: bool,
- extra_data: &mut ExtraStyleData<'a>) -> bool {
+ pub fn rebuild<'a, 'b, I>(&mut self,
+ doc_stylesheets: I,
+ guards: &StylesheetGuards,
+ ua_stylesheets: Option<&UserAgentStylesheets>,
+ stylesheets_changed: bool,
+ author_style_disabled: bool,
+ extra_data: &mut ExtraStyleData<'a>) -> bool
+ where I: Iterator<Item = &'b Arc<Stylesheet>> + Clone,
+ {
debug_assert!(!self.is_cleared || self.is_device_dirty);
self.is_cleared = false;
@@ -287,7 +289,7 @@ impl Stylist {
let cascaded_rule = ViewportRule {
declarations: viewport::Cascade::from_stylesheets(
- doc_stylesheets, guards.author, &self.device
+ doc_stylesheets.clone(), guards.author, &self.device
).finish(),
};
@@ -317,7 +319,7 @@ impl Stylist {
}
// Only use author stylesheets if author styles are enabled.
- let sheets_to_add = doc_stylesheets.iter().filter(|s| {
+ let sheets_to_add = doc_stylesheets.filter(|s| {
!author_style_disabled || s.origin != Origin::Author
});
@@ -338,13 +340,15 @@ impl Stylist {
/// clear the stylist and then rebuild it. Chances are, you want to use
/// either clear() or rebuild(), with the latter done lazily, instead.
- pub fn update<'a>(&mut self,
- doc_stylesheets: &[Arc<Stylesheet>],
- guards: &StylesheetGuards,
- ua_stylesheets: Option<&UserAgentStylesheets>,
- stylesheets_changed: bool,
- author_style_disabled: bool,
- extra_data: &mut ExtraStyleData<'a>) -> bool {
+ pub fn update<'a, 'b, I>(&mut self,
+ doc_stylesheets: I,
+ guards: &StylesheetGuards,
+ ua_stylesheets: Option<&UserAgentStylesheets>,
+ stylesheets_changed: bool,
+ author_style_disabled: bool,
+ extra_data: &mut ExtraStyleData<'a>) -> bool
+ where I: Iterator<Item = &'b Arc<Stylesheet>> + Clone,
+ {
debug_assert!(!self.is_cleared || self.is_device_dirty);
// We have to do a dirtiness check before clearing, because if
@@ -357,7 +361,9 @@ impl Stylist {
author_style_disabled, extra_data)
}
- fn add_stylesheet<'a>(&mut self, stylesheet: &Stylesheet, guard: &SharedRwLockReadGuard,
+ fn add_stylesheet<'a>(&mut self,
+ stylesheet: &Stylesheet,
+ guard: &SharedRwLockReadGuard,
extra_data: &mut ExtraStyleData<'a>) {
if stylesheet.disabled() || !stylesheet.is_effective_for_device(&self.device, guard) {
return;
@@ -656,10 +662,12 @@ impl Stylist {
/// FIXME(emilio): The semantics of the device for Servo and Gecko are
/// different enough we may want to unify them.
#[cfg(feature = "servo")]
- pub fn set_device(&mut self, mut device: Device, guard: &SharedRwLockReadGuard,
+ pub fn set_device(&mut self,
+ mut device: Device,
+ guard: &SharedRwLockReadGuard,
stylesheets: &[Arc<Stylesheet>]) {
let cascaded_rule = ViewportRule {
- declarations: viewport::Cascade::from_stylesheets(stylesheets, guard, &device).finish(),
+ declarations: viewport::Cascade::from_stylesheets(stylesheets.iter(), guard, &device).finish(),
};
self.viewport_constraints =
diff --git a/components/style/viewport.rs b/components/style/viewport.rs
index 7096c381d23..c887614ad57 100644
--- a/components/style/viewport.rs
+++ b/components/style/viewport.rs
@@ -26,6 +26,7 @@ use std::iter::Enumerate;
use std::str::Chars;
use style_traits::{PinchZoomFactor, ToCss};
use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom};
+use stylearc::Arc;
use stylesheets::{Stylesheet, Origin};
use values::computed::{Context, ToComputedValue};
use values::specified::{NoCalcLength, LengthOrPercentageOrAuto, ViewportPercentageLength};
@@ -329,7 +330,6 @@ fn is_whitespace_separator_or_equals(c: &char) -> bool {
}
impl Parse for ViewportRule {
- #[allow(missing_docs)]
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
let parser = ViewportRuleParser { context: context };
@@ -545,14 +545,15 @@ impl Cascade {
}
}
- pub fn from_stylesheets<'a, I>(stylesheets: I, guard: &SharedRwLockReadGuard,
- device: &Device) -> Self
- where I: IntoIterator,
- I::Item: AsRef<Stylesheet>,
+ pub fn from_stylesheets<'a, I>(stylesheets: I,
+ guard: &SharedRwLockReadGuard,
+ device: &Device)
+ -> Self
+ where I: Iterator<Item = &'a Arc<Stylesheet>>,
{
let mut cascade = Self::new();
for stylesheet in stylesheets {
- stylesheet.as_ref().effective_viewport_rules(device, guard, |rule| {
+ stylesheet.effective_viewport_rules(device, guard, |rule| {
for declaration in &rule.declarations {
cascade.add(Cow::Borrowed(declaration))
}
diff --git a/tests/unit/style/viewport.rs b/tests/unit/style/viewport.rs
index ed8b9b527ee..e9c11495878 100644
--- a/tests/unit/style/viewport.rs
+++ b/tests/unit/style/viewport.rs
@@ -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);