Skip to content

Commit 5d4f863

Browse files
committed
servo: Merge #1388 - Fixed this issue (rust-lang/rust#10683) (from hyunjunekim:cssissues); r=kmcallister
Fixed this issue ( rust-lang/rust#10683 ) Source-Repo: https://github.com/servo/servo Source-Revision: c5d81f13c167ba46836b78359389e8d1a3f817d6 UltraBlame original commit: 19615f9ab014ee097b16427c1c85db9c1a353b6d
1 parent 98477c6 commit 5d4f863

File tree

5 files changed

+60
-30
lines changed

5 files changed

+60
-30
lines changed

servo/src/components/script/dom/htmliframeelement.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ impl HTMLIFrameElement {
9898
if "sandbox" == name {
9999
let mut modes = AllowNothing as u8;
100100
for word in value.split_iter(' ') {
101-
modes |= match word.to_ascii_lower().as_slice() {
101+
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
102+
let word_lower = word.to_ascii_lower();
103+
modes |= match word_lower.as_slice() {
102104
"allow-same-origin" => AllowSameOrigin,
103105
"allow-forms" => AllowForms,
104106
"allow-pointer-lock" => AllowPointerLock,

servo/src/components/style/common_types.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ 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+
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
54+
let unit_lower = unit.to_ascii_lower();
55+
match unit_lower.as_slice() {
5456
"px" => Some(Length::from_px(value)),
5557
"in" => Some(Au_(Au((value * AU_PER_IN) as i32))),
5658
"cm" => Some(Au_(Au((value * AU_PER_CM) as i32))),

servo/src/components/style/media_queries.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ 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+
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
86+
let value_lower = value.to_ascii_lower();
87+
match value_lower.as_slice() {
8688
"screen" => Some(MediaQuery{ media_type: MediaType(Screen) }),
8789
"print" => Some(MediaQuery{ media_type: MediaType(Print) }),
8890
"all" => Some(MediaQuery{ media_type: All }),

servo/src/components/style/properties.rs.mako

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,15 @@ 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+
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
194+
let value_lower = value.to_ascii_lower();
195+
match value_lower.as_slice() {
196+
"thin" => Some(specified::Length::from_px(1.)),
197+
"medium" => Some(specified::Length::from_px(3.)),
198+
"thick" => Some(specified::Length::from_px(5.)),
199+
_ => None
200+
}
197201
},
198202
_ => specified::Length::parse_non_negative(component_value)
199203
}
@@ -332,11 +336,15 @@ pub mod longhands {
332336
/// | <percentage> | <length>
333337
pub fn from_component_value(input: &ComponentValue) -> Option<SpecifiedValue> {
334338
match input {
335-
&Ident(ref value) => match value.to_ascii_lower().as_slice() {
336-
% for keyword in vertical_align_keywords:
339+
&Ident(ref value) => {
340+
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
341+
let value_lower = value.to_ascii_lower();
342+
match value_lower.as_slice() {
343+
% for keyword in vertical_align_keywords:
337344
"${keyword}" => Some(Specified_${to_rust_ident(keyword)}),
338-
% endfor
339-
_ => None,
345+
% endfor
346+
_ => None,
347+
}
340348
},
341349
_ => specified::LengthOrPercentage::parse_non_negative(input)
342350
.map(SpecifiedLengthOrPercentage)
@@ -454,8 +462,10 @@ pub mod longhands {
454462
// TODO: avoid copying strings?
455463
Some(&String(ref value)) => add!(FamilyName(value.to_owned())),
456464
Some(&Ident(ref value)) => {
465+
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
457466
let value = value.as_slice();
458-
match value.to_ascii_lower().as_slice() {
467+
let value_lower = value.to_ascii_lower();
468+
match value_lower.as_slice() {
459469
// "serif" => add!(Serif),
460470
// "sans-serif" => add!(SansSerif),
461471
// "cursive" => add!(Cursive),
@@ -503,12 +513,16 @@ pub mod longhands {
503513
/// normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
504514
pub fn from_component_value(input: &ComponentValue) -> Option<SpecifiedValue> {
505515
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,
516+
&Ident(ref value) => {
517+
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
518+
let value_lower = value.to_ascii_lower();
519+
match value_lower.as_slice() {
520+
"bold" => Some(SpecifiedWeight700),
521+
"normal" => Some(SpecifiedWeight400),
522+
"bolder" => Some(Bolder),
523+
"lighter" => Some(Lighther),
524+
_ => None,
525+
}
512526
},
513527
&Number(ref value) => match value.int_value {
514528
Some(100) => Some(SpecifiedWeight100),

servo/src/components/style/selectors.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,18 @@ 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+
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
313+
let name_lower = name.to_ascii_lower();
314+
match name_lower.as_slice() {
315+
// Supported CSS 2.1 pseudo-elements only.
316+
// ** Do not add to this list! **
317+
"before" => PseudoElementResult(Before),
318+
"after" => PseudoElementResult(After),
319+
"first-line" => PseudoElementResult(FirstLine),
320+
"first-letter" => PseudoElementResult(FirstLetter),
321+
_ => InvalidSimpleSelector
322+
}
319323
},
320324
Some(result) => SimpleSelectorResult(result),
321325
},
@@ -443,7 +447,9 @@ fn parse_attribute_selector(content: ~[ComponentValue], namespaces: &NamespaceMa
443447

444448

445449
fn parse_simple_pseudo_class(name: &str) -> Option<SimpleSelector> {
446-
match name.to_ascii_lower().as_slice() {
450+
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
451+
let name_lower = name.to_ascii_lower();
452+
match name_lower.as_slice() {
447453
"any-link" => Some(AnyLink),
448454
"link" => Some(Link),
449455
"visited" => Some(Visited),
@@ -463,7 +469,9 @@ fn parse_simple_pseudo_class(name: &str) -> Option<SimpleSelector> {
463469
fn parse_functional_pseudo_class(name: ~str, arguments: ~[ComponentValue],
464470
namespaces: &NamespaceMap, inside_negation: bool)
465471
-> Option<SimpleSelector> {
466-
match name.to_ascii_lower().as_slice() {
472+
// FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
473+
let name_lower = name.to_ascii_lower();
474+
match name_lower.as_slice() {
467475
// "lang" => parse_lang(arguments),
468476
"nth-child" => parse_nth(arguments).map(|(a, b)| NthChild(a, b)),
469477
"nth-last-child" => parse_nth(arguments).map(|(a, b)| NthLastChild(a, b)),
@@ -476,7 +484,9 @@ fn parse_functional_pseudo_class(name: ~str, arguments: ~[ComponentValue],
476484

477485

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

0 commit comments

Comments
 (0)