servo: Merge #18008 - stylo: Avoid reporting rules that contain both normal and important declarations twice (from emilio:double-important); r=upsuper

Bug: 1387906
Source-Repo: https://github.com/servo/servo
Source-Revision: 4fdc571e9fa4e95ec7a5ce7bfd03db6b544b8c9e

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 0474e60faf024161af94689d7d77233e55947605
This commit is contained in:
Emilio Cobos Álvarez 2017-08-08 03:21:54 -05:00
parent cf112f4b88
commit f0e3ab05cb

View File

@ -1823,13 +1823,34 @@ pub extern "C" fn Servo_ComputedValues_EqualCustomProperties(
#[no_mangle]
pub extern "C" fn Servo_ComputedValues_GetStyleRuleList(values: ServoStyleContextBorrowed,
rules: RawGeckoServoStyleRuleListBorrowedMut) {
if let Some(ref rule_node) = values.rules {
let rule_node = match values.rules {
Some(ref r) => r,
None => return,
};
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
// TODO(emilio): Will benefit from SmallVec.
let mut result = vec![];
for node in rule_node.self_and_ancestors() {
if let &StyleSource::Style(ref rule) = node.style_source() {
result.push(rule);
let style_rule = match *node.style_source() {
StyleSource::Style(ref rule) => rule,
_ => continue,
};
if node.importance().important() {
let block = style_rule.read_with(&guard).block.read_with(&guard);
if block.any_normal() {
// We'll append it when we find the normal rules in our
// parent chain.
continue;
}
}
result.push(style_rule);
}
unsafe { rules.set_len(result.len() as u32) };
for (ref src, ref mut dest) in result.into_iter().zip(rules.iter_mut()) {
src.with_raw_offset_arc(|arc| {
@ -1837,7 +1858,6 @@ pub extern "C" fn Servo_ComputedValues_GetStyleRuleList(values: ServoStyleContex
})
}
}
}
/// See the comment in `Device` to see why it's ok to pass an owned reference to
/// the pres context (hint: the context outlives the StyleSet, that holds the