Bug 1858509 add thread-safety annotations around MediaSourceDemuxer::mMonitor r=alwu
[gecko.git] / layout / style / GeckoBindings.h
blob327b3d587844c0ad81f5b9c2c622bf52315380bf
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 Servo to call into Gecko */
9 #ifndef mozilla_GeckoBindings_h
10 #define mozilla_GeckoBindings_h
12 #include <stdint.h>
14 #include "mozilla/ServoTypes.h"
15 #include "mozilla/ServoBindingTypes.h"
16 #include "mozilla/css/DocumentMatchingFunction.h"
17 #include "mozilla/css/SheetLoadData.h"
18 #include "mozilla/dom/Document.h"
19 #include "mozilla/EffectCompositor.h"
20 #include "mozilla/PreferenceSheet.h"
21 #include "nsStyleStruct.h"
22 #include "COLRFonts.h"
24 class nsAtom;
25 class nsIURI;
26 class nsSimpleContentList;
27 struct nsFont;
28 class ServoComputedData;
30 namespace mozilla {
31 class ComputedStyle;
32 class SeenPtrs;
33 class ServoElementSnapshot;
34 class ServoElementSnapshotTable;
35 class StyleSheet;
36 enum class PseudoStyleType : uint8_t;
37 enum class PointerCapabilities : uint8_t;
38 enum class UpdateAnimationsTasks : uint8_t;
39 struct Keyframe;
40 struct StyleStylesheetContents;
42 namespace css {
43 class LoaderReusableStyleSheets;
45 namespace dom {
46 enum class CompositeOperationOrAuto : uint8_t;
47 enum class ScreenColorGamut : uint8_t;
48 } // namespace dom
49 } // namespace mozilla
51 #ifdef NIGHTLY_BUILD
52 const bool GECKO_IS_NIGHTLY = true;
53 #else
54 const bool GECKO_IS_NIGHTLY = false;
55 #endif
57 #define NS_DECL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \
58 void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr); \
59 void Gecko_Release##name_##ArbitraryThread(class_* aPtr);
60 #define NS_IMPL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \
61 static_assert(class_::HasThreadSafeRefCnt::value, \
62 "NS_DECL_THREADSAFE_FFI_REFCOUNTING can only be used with " \
63 "classes that have thread-safe refcounting"); \
64 void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr) { NS_ADDREF(aPtr); } \
65 void Gecko_Release##name_##ArbitraryThread(class_* aPtr) { NS_RELEASE(aPtr); }
67 extern "C" {
69 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsIURI, nsIURI);
71 // Debugging stuff.
72 void Gecko_Element_DebugListAttributes(const mozilla::dom::Element*,
73 nsCString*);
75 void Gecko_Snapshot_DebugListAttributes(const mozilla::ServoElementSnapshot*,
76 nsCString*);
78 bool Gecko_IsSignificantChild(const nsINode*, bool whitespace_is_significant);
80 const nsINode* Gecko_GetLastChild(const nsINode*);
81 const nsINode* Gecko_GetFlattenedTreeParentNode(const nsINode*);
82 const mozilla::dom::Element* Gecko_GetBeforeOrAfterPseudo(
83 const mozilla::dom::Element*, bool is_before);
84 const mozilla::dom::Element* Gecko_GetMarkerPseudo(
85 const mozilla::dom::Element*);
87 nsTArray<nsIContent*>* Gecko_GetAnonymousContentForElement(
88 const mozilla::dom::Element*);
89 void Gecko_DestroyAnonymousContentList(nsTArray<nsIContent*>* anon_content);
91 const nsTArray<RefPtr<nsINode>>* Gecko_GetAssignedNodes(
92 const mozilla::dom::Element*);
94 void Gecko_GetQueryContainerSize(const mozilla::dom::Element*,
95 nscoord* aOutWidth, nscoord* aOutHeight);
97 void Gecko_ComputedStyle_Init(mozilla::ComputedStyle* context,
98 const ServoComputedData* values,
99 mozilla::PseudoStyleType pseudo_type);
101 void Gecko_ComputedStyle_Destroy(mozilla::ComputedStyle* context);
103 // By default, Servo walks the DOM by traversing the siblings of the DOM-view
104 // first child. This generally works, but misses anonymous children, which we
105 // want to traverse during styling. To support these cases, we create an
106 // optional stack-allocated iterator in aIterator for nodes that need it.
107 void Gecko_ConstructStyleChildrenIterator(const mozilla::dom::Element*,
108 mozilla::dom::StyleChildrenIterator*);
110 void Gecko_DestroyStyleChildrenIterator(mozilla::dom::StyleChildrenIterator*);
112 const nsINode* Gecko_GetNextStyleChild(mozilla::dom::StyleChildrenIterator*);
114 nsAtom* Gecko_Element_ImportedPart(const nsAttrValue*, nsAtom*);
115 nsAtom** Gecko_Element_ExportedParts(const nsAttrValue*, nsAtom*,
116 size_t* aOutLength);
118 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::SheetLoadDataHolder,
119 SheetLoadDataHolder);
121 void Gecko_StyleSheet_FinishAsyncParse(
122 mozilla::css::SheetLoadDataHolder* data,
123 mozilla::StyleStrong<mozilla::StyleStylesheetContents> sheet_contents,
124 mozilla::StyleUseCounters* use_counters);
126 mozilla::StyleSheet* Gecko_LoadStyleSheet(
127 mozilla::css::Loader* loader, mozilla::StyleSheet* parent,
128 mozilla::css::SheetLoadData* parent_load_data,
129 mozilla::css::LoaderReusableStyleSheets* reusable_sheets,
130 const mozilla::StyleCssUrl* url,
131 mozilla::StyleStrong<mozilla::StyleLockedMediaList> media_list);
133 void Gecko_LoadStyleSheetAsync(
134 mozilla::css::SheetLoadDataHolder* parent_data,
135 const mozilla::StyleCssUrl* url,
136 mozilla::StyleStrong<mozilla::StyleLockedMediaList>,
137 mozilla::StyleStrong<mozilla::StyleLockedImportRule>);
139 // Selector Matching.
140 uint64_t Gecko_ElementState(const mozilla::dom::Element*);
141 bool Gecko_IsRootElement(const mozilla::dom::Element*);
143 bool Gecko_MatchLang(const mozilla::dom::Element*, nsAtom* override_lang,
144 bool has_override_lang, const char16_t* value);
146 nsAtom* Gecko_GetXMLLangValue(const mozilla::dom::Element*);
148 const mozilla::PreferenceSheet::Prefs* Gecko_GetPrefSheetPrefs(
149 const mozilla::dom::Document*);
151 bool Gecko_IsTableBorderNonzero(const mozilla::dom::Element* element);
152 bool Gecko_IsBrowserFrame(const mozilla::dom::Element* element);
153 bool Gecko_IsSelectListBox(const mozilla::dom::Element* element);
155 // Attributes.
156 #define SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_) \
157 nsAtom* prefix_##LangValue(implementor_ element);
159 bool Gecko_AttrEquals(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
160 bool Gecko_AttrDashEquals(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
161 bool Gecko_AttrIncludes(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
162 bool Gecko_AttrHasSubstring(const nsAttrValue*, const nsAtom*,
163 bool aIgnoreCase);
164 bool Gecko_AttrHasPrefix(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
165 bool Gecko_AttrHasSuffix(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
167 bool Gecko_AssertClassAttrValueIsSane(const nsAttrValue*);
168 const nsAttrValue* Gecko_GetSVGAnimatedClass(const mozilla::dom::Element*);
170 SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_,
171 const mozilla::dom::Element*)
173 SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(
174 Gecko_Snapshot, const mozilla::ServoElementSnapshot*)
176 #undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS
178 // Style attributes.
179 const mozilla::StyleLockedDeclarationBlock* Gecko_GetStyleAttrDeclarationBlock(
180 const mozilla::dom::Element* element);
182 void Gecko_UnsetDirtyStyleAttr(const mozilla::dom::Element* element);
184 const mozilla::StyleLockedDeclarationBlock*
185 Gecko_GetHTMLPresentationAttrDeclarationBlock(
186 const mozilla::dom::Element* element);
188 const mozilla::StyleLockedDeclarationBlock*
189 Gecko_GetExtraContentStyleDeclarations(const mozilla::dom::Element* element);
191 const mozilla::StyleLockedDeclarationBlock*
192 Gecko_GetUnvisitedLinkAttrDeclarationBlock(
193 const mozilla::dom::Element* element);
195 const mozilla::StyleLockedDeclarationBlock*
196 Gecko_GetVisitedLinkAttrDeclarationBlock(const mozilla::dom::Element* element);
198 const mozilla::StyleLockedDeclarationBlock*
199 Gecko_GetActiveLinkAttrDeclarationBlock(const mozilla::dom::Element* element);
201 // Visited handling.
203 // Returns whether visited styles are enabled for a given document.
204 bool Gecko_VisitedStylesEnabled(const mozilla::dom::Document*);
206 // Animations
207 bool Gecko_GetAnimationRule(
208 const mozilla::dom::Element* aElementOrPseudo,
209 mozilla::EffectCompositor::CascadeLevel aCascadeLevel,
210 mozilla::StyleAnimationValueMap* aAnimationValues);
212 bool Gecko_StyleAnimationsEquals(
213 const nsStyleAutoArray<mozilla::StyleAnimation>*,
214 const nsStyleAutoArray<mozilla::StyleAnimation>*);
216 bool Gecko_StyleScrollTimelinesEquals(
217 const nsStyleAutoArray<mozilla::StyleScrollTimeline>*,
218 const nsStyleAutoArray<mozilla::StyleScrollTimeline>*);
220 bool Gecko_StyleViewTimelinesEquals(
221 const nsStyleAutoArray<mozilla::StyleViewTimeline>*,
222 const nsStyleAutoArray<mozilla::StyleViewTimeline>*);
224 void Gecko_CopyAnimationNames(
225 nsStyleAutoArray<mozilla::StyleAnimation>* aDest,
226 const nsStyleAutoArray<mozilla::StyleAnimation>* aSrc);
228 // This function takes an already addrefed nsAtom
229 void Gecko_SetAnimationName(mozilla::StyleAnimation* aStyleAnimation,
230 nsAtom* aAtom);
232 void Gecko_UpdateAnimations(const mozilla::dom::Element* aElementOrPseudo,
233 const mozilla::ComputedStyle* aOldComputedValues,
234 const mozilla::ComputedStyle* aComputedValues,
235 mozilla::UpdateAnimationsTasks aTasks);
237 size_t Gecko_GetAnimationEffectCount(
238 const mozilla::dom::Element* aElementOrPseudo);
239 bool Gecko_ElementHasAnimations(const mozilla::dom::Element* aElementOrPseudo);
240 bool Gecko_ElementHasCSSAnimations(
241 const mozilla::dom::Element* aElementOrPseudo);
242 bool Gecko_ElementHasCSSTransitions(
243 const mozilla::dom::Element* aElementOrPseudo);
244 bool Gecko_ElementHasWebAnimations(
245 const mozilla::dom::Element* aElementOrPseudo);
246 size_t Gecko_ElementTransitions_Length(
247 const mozilla::dom::Element* aElementOrPseudo);
249 nsCSSPropertyID Gecko_ElementTransitions_PropertyAt(
250 const mozilla::dom::Element* aElementOrPseudo, size_t aIndex);
252 const mozilla::StyleAnimationValue* Gecko_ElementTransitions_EndValueAt(
253 const mozilla::dom::Element* aElementOrPseudo, size_t aIndex);
255 double Gecko_GetProgressFromComputedTiming(const mozilla::ComputedTiming*);
257 double Gecko_GetPositionInSegment(const mozilla::AnimationPropertySegment*,
258 double aProgress, bool aBeforeFlag);
260 // Get servo's AnimationValue for |aProperty| from the cached base style
261 // |aBaseStyles|.
262 // |aBaseStyles| is nsRefPtrHashtable<nsUint32HashKey, StyleAnimationValue>.
263 // We use RawServoAnimationValueTableBorrowed to avoid exposing
264 // nsRefPtrHashtable in FFI.
265 const mozilla::StyleAnimationValue* Gecko_AnimationGetBaseStyle(
266 const RawServoAnimationValueTable* aBaseStyles, nsCSSPropertyID aProperty);
268 void Gecko_StyleTransition_SetUnsupportedProperty(
269 mozilla::StyleTransition* aTransition, nsAtom* aAtom);
271 // Atoms.
272 nsAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
273 nsAtom* Gecko_Atomize16(const nsAString* aString);
274 void Gecko_AddRefAtom(nsAtom* aAtom);
275 void Gecko_ReleaseAtom(nsAtom* aAtom);
277 // will not run destructors on dst, give it uninitialized memory
278 // font_id is LookAndFeel::FontID
279 void Gecko_nsFont_InitSystem(nsFont* dst, mozilla::StyleSystemFont font_id,
280 const nsStyleFont* font,
281 const mozilla::dom::Document*);
283 void Gecko_nsFont_Destroy(nsFont* dst);
285 // The gfxFontFeatureValueSet returned from this function has zero reference.
286 gfxFontFeatureValueSet* Gecko_ConstructFontFeatureValueSet();
288 nsTArray<uint32_t>* Gecko_AppendFeatureValueHashEntry(
289 gfxFontFeatureValueSet* value_set, nsAtom* family, uint32_t alternate,
290 nsAtom* name);
292 // Font variant alternates
293 void Gecko_ClearAlternateValues(nsFont* font, size_t length);
295 void Gecko_AppendAlternateValues(nsFont* font, uint32_t alternate_name,
296 nsAtom* atom);
298 void Gecko_CopyAlternateValuesFrom(nsFont* dest, const nsFont* src);
300 // The FontPaletteValueSet returned from this function has zero reference.
301 mozilla::gfx::FontPaletteValueSet* Gecko_ConstructFontPaletteValueSet();
303 mozilla::gfx::FontPaletteValueSet::PaletteValues*
304 Gecko_AppendPaletteValueHashEntry(
305 mozilla::gfx::FontPaletteValueSet* aPaletteValueSet, nsAtom* aFamily,
306 nsAtom* aName);
308 void Gecko_SetFontPaletteBase(
309 mozilla::gfx::FontPaletteValueSet::PaletteValues* aValues,
310 int32_t aBasePaletteIndex);
312 void Gecko_SetFontPaletteOverride(
313 mozilla::gfx::FontPaletteValueSet::PaletteValues* aValues, int32_t aIndex,
314 mozilla::StyleAbsoluteColor* aColor);
316 // Visibility style
317 void Gecko_SetImageOrientation(nsStyleVisibility* aVisibility,
318 uint8_t aOrientation, bool aFlip);
320 void Gecko_SetImageOrientationAsFromImage(nsStyleVisibility* aVisibility);
322 void Gecko_CopyImageOrientationFrom(nsStyleVisibility* aDst,
323 const nsStyleVisibility* aSrc);
325 // Counter style.
326 void Gecko_CounterStyle_ToPtr(const mozilla::StyleCounterStyle*,
327 mozilla::CounterStylePtr*);
329 void Gecko_SetCounterStyleToNone(mozilla::CounterStylePtr*);
331 void Gecko_SetCounterStyleToString(mozilla::CounterStylePtr* ptr,
332 const nsACString* symbol);
334 void Gecko_CopyCounterStyle(mozilla::CounterStylePtr* dst,
335 const mozilla::CounterStylePtr* src);
337 nsAtom* Gecko_CounterStyle_GetName(const mozilla::CounterStylePtr* ptr);
339 const mozilla::AnonymousCounterStyle* Gecko_CounterStyle_GetAnonymous(
340 const mozilla::CounterStylePtr* ptr);
342 // list-style-image style.
343 void Gecko_SetListStyleImageNone(nsStyleList* style_struct);
345 void Gecko_SetListStyleImageImageValue(
346 nsStyleList* style_struct, const mozilla::StyleComputedImageUrl* url);
348 void Gecko_CopyListStyleImageFrom(nsStyleList* dest, const nsStyleList* src);
350 // Dirtiness tracking.
351 void Gecko_NoteDirtyElement(const mozilla::dom::Element*);
352 void Gecko_NoteDirtySubtreeForInvalidation(const mozilla::dom::Element*);
353 void Gecko_NoteAnimationOnlyDirtyElement(const mozilla::dom::Element*);
355 bool Gecko_AnimationNameMayBeReferencedFromStyle(const nsPresContext*,
356 nsAtom* name);
358 float Gecko_GetScrollbarInlineSize(const nsPresContext*);
360 // Incremental restyle.
361 mozilla::PseudoStyleType Gecko_GetImplementedPseudo(
362 const mozilla::dom::Element*);
364 // We'd like to return `nsChangeHint` here, but bindgen bitfield enums don't
365 // work as return values with the Linux 32-bit ABI at the moment because
366 // they wrap the value in a struct.
367 uint32_t Gecko_CalcStyleDifference(const mozilla::ComputedStyle* old_style,
368 const mozilla::ComputedStyle* new_style,
369 bool* any_style_struct_changed,
370 bool* reset_only_changed);
372 nscoord Gecko_CalcLineHeight(const mozilla::StyleLineHeight*,
373 const nsPresContext*, bool aVertical,
374 const nsStyleFont* aAgainstFont,
375 const mozilla::dom::Element* aElement);
377 // Get an element snapshot for a given element from the table.
378 const mozilla::ServoElementSnapshot* Gecko_GetElementSnapshot(
379 const mozilla::ServoElementSnapshotTable* table,
380 const mozilla::dom::Element*);
382 // Have we seen this pointer before?
383 bool Gecko_HaveSeenPtr(mozilla::SeenPtrs* table, const void* ptr);
385 // `array` must be an nsTArray
386 // If changing this signature, please update the
387 // friend function declaration in nsTArray.h
388 void Gecko_EnsureTArrayCapacity(void* array, size_t capacity, size_t elem_size);
390 // Same here, `array` must be an nsTArray<T>, for some T.
392 // Important note: Only valid for POD types, since destructors won't be run
393 // otherwise. This is ensured with rust traits for the relevant structs.
394 void Gecko_ClearPODTArray(void* array, size_t elem_size, size_t elem_align);
396 void Gecko_ResizeTArrayForStrings(nsTArray<nsString>* array, uint32_t length);
397 void Gecko_ResizeAtomArray(nsTArray<RefPtr<nsAtom>>* array, uint32_t length);
399 void Gecko_EnsureImageLayersLength(nsStyleImageLayers* layers, size_t len,
400 nsStyleImageLayers::LayerType layer_type);
402 void Gecko_EnsureStyleAnimationArrayLength(void* array, size_t len);
403 void Gecko_EnsureStyleTransitionArrayLength(void* array, size_t len);
404 void Gecko_EnsureStyleScrollTimelineArrayLength(void* array, size_t len);
405 void Gecko_EnsureStyleViewTimelineArrayLength(void* array, size_t len);
407 // Searches from the beginning of |keyframes| for a Keyframe object with the
408 // specified offset and timing function. If none is found, a new Keyframe object
409 // with the specified |offset| and |timingFunction| will be prepended to
410 // |keyframes|.
412 // @param keyframes An array of Keyframe objects, sorted by offset.
413 // The first Keyframe in the array, if any, MUST have an
414 // offset greater than or equal to |offset|.
415 // @param offset The offset to search for, or, if no suitable Keyframe is
416 // found, the offset to use for the created Keyframe.
417 // Must be a floating point number in the range [0.0, 1.0].
418 // @param timingFunction The timing function to match, or, if no suitable
419 // Keyframe is found, to set on the created Keyframe.
420 // @param composition The composition to match, or, if no suitable Keyframe is
421 // found, to set on the created Keyframe.
423 // @returns The matching or created Keyframe.
424 mozilla::Keyframe* Gecko_GetOrCreateKeyframeAtStart(
425 nsTArray<mozilla::Keyframe>* keyframes, float offset,
426 const mozilla::StyleComputedTimingFunction* timingFunction,
427 const mozilla::dom::CompositeOperationOrAuto composition);
429 // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
430 // from the beginning of |keyframes| for a Keyframe with matching timing
431 // function, composition, and an offset of 0.0.
432 // Furthermore, if a matching Keyframe is not found, a new Keyframe will be
433 // inserted after the *last* Keyframe in |keyframes| with offset 0.0.
434 mozilla::Keyframe* Gecko_GetOrCreateInitialKeyframe(
435 nsTArray<mozilla::Keyframe>* keyframes,
436 const mozilla::StyleComputedTimingFunction* timingFunction,
437 const mozilla::dom::CompositeOperationOrAuto composition);
439 // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
440 // from the *end* of |keyframes| for a Keyframe with matching timing function,
441 // composition, and an offset of 1.0. If a matching Keyframe is not found, a new
442 // Keyframe will be appended to the end of |keyframes|.
443 mozilla::Keyframe* Gecko_GetOrCreateFinalKeyframe(
444 nsTArray<mozilla::Keyframe>* keyframes,
445 const mozilla::StyleComputedTimingFunction* timingFunction,
446 const mozilla::dom::CompositeOperationOrAuto composition);
448 // Appends and returns a new PropertyValuePair to |aProperties| initialized with
449 // its mProperty member set to |aProperty| and all other members initialized to
450 // their default values.
451 mozilla::PropertyValuePair* Gecko_AppendPropertyValuePair(
452 nsTArray<mozilla::PropertyValuePair>*, nsCSSPropertyID aProperty);
454 void Gecko_ResetFilters(nsStyleEffects* effects, size_t new_len);
456 void Gecko_CopyFiltersFrom(nsStyleEffects* aSrc, nsStyleEffects* aDest);
458 void Gecko_nsStyleSVG_SetDashArrayLength(nsStyleSVG* svg, uint32_t len);
460 void Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG* dst, const nsStyleSVG* src);
462 void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* svg, uint32_t len);
464 void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* dst,
465 const nsStyleSVG* src);
467 void Gecko_GetComputedURLSpec(const mozilla::StyleComputedUrl* url,
468 nsCString* spec);
470 void Gecko_GetComputedImageURLSpec(const mozilla::StyleComputedUrl* url,
471 nsCString* spec);
473 // Return true if the given image MIME type is supported
474 bool Gecko_IsSupportedImageMimeType(const uint8_t* mime_type,
475 const uint32_t len);
477 void Gecko_nsIURI_Debug(nsIURI*, nsCString* spec);
479 void Gecko_nsIReferrerInfo_Debug(nsIReferrerInfo* aReferrerInfo,
480 nsCString* aOut);
482 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::URLExtraData, URLExtraData);
483 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsIReferrerInfo, nsIReferrerInfo);
485 void Gecko_FillAllImageLayers(nsStyleImageLayers* layers, uint32_t max_len);
487 void Gecko_LoadData_Drop(mozilla::StyleLoadData*);
489 void Gecko_nsStyleFont_SetLang(nsStyleFont* font, nsAtom* atom);
491 void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont,
492 const nsStyleFont* aSource);
494 mozilla::Length Gecko_nsStyleFont_ComputeMinSize(const nsStyleFont*,
495 const mozilla::dom::Document*);
497 // Computes the default generic font for a language.
498 mozilla::StyleGenericFontFamily
499 Gecko_nsStyleFont_ComputeFallbackFontTypeForLanguage(
500 const mozilla::dom::Document*, nsAtom* language);
502 mozilla::Length Gecko_GetBaseSize(const mozilla::dom::Document*,
503 nsAtom* language,
504 mozilla::StyleGenericFontFamily);
506 struct GeckoFontMetrics {
507 mozilla::Length mXSize;
508 mozilla::Length mChSize; // negatives indicate not found.
509 mozilla::Length mCapHeight; // negatives indicate not found.
510 mozilla::Length mIcWidth; // negatives indicate not found.
511 mozilla::Length mAscent;
512 mozilla::Length mComputedEmSize;
513 float mScriptPercentScaleDown; // zero is invalid or means not found.
514 float mScriptScriptPercentScaleDown; // zero is invalid or means not found.
517 GeckoFontMetrics Gecko_GetFontMetrics(const nsPresContext*, bool is_vertical,
518 const nsStyleFont* font,
519 mozilla::Length font_size,
520 bool use_user_font_set,
521 bool retrieve_math_scales);
523 mozilla::StyleSheet* Gecko_StyleSheet_Clone(
524 const mozilla::StyleSheet* aSheet,
525 const mozilla::StyleSheet* aNewParentSheet);
527 void Gecko_StyleSheet_AddRef(const mozilla::StyleSheet* aSheet);
528 void Gecko_StyleSheet_Release(const mozilla::StyleSheet* aSheet);
529 bool Gecko_IsDocumentBody(const mozilla::dom::Element* element);
531 bool Gecko_IsDarkColorScheme(const mozilla::dom::Document*,
532 const mozilla::StyleColorScheme*);
533 nscolor Gecko_ComputeSystemColor(mozilla::StyleSystemColor,
534 const mozilla::dom::Document*,
535 const mozilla::StyleColorScheme*);
537 // We use an int32_t here instead of a LookAndFeel::IntID/FloatID because
538 // forward-declaring a nested enum/struct is impossible.
539 int32_t Gecko_GetLookAndFeelInt(int32_t int_id);
540 float Gecko_GetLookAndFeelFloat(int32_t float_id);
542 void Gecko_AddPropertyToSet(nsCSSPropertyIDSet*, nsCSSPropertyID);
544 // Style-struct management.
545 #define STYLE_STRUCT(name) \
546 void Gecko_Construct_Default_nsStyle##name(nsStyle##name* ptr, \
547 const mozilla::dom::Document*); \
548 void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \
549 const nsStyle##name* other); \
550 void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr);
551 #include "nsStyleStructList.h"
552 #undef STYLE_STRUCT
554 bool Gecko_DocumentRule_UseForPresentation(
555 const mozilla::dom::Document*, const nsACString* aPattern,
556 mozilla::css::DocumentMatchingFunction);
558 // Allocator hinting.
559 void Gecko_SetJemallocThreadLocalArena(bool enabled);
561 // Pseudo-element flags.
562 #define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
563 const uint32_t SERVO_CSS_PSEUDO_ELEMENT_FLAGS_##name_ = flags_;
564 #include "nsCSSPseudoElementList.h"
565 #undef CSS_PSEUDO_ELEMENT
567 bool Gecko_ErrorReportingEnabled(const mozilla::StyleSheet* sheet,
568 const mozilla::css::Loader* loader,
569 uint64_t* aOutWindowId);
571 void Gecko_ReportUnexpectedCSSError(
572 uint64_t windowId, nsIURI* uri, const char* message, const char* param,
573 uint32_t paramLen, const char* prefix, const char* prefixParam,
574 uint32_t prefixParamLen, const char* suffix, const char* source,
575 uint32_t sourceLen, const char* selectors, uint32_t selectorsLen,
576 uint32_t lineNumber, uint32_t colNumber);
578 // DOM APIs.
579 void Gecko_ContentList_AppendAll(nsSimpleContentList* aContentList,
580 const mozilla::dom::Element** aElements,
581 size_t aLength);
583 // FIXME(emilio): These two below should be a single function that takes a
584 // `const DocumentOrShadowRoot*`, but that doesn't make MSVC builds happy for a
585 // reason I haven't really dug into.
586 const nsTArray<mozilla::dom::Element*>* Gecko_Document_GetElementsWithId(
587 const mozilla::dom::Document*, nsAtom* aId);
589 const nsTArray<mozilla::dom::Element*>* Gecko_ShadowRoot_GetElementsWithId(
590 const mozilla::dom::ShadowRoot*, nsAtom* aId);
592 bool Gecko_ComputeBoolPrefMediaQuery(nsAtom*);
594 // Check whether font format/tech is supported.
595 bool Gecko_IsFontFormatSupported(
596 mozilla::StyleFontFaceSourceFormatKeyword aFormat);
597 bool Gecko_IsFontTechSupported(mozilla::StyleFontFaceSourceTechFlags aFlag);
599 bool Gecko_IsKnownIconFontFamily(const nsAtom* aFamilyName);
601 // Returns true if we're currently performing the servo traversal.
602 bool Gecko_IsInServoTraversal();
604 // Returns true if we're currently on the main thread.
605 bool Gecko_IsMainThread();
607 // Returns true if we're currently on a DOM worker thread.
608 bool Gecko_IsDOMWorkerThread();
610 // Returns the preferred number of style threads to use, or -1 for no
611 // preference.
612 int32_t Gecko_GetNumStyleThreads();
614 // Media feature helpers.
616 // Defined in nsMediaFeatures.cpp.
617 mozilla::StyleDisplayMode Gecko_MediaFeatures_GetDisplayMode(
618 const mozilla::dom::Document*);
620 bool Gecko_MediaFeatures_ShouldAvoidNativeTheme(const mozilla::dom::Document*);
621 bool Gecko_MediaFeatures_UseOverlayScrollbars(const mozilla::dom::Document*);
622 int32_t Gecko_MediaFeatures_GetColorDepth(const mozilla::dom::Document*);
623 int32_t Gecko_MediaFeatures_GetMonochromeBitsPerPixel(
624 const mozilla::dom::Document*);
625 mozilla::dom::ScreenColorGamut Gecko_MediaFeatures_ColorGamut(
626 const mozilla::dom::Document*);
628 void Gecko_MediaFeatures_GetDeviceSize(const mozilla::dom::Document*,
629 nscoord* width, nscoord* height);
631 float Gecko_MediaFeatures_GetResolution(const mozilla::dom::Document*);
632 bool Gecko_MediaFeatures_PrefersReducedMotion(const mozilla::dom::Document*);
633 bool Gecko_MediaFeatures_PrefersReducedTransparency(
634 const mozilla::dom::Document*);
635 mozilla::StylePrefersContrast Gecko_MediaFeatures_PrefersContrast(
636 const mozilla::dom::Document*);
637 mozilla::StylePrefersColorScheme Gecko_MediaFeatures_PrefersColorScheme(
638 const mozilla::dom::Document*, bool aUseContent);
639 bool Gecko_MediaFeatures_InvertedColors(const mozilla::dom::Document*);
640 mozilla::StyleScripting Gecko_MediaFeatures_Scripting(
641 const mozilla::dom::Document*);
643 mozilla::StyleDynamicRange Gecko_MediaFeatures_DynamicRange(
644 const mozilla::dom::Document*);
645 mozilla::StyleDynamicRange Gecko_MediaFeatures_VideoDynamicRange(
646 const mozilla::dom::Document*);
648 mozilla::PointerCapabilities Gecko_MediaFeatures_PrimaryPointerCapabilities(
649 const mozilla::dom::Document*);
651 mozilla::PointerCapabilities Gecko_MediaFeatures_AllPointerCapabilities(
652 const mozilla::dom::Document*);
654 float Gecko_MediaFeatures_GetDevicePixelRatio(const mozilla::dom::Document*);
656 bool Gecko_MediaFeatures_IsResourceDocument(const mozilla::dom::Document*);
657 bool Gecko_MediaFeatures_MatchesPlatform(mozilla::StylePlatform);
659 void Gecko_GetSafeAreaInsets(const nsPresContext*, float*, float*, float*,
660 float*);
662 void Gecko_PrintfStderr(const nsCString*);
664 } // extern "C"
666 #endif // mozilla_GeckoBindings_h