mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Move Event States to |Element|.
Conceptually they belong there, rather than on |Node|. Fixes #7934.
This commit is contained in:
parent
628c2a0432
commit
75ec093334
14 changed files with 251 additions and 262 deletions
|
@ -5,15 +5,15 @@
|
|||
use dom::attr::{Attr, AttrValue};
|
||||
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLFieldSetElementDerived, NodeCast};
|
||||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, HTMLFieldSetElementDerived, NodeCast};
|
||||
use dom::bindings::codegen::UnionTypes::HTMLElementOrLong;
|
||||
use dom::bindings::codegen::UnionTypes::HTMLOptionElementOrHTMLOptGroupElement;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::document::Document;
|
||||
use dom::element::AttributeMutation;
|
||||
use dom::element::{AttributeMutation, IN_ENABLED_STATE};
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::htmlformelement::{FormControl, HTMLFormElement};
|
||||
use dom::node::{IN_ENABLED_STATE, Node, NodeFlags, window_from_node};
|
||||
use dom::node::{Node, window_from_node};
|
||||
use dom::validitystate::ValidityState;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use std::borrow::ToOwned;
|
||||
|
@ -33,7 +33,7 @@ impl HTMLSelectElement {
|
|||
document: &Document) -> HTMLSelectElement {
|
||||
HTMLSelectElement {
|
||||
htmlelement:
|
||||
HTMLElement::new_inherited_with_flags(NodeFlags::new() | IN_ENABLED_STATE,
|
||||
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
|
||||
localName, prefix, document)
|
||||
}
|
||||
}
|
||||
|
@ -107,16 +107,16 @@ impl VirtualMethods for HTMLSelectElement {
|
|||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||
if 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,8 +127,8 @@ impl VirtualMethods for HTMLSelectElement {
|
|||
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) {
|
||||
|
@ -137,10 +137,11 @@ impl VirtualMethods for HTMLSelectElement {
|
|||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue