зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #15837 - Return true in set_property only when declaration block is changed (from upsuper:bug1344135); r=emilio
This is [bug 1344135](https://bugzilla.mozilla.org/show_bug.cgi?id=1344135). Source-Repo: https://github.com/servo/servo Source-Revision: b11847d86c4983b76a8e8dc11716dc66b66148d7 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 61d2b45dff60297c7f0937dab733d5fb5a582f06
This commit is contained in:
Родитель
18cf417f1d
Коммит
e88ac040ed
|
@ -266,11 +266,9 @@ impl CSSStyleDeclaration {
|
||||||
|
|
||||||
// Step 8
|
// Step 8
|
||||||
// Step 9
|
// Step 9
|
||||||
// We could try to be better I guess?
|
*changed = false;
|
||||||
*changed = !declarations.is_empty();
|
|
||||||
for declaration in declarations {
|
for declaration in declarations {
|
||||||
// TODO(emilio): We could check it changed
|
*changed |= pdb.set_parsed_declaration(declaration.0, importance);
|
||||||
pdb.set_parsed_declaration(declaration.0, importance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -171,10 +171,11 @@ impl PropertyDeclarationBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds or overrides the declaration for a given property in this block,
|
/// 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,
|
pub fn set_parsed_declaration(&mut self,
|
||||||
declaration: PropertyDeclaration,
|
declaration: PropertyDeclaration,
|
||||||
importance: Importance) {
|
importance: Importance) -> bool {
|
||||||
for slot in &mut *self.declarations {
|
for slot in &mut *self.declarations {
|
||||||
if slot.0.id() == declaration.id() {
|
if slot.0.id() == declaration.id() {
|
||||||
match (slot.1, importance) {
|
match (slot.1, importance) {
|
||||||
|
@ -184,10 +185,12 @@ impl PropertyDeclarationBlock {
|
||||||
(Importance::Important, Importance::Normal) => {
|
(Importance::Important, Importance::Normal) => {
|
||||||
self.important_count -= 1;
|
self.important_count -= 1;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => if slot.0 == declaration {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*slot = (declaration, importance);
|
*slot = (declaration, importance);
|
||||||
return
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,6 +198,7 @@ impl PropertyDeclarationBlock {
|
||||||
if importance.important() {
|
if importance.important() {
|
||||||
self.important_count += 1;
|
self.important_count += 1;
|
||||||
}
|
}
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the declaration importance for a given property, if found.
|
/// Set the declaration importance for a given property, if found.
|
||||||
|
|
|
@ -837,10 +837,11 @@ fn set_property(declarations: RawServoDeclarationBlockBorrowed, property_id: Pro
|
||||||
Box::new(StdoutErrorReporter), extra_data) {
|
Box::new(StdoutErrorReporter), extra_data) {
|
||||||
let mut declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations).write();
|
let mut declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations).write();
|
||||||
let importance = if is_important { Importance::Important } else { Importance::Normal };
|
let importance = if is_important { Importance::Important } else { Importance::Normal };
|
||||||
|
let mut changed = false;
|
||||||
for decl in decls.into_iter() {
|
for decl in decls.into_iter() {
|
||||||
declarations.set_parsed_declaration(decl.0, importance);
|
changed |= declarations.set_parsed_declaration(decl.0, importance);
|
||||||
}
|
}
|
||||||
true
|
changed
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче