mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Allow resetting multiple flags at once in Element::set_state (#35580)
Previously, the code would incorrectly return without updating the flags if the caller tried to reset multiple flags at once and the not all of them were true. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
cf2b93f18a
commit
6ccdf7d19f
1 changed files with 9 additions and 5 deletions
|
@ -4307,16 +4307,20 @@ impl Element {
|
||||||
|
|
||||||
pub(crate) fn set_state(&self, which: ElementState, value: bool) {
|
pub(crate) fn set_state(&self, which: ElementState, value: bool) {
|
||||||
let mut state = self.state.get();
|
let mut state = self.state.get();
|
||||||
if state.contains(which) == value {
|
let previous_state = state;
|
||||||
return;
|
|
||||||
}
|
|
||||||
let node = self.upcast::<Node>();
|
|
||||||
node.owner_doc().element_state_will_change(self);
|
|
||||||
if value {
|
if value {
|
||||||
state.insert(which);
|
state.insert(which);
|
||||||
} else {
|
} else {
|
||||||
state.remove(which);
|
state.remove(which);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if previous_state == state {
|
||||||
|
// Nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let node = self.upcast::<Node>();
|
||||||
|
node.owner_doc().element_state_will_change(self);
|
||||||
self.state.set(state);
|
self.state.set(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue