File: ServoBindings.h

package info (click to toggle)
firefox 141.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,550,588 kB
  • sloc: cpp: 7,426,506; javascript: 6,367,238; ansic: 3,707,351; python: 1,369,002; xml: 623,983; asm: 426,918; java: 184,324; sh: 64,488; makefile: 19,203; objc: 13,059; perl: 12,955; yacc: 4,583; cs: 3,846; pascal: 3,352; lex: 1,720; ruby: 1,071; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10
file content (120 lines) | stat: -rw-r--r-- 4,701 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* FFI functions for Gecko to call into Servo */

#ifndef mozilla_ServoBindings_h
#define mozilla_ServoBindings_h

#include "mozilla/ServoStyleConsts.h"

// These functions are defined via macros in Rust, so cbindgen doesn't see them.

namespace mozilla {

// The clang we use on windows complains about returning StyleStrong<> and
// StyleOwned<>, since the template parameters are incomplete.
//
// But they only contain pointers so it is ok. Also, this warning hilariously
// doesn't exist in GCC.
//
// A solution for this is to explicitly instantiate the template, but duplicate
// instantiations are an error.
//
// https://github.com/eqrion/cbindgen/issues/402 tracks an improvement to
// cbindgen that would allow it to autogenerate the template instantiations on
// its own.
#pragma GCC diagnostic push
#ifdef __clang__
#  pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
#endif

extern "C" {

#define BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX(type_, prefix_)      \
  void Servo_##type_##_Debug(const mozilla::Style##prefix_##type_*,      \
                             nsACString* result);                        \
  void Servo_##type_##_GetCssText(const mozilla::Style##prefix_##type_*, \
                                  nsACString* result);

#define BASIC_RULE_FUNCS_WITHOUT_GETTER_LOCKED(type_) \
  BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX(type_, Locked)
#define BASIC_RULE_FUNCS_WITHOUT_GETTER_UNLOCKED(type_) \
  BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX(type_, )

#define BASIC_RULE_FUNCS_WITH_PREFIX(type_, prefix_)                        \
  StyleStrong<mozilla::Style##prefix_##type_##Rule>                         \
      Servo_CssRules_Get##type_##RuleAt(const StyleLockedCssRules* rules,   \
                                        uint32_t index, uint32_t* line,     \
                                        uint32_t* column);                  \
  void Servo_StyleSet_##type_##RuleChanged(                                 \
      const StylePerDocumentStyleData*, const Style##prefix_##type_##Rule*, \
      const StyleDomStyleSheet*, StyleRuleChangeKind);                      \
  BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX(type_##Rule, prefix_)

#define BASIC_RULE_FUNCS_LOCKED(type_) \
  BASIC_RULE_FUNCS_WITH_PREFIX(type_, Locked)

#define BASIC_RULE_FUNCS_UNLOCKED(type_) BASIC_RULE_FUNCS_WITH_PREFIX(type_, )

#define GROUP_RULE_FUNCS_WITH_PREFIX(type_, prefix_)                      \
  BASIC_RULE_FUNCS_WITH_PREFIX(type_, prefix_)                            \
  StyleStrong<mozilla::StyleLockedCssRules> Servo_##type_##Rule_GetRules( \
      const mozilla::Style##prefix_##type_##Rule* rule);

#define GROUP_RULE_FUNCS_LOCKED(type_) \
  GROUP_RULE_FUNCS_WITH_PREFIX(type_, Locked)

#define GROUP_RULE_FUNCS_UNLOCKED(type_) GROUP_RULE_FUNCS_WITH_PREFIX(type_, )

BASIC_RULE_FUNCS_LOCKED(Style)
BASIC_RULE_FUNCS_LOCKED(Import)
BASIC_RULE_FUNCS_WITHOUT_GETTER_LOCKED(Keyframe)
BASIC_RULE_FUNCS_LOCKED(Keyframes)
GROUP_RULE_FUNCS_UNLOCKED(Media)
GROUP_RULE_FUNCS_UNLOCKED(Document)
BASIC_RULE_FUNCS_UNLOCKED(Namespace)
BASIC_RULE_FUNCS_UNLOCKED(Margin)
GROUP_RULE_FUNCS_LOCKED(Page)
BASIC_RULE_FUNCS_UNLOCKED(Property)
GROUP_RULE_FUNCS_UNLOCKED(Supports)
GROUP_RULE_FUNCS_UNLOCKED(LayerBlock)
BASIC_RULE_FUNCS_UNLOCKED(LayerStatement)
BASIC_RULE_FUNCS_UNLOCKED(FontFeatureValues)
BASIC_RULE_FUNCS_UNLOCKED(FontPaletteValues)
BASIC_RULE_FUNCS_LOCKED(FontFace)
BASIC_RULE_FUNCS_LOCKED(CounterStyle)
GROUP_RULE_FUNCS_UNLOCKED(Container)
GROUP_RULE_FUNCS_UNLOCKED(Scope)
GROUP_RULE_FUNCS_UNLOCKED(StartingStyle)
BASIC_RULE_FUNCS_LOCKED(PositionTry)
BASIC_RULE_FUNCS_LOCKED(NestedDeclarations)

#undef GROUP_RULE_FUNCS_LOCKED
#undef GROUP_RULE_FUNCS_UNLOCKED
#undef GROUP_RULE_FUNCS_WITH_PREFIX
#undef BASIC_RULE_FUNCS_LOCKED
#undef BASIC_RULE_FUNCS_UNLOCKED
#undef BASIC_RULE_FUNCS_WITH_PREFIX
#undef BASIC_RULE_FUNCS_WITHOUT_GETTER_LOCKED
#undef BASIC_RULE_FUNCS_WITHOUT_GETTER_UNLOCKED
#undef BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX

void Servo_CounterStyleRule_GetDescriptorCssText(
    const StyleLockedCounterStyleRule* rule, nsCSSCounterDesc desc,
    nsACString* result);

bool Servo_CounterStyleRule_SetDescriptor(
    const StyleLockedCounterStyleRule* rule, nsCSSCounterDesc desc,
    const nsACString* value);

}  // extern "C"

#pragma GCC diagnostic pop

}  // namespace mozilla

#endif  // mozilla_ServoBindings_h