mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +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,12 +5,13 @@
|
|||
use dom::attr::Attr;
|
||||
use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding::HTMLOptGroupElementMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLOptionElementDerived, NodeCast};
|
||||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, HTMLOptionElementCast};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLOptionElementDerived, NodeCast};
|
||||
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::node::{IN_ENABLED_STATE, Node, NodeFlags};
|
||||
use dom::node::{Node};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use util::str::DOMString;
|
||||
|
||||
|
@ -25,7 +26,7 @@ impl HTMLOptGroupElement {
|
|||
document: &Document) -> HTMLOptGroupElement {
|
||||
HTMLOptGroupElement {
|
||||
htmlelement:
|
||||
HTMLElement::new_inherited_with_flags(NodeFlags::new() | IN_ENABLED_STATE,
|
||||
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
|
||||
localName, prefix, document)
|
||||
}
|
||||
}
|
||||
|
@ -66,19 +67,22 @@ impl VirtualMethods for HTMLOptGroupElement {
|
|||
AttributeMutation::Removed => false,
|
||||
};
|
||||
let node = NodeCast::from_ref(self);
|
||||
node.set_disabled_state(disabled_state);
|
||||
node.set_enabled_state(!disabled_state);
|
||||
let el = ElementCast::from_ref(self);
|
||||
el.set_disabled_state(disabled_state);
|
||||
el.set_enabled_state(!disabled_state);
|
||||
let options = node.children().filter(|child| {
|
||||
child.is_htmloptionelement()
|
||||
});
|
||||
}).map(|child| Root::from_ref(HTMLOptionElementCast::to_ref(child.r()).unwrap()));
|
||||
if disabled_state {
|
||||
for option in options {
|
||||
option.set_disabled_state(true);
|
||||
option.set_enabled_state(false);
|
||||
let el = ElementCast::from_ref(option.r());
|
||||
el.set_disabled_state(true);
|
||||
el.set_enabled_state(false);
|
||||
}
|
||||
} else {
|
||||
for option in options {
|
||||
option.check_disabled_attribute();
|
||||
let el = ElementCast::from_ref(option.r());
|
||||
el.check_disabled_attribute();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue