added support for :read-only and :read-write pseudo-classes

partial fix for https://github.com/servo/servo/issues/10732
This commit is contained in:
Yoav Alon 2016-04-25 18:55:31 +03:00
parent f773dc182b
commit 9bf909ac2f
9 changed files with 82 additions and 31 deletions

View file

@ -104,7 +104,7 @@ impl HTMLTextAreaElement {
let chan = document.window().constellation_chan();
HTMLTextAreaElement {
htmlelement:
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE | IN_READ_WRITE_STATE,
localName, prefix, document),
textinput: DOMRefCell::new(TextInput::new(
Lines::Multiple, DOMString::new(), chan, None, SelectionDirection::None)),
@ -290,14 +290,31 @@ impl VirtualMethods for HTMLTextAreaElement {
AttributeMutation::Set(_) => {
el.set_disabled_state(true);
el.set_enabled_state(false);
el.set_read_write_state(false);
},
AttributeMutation::Removed => {
el.set_disabled_state(false);
el.set_enabled_state(true);
el.check_ancestors_disabled_state_for_form_control();
if !el.disabled_state() && !el.read_write_state() {
el.set_read_write_state(true);
}
}
}
},
atom!("readonly") => {
let el = self.upcast::<Element>();
match mutation {
AttributeMutation::Set(_) => {
el.set_read_write_state(false);
},
AttributeMutation::Removed => {
el.set_read_write_state(!el.disabled_state());
}
}
}
_ => {},
}
}