Hoist checked and indeterminate state into EventState.

This is necessary for those selectors to take advantage of restyle hints.
This commit is contained in:
Bobby Holley 2015-10-22 12:56:18 -07:00
parent 7512aa69c0
commit f7f27a8146
2 changed files with 27 additions and 18 deletions

View file

@ -85,19 +85,28 @@ use util::str::{DOMString, LengthOrPercentageOrAuto};
bitflags! {
#[doc = "Element Event States."]
#[derive(JSTraceable, HeapSizeOf)]
flags EventState: u8 {
flags EventState: u16 {
#[doc = "The mouse is down on this element. \
(https://html.spec.whatwg.org/multipage/#selector-active). \
FIXME(#7333): set/unset this when appropriate"]
const IN_ACTIVE_STATE = 0x01,
#[doc = "This element has focus."]
#[doc = "This element has focus.
https://html.spec.whatwg.org/multipage/scripting.html#selector-focus"]
const IN_FOCUS_STATE = 0x02,
#[doc = "The mouse is hovering over this element."]
#[doc = "The mouse is hovering over this element. \
https://html.spec.whatwg.org/multipage/scripting.html#selector-hover"]
const IN_HOVER_STATE = 0x04,
#[doc = "Content is enabled (and can be disabled)."]
#[doc = "Content is enabled (and can be disabled). \
http://www.whatwg.org/html/#selector-enabled"]
const IN_ENABLED_STATE = 0x08,
#[doc = "Content is disabled."]
#[doc = "Content is disabled. \
http://www.whatwg.org/html/#selector-disabled"]
const IN_DISABLED_STATE = 0x10,
#[doc = "Content is checked. \
https://html.spec.whatwg.org/multipage/scripting.html#selector-checked"]
const IN_CHECKED_STATE = 0x20,
#[doc = "https://html.spec.whatwg.org/multipage/scripting.html#selector-indeterminate"]
const IN_INDETERMINATE_STATE = 0x40,
}
}
@ -1834,7 +1843,11 @@ impl Element {
self.set_click_in_progress(false);
}
fn set_state(&self, which: EventState, value: bool) {
pub fn get_state(&self) -> EventState {
self.event_state.get()
}
pub fn set_state(&self, which: EventState, value: bool) {
let mut state = self.event_state.get();
if state.contains(which) == value {
return