Skip to content

Fixed this issue (https://github.com/mozilla/rust/issues/10683) #1388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/script/dom/htmliframeelement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ 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() {
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
let word_lower = word.to_ascii_lower();
modes |= match word_lower.as_slice() {
"allow-same-origin" => AllowSameOrigin,
"allow-forms" => AllowForms,
"allow-pointer-lock" => AllowPointerLock,
Expand Down
4 changes: 3 additions & 1 deletion src/components/style/common_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ 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() {
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
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))),
Expand Down
4 changes: 3 additions & 1 deletion src/components/style/media_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ 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() {
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
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 }),
Expand Down
46 changes: 30 additions & 16 deletions src/components/style/properties.rs.mako
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,15 @@ 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) => {
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
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)
}
Expand Down Expand Up @@ -332,11 +336,15 @@ 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) => {
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
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)
Expand Down Expand Up @@ -454,8 +462,10 @@ pub mod longhands {
// TODO: avoid copying strings?
Some(&String(ref value)) => add!(FamilyName(value.to_owned())),
Some(&Ident(ref value)) => {
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
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),
Expand Down Expand Up @@ -503,12 +513,16 @@ 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) => {
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
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),
Expand Down
32 changes: 21 additions & 11 deletions src/components/style/selectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,18 @@ 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 => {
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
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),
},
Expand Down Expand Up @@ -443,7 +447,9 @@ fn parse_attribute_selector(content: ~[ComponentValue], namespaces: &NamespaceMa


fn parse_simple_pseudo_class(name: &str) -> Option<SimpleSelector> {
match name.to_ascii_lower().as_slice() {
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
let name_lower = name.to_ascii_lower();
match name_lower.as_slice() {
"any-link" => Some(AnyLink),
"link" => Some(Link),
"visited" => Some(Visited),
Expand All @@ -463,7 +469,9 @@ 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() {
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
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)),
Expand All @@ -476,7 +484,9 @@ fn parse_functional_pseudo_class(name: ~str, arguments: ~[ComponentValue],


fn parse_pseudo_element(name: ~str) -> Option<PseudoElement> {
match name.to_ascii_lower().as_slice() {
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
let name_lower = name.to_ascii_lower();
match name_lower.as_slice() {
// All supported pseudo-elements
"before" => Some(Before),
"after" => Some(After),
Expand Down