mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Implement step 5.13 for dirname correctly
This commit is contained in:
parent
6188116090
commit
ab2aeb6d97
2 changed files with 23 additions and 24 deletions
|
@ -951,17 +951,6 @@ impl HTMLFormElement {
|
||||||
HTMLElementTypeId::HTMLInputElement => {
|
HTMLElementTypeId::HTMLInputElement => {
|
||||||
let input = child.downcast::<HTMLInputElement>().unwrap();
|
let input = child.downcast::<HTMLInputElement>().unwrap();
|
||||||
data_set.append(&mut input.form_datums(submitter, encoding));
|
data_set.append(&mut input.form_datums(submitter, encoding));
|
||||||
|
|
||||||
let input_element = child.downcast::<Element>().unwrap();
|
|
||||||
let dirname: DOMString = input.DirName();
|
|
||||||
if !dirname.is_empty() {
|
|
||||||
let directionality = DOMString::from(input_element.directionality());
|
|
||||||
data_set.push(FormDatum {
|
|
||||||
ty: input.Type().clone(),
|
|
||||||
name: dirname.clone(),
|
|
||||||
value: FormDatumValue::String(directionality),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
HTMLElementTypeId::HTMLButtonElement => {
|
HTMLElementTypeId::HTMLButtonElement => {
|
||||||
let button = child.downcast::<HTMLButtonElement>().unwrap();
|
let button = child.downcast::<HTMLButtonElement>().unwrap();
|
||||||
|
@ -987,21 +976,31 @@ impl HTMLFormElement {
|
||||||
value: FormDatumValue::String(textarea.Value()),
|
value: FormDatumValue::String(textarea.Value()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let area_element = child.downcast::<Element>().unwrap();
|
|
||||||
let dirname: DOMString = textarea.DirName();
|
|
||||||
if !dirname.is_empty() {
|
|
||||||
let directionality = DOMString::from(area_element.directionality());
|
|
||||||
data_set.push(FormDatum {
|
|
||||||
ty: textarea.Type().clone(),
|
|
||||||
name: dirname.clone(),
|
|
||||||
value: FormDatumValue::String(directionality),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Step: 5.13. Add an entry if element has dirname attribute
|
||||||
|
// An element can only have a dirname attribute if it is a textarea element
|
||||||
|
// or an input element whose type attribute is in either the Text state or the Search state
|
||||||
|
let child_element = child.downcast::<Element>().unwrap();
|
||||||
|
let input_matches = child_element
|
||||||
|
.downcast::<HTMLInputElement>()
|
||||||
|
.map(|input| {
|
||||||
|
input.input_type() == InputType::Text || input.input_type() == InputType::Search
|
||||||
|
})
|
||||||
|
.unwrap_or(false);
|
||||||
|
let textarea_matches = child_element.is::<HTMLTextAreaElement>();
|
||||||
|
let dirname = child_element.get_string_attribute(&local_name!("dirname"));
|
||||||
|
if (input_matches || textarea_matches) && !dirname.is_empty() {
|
||||||
|
let dir = DOMString::from(child_element.directionality());
|
||||||
|
data_set.push(FormDatum {
|
||||||
|
ty: DOMString::from("string"),
|
||||||
|
name: dirname.clone(),
|
||||||
|
value: FormDatumValue::String(dir),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
data_set
|
data_set
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,14 +339,14 @@ impl HTMLInputElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn directionality_from_value(value: &str) -> String {
|
pub fn directionality_from_value(value: &str) -> String {
|
||||||
if HTMLInputElement::first_strong_character_is_rtl(value) {
|
if HTMLInputElement::is_first_strong_character_rtl(value) {
|
||||||
"rtl".to_owned()
|
"rtl".to_owned()
|
||||||
} else {
|
} else {
|
||||||
"ltr".to_owned()
|
"ltr".to_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn first_strong_character_is_rtl(value: &str) -> bool {
|
fn is_first_strong_character_rtl(value: &str) -> bool {
|
||||||
for ch in value.chars() {
|
for ch in value.chars() {
|
||||||
return match bidi_class(ch) {
|
return match bidi_class(ch) {
|
||||||
BidiClass::L => false,
|
BidiClass::L => false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue