style: Use consistent formatting for functions in the glue file.

I'm tired of only drive-by fixing them :)
This commit is contained in:
Emilio Cobos Álvarez 2018-02-13 14:25:26 +01:00
parent 9e64008e75
commit 1b24ba12b7
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -390,9 +390,10 @@ pub extern "C" fn Servo_AnimationValues_Interpolate(
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_AnimationValues_IsInterpolable(from: RawServoAnimationValueBorrowed, pub extern "C" fn Servo_AnimationValues_IsInterpolable(
to: RawServoAnimationValueBorrowed) from: RawServoAnimationValueBorrowed,
-> bool { to: RawServoAnimationValueBorrowed,
) -> bool {
let from_value = AnimationValue::as_arc(&from); let from_value = AnimationValue::as_arc(&from);
let to_value = AnimationValue::as_arc(&to); let to_value = AnimationValue::as_arc(&to);
from_value.animate(to_value, Procedure::Interpolate { progress: 0.5 }).is_ok() from_value.animate(to_value, Procedure::Interpolate { progress: 0.5 }).is_ok()
@ -429,9 +430,8 @@ pub extern "C" fn Servo_AnimationValues_Accumulate(
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_AnimationValues_GetZeroValue( pub extern "C" fn Servo_AnimationValues_GetZeroValue(
value_to_match: RawServoAnimationValueBorrowed) value_to_match: RawServoAnimationValueBorrowed,
-> RawServoAnimationValueStrong ) -> RawServoAnimationValueStrong {
{
let value_to_match = AnimationValue::as_arc(&value_to_match); let value_to_match = AnimationValue::as_arc(&value_to_match);
if let Ok(zero_value) = value_to_match.to_animated_zero() { if let Ok(zero_value) = value_to_match.to_animated_zero() {
Arc::new(zero_value).into_strong() Arc::new(zero_value).into_strong()
@ -441,9 +441,10 @@ pub extern "C" fn Servo_AnimationValues_GetZeroValue(
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_AnimationValues_ComputeDistance(from: RawServoAnimationValueBorrowed, pub extern "C" fn Servo_AnimationValues_ComputeDistance(
to: RawServoAnimationValueBorrowed) from: RawServoAnimationValueBorrowed,
-> f64 { to: RawServoAnimationValueBorrowed,
) -> f64 {
let from_value = AnimationValue::as_arc(&from); let from_value = AnimationValue::as_arc(&from);
let to_value = AnimationValue::as_arc(&to); let to_value = AnimationValue::as_arc(&to);
// If compute_squared_distance() failed, this function will return negative value // If compute_squared_distance() failed, this function will return negative value
@ -592,25 +593,28 @@ pub extern "C" fn Servo_ComposeAnimationSegment(
) -> RawServoAnimationValueStrong { ) -> RawServoAnimationValueStrong {
let underlying_value = AnimationValue::arc_from_borrowed(&underlying_value).map(|v| &**v); let underlying_value = AnimationValue::arc_from_borrowed(&underlying_value).map(|v| &**v);
let last_value = AnimationValue::arc_from_borrowed(&last_value).map(|v| &**v); let last_value = AnimationValue::arc_from_borrowed(&last_value).map(|v| &**v);
let result = compose_animation_segment(segment, let result = compose_animation_segment(
underlying_value, segment,
last_value, underlying_value,
iteration_composite, last_value,
current_iteration, iteration_composite,
progress, current_iteration,
progress); progress,
progress,
);
Arc::new(result).into_strong() Arc::new(result).into_strong()
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_AnimationCompose(raw_value_map: RawServoAnimationValueMapBorrowedMut, pub extern "C" fn Servo_AnimationCompose(
base_values: RawServoAnimationValueTableBorrowed, raw_value_map: RawServoAnimationValueMapBorrowedMut,
css_property: nsCSSPropertyID, base_values: RawServoAnimationValueTableBorrowed,
segment: RawGeckoAnimationPropertySegmentBorrowed, css_property: nsCSSPropertyID,
last_segment: RawGeckoAnimationPropertySegmentBorrowed, segment: RawGeckoAnimationPropertySegmentBorrowed,
computed_timing: RawGeckoComputedTimingBorrowed, last_segment: RawGeckoAnimationPropertySegmentBorrowed,
iteration_composite: IterationCompositeOperation) computed_timing: RawGeckoComputedTimingBorrowed,
{ iteration_composite: IterationCompositeOperation,
) {
use style::gecko_bindings::bindings::Gecko_AnimationGetBaseStyle; use style::gecko_bindings::bindings::Gecko_AnimationGetBaseStyle;
use style::gecko_bindings::bindings::Gecko_GetPositionInSegment; use style::gecko_bindings::bindings::Gecko_GetPositionInSegment;
use style::gecko_bindings::bindings::Gecko_GetProgressFromComputedTiming; use style::gecko_bindings::bindings::Gecko_GetProgressFromComputedTiming;
@ -669,13 +673,15 @@ pub extern "C" fn Servo_AnimationCompose(raw_value_map: RawServoAnimationValueMa
unsafe { Gecko_GetPositionInSegment(segment, progress, computed_timing.mBeforeFlag) } unsafe { Gecko_GetPositionInSegment(segment, progress, computed_timing.mBeforeFlag) }
}; };
let result = compose_animation_segment(segment, let result = compose_animation_segment(
underlying_value.as_ref(), segment,
last_value, underlying_value.as_ref(),
iteration_composite, last_value,
computed_timing.mCurrentIteration, iteration_composite,
progress, computed_timing.mCurrentIteration,
position); progress,
position,
);
value_map.insert(property, result); value_map.insert(property, result);
} }
@ -689,10 +695,11 @@ macro_rules! get_property_id_from_nscsspropertyid {
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_AnimationValue_Serialize(value: RawServoAnimationValueBorrowed, pub extern "C" fn Servo_AnimationValue_Serialize(
property: nsCSSPropertyID, value: RawServoAnimationValueBorrowed,
buffer: *mut nsAString) property: nsCSSPropertyID,
{ buffer: *mut nsAString,
) {
let uncomputed_value = AnimationValue::as_arc(&value).uncompute(); let uncomputed_value = AnimationValue::as_arc(&value).uncompute();
let buffer = unsafe { buffer.as_mut().unwrap() }; let buffer = unsafe { buffer.as_mut().unwrap() };
let rv = PropertyDeclarationBlock::with_one(uncomputed_value, Importance::Normal) let rv = PropertyDeclarationBlock::with_one(uncomputed_value, Importance::Normal)
@ -729,7 +736,7 @@ pub extern "C" fn Servo_Shorthand_AnimationValues_Serialize(shorthand_property:
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_AnimationValue_GetOpacity( pub extern "C" fn Servo_AnimationValue_GetOpacity(
value: RawServoAnimationValueBorrowed value: RawServoAnimationValueBorrowed,
) -> f32 { ) -> f32 {
let value = AnimationValue::as_arc(&value); let value = AnimationValue::as_arc(&value);
if let AnimationValue::Opacity(opacity) = **value { if let AnimationValue::Opacity(opacity) = **value {
@ -954,18 +961,21 @@ pub extern "C" fn Servo_Element_ClearData(element: RawGeckoElementBorrowed) {
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_Element_SizeOfExcludingThisAndCVs(malloc_size_of: GeckoMallocSizeOf, pub extern "C" fn Servo_Element_SizeOfExcludingThisAndCVs(
malloc_enclosing_size_of: malloc_size_of: GeckoMallocSizeOf,
GeckoMallocSizeOf, malloc_enclosing_size_of: GeckoMallocSizeOf,
seen_ptrs: *mut SeenPtrs, seen_ptrs: *mut SeenPtrs,
element: RawGeckoElementBorrowed) -> usize { element: RawGeckoElementBorrowed,
) -> usize {
let element = GeckoElement(element); let element = GeckoElement(element);
let borrow = element.borrow_data(); let borrow = element.borrow_data();
if let Some(data) = borrow { if let Some(data) = borrow {
let have_seen_ptr = move |ptr| { unsafe { Gecko_HaveSeenPtr(seen_ptrs, ptr) } }; let have_seen_ptr = move |ptr| { unsafe { Gecko_HaveSeenPtr(seen_ptrs, ptr) } };
let mut ops = MallocSizeOfOps::new(malloc_size_of.unwrap(), let mut ops = MallocSizeOfOps::new(
Some(malloc_enclosing_size_of.unwrap()), malloc_size_of.unwrap(),
Some(Box::new(have_seen_ptr))); Some(malloc_enclosing_size_of.unwrap()),
Some(Box::new(have_seen_ptr)),
);
(*data).size_of_excluding_cvs(&mut ops) (*data).size_of_excluding_cvs(&mut ops)
} else { } else {
0 0
@ -981,27 +991,29 @@ pub extern "C" fn Servo_Element_HasPrimaryComputedValues(element: RawGeckoElemen
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_Element_GetPrimaryComputedValues(element: RawGeckoElementBorrowed) pub extern "C" fn Servo_Element_GetPrimaryComputedValues(
-> ServoStyleContextStrong element: RawGeckoElementBorrowed,
{ ) -> ServoStyleContextStrong {
let element = GeckoElement(element); let element = GeckoElement(element);
let data = element.borrow_data().expect("Getting CVs on unstyled element"); let data = element.borrow_data().expect("Getting CVs on unstyled element");
data.styles.primary().clone().into() data.styles.primary().clone().into()
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_Element_HasPseudoComputedValues(element: RawGeckoElementBorrowed, pub extern "C" fn Servo_Element_HasPseudoComputedValues(
index: usize) -> bool element: RawGeckoElementBorrowed,
{ index: usize,
) -> bool {
let element = GeckoElement(element); let element = GeckoElement(element);
let data = element.borrow_data().expect("Looking for CVs on unstyled element"); let data = element.borrow_data().expect("Looking for CVs on unstyled element");
data.styles.pseudos.as_array()[index].is_some() data.styles.pseudos.as_array()[index].is_some()
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_Element_GetPseudoComputedValues(element: RawGeckoElementBorrowed, pub extern "C" fn Servo_Element_GetPseudoComputedValues(
index: usize) -> ServoStyleContextStrong element: RawGeckoElementBorrowed,
{ index: usize,
) -> ServoStyleContextStrong {
let element = GeckoElement(element); let element = GeckoElement(element);
let data = element.borrow_data().expect("Getting CVs that aren't present"); let data = element.borrow_data().expect("Getting CVs that aren't present");
data.styles.pseudos.as_array()[index].as_ref().expect("Getting CVs that aren't present") data.styles.pseudos.as_array()[index].as_ref().expect("Getting CVs that aren't present")
@ -1062,7 +1074,7 @@ pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(
extra_data: *mut URLExtraData, extra_data: *mut URLExtraData,
line_number_offset: u32, line_number_offset: u32,
quirks_mode: nsCompatibility, quirks_mode: nsCompatibility,
reusable_sheets: *mut LoaderReusableStyleSheets reusable_sheets: *mut LoaderReusableStyleSheets,
) -> RawServoStyleSheetContentsStrong { ) -> RawServoStyleSheetContentsStrong {
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;
let input = unsafe { ::std::str::from_utf8_unchecked(::std::slice::from_raw_parts(data, data_len)) }; let input = unsafe { ::std::str::from_utf8_unchecked(::std::slice::from_raw_parts(data, data_len)) };
@ -1319,7 +1331,7 @@ pub extern "C" fn Servo_StyleSheet_SizeOfIncludingThis(
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_StyleSheet_GetOrigin( pub extern "C" fn Servo_StyleSheet_GetOrigin(
sheet: RawServoStyleSheetContentsBorrowed sheet: RawServoStyleSheetContentsBorrowed,
) -> u8 { ) -> u8 {
let origin = match StylesheetContents::as_arc(&sheet).origin { let origin = match StylesheetContents::as_arc(&sheet).origin {
Origin::UserAgent => OriginFlags_UserAgent, Origin::UserAgent => OriginFlags_UserAgent,
@ -1388,8 +1400,10 @@ fn write_locked_arc<T, R, F>(raw: &<Locked<T> as HasFFI>::FFIType, func: F) -> R
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_CssRules_ListTypes(rules: ServoCssRulesBorrowed, pub extern "C" fn Servo_CssRules_ListTypes(
result: nsTArrayBorrowed_uintptr_t) { rules: ServoCssRulesBorrowed,
result: nsTArrayBorrowed_uintptr_t,
) {
read_locked_arc(rules, |rules: &CssRules| { read_locked_arc(rules, |rules: &CssRules| {
let iter = rules.0.iter().map(|rule| rule.rule_type() as usize); let iter = rules.0.iter().map(|rule| rule.rule_type() as usize);
let (size, upper) = iter.size_hint(); let (size, upper) = iter.size_hint();
@ -1487,9 +1501,12 @@ macro_rules! impl_basic_rule_funcs {
to_css: $to_css:ident, to_css: $to_css:ident,
} => { } => {
#[no_mangle] #[no_mangle]
pub extern "C" fn $getter(rules: ServoCssRulesBorrowed, index: u32, pub extern "C" fn $getter(
line: *mut u32, column: *mut u32) rules: ServoCssRulesBorrowed,
-> Strong<$raw_type> { index: u32,
line: *mut u32,
column: *mut u32,
) -> Strong<$raw_type> {
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read(); let guard = global_style_data.shared_lock.read();
let rules = Locked::<CssRules>::as_arc(&rules).read_with(&guard); let rules = Locked::<CssRules>::as_arc(&rules).read_with(&guard);
@ -1615,9 +1632,9 @@ macro_rules! impl_getter_for_embedded_rule {
} }
impl_getter_for_embedded_rule!(Servo_CssRules_GetFontFaceRuleAt: impl_getter_for_embedded_rule!(Servo_CssRules_GetFontFaceRuleAt:
FontFace -> nsCSSFontFaceRule); FontFace -> nsCSSFontFaceRule);
impl_getter_for_embedded_rule!(Servo_CssRules_GetCounterStyleRuleAt: impl_getter_for_embedded_rule!(Servo_CssRules_GetCounterStyleRuleAt:
CounterStyle -> nsCSSCounterStyleRule); CounterStyle -> nsCSSCounterStyleRule);
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_StyleRule_GetStyle(rule: RawServoStyleRuleBorrowed) -> RawServoDeclarationBlockStrong { pub extern "C" fn Servo_StyleRule_GetStyle(rule: RawServoStyleRuleBorrowed) -> RawServoDeclarationBlockStrong {
@ -1643,9 +1660,11 @@ pub extern "C" fn Servo_StyleRule_GetSelectorText(rule: RawServoStyleRuleBorrowe
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_StyleRule_GetSelectorTextAtIndex(rule: RawServoStyleRuleBorrowed, pub extern "C" fn Servo_StyleRule_GetSelectorTextAtIndex(
index: u32, rule: RawServoStyleRuleBorrowed,
result: *mut nsAString) { index: u32,
result: *mut nsAString,
) {
read_locked_arc(rule, |rule: &StyleRule| { read_locked_arc(rule, |rule: &StyleRule| {
let index = index as usize; let index = index as usize;
if index >= rule.selectors.0.len() { if index >= rule.selectors.0.len() {
@ -1680,10 +1699,12 @@ pub extern "C" fn Servo_StyleRule_GetSpecificityAtIndex(
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_StyleRule_SelectorMatchesElement(rule: RawServoStyleRuleBorrowed, pub extern "C" fn Servo_StyleRule_SelectorMatchesElement(
element: RawGeckoElementBorrowed, rule: RawServoStyleRuleBorrowed,
index: u32, element: RawGeckoElementBorrowed,
pseudo_type: CSSPseudoElementType) -> bool { index: u32,
pseudo_type: CSSPseudoElementType,
) -> bool {
read_locked_arc(rule, |rule: &StyleRule| { read_locked_arc(rule, |rule: &StyleRule| {
let index = index as usize; let index = index as usize;
if index >= rule.selectors.0.len() { if index >= rule.selectors.0.len() {
@ -1833,7 +1854,7 @@ pub extern "C" fn Servo_ImportRule_GetHref(rule: RawServoImportRuleBorrowed, res
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_ImportRule_GetSheet( pub extern "C" fn Servo_ImportRule_GetSheet(
rule: RawServoImportRuleBorrowed rule: RawServoImportRuleBorrowed,
) -> *const ServoStyleSheet { ) -> *const ServoStyleSheet {
read_locked_arc(rule, |rule: &ImportRule| { read_locked_arc(rule, |rule: &ImportRule| {
rule.stylesheet.0.raw() as *const ServoStyleSheet rule.stylesheet.0.raw() as *const ServoStyleSheet
@ -1896,8 +1917,12 @@ pub extern "C" fn Servo_KeyframesRule_GetCount(rule: RawServoKeyframesRuleBorrow
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_KeyframesRule_GetKeyframeAt(rule: RawServoKeyframesRuleBorrowed, index: u32, pub extern "C" fn Servo_KeyframesRule_GetKeyframeAt(
line: *mut u32, column: *mut u32) -> RawServoKeyframeStrong { rule: RawServoKeyframesRuleBorrowed,
index: u32,
line: *mut u32,
column: *mut u32,
) -> RawServoKeyframeStrong {
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read(); let guard = global_style_data.shared_lock.read();
let key = Locked::<KeyframesRule>::as_arc(&rule).read_with(&guard) let key = Locked::<KeyframesRule>::as_arc(&rule).read_with(&guard)
@ -1909,8 +1934,10 @@ pub extern "C" fn Servo_KeyframesRule_GetKeyframeAt(rule: RawServoKeyframesRuleB
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_KeyframesRule_FindRule(rule: RawServoKeyframesRuleBorrowed, pub extern "C" fn Servo_KeyframesRule_FindRule(
key: *const nsACString) -> u32 { rule: RawServoKeyframesRuleBorrowed,
key: *const nsACString,
) -> u32 {
let key = unsafe { key.as_ref().unwrap().as_str_unchecked() }; let key = unsafe { key.as_ref().unwrap().as_str_unchecked() };
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read(); let guard = global_style_data.shared_lock.read();
@ -1974,8 +2001,10 @@ pub extern "C" fn Servo_PageRule_GetStyle(rule: RawServoPageRuleBorrowed) -> Raw
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_PageRule_SetStyle(rule: RawServoPageRuleBorrowed, pub extern "C" fn Servo_PageRule_SetStyle(
declarations: RawServoDeclarationBlockBorrowed) { rule: RawServoPageRuleBorrowed,
declarations: RawServoDeclarationBlockBorrowed,
) {
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations); let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
write_locked_arc(rule, |rule: &mut PageRule| { write_locked_arc(rule, |rule: &mut PageRule| {
rule.block = declarations.clone_arc(); rule.block = declarations.clone_arc();
@ -1983,32 +2012,40 @@ pub extern "C" fn Servo_PageRule_SetStyle(rule: RawServoPageRuleBorrowed,
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_SupportsRule_GetConditionText(rule: RawServoSupportsRuleBorrowed, pub extern "C" fn Servo_SupportsRule_GetConditionText(
result: *mut nsAString) { rule: RawServoSupportsRuleBorrowed,
result: *mut nsAString,
) {
read_locked_arc(rule, |rule: &SupportsRule| { read_locked_arc(rule, |rule: &SupportsRule| {
rule.condition.to_css(&mut CssWriter::new(unsafe { result.as_mut().unwrap() })).unwrap(); rule.condition.to_css(&mut CssWriter::new(unsafe { result.as_mut().unwrap() })).unwrap();
}) })
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_DocumentRule_GetConditionText(rule: RawServoDocumentRuleBorrowed, pub extern "C" fn Servo_DocumentRule_GetConditionText(
result: *mut nsAString) { rule: RawServoDocumentRuleBorrowed,
result: *mut nsAString,
) {
read_locked_arc(rule, |rule: &DocumentRule| { read_locked_arc(rule, |rule: &DocumentRule| {
rule.condition.to_css(&mut CssWriter::new(unsafe { result.as_mut().unwrap() })).unwrap(); rule.condition.to_css(&mut CssWriter::new(unsafe { result.as_mut().unwrap() })).unwrap();
}) })
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_FontFeatureValuesRule_GetFontFamily(rule: RawServoFontFeatureValuesRuleBorrowed, pub extern "C" fn Servo_FontFeatureValuesRule_GetFontFamily(
result: *mut nsAString) { rule: RawServoFontFeatureValuesRuleBorrowed,
result: *mut nsAString,
) {
read_locked_arc(rule, |rule: &FontFeatureValuesRule| { read_locked_arc(rule, |rule: &FontFeatureValuesRule| {
rule.font_family_to_css(&mut CssWriter::new(unsafe { result.as_mut().unwrap() })).unwrap(); rule.font_family_to_css(&mut CssWriter::new(unsafe { result.as_mut().unwrap() })).unwrap();
}) })
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_FontFeatureValuesRule_GetValueText(rule: RawServoFontFeatureValuesRuleBorrowed, pub extern "C" fn Servo_FontFeatureValuesRule_GetValueText(
result: *mut nsAString) { rule: RawServoFontFeatureValuesRuleBorrowed,
result: *mut nsAString,
) {
read_locked_arc(rule, |rule: &FontFeatureValuesRule| { read_locked_arc(rule, |rule: &FontFeatureValuesRule| {
rule.value_to_css(&mut CssWriter::new(unsafe { result.as_mut().unwrap() })).unwrap(); rule.value_to_css(&mut CssWriter::new(unsafe { result.as_mut().unwrap() })).unwrap();
}) })
@ -2070,13 +2107,13 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed, pub extern "C" fn Servo_ResolvePseudoStyle(
pseudo_type: CSSPseudoElementType, element: RawGeckoElementBorrowed,
is_probe: bool, pseudo_type: CSSPseudoElementType,
inherited_style: ServoStyleContextBorrowedOrNull, is_probe: bool,
raw_data: RawServoStyleSetBorrowed) inherited_style: ServoStyleContextBorrowedOrNull,
-> ServoStyleContextStrong raw_data: RawServoStyleSetBorrowed,
{ ) -> ServoStyleContextStrong {
let element = GeckoElement(element); let element = GeckoElement(element);
let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow(); let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
@ -2191,9 +2228,10 @@ pub extern "C" fn Servo_ComputedValues_ResolveXULTreePseudoStyle(
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_SetExplicitStyle(element: RawGeckoElementBorrowed, pub extern "C" fn Servo_SetExplicitStyle(
style: ServoStyleContextBorrowed) element: RawGeckoElementBorrowed,
{ style: ServoStyleContextBorrowed,
) {
let element = GeckoElement(element); let element = GeckoElement(element);
debug!("Servo_SetExplicitStyle: {:?}", element); debug!("Servo_SetExplicitStyle: {:?}", element);
// We only support this API for initial styling. There's no reason it couldn't // We only support this API for initial styling. There's no reason it couldn't
@ -2204,13 +2242,13 @@ pub extern "C" fn Servo_SetExplicitStyle(element: RawGeckoElementBorrowed,
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_HasAuthorSpecifiedRules(style: ServoStyleContextBorrowed, pub extern "C" fn Servo_HasAuthorSpecifiedRules(
element: RawGeckoElementBorrowed, style: ServoStyleContextBorrowed,
pseudo_type: CSSPseudoElementType, element: RawGeckoElementBorrowed,
rule_type_mask: u32, pseudo_type: CSSPseudoElementType,
author_colors_allowed: bool) rule_type_mask: u32,
-> bool author_colors_allowed: bool,
{ ) -> bool {
let element = GeckoElement(element); let element = GeckoElement(element);
let pseudo = PseudoElement::from_pseudo_type(pseudo_type); let pseudo = PseudoElement::from_pseudo_type(pseudo_type);
@ -2379,8 +2417,9 @@ pub extern "C" fn Servo_ComputedValues_GetStyleBits(values: ServoStyleContextBor
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_ComputedValues_SpecifiesAnimationsOrTransitions(values: ServoStyleContextBorrowed) pub extern "C" fn Servo_ComputedValues_SpecifiesAnimationsOrTransitions(
-> bool { values: ServoStyleContextBorrowed,
) -> bool {
let b = values.get_box(); let b = values.get_box();
b.specifies_animations() || b.specifies_transitions() b.specifies_animations() || b.specifies_transitions()
} }
@ -2433,8 +2472,9 @@ pub extern "C" fn Servo_ComputedValues_GetStyleRuleList(
/// the pres context (hint: the context outlives the StyleSet, that holds the /// the pres context (hint: the context outlives the StyleSet, that holds the
/// device alive). /// device alive).
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_StyleSet_Init(pres_context: RawGeckoPresContextOwned) pub extern "C" fn Servo_StyleSet_Init(
-> *mut RawServoStyleSet { pres_context: RawGeckoPresContextOwned,
) -> *mut RawServoStyleSet {
let data = Box::new(PerDocumentStyleData::new(pres_context)); let data = Box::new(PerDocumentStyleData::new(pres_context));
Box::into_raw(data) as *mut RawServoStyleSet Box::into_raw(data) as *mut RawServoStyleSet
} }
@ -2546,9 +2586,11 @@ pub extern "C" fn Servo_ParseEasing(
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_GetProperties_Overriding_Animation(element: RawGeckoElementBorrowed, pub extern "C" fn Servo_GetProperties_Overriding_Animation(
list: RawGeckoCSSPropertyIDListBorrowed, element: RawGeckoElementBorrowed,
set: nsCSSPropertyIDSetBorrowedMut) { list: RawGeckoCSSPropertyIDListBorrowed,
set: nsCSSPropertyIDSetBorrowedMut,
) {
let element = GeckoElement(element); let element = GeckoElement(element);
let element_data = match element.borrow_data() { let element_data = match element.borrow_data() {
Some(data) => data, Some(data) => data,
@ -2631,8 +2673,9 @@ pub extern "C" fn Servo_DeclarationBlock_CreateEmpty() -> RawServoDeclarationBlo
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_Clone(declarations: RawServoDeclarationBlockBorrowed) pub extern "C" fn Servo_DeclarationBlock_Clone(
-> RawServoDeclarationBlockStrong { declarations: RawServoDeclarationBlockBorrowed,
) -> RawServoDeclarationBlockStrong {
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read(); let guard = global_style_data.shared_lock.read();
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations); let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
@ -3042,10 +3085,10 @@ macro_rules! match_wrap_declared {
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_PropertyIsSet(declarations: pub extern "C" fn Servo_DeclarationBlock_PropertyIsSet(
RawServoDeclarationBlockBorrowed, declarations: RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID) property: nsCSSPropertyID,
-> bool { ) -> bool {
read_locked_arc(declarations, |decls: &PropertyDeclarationBlock| { read_locked_arc(declarations, |decls: &PropertyDeclarationBlock| {
decls.contains(get_longhand_from_id!(property)) decls.contains(get_longhand_from_id!(property))
}) })
@ -3477,7 +3520,7 @@ pub extern "C" fn Servo_NoteExplicitHints(
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_TakeChangeHint( pub extern "C" fn Servo_TakeChangeHint(
element: RawGeckoElementBorrowed, element: RawGeckoElementBorrowed,
was_restyled: *mut bool was_restyled: *mut bool,
) -> u32 { ) -> u32 {
let was_restyled = unsafe { was_restyled.as_mut().unwrap() }; let was_restyled = unsafe { was_restyled.as_mut().unwrap() };
let element = GeckoElement(element); let element = GeckoElement(element);
@ -3526,7 +3569,7 @@ pub extern "C" fn Servo_ResolveStyleLazily(
rule_inclusion: StyleRuleInclusion, rule_inclusion: StyleRuleInclusion,
snapshots: *const ServoElementSnapshotTable, snapshots: *const ServoElementSnapshotTable,
raw_data: RawServoStyleSetBorrowed, raw_data: RawServoStyleSetBorrowed,
ignore_existing_styles: bool ignore_existing_styles: bool,
) -> ServoStyleContextStrong { ) -> ServoStyleContextStrong {
debug_assert!(!snapshots.is_null()); debug_assert!(!snapshots.is_null());
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;