style: Use Servo side data to back InspectorUtils::CssPropertySupportsType.

The only difference in the final result is "all" shorthand, for which
the original result is wrong because "all" shorthand doesn't accept any
value other than the CSS-wide keywords.

Bug: 1455576
Reviewed-by: emilio
MozReview-Commit-ID: BmT7kGwC0ZQ
This commit is contained in:
Xidorn Quan 2018-04-26 09:01:02 +10:00 committed by Emilio Cobos Álvarez
parent 7fe7b2ffb1
commit 14b05bead7
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -164,7 +164,7 @@ use style::values::generics::rect::Rect;
use style::values::specified;
use style::values::specified::gecko::{IntersectionObserverRootMargin, PixelOrPercentage};
use style::values::specified::source_size_list::SourceSizeList;
use style_traits::{CssWriter, ParsingMode, StyleParseErrorKind, ToCss};
use style_traits::{CssType, CssWriter, ParsingMode, StyleParseErrorKind, ToCss};
use super::error_reporter::ErrorReporter;
use super::stylesheet_loader::{AsyncStylesheetParser, StylesheetLoader};
@ -974,6 +974,35 @@ pub unsafe extern "C" fn Servo_Property_IsInherited(
longhand_id.inherited()
}
#[no_mangle]
pub unsafe extern "C" fn Servo_Property_SupportsType(
prop_name: *const nsACString,
ty: u32,
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;
// This should match the constants in InspectorUtils.
// (Let's don't bother importing InspectorUtilsBinding into bindings
// because it is not used anywhere else, and issue here would be
// caught by the property-db test anyway.)
let ty = match ty {
1 => CssType::COLOR,
2 => CssType::GRADIENT,
3 => CssType::TIMING_FUNCTION,
_ => unreachable!("unknown CSS type {}", ty),
};
prop_id.supports_type(ty)
}
#[no_mangle]
pub extern "C" fn Servo_Property_IsAnimatable(property: nsCSSPropertyID) -> bool {
use style::properties::animated_properties;