stylo: Implement GetSpecificity for ServoStyleRule

This commit is contained in:
Fernando Jiménez Moreno 2017-06-10 12:41:46 +02:00
parent 87140641a4
commit 2cc940384d
3 changed files with 39 additions and 26 deletions

View file

@ -1187,14 +1187,15 @@ pub extern "C" fn Servo_StyleRule_GetSelectorText(rule: RawServoStyleRuleBorrowe
}
#[no_mangle]
pub extern "C" fn Servo_StyleRule_GetSelectorTextFromIndex(rule: RawServoStyleRuleBorrowed,
aSelectorIndex: u32,
result: *mut nsAString) {
pub extern "C" fn Servo_StyleRule_GetSelectorTextAtIndex(rule: RawServoStyleRuleBorrowed,
index: u32,
result: *mut nsAString) {
read_locked_arc(rule, |rule: &StyleRule| {
rule.selectors.to_css_from_index(
aSelectorIndex as usize,
unsafe { result.as_mut().unwrap() }
).unwrap();
let index = index as usize;
if index >= rule.selectors.0.len() {
return;
}
rule.selectors.0[index].selector.to_css(unsafe { result.as_mut().unwrap() }).unwrap();
})
}
@ -1205,6 +1206,21 @@ pub extern "C" fn Servo_StyleRule_GetSelectorCount(rule: RawServoStyleRuleBorrow
})
}
#[no_mangle]
pub extern "C" fn Servo_StyleRule_GetSpecificityAtIndex(rule: RawServoStyleRuleBorrowed,
index: u32,
specificity: *mut u64) {
read_locked_arc(rule, |rule: &StyleRule| {
let mut specificity = unsafe { specificity.as_mut().unwrap() };
let index = index as usize;
if index >= rule.selectors.0.len() {
*specificity = 0;
return;
}
*specificity = rule.selectors.0[index].selector.specificity() as u64;
})
}
#[no_mangle]
pub extern "C" fn Servo_ImportRule_GetHref(rule: RawServoImportRuleBorrowed, result: *mut nsAString) {
read_locked_arc(rule, |rule: &ImportRule| {