Skip to content

Commit 8f57e70

Browse files
hyunjunekimtherealglazou
authored andcommitted
Fixed this issue (rust-lang/rust#10683)
1 parent af9b9dd commit 8f57e70

File tree

5 files changed

+49
-30
lines changed

5 files changed

+49
-30
lines changed

src/components/script/dom/htmliframeelement.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ impl HTMLIFrameElement {
116116
if "sandbox" == name {
117117
let mut modes = AllowNothing as u8;
118118
for word in value.split_iter(' ') {
119-
modes |= match word.to_ascii_lower().as_slice() {
119+
let word_lower = word.to_ascii_lower();
120+
modes |= match word_lower.as_slice() {
120121
"allow-same-origin" => AllowSameOrigin,
121122
"allow-forms" => AllowForms,
122123
"allow-pointer-lock" => AllowPointerLock,

src/components/style/common_types.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ pub mod specified {
5050
Length::parse_internal(input, /* negative_ok = */ false)
5151
}
5252
pub fn parse_dimension(value: CSSFloat, unit: &str) -> Option<Length> {
53-
match unit.to_ascii_lower().as_slice() {
53+
let unit_lower = unit.to_ascii_lower();
54+
match unit_lower.as_slice() {
5455
"px" => Some(Length::from_px(value)),
5556
"in" => Some(Au_(Au((value * AU_PER_IN) as i32))),
5657
"cm" => Some(Au_(Au((value * AU_PER_CM) as i32))),

src/components/style/media_queries.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ pub fn parse_media_query_list(input: &[ComponentValue]) -> MediaQueryList {
8282
loop {
8383
let mq = match next {
8484
Some(&Ident(ref value)) => {
85-
match value.to_ascii_lower().as_slice() {
85+
let value_lower = value.to_ascii_lower();
86+
match value_lower.as_slice() {
8687
"screen" => Some(MediaQuery{ media_type: MediaType(Screen) }),
8788
"print" => Some(MediaQuery{ media_type: MediaType(Print) }),
8889
"all" => Some(MediaQuery{ media_type: All }),

src/components/style/properties.rs.mako

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,14 @@ pub mod longhands {
189189

190190
pub fn parse_border_width(component_value: &ComponentValue) -> Option<specified::Length> {
191191
match component_value {
192-
&Ident(ref value) => match value.to_ascii_lower().as_slice() {
193-
"thin" => Some(specified::Length::from_px(1.)),
194-
"medium" => Some(specified::Length::from_px(3.)),
195-
"thick" => Some(specified::Length::from_px(5.)),
196-
_ => None
192+
&Ident(ref value) => {
193+
let value_lower = value.to_ascii_lower();
194+
match value_lower.as_slice() {
195+
"thin" => Some(specified::Length::from_px(1.)),
196+
"medium" => Some(specified::Length::from_px(3.)),
197+
"thick" => Some(specified::Length::from_px(5.)),
198+
_ => None
199+
}
197200
},
198201
_ => specified::Length::parse_non_negative(component_value)
199202
}
@@ -332,11 +335,14 @@ pub mod longhands {
332335
/// | <percentage> | <length>
333336
pub fn from_component_value(input: &ComponentValue) -> Option<SpecifiedValue> {
334337
match input {
335-
&Ident(ref value) => match value.to_ascii_lower().as_slice() {
336-
% for keyword in vertical_align_keywords:
338+
&Ident(ref value) => {
339+
let value_lower = value.to_ascii_lower();
340+
match value_lower.as_slice() {
341+
% for keyword in vertical_align_keywords:
337342
"${keyword}" => Some(Specified_${to_rust_ident(keyword)}),
338-
% endfor
339-
_ => None,
343+
% endfor
344+
_ => None,
345+
}
340346
},
341347
_ => specified::LengthOrPercentage::parse_non_negative(input)
342348
.map(SpecifiedLengthOrPercentage)
@@ -455,7 +461,8 @@ pub mod longhands {
455461
Some(&String(ref value)) => add!(FamilyName(value.to_owned())),
456462
Some(&Ident(ref value)) => {
457463
let value = value.as_slice();
458-
match value.to_ascii_lower().as_slice() {
464+
let value_lower = value.to_ascii_lower();
465+
match value_lower.as_slice() {
459466
// "serif" => add!(Serif),
460467
// "sans-serif" => add!(SansSerif),
461468
// "cursive" => add!(Cursive),
@@ -503,12 +510,15 @@ pub mod longhands {
503510
/// normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
504511
pub fn from_component_value(input: &ComponentValue) -> Option<SpecifiedValue> {
505512
match input {
506-
&Ident(ref value) => match value.to_ascii_lower().as_slice() {
507-
"bold" => Some(SpecifiedWeight700),
508-
"normal" => Some(SpecifiedWeight400),
509-
"bolder" => Some(Bolder),
510-
"lighter" => Some(Lighther),
511-
_ => None,
513+
&Ident(ref value) => {
514+
let value_lower = value.to_ascii_lower();
515+
match value_lower.as_slice() {
516+
"bold" => Some(SpecifiedWeight700),
517+
"normal" => Some(SpecifiedWeight400),
518+
"bolder" => Some(Bolder),
519+
"lighter" => Some(Lighther),
520+
_ => None,
521+
}
512522
},
513523
&Number(ref value) => match value.int_value {
514524
Some(100) => Some(SpecifiedWeight100),

src/components/style/selectors.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,17 @@ fn parse_one_simple_selector(iter: &mut Iter, namespaces: &NamespaceMap, inside_
308308
iter.next();
309309
match iter.next() {
310310
Some(Ident(name)) => match parse_simple_pseudo_class(name) {
311-
None => match name.to_ascii_lower().as_slice() {
312-
// Supported CSS 2.1 pseudo-elements only.
313-
// ** Do not add to this list! **
314-
"before" => PseudoElementResult(Before),
315-
"after" => PseudoElementResult(After),
316-
"first-line" => PseudoElementResult(FirstLine),
317-
"first-letter" => PseudoElementResult(FirstLetter),
318-
_ => InvalidSimpleSelector
311+
None => {
312+
let name_lower = name.to_ascii_lower();
313+
match name_lower.as_slice() {
314+
// Supported CSS 2.1 pseudo-elements only.
315+
// ** Do not add to this list! **
316+
"before" => PseudoElementResult(Before),
317+
"after" => PseudoElementResult(After),
318+
"first-line" => PseudoElementResult(FirstLine),
319+
"first-letter" => PseudoElementResult(FirstLetter),
320+
_ => InvalidSimpleSelector
321+
}
319322
},
320323
Some(result) => SimpleSelectorResult(result),
321324
},
@@ -443,7 +446,8 @@ fn parse_attribute_selector(content: ~[ComponentValue], namespaces: &NamespaceMa
443446

444447

445448
fn parse_simple_pseudo_class(name: &str) -> Option<SimpleSelector> {
446-
match name.to_ascii_lower().as_slice() {
449+
let name_lower = name.to_ascii_lower();
450+
match name_lower.as_slice() {
447451
"any-link" => Some(AnyLink),
448452
"link" => Some(Link),
449453
"visited" => Some(Visited),
@@ -463,7 +467,8 @@ fn parse_simple_pseudo_class(name: &str) -> Option<SimpleSelector> {
463467
fn parse_functional_pseudo_class(name: ~str, arguments: ~[ComponentValue],
464468
namespaces: &NamespaceMap, inside_negation: bool)
465469
-> Option<SimpleSelector> {
466-
match name.to_ascii_lower().as_slice() {
470+
let name_lower = name.to_ascii_lower();
471+
match name_lower.as_slice() {
467472
// "lang" => parse_lang(arguments),
468473
"nth-child" => parse_nth(arguments).map(|(a, b)| NthChild(a, b)),
469474
"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],
476481

477482

478483
fn parse_pseudo_element(name: ~str) -> Option<PseudoElement> {
479-
match name.to_ascii_lower().as_slice() {
484+
let name_lower = name.to_ascii_lower();
485+
match name_lower.as_slice() {
480486
// All supported pseudo-elements
481487
"before" => Some(Before),
482488
"after" => Some(After),

0 commit comments

Comments
 (0)