mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Fixed this issue (https://github.com/mozilla/rust/issues/10683)
This commit is contained in:
parent
a5aabefa4c
commit
a7865495f6
5 changed files with 49 additions and 30 deletions
|
@ -116,7 +116,8 @@ impl HTMLIFrameElement {
|
|||
if "sandbox" == name {
|
||||
let mut modes = AllowNothing as u8;
|
||||
for word in value.split_iter(' ') {
|
||||
modes |= match word.to_ascii_lower().as_slice() {
|
||||
let word_lower = word.to_ascii_lower();
|
||||
modes |= match word_lower.as_slice() {
|
||||
"allow-same-origin" => AllowSameOrigin,
|
||||
"allow-forms" => AllowForms,
|
||||
"allow-pointer-lock" => AllowPointerLock,
|
||||
|
|
|
@ -50,7 +50,8 @@ pub mod specified {
|
|||
Length::parse_internal(input, /* negative_ok = */ false)
|
||||
}
|
||||
pub fn parse_dimension(value: CSSFloat, unit: &str) -> Option<Length> {
|
||||
match unit.to_ascii_lower().as_slice() {
|
||||
let unit_lower = unit.to_ascii_lower();
|
||||
match unit_lower.as_slice() {
|
||||
"px" => Some(Length::from_px(value)),
|
||||
"in" => Some(Au_(Au((value * AU_PER_IN) as i32))),
|
||||
"cm" => Some(Au_(Au((value * AU_PER_CM) as i32))),
|
||||
|
|
|
@ -82,7 +82,8 @@ pub fn parse_media_query_list(input: &[ComponentValue]) -> MediaQueryList {
|
|||
loop {
|
||||
let mq = match next {
|
||||
Some(&Ident(ref value)) => {
|
||||
match value.to_ascii_lower().as_slice() {
|
||||
let value_lower = value.to_ascii_lower();
|
||||
match value_lower.as_slice() {
|
||||
"screen" => Some(MediaQuery{ media_type: MediaType(Screen) }),
|
||||
"print" => Some(MediaQuery{ media_type: MediaType(Print) }),
|
||||
"all" => Some(MediaQuery{ media_type: All }),
|
||||
|
|
|
@ -189,11 +189,14 @@ pub mod longhands {
|
|||
|
||||
pub fn parse_border_width(component_value: &ComponentValue) -> Option<specified::Length> {
|
||||
match component_value {
|
||||
&Ident(ref value) => match value.to_ascii_lower().as_slice() {
|
||||
"thin" => Some(specified::Length::from_px(1.)),
|
||||
"medium" => Some(specified::Length::from_px(3.)),
|
||||
"thick" => Some(specified::Length::from_px(5.)),
|
||||
_ => None
|
||||
&Ident(ref value) => {
|
||||
let value_lower = value.to_ascii_lower();
|
||||
match value_lower.as_slice() {
|
||||
"thin" => Some(specified::Length::from_px(1.)),
|
||||
"medium" => Some(specified::Length::from_px(3.)),
|
||||
"thick" => Some(specified::Length::from_px(5.)),
|
||||
_ => None
|
||||
}
|
||||
},
|
||||
_ => specified::Length::parse_non_negative(component_value)
|
||||
}
|
||||
|
@ -332,11 +335,14 @@ pub mod longhands {
|
|||
/// | <percentage> | <length>
|
||||
pub fn from_component_value(input: &ComponentValue) -> Option<SpecifiedValue> {
|
||||
match input {
|
||||
&Ident(ref value) => match value.to_ascii_lower().as_slice() {
|
||||
% for keyword in vertical_align_keywords:
|
||||
&Ident(ref value) => {
|
||||
let value_lower = value.to_ascii_lower();
|
||||
match value_lower.as_slice() {
|
||||
% for keyword in vertical_align_keywords:
|
||||
"${keyword}" => Some(Specified_${to_rust_ident(keyword)}),
|
||||
% endfor
|
||||
_ => None,
|
||||
% endfor
|
||||
_ => None,
|
||||
}
|
||||
},
|
||||
_ => specified::LengthOrPercentage::parse_non_negative(input)
|
||||
.map(SpecifiedLengthOrPercentage)
|
||||
|
@ -455,7 +461,8 @@ pub mod longhands {
|
|||
Some(&String(ref value)) => add!(FamilyName(value.to_owned())),
|
||||
Some(&Ident(ref value)) => {
|
||||
let value = value.as_slice();
|
||||
match value.to_ascii_lower().as_slice() {
|
||||
let value_lower = value.to_ascii_lower();
|
||||
match value_lower.as_slice() {
|
||||
// "serif" => add!(Serif),
|
||||
// "sans-serif" => add!(SansSerif),
|
||||
// "cursive" => add!(Cursive),
|
||||
|
@ -503,12 +510,15 @@ pub mod longhands {
|
|||
/// normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
|
||||
pub fn from_component_value(input: &ComponentValue) -> Option<SpecifiedValue> {
|
||||
match input {
|
||||
&Ident(ref value) => match value.to_ascii_lower().as_slice() {
|
||||
"bold" => Some(SpecifiedWeight700),
|
||||
"normal" => Some(SpecifiedWeight400),
|
||||
"bolder" => Some(Bolder),
|
||||
"lighter" => Some(Lighther),
|
||||
_ => None,
|
||||
&Ident(ref value) => {
|
||||
let value_lower = value.to_ascii_lower();
|
||||
match value_lower.as_slice() {
|
||||
"bold" => Some(SpecifiedWeight700),
|
||||
"normal" => Some(SpecifiedWeight400),
|
||||
"bolder" => Some(Bolder),
|
||||
"lighter" => Some(Lighther),
|
||||
_ => None,
|
||||
}
|
||||
},
|
||||
&Number(ref value) => match value.int_value {
|
||||
Some(100) => Some(SpecifiedWeight100),
|
||||
|
|
|
@ -308,14 +308,17 @@ fn parse_one_simple_selector(iter: &mut Iter, namespaces: &NamespaceMap, inside_
|
|||
iter.next();
|
||||
match iter.next() {
|
||||
Some(Ident(name)) => match parse_simple_pseudo_class(name) {
|
||||
None => match name.to_ascii_lower().as_slice() {
|
||||
// Supported CSS 2.1 pseudo-elements only.
|
||||
// ** Do not add to this list! **
|
||||
"before" => PseudoElementResult(Before),
|
||||
"after" => PseudoElementResult(After),
|
||||
"first-line" => PseudoElementResult(FirstLine),
|
||||
"first-letter" => PseudoElementResult(FirstLetter),
|
||||
_ => InvalidSimpleSelector
|
||||
None => {
|
||||
let name_lower = name.to_ascii_lower();
|
||||
match name_lower.as_slice() {
|
||||
// Supported CSS 2.1 pseudo-elements only.
|
||||
// ** Do not add to this list! **
|
||||
"before" => PseudoElementResult(Before),
|
||||
"after" => PseudoElementResult(After),
|
||||
"first-line" => PseudoElementResult(FirstLine),
|
||||
"first-letter" => PseudoElementResult(FirstLetter),
|
||||
_ => InvalidSimpleSelector
|
||||
}
|
||||
},
|
||||
Some(result) => SimpleSelectorResult(result),
|
||||
},
|
||||
|
@ -443,7 +446,8 @@ fn parse_attribute_selector(content: ~[ComponentValue], namespaces: &NamespaceMa
|
|||
|
||||
|
||||
fn parse_simple_pseudo_class(name: &str) -> Option<SimpleSelector> {
|
||||
match name.to_ascii_lower().as_slice() {
|
||||
let name_lower = name.to_ascii_lower();
|
||||
match name_lower.as_slice() {
|
||||
"any-link" => Some(AnyLink),
|
||||
"link" => Some(Link),
|
||||
"visited" => Some(Visited),
|
||||
|
@ -463,7 +467,8 @@ fn parse_simple_pseudo_class(name: &str) -> Option<SimpleSelector> {
|
|||
fn parse_functional_pseudo_class(name: ~str, arguments: ~[ComponentValue],
|
||||
namespaces: &NamespaceMap, inside_negation: bool)
|
||||
-> Option<SimpleSelector> {
|
||||
match name.to_ascii_lower().as_slice() {
|
||||
let name_lower = name.to_ascii_lower();
|
||||
match name_lower.as_slice() {
|
||||
// "lang" => parse_lang(arguments),
|
||||
"nth-child" => parse_nth(arguments).map(|(a, b)| NthChild(a, b)),
|
||||
"nth-last-child" => parse_nth(arguments).map(|(a, b)| NthLastChild(a, b)),
|
||||
|
@ -476,7 +481,8 @@ fn parse_functional_pseudo_class(name: ~str, arguments: ~[ComponentValue],
|
|||
|
||||
|
||||
fn parse_pseudo_element(name: ~str) -> Option<PseudoElement> {
|
||||
match name.to_ascii_lower().as_slice() {
|
||||
let name_lower = name.to_ascii_lower();
|
||||
match name_lower.as_slice() {
|
||||
// All supported pseudo-elements
|
||||
"before" => Some(Before),
|
||||
"after" => Some(After),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue