mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00: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) {
|
||||
let mut state = self.state.get();
|
||||
if state.contains(which) == value {
|
||||
return;
|
||||
}
|
||||
let node = self.upcast::<Node>();
|
||||
node.owner_doc().element_state_will_change(self);
|
||||
let previous_state = state;
|
||||
if value {
|
||||
state.insert(which);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue