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
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"
26 class nsSimpleContentList
;
28 class ServoComputedData
;
33 class ServoElementSnapshot
;
34 class ServoElementSnapshotTable
;
36 enum class PseudoStyleType
: uint8_t;
37 enum class PointerCapabilities
: uint8_t;
38 enum class UpdateAnimationsTasks
: uint8_t;
42 class LoaderReusableStyleSheets
;
45 enum class CompositeOperationOrAuto
: uint8_t;
46 enum class ScreenColorGamut
: uint8_t;
48 } // namespace mozilla
51 const bool GECKO_IS_NIGHTLY
= true;
53 const bool GECKO_IS_NIGHTLY
= false;
56 #define NS_DECL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \
57 void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr); \
58 void Gecko_Release##name_##ArbitraryThread(class_* aPtr);
59 #define NS_IMPL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \
60 static_assert(class_::HasThreadSafeRefCnt::value, \
61 "NS_DECL_THREADSAFE_FFI_REFCOUNTING can only be used with " \
62 "classes that have thread-safe refcounting"); \
63 void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr) { NS_ADDREF(aPtr); } \
64 void Gecko_Release##name_##ArbitraryThread(class_* aPtr) { NS_RELEASE(aPtr); }
68 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsIURI
, nsIURI
);
71 void Gecko_Element_DebugListAttributes(const mozilla::dom::Element
*,
74 void Gecko_Snapshot_DebugListAttributes(const mozilla::ServoElementSnapshot
*,
77 bool Gecko_IsSignificantChild(const nsINode
*, bool whitespace_is_significant
);
79 const nsINode
* Gecko_GetLastChild(const nsINode
*);
80 const nsINode
* Gecko_GetFlattenedTreeParentNode(const nsINode
*);
81 const mozilla::dom::Element
* Gecko_GetBeforeOrAfterPseudo(
82 const mozilla::dom::Element
*, bool is_before
);
83 const mozilla::dom::Element
* Gecko_GetMarkerPseudo(
84 const mozilla::dom::Element
*);
86 nsTArray
<nsIContent
*>* Gecko_GetAnonymousContentForElement(
87 const mozilla::dom::Element
*);
88 void Gecko_DestroyAnonymousContentList(nsTArray
<nsIContent
*>* anon_content
);
90 const nsTArray
<RefPtr
<nsINode
>>* Gecko_GetAssignedNodes(
91 const mozilla::dom::Element
*);
93 void Gecko_GetQueryContainerSize(const mozilla::dom::Element
*,
94 nscoord
* aOutWidth
, nscoord
* aOutHeight
);
96 void Gecko_ComputedStyle_Init(mozilla::ComputedStyle
* context
,
97 const ServoComputedData
* values
,
98 mozilla::PseudoStyleType pseudo_type
);
100 void Gecko_ComputedStyle_Destroy(mozilla::ComputedStyle
* context
);
102 // By default, Servo walks the DOM by traversing the siblings of the DOM-view
103 // first child. This generally works, but misses anonymous children, which we
104 // want to traverse during styling. To support these cases, we create an
105 // optional stack-allocated iterator in aIterator for nodes that need it.
106 void Gecko_ConstructStyleChildrenIterator(const mozilla::dom::Element
*,
107 mozilla::dom::StyleChildrenIterator
*);
109 void Gecko_DestroyStyleChildrenIterator(mozilla::dom::StyleChildrenIterator
*);
111 const nsINode
* Gecko_GetNextStyleChild(mozilla::dom::StyleChildrenIterator
*);
113 nsAtom
* Gecko_Element_ImportedPart(const nsAttrValue
*, nsAtom
*);
114 nsAtom
** Gecko_Element_ExportedParts(const nsAttrValue
*, nsAtom
*,
117 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::SheetLoadDataHolder
,
118 SheetLoadDataHolder
);
120 void Gecko_StyleSheet_FinishAsyncParse(
121 mozilla::css::SheetLoadDataHolder
* data
,
122 mozilla::StyleStrong
<RawServoStyleSheetContents
> sheet_contents
,
123 mozilla::StyleOwnedOrNull
<StyleUseCounters
> use_counters
);
125 mozilla::StyleSheet
* Gecko_LoadStyleSheet(
126 mozilla::css::Loader
* loader
, mozilla::StyleSheet
* parent
,
127 mozilla::css::SheetLoadData
* parent_load_data
,
128 mozilla::css::LoaderReusableStyleSheets
* reusable_sheets
,
129 const mozilla::StyleCssUrl
* url
,
130 mozilla::StyleStrong
<RawServoMediaList
> media_list
);
132 void Gecko_LoadStyleSheetAsync(mozilla::css::SheetLoadDataHolder
* parent_data
,
133 const mozilla::StyleCssUrl
* url
,
134 mozilla::StyleStrong
<RawServoMediaList
>,
135 mozilla::StyleStrong
<RawServoImportRule
>);
137 // Selector Matching.
138 uint64_t Gecko_ElementState(const mozilla::dom::Element
*);
139 bool Gecko_IsRootElement(const mozilla::dom::Element
*);
141 bool Gecko_MatchLang(const mozilla::dom::Element
*, nsAtom
* override_lang
,
142 bool has_override_lang
, const char16_t
* value
);
144 nsAtom
* Gecko_GetXMLLangValue(const mozilla::dom::Element
*);
146 const mozilla::PreferenceSheet::Prefs
* Gecko_GetPrefSheetPrefs(
147 const mozilla::dom::Document
*);
149 bool Gecko_IsTableBorderNonzero(const mozilla::dom::Element
* element
);
150 bool Gecko_IsBrowserFrame(const mozilla::dom::Element
* element
);
151 bool Gecko_IsSelectListBox(const mozilla::dom::Element
* element
);
154 #define SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_) \
155 nsAtom* prefix_##LangValue(implementor_ element); \
156 bool prefix_##HasAttr(implementor_ element, nsAtom* ns, nsAtom* name); \
157 bool prefix_##AttrEquals(implementor_ element, nsAtom* ns, nsAtom* name, \
158 nsAtom* str, bool ignoreCase); \
159 bool prefix_##AttrDashEquals(implementor_ element, nsAtom* ns, nsAtom* name, \
160 nsAtom* str, bool ignore_case); \
161 bool prefix_##AttrIncludes(implementor_ element, nsAtom* ns, nsAtom* name, \
162 nsAtom* str, bool ignore_case); \
163 bool prefix_##AttrHasSubstring(implementor_ element, nsAtom* ns, \
164 nsAtom* name, nsAtom* str, bool ignore_case); \
165 bool prefix_##AttrHasPrefix(implementor_ element, nsAtom* ns, nsAtom* name, \
166 nsAtom* str, bool ignore_case); \
167 bool prefix_##AttrHasSuffix(implementor_ element, nsAtom* ns, nsAtom* name, \
168 nsAtom* str, bool ignore_case);
170 bool Gecko_AssertClassAttrValueIsSane(const nsAttrValue
*);
171 const nsAttrValue
* Gecko_GetSVGAnimatedClass(const mozilla::dom::Element
*);
173 SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_
,
174 const mozilla::dom::Element
*)
176 SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(
177 Gecko_Snapshot
, const mozilla::ServoElementSnapshot
*)
179 #undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS
182 const mozilla::StyleStrong
<RawServoDeclarationBlock
>*
183 Gecko_GetStyleAttrDeclarationBlock(const mozilla::dom::Element
* element
);
185 void Gecko_UnsetDirtyStyleAttr(const mozilla::dom::Element
* element
);
187 const mozilla::StyleStrong
<RawServoDeclarationBlock
>*
188 Gecko_GetHTMLPresentationAttrDeclarationBlock(
189 const mozilla::dom::Element
* element
);
191 const mozilla::StyleStrong
<RawServoDeclarationBlock
>*
192 Gecko_GetExtraContentStyleDeclarations(const mozilla::dom::Element
* element
);
194 const mozilla::StyleStrong
<RawServoDeclarationBlock
>*
195 Gecko_GetUnvisitedLinkAttrDeclarationBlock(
196 const mozilla::dom::Element
* element
);
198 const mozilla::StyleStrong
<RawServoDeclarationBlock
>*
199 Gecko_GetVisitedLinkAttrDeclarationBlock(const mozilla::dom::Element
* element
);
201 const mozilla::StyleStrong
<RawServoDeclarationBlock
>*
202 Gecko_GetActiveLinkAttrDeclarationBlock(const mozilla::dom::Element
* element
);
206 // Returns whether visited styles are enabled for a given document.
207 bool Gecko_VisitedStylesEnabled(const mozilla::dom::Document
*);
210 bool Gecko_GetAnimationRule(
211 const mozilla::dom::Element
* aElementOrPseudo
,
212 mozilla::EffectCompositor::CascadeLevel aCascadeLevel
,
213 RawServoAnimationValueMap
* aAnimationValues
);
215 bool Gecko_StyleAnimationsEquals(
216 const nsStyleAutoArray
<mozilla::StyleAnimation
>*,
217 const nsStyleAutoArray
<mozilla::StyleAnimation
>*);
219 bool Gecko_StyleScrollTimelinesEquals(
220 const nsStyleAutoArray
<mozilla::StyleScrollTimeline
>*,
221 const nsStyleAutoArray
<mozilla::StyleScrollTimeline
>*);
223 bool Gecko_StyleViewTimelinesEquals(
224 const nsStyleAutoArray
<mozilla::StyleViewTimeline
>*,
225 const nsStyleAutoArray
<mozilla::StyleViewTimeline
>*);
227 void Gecko_CopyAnimationNames(
228 nsStyleAutoArray
<mozilla::StyleAnimation
>* aDest
,
229 const nsStyleAutoArray
<mozilla::StyleAnimation
>* aSrc
);
231 // This function takes an already addrefed nsAtom
232 void Gecko_SetAnimationName(mozilla::StyleAnimation
* aStyleAnimation
,
235 void Gecko_UpdateAnimations(const mozilla::dom::Element
* aElementOrPseudo
,
236 const mozilla::ComputedStyle
* aOldComputedValues
,
237 const mozilla::ComputedStyle
* aComputedValues
,
238 mozilla::UpdateAnimationsTasks aTasks
);
240 size_t Gecko_GetAnimationEffectCount(
241 const mozilla::dom::Element
* aElementOrPseudo
);
242 bool Gecko_ElementHasAnimations(const mozilla::dom::Element
* aElementOrPseudo
);
243 bool Gecko_ElementHasCSSAnimations(
244 const mozilla::dom::Element
* aElementOrPseudo
);
245 bool Gecko_ElementHasCSSTransitions(
246 const mozilla::dom::Element
* aElementOrPseudo
);
247 bool Gecko_ElementHasWebAnimations(
248 const mozilla::dom::Element
* aElementOrPseudo
);
249 size_t Gecko_ElementTransitions_Length(
250 const mozilla::dom::Element
* aElementOrPseudo
);
252 nsCSSPropertyID
Gecko_ElementTransitions_PropertyAt(
253 const mozilla::dom::Element
* aElementOrPseudo
, size_t aIndex
);
255 const RawServoAnimationValue
* Gecko_ElementTransitions_EndValueAt(
256 const mozilla::dom::Element
* aElementOrPseudo
, size_t aIndex
);
258 double Gecko_GetProgressFromComputedTiming(const mozilla::ComputedTiming
*);
260 double Gecko_GetPositionInSegment(const mozilla::AnimationPropertySegment
*,
261 double aProgress
, bool aBeforeFlag
);
263 // Get servo's AnimationValue for |aProperty| from the cached base style
265 // |aBaseStyles| is nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>.
266 // We use RawServoAnimationValueTableBorrowed to avoid exposing
267 // nsRefPtrHashtable in FFI.
268 const RawServoAnimationValue
* Gecko_AnimationGetBaseStyle(
269 const RawServoAnimationValueTable
* aBaseStyles
, nsCSSPropertyID aProperty
);
271 void Gecko_StyleTransition_SetUnsupportedProperty(
272 mozilla::StyleTransition
* aTransition
, nsAtom
* aAtom
);
275 nsAtom
* Gecko_Atomize(const char* aString
, uint32_t aLength
);
276 nsAtom
* Gecko_Atomize16(const nsAString
* aString
);
277 void Gecko_AddRefAtom(nsAtom
* aAtom
);
278 void Gecko_ReleaseAtom(nsAtom
* aAtom
);
280 // will not run destructors on dst, give it uninitialized memory
281 // font_id is LookAndFeel::FontID
282 void Gecko_nsFont_InitSystem(nsFont
* dst
, mozilla::StyleSystemFont font_id
,
283 const nsStyleFont
* font
,
284 const mozilla::dom::Document
*);
286 void Gecko_nsFont_Destroy(nsFont
* dst
);
288 // The gfxFontFeatureValueSet returned from this function has zero reference.
289 gfxFontFeatureValueSet
* Gecko_ConstructFontFeatureValueSet();
291 nsTArray
<uint32_t>* Gecko_AppendFeatureValueHashEntry(
292 gfxFontFeatureValueSet
* value_set
, nsAtom
* family
, uint32_t alternate
,
295 // Font variant alternates
296 void Gecko_ClearAlternateValues(nsFont
* font
, size_t length
);
298 void Gecko_AppendAlternateValues(nsFont
* font
, uint32_t alternate_name
,
301 void Gecko_CopyAlternateValuesFrom(nsFont
* dest
, const nsFont
* src
);
303 // The FontPaletteValueSet returned from this function has zero reference.
304 mozilla::gfx::FontPaletteValueSet
* Gecko_ConstructFontPaletteValueSet();
306 mozilla::gfx::FontPaletteValueSet::PaletteValues
*
307 Gecko_AppendPaletteValueHashEntry(
308 mozilla::gfx::FontPaletteValueSet
* aPaletteValueSet
, nsAtom
* aFamily
,
311 void Gecko_SetFontPaletteBase(
312 mozilla::gfx::FontPaletteValueSet::PaletteValues
* aValues
,
313 int32_t aBasePaletteIndex
);
315 void Gecko_SetFontPaletteOverride(
316 mozilla::gfx::FontPaletteValueSet::PaletteValues
* aValues
, int32_t aIndex
,
317 mozilla::StyleAbsoluteColor
* aColor
);
320 void Gecko_SetImageOrientation(nsStyleVisibility
* aVisibility
,
321 uint8_t aOrientation
, bool aFlip
);
323 void Gecko_SetImageOrientationAsFromImage(nsStyleVisibility
* aVisibility
);
325 void Gecko_CopyImageOrientationFrom(nsStyleVisibility
* aDst
,
326 const nsStyleVisibility
* aSrc
);
329 void Gecko_CounterStyle_ToPtr(const mozilla::StyleCounterStyle
*,
330 mozilla::CounterStylePtr
*);
332 void Gecko_SetCounterStyleToNone(mozilla::CounterStylePtr
*);
334 void Gecko_SetCounterStyleToString(mozilla::CounterStylePtr
* ptr
,
335 const nsACString
* symbol
);
337 void Gecko_CopyCounterStyle(mozilla::CounterStylePtr
* dst
,
338 const mozilla::CounterStylePtr
* src
);
340 nsAtom
* Gecko_CounterStyle_GetName(const mozilla::CounterStylePtr
* ptr
);
342 const mozilla::AnonymousCounterStyle
* Gecko_CounterStyle_GetAnonymous(
343 const mozilla::CounterStylePtr
* ptr
);
345 // list-style-image style.
346 void Gecko_SetListStyleImageNone(nsStyleList
* style_struct
);
348 void Gecko_SetListStyleImageImageValue(
349 nsStyleList
* style_struct
, const mozilla::StyleComputedImageUrl
* url
);
351 void Gecko_CopyListStyleImageFrom(nsStyleList
* dest
, const nsStyleList
* src
);
353 // Dirtiness tracking.
354 void Gecko_NoteDirtyElement(const mozilla::dom::Element
*);
355 void Gecko_NoteDirtySubtreeForInvalidation(const mozilla::dom::Element
*);
356 void Gecko_NoteAnimationOnlyDirtyElement(const mozilla::dom::Element
*);
358 bool Gecko_AnimationNameMayBeReferencedFromStyle(const nsPresContext
*,
361 float Gecko_GetScrollbarInlineSize(const nsPresContext
*);
363 // Incremental restyle.
364 mozilla::PseudoStyleType
Gecko_GetImplementedPseudo(
365 const mozilla::dom::Element
*);
367 // We'd like to return `nsChangeHint` here, but bindgen bitfield enums don't
368 // work as return values with the Linux 32-bit ABI at the moment because
369 // they wrap the value in a struct.
370 uint32_t Gecko_CalcStyleDifference(const mozilla::ComputedStyle
* old_style
,
371 const mozilla::ComputedStyle
* new_style
,
372 bool* any_style_struct_changed
,
373 bool* reset_only_changed
);
375 nscoord
Gecko_CalcLineHeight(const mozilla::StyleLineHeight
*,
376 const nsPresContext
*, bool aVertical
,
377 const nsStyleFont
* aAgainstFont
,
378 const mozilla::dom::Element
* aElement
);
380 // Get an element snapshot for a given element from the table.
381 const mozilla::ServoElementSnapshot
* Gecko_GetElementSnapshot(
382 const mozilla::ServoElementSnapshotTable
* table
,
383 const mozilla::dom::Element
*);
385 // Have we seen this pointer before?
386 bool Gecko_HaveSeenPtr(mozilla::SeenPtrs
* table
, const void* ptr
);
388 // `array` must be an nsTArray
389 // If changing this signature, please update the
390 // friend function declaration in nsTArray.h
391 void Gecko_EnsureTArrayCapacity(void* array
, size_t capacity
, size_t elem_size
);
393 // Same here, `array` must be an nsTArray<T>, for some T.
395 // Important note: Only valid for POD types, since destructors won't be run
396 // otherwise. This is ensured with rust traits for the relevant structs.
397 void Gecko_ClearPODTArray(void* array
, size_t elem_size
, size_t elem_align
);
399 void Gecko_ResizeTArrayForStrings(nsTArray
<nsString
>* array
, uint32_t length
);
400 void Gecko_ResizeAtomArray(nsTArray
<RefPtr
<nsAtom
>>* array
, uint32_t length
);
402 void Gecko_EnsureImageLayersLength(nsStyleImageLayers
* layers
, size_t len
,
403 nsStyleImageLayers::LayerType layer_type
);
405 void Gecko_EnsureStyleAnimationArrayLength(void* array
, size_t len
);
406 void Gecko_EnsureStyleTransitionArrayLength(void* array
, size_t len
);
407 void Gecko_EnsureStyleScrollTimelineArrayLength(void* array
, size_t len
);
408 void Gecko_EnsureStyleViewTimelineArrayLength(void* array
, size_t len
);
410 // Searches from the beginning of |keyframes| for a Keyframe object with the
411 // specified offset and timing function. If none is found, a new Keyframe object
412 // with the specified |offset| and |timingFunction| will be prepended to
415 // @param keyframes An array of Keyframe objects, sorted by offset.
416 // The first Keyframe in the array, if any, MUST have an
417 // offset greater than or equal to |offset|.
418 // @param offset The offset to search for, or, if no suitable Keyframe is
419 // found, the offset to use for the created Keyframe.
420 // Must be a floating point number in the range [0.0, 1.0].
421 // @param timingFunction The timing function to match, or, if no suitable
422 // Keyframe is found, to set on the created Keyframe.
423 // @param composition The composition to match, or, if no suitable Keyframe is
424 // found, to set on the created Keyframe.
426 // @returns The matching or created Keyframe.
427 mozilla::Keyframe
* Gecko_GetOrCreateKeyframeAtStart(
428 nsTArray
<mozilla::Keyframe
>* keyframes
, float offset
,
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 beginning of |keyframes| for a Keyframe with matching timing
434 // function, composition, and an offset of 0.0.
435 // Furthermore, if a matching Keyframe is not found, a new Keyframe will be
436 // inserted after the *last* Keyframe in |keyframes| with offset 0.0.
437 mozilla::Keyframe
* Gecko_GetOrCreateInitialKeyframe(
438 nsTArray
<mozilla::Keyframe
>* keyframes
,
439 const mozilla::StyleComputedTimingFunction
* timingFunction
,
440 const mozilla::dom::CompositeOperationOrAuto composition
);
442 // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
443 // from the *end* of |keyframes| for a Keyframe with matching timing function,
444 // composition, and an offset of 1.0. If a matching Keyframe is not found, a new
445 // Keyframe will be appended to the end of |keyframes|.
446 mozilla::Keyframe
* Gecko_GetOrCreateFinalKeyframe(
447 nsTArray
<mozilla::Keyframe
>* keyframes
,
448 const mozilla::StyleComputedTimingFunction
* timingFunction
,
449 const mozilla::dom::CompositeOperationOrAuto composition
);
451 // Appends and returns a new PropertyValuePair to |aProperties| initialized with
452 // its mProperty member set to |aProperty| and all other members initialized to
453 // their default values.
454 mozilla::PropertyValuePair
* Gecko_AppendPropertyValuePair(
455 nsTArray
<mozilla::PropertyValuePair
>*, nsCSSPropertyID aProperty
);
457 void Gecko_ResetFilters(nsStyleEffects
* effects
, size_t new_len
);
459 void Gecko_CopyFiltersFrom(nsStyleEffects
* aSrc
, nsStyleEffects
* aDest
);
461 void Gecko_nsStyleSVG_SetDashArrayLength(nsStyleSVG
* svg
, uint32_t len
);
463 void Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG
* dst
, const nsStyleSVG
* src
);
465 void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG
* svg
, uint32_t len
);
467 void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG
* dst
,
468 const nsStyleSVG
* src
);
470 void Gecko_GetComputedURLSpec(const mozilla::StyleComputedUrl
* url
,
473 void Gecko_GetComputedImageURLSpec(const mozilla::StyleComputedUrl
* url
,
476 // Return true if the given image MIME type is supported
477 bool Gecko_IsSupportedImageMimeType(const uint8_t* mime_type
,
480 void Gecko_nsIURI_Debug(nsIURI
*, nsCString
* spec
);
482 void Gecko_nsIReferrerInfo_Debug(nsIReferrerInfo
* aReferrerInfo
,
485 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::URLExtraData
, URLExtraData
);
486 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsIReferrerInfo
, nsIReferrerInfo
);
488 void Gecko_FillAllImageLayers(nsStyleImageLayers
* layers
, uint32_t max_len
);
490 void Gecko_LoadData_Drop(mozilla::StyleLoadData
*);
492 void Gecko_nsStyleFont_SetLang(nsStyleFont
* font
, nsAtom
* atom
);
494 void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont
* aFont
,
495 const nsStyleFont
* aSource
);
497 mozilla::Length
Gecko_nsStyleFont_ComputeMinSize(const nsStyleFont
*,
498 const mozilla::dom::Document
*);
500 // Computes the default generic font for a language.
501 mozilla::StyleGenericFontFamily
502 Gecko_nsStyleFont_ComputeFallbackFontTypeForLanguage(
503 const mozilla::dom::Document
*, nsAtom
* language
);
505 mozilla::Length
Gecko_GetBaseSize(const mozilla::dom::Document
*,
507 mozilla::StyleGenericFontFamily
);
509 struct GeckoFontMetrics
{
510 mozilla::Length mXSize
;
511 mozilla::Length mChSize
; // negatives indicate not found.
512 mozilla::Length mCapHeight
; // negatives indicate not found.
513 mozilla::Length mIcWidth
; // negatives indicate not found.
514 mozilla::Length mAscent
;
515 float mScriptPercentScaleDown
; // zero is invalid or means not found.
516 float mScriptScriptPercentScaleDown
; // zero is invalid or means not found.
519 GeckoFontMetrics
Gecko_GetFontMetrics(const nsPresContext
*, bool is_vertical
,
520 const nsStyleFont
* font
,
521 mozilla::Length font_size
,
522 bool use_user_font_set
,
523 bool retrieve_math_scales
);
525 mozilla::StyleSheet
* Gecko_StyleSheet_Clone(
526 const mozilla::StyleSheet
* aSheet
,
527 const mozilla::StyleSheet
* aNewParentSheet
);
529 void Gecko_StyleSheet_AddRef(const mozilla::StyleSheet
* aSheet
);
530 void Gecko_StyleSheet_Release(const mozilla::StyleSheet
* aSheet
);
531 bool Gecko_IsDocumentBody(const mozilla::dom::Element
* element
);
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"
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
);
579 void Gecko_ContentList_AppendAll(nsSimpleContentList
* aContentList
,
580 const mozilla::dom::Element
** aElements
,
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 // Check the value of the given bool preference. The pref name needs to
593 // be null-terminated.
594 bool Gecko_GetBoolPrefValue(const char* pref_name
);
596 // Check whether font format/tech is supported.
597 bool Gecko_IsFontFormatSupported(
598 mozilla::StyleFontFaceSourceFormatKeyword aFormat
);
599 bool Gecko_IsFontTechSupported(mozilla::StyleFontFaceSourceTechFlags aFlag
);
601 bool Gecko_IsKnownIconFontFamily(const nsAtom
* aFamilyName
);
603 // Returns true if we're currently performing the servo traversal.
604 bool Gecko_IsInServoTraversal();
606 // Returns true if we're currently on the main thread.
607 bool Gecko_IsMainThread();
609 // Returns true if we're currently on a DOM worker thread.
610 bool Gecko_IsDOMWorkerThread();
612 // Media feature helpers.
614 // Defined in nsMediaFeatures.cpp.
615 mozilla::StyleDisplayMode
Gecko_MediaFeatures_GetDisplayMode(
616 const mozilla::dom::Document
*);
618 bool Gecko_MediaFeatures_WindowsNonNativeMenus(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*,
662 void Gecko_PrintfStderr(const nsCString
*);
666 #endif // mozilla_GeckoBindings_h