Move Event States to |Element|.

Conceptually they belong there, rather than on |Node|.

Fixes #7934.
This commit is contained in:
Bobby Holley 2015-10-07 20:02:00 -07:00
parent 628c2a0432
commit 75ec093334
14 changed files with 251 additions and 262 deletions

View file

@ -17,14 +17,14 @@ use dom::bindings::codegen::InheritTypes::{KeyboardEventCast, NodeCast};
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, LayoutJS, Root, RootedReference};
use dom::document::Document;
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
use dom::element::{AttributeMutation, Element, IN_ENABLED_STATE, RawLayoutElementHelpers};
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::eventtarget::EventTarget;
use dom::htmlelement::HTMLElement;
use dom::htmlformelement::{FormControl, FormDatum, FormSubmitter, HTMLFormElement};
use dom::htmlformelement::{ResetFrom, SubmittedFrom};
use dom::keyboardevent::KeyboardEvent;
use dom::node::{IN_ENABLED_STATE, Node, NodeDamage, NodeFlags};
use dom::node::{Node, NodeDamage};
use dom::node::{document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use msg::constellation_msg::ConstellationChan;
@ -109,7 +109,7 @@ impl HTMLInputElement {
let chan = document.window().r().constellation_chan();
HTMLInputElement {
htmlelement:
HTMLElement::new_inherited_with_flags(NodeFlags::new() | IN_ENABLED_STATE,
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
localName, prefix, document),
input_type: Cell::new(InputType::InputText),
checked: Cell::new(false),
@ -472,8 +472,8 @@ impl HTMLInputElement {
fn mutable(&self) -> bool {
// https://html.spec.whatwg.org/multipage/#the-input-element:concept-fe-mutable
// https://html.spec.whatwg.org/multipage/#the-readonly-attribute:concept-fe-mutable
let node = NodeCast::from_ref(self);
!(node.get_disabled_state() || self.ReadOnly())
let el = ElementCast::from_ref(self);
!(el.get_disabled_state() || self.ReadOnly())
}
// https://html.spec.whatwg.org/multipage/#the-input-element:concept-form-reset-control
@ -511,10 +511,10 @@ impl VirtualMethods for HTMLInputElement {
},
AttributeMutation::Removed => false,
};
let node = NodeCast::from_ref(self);
node.set_disabled_state(disabled_state);
node.set_enabled_state(!disabled_state);
node.check_ancestors_disabled_state_for_form_control();
let el = ElementCast::from_ref(self);
el.set_disabled_state(disabled_state);
el.set_enabled_state(!disabled_state);
el.check_ancestors_disabled_state_for_form_control();
},
&atom!(checked) if !self.checked_changed.get() => {
let checked_state = match mutation {
@ -596,8 +596,8 @@ impl VirtualMethods for HTMLInputElement {
s.bind_to_tree(tree_in_doc);
}
let node = NodeCast::from_ref(self);
node.check_ancestors_disabled_state_for_form_control();
let el = ElementCast::from_ref(self);
el.check_ancestors_disabled_state_for_form_control();
}
fn unbind_from_tree(&self, tree_in_doc: bool) {
@ -606,10 +606,11 @@ impl VirtualMethods for HTMLInputElement {
}
let node = NodeCast::from_ref(self);
let el = ElementCast::from_ref(self);
if node.ancestors().any(|ancestor| ancestor.r().is_htmlfieldsetelement()) {
node.check_ancestors_disabled_state_for_form_control();
el.check_ancestors_disabled_state_for_form_control();
} else {
node.check_disabled_attribute();
el.check_disabled_attribute();
}
}