Add support for caseless group name matching in HTML input elements

This commit is contained in:
Keith Yeung 2015-09-28 17:22:35 -07:00
parent 4823ec947e
commit 5c9a25d46b
6 changed files with 19 additions and 23 deletions

View file

@ -90,3 +90,4 @@ euclid = "0.2"
tendril = "0.1.1"
rand = "0.3"
serde = "0.6"
caseless = "0.1.0"

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use caseless::compatibility_caseless_match_str;
use dom::activation::Activatable;
use dom::attr::{Attr, AttrValue};
use dom::bindings::cell::DOMRefCell;
@ -388,9 +389,8 @@ fn in_same_group(other: &HTMLInputElement, owner: Option<&HTMLFormElement>,
other.input_type.get() == InputType::InputRadio &&
// TODO Both a and b are in the same home subtree.
other_owner == owner &&
// TODO should be a unicode compatibility caseless match
match (other.get_radio_group_name(), group) {
(Some(ref s1), Some(s2)) => s1 == s2 && s2 != &atom!(""),
(Some(ref s1), Some(s2)) => compatibility_caseless_match_str(s1, s2) && s2 != &atom!(""),
_ => false
}
}

View file

@ -46,6 +46,7 @@ extern crate util;
extern crate angle;
extern crate canvas;
extern crate canvas_traits;
extern crate caseless;
extern crate core;
extern crate cssparser;
extern crate devtools_traits;

View file

@ -167,6 +167,15 @@ dependencies = [
"util 0.0.1",
]
[[package]]
name = "caseless"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cgl"
version = "0.1.0"
@ -1442,6 +1451,7 @@ dependencies = [
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"canvas 0.0.1",
"canvas_traits 0.0.1",
"caseless 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"devtools_traits 0.0.1",
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1780,6 +1790,11 @@ dependencies = [
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "unicode-normalization"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-script"
version = "0.1.1"

View file

@ -1,23 +1,5 @@
[radio-groupname-case.html]
type: testharness
[radio button group name = sImPlE]
expected: FAIL
[radio button group name = paSSfield-killroyß]
expected: FAIL
[radio button group name = глупый]
expected: FAIL
[radio button group name = åωk]
expected: FAIL
[radio button group name = blah1]
expected: FAIL
[radio button group name = tÉdz5アパートFi]
expected: FAIL
[radio button group name = ΣΣ]
expected: FAIL

View file

@ -3,6 +3,3 @@
[canceled activation steps on unchecked radio]
expected: FAIL
[radio inputs with name attributes groüp2 and groÜp2 belong to the same radio button group]
expected: FAIL