mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Split up the InputButton variant
This commit is contained in:
parent
bc7b5b35b4
commit
2c2d741b1f
1 changed files with 10 additions and 8 deletions
|
@ -41,7 +41,9 @@ const DEFAULT_RESET_VALUE: &'static str = "Reset";
|
||||||
#[deriving(PartialEq)]
|
#[deriving(PartialEq)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
enum InputType {
|
enum InputType {
|
||||||
InputButton(Option<&'static str>),
|
InputSubmit,
|
||||||
|
InputReset,
|
||||||
|
InputButton,
|
||||||
InputText,
|
InputText,
|
||||||
InputFile,
|
InputFile,
|
||||||
InputImage,
|
InputImage,
|
||||||
|
@ -110,9 +112,9 @@ impl LayoutHTMLInputElementHelpers for JS<HTMLInputElement> {
|
||||||
match (*self.unsafe_get()).input_type.get() {
|
match (*self.unsafe_get()).input_type.get() {
|
||||||
InputCheckbox | InputRadio => "".to_string(),
|
InputCheckbox | InputRadio => "".to_string(),
|
||||||
InputFile | InputImage => "".to_string(),
|
InputFile | InputImage => "".to_string(),
|
||||||
InputButton(ref default) => get_raw_attr_value(self)
|
InputButton => get_raw_attr_value(self).unwrap_or_else(|| "".to_string()),
|
||||||
.or_else(|| default.map(|v| v.to_string()))
|
InputSubmit => get_raw_attr_value(self).unwrap_or_else(|| DEFAULT_SUBMIT_VALUE.to_string()),
|
||||||
.unwrap_or_else(|| "".to_string()),
|
InputReset => get_raw_attr_value(self).unwrap_or_else(|| DEFAULT_RESET_VALUE.to_string()),
|
||||||
InputPassword => {
|
InputPassword => {
|
||||||
let raw = get_raw_textinput_value(self);
|
let raw = get_raw_textinput_value(self);
|
||||||
String::from_char(raw.char_len(), '●')
|
String::from_char(raw.char_len(), '●')
|
||||||
|
@ -305,9 +307,9 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
&atom!("type") => {
|
&atom!("type") => {
|
||||||
let value = attr.value();
|
let value = attr.value();
|
||||||
self.input_type.set(match value.as_slice() {
|
self.input_type.set(match value.as_slice() {
|
||||||
"button" => InputButton(None),
|
"button" => InputButton,
|
||||||
"submit" => InputButton(Some(DEFAULT_SUBMIT_VALUE)),
|
"submit" => InputSubmit,
|
||||||
"reset" => InputButton(Some(DEFAULT_RESET_VALUE)),
|
"reset" => InputReset,
|
||||||
"file" => InputFile,
|
"file" => InputFile,
|
||||||
"radio" => InputRadio,
|
"radio" => InputRadio,
|
||||||
"checkbox" => InputCheckbox,
|
"checkbox" => InputCheckbox,
|
||||||
|
@ -421,7 +423,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
match self.input_type.get() {
|
match self.input_type.get() {
|
||||||
InputCheckbox => self.SetChecked(!self.checked.get()),
|
InputCheckbox => self.SetChecked(!self.checked.get()),
|
||||||
InputRadio => self.SetChecked(true),
|
InputRadio => self.SetChecked(true),
|
||||||
InputButton(Some(DEFAULT_SUBMIT_VALUE)) => {
|
InputSubmit => {
|
||||||
self.form_owner().map(|o| {
|
self.form_owner().map(|o| {
|
||||||
o.root().submit(NotFromFormSubmitMethod, InputElement(self.clone()))
|
o.root().submit(NotFromFormSubmitMethod, InputElement(self.clone()))
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue