stylo: Avoid reporting rules that contain both normal and important declarations twice.

Bug: 1387906
This commit is contained in:
Emilio Cobos Álvarez 2017-08-08 09:58:41 +02:00
parent 82de4c49f3
commit cd58dc6aa9
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -1823,19 +1823,39 @@ 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 mut result = vec![];
for node in rule_node.self_and_ancestors() {
if let &StyleSource::Style(ref rule) = node.style_source() {
result.push(rule);
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() {
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;
}
}
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| {
**dest = *Locked::<StyleRule>::arc_as_borrowed(arc);
})
}
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| {
**dest = *Locked::<StyleRule>::arc_as_borrowed(arc);
})
}
}