Line data Source code
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 : #ifndef mozilla_ServoBindings_h
8 : #define mozilla_ServoBindings_h
9 :
10 : #include <stdint.h>
11 :
12 : #include "mozilla/ServoTypes.h"
13 : #include "mozilla/ServoBindingTypes.h"
14 : #include "mozilla/ServoElementSnapshot.h"
15 : #include "mozilla/css/SheetParsingMode.h"
16 : #include "mozilla/css/URLMatchingFunction.h"
17 : #include "mozilla/EffectCompositor.h"
18 : #include "mozilla/ComputedTimingFunction.h"
19 : #include "nsChangeHint.h"
20 : #include "nsCSSPseudoClasses.h"
21 : #include "nsIDocument.h"
22 : #include "nsStyleStruct.h"
23 :
24 : /*
25 : * API for Servo to access Gecko data structures. This file must compile as valid
26 : * C code in order for the binding generator to parse it.
27 : *
28 : * Functions beginning with Gecko_ are implemented in Gecko and invoked from Servo.
29 : * Functions beginning with Servo_ are implemented in Servo and invoked from Gecko.
30 : */
31 :
32 : class nsIAtom;
33 : class nsIPrincipal;
34 : class nsIURI;
35 : struct nsFont;
36 : namespace mozilla {
37 : class FontFamilyList;
38 : enum FontFamilyType : uint32_t;
39 : enum class CSSPseudoElementType : uint8_t;
40 : struct Keyframe;
41 : enum Side;
42 : struct StyleTransition;
43 : namespace css {
44 : struct URLValue;
45 : struct ImageValue;
46 : class LoaderReusableStyleSheets;
47 : };
48 : namespace dom {
49 : enum class IterationCompositeOperation : uint8_t;
50 : };
51 : enum class UpdateAnimationsTasks : uint8_t;
52 : struct LangGroupFontPrefs;
53 : class ServoStyleSheet;
54 : class ServoElementSnapshotTable;
55 : }
56 : using mozilla::FontFamilyList;
57 : using mozilla::FontFamilyType;
58 : using mozilla::ServoElementSnapshot;
59 : class nsCSSCounterStyleRule;
60 : class nsCSSFontFaceRule;
61 : struct nsMediaFeature;
62 : struct nsStyleList;
63 : struct nsStyleImage;
64 : struct nsStyleGradientStop;
65 : class nsStyleGradient;
66 : class nsStyleCoord;
67 : struct nsStyleDisplay;
68 : class nsXBLBinding;
69 :
70 : #define NS_DECL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \
71 : void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr); \
72 : void Gecko_Release##name_##ArbitraryThread(class_* aPtr);
73 : #define NS_IMPL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \
74 : static_assert(class_::HasThreadSafeRefCnt::value, \
75 : "NS_DECL_THREADSAFE_FFI_REFCOUNTING can only be used with " \
76 : "classes that have thread-safe refcounting"); \
77 : void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr) \
78 : { NS_ADDREF(aPtr); } \
79 : void Gecko_Release##name_##ArbitraryThread(class_* aPtr) \
80 : { NS_RELEASE(aPtr); }
81 :
82 : #define NS_DECL_FFI_REFCOUNTING(class_, name_) \
83 : void Gecko_##name_##_AddRef(class_* aPtr); \
84 : void Gecko_##name_##_Release(class_* aPtr);
85 : #define NS_IMPL_FFI_REFCOUNTING(class_, name_) \
86 : void Gecko_##name_##_AddRef(class_* aPtr) \
87 : { MOZ_ASSERT(NS_IsMainThread()); NS_ADDREF(aPtr); } \
88 : void Gecko_##name_##_Release(class_* aPtr) \
89 : { MOZ_ASSERT(NS_IsMainThread()); NS_RELEASE(aPtr); }
90 :
91 : #define DEFINE_ARRAY_TYPE_FOR(type_) \
92 : struct nsTArrayBorrowed_##type_ { \
93 : nsTArray<type_>* mArray; \
94 : MOZ_IMPLICIT nsTArrayBorrowed_##type_(nsTArray<type_>* aArray) \
95 : : mArray(aArray) {} \
96 : }
97 0 : DEFINE_ARRAY_TYPE_FOR(uintptr_t);
98 : #undef DEFINE_ARRAY_TYPE_FOR
99 :
100 : extern "C" {
101 :
102 : class ServoBundledURI
103 : {
104 : public:
105 : already_AddRefed<mozilla::css::URLValue> IntoCssUrl();
106 : const uint8_t* mURLString;
107 : uint32_t mURLStringLength;
108 : mozilla::URLExtraData* mExtraData;
109 : };
110 :
111 : struct FontSizePrefs
112 : {
113 : void CopyFrom(const mozilla::LangGroupFontPrefs&);
114 : nscoord mDefaultVariableSize;
115 : nscoord mDefaultFixedSize;
116 : nscoord mDefaultSerifSize;
117 : nscoord mDefaultSansSerifSize;
118 : nscoord mDefaultMonospaceSize;
119 : nscoord mDefaultCursiveSize;
120 : nscoord mDefaultFantasySize;
121 : };
122 :
123 : // DOM Traversal.
124 : uint32_t Gecko_ChildrenCount(RawGeckoNodeBorrowed node);
125 : bool Gecko_NodeIsElement(RawGeckoNodeBorrowed node);
126 : bool Gecko_IsInDocument(RawGeckoNodeBorrowed node);
127 : bool Gecko_FlattenedTreeParentIsParent(RawGeckoNodeBorrowed node);
128 : bool Gecko_IsSignificantChild(RawGeckoNodeBorrowed node,
129 : bool text_is_significant,
130 : bool whitespace_is_significant);
131 : RawGeckoNodeBorrowedOrNull Gecko_GetLastChild(RawGeckoNodeBorrowed node);
132 : RawGeckoNodeBorrowedOrNull Gecko_GetFlattenedTreeParentNode(RawGeckoNodeBorrowed node);
133 : RawGeckoElementBorrowedOrNull Gecko_GetBeforeOrAfterPseudo(RawGeckoElementBorrowed element, bool is_before);
134 : nsTArray<nsIContent*>* Gecko_GetAnonymousContentForElement(RawGeckoElementBorrowed element);
135 : void Gecko_DestroyAnonymousContentList(nsTArray<nsIContent*>* anon_content);
136 :
137 : // By default, Servo walks the DOM by traversing the siblings of the DOM-view
138 : // first child. This generally works, but misses anonymous children, which we
139 : // want to traverse during styling. To support these cases, we create an
140 : // optional stack-allocated iterator in aIterator for nodes that need it.
141 : void Gecko_ConstructStyleChildrenIterator(RawGeckoElementBorrowed aElement,
142 : RawGeckoStyleChildrenIteratorBorrowedMut aIterator);
143 : void Gecko_DestroyStyleChildrenIterator(RawGeckoStyleChildrenIteratorBorrowedMut aIterator);
144 : RawGeckoNodeBorrowedOrNull Gecko_GetNextStyleChild(RawGeckoStyleChildrenIteratorBorrowedMut it);
145 :
146 : mozilla::ServoStyleSheet*
147 : Gecko_LoadStyleSheet(mozilla::css::Loader* loader,
148 : mozilla::ServoStyleSheet* parent,
149 : mozilla::css::LoaderReusableStyleSheets* reusable_sheets,
150 : RawGeckoURLExtraData* base_url_data,
151 : const uint8_t* url_bytes,
152 : uint32_t url_length,
153 : RawServoMediaListStrong media_list);
154 :
155 : // Selector Matching.
156 : uint64_t Gecko_ElementState(RawGeckoElementBorrowed element);
157 : uint64_t Gecko_DocumentState(const nsIDocument* aDocument);
158 : bool Gecko_IsTextNode(RawGeckoNodeBorrowed node);
159 : bool Gecko_IsRootElement(RawGeckoElementBorrowed element);
160 : bool Gecko_MatchesElement(mozilla::CSSPseudoClassType type, RawGeckoElementBorrowed element);
161 : nsIAtom* Gecko_LocalName(RawGeckoElementBorrowed element);
162 : nsIAtom* Gecko_Namespace(RawGeckoElementBorrowed element);
163 : nsIAtom* Gecko_GetElementId(RawGeckoElementBorrowed element);
164 : bool Gecko_MatchLang(RawGeckoElementBorrowed element,
165 : nsIAtom* override_lang, bool has_override_lang,
166 : const char16_t* value);
167 : nsIAtom* Gecko_GetXMLLangValue(RawGeckoElementBorrowed element);
168 : nsIDocument::DocumentTheme Gecko_GetDocumentLWTheme(const nsIDocument* aDocument);
169 :
170 : // Attributes.
171 : #define SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_) \
172 : nsIAtom* prefix_##AtomAttrValue(implementor_ element, nsIAtom* attribute); \
173 : nsIAtom* prefix_##LangValue(implementor_ element); \
174 : bool prefix_##HasAttr(implementor_ element, nsIAtom* ns, nsIAtom* name); \
175 : bool prefix_##AttrEquals(implementor_ element, nsIAtom* ns, nsIAtom* name, \
176 : nsIAtom* str, bool ignoreCase); \
177 : bool prefix_##AttrDashEquals(implementor_ element, nsIAtom* ns, \
178 : nsIAtom* name, nsIAtom* str, bool ignore_case);\
179 : bool prefix_##AttrIncludes(implementor_ element, nsIAtom* ns, \
180 : nsIAtom* name, nsIAtom* str, bool ignore_case); \
181 : bool prefix_##AttrHasSubstring(implementor_ element, nsIAtom* ns, \
182 : nsIAtom* name, nsIAtom* str, \
183 : bool ignore_case); \
184 : bool prefix_##AttrHasPrefix(implementor_ element, nsIAtom* ns, \
185 : nsIAtom* name, nsIAtom* str, bool ignore_case); \
186 : bool prefix_##AttrHasSuffix(implementor_ element, nsIAtom* ns, \
187 : nsIAtom* name, nsIAtom* str, bool ignore_case); \
188 : uint32_t prefix_##ClassOrClassList(implementor_ element, nsIAtom** class_, \
189 : nsIAtom*** classList);
190 :
191 : SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_, RawGeckoElementBorrowed)
192 : SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_Snapshot,
193 : const ServoElementSnapshot*)
194 :
195 : #undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS
196 :
197 : // Style attributes.
198 : RawServoDeclarationBlockStrongBorrowedOrNull
199 : Gecko_GetStyleAttrDeclarationBlock(RawGeckoElementBorrowed element);
200 : void Gecko_UnsetDirtyStyleAttr(RawGeckoElementBorrowed element);
201 : RawServoDeclarationBlockStrongBorrowedOrNull
202 : Gecko_GetHTMLPresentationAttrDeclarationBlock(RawGeckoElementBorrowed element);
203 : RawServoDeclarationBlockStrongBorrowedOrNull
204 : Gecko_GetExtraContentStyleDeclarations(RawGeckoElementBorrowed element);
205 : RawServoDeclarationBlockStrongBorrowedOrNull
206 : Gecko_GetUnvisitedLinkAttrDeclarationBlock(RawGeckoElementBorrowed element);
207 : RawServoDeclarationBlockStrongBorrowedOrNull
208 : Gecko_GetVisitedLinkAttrDeclarationBlock(RawGeckoElementBorrowed element);
209 : RawServoDeclarationBlockStrongBorrowedOrNull
210 : Gecko_GetActiveLinkAttrDeclarationBlock(RawGeckoElementBorrowed element);
211 :
212 : // Animations
213 : bool
214 : Gecko_GetAnimationRule(RawGeckoElementBorrowed aElementOrPseudo,
215 : mozilla::EffectCompositor::CascadeLevel aCascadeLevel,
216 : RawServoAnimationValueMapBorrowedMut aAnimationValues);
217 : RawServoDeclarationBlockStrongBorrowedOrNull
218 : Gecko_GetSMILOverrideDeclarationBlock(RawGeckoElementBorrowed element);
219 : bool Gecko_StyleAnimationsEquals(RawGeckoStyleAnimationListBorrowed,
220 : RawGeckoStyleAnimationListBorrowed);
221 : void Gecko_UpdateAnimations(RawGeckoElementBorrowed aElementOrPseudo,
222 : ServoComputedValuesBorrowedOrNull aOldComputedValues,
223 : ServoComputedValuesBorrowedOrNull aComputedValues,
224 : mozilla::UpdateAnimationsTasks aTasks);
225 : bool Gecko_ElementHasAnimations(RawGeckoElementBorrowed aElementOrPseudo);
226 : bool Gecko_ElementHasCSSAnimations(RawGeckoElementBorrowed aElementOrPseudo);
227 : bool Gecko_ElementHasCSSTransitions(RawGeckoElementBorrowed aElementOrPseudo);
228 : size_t Gecko_ElementTransitions_Length(RawGeckoElementBorrowed aElementOrPseudo);
229 : nsCSSPropertyID Gecko_ElementTransitions_PropertyAt(
230 : RawGeckoElementBorrowed aElementOrPseudo,
231 : size_t aIndex);
232 : RawServoAnimationValueBorrowedOrNull Gecko_ElementTransitions_EndValueAt(
233 : RawGeckoElementBorrowed aElementOrPseudo,
234 : size_t aIndex);
235 : double Gecko_GetProgressFromComputedTiming(RawGeckoComputedTimingBorrowed aComputedTiming);
236 : double Gecko_GetPositionInSegment(
237 : RawGeckoAnimationPropertySegmentBorrowed aSegment,
238 : double aProgress,
239 : mozilla::ComputedTimingFunction::BeforeFlag aBeforeFlag);
240 : bool Gecko_IsFramesTimingEnabled();
241 : // Get servo's AnimationValue for |aProperty| from the cached base style
242 : // |aBaseStyles|.
243 : // |aBaseStyles| is nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>.
244 : // We use void* to avoid exposing nsRefPtrHashtable in FFI.
245 : RawServoAnimationValueBorrowedOrNull Gecko_AnimationGetBaseStyle(
246 : void* aBaseStyles,
247 : nsCSSPropertyID aProperty);
248 : void Gecko_StyleTransition_SetUnsupportedProperty(
249 : mozilla::StyleTransition* aTransition,
250 : nsIAtom* aAtom);
251 :
252 : // Atoms.
253 : nsIAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
254 : nsIAtom* Gecko_Atomize16(const nsAString* aString);
255 : void Gecko_AddRefAtom(nsIAtom* aAtom);
256 : void Gecko_ReleaseAtom(nsIAtom* aAtom);
257 : const uint16_t* Gecko_GetAtomAsUTF16(nsIAtom* aAtom, uint32_t* aLength);
258 : bool Gecko_AtomEqualsUTF8(nsIAtom* aAtom, const char* aString, uint32_t aLength);
259 : bool Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom* aAtom, const char* aString, uint32_t aLength);
260 :
261 : // Border style
262 : void Gecko_EnsureMozBorderColors(nsStyleBorder* aBorder);
263 : void Gecko_ClearMozBorderColors(nsStyleBorder* aBorder, mozilla::Side aSide);
264 : void Gecko_AppendMozBorderColors(nsStyleBorder* aBorder, mozilla::Side aSide,
265 : nscolor aColor);
266 : void Gecko_CopyMozBorderColors(nsStyleBorder* aDest, const nsStyleBorder* aSrc,
267 : mozilla::Side aSide);
268 : const nsBorderColors* Gecko_GetMozBorderColors(const nsStyleBorder* aBorder,
269 : mozilla::Side aSide);
270 :
271 : // Font style
272 : void Gecko_FontFamilyList_Clear(FontFamilyList* aList);
273 : void Gecko_FontFamilyList_AppendNamed(FontFamilyList* aList, nsIAtom* aName, bool aQuoted);
274 : void Gecko_FontFamilyList_AppendGeneric(FontFamilyList* list, FontFamilyType familyType);
275 : void Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src);
276 : // will not run destructors on dst, give it uninitialized memory
277 : // font_id is LookAndFeel::FontID
278 : void Gecko_nsFont_InitSystem(nsFont* dst, int32_t font_id,
279 : const nsStyleFont* font, RawGeckoPresContextBorrowed pres_context);
280 : void Gecko_nsFont_Destroy(nsFont* dst);
281 :
282 : // Font variant alternates
283 : void Gecko_ClearAlternateValues(nsFont* font, size_t length);
284 : void Gecko_AppendAlternateValues(nsFont* font, uint32_t alternate_name, nsIAtom* atom);
285 : void Gecko_CopyAlternateValuesFrom(nsFont* dest, const nsFont* src);
286 :
287 : // Visibility style
288 : void Gecko_SetImageOrientation(nsStyleVisibility* aVisibility,
289 : double aRadians,
290 : bool aFlip);
291 : void Gecko_SetImageOrientationAsFromImage(nsStyleVisibility* aVisibility);
292 : void Gecko_CopyImageOrientationFrom(nsStyleVisibility* aDst,
293 : const nsStyleVisibility* aSrc);
294 :
295 : // Counter style.
296 : // This function takes an already addrefed nsIAtom
297 : void Gecko_SetCounterStyleToName(mozilla::CounterStylePtr* ptr, nsIAtom* name,
298 : RawGeckoPresContextBorrowed pres_context);
299 : void Gecko_SetCounterStyleToSymbols(mozilla::CounterStylePtr* ptr,
300 : uint8_t symbols_type,
301 : nsACString const* const* symbols,
302 : uint32_t symbols_count);
303 : void Gecko_SetCounterStyleToString(mozilla::CounterStylePtr* ptr,
304 : const nsACString* symbol);
305 : void Gecko_CopyCounterStyle(mozilla::CounterStylePtr* dst,
306 : const mozilla::CounterStylePtr* src);
307 :
308 : // background-image style.
309 : void Gecko_SetNullImageValue(nsStyleImage* image);
310 : void Gecko_SetGradientImageValue(nsStyleImage* image, nsStyleGradient* gradient);
311 : NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::ImageValue, ImageValue);
312 : mozilla::css::ImageValue* Gecko_ImageValue_Create(ServoBundledURI aURI);
313 : void Gecko_SetLayerImageImageValue(nsStyleImage* image,
314 : mozilla::css::ImageValue* aImageValue);
315 :
316 : void Gecko_SetImageElement(nsStyleImage* image, nsIAtom* atom);
317 : void Gecko_CopyImageValueFrom(nsStyleImage* image, const nsStyleImage* other);
318 : void Gecko_InitializeImageCropRect(nsStyleImage* image);
319 :
320 : nsStyleGradient* Gecko_CreateGradient(uint8_t shape,
321 : uint8_t size,
322 : bool repeating,
323 : bool legacy_syntax,
324 : bool moz_legacy_syntax,
325 : uint32_t stops);
326 :
327 : const mozilla::css::URLValueData* Gecko_GetURLValue(const nsStyleImage* image);
328 : nsIAtom* Gecko_GetImageElement(const nsStyleImage* image);
329 : const nsStyleGradient* Gecko_GetGradientImageValue(const nsStyleImage* image);
330 :
331 : // list-style-image style.
332 : void Gecko_SetListStyleImageNone(nsStyleList* style_struct);
333 : void Gecko_SetListStyleImageImageValue(nsStyleList* style_struct,
334 : mozilla::css::ImageValue* aImageValue);
335 : void Gecko_CopyListStyleImageFrom(nsStyleList* dest, const nsStyleList* src);
336 :
337 : // cursor style.
338 : void Gecko_SetCursorArrayLength(nsStyleUserInterface* ui, size_t len);
339 : void Gecko_SetCursorImageValue(nsCursorImage* aCursor,
340 : mozilla::css::ImageValue* aImageValue);
341 : void Gecko_CopyCursorArrayFrom(nsStyleUserInterface* dest,
342 : const nsStyleUserInterface* src);
343 :
344 : void Gecko_SetContentDataImageValue(nsStyleContentData* aList,
345 : mozilla::css::ImageValue* aImageValue);
346 : nsStyleContentData::CounterFunction* Gecko_SetCounterFunction(
347 : nsStyleContentData* content_data, nsStyleContentType type);
348 :
349 : // Dirtiness tracking.
350 : uint32_t Gecko_GetNodeFlags(RawGeckoNodeBorrowed node);
351 : void Gecko_SetNodeFlags(RawGeckoNodeBorrowed node, uint32_t flags);
352 : void Gecko_UnsetNodeFlags(RawGeckoNodeBorrowed node, uint32_t flags);
353 : void Gecko_SetOwnerDocumentNeedsStyleFlush(RawGeckoElementBorrowed element);
354 :
355 : // Incremental restyle.
356 : // Also, we might want a ComputedValues to ComputedValues API for animations?
357 : // Not if we do them in Gecko...
358 : nsStyleContext* Gecko_GetStyleContext(RawGeckoElementBorrowed element,
359 : nsIAtom* aPseudoTagOrNull);
360 : mozilla::CSSPseudoElementType Gecko_GetImplementedPseudo(RawGeckoElementBorrowed element);
361 : nsChangeHint Gecko_CalcStyleDifference(nsStyleContext* oldstyle,
362 : ServoComputedValuesBorrowed newstyle,
363 : bool* any_style_changed);
364 : nsChangeHint Gecko_HintsHandledForDescendants(nsChangeHint aHint);
365 :
366 : // Get an element snapshot for a given element from the table.
367 : const ServoElementSnapshot*
368 : Gecko_GetElementSnapshot(const mozilla::ServoElementSnapshotTable* table,
369 : RawGeckoElementBorrowed element);
370 :
371 : void Gecko_DropElementSnapshot(ServoElementSnapshotOwned snapshot);
372 :
373 : // `array` must be an nsTArray
374 : // If changing this signature, please update the
375 : // friend function declaration in nsTArray.h
376 : void Gecko_EnsureTArrayCapacity(void* array, size_t capacity, size_t elem_size);
377 :
378 : // Same here, `array` must be an nsTArray<T>, for some T.
379 : //
380 : // Important note: Only valid for POD types, since destructors won't be run
381 : // otherwise. This is ensured with rust traits for the relevant structs.
382 : void Gecko_ClearPODTArray(void* array, size_t elem_size, size_t elem_align);
383 :
384 : void Gecko_ResizeTArrayForStrings(nsTArray<nsString>* array, uint32_t length);
385 :
386 : void Gecko_SetStyleGridTemplateArrayLengths(nsStyleGridTemplate* grid_template,
387 : uint32_t track_sizes);
388 :
389 : void Gecko_SetGridTemplateLineNamesLength(nsStyleGridTemplate* grid_template,
390 : uint32_t track_sizes);
391 :
392 : void Gecko_CopyStyleGridTemplateValues(nsStyleGridTemplate* grid_template,
393 : const nsStyleGridTemplate* other);
394 :
395 : mozilla::css::GridTemplateAreasValue* Gecko_NewGridTemplateAreasValue(uint32_t areas,
396 : uint32_t templates,
397 : uint32_t columns);
398 : NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::GridTemplateAreasValue, GridTemplateAreasValue);
399 :
400 : // Clear the mContents, mCounterIncrements, or mCounterResets field in nsStyleContent. This is
401 : // needed to run the destructors, otherwise we'd leak the images, strings, and whatnot.
402 : void Gecko_ClearAndResizeStyleContents(nsStyleContent* content,
403 : uint32_t how_many);
404 : void Gecko_ClearAndResizeCounterIncrements(nsStyleContent* content,
405 : uint32_t how_many);
406 : void Gecko_ClearAndResizeCounterResets(nsStyleContent* content,
407 : uint32_t how_many);
408 : void Gecko_CopyStyleContentsFrom(nsStyleContent* content, const nsStyleContent* other);
409 : void Gecko_CopyCounterResetsFrom(nsStyleContent* content, const nsStyleContent* other);
410 : void Gecko_CopyCounterIncrementsFrom(nsStyleContent* content, const nsStyleContent* other);
411 :
412 : void Gecko_EnsureImageLayersLength(nsStyleImageLayers* layers, size_t len,
413 : nsStyleImageLayers::LayerType layer_type);
414 :
415 : void Gecko_EnsureStyleAnimationArrayLength(void* array, size_t len);
416 : void Gecko_EnsureStyleTransitionArrayLength(void* array, size_t len);
417 :
418 : void Gecko_ClearWillChange(nsStyleDisplay* display, size_t length);
419 : void Gecko_AppendWillChange(nsStyleDisplay* display, nsIAtom* atom);
420 : void Gecko_CopyWillChangeFrom(nsStyleDisplay* dest, nsStyleDisplay* src);
421 :
422 : // Searches from the beginning of |keyframes| for a Keyframe object with the
423 : // specified offset and timing function. If none is found, a new Keyframe object
424 : // with the specified |offset| and |timingFunction| will be prepended to
425 : // |keyframes|.
426 : //
427 : // @param keyframes An array of Keyframe objects, sorted by offset.
428 : // The first Keyframe in the array, if any, MUST have an
429 : // offset greater than or equal to |offset|.
430 : // @param offset The offset to search for, or, if no suitable Keyframe is
431 : // found, the offset to use for the created Keyframe.
432 : // Must be a floating point number in the range [0.0, 1.0].
433 : // @param timingFunction The timing function to match, or, if no suitable
434 : // Keyframe is found, to set on the created Keyframe.
435 : //
436 : // @returns The matching or created Keyframe.
437 : mozilla::Keyframe* Gecko_GetOrCreateKeyframeAtStart(
438 : RawGeckoKeyframeListBorrowedMut keyframes,
439 : float offset,
440 : const nsTimingFunction* timingFunction);
441 :
442 : // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
443 : // from the beginning of |keyframes| for a Keyframe with matching timing
444 : // function and an offset of 0.0.
445 : // Furthermore, if a matching Keyframe is not found, a new Keyframe will be
446 : // inserted after the *last* Keyframe in |keyframes| with offset 0.0.
447 : mozilla::Keyframe* Gecko_GetOrCreateInitialKeyframe(
448 : RawGeckoKeyframeListBorrowedMut keyframes,
449 : const nsTimingFunction* timingFunction);
450 :
451 : // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
452 : // from the *end* of |keyframes| for a Keyframe with matching timing function
453 : // and an offset of 1.0. If a matching Keyframe is not found, a new Keyframe
454 : // will be appended to the end of |keyframes|.
455 : mozilla::Keyframe* Gecko_GetOrCreateFinalKeyframe(
456 : RawGeckoKeyframeListBorrowedMut keyframes,
457 : const nsTimingFunction* timingFunction);
458 :
459 : // Clean up pointer-based coordinates
460 : void Gecko_ResetStyleCoord(nsStyleUnit* unit, nsStyleUnion* value);
461 :
462 : // Set an nsStyleCoord to a computed `calc()` value
463 : void Gecko_SetStyleCoordCalcValue(nsStyleUnit* unit, nsStyleUnion* value, nsStyleCoord::CalcValue calc);
464 :
465 : void Gecko_CopyShapeSourceFrom(mozilla::StyleShapeSource* dst, const mozilla::StyleShapeSource* src);
466 :
467 : void Gecko_DestroyShapeSource(mozilla::StyleShapeSource* shape);
468 : mozilla::StyleBasicShape* Gecko_NewBasicShape(mozilla::StyleBasicShapeType type);
469 : void Gecko_StyleShapeSource_SetURLValue(mozilla::StyleShapeSource* shape, ServoBundledURI uri);
470 :
471 : void Gecko_ResetFilters(nsStyleEffects* effects, size_t new_len);
472 : void Gecko_CopyFiltersFrom(nsStyleEffects* aSrc, nsStyleEffects* aDest);
473 : void Gecko_nsStyleFilter_SetURLValue(nsStyleFilter* effects, ServoBundledURI uri);
474 :
475 : void Gecko_nsStyleSVGPaint_CopyFrom(nsStyleSVGPaint* dest, const nsStyleSVGPaint* src);
476 : void Gecko_nsStyleSVGPaint_SetURLValue(nsStyleSVGPaint* paint, ServoBundledURI uri);
477 : void Gecko_nsStyleSVGPaint_Reset(nsStyleSVGPaint* paint);
478 :
479 : void Gecko_nsStyleSVG_SetDashArrayLength(nsStyleSVG* svg, uint32_t len);
480 : void Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG* dst, const nsStyleSVG* src);
481 : void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* svg, uint32_t len);
482 : void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* dst, const nsStyleSVG* src);
483 :
484 : mozilla::css::URLValue* Gecko_NewURLValue(ServoBundledURI uri);
485 : NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::URLValue, CSSURLValue);
486 : NS_DECL_THREADSAFE_FFI_REFCOUNTING(RawGeckoURLExtraData, URLExtraData);
487 :
488 : void Gecko_FillAllBackgroundLists(nsStyleImageLayers* layers, uint32_t max_len);
489 : void Gecko_FillAllMaskLists(nsStyleImageLayers* layers, uint32_t max_len);
490 : NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleCoord::Calc, Calc);
491 :
492 : nsCSSShadowArray* Gecko_NewCSSShadowArray(uint32_t len);
493 : NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSShadowArray, CSSShadowArray);
494 :
495 : nsStyleQuoteValues* Gecko_NewStyleQuoteValues(uint32_t len);
496 : NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleQuoteValues, QuoteValues);
497 :
498 : nsCSSValueSharedList* Gecko_NewCSSValueSharedList(uint32_t len);
499 : nsCSSValueSharedList* Gecko_NewNoneTransform();
500 :
501 : // Getter for nsCSSValue
502 : nsCSSValueBorrowedMut Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut css_value, int32_t index);
503 : // const version of the above function.
504 : nsCSSValueBorrowed Gecko_CSSValue_GetArrayItemConst(nsCSSValueBorrowed css_value, int32_t index);
505 : nscoord Gecko_CSSValue_GetAbsoluteLength(nsCSSValueBorrowed css_value);
506 : nsCSSKeyword Gecko_CSSValue_GetKeyword(nsCSSValueBorrowed aCSSValue);
507 : float Gecko_CSSValue_GetNumber(nsCSSValueBorrowed css_value);
508 : float Gecko_CSSValue_GetPercentage(nsCSSValueBorrowed css_value);
509 : nsStyleCoord::CalcValue Gecko_CSSValue_GetCalc(nsCSSValueBorrowed aCSSValue);
510 :
511 : void Gecko_CSSValue_SetAbsoluteLength(nsCSSValueBorrowedMut css_value, nscoord len);
512 : void Gecko_CSSValue_SetNumber(nsCSSValueBorrowedMut css_value, float number);
513 : void Gecko_CSSValue_SetKeyword(nsCSSValueBorrowedMut css_value, nsCSSKeyword keyword);
514 : void Gecko_CSSValue_SetPercentage(nsCSSValueBorrowedMut css_value, float percent);
515 : void Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut css_value, nsStyleCoord::CalcValue calc);
516 : void Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut css_value, int32_t len);
517 : void Gecko_CSSValue_SetString(nsCSSValueBorrowedMut css_value,
518 : const uint8_t* string, uint32_t len, nsCSSUnit unit);
519 : void Gecko_CSSValue_SetStringFromAtom(nsCSSValueBorrowedMut css_value,
520 : nsIAtom* atom, nsCSSUnit unit);
521 : // Take an addrefed nsIAtom and set it to the nsCSSValue
522 : void Gecko_CSSValue_SetAtomIdent(nsCSSValueBorrowedMut css_value, nsIAtom* atom);
523 : void Gecko_CSSValue_SetArray(nsCSSValueBorrowedMut css_value, int32_t len);
524 : void Gecko_CSSValue_SetURL(nsCSSValueBorrowedMut css_value, ServoBundledURI uri);
525 : void Gecko_CSSValue_SetInt(nsCSSValueBorrowedMut css_value, int32_t integer, nsCSSUnit unit);
526 : void Gecko_CSSValue_SetPair(nsCSSValueBorrowedMut css_value,
527 : nsCSSValueBorrowed xvalue, nsCSSValueBorrowed yvalue);
528 : void Gecko_CSSValue_SetList(nsCSSValueBorrowedMut css_value, uint32_t len);
529 : void Gecko_CSSValue_SetPairList(nsCSSValueBorrowedMut css_value, uint32_t len);
530 : void Gecko_CSSValue_InitSharedList(nsCSSValueBorrowedMut css_value, uint32_t len);
531 : void Gecko_CSSValue_Drop(nsCSSValueBorrowedMut css_value);
532 : NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList);
533 : bool Gecko_PropertyId_IsPrefEnabled(nsCSSPropertyID id);
534 :
535 : void Gecko_nsStyleFont_SetLang(nsStyleFont* font, nsIAtom* atom);
536 : void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont, const nsStyleFont* aSource);
537 : void Gecko_nsStyleFont_FixupNoneGeneric(nsStyleFont* font,
538 : RawGeckoPresContextBorrowed pres_context);
539 : void Gecko_nsStyleFont_PrefillDefaultForGeneric(nsStyleFont* font,
540 : RawGeckoPresContextBorrowed pres_context,
541 : uint8_t generic_id);
542 : void Gecko_nsStyleFont_FixupMinFontSize(nsStyleFont* font,
543 : RawGeckoPresContextBorrowed pres_context);
544 : FontSizePrefs Gecko_GetBaseSize(nsIAtom* lang);
545 :
546 : // XBL related functions.
547 : RawGeckoElementBorrowedOrNull Gecko_GetBindingParent(RawGeckoElementBorrowed aElement);
548 : RawGeckoXBLBindingBorrowedOrNull Gecko_GetXBLBinding(RawGeckoElementBorrowed aElement);
549 : RawServoStyleSetBorrowedOrNull Gecko_XBLBinding_GetRawServoStyleSet(RawGeckoXBLBindingBorrowed aXBLBinding);
550 : bool Gecko_XBLBinding_InheritsStyle(RawGeckoXBLBindingBorrowed aXBLBinding);
551 :
552 : struct GeckoFontMetrics
553 : {
554 : nscoord mChSize;
555 : nscoord mXSize;
556 : };
557 :
558 : GeckoFontMetrics Gecko_GetFontMetrics(RawGeckoPresContextBorrowed pres_context,
559 : bool is_vertical,
560 : const nsStyleFont* font,
561 : nscoord font_size,
562 : bool use_user_font_set);
563 : int32_t Gecko_GetAppUnitsPerPhysicalInch(RawGeckoPresContextBorrowed pres_context);
564 : void InitializeServo();
565 : void ShutdownServo();
566 : void AssertIsMainThreadOrServoLangFontPrefsCacheLocked();
567 :
568 : mozilla::ServoStyleSheet* Gecko_StyleSheet_Clone(
569 : const mozilla::ServoStyleSheet* aSheet,
570 : const mozilla::ServoStyleSheet* aNewParentSheet);
571 : void Gecko_StyleSheet_AddRef(const mozilla::ServoStyleSheet* aSheet);
572 : void Gecko_StyleSheet_Release(const mozilla::ServoStyleSheet* aSheet);
573 :
574 : const nsMediaFeature* Gecko_GetMediaFeatures();
575 : nsCSSKeyword Gecko_LookupCSSKeyword(const uint8_t* string, uint32_t len);
576 : const char* Gecko_CSSKeywordString(nsCSSKeyword keyword, uint32_t* len);
577 :
578 : // Font face rule
579 : // Creates and returns a new (already-addrefed) nsCSSFontFaceRule object.
580 : nsCSSFontFaceRule* Gecko_CSSFontFaceRule_Create(uint32_t line, uint32_t column);
581 : nsCSSFontFaceRule* Gecko_CSSFontFaceRule_Clone(const nsCSSFontFaceRule* rule);
582 : void Gecko_CSSFontFaceRule_GetCssText(const nsCSSFontFaceRule* rule, nsAString* result);
583 : NS_DECL_FFI_REFCOUNTING(nsCSSFontFaceRule, CSSFontFaceRule);
584 :
585 : // Counter style rule
586 : // Creates and returns a new (already-addrefed) nsCSSCounterStyleRule object.
587 : nsCSSCounterStyleRule* Gecko_CSSCounterStyle_Create(nsIAtom* name);
588 : nsCSSCounterStyleRule* Gecko_CSSCounterStyle_Clone(const nsCSSCounterStyleRule* rule);
589 : void Gecko_CSSCounterStyle_GetCssText(const nsCSSCounterStyleRule* rule, nsAString* result);
590 : NS_DECL_FFI_REFCOUNTING(nsCSSCounterStyleRule, CSSCounterStyleRule);
591 :
592 : RawGeckoElementBorrowedOrNull Gecko_GetBody(RawGeckoPresContextBorrowed pres_context);
593 :
594 : // We use an int32_t here instead of a LookAndFeel::ColorID
595 : // because forward-declaring a nested enum/struct is impossible
596 : nscolor Gecko_GetLookAndFeelSystemColor(int32_t color_id,
597 : RawGeckoPresContextBorrowed pres_context);
598 :
599 : bool Gecko_MatchStringArgPseudo(RawGeckoElementBorrowed element,
600 : mozilla::CSSPseudoClassType type,
601 : const char16_t* ident,
602 : bool* set_slow_selector);
603 :
604 : void Gecko_AddPropertyToSet(nsCSSPropertyIDSetBorrowedMut, nsCSSPropertyID);
605 :
606 : // Register a namespace and get a namespace id.
607 : // Returns -1 on error (OOM)
608 : int32_t Gecko_RegisterNamespace(nsIAtom* ns);
609 :
610 : // Style-struct management.
611 : #define STYLE_STRUCT(name, checkdata_cb) \
612 : void Gecko_Construct_Default_nsStyle##name( \
613 : nsStyle##name* ptr, \
614 : RawGeckoPresContextBorrowed pres_context); \
615 : void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \
616 : const nsStyle##name* other); \
617 : void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr);
618 : #include "nsStyleStructList.h"
619 : #undef STYLE_STRUCT
620 :
621 : void Gecko_Construct_nsStyleVariables(nsStyleVariables* ptr);
622 :
623 : void Gecko_RegisterProfilerThread(const char* name);
624 : void Gecko_UnregisterProfilerThread();
625 :
626 : bool Gecko_DocumentRule_UseForPresentation(RawGeckoPresContextBorrowed,
627 : const nsACString* aPattern,
628 : mozilla::css::URLMatchingFunction aURLMatchingFunction);
629 :
630 : // Allocator hinting.
631 : void Gecko_SetJemallocThreadLocalArena(bool enabled);
632 :
633 : // Pseudo-element flags.
634 : #define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
635 : const uint32_t SERVO_CSS_PSEUDO_ELEMENT_FLAGS_##name_ = flags_;
636 : #include "nsCSSPseudoElementList.h"
637 : #undef CSS_PSEUDO_ELEMENT
638 :
639 : #define SERVO_BINDING_FUNC(name_, return_, ...) return_ name_(__VA_ARGS__);
640 : #include "mozilla/ServoBindingList.h"
641 : #undef SERVO_BINDING_FUNC
642 :
643 : mozilla::css::ErrorReporter* Gecko_CreateCSSErrorReporter(mozilla::ServoStyleSheet* sheet,
644 : mozilla::css::Loader* loader,
645 : nsIURI* uri);
646 : void Gecko_DestroyCSSErrorReporter(mozilla::css::ErrorReporter* reporter);
647 : void Gecko_ReportUnexpectedCSSError(mozilla::css::ErrorReporter* reporter,
648 : const char* message,
649 : const char* param,
650 : uint32_t paramLen,
651 : const char* source,
652 : uint32_t sourceLen,
653 : uint32_t lineNumber,
654 : uint32_t colNumber,
655 : nsIURI* aURI);
656 :
657 : } // extern "C"
658 :
659 : #endif // mozilla_ServoBindings_h
|