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

@ -15,13 +15,13 @@ use dom::bindings::global::GlobalRef;
use dom::bindings::js::{LayoutJS, Root};
use dom::bindings::refcounted::Trusted;
use dom::document::Document;
use dom::element::AttributeMutation;
use dom::element::{AttributeMutation, IN_ENABLED_STATE};
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::htmlelement::HTMLElement;
use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::keyboardevent::KeyboardEvent;
use dom::node::{ChildrenMutation, IN_ENABLED_STATE, Node, NodeDamage};
use dom::node::{NodeFlags, document_from_node, window_from_node};
use dom::node::{ChildrenMutation, Node, NodeDamage};
use dom::node::{document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use msg::constellation_msg::ConstellationChan;
use script_task::ScriptTaskEventCategory::InputEvent;
@ -87,7 +87,7 @@ impl HTMLTextAreaElement {
let chan = document.window().r().constellation_chan();
HTMLTextAreaElement {
htmlelement:
HTMLElement::new_inherited_with_flags(NodeFlags::new() | IN_ENABLED_STATE,
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
localName, prefix, document),
textinput: DOMRefCell::new(TextInput::new(Lines::Multiple, "".to_owned(), chan)),
cols: Cell::new(DEFAULT_COLS),
@ -245,16 +245,16 @@ impl VirtualMethods for HTMLTextAreaElement {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
&atom!(disabled) => {
let node = NodeCast::from_ref(self);
let el = ElementCast::from_ref(self);
match mutation {
AttributeMutation::Set(_) => {
node.set_disabled_state(true);
node.set_enabled_state(false);
el.set_disabled_state(true);
el.set_enabled_state(false);
},
AttributeMutation::Removed => {
node.set_disabled_state(false);
node.set_enabled_state(true);
node.check_ancestors_disabled_state_for_form_control();
el.set_disabled_state(false);
el.set_enabled_state(true);
el.check_ancestors_disabled_state_for_form_control();
}
}
},
@ -279,8 +279,8 @@ impl VirtualMethods for HTMLTextAreaElement {
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 parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
@ -297,10 +297,11 @@ impl VirtualMethods for HTMLTextAreaElement {
}
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();
}
}