Bug 1833466 - Implement CSSMarginRule and the corresponding DOM API. r=webidl,firefox...
[gecko.git] / servo / components / style / gecko / arc_types.rs
blob259d9f1570a07cd624fb1865916a6a24b10551bb
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,
22 use servo_arc::Arc;
24 macro_rules! impl_simple_arc_ffi {
25     ($ty:ty, $addref:ident, $release:ident) => {
26         #[no_mangle]
27         pub unsafe extern "C" fn $addref(obj: *const $ty) {
28             std::mem::forget(Arc::from_raw_addrefed(obj));
29         }
31         #[no_mangle]
32         pub unsafe extern "C" fn $release(obj: *const $ty) {
33             let _ = Arc::from_raw(obj);
34         }
35     };
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);
43     };
46 impl_locked_arc_ffi!(
47     CssRules,
48     LockedCssRules,
49     Servo_CssRules_AddRef,
50     Servo_CssRules_Release
52 impl_locked_arc_ffi!(
53     PropertyDeclarationBlock,
54     LockedDeclarationBlock,
55     Servo_DeclarationBlock_AddRef,
56     Servo_DeclarationBlock_Release
58 impl_locked_arc_ffi!(
59     StyleRule,
60     LockedStyleRule,
61     Servo_StyleRule_AddRef,
62     Servo_StyleRule_Release
64 impl_locked_arc_ffi!(
65     ImportRule,
66     LockedImportRule,
67     Servo_ImportRule_AddRef,
68     Servo_ImportRule_Release
70 impl_locked_arc_ffi!(
71     Keyframe,
72     LockedKeyframe,
73     Servo_Keyframe_AddRef,
74     Servo_Keyframe_Release
76 impl_locked_arc_ffi!(
77     KeyframesRule,
78     LockedKeyframesRule,
79     Servo_KeyframesRule_AddRef,
80     Servo_KeyframesRule_Release
82 impl_simple_arc_ffi!(
83     LayerBlockRule,
84     Servo_LayerBlockRule_AddRef,
85     Servo_LayerBlockRule_Release
87 impl_simple_arc_ffi!(
88     LayerStatementRule,
89     Servo_LayerStatementRule_AddRef,
90     Servo_LayerStatementRule_Release
92 impl_locked_arc_ffi!(
93     MediaList,
94     LockedMediaList,
95     Servo_MediaList_AddRef,
96     Servo_MediaList_Release
98 impl_simple_arc_ffi!(MediaRule, Servo_MediaRule_AddRef, Servo_MediaRule_Release);
99 impl_simple_arc_ffi!(
100     NamespaceRule,
101     Servo_NamespaceRule_AddRef,
102     Servo_NamespaceRule_Release
104 impl_simple_arc_ffi!(
105     MarginRule,
106     Servo_MarginRule_AddRef,
107     Servo_MarginRule_Release
109 impl_locked_arc_ffi!(
110     PageRule,
111     LockedPageRule,
112     Servo_PageRule_AddRef,
113     Servo_PageRule_Release
115 impl_simple_arc_ffi!(
116     PropertyRule,
117     Servo_PropertyRule_AddRef,
118     Servo_PropertyRule_Release
120 impl_simple_arc_ffi!(
121     SupportsRule,
122     Servo_SupportsRule_AddRef,
123     Servo_SupportsRule_Release
125 impl_simple_arc_ffi!(
126     ContainerRule,
127     Servo_ContainerRule_AddRef,
128     Servo_ContainerRule_Release
130 impl_simple_arc_ffi!(
131     DocumentRule,
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!(
146     FontFaceRule,
147     LockedFontFaceRule,
148     Servo_FontFaceRule_AddRef,
149     Servo_FontFaceRule_Release
151 impl_locked_arc_ffi!(
152     CounterStyleRule,
153     LockedCounterStyleRule,
154     Servo_CounterStyleRule_AddRef,
155     Servo_CounterStyleRule_Release
158 impl_simple_arc_ffi!(
159     StylesheetContents,
160     Servo_StyleSheetContents_AddRef,
161     Servo_StyleSheetContents_Release
163 impl_simple_arc_ffi!(
164     CssUrlData,
165     Servo_CssUrlData_AddRef,
166     Servo_CssUrlData_Release
168 impl_simple_arc_ffi!(
169     ComputedValues,
170     Servo_ComputedStyle_AddRef,
171     Servo_ComputedStyle_Release
173 impl_simple_arc_ffi!(
174     AnimationValue,
175     Servo_AnimationValue_AddRef,
176     Servo_AnimationValue_Release
178 impl_simple_arc_ffi!(
179     ScopeRule,
180     Servo_ScopeRule_AddRef,
181     Servo_ScopeRule_Release
183 impl_simple_arc_ffi!(
184     StartingStyleRule,
185     Servo_StartingStyleRule_AddRef,
186     Servo_StartingStyleRule_Release