aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--components/selectors/Cargo.toml2
-rw-r--r--components/style/restyle_hints.rs39
-rw-r--r--python/servo/testing_commands.py4
-rw-r--r--tests/unit/style/lib.rs1
-rw-r--r--tests/unit/style/restyle_hints.rs31
6 files changed, 52 insertions, 27 deletions
diff --git a/.travis.yml b/.travis.yml
index d6dc6cc89b4..534ecf3f1af 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,7 +22,7 @@ matrix:
- bash etc/ci/lockfile_changed.sh
- bash etc/ci/manifest_changed.sh
- ./mach cargo test -p selectors
- - ./mach cargo test -p style
+ - ./mach test-unit -p style
cache:
directories:
- .cargo
diff --git a/components/selectors/Cargo.toml b/components/selectors/Cargo.toml
index 9e5e9df6f35..22ee4e526c2 100644
--- a/components/selectors/Cargo.toml
+++ b/components/selectors/Cargo.toml
@@ -14,6 +14,8 @@ license = "MPL-2.0"
[lib]
name = "selectors"
path = "lib.rs"
+# https://github.com/servo/servo/issues/16710
+doctest = false
[dependencies]
bitflags = "0.7"
diff --git a/components/style/restyle_hints.rs b/components/style/restyle_hints.rs
index 193b7e82a9d..0e7dcd19adc 100644
--- a/components/style/restyle_hints.rs
+++ b/components/style/restyle_hints.rs
@@ -431,8 +431,11 @@ fn combinator_to_restyle_hint(combinator: Option<Combinator>) -> RestyleHint {
#[derive(Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
-struct Sensitivities {
+/// The aspects of an selector which are sensitive.
+pub struct Sensitivities {
+ /// The states which are sensitive.
pub states: ElementState,
+ /// Whether attributes are sensitive.
pub attrs: bool,
}
@@ -469,11 +472,13 @@ impl Sensitivities {
/// change may have on the style of elements in the document.
#[derive(Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
-struct Dependency {
+pub struct Dependency {
#[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")]
selector: SelectorInner<SelectorImpl>,
- hint: RestyleHint,
- sensitivities: Sensitivities,
+ /// The hint associated with this dependency.
+ pub hint: RestyleHint,
+ /// The sensitivities associated with this dependency.
+ pub sensitivities: Sensitivities,
}
@@ -681,27 +686,9 @@ impl DependencySet {
}
}
}
-}
-#[test]
-#[cfg(all(test, feature = "servo"))]
-fn smoke_restyle_hints() {
- use cssparser::Parser;
- use selector_parser::SelectorParser;
- use stylesheets::{Origin, Namespaces};
- let namespaces = Namespaces::default();
- let parser = SelectorParser {
- stylesheet_origin: Origin::Author,
- namespaces: &namespaces,
- };
-
- let mut dependencies = DependencySet::new();
-
- let mut p = Parser::new(":not(:active) ~ label");
- let selector = ComplexSelector::parse(&parser, &mut p).unwrap();
- dependencies.note_selector(&selector);
- assert_eq!(dependencies.len(), 1);
- assert_eq!(dependencies.state_deps.len(), 1);
- assert!(!dependencies.state_deps[0].sensitivities.states.is_empty());
- assert!(dependencies.state_deps[0].hint.contains(RESTYLE_LATER_SIBLINGS));
+ /// Get the dependencies affected by state.
+ pub fn get_state_deps(&self) -> &[Dependency] {
+ &self.state_deps
+ }
}
diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py
index 70c90eab136..64d79e38501 100644
--- a/python/servo/testing_commands.py
+++ b/python/servo/testing_commands.py
@@ -231,8 +231,10 @@ class MachCommands(CommandBase):
else:
test_patterns.append(test)
+ in_crate_packages = []
if not packages:
packages = set(os.listdir(path.join(self.context.topdir, "tests", "unit"))) - set(['.DS_Store'])
+ in_crate_packages += ["selectors"]
packages.discard('stylo')
@@ -255,6 +257,8 @@ class MachCommands(CommandBase):
args = ["cargo", "bench" if bench else "test"]
for crate in packages:
args += ["-p", "%s_tests" % crate]
+ for crate in in_crate_packages:
+ args += ["-p", crate]
args += test_patterns
if features:
diff --git a/tests/unit/style/lib.rs b/tests/unit/style/lib.rs
index 4a03cf0f232..0c2d9c8b53e 100644
--- a/tests/unit/style/lib.rs
+++ b/tests/unit/style/lib.rs
@@ -27,6 +27,7 @@ mod logical_geometry;
mod media_queries;
mod parsing;
mod properties;
+mod restyle_hints;
mod rule_tree;
mod size_of;
mod str;
diff --git a/tests/unit/style/restyle_hints.rs b/tests/unit/style/restyle_hints.rs
new file mode 100644
index 00000000000..9a050e05fb5
--- /dev/null
+++ b/tests/unit/style/restyle_hints.rs
@@ -0,0 +1,31 @@
+/* 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/. */
+
+#[test]
+fn smoke_restyle_hints() {
+ use cssparser::Parser;
+ use selectors::parser::SelectorList;
+ use style::restyle_hints::{DependencySet, RESTYLE_LATER_SIBLINGS};
+ use style::selector_parser::SelectorParser;
+ use style::stylesheets::{Origin, Namespaces};
+ let namespaces = Namespaces::default();
+ let parser = SelectorParser {
+ stylesheet_origin: Origin::Author,
+ namespaces: &namespaces,
+ };
+
+ let mut dependencies = DependencySet::new();
+
+ let mut p = Parser::new(":not(:active) ~ label");
+ let selectors = SelectorList::parse(&parser, &mut p).unwrap();
+ assert_eq!((selectors.0).len(), 1);
+
+ let selector = (selectors.0).first().unwrap();
+ dependencies.note_selector(selector);
+ assert_eq!(dependencies.len(), 1);
+ let state_deps = dependencies.get_state_deps();
+ assert_eq!(state_deps.len(), 1);
+ assert!(!state_deps[0].sensitivities.states.is_empty());
+ assert!(state_deps[0].hint.contains(RESTYLE_LATER_SIBLINGS));
+}