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:
Simon Wülker 2025-02-21 15:42:28 +01:00 committed by GitHub
parent cf2b93f18a
commit 6ccdf7d19f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);
}