mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #10834 - yoava333:master, r=SimonSapin
added support for :read-only and :read-write pseudo-classes partial fix for https://github.com/servo/servo/issues/10732 It's not a full fix because: 1. there's a bug in wpt-test https://github.com/w3c/web-platform-tests/issues/2889#issuecomment-214144420 2. we don't fully support all input types (namely image, color, hidden and range), which are defaulted to input text. this means that :read-write which is applicable to input text is mis-handled in those cases. 3. we don't support contenteditable, which is also possibly :read-write <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10834) <!-- Reviewable:end -->
This commit is contained in:
commit
ac8406f4ae
9 changed files with 82 additions and 31 deletions
|
@ -125,7 +125,7 @@ impl HTMLInputElement {
|
|||
let chan = document.window().constellation_chan().clone();
|
||||
HTMLInputElement {
|
||||
htmlelement:
|
||||
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
|
||||
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE | IN_READ_WRITE_STATE,
|
||||
localName, prefix, document),
|
||||
input_type: Cell::new(InputType::InputText),
|
||||
placeholder: DOMRefCell::new(DOMString::new()),
|
||||
|
@ -713,6 +713,11 @@ impl VirtualMethods for HTMLInputElement {
|
|||
el.set_disabled_state(disabled_state);
|
||||
el.set_enabled_state(!disabled_state);
|
||||
el.check_ancestors_disabled_state_for_form_control();
|
||||
|
||||
if self.input_type.get() == InputType::InputText {
|
||||
let read_write = !(self.ReadOnly() || el.disabled_state());
|
||||
el.set_read_write_state(read_write);
|
||||
}
|
||||
},
|
||||
&atom!("checked") if !self.checked_changed.get() => {
|
||||
let checked_state = match mutation {
|
||||
|
@ -748,6 +753,15 @@ impl VirtualMethods for HTMLInputElement {
|
|||
// https://html.spec.whatwg.org/multipage/#input-type-change
|
||||
let (old_value_mode, old_idl_value) = (self.value_mode(), self.Value());
|
||||
self.input_type.set(new_type);
|
||||
|
||||
let el = self.upcast::<Element>();
|
||||
if new_type == InputType::InputText {
|
||||
let read_write = !(self.ReadOnly() || el.disabled_state());
|
||||
el.set_read_write_state(read_write);
|
||||
} else {
|
||||
el.set_read_write_state(false);
|
||||
}
|
||||
|
||||
let new_value_mode = self.value_mode();
|
||||
|
||||
match (&old_value_mode, old_idl_value.is_empty(), new_value_mode) {
|
||||
|
@ -792,6 +806,10 @@ impl VirtualMethods for HTMLInputElement {
|
|||
self.radio_group_name().as_ref());
|
||||
}
|
||||
self.input_type.set(InputType::InputText);
|
||||
let el = self.upcast::<Element>();
|
||||
|
||||
let read_write = !(self.ReadOnly() || el.disabled_state());
|
||||
el.set_read_write_state(read_write);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -825,6 +843,17 @@ impl VirtualMethods for HTMLInputElement {
|
|||
attr.value().chars().filter(|&c| c != '\n' && c != '\r'));
|
||||
}
|
||||
},
|
||||
&atom!("readonly") if self.input_type.get() == InputType::InputText => {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue