Bug 1329088 - Expose CSS length mode in Stylo glue. r=emilio
Add length mode args to Stylo glue functions so that Gecko can enable the
special SVG mode as needed.
MozReview-Commit-ID: 1luM13MFEXX
--- a/servo/components/style/build_gecko.rs
+++ b/servo/components/style/build_gecko.rs
@@ -443,16 +443,17 @@ mod bindings {
"StyleGeometryBox",
"StyleShapeSource",
"StyleTransition",
"mozilla::UniquePtr",
"mozilla::DefaultDelete",
"mozilla::Side",
"mozilla::binding_danger::AssertAndSuppressCleanupPolicy",
"RawServoAnimationValueMapBorrowed",
+ "mozilla::LengthMode",
];
let opaque_types = [
"std::pair__PCCP",
"std::namespace::atomic___base", "std::atomic__My_base",
"std::atomic",
"std::atomic___base",
"mozilla::gfx::.*",
"FallibleTArray",
@@ -697,16 +698,17 @@ mod bindings {
"nsTimingFunction",
"nscolor",
"nscoord",
"nsresult",
"Loader",
"ServoStyleSheet",
"EffectCompositor_CascadeLevel",
"UpdateAnimationsTasks",
+ "LengthMode",
];
struct ArrayType {
cpp_type: &'static str,
rust_type: &'static str
}
let array_types = [
ArrayType { cpp_type: "uintptr_t", rust_type: "usize" },
];
--- a/servo/components/style/properties/declaration_block.rs
+++ b/servo/components/style/properties/declaration_block.rs
@@ -623,23 +623,24 @@ pub fn parse_style_attribute(input: &str
/// Parse a given property declaration. Can result in multiple
/// `PropertyDeclaration`s when expanding a shorthand, for example.
///
/// The vector returned will not have the importance set;
/// this does not attempt to parse !important at all
pub fn parse_one_declaration(id: PropertyId,
input: &str,
url_data: &UrlExtraData,
+ length_mode: LengthMode,
error_reporter: &ParseErrorReporter)
-> Result<ParsedDeclaration, ()> {
let context = ParserContext::new(Origin::Author,
url_data,
error_reporter,
Some(CssRuleType::Style),
- LengthMode::Default);
+ length_mode);
Parser::new(input).parse_entirely(|parser| {
ParsedDeclaration::parse(id, &context, parser)
.map_err(|_| ())
})
}
/// A struct to parse property declarations.
struct PropertyDeclarationParser<'a, 'b: 'a> {
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -66,17 +66,17 @@ use style::gecko_bindings::structs::nsCS
use style::gecko_bindings::structs::nsresult;
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasFFI, HasArcFFI, HasBoxFFI};
use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
use style::gecko_bindings::sugar::refptr::RefPtr;
use style::gecko_properties::{self, style_structs};
use style::keyframes::KeyframesStepValue;
use style::media_queries::{MediaList, parse_media_query_list};
use style::parallel;
-use style::parser::ParserContext;
+use style::parser::{LengthMode, ParserContext};
use style::properties::{CascadeFlags, ComputedValues, Importance, ParsedDeclaration};
use style::properties::{PropertyDeclarationBlock, PropertyId};
use style::properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
use style::properties::animated_properties::{AnimationValue, Interpolate, TransitionProperty};
use style::properties::parse_one_declaration;
use style::restyle_hints::{self, RestyleHint};
use style::rule_tree::StyleSource;
use style::selector_parser::PseudoElementCascadeType;
@@ -1152,47 +1152,51 @@ pub extern "C" fn Servo_DeclarationBlock
property: *const nsACString) -> bool {
let property_id = get_property_id_from_property!(property, false);
read_locked_arc(declarations, |decls: &PropertyDeclarationBlock| {
decls.property_priority(&property_id).important()
})
}
fn set_property(declarations: RawServoDeclarationBlockBorrowed, property_id: PropertyId,
- value: *const nsACString, is_important: bool, data: *mut URLExtraData) -> bool {
+ value: *const nsACString, is_important: bool, data: *mut URLExtraData,
+ length_mode: structs::LengthMode) -> bool {
let value = unsafe { value.as_ref().unwrap().as_str_unchecked() };
-
let url_data = unsafe { RefPtr::from_ptr_ref(&data) };
- if let Ok(parsed) = parse_one_declaration(property_id, value, url_data,
+ let length_mode = match length_mode {
+ structs::LengthMode::Default => LengthMode::Default,
+ structs::LengthMode::SVG => LengthMode::SVG,
+ };
+ if let Ok(parsed) = parse_one_declaration(property_id, value, url_data, length_mode,
&StdoutErrorReporter) {
let importance = if is_important { Importance::Important } else { Importance::Normal };
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
parsed.expand_set_into(decls, importance)
})
} else {
false
}
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetProperty(declarations: RawServoDeclarationBlockBorrowed,
property: *const nsACString, value: *const nsACString,
- is_important: bool,
- data: *mut URLExtraData) -> bool {
+ is_important: bool, data: *mut URLExtraData,
+ length_mode: structs::LengthMode) -> bool {
set_property(declarations, get_property_id_from_property!(property, false),
- value, is_important, data)
+ value, is_important, data, length_mode)
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetPropertyById(declarations: RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID, value: *const nsACString,
- is_important: bool,
- data: *mut URLExtraData) -> bool {
+ is_important: bool, data: *mut URLExtraData,
+ length_mode: structs::LengthMode) -> bool {
set_property(declarations, get_property_id_from_nscsspropertyid!(property, false),
- value, is_important, data)
+ value, is_important, data, length_mode)
}
fn remove_property(declarations: RawServoDeclarationBlockBorrowed, property_id: PropertyId) {
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
decls.remove_property(&property_id);
});
}
@@ -1673,17 +1677,17 @@ pub extern "C" fn Servo_CSSSupports2(pro
let id = if let Ok(id) = PropertyId::parse(property.into()) {
id
} else {
return false
};
let value = unsafe { value.as_ref().unwrap().as_str_unchecked() };
let url_data = unsafe { dummy_url_data() };
- parse_one_declaration(id, &value, url_data, &StdoutErrorReporter).is_ok()
+ parse_one_declaration(id, &value, url_data, LengthMode::Default, &StdoutErrorReporter).is_ok()
}
#[no_mangle]
pub extern "C" fn Servo_CSSSupports(cond: *const nsACString) -> bool {
let condition = unsafe { cond.as_ref().unwrap().as_str_unchecked() };
let mut input = Parser::new(&condition);
let cond = parse_condition_or_declaration(&mut input);
if let Ok(cond) = cond {