Add an FFI which returns computed values for a given declaration block with/without parent_style. r?heycam

The function uses document's default computed values if the parent style
is not specified.
This commit is contained in:
Hiroyuki Ikezoe 2017-04-14 23:39:16 +09:00
parent 39d3c22edc
commit bd066af640
3 changed files with 52 additions and 1 deletions

View file

@ -2123,3 +2123,27 @@ pub extern "C" fn Servo_StyleSet_GetFontFaceRules(raw_data: RawServoStyleSetBorr
dest.mSheetType = src.1.into();
}
}
#[no_mangle]
pub extern "C" fn Servo_StyleSet_ResolveForDeclarations(raw_data: RawServoStyleSetBorrowed,
parent_style_or_null: ServoComputedValuesBorrowedOrNull,
declarations: RawServoDeclarationBlockBorrowed)
-> ServoComputedValuesStrong
{
let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
let guards = StylesheetGuards::same(&guard);
let parent_style = match ComputedValues::arc_from_borrowed(&parent_style_or_null) {
Some(parent) => &parent,
None => doc_data.default_computed_values(),
};
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
doc_data.stylist.compute_for_declarations(&guards,
parent_style,
declarations.clone()).into_strong()
}