Backed out changeset ce926ee22c80 (bug 1833466) for causing build bustages @ layout...
[gecko.git] / layout / style / ServoBindings.h
blob52538cafb8e3d51dda39219b9dda55e35fb8cfe0
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* FFI functions for Gecko to call into Servo */
9 #ifndef mozilla_ServoBindings_h
10 #define mozilla_ServoBindings_h
12 #include "mozilla/ServoStyleConsts.h"
14 // These functions are defined via macros in Rust, so cbindgen doesn't see them.
16 namespace mozilla {
18 // The clang we use on windows complains about returning StyleStrong<> and
19 // StyleOwned<>, since the template parameters are incomplete.
21 // But they only contain pointers so it is ok. Also, this warning hilariously
22 // doesn't exist in GCC.
24 // A solution for this is to explicitly instantiate the template, but duplicate
25 // instantiations are an error.
27 // https://github.com/eqrion/cbindgen/issues/402 tracks an improvement to
28 // cbindgen that would allow it to autogenerate the template instantiations on
29 // its own.
30 #pragma GCC diagnostic push
31 #ifdef __clang__
32 # pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
33 #endif
35 extern "C" {
37 #define BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX(type_, prefix_) \
38 void Servo_##type_##_Debug(const mozilla::Style##prefix_##type_*, \
39 nsACString* result); \
40 void Servo_##type_##_GetCssText(const mozilla::Style##prefix_##type_*, \
41 nsACString* result);
43 #define BASIC_RULE_FUNCS_WITHOUT_GETTER_LOCKED(type_) \
44 BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX(type_, Locked)
45 #define BASIC_RULE_FUNCS_WITHOUT_GETTER_UNLOCKED(type_) \
46 BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX(type_, )
48 #define BASIC_RULE_FUNCS_WITH_PREFIX(type_, prefix_) \
49 StyleStrong<mozilla::Style##prefix_##type_##Rule> \
50 Servo_CssRules_Get##type_##RuleAt(const StyleLockedCssRules* rules, \
51 uint32_t index, uint32_t* line, \
52 uint32_t* column); \
53 void Servo_StyleSet_##type_##RuleChanged( \
54 const StylePerDocumentStyleData*, const Style##prefix_##type_##Rule*, \
55 const StyleDomStyleSheet*, StyleRuleChangeKind); \
56 BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX(type_##Rule, prefix_)
58 #define BASIC_RULE_FUNCS_LOCKED(type_) \
59 BASIC_RULE_FUNCS_WITH_PREFIX(type_, Locked)
61 #define BASIC_RULE_FUNCS_UNLOCKED(type_) BASIC_RULE_FUNCS_WITH_PREFIX(type_, )
63 #define GROUP_RULE_FUNCS_WITH_PREFIX(type_, prefix_) \
64 BASIC_RULE_FUNCS_WITH_PREFIX(type_, prefix_) \
65 StyleStrong<mozilla::StyleLockedCssRules> Servo_##type_##Rule_GetRules( \
66 const mozilla::Style##prefix_##type_##Rule* rule);
68 #define GROUP_RULE_FUNCS_LOCKED(type_) \
69 GROUP_RULE_FUNCS_WITH_PREFIX(type_, Locked)
71 #define GROUP_RULE_FUNCS_UNLOCKED(type_) GROUP_RULE_FUNCS_WITH_PREFIX(type_, )
73 BASIC_RULE_FUNCS_LOCKED(Style)
74 BASIC_RULE_FUNCS_LOCKED(Import)
75 BASIC_RULE_FUNCS_WITHOUT_GETTER_LOCKED(Keyframe)
76 BASIC_RULE_FUNCS_LOCKED(Keyframes)
77 GROUP_RULE_FUNCS_UNLOCKED(Media)
78 GROUP_RULE_FUNCS_UNLOCKED(Document)
79 BASIC_RULE_FUNCS_UNLOCKED(Namespace)
80 GROUP_RULE_FUNCS_LOCKED(Page)
81 BASIC_RULE_FUNCS_UNLOCKED(Property)
82 GROUP_RULE_FUNCS_UNLOCKED(Supports)
83 GROUP_RULE_FUNCS_UNLOCKED(LayerBlock)
84 BASIC_RULE_FUNCS_UNLOCKED(LayerStatement)
85 BASIC_RULE_FUNCS_UNLOCKED(FontFeatureValues)
86 BASIC_RULE_FUNCS_UNLOCKED(FontPaletteValues)
87 BASIC_RULE_FUNCS_LOCKED(FontFace)
88 BASIC_RULE_FUNCS_LOCKED(CounterStyle)
89 GROUP_RULE_FUNCS_UNLOCKED(Container)
90 GROUP_RULE_FUNCS_UNLOCKED(Scope)
91 GROUP_RULE_FUNCS_UNLOCKED(StartingStyle)
93 #undef GROUP_RULE_FUNCS_LOCKED
94 #undef GROUP_RULE_FUNCS_UNLOCKED
95 #undef GROUP_RULE_FUNCS_WITH_PREFIX
96 #undef BASIC_RULE_FUNCS_LOCKED
97 #undef BASIC_RULE_FUNCS_UNLOCKED
98 #undef BASIC_RULE_FUNCS_WITH_PREFIX
99 #undef BASIC_RULE_FUNCS_WITHOUT_GETTER_LOCKED
100 #undef BASIC_RULE_FUNCS_WITHOUT_GETTER_UNLOCKED
101 #undef BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX
103 #define BASIC_SERDE_FUNCS(type_) \
104 bool Servo_##type_##_Deserialize(mozilla::ipc::ByteBuf* input, type_* v); \
105 bool Servo_##type_##_Serialize(const type_* v, mozilla::ipc::ByteBuf* output);
107 BASIC_SERDE_FUNCS(LengthPercentage)
108 BASIC_SERDE_FUNCS(StyleRotate)
109 BASIC_SERDE_FUNCS(StyleScale)
110 BASIC_SERDE_FUNCS(StyleTranslate)
111 BASIC_SERDE_FUNCS(StyleTransform)
112 BASIC_SERDE_FUNCS(StyleOffsetPath)
113 BASIC_SERDE_FUNCS(StyleOffsetRotate)
114 BASIC_SERDE_FUNCS(StylePositionOrAuto)
115 BASIC_SERDE_FUNCS(StyleOffsetPosition)
116 BASIC_SERDE_FUNCS(StyleComputedTimingFunction)
118 #undef BASIC_SERDE_FUNCS
120 void Servo_CounterStyleRule_GetDescriptorCssText(
121 const StyleLockedCounterStyleRule* rule, nsCSSCounterDesc desc,
122 nsACString* result);
124 bool Servo_CounterStyleRule_SetDescriptor(
125 const StyleLockedCounterStyleRule* rule, nsCSSCounterDesc desc,
126 const nsACString* value);
128 } // extern "C"
130 #pragma GCC diagnostic pop
132 } // namespace mozilla
134 #endif // mozilla_ServoBindings_h