1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
5 //! This file lists all arc FFI types and defines corresponding addref and release functions. This
6 //! list loosely corresponds to ServoLockedArcTypeList.h file in Gecko.
8 #![allow(non_snake_case, missing_docs)]
10 use crate::gecko::url::CssUrlData;
11 use crate::media_queries::MediaList;
12 use crate::properties::animated_properties::AnimationValue;
13 use crate::properties::{ComputedValues, PropertyDeclarationBlock};
14 use crate::shared_lock::Locked;
15 use crate::stylesheets::keyframes_rule::Keyframe;
16 use crate::stylesheets::{
17 ContainerRule, CounterStyleRule, CssRules, DocumentRule, FontFaceRule, FontFeatureValuesRule,
18 FontPaletteValuesRule, ImportRule, KeyframesRule, LayerBlockRule, LayerStatementRule,
19 MarginRule, MediaRule, NamespaceRule, PageRule, PropertyRule, ScopeRule, StartingStyleRule,
20 StyleRule, StylesheetContents, SupportsRule,
24 macro_rules! impl_simple_arc_ffi {
25 ($ty:ty, $addref:ident, $release:ident) => {
27 pub unsafe extern "C" fn $addref(obj: *const $ty) {
28 std::mem::forget(Arc::from_raw_addrefed(obj));
32 pub unsafe extern "C" fn $release(obj: *const $ty) {
33 let _ = Arc::from_raw(obj);
38 macro_rules! impl_locked_arc_ffi {
39 ($servo_type:ty, $alias:ident, $addref:ident, $release:ident) => {
40 /// A simple alias for a locked type.
41 pub type $alias = Locked<$servo_type>;
42 impl_simple_arc_ffi!($alias, $addref, $release);
49 Servo_CssRules_AddRef,
50 Servo_CssRules_Release
53 PropertyDeclarationBlock,
54 LockedDeclarationBlock,
55 Servo_DeclarationBlock_AddRef,
56 Servo_DeclarationBlock_Release
61 Servo_StyleRule_AddRef,
62 Servo_StyleRule_Release
67 Servo_ImportRule_AddRef,
68 Servo_ImportRule_Release
73 Servo_Keyframe_AddRef,
74 Servo_Keyframe_Release
79 Servo_KeyframesRule_AddRef,
80 Servo_KeyframesRule_Release
84 Servo_LayerBlockRule_AddRef,
85 Servo_LayerBlockRule_Release
89 Servo_LayerStatementRule_AddRef,
90 Servo_LayerStatementRule_Release
95 Servo_MediaList_AddRef,
96 Servo_MediaList_Release
98 impl_simple_arc_ffi!(MediaRule, Servo_MediaRule_AddRef, Servo_MediaRule_Release);
101 Servo_NamespaceRule_AddRef,
102 Servo_NamespaceRule_Release
104 impl_simple_arc_ffi!(
106 Servo_MarginRule_AddRef,
107 Servo_MarginRule_Release
109 impl_locked_arc_ffi!(
112 Servo_PageRule_AddRef,
113 Servo_PageRule_Release
115 impl_simple_arc_ffi!(
117 Servo_PropertyRule_AddRef,
118 Servo_PropertyRule_Release
120 impl_simple_arc_ffi!(
122 Servo_SupportsRule_AddRef,
123 Servo_SupportsRule_Release
125 impl_simple_arc_ffi!(
127 Servo_ContainerRule_AddRef,
128 Servo_ContainerRule_Release
130 impl_simple_arc_ffi!(
132 Servo_DocumentRule_AddRef,
133 Servo_DocumentRule_Release
135 impl_simple_arc_ffi!(
136 FontFeatureValuesRule,
137 Servo_FontFeatureValuesRule_AddRef,
138 Servo_FontFeatureValuesRule_Release
140 impl_simple_arc_ffi!(
141 FontPaletteValuesRule,
142 Servo_FontPaletteValuesRule_AddRef,
143 Servo_FontPaletteValuesRule_Release
145 impl_locked_arc_ffi!(
148 Servo_FontFaceRule_AddRef,
149 Servo_FontFaceRule_Release
151 impl_locked_arc_ffi!(
153 LockedCounterStyleRule,
154 Servo_CounterStyleRule_AddRef,
155 Servo_CounterStyleRule_Release
158 impl_simple_arc_ffi!(
160 Servo_StyleSheetContents_AddRef,
161 Servo_StyleSheetContents_Release
163 impl_simple_arc_ffi!(
165 Servo_CssUrlData_AddRef,
166 Servo_CssUrlData_Release
168 impl_simple_arc_ffi!(
170 Servo_ComputedStyle_AddRef,
171 Servo_ComputedStyle_Release
173 impl_simple_arc_ffi!(
175 Servo_AnimationValue_AddRef,
176 Servo_AnimationValue_Release
178 impl_simple_arc_ffi!(ScopeRule, Servo_ScopeRule_AddRef, Servo_ScopeRule_Release);
179 impl_simple_arc_ffi!(
181 Servo_StartingStyleRule_AddRef,
182 Servo_StartingStyleRule_Release