Bug 1464091 - Ignore case in media feature names inside media query expressions. r=heycam, a=RyanVM
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 31 May 2018 18:22:48 +1000
changeset 471310 bbba8cee7041
parent 471309 70c46487e513
child 471311 91934961833a
push id9364
push userryanvm@gmail.com
push dateWed, 13 Jun 2018 23:32:57 +0000
treeherdermozilla-beta@91934961833a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam, RyanVM
bugs1464091
milestone61.0
Bug 1464091 - Ignore case in media feature names inside media query expressions. r=heycam, a=RyanVM Media feature names are converted to lower case before being processed, making them effectively case-insensitive. Prefixes ("min-", etc.) and values are already treated in a case-insensitive manner. MozReview-Commit-ID: JUeeEQEMIi4
servo/components/style/gecko/media_queries.rs
--- a/servo/components/style/gecko/media_queries.rs
+++ b/servo/components/style/gecko/media_queries.rs
@@ -18,17 +18,17 @@ use gecko_bindings::structs::{nsMediaFea
 use gecko_bindings::structs::{nsMediaFeature_ValueType, nsPresContext};
 use gecko_bindings::structs::RawGeckoPresContextOwned;
 use media_queries::MediaType;
 use parser::{Parse, ParserContext};
 use properties::ComputedValues;
 use servo_arc::Arc;
 use std::fmt::{self, Write};
 use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicUsize, Ordering};
-use str::starts_with_ignore_ascii_case;
+use str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase};
 use string_cache::Atom;
 use style_traits::{CSSPixel, CssWriter, DevicePixel};
 use style_traits::{ParseError, StyleParseErrorKind, ToCss};
 use style_traits::viewport::ViewportConstraints;
 use stylesheets::Origin;
 use values::{serialize_atom_identifier, CSSFloat, CustomIdent, KeyframesName};
 use values::computed::{self, ToComputedValue};
 use values::computed::font::FontSize;
@@ -638,17 +638,17 @@ impl Expression {
                         Range::Min
                     } else if starts_with_ignore_ascii_case(feature_name, "max-") {
                         feature_name = &feature_name[4..];
                         Range::Max
                     } else {
                         Range::Equal
                     };
 
-                    let atom = Atom::from(feature_name);
+                    let atom = Atom::from(string_as_ascii_lowercase(feature_name));
                     match find_feature(|f| atom.as_ptr() == unsafe { *f.mName as *mut _ }) {
                         Some(f) => Ok((f, range)),
                         None => Err(()),
                     }
                 };
 
                 match result {
                     Ok((f, r)) => {