Move dirname collection to input

This commit is contained in:
Dmitry Kolupaev 2020-01-30 23:06:22 +03:00
parent ef49f2e0eb
commit cb34e5c887
5 changed files with 43 additions and 37 deletions

View file

@ -745,8 +745,6 @@ impl HTMLFormElement {
.map(|field| (&*field.name, field.replace_value(charset))), .map(|field| (&*field.name, field.replace_value(charset))),
); );
println!("New URL: {url}", url = &load_data.url);
self.plan_to_navigate(load_data, target); self.plan_to_navigate(load_data, target);
} }
@ -952,22 +950,7 @@ impl HTMLFormElement {
match element { match element {
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));
// TODO: probably move to input.form_datums(...) function
// 4.10.18.2 https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#submitting-element-directionality:-the-dirname-attribute
let dirname: DOMString = input.DirName();
let dirname_str: &str = &*dirname;
if !dirname_str.is_empty() {
data_set.push(FormDatum {
ty: input.Type(),
name: DOMString::from_string(dirname_str.to_owned()),
value: FormDatumValue::String(DOMString::from(
input.directionality("auto"),
)),
});
}
}, },
HTMLElementTypeId::HTMLButtonElement => { HTMLElementTypeId::HTMLButtonElement => {
let button = child.downcast::<HTMLButtonElement>().unwrap(); let button = child.downcast::<HTMLButtonElement>().unwrap();

View file

@ -1473,11 +1473,25 @@ impl HTMLInputElement {
} }
// Step 5.12 // Step 5.12
vec![FormDatum { let mut result = vec![FormDatum {
ty: ty.clone(), ty: ty.clone(),
name: name, name: name,
value: FormDatumValue::String(self.Value()), value: FormDatumValue::String(self.Value()),
}] }];
// 4.10.18.2
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#submitting-element-directionality:-the-dirname-attribute
let dirname: DOMString = self.DirName();
let directionality = DOMString::from(self.directionality("auto"));
if !dirname.is_empty() {
result.push(FormDatum {
ty: ty.clone(),
name: dirname.clone(),
value: FormDatumValue::String(directionality),
});
}
result
} }
// https://html.spec.whatwg.org/multipage/#radio-button-group // https://html.spec.whatwg.org/multipage/#radio-button-group

View file

@ -2017,7 +2017,6 @@ impl Window {
} }
// TODO: step 11, navigationType. // TODO: step 11, navigationType.
// Step 12, 13 // Step 12, 13
println!("ScriptThread::navigate");
ScriptThread::navigate(pipeline_id, load_data, replace); ScriptThread::navigate(pipeline_id, load_data, replace);
}; };
} }

View file

@ -20,12 +20,17 @@
} }
var t = async_test("submit element directionality"); var t = async_test("submit element directionality");
setTimeout(function() {
document.querySelector("input").value = "foobar"; document.querySelector("input").value = "foobar";
document.querySelector("button").click(); document.querySelector("button").click();
document.querySelector("iframe").onload = t.step_func_done(function() { var iframe = document.querySelector("iframe");
iframe.onload = t.step_func(function() {
// The initial about:blank load event can be fired before the form navigation occurs.
// See https://github.com/whatwg/html/issues/490 for more information.
if(iframe.contentWindow.location.href == "about:blank") { return; }
assert_equals(getParameterByName("comment.dir"), "ltr"); assert_equals(getParameterByName("comment.dir"), "ltr");
t.done();
}); });
}, 3000);
</script> </script>

View file

@ -7,7 +7,7 @@
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<div id="log"></div> <div id="log"></div>
<form action="dirname-ltr-iframe.html" method=get target="iframe"> <form action="dirname-ltr-iframe.html" method=get target="iframe">
<p><label>Comment: <input type=text id="comment-input" name="comment" dirname="comment.dir" required/></label></p> <p><label>Comment: <input type=text name="comment" dirname="comment.dir" required/></label></p>
<p><button type=submit>Post Comment</button></p> <p><button type=submit>Post Comment</button></p>
</form> </form>
<iframe name="iframe"></iframe> <iframe name="iframe"></iframe>
@ -20,13 +20,18 @@
} }
var t = async_test("submit element directionality"); var t = async_test("submit element directionality");
setTimeout(3000, function() {
var rtlValue = "مرحبا"; var rtlValue = "مرحبا";
document.querySelector("input").value = rtlValue; document.querySelector("input").value = rtlValue;
document.querySelector("button").click(); document.querySelector("button").click();
document.querySelector("iframe").onload = t.step_func_done(function() { var iframe = document.querySelector("iframe");
iframe.onload = t.step_func(function() {
// The initial about:blank load event can be fired before the form navigation occurs.
// See https://github.com/whatwg/html/issues/490 for more information.
if(iframe.contentWindow.location.href == "about:blank") { return; }
assert_equals(getParameterByName("comment.dir"), "rtl"); assert_equals(getParameterByName("comment.dir"), "rtl");
t.done();
}); });
}, 3000);
</script> </script>