Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Auto merge of #15837 - upsuper:bug1344135, r=emilio
Return true in set_property only when declaration block is changed

This is [bug 1344135](https://bugzilla.mozilla.org/show_bug.cgi?id=1344135).

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15837)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Mar 7, 2017
2 parents f85c8ef + 4f07826 commit b11847d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
6 changes: 2 additions & 4 deletions components/script/dom/cssstyledeclaration.rs
Expand Up @@ -266,11 +266,9 @@ impl CSSStyleDeclaration {

// Step 8
// Step 9
// We could try to be better I guess?
*changed = !declarations.is_empty();
*changed = false;
for declaration in declarations {
// TODO(emilio): We could check it changed
pdb.set_parsed_declaration(declaration.0, importance);
*changed |= pdb.set_parsed_declaration(declaration.0, importance);
}

Ok(())
Expand Down
12 changes: 8 additions & 4 deletions components/style/properties/declaration_block.rs
Expand Up @@ -171,10 +171,11 @@ impl PropertyDeclarationBlock {
}

/// Adds or overrides the declaration for a given property in this block,
/// without taking into account any kind of priority.
/// without taking into account any kind of priority. Returns whether the
/// declaration block is actually changed.
pub fn set_parsed_declaration(&mut self,
declaration: PropertyDeclaration,
importance: Importance) {
importance: Importance) -> bool {
for slot in &mut *self.declarations {
if slot.0.id() == declaration.id() {
match (slot.1, importance) {
Expand All @@ -184,17 +185,20 @@ impl PropertyDeclarationBlock {
(Importance::Important, Importance::Normal) => {
self.important_count -= 1;
}
_ => {}
_ => if slot.0 == declaration {
return false;
}
}
*slot = (declaration, importance);
return
return true;
}
}

self.declarations.push((declaration, importance));
if importance.important() {
self.important_count += 1;
}
true
}

/// Set the declaration importance for a given property, if found.
Expand Down
5 changes: 3 additions & 2 deletions ports/geckolib/glue.rs
Expand Up @@ -837,10 +837,11 @@ fn set_property(declarations: RawServoDeclarationBlockBorrowed, property_id: Pro
Box::new(StdoutErrorReporter), extra_data) {
let mut declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations).write();
let importance = if is_important { Importance::Important } else { Importance::Normal };
let mut changed = false;
for decl in decls.into_iter() {
declarations.set_parsed_declaration(decl.0, importance);
changed |= declarations.set_parsed_declaration(decl.0, importance);
}
true
changed
} else {
false
}
Expand Down

0 comments on commit b11847d

Please sign in to comment.