Bug 1350175 - Part 4: Set line and column values for CSS rules from Gecko glue. r=xidorn
MozReview-Commit-ID: HnhZnoul55s
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -753,31 +753,34 @@ pub extern "C" fn Servo_CssRules_DeleteR
macro_rules! impl_basic_rule_funcs {
{ ($name:ident, $rule_type:ty, $raw_type:ty),
getter: $getter:ident,
debug: $debug:ident,
to_css: $to_css:ident,
} => {
#[no_mangle]
- pub extern "C" fn $getter(rules: ServoCssRulesBorrowed, index: u32, line: *mut u32, column: *mut u32)
+ pub extern "C" fn $getter(rules: ServoCssRulesBorrowed, index: u32,
+ line: *mut u32, column: *mut u32)
-> Strong<$raw_type> {
- read_locked_arc(rules, |rules: &CssRules| {
- match rules.0[index as usize] {
- CssRule::$name(ref rule) => {
- *unsafe { line.as_mut().unwrap() } = 0;
- *unsafe { column.as_mut().unwrap() } = 0;
- rule.clone().into_strong()
- },
- _ => {
- unreachable!(concat!(stringify!($getter), "should only be called ",
- "on a ", stringify!($name), " rule"));
- }
+ let global_style_data = &*GLOBAL_STYLE_DATA;
+ let guard = global_style_data.shared_lock.read();
+ let rules = Locked::<CssRules>::as_arc(&rules).read_with(&guard);
+ match rules.0[index as usize] {
+ CssRule::$name(ref rule) => {
+ let location = rule.read_with(&guard).source_location;
+ *unsafe { line.as_mut().unwrap() } = location.line as u32;
+ *unsafe { column.as_mut().unwrap() } = location.column as u32;
+ rule.clone().into_strong()
+ },
+ _ => {
+ unreachable!(concat!(stringify!($getter), "should only be called ",
+ "on a ", stringify!($name), " rule"));
}
- })
+ }
}
#[no_mangle]
pub extern "C" fn $debug(rule: &$raw_type, result: *mut nsACString) {
read_locked_arc(rule, |rule: &$rule_type| {
write!(unsafe { result.as_mut().unwrap() }, "{:?}", *rule).unwrap();
})
}