servo: Merge #17915 - Remove Gecko_GetMediaFeatures and access nsMediaFeatures::features directly (from upsuper:media-features); r=emilio
authorXidorn Quan <me@upsuper.org>
Sat, 29 Jul 2017 05:22:20 -0500
changeset 420523 618bd2e8fb6d7dad47e6b105becd9632cf8d350b
parent 420522 cdb98cea92adbf901b34bebcdecb6f5908f2eeac
child 420524 564a2867f073ba9e592f28330830daf91bf5e1ae
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs17915, 1385529
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #17915 - Remove Gecko_GetMediaFeatures and access nsMediaFeatures::features directly (from upsuper:media-features); r=emilio This is the Servo side change of [bug 1385529](https://bugzilla.mozilla.org/show_bug.cgi?id=1385529). Source-Repo: https://github.com/servo/servo Source-Revision: 03223be66bd6ff5011479903da6ae706c503c2cc
servo/components/style/gecko/generated/bindings.rs
servo/components/style/gecko/media_queries.rs
--- a/servo/components/style/gecko/generated/bindings.rs
+++ b/servo/components/style/gecko/generated/bindings.rs
@@ -73,17 +73,16 @@ use gecko_bindings::structs::nsCSSUnit;
 use gecko_bindings::structs::nsCSSValue;
 use gecko_bindings::structs::nsCSSValueSharedList;
 use gecko_bindings::structs::nsChangeHint;
 use gecko_bindings::structs::nsCursorImage;
 use gecko_bindings::structs::nsFont;
 use gecko_bindings::structs::nsIAtom;
 use gecko_bindings::structs::nsIURI;
 use gecko_bindings::structs::nsCompatibility;
-use gecko_bindings::structs::nsMediaFeature;
 use gecko_bindings::structs::nsRestyleHint;
 use gecko_bindings::structs::nsStyleBackground;
 unsafe impl Send for nsStyleBackground {}
 unsafe impl Sync for nsStyleBackground {}
 use gecko_bindings::structs::nsStyleBorder;
 unsafe impl Send for nsStyleBorder {}
 unsafe impl Sync for nsStyleBorder {}
 use gecko_bindings::structs::nsStyleColor;
@@ -1481,19 +1480,16 @@ extern "C" {
 }
 extern "C" {
     pub fn Gecko_StyleSheet_AddRef(aSheet: *const ServoStyleSheet);
 }
 extern "C" {
     pub fn Gecko_StyleSheet_Release(aSheet: *const ServoStyleSheet);
 }
 extern "C" {
-    pub fn Gecko_GetMediaFeatures() -> *const nsMediaFeature;
-}
-extern "C" {
     pub fn Gecko_LookupCSSKeyword(string: *const u8, len: u32)
      -> nsCSSKeyword;
 }
 extern "C" {
     pub fn Gecko_CSSKeywordString(keyword: nsCSSKeyword, len: *mut u32)
      -> *const ::std::os::raw::c_char;
 }
 extern "C" {
--- a/servo/components/style/gecko/media_queries.rs
+++ b/servo/components/style/gecko/media_queries.rs
@@ -8,16 +8,17 @@ use app_units::AU_PER_PX;
 use app_units::Au;
 use context::QuirksMode;
 use cssparser::{CssStringWriter, Parser, RGBA, Token, BasicParseError};
 use euclid::ScaleFactor;
 use euclid::Size2D;
 use font_metrics::get_metrics_provider_for_product;
 use gecko::values::convert_nscolor_to_rgba;
 use gecko_bindings::bindings;
+use gecko_bindings::structs;
 use gecko_bindings::structs::{nsCSSKeyword, nsCSSProps_KTableEntry, nsCSSValue, nsCSSUnit, nsStringBuffer};
 use gecko_bindings::structs::{nsMediaExpression_Range, nsMediaFeature};
 use gecko_bindings::structs::{nsMediaFeature_ValueType, nsMediaFeature_RangeType, nsMediaFeature_RequirementFlags};
 use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextOwned};
 use media_queries::MediaType;
 use parser::ParserContext;
 use properties::{ComputedValues, StyleBuilder};
 use properties::longhands::font_size;
@@ -420,31 +421,25 @@ impl MediaExpressionValue {
             }
         }
     }
 }
 
 fn find_feature<F>(mut f: F) -> Option<&'static nsMediaFeature>
     where F: FnMut(&'static nsMediaFeature) -> bool,
 {
-    // FIXME(emilio): With build-time bindgen, we would be able to use
-    // structs::nsMediaFeatures_features. That would unfortunately break MSVC
-    // builds, or require one bindings file per platform.
-    //
-    // I'm not into any of those, so meanwhile let's use a FFI function.
     unsafe {
-        let mut features = bindings::Gecko_GetMediaFeatures();
+        let mut features = structs::nsMediaFeatures_features.as_ptr();
         while !(*features).mName.is_null() {
             if f(&*features) {
                 return Some(&*features);
             }
             features = features.offset(1);
         }
     }
-
     None
 }
 
 unsafe fn find_in_table<F>(mut current_entry: *const nsCSSProps_KTableEntry,
                            mut f: F)
                            -> Option<(nsCSSKeyword, i16)>
     where F: FnMut(nsCSSKeyword, i16) -> bool
 {