diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index 4d81d457f88..f658ed5375e 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -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(()) diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index 949de6bd38e..ac618dcbf72 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -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) { @@ -184,10 +185,12 @@ impl PropertyDeclarationBlock { (Importance::Important, Importance::Normal) => { self.important_count -= 1; } - _ => {} + _ => if slot.0 == declaration { + return false; + } } *slot = (declaration, importance); - return + return true; } } @@ -195,6 +198,7 @@ impl PropertyDeclarationBlock { if importance.important() { self.important_count += 1; } + true } /// Set the declaration importance for a given property, if found. diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 8c3584c1026..4dccb916c72 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -837,10 +837,11 @@ fn set_property(declarations: RawServoDeclarationBlockBorrowed, property_id: Pro Box::new(StdoutErrorReporter), extra_data) { let mut declarations = RwLock::::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 }