# HG changeset patch # User Xidorn Quan # Date 1524956611 -36000 # Node ID 5edb30a5ac7b2382b6d412ce90817e7bc782d529 # Parent 2d7060c1a6b64f6126ea31a9f5ad9eecaaac8e11 Bug 1434130 part 2 - Add collect_values function to SpecifiedValueInfo trait for collecting possible values. r=emilio This is the basic structure of the stuff. Following patches will fill the gap between Gecko and Servo on value generating, and finally hook it into InspectorUtils. MozReview-Commit-ID: KNLAfFBiY6e diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -928,30 +928,46 @@ pub extern "C" fn Servo_ComputedValues_E }; match AnimationValue::from_computed_values(property, &computed_values) { Some(v) => Arc::new(v).into_strong(), None => Strong::null(), } } +macro_rules! parse_enabled_property_name { + ($prop_name:ident, $found:ident, $default:expr) => {{ + let prop_name = $prop_name.as_ref().unwrap().as_str_unchecked(); + // XXX This can be simplified once Option::filter is stable. + let prop_id = PropertyId::parse(prop_name).ok().and_then(|p| { + if p.enabled_for_all_content() { + Some(p) + } else { + None + } + }); + match prop_id { + Some(p) => { + *$found = true; + p + } + None => { + *$found = false; + return $default; + } + } + }} +} + #[no_mangle] pub unsafe extern "C" fn Servo_Property_IsShorthand( prop_name: *const nsACString, found: *mut bool ) -> bool { - let prop_id = PropertyId::parse(prop_name.as_ref().unwrap().as_str_unchecked()); - let prop_id = match prop_id { - Ok(ref p) if p.enabled_for_all_content() => p, - _ => { - *found = false; - return false; - } - }; - *found = true; + let prop_id = parse_enabled_property_name!(prop_name, found, false); prop_id.is_shorthand() } #[no_mangle] pub unsafe extern "C" fn Servo_Property_IsInherited( prop_name: *const nsACString, ) -> bool { let prop_name = prop_name.as_ref().unwrap().as_str_unchecked();