Bug 1879449 [wpt PR 44489] - [wptrunner] Add `infrastructure/expected-fail/` test...
[gecko.git] / layout / style / GeckoBindings.h
blob7bb839ae18835d128dc9285b7f9dc5b5e06335af
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_IsSelectListBox(const mozilla::dom::Element* element);
154 // Attributes.
155 #define SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_) \
156 nsAtom* prefix_##LangValue(implementor_ element);
158 bool Gecko_AttrEquals(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
159 bool Gecko_AttrDashEquals(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
160 bool Gecko_AttrIncludes(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
161 bool Gecko_AttrHasSubstring(const nsAttrValue*, const nsAtom*,
162 bool aIgnoreCase);
163 bool Gecko_AttrHasPrefix(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
164 bool Gecko_AttrHasSuffix(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
166 bool Gecko_AssertClassAttrValueIsSane(const nsAttrValue*);
167 const nsAttrValue* Gecko_GetSVGAnimatedClass(const mozilla::dom::Element*);
169 SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_,
170 const mozilla::dom::Element*)
172 SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(
173 Gecko_Snapshot, const mozilla::ServoElementSnapshot*)
175 #undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS
177 // Style attributes.
178 const mozilla::StyleLockedDeclarationBlock* Gecko_GetStyleAttrDeclarationBlock(
179 const mozilla::dom::Element* element);
181 void Gecko_UnsetDirtyStyleAttr(const mozilla::dom::Element* element);
183 const mozilla::StyleLockedDeclarationBlock*
184 Gecko_GetHTMLPresentationAttrDeclarationBlock(
185 const mozilla::dom::Element* element);
187 const mozilla::StyleLockedDeclarationBlock*
188 Gecko_GetExtraContentStyleDeclarations(const mozilla::dom::Element* element);
190 const mozilla::StyleLockedDeclarationBlock*
191 Gecko_GetUnvisitedLinkAttrDeclarationBlock(
192 const mozilla::dom::Element* element);
194 const mozilla::StyleLockedDeclarationBlock*
195 Gecko_GetVisitedLinkAttrDeclarationBlock(const mozilla::dom::Element* element);
197 const mozilla::StyleLockedDeclarationBlock*
198 Gecko_GetActiveLinkAttrDeclarationBlock(const mozilla::dom::Element* element);
200 // Visited handling.
202 // Returns whether visited styles are enabled for a given document.
203 bool Gecko_VisitedStylesEnabled(const mozilla::dom::Document*);
205 // Animations
206 bool Gecko_GetAnimationRule(
207 const mozilla::dom::Element* aElementOrPseudo,
208 mozilla::EffectCompositor::CascadeLevel aCascadeLevel,
209 mozilla::StyleAnimationValueMap* aAnimationValues);
211 bool Gecko_StyleAnimationsEquals(
212 const nsStyleAutoArray<mozilla::StyleAnimation>*,
213 const nsStyleAutoArray<mozilla::StyleAnimation>*);
215 bool Gecko_StyleScrollTimelinesEquals(
216 const nsStyleAutoArray<mozilla::StyleScrollTimeline>*,
217 const nsStyleAutoArray<mozilla::StyleScrollTimeline>*);
219 bool Gecko_StyleViewTimelinesEquals(
220 const nsStyleAutoArray<mozilla::StyleViewTimeline>*,
221 const nsStyleAutoArray<mozilla::StyleViewTimeline>*);
223 void Gecko_UpdateAnimations(const mozilla::dom::Element* aElementOrPseudo,
224 const mozilla::ComputedStyle* aOldComputedValues,
225 const mozilla::ComputedStyle* aComputedValues,
226 mozilla::UpdateAnimationsTasks aTasks);
228 size_t Gecko_GetAnimationEffectCount(
229 const mozilla::dom::Element* aElementOrPseudo);
230 bool Gecko_ElementHasAnimations(const mozilla::dom::Element* aElementOrPseudo);
231 bool Gecko_ElementHasCSSAnimations(
232 const mozilla::dom::Element* aElementOrPseudo);
233 bool Gecko_ElementHasCSSTransitions(
234 const mozilla::dom::Element* aElementOrPseudo);
235 bool Gecko_ElementHasWebAnimations(
236 const mozilla::dom::Element* aElementOrPseudo);
237 size_t Gecko_ElementTransitions_Length(
238 const mozilla::dom::Element* aElementOrPseudo);
240 nsCSSPropertyID Gecko_ElementTransitions_PropertyAt(
241 const mozilla::dom::Element* aElementOrPseudo, size_t aIndex);
243 const mozilla::StyleAnimationValue* Gecko_ElementTransitions_EndValueAt(
244 const mozilla::dom::Element* aElementOrPseudo, size_t aIndex);
246 double Gecko_GetProgressFromComputedTiming(const mozilla::ComputedTiming*);
248 double Gecko_GetPositionInSegment(const mozilla::AnimationPropertySegment*,
249 double aProgress, bool aBeforeFlag);
251 // Get servo's AnimationValue for |aProperty| from the cached base style
252 // |aBaseStyles|.
253 // |aBaseStyles| is nsRefPtrHashtable<nsGenericHashKey<AnimatedPropertyID>,
254 // StyleAnimationValue>.
255 // We use RawServoAnimationValueTableBorrowed to avoid exposing
256 // nsRefPtrHashtable in FFI.
257 const mozilla::StyleAnimationValue* Gecko_AnimationGetBaseStyle(
258 const RawServoAnimationValueTable* aBaseStyles,
259 const mozilla::AnimatedPropertyID* aProperty);
261 void Gecko_StyleTransition_SetUnsupportedProperty(
262 mozilla::StyleTransition* aTransition, nsAtom* aAtom);
264 // Atoms.
265 nsAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
266 nsAtom* Gecko_Atomize16(const nsAString* aString);
267 void Gecko_AddRefAtom(nsAtom* aAtom);
268 void Gecko_ReleaseAtom(nsAtom* aAtom);
270 // will not run destructors on dst, give it uninitialized memory
271 // font_id is LookAndFeel::FontID
272 void Gecko_nsFont_InitSystem(nsFont* dst, mozilla::StyleSystemFont font_id,
273 const nsStyleFont* font,
274 const mozilla::dom::Document*);
276 void Gecko_nsFont_Destroy(nsFont* dst);
278 // The gfxFontFeatureValueSet returned from this function has zero reference.
279 gfxFontFeatureValueSet* Gecko_ConstructFontFeatureValueSet();
281 nsTArray<uint32_t>* Gecko_AppendFeatureValueHashEntry(
282 gfxFontFeatureValueSet* value_set, nsAtom* family, uint32_t alternate,
283 nsAtom* name);
285 // Font variant alternates
286 void Gecko_ClearAlternateValues(nsFont* font, size_t length);
288 void Gecko_AppendAlternateValues(nsFont* font, uint32_t alternate_name,
289 nsAtom* atom);
291 void Gecko_CopyAlternateValuesFrom(nsFont* dest, const nsFont* src);
293 // The FontPaletteValueSet returned from this function has zero reference.
294 mozilla::gfx::FontPaletteValueSet* Gecko_ConstructFontPaletteValueSet();
296 mozilla::gfx::FontPaletteValueSet::PaletteValues*
297 Gecko_AppendPaletteValueHashEntry(
298 mozilla::gfx::FontPaletteValueSet* aPaletteValueSet, nsAtom* aFamily,
299 nsAtom* aName);
301 void Gecko_SetFontPaletteBase(
302 mozilla::gfx::FontPaletteValueSet::PaletteValues* aValues,
303 int32_t aBasePaletteIndex);
305 void Gecko_SetFontPaletteOverride(
306 mozilla::gfx::FontPaletteValueSet::PaletteValues* aValues, int32_t aIndex,
307 mozilla::StyleAbsoluteColor* aColor);
309 // Visibility style
310 void Gecko_SetImageOrientation(nsStyleVisibility* aVisibility,
311 uint8_t aOrientation, bool aFlip);
313 void Gecko_SetImageOrientationAsFromImage(nsStyleVisibility* aVisibility);
315 void Gecko_CopyImageOrientationFrom(nsStyleVisibility* aDst,
316 const nsStyleVisibility* aSrc);
318 // Counter style.
319 void Gecko_CounterStyle_ToPtr(const mozilla::StyleCounterStyle*,
320 mozilla::CounterStylePtr*);
322 void Gecko_SetCounterStyleToNone(mozilla::CounterStylePtr*);
324 void Gecko_SetCounterStyleToString(mozilla::CounterStylePtr* ptr,
325 const nsACString* symbol);
327 void Gecko_CopyCounterStyle(mozilla::CounterStylePtr* dst,
328 const mozilla::CounterStylePtr* src);
330 nsAtom* Gecko_CounterStyle_GetName(const mozilla::CounterStylePtr* ptr);
332 const mozilla::AnonymousCounterStyle* Gecko_CounterStyle_GetAnonymous(
333 const mozilla::CounterStylePtr* ptr);
335 // list-style-image style.
336 void Gecko_SetListStyleImageNone(nsStyleList* style_struct);
338 void Gecko_SetListStyleImageImageValue(
339 nsStyleList* style_struct, const mozilla::StyleComputedImageUrl* url);
341 void Gecko_CopyListStyleImageFrom(nsStyleList* dest, const nsStyleList* src);
343 // Dirtiness tracking.
344 void Gecko_NoteDirtyElement(const mozilla::dom::Element*);
345 void Gecko_NoteDirtySubtreeForInvalidation(const mozilla::dom::Element*);
346 void Gecko_NoteAnimationOnlyDirtyElement(const mozilla::dom::Element*);
348 bool Gecko_AnimationNameMayBeReferencedFromStyle(const nsPresContext*,
349 nsAtom* name);
351 float Gecko_GetScrollbarInlineSize(const nsPresContext*);
353 // Incremental restyle.
354 mozilla::PseudoStyleType Gecko_GetImplementedPseudo(
355 const mozilla::dom::Element*);
357 // We'd like to return `nsChangeHint` here, but bindgen bitfield enums don't
358 // work as return values with the Linux 32-bit ABI at the moment because
359 // they wrap the value in a struct.
360 uint32_t Gecko_CalcStyleDifference(const mozilla::ComputedStyle* old_style,
361 const mozilla::ComputedStyle* new_style,
362 bool* any_style_struct_changed,
363 bool* reset_only_changed);
365 nscoord Gecko_CalcLineHeight(const mozilla::StyleLineHeight*,
366 const nsPresContext*, bool aVertical,
367 const nsStyleFont* aAgainstFont,
368 const mozilla::dom::Element* aElement);
370 // Get an element snapshot for a given element from the table.
371 const mozilla::ServoElementSnapshot* Gecko_GetElementSnapshot(
372 const mozilla::ServoElementSnapshotTable* table,
373 const mozilla::dom::Element*);
375 // Have we seen this pointer before?
376 bool Gecko_HaveSeenPtr(mozilla::SeenPtrs* table, const void* ptr);
378 // `array` must be an nsTArray
379 // If changing this signature, please update the
380 // friend function declaration in nsTArray.h
381 void Gecko_EnsureTArrayCapacity(void* array, size_t capacity, size_t elem_size);
383 // Same here, `array` must be an nsTArray<T>, for some T.
385 // Important note: Only valid for POD types, since destructors won't be run
386 // otherwise. This is ensured with rust traits for the relevant structs.
387 void Gecko_ClearPODTArray(void* array, size_t elem_size, size_t elem_align);
389 void Gecko_ResizeTArrayForStrings(nsTArray<nsString>* array, uint32_t length);
390 void Gecko_ResizeAtomArray(nsTArray<RefPtr<nsAtom>>* array, uint32_t length);
392 void Gecko_EnsureImageLayersLength(nsStyleImageLayers* layers, size_t len,
393 nsStyleImageLayers::LayerType layer_type);
395 void Gecko_EnsureStyleAnimationArrayLength(void* array, size_t len);
396 void Gecko_EnsureStyleTransitionArrayLength(void* array, size_t len);
397 void Gecko_EnsureStyleScrollTimelineArrayLength(void* array, size_t len);
398 void Gecko_EnsureStyleViewTimelineArrayLength(void* array, size_t len);
400 // Searches from the beginning of |keyframes| for a Keyframe object with the
401 // specified offset and timing function. If none is found, a new Keyframe object
402 // with the specified |offset| and |timingFunction| will be prepended to
403 // |keyframes|.
405 // @param keyframes An array of Keyframe objects, sorted by offset.
406 // The first Keyframe in the array, if any, MUST have an
407 // offset greater than or equal to |offset|.
408 // @param offset The offset to search for, or, if no suitable Keyframe is
409 // found, the offset to use for the created Keyframe.
410 // Must be a floating point number in the range [0.0, 1.0].
411 // @param timingFunction The timing function to match, or, if no suitable
412 // Keyframe is found, to set on the created Keyframe.
413 // @param composition The composition to match, or, if no suitable Keyframe is
414 // found, to set on the created Keyframe.
416 // @returns The matching or created Keyframe.
417 mozilla::Keyframe* Gecko_GetOrCreateKeyframeAtStart(
418 nsTArray<mozilla::Keyframe>* keyframes, float offset,
419 const mozilla::StyleComputedTimingFunction* timingFunction,
420 const mozilla::dom::CompositeOperationOrAuto composition);
422 // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
423 // from the beginning of |keyframes| for a Keyframe with matching timing
424 // function, composition, and an offset of 0.0.
425 // Furthermore, if a matching Keyframe is not found, a new Keyframe will be
426 // inserted after the *last* Keyframe in |keyframes| with offset 0.0.
427 mozilla::Keyframe* Gecko_GetOrCreateInitialKeyframe(
428 nsTArray<mozilla::Keyframe>* keyframes,
429 const mozilla::StyleComputedTimingFunction* timingFunction,
430 const mozilla::dom::CompositeOperationOrAuto composition);
432 // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
433 // from the *end* of |keyframes| for a Keyframe with matching timing function,
434 // composition, and an offset of 1.0. If a matching Keyframe is not found, a new
435 // Keyframe will be appended to the end of |keyframes|.
436 mozilla::Keyframe* Gecko_GetOrCreateFinalKeyframe(
437 nsTArray<mozilla::Keyframe>* keyframes,
438 const mozilla::StyleComputedTimingFunction* timingFunction,
439 const mozilla::dom::CompositeOperationOrAuto composition);
441 // Appends and returns a new PropertyValuePair to |aProperties| initialized with
442 // its mProperty member set to |aProperty| and all other members initialized to
443 // their default values.
444 mozilla::PropertyValuePair* Gecko_AppendPropertyValuePair(
445 nsTArray<mozilla::PropertyValuePair>*,
446 const mozilla::AnimatedPropertyID* aProperty);
448 void Gecko_ResetFilters(nsStyleEffects* effects, size_t new_len);
450 void Gecko_CopyFiltersFrom(nsStyleEffects* aSrc, nsStyleEffects* aDest);
452 void Gecko_nsStyleSVG_SetDashArrayLength(nsStyleSVG* svg, uint32_t len);
454 void Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG* dst, const nsStyleSVG* src);
456 void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* svg, uint32_t len);
458 void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* dst,
459 const nsStyleSVG* src);
461 void Gecko_GetComputedURLSpec(const mozilla::StyleComputedUrl* url,
462 nsCString* spec);
464 void Gecko_GetComputedImageURLSpec(const mozilla::StyleComputedUrl* url,
465 nsCString* spec);
467 // Return true if the given image MIME type is supported
468 bool Gecko_IsSupportedImageMimeType(const uint8_t* mime_type,
469 const uint32_t len);
471 void Gecko_nsIURI_Debug(nsIURI*, nsCString* spec);
473 void Gecko_nsIReferrerInfo_Debug(nsIReferrerInfo* aReferrerInfo,
474 nsCString* aOut);
476 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::URLExtraData, URLExtraData);
477 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsIReferrerInfo, nsIReferrerInfo);
479 void Gecko_FillAllImageLayers(nsStyleImageLayers* layers, uint32_t max_len);
481 void Gecko_LoadData_Drop(mozilla::StyleLoadData*);
483 void Gecko_nsStyleFont_SetLang(nsStyleFont* font, nsAtom* atom);
485 void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont,
486 const nsStyleFont* aSource);
488 mozilla::Length Gecko_nsStyleFont_ComputeMinSize(const nsStyleFont*,
489 const mozilla::dom::Document*);
491 // Computes the default generic font for a language.
492 mozilla::StyleGenericFontFamily
493 Gecko_nsStyleFont_ComputeFallbackFontTypeForLanguage(
494 const mozilla::dom::Document*, nsAtom* language);
496 mozilla::Length Gecko_GetBaseSize(const mozilla::dom::Document*,
497 nsAtom* language,
498 mozilla::StyleGenericFontFamily);
500 struct GeckoFontMetrics {
501 mozilla::Length mXSize;
502 mozilla::Length mChSize; // negatives indicate not found.
503 mozilla::Length mCapHeight; // negatives indicate not found.
504 mozilla::Length mIcWidth; // negatives indicate not found.
505 mozilla::Length mAscent;
506 mozilla::Length mComputedEmSize;
507 float mScriptPercentScaleDown; // zero is invalid or means not found.
508 float mScriptScriptPercentScaleDown; // zero is invalid or means not found.
511 GeckoFontMetrics Gecko_GetFontMetrics(const nsPresContext*, bool is_vertical,
512 const nsStyleFont* font,
513 mozilla::Length font_size,
514 bool use_user_font_set,
515 bool retrieve_math_scales);
517 mozilla::StyleSheet* Gecko_StyleSheet_Clone(
518 const mozilla::StyleSheet* aSheet,
519 const mozilla::StyleSheet* aNewParentSheet);
521 void Gecko_StyleSheet_AddRef(const mozilla::StyleSheet* aSheet);
522 void Gecko_StyleSheet_Release(const mozilla::StyleSheet* aSheet);
523 bool Gecko_IsDocumentBody(const mozilla::dom::Element* element);
525 bool Gecko_IsDarkColorScheme(const mozilla::dom::Document*,
526 const mozilla::StyleColorScheme*);
527 nscolor Gecko_ComputeSystemColor(mozilla::StyleSystemColor,
528 const mozilla::dom::Document*,
529 const mozilla::StyleColorScheme*);
531 // We use an int32_t here instead of a LookAndFeel::IntID/FloatID because
532 // forward-declaring a nested enum/struct is impossible.
533 int32_t Gecko_GetLookAndFeelInt(int32_t int_id);
534 float Gecko_GetLookAndFeelFloat(int32_t float_id);
536 void Gecko_AddPropertyToSet(nsCSSPropertyIDSet*, nsCSSPropertyID);
538 // Style-struct management.
539 #define STYLE_STRUCT(name) \
540 void Gecko_Construct_Default_nsStyle##name(nsStyle##name* ptr, \
541 const mozilla::dom::Document*); \
542 void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \
543 const nsStyle##name* other); \
544 void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr);
545 #include "nsStyleStructList.h"
546 #undef STYLE_STRUCT
548 bool Gecko_DocumentRule_UseForPresentation(
549 const mozilla::dom::Document*, const nsACString* aPattern,
550 mozilla::css::DocumentMatchingFunction);
552 // Allocator hinting.
553 void Gecko_SetJemallocThreadLocalArena(bool enabled);
555 // Pseudo-element flags.
556 #define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
557 const uint32_t SERVO_CSS_PSEUDO_ELEMENT_FLAGS_##name_ = flags_;
558 #include "nsCSSPseudoElementList.h"
559 #undef CSS_PSEUDO_ELEMENT
561 bool Gecko_ErrorReportingEnabled(const mozilla::StyleSheet* sheet,
562 const mozilla::css::Loader* loader,
563 uint64_t* aOutWindowId);
565 void Gecko_ReportUnexpectedCSSError(
566 uint64_t windowId, nsIURI* uri, const char* message, const char* param,
567 uint32_t paramLen, const char* prefix, const char* prefixParam,
568 uint32_t prefixParamLen, const char* suffix, const char* source,
569 uint32_t sourceLen, const char* selectors, uint32_t selectorsLen,
570 uint32_t lineNumber, uint32_t colNumber);
572 // DOM APIs.
573 void Gecko_ContentList_AppendAll(nsSimpleContentList* aContentList,
574 const mozilla::dom::Element** aElements,
575 size_t aLength);
577 // FIXME(emilio): These two below should be a single function that takes a
578 // `const DocumentOrShadowRoot*`, but that doesn't make MSVC builds happy for a
579 // reason I haven't really dug into.
580 const nsTArray<mozilla::dom::Element*>* Gecko_Document_GetElementsWithId(
581 const mozilla::dom::Document*, nsAtom* aId);
583 const nsTArray<mozilla::dom::Element*>* Gecko_ShadowRoot_GetElementsWithId(
584 const mozilla::dom::ShadowRoot*, nsAtom* aId);
586 bool Gecko_ComputeBoolPrefMediaQuery(nsAtom*);
588 // Check whether font format/tech is supported.
589 bool Gecko_IsFontFormatSupported(
590 mozilla::StyleFontFaceSourceFormatKeyword aFormat);
591 bool Gecko_IsFontTechSupported(mozilla::StyleFontFaceSourceTechFlags aFlag);
593 bool Gecko_IsKnownIconFontFamily(const nsAtom* aFamilyName);
595 // Returns true if we're currently performing the servo traversal.
596 bool Gecko_IsInServoTraversal();
598 // Returns true if we're currently on the main thread.
599 bool Gecko_IsMainThread();
601 // Returns true if we're currently on a DOM worker thread.
602 bool Gecko_IsDOMWorkerThread();
604 // Returns the preferred number of style threads to use, or -1 for no
605 // preference.
606 int32_t Gecko_GetNumStyleThreads();
608 // Media feature helpers.
610 // Defined in nsMediaFeatures.cpp.
611 mozilla::StyleDisplayMode Gecko_MediaFeatures_GetDisplayMode(
612 const mozilla::dom::Document*);
614 bool Gecko_MediaFeatures_UseOverlayScrollbars(const mozilla::dom::Document*);
615 int32_t Gecko_MediaFeatures_GetColorDepth(const mozilla::dom::Document*);
616 int32_t Gecko_MediaFeatures_GetMonochromeBitsPerPixel(
617 const mozilla::dom::Document*);
618 mozilla::dom::ScreenColorGamut Gecko_MediaFeatures_ColorGamut(
619 const mozilla::dom::Document*);
621 void Gecko_MediaFeatures_GetDeviceSize(const mozilla::dom::Document*,
622 nscoord* width, nscoord* height);
624 float Gecko_MediaFeatures_GetResolution(const mozilla::dom::Document*);
625 bool Gecko_MediaFeatures_PrefersReducedMotion(const mozilla::dom::Document*);
626 bool Gecko_MediaFeatures_PrefersReducedTransparency(
627 const mozilla::dom::Document*);
628 mozilla::StylePrefersContrast Gecko_MediaFeatures_PrefersContrast(
629 const mozilla::dom::Document*);
630 mozilla::StylePrefersColorScheme Gecko_MediaFeatures_PrefersColorScheme(
631 const mozilla::dom::Document*, bool aUseContent);
632 bool Gecko_MediaFeatures_InvertedColors(const mozilla::dom::Document*);
633 mozilla::StyleScripting Gecko_MediaFeatures_Scripting(
634 const mozilla::dom::Document*);
636 mozilla::StyleDynamicRange Gecko_MediaFeatures_DynamicRange(
637 const mozilla::dom::Document*);
638 mozilla::StyleDynamicRange Gecko_MediaFeatures_VideoDynamicRange(
639 const mozilla::dom::Document*);
641 mozilla::PointerCapabilities Gecko_MediaFeatures_PrimaryPointerCapabilities(
642 const mozilla::dom::Document*);
644 mozilla::PointerCapabilities Gecko_MediaFeatures_AllPointerCapabilities(
645 const mozilla::dom::Document*);
647 float Gecko_MediaFeatures_GetDevicePixelRatio(const mozilla::dom::Document*);
649 bool Gecko_MediaFeatures_IsResourceDocument(const mozilla::dom::Document*);
650 bool Gecko_MediaFeatures_MatchesPlatform(mozilla::StylePlatform);
651 mozilla::StyleGtkThemeFamily Gecko_MediaFeatures_GtkThemeFamily();
653 void Gecko_GetSafeAreaInsets(const nsPresContext*, float*, float*, float*,
654 float*);
656 void Gecko_PrintfStderr(const nsCString*);
658 } // extern "C"
660 #endif // mozilla_GeckoBindings_h