ServoBindings.h (4818B)
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/. */ 6 7 /* FFI functions for Gecko to call into Servo */ 8 9 #ifndef mozilla_ServoBindings_h 10 #define mozilla_ServoBindings_h 11 12 #include "mozilla/ServoStyleConsts.h" 13 14 // These functions are defined via macros in Rust, so cbindgen doesn't see them. 15 16 namespace mozilla { 17 18 // The clang we use on windows complains about returning StyleStrong<> and 19 // StyleOwned<>, since the template parameters are incomplete. 20 // 21 // But they only contain pointers so it is ok. Also, this warning hilariously 22 // doesn't exist in GCC. 23 // 24 // A solution for this is to explicitly instantiate the template, but duplicate 25 // instantiations are an error. 26 // 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 34 35 extern "C" { 36 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); 42 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_, ) 47 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 const nsTArray<StyleCssRuleRef>*); \ 57 BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX(type_##Rule, prefix_) 58 59 #define BASIC_RULE_FUNCS_LOCKED(type_) \ 60 BASIC_RULE_FUNCS_WITH_PREFIX(type_, Locked) 61 62 #define BASIC_RULE_FUNCS_UNLOCKED(type_) BASIC_RULE_FUNCS_WITH_PREFIX(type_, ) 63 64 #define GROUP_RULE_FUNCS_WITH_PREFIX(type_, prefix_) \ 65 BASIC_RULE_FUNCS_WITH_PREFIX(type_, prefix_) \ 66 StyleStrong<mozilla::StyleLockedCssRules> Servo_##type_##Rule_GetRules( \ 67 const mozilla::Style##prefix_##type_##Rule* rule); 68 69 #define GROUP_RULE_FUNCS_LOCKED(type_) \ 70 GROUP_RULE_FUNCS_WITH_PREFIX(type_, Locked) 71 72 #define GROUP_RULE_FUNCS_UNLOCKED(type_) GROUP_RULE_FUNCS_WITH_PREFIX(type_, ) 73 74 BASIC_RULE_FUNCS_LOCKED(Style) 75 BASIC_RULE_FUNCS_LOCKED(Import) 76 BASIC_RULE_FUNCS_WITHOUT_GETTER_LOCKED(Keyframe) 77 BASIC_RULE_FUNCS_LOCKED(Keyframes) 78 GROUP_RULE_FUNCS_UNLOCKED(Media) 79 GROUP_RULE_FUNCS_UNLOCKED(Document) 80 BASIC_RULE_FUNCS_UNLOCKED(Namespace) 81 BASIC_RULE_FUNCS_UNLOCKED(Margin) 82 BASIC_RULE_FUNCS_UNLOCKED(CustomMedia) 83 GROUP_RULE_FUNCS_LOCKED(Page) 84 BASIC_RULE_FUNCS_UNLOCKED(Property) 85 GROUP_RULE_FUNCS_UNLOCKED(Supports) 86 GROUP_RULE_FUNCS_UNLOCKED(LayerBlock) 87 BASIC_RULE_FUNCS_UNLOCKED(LayerStatement) 88 BASIC_RULE_FUNCS_UNLOCKED(FontFeatureValues) 89 BASIC_RULE_FUNCS_UNLOCKED(FontPaletteValues) 90 BASIC_RULE_FUNCS_LOCKED(FontFace) 91 BASIC_RULE_FUNCS_LOCKED(CounterStyle) 92 GROUP_RULE_FUNCS_UNLOCKED(Container) 93 GROUP_RULE_FUNCS_UNLOCKED(Scope) 94 GROUP_RULE_FUNCS_UNLOCKED(StartingStyle) 95 BASIC_RULE_FUNCS_LOCKED(PositionTry) 96 BASIC_RULE_FUNCS_LOCKED(NestedDeclarations) 97 98 #undef GROUP_RULE_FUNCS_LOCKED 99 #undef GROUP_RULE_FUNCS_UNLOCKED 100 #undef GROUP_RULE_FUNCS_WITH_PREFIX 101 #undef BASIC_RULE_FUNCS_LOCKED 102 #undef BASIC_RULE_FUNCS_UNLOCKED 103 #undef BASIC_RULE_FUNCS_WITH_PREFIX 104 #undef BASIC_RULE_FUNCS_WITHOUT_GETTER_LOCKED 105 #undef BASIC_RULE_FUNCS_WITHOUT_GETTER_UNLOCKED 106 #undef BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX 107 108 void Servo_CounterStyleRule_GetDescriptorCssText( 109 const StyleLockedCounterStyleRule* rule, nsCSSCounterDesc desc, 110 nsACString* result); 111 112 bool Servo_CounterStyleRule_SetDescriptor( 113 const StyleLockedCounterStyleRule* rule, nsCSSCounterDesc desc, 114 const nsACString* value); 115 116 } // extern "C" 117 118 #pragma GCC diagnostic pop 119 120 } // namespace mozilla 121 122 #endif // mozilla_ServoBindings_h