Skip to content

Commit

Permalink
Remove Gecko_GetMediaFeatures and access nsMediaFeatures::features di…
Browse files Browse the repository at this point in the history
…rectly.
  • Loading branch information
upsuper committed Jul 29, 2017
1 parent dde1f46 commit dd2b851
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
4 changes: 0 additions & 4 deletions components/style/gecko/generated/bindings.rs
Expand Up @@ -78,7 +78,6 @@ 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 {}
Expand Down Expand Up @@ -1485,9 +1484,6 @@ extern "C" {
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;
Expand Down
9 changes: 2 additions & 7 deletions components/style/gecko/media_queries.rs
Expand Up @@ -13,6 +13,7 @@ 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};
Expand Down Expand Up @@ -425,21 +426,15 @@ 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
}

Expand Down

0 comments on commit dd2b851

Please sign in to comment.