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