Bug 1637593 [wpt PR 23564] - Fix superclass calls in MarionetteRefTestExecutor, a...
[gecko.git] / layout / style / GeckoBindings.h
blob9851ddf421cbfef6c176814dd5be18a8b23b20ed
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/EffectCompositor.h"
19 #include "mozilla/ComputedTimingFunction.h"
20 #include "mozilla/PreferenceSheet.h"
21 #include "nsStyleStruct.h"
23 class nsAtom;
24 class nsIURI;
25 class nsSimpleContentList;
26 struct nsFont;
27 class ServoComputedData;
29 namespace mozilla {
30 class ComputedStyle;
31 class SeenPtrs;
32 class ServoElementSnapshot;
33 class ServoElementSnapshotTable;
34 class SharedFontList;
35 class StyleSheet;
36 enum class PseudoStyleType : uint8_t;
37 enum class PointerCapabilities : uint8_t;
38 enum class UpdateAnimationsTasks : uint8_t;
39 struct FontFamilyName;
40 struct Keyframe;
42 namespace css {
43 class LoaderReusableStyleSheets;
45 } // namespace mozilla
47 #ifdef NIGHTLY_BUILD
48 const bool GECKO_IS_NIGHTLY = true;
49 #else
50 const bool GECKO_IS_NIGHTLY = false;
51 #endif
53 #define NS_DECL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \
54 void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr); \
55 void Gecko_Release##name_##ArbitraryThread(class_* aPtr);
56 #define NS_IMPL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \
57 static_assert(class_::HasThreadSafeRefCnt::value, \
58 "NS_DECL_THREADSAFE_FFI_REFCOUNTING can only be used with " \
59 "classes that have thread-safe refcounting"); \
60 void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr) { NS_ADDREF(aPtr); } \
61 void Gecko_Release##name_##ArbitraryThread(class_* aPtr) { NS_RELEASE(aPtr); }
63 extern "C" {
65 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsIURI, nsIURI);
67 // Debugging stuff.
68 void Gecko_Element_DebugListAttributes(const mozilla::dom::Element*,
69 nsCString*);
71 void Gecko_Snapshot_DebugListAttributes(const mozilla::ServoElementSnapshot*,
72 nsCString*);
74 bool Gecko_IsSignificantChild(const nsINode*, bool whitespace_is_significant);
76 const nsINode* Gecko_GetLastChild(const nsINode*);
77 const nsINode* Gecko_GetPreviousSibling(const nsINode*);
79 const nsINode* Gecko_GetFlattenedTreeParentNode(const nsINode*);
80 const mozilla::dom::Element* Gecko_GetBeforeOrAfterPseudo(
81 const mozilla::dom::Element*, bool is_before);
82 const mozilla::dom::Element* Gecko_GetMarkerPseudo(
83 const mozilla::dom::Element*);
85 nsTArray<nsIContent*>* Gecko_GetAnonymousContentForElement(
86 const mozilla::dom::Element*);
87 void Gecko_DestroyAnonymousContentList(nsTArray<nsIContent*>* anon_content);
89 const nsTArray<RefPtr<nsINode>>* Gecko_GetAssignedNodes(
90 const mozilla::dom::Element*);
92 void Gecko_ComputedStyle_Init(mozilla::ComputedStyle* context,
93 const ServoComputedData* values,
94 mozilla::PseudoStyleType pseudo_type);
96 void Gecko_ComputedStyle_Destroy(mozilla::ComputedStyle* context);
98 // By default, Servo walks the DOM by traversing the siblings of the DOM-view
99 // first child. This generally works, but misses anonymous children, which we
100 // want to traverse during styling. To support these cases, we create an
101 // optional stack-allocated iterator in aIterator for nodes that need it.
102 void Gecko_ConstructStyleChildrenIterator(const mozilla::dom::Element*,
103 mozilla::dom::StyleChildrenIterator*);
105 void Gecko_DestroyStyleChildrenIterator(mozilla::dom::StyleChildrenIterator*);
107 const nsINode* Gecko_GetNextStyleChild(mozilla::dom::StyleChildrenIterator*);
109 nsAtom* Gecko_Element_ImportedPart(const nsAttrValue*, nsAtom*);
110 nsAtom** Gecko_Element_ExportedParts(const nsAttrValue*, nsAtom*,
111 size_t* aOutLength);
113 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::SheetLoadDataHolder,
114 SheetLoadDataHolder);
116 void Gecko_StyleSheet_FinishAsyncParse(
117 mozilla::css::SheetLoadDataHolder* data,
118 mozilla::StyleStrong<RawServoStyleSheetContents> sheet_contents,
119 mozilla::StyleOwnedOrNull<StyleUseCounters> use_counters);
121 mozilla::StyleSheet* Gecko_LoadStyleSheet(
122 mozilla::css::Loader* loader, mozilla::StyleSheet* parent,
123 mozilla::css::SheetLoadData* parent_load_data,
124 mozilla::css::LoaderReusableStyleSheets* reusable_sheets,
125 const mozilla::StyleCssUrl* url,
126 mozilla::StyleStrong<RawServoMediaList> media_list);
128 void Gecko_LoadStyleSheetAsync(mozilla::css::SheetLoadDataHolder* parent_data,
129 const mozilla::StyleCssUrl* url,
130 mozilla::StyleStrong<RawServoMediaList>,
131 mozilla::StyleStrong<RawServoImportRule>);
133 // Selector Matching.
134 uint64_t Gecko_ElementState(const mozilla::dom::Element*);
135 bool Gecko_IsRootElement(const mozilla::dom::Element*);
137 bool Gecko_MatchLang(const mozilla::dom::Element*, nsAtom* override_lang,
138 bool has_override_lang, const char16_t* value);
140 nsAtom* Gecko_GetXMLLangValue(const mozilla::dom::Element*);
142 mozilla::dom::Document::DocumentTheme Gecko_GetDocumentLWTheme(
143 const mozilla::dom::Document*);
145 const mozilla::PreferenceSheet::Prefs* Gecko_GetPrefSheetPrefs(
146 const mozilla::dom::Document*);
148 bool Gecko_IsTableBorderNonzero(const mozilla::dom::Element* element);
149 bool Gecko_IsBrowserFrame(const mozilla::dom::Element* element);
151 // Attributes.
152 #define SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_) \
153 nsAtom* prefix_##LangValue(implementor_ element); \
154 bool prefix_##HasAttr(implementor_ element, nsAtom* ns, nsAtom* name); \
155 bool prefix_##AttrEquals(implementor_ element, nsAtom* ns, nsAtom* name, \
156 nsAtom* str, bool ignoreCase); \
157 bool prefix_##AttrDashEquals(implementor_ element, nsAtom* ns, nsAtom* name, \
158 nsAtom* str, bool ignore_case); \
159 bool prefix_##AttrIncludes(implementor_ element, nsAtom* ns, nsAtom* name, \
160 nsAtom* str, bool ignore_case); \
161 bool prefix_##AttrHasSubstring(implementor_ element, nsAtom* ns, \
162 nsAtom* name, nsAtom* str, bool ignore_case); \
163 bool prefix_##AttrHasPrefix(implementor_ element, nsAtom* ns, nsAtom* name, \
164 nsAtom* str, bool ignore_case); \
165 bool prefix_##AttrHasSuffix(implementor_ element, nsAtom* ns, nsAtom* name, \
166 nsAtom* str, bool ignore_case);
168 bool Gecko_AssertClassAttrValueIsSane(const nsAttrValue*);
169 const nsAttrValue* Gecko_GetSVGAnimatedClass(const mozilla::dom::Element*);
171 SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_,
172 const mozilla::dom::Element*)
174 SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(
175 Gecko_Snapshot, const mozilla::ServoElementSnapshot*)
177 #undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS
179 // Style attributes.
180 const mozilla::StyleStrong<RawServoDeclarationBlock>*
181 Gecko_GetStyleAttrDeclarationBlock(const mozilla::dom::Element* element);
183 void Gecko_UnsetDirtyStyleAttr(const mozilla::dom::Element* element);
185 const mozilla::StyleStrong<RawServoDeclarationBlock>*
186 Gecko_GetHTMLPresentationAttrDeclarationBlock(
187 const mozilla::dom::Element* element);
189 const mozilla::StyleStrong<RawServoDeclarationBlock>*
190 Gecko_GetExtraContentStyleDeclarations(const mozilla::dom::Element* element);
192 const mozilla::StyleStrong<RawServoDeclarationBlock>*
193 Gecko_GetUnvisitedLinkAttrDeclarationBlock(
194 const mozilla::dom::Element* element);
196 const mozilla::StyleStrong<RawServoDeclarationBlock>*
197 Gecko_GetVisitedLinkAttrDeclarationBlock(const mozilla::dom::Element* element);
199 const mozilla::StyleStrong<RawServoDeclarationBlock>*
200 Gecko_GetActiveLinkAttrDeclarationBlock(const mozilla::dom::Element* element);
202 // Visited handling.
204 // Returns whether visited styles are enabled for a given document.
205 bool Gecko_VisitedStylesEnabled(const mozilla::dom::Document*);
207 // Animations
208 bool Gecko_GetAnimationRule(
209 const mozilla::dom::Element* aElementOrPseudo,
210 mozilla::EffectCompositor::CascadeLevel aCascadeLevel,
211 RawServoAnimationValueMap* aAnimationValues);
213 bool Gecko_StyleAnimationsEquals(
214 const nsStyleAutoArray<mozilla::StyleAnimation>*,
215 const nsStyleAutoArray<mozilla::StyleAnimation>*);
217 void Gecko_CopyAnimationNames(
218 nsStyleAutoArray<mozilla::StyleAnimation>* aDest,
219 const nsStyleAutoArray<mozilla::StyleAnimation>* aSrc);
221 // This function takes an already addrefed nsAtom
222 void Gecko_SetAnimationName(mozilla::StyleAnimation* aStyleAnimation,
223 nsAtom* aAtom);
225 void Gecko_UpdateAnimations(const mozilla::dom::Element* aElementOrPseudo,
226 const mozilla::ComputedStyle* aOldComputedValues,
227 const mozilla::ComputedStyle* aComputedValues,
228 mozilla::UpdateAnimationsTasks aTasks);
230 size_t Gecko_GetAnimationEffectCount(
231 const mozilla::dom::Element* aElementOrPseudo);
232 bool Gecko_ElementHasAnimations(const mozilla::dom::Element* aElementOrPseudo);
233 bool Gecko_ElementHasCSSAnimations(
234 const mozilla::dom::Element* aElementOrPseudo);
235 bool Gecko_ElementHasCSSTransitions(
236 const mozilla::dom::Element* aElementOrPseudo);
237 bool Gecko_ElementHasWebAnimations(
238 const mozilla::dom::Element* aElementOrPseudo);
239 size_t Gecko_ElementTransitions_Length(
240 const mozilla::dom::Element* aElementOrPseudo);
242 nsCSSPropertyID Gecko_ElementTransitions_PropertyAt(
243 const mozilla::dom::Element* aElementOrPseudo, size_t aIndex);
245 const RawServoAnimationValue* Gecko_ElementTransitions_EndValueAt(
246 const mozilla::dom::Element* aElementOrPseudo, size_t aIndex);
248 double Gecko_GetProgressFromComputedTiming(const mozilla::ComputedTiming*);
250 double Gecko_GetPositionInSegment(
251 const mozilla::AnimationPropertySegment*, double aProgress,
252 mozilla::ComputedTimingFunction::BeforeFlag aBeforeFlag);
254 // Get servo's AnimationValue for |aProperty| from the cached base style
255 // |aBaseStyles|.
256 // |aBaseStyles| is nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>.
257 // We use RawServoAnimationValueTableBorrowed to avoid exposing
258 // nsRefPtrHashtable in FFI.
259 const RawServoAnimationValue* Gecko_AnimationGetBaseStyle(
260 const RawServoAnimationValueTable* aBaseStyles, nsCSSPropertyID aProperty);
262 void Gecko_StyleTransition_SetUnsupportedProperty(
263 mozilla::StyleTransition* aTransition, nsAtom* aAtom);
265 // Atoms.
266 nsAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
267 nsAtom* Gecko_Atomize16(const nsAString* aString);
268 void Gecko_AddRefAtom(nsAtom* aAtom);
269 void Gecko_ReleaseAtom(nsAtom* aAtom);
271 // Font style
272 void Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src);
274 void Gecko_nsTArray_FontFamilyName_AppendNamed(
275 nsTArray<mozilla::FontFamilyName>* aNames, nsAtom* aName,
276 mozilla::StyleFontFamilyNameSyntax);
278 void Gecko_nsTArray_FontFamilyName_AppendGeneric(
279 nsTArray<mozilla::FontFamilyName>* aNames, mozilla::StyleGenericFontFamily);
281 // Returns an already-AddRefed SharedFontList with an empty mNames array.
282 mozilla::SharedFontList* Gecko_SharedFontList_Create();
284 size_t Gecko_SharedFontList_SizeOfIncludingThis(
285 mozilla::SharedFontList* fontlist);
287 size_t Gecko_SharedFontList_SizeOfIncludingThisIfUnshared(
288 mozilla::SharedFontList* fontlist);
290 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::SharedFontList, SharedFontList);
292 // will not run destructors on dst, give it uninitialized memory
293 // font_id is LookAndFeel::FontID
294 void Gecko_nsFont_InitSystem(nsFont* dst, int32_t font_id,
295 const nsStyleFont* font,
296 const mozilla::dom::Document*);
298 void Gecko_nsFont_Destroy(nsFont* dst);
300 // The gfxFontFeatureValueSet returned from this function has zero reference.
301 gfxFontFeatureValueSet* Gecko_ConstructFontFeatureValueSet();
303 nsTArray<uint32_t>* Gecko_AppendFeatureValueHashEntry(
304 gfxFontFeatureValueSet* value_set, nsAtom* family, uint32_t alternate,
305 nsAtom* name);
307 // Font variant alternates
308 void Gecko_ClearAlternateValues(nsFont* font, size_t length);
310 void Gecko_AppendAlternateValues(nsFont* font, uint32_t alternate_name,
311 nsAtom* atom);
313 void Gecko_CopyAlternateValuesFrom(nsFont* dest, const nsFont* src);
315 // Visibility style
316 void Gecko_SetImageOrientation(nsStyleVisibility* aVisibility,
317 uint8_t aOrientation, bool aFlip);
319 void Gecko_SetImageOrientationAsFromImage(nsStyleVisibility* aVisibility);
321 void Gecko_CopyImageOrientationFrom(nsStyleVisibility* aDst,
322 const nsStyleVisibility* aSrc);
324 // Counter style.
325 void Gecko_CounterStyle_ToPtr(const mozilla::StyleCounterStyle*,
326 mozilla::CounterStylePtr*);
328 void Gecko_SetCounterStyleToNone(mozilla::CounterStylePtr*);
330 void Gecko_SetCounterStyleToString(mozilla::CounterStylePtr* ptr,
331 const nsACString* symbol);
333 void Gecko_CopyCounterStyle(mozilla::CounterStylePtr* dst,
334 const mozilla::CounterStylePtr* src);
336 nsAtom* Gecko_CounterStyle_GetName(const mozilla::CounterStylePtr* ptr);
338 const mozilla::AnonymousCounterStyle* Gecko_CounterStyle_GetAnonymous(
339 const mozilla::CounterStylePtr* ptr);
341 // list-style-image style.
342 void Gecko_SetListStyleImageNone(nsStyleList* style_struct);
344 void Gecko_SetListStyleImageImageValue(
345 nsStyleList* style_struct, const mozilla::StyleComputedImageUrl* url);
347 void Gecko_CopyListStyleImageFrom(nsStyleList* dest, const nsStyleList* src);
349 // Dirtiness tracking.
350 void Gecko_SetNodeFlags(const nsINode* node, uint32_t flags);
351 void Gecko_UnsetNodeFlags(const nsINode* node, uint32_t flags);
352 void Gecko_NoteDirtyElement(const mozilla::dom::Element*);
353 void Gecko_NoteDirtySubtreeForInvalidation(const mozilla::dom::Element*);
354 void Gecko_NoteAnimationOnlyDirtyElement(const mozilla::dom::Element*);
356 bool Gecko_AnimationNameMayBeReferencedFromStyle(const nsPresContext*,
357 nsAtom* name);
359 // Incremental restyle.
360 mozilla::PseudoStyleType Gecko_GetImplementedPseudo(
361 const mozilla::dom::Element*);
363 // We'd like to return `nsChangeHint` here, but bindgen bitfield enums don't
364 // work as return values with the Linux 32-bit ABI at the moment because
365 // they wrap the value in a struct.
366 uint32_t Gecko_CalcStyleDifference(const mozilla::ComputedStyle* old_style,
367 const mozilla::ComputedStyle* new_style,
368 bool* any_style_struct_changed,
369 bool* reset_only_changed);
371 // Get an element snapshot for a given element from the table.
372 const mozilla::ServoElementSnapshot* Gecko_GetElementSnapshot(
373 const mozilla::ServoElementSnapshotTable* table,
374 const mozilla::dom::Element*);
376 // Have we seen this pointer before?
377 bool Gecko_HaveSeenPtr(mozilla::SeenPtrs* table, const void* ptr);
379 // `array` must be an nsTArray
380 // If changing this signature, please update the
381 // friend function declaration in nsTArray.h
382 void Gecko_EnsureTArrayCapacity(void* array, size_t capacity, size_t elem_size);
384 // Same here, `array` must be an nsTArray<T>, for some T.
386 // Important note: Only valid for POD types, since destructors won't be run
387 // otherwise. This is ensured with rust traits for the relevant structs.
388 void Gecko_ClearPODTArray(void* array, size_t elem_size, size_t elem_align);
390 void Gecko_ResizeTArrayForStrings(nsTArray<nsString>* array, uint32_t length);
391 void Gecko_ResizeAtomArray(nsTArray<RefPtr<nsAtom>>* array, uint32_t length);
393 void Gecko_EnsureImageLayersLength(nsStyleImageLayers* layers, size_t len,
394 nsStyleImageLayers::LayerType layer_type);
396 void Gecko_EnsureStyleAnimationArrayLength(void* array, size_t len);
397 void Gecko_EnsureStyleTransitionArrayLength(void* array, size_t len);
399 // Searches from the beginning of |keyframes| for a Keyframe object with the
400 // specified offset and timing function. If none is found, a new Keyframe object
401 // with the specified |offset| and |timingFunction| will be prepended to
402 // |keyframes|.
404 // @param keyframes An array of Keyframe objects, sorted by offset.
405 // The first Keyframe in the array, if any, MUST have an
406 // offset greater than or equal to |offset|.
407 // @param offset The offset to search for, or, if no suitable Keyframe is
408 // found, the offset to use for the created Keyframe.
409 // Must be a floating point number in the range [0.0, 1.0].
410 // @param timingFunction The timing function to match, or, if no suitable
411 // Keyframe is found, to set on the created Keyframe.
413 // @returns The matching or created Keyframe.
414 mozilla::Keyframe* Gecko_GetOrCreateKeyframeAtStart(
415 nsTArray<mozilla::Keyframe>* keyframes, float offset,
416 const nsTimingFunction* timingFunction);
418 // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
419 // from the beginning of |keyframes| for a Keyframe with matching timing
420 // function and an offset of 0.0.
421 // Furthermore, if a matching Keyframe is not found, a new Keyframe will be
422 // inserted after the *last* Keyframe in |keyframes| with offset 0.0.
423 mozilla::Keyframe* Gecko_GetOrCreateInitialKeyframe(
424 nsTArray<mozilla::Keyframe>* keyframes,
425 const nsTimingFunction* timingFunction);
427 // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
428 // from the *end* of |keyframes| for a Keyframe with matching timing function
429 // and an offset of 1.0. If a matching Keyframe is not found, a new Keyframe
430 // will be appended to the end of |keyframes|.
431 mozilla::Keyframe* Gecko_GetOrCreateFinalKeyframe(
432 nsTArray<mozilla::Keyframe>* keyframes,
433 const nsTimingFunction* timingFunction);
435 // Appends and returns a new PropertyValuePair to |aProperties| initialized with
436 // its mProperty member set to |aProperty| and all other members initialized to
437 // their default values.
438 mozilla::PropertyValuePair* Gecko_AppendPropertyValuePair(
439 nsTArray<mozilla::PropertyValuePair>*, nsCSSPropertyID aProperty);
441 void Gecko_ResetFilters(nsStyleEffects* effects, size_t new_len);
443 void Gecko_CopyFiltersFrom(nsStyleEffects* aSrc, nsStyleEffects* aDest);
445 void Gecko_nsStyleSVG_SetDashArrayLength(nsStyleSVG* svg, uint32_t len);
447 void Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG* dst, const nsStyleSVG* src);
449 void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* svg, uint32_t len);
451 void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* dst,
452 const nsStyleSVG* src);
454 void Gecko_GetComputedURLSpec(const mozilla::StyleComputedUrl* url,
455 nsCString* spec);
457 void Gecko_GetComputedImageURLSpec(const mozilla::StyleComputedUrl* url,
458 nsCString* spec);
460 void Gecko_nsIURI_Debug(nsIURI*, nsCString* spec);
462 void Gecko_nsIReferrerInfo_Debug(nsIReferrerInfo* aReferrerInfo,
463 nsCString* aOut);
465 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::URLExtraData, URLExtraData);
466 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsIReferrerInfo, nsIReferrerInfo);
468 void Gecko_FillAllImageLayers(nsStyleImageLayers* layers, uint32_t max_len);
470 float Gecko_FontStretch_ToFloat(mozilla::FontStretch aStretch);
472 void Gecko_FontStretch_SetFloat(mozilla::FontStretch* aStretch,
473 float aFloatValue);
475 void Gecko_LoadData_Drop(mozilla::StyleLoadData*);
477 float Gecko_FontSlantStyle_ToFloat(mozilla::FontSlantStyle aStyle);
478 void Gecko_FontSlantStyle_SetNormal(mozilla::FontSlantStyle*);
479 void Gecko_FontSlantStyle_SetItalic(mozilla::FontSlantStyle*);
481 void Gecko_FontSlantStyle_SetOblique(mozilla::FontSlantStyle*,
482 float angle_degrees);
484 void Gecko_FontSlantStyle_Get(mozilla::FontSlantStyle, bool* normal,
485 bool* italic, float* oblique_angle);
487 float Gecko_FontWeight_ToFloat(mozilla::FontWeight aWeight);
489 void Gecko_FontWeight_SetFloat(mozilla::FontWeight* aWeight, float aFloatValue);
491 void Gecko_nsStyleFont_SetLang(nsStyleFont* font, nsAtom* atom);
493 void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont,
494 const nsStyleFont* aSource);
496 // Moves the generic family in the font-family to the front, or prepends
497 // aDefaultGeneric, so that user-configured fonts take precedent over document
498 // fonts.
500 // Document fonts may still be used as fallback for unsupported glyphs though.
501 void Gecko_nsStyleFont_PrioritizeUserFonts(
502 nsStyleFont* font, mozilla::StyleGenericFontFamily aDefaultGeneric);
504 nscoord Gecko_nsStyleFont_ComputeMinSize(const nsStyleFont*,
505 const mozilla::dom::Document*);
507 // Computes the default generic font for a generic family and language.
508 mozilla::StyleGenericFontFamily Gecko_nsStyleFont_ComputeDefaultFontType(
509 const mozilla::dom::Document*,
510 mozilla::StyleGenericFontFamily generic_family, nsAtom* language);
512 mozilla::FontSizePrefs Gecko_GetBaseSize(nsAtom* lang);
514 struct GeckoFontMetrics {
515 nscoord mChSize; // -1.0 indicates not found
516 nscoord mXSize;
519 GeckoFontMetrics Gecko_GetFontMetrics(const nsPresContext*, bool is_vertical,
520 const nsStyleFont* font,
521 nscoord font_size,
522 bool use_user_font_set);
524 mozilla::StyleSheet* Gecko_StyleSheet_Clone(
525 const mozilla::StyleSheet* aSheet,
526 const mozilla::StyleSheet* aNewParentSheet);
528 void Gecko_StyleSheet_AddRef(const mozilla::StyleSheet* aSheet);
529 void Gecko_StyleSheet_Release(const mozilla::StyleSheet* aSheet);
530 bool Gecko_IsDocumentBody(const mozilla::dom::Element* element);
532 // We use an int32_t here instead of a LookAndFeel::ColorID
533 // because forward-declaring a nested enum/struct is impossible
534 nscolor Gecko_GetLookAndFeelSystemColor(int32_t color_id,
535 const mozilla::dom::Document*);
537 void Gecko_AddPropertyToSet(nsCSSPropertyIDSet*, nsCSSPropertyID);
539 // Style-struct management.
540 #define STYLE_STRUCT(name) \
541 void Gecko_Construct_Default_nsStyle##name(nsStyle##name* ptr, \
542 const mozilla::dom::Document*); \
543 void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \
544 const nsStyle##name* other); \
545 void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr);
546 #include "nsStyleStructList.h"
547 #undef STYLE_STRUCT
549 void Gecko_RegisterProfilerThread(const char* name);
550 void Gecko_UnregisterProfilerThread();
552 #ifdef MOZ_GECKO_PROFILER
553 void Gecko_Construct_AutoProfilerLabel(mozilla::AutoProfilerLabel*,
554 JS::ProfilingCategoryPair);
555 void Gecko_Destroy_AutoProfilerLabel(mozilla::AutoProfilerLabel*);
556 #endif
558 bool Gecko_DocumentRule_UseForPresentation(
559 const mozilla::dom::Document*, const nsACString* aPattern,
560 mozilla::css::DocumentMatchingFunction);
562 // Allocator hinting.
563 void Gecko_SetJemallocThreadLocalArena(bool enabled);
565 // Pseudo-element flags.
566 #define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
567 const uint32_t SERVO_CSS_PSEUDO_ELEMENT_FLAGS_##name_ = flags_;
568 #include "nsCSSPseudoElementList.h"
569 #undef CSS_PSEUDO_ELEMENT
571 bool Gecko_ErrorReportingEnabled(const mozilla::StyleSheet* sheet,
572 const mozilla::css::Loader* loader,
573 uint64_t* aOutWindowId);
575 void Gecko_ReportUnexpectedCSSError(
576 uint64_t windowId, nsIURI* uri, const char* message, const char* param,
577 uint32_t paramLen, const char* prefix, const char* prefixParam,
578 uint32_t prefixParamLen, const char* suffix, const char* source,
579 uint32_t sourceLen, const char* selectors, uint32_t selectorsLen,
580 uint32_t lineNumber, uint32_t colNumber);
582 // DOM APIs.
583 void Gecko_ContentList_AppendAll(nsSimpleContentList* aContentList,
584 const mozilla::dom::Element** aElements,
585 size_t aLength);
587 // FIXME(emilio): These two below should be a single function that takes a
588 // `const DocumentOrShadowRoot*`, but that doesn't make MSVC builds happy for a
589 // reason I haven't really dug into.
590 const nsTArray<mozilla::dom::Element*>* Gecko_Document_GetElementsWithId(
591 const mozilla::dom::Document*, nsAtom* aId);
593 const nsTArray<mozilla::dom::Element*>* Gecko_ShadowRoot_GetElementsWithId(
594 const mozilla::dom::ShadowRoot*, nsAtom* aId);
596 // Check the value of the given bool preference. The pref name needs to
597 // be null-terminated.
598 bool Gecko_GetBoolPrefValue(const char* pref_name);
600 // Returns true if we're currently performing the servo traversal.
601 bool Gecko_IsInServoTraversal();
603 // Returns true if we're currently on the main thread.
604 bool Gecko_IsMainThread();
606 // Media feature helpers.
608 // Defined in nsMediaFeatures.cpp.
609 mozilla::StyleDisplayMode Gecko_MediaFeatures_GetDisplayMode(
610 const mozilla::dom::Document*);
612 uint32_t Gecko_MediaFeatures_GetColorDepth(const mozilla::dom::Document*);
614 void Gecko_MediaFeatures_GetDeviceSize(const mozilla::dom::Document*,
615 nscoord* width, nscoord* height);
617 float Gecko_MediaFeatures_GetResolution(const mozilla::dom::Document*);
618 bool Gecko_MediaFeatures_PrefersReducedMotion(const mozilla::dom::Document*);
619 mozilla::StylePrefersColorScheme Gecko_MediaFeatures_PrefersColorScheme(
620 const mozilla::dom::Document*);
622 mozilla::PointerCapabilities Gecko_MediaFeatures_PrimaryPointerCapabilities(
623 const mozilla::dom::Document*);
625 mozilla::PointerCapabilities Gecko_MediaFeatures_AllPointerCapabilities(
626 const mozilla::dom::Document*);
628 float Gecko_MediaFeatures_GetDevicePixelRatio(const mozilla::dom::Document*);
630 bool Gecko_MediaFeatures_HasSystemMetric(const mozilla::dom::Document*,
631 nsAtom* metric,
632 bool is_accessible_from_content);
634 bool Gecko_MediaFeatures_IsResourceDocument(const mozilla::dom::Document*);
635 nsAtom* Gecko_MediaFeatures_GetOperatingSystemVersion(
636 const mozilla::dom::Document*);
638 void Gecko_GetSafeAreaInsets(const nsPresContext*, float*, float*, float*,
639 float*);
641 void Gecko_PrintfStderr(const nsCString*);
643 } // extern "C"
645 #endif // mozilla_GeckoBindings_h