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;
40 struct StyleStylesheetContents
;
43 class LoaderReusableStyleSheets
;
46 enum class CompositeOperationOrAuto
: uint8_t;
47 enum class ScreenColorGamut
: uint8_t;
49 } // namespace mozilla
52 const bool GECKO_IS_NIGHTLY
= true;
54 const bool GECKO_IS_NIGHTLY
= false;
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); }
69 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsIURI
, nsIURI
);
72 void Gecko_Element_DebugListAttributes(const mozilla::dom::Element
*,
75 void Gecko_Snapshot_DebugListAttributes(const mozilla::ServoElementSnapshot
*,
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
*,
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
);
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
*,
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
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
);
202 // Returns whether visited styles are enabled for a given document.
203 bool Gecko_VisitedStylesEnabled(const mozilla::dom::Document
*);
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
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
);
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
,
285 // Font variant alternates
286 void Gecko_ClearAlternateValues(nsFont
* font
, size_t length
);
288 void Gecko_AppendAlternateValues(nsFont
* font
, uint32_t alternate_name
,
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
,
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
);
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 // list-style-image style.
319 void Gecko_SetListStyleImageNone(nsStyleList
* style_struct
);
321 void Gecko_SetListStyleImageImageValue(
322 nsStyleList
* style_struct
, const mozilla::StyleComputedImageUrl
* url
);
324 void Gecko_CopyListStyleImageFrom(nsStyleList
* dest
, const nsStyleList
* src
);
326 // Dirtiness tracking.
327 void Gecko_NoteDirtyElement(const mozilla::dom::Element
*);
328 void Gecko_NoteDirtySubtreeForInvalidation(const mozilla::dom::Element
*);
329 void Gecko_NoteAnimationOnlyDirtyElement(const mozilla::dom::Element
*);
331 bool Gecko_AnimationNameMayBeReferencedFromStyle(const nsPresContext
*,
334 float Gecko_GetScrollbarInlineSize(const nsPresContext
*);
336 // Incremental restyle.
337 mozilla::PseudoStyleType
Gecko_GetImplementedPseudo(
338 const mozilla::dom::Element
*);
340 // We'd like to return `nsChangeHint` here, but bindgen bitfield enums don't
341 // work as return values with the Linux 32-bit ABI at the moment because
342 // they wrap the value in a struct.
343 uint32_t Gecko_CalcStyleDifference(const mozilla::ComputedStyle
* old_style
,
344 const mozilla::ComputedStyle
* new_style
,
345 bool* any_style_struct_changed
,
346 bool* reset_only_changed
);
348 nscoord
Gecko_CalcLineHeight(const mozilla::StyleLineHeight
*,
349 const nsPresContext
*, bool aVertical
,
350 const nsStyleFont
* aAgainstFont
,
351 const mozilla::dom::Element
* aElement
);
353 // Get an element snapshot for a given element from the table.
354 const mozilla::ServoElementSnapshot
* Gecko_GetElementSnapshot(
355 const mozilla::ServoElementSnapshotTable
* table
,
356 const mozilla::dom::Element
*);
358 // Have we seen this pointer before?
359 bool Gecko_HaveSeenPtr(mozilla::SeenPtrs
* table
, const void* ptr
);
361 void Gecko_EnsureImageLayersLength(nsStyleImageLayers
* layers
, size_t len
,
362 nsStyleImageLayers::LayerType layer_type
);
364 void Gecko_EnsureStyleAnimationArrayLength(void* array
, size_t len
);
365 void Gecko_EnsureStyleTransitionArrayLength(void* array
, size_t len
);
366 void Gecko_EnsureStyleScrollTimelineArrayLength(void* array
, size_t len
);
367 void Gecko_EnsureStyleViewTimelineArrayLength(void* array
, size_t len
);
369 // Searches from the beginning of |keyframes| for a Keyframe object with the
370 // specified offset and timing function. If none is found, a new Keyframe object
371 // with the specified |offset| and |timingFunction| will be prepended to
374 // @param keyframes An array of Keyframe objects, sorted by offset.
375 // The first Keyframe in the array, if any, MUST have an
376 // offset greater than or equal to |offset|.
377 // @param offset The offset to search for, or, if no suitable Keyframe is
378 // found, the offset to use for the created Keyframe.
379 // Must be a floating point number in the range [0.0, 1.0].
380 // @param timingFunction The timing function to match, or, if no suitable
381 // Keyframe is found, to set on the created Keyframe.
382 // @param composition The composition to match, or, if no suitable Keyframe is
383 // found, to set on the created Keyframe.
385 // @returns The matching or created Keyframe.
386 mozilla::Keyframe
* Gecko_GetOrCreateKeyframeAtStart(
387 nsTArray
<mozilla::Keyframe
>* keyframes
, float offset
,
388 const mozilla::StyleComputedTimingFunction
* timingFunction
,
389 const mozilla::dom::CompositeOperationOrAuto composition
);
391 // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
392 // from the beginning of |keyframes| for a Keyframe with matching timing
393 // function, composition, and an offset of 0.0.
394 // Furthermore, if a matching Keyframe is not found, a new Keyframe will be
395 // inserted after the *last* Keyframe in |keyframes| with offset 0.0.
396 mozilla::Keyframe
* Gecko_GetOrCreateInitialKeyframe(
397 nsTArray
<mozilla::Keyframe
>* keyframes
,
398 const mozilla::StyleComputedTimingFunction
* timingFunction
,
399 const mozilla::dom::CompositeOperationOrAuto composition
);
401 // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
402 // from the *end* of |keyframes| for a Keyframe with matching timing function,
403 // composition, and an offset of 1.0. If a matching Keyframe is not found, a new
404 // Keyframe will be appended to the end of |keyframes|.
405 mozilla::Keyframe
* Gecko_GetOrCreateFinalKeyframe(
406 nsTArray
<mozilla::Keyframe
>* keyframes
,
407 const mozilla::StyleComputedTimingFunction
* timingFunction
,
408 const mozilla::dom::CompositeOperationOrAuto composition
);
410 void Gecko_ResetFilters(nsStyleEffects
* effects
, size_t new_len
);
412 void Gecko_CopyFiltersFrom(nsStyleEffects
* aSrc
, nsStyleEffects
* aDest
);
414 void Gecko_nsStyleSVG_SetDashArrayLength(nsStyleSVG
* svg
, uint32_t len
);
416 void Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG
* dst
, const nsStyleSVG
* src
);
418 void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG
* svg
, uint32_t len
);
420 void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG
* dst
,
421 const nsStyleSVG
* src
);
423 void Gecko_GetComputedURLSpec(const mozilla::StyleComputedUrl
* url
,
426 void Gecko_GetComputedImageURLSpec(const mozilla::StyleComputedUrl
* url
,
429 // Return true if the given image MIME type is supported
430 bool Gecko_IsSupportedImageMimeType(const uint8_t* mime_type
,
433 void Gecko_nsIURI_Debug(nsIURI
*, nsCString
* spec
);
435 void Gecko_nsIReferrerInfo_Debug(nsIReferrerInfo
* aReferrerInfo
,
438 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::URLExtraData
, URLExtraData
);
439 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsIReferrerInfo
, nsIReferrerInfo
);
441 void Gecko_FillAllImageLayers(nsStyleImageLayers
* layers
, uint32_t max_len
);
443 void Gecko_LoadData_Drop(mozilla::StyleLoadData
*);
445 void Gecko_nsStyleFont_SetLang(nsStyleFont
* font
, nsAtom
* atom
);
447 void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont
* aFont
,
448 const nsStyleFont
* aSource
);
450 mozilla::Length
Gecko_nsStyleFont_ComputeMinSize(const nsStyleFont
*,
451 const mozilla::dom::Document
*);
453 // Computes the default generic font for a language.
454 mozilla::StyleGenericFontFamily
455 Gecko_nsStyleFont_ComputeFallbackFontTypeForLanguage(
456 const mozilla::dom::Document
*, nsAtom
* language
);
458 mozilla::Length
Gecko_GetBaseSize(const mozilla::dom::Document
*,
460 mozilla::StyleGenericFontFamily
);
462 struct GeckoFontMetrics
{
463 mozilla::Length mXSize
;
464 mozilla::Length mChSize
; // negatives indicate not found.
465 mozilla::Length mCapHeight
; // negatives indicate not found.
466 mozilla::Length mIcWidth
; // negatives indicate not found.
467 mozilla::Length mAscent
;
468 mozilla::Length mComputedEmSize
;
469 float mScriptPercentScaleDown
; // zero is invalid or means not found.
470 float mScriptScriptPercentScaleDown
; // zero is invalid or means not found.
473 GeckoFontMetrics
Gecko_GetFontMetrics(const nsPresContext
*, bool is_vertical
,
474 const nsStyleFont
* font
,
475 mozilla::Length font_size
,
476 bool use_user_font_set
,
477 bool retrieve_math_scales
);
479 mozilla::StyleSheet
* Gecko_StyleSheet_Clone(
480 const mozilla::StyleSheet
* aSheet
,
481 const mozilla::StyleSheet
* aNewParentSheet
);
483 void Gecko_StyleSheet_AddRef(const mozilla::StyleSheet
* aSheet
);
484 void Gecko_StyleSheet_Release(const mozilla::StyleSheet
* aSheet
);
486 struct GeckoImplicitScopeRoot
{
487 const mozilla::dom::Element
* mHost
;
488 const mozilla::dom::Element
* mRoot
;
491 GeckoImplicitScopeRoot
Gecko_StyleSheet_ImplicitScopeRoot(
492 const mozilla::StyleSheet
* aSheet
);
494 bool Gecko_IsDocumentBody(const mozilla::dom::Element
* element
);
496 bool Gecko_IsDarkColorScheme(const mozilla::dom::Document
*,
497 const mozilla::StyleColorScheme
*);
498 nscolor
Gecko_ComputeSystemColor(mozilla::StyleSystemColor
,
499 const mozilla::dom::Document
*,
500 const mozilla::StyleColorScheme
*);
502 // We use an int32_t here instead of a LookAndFeel::IntID/FloatID because
503 // forward-declaring a nested enum/struct is impossible.
504 int32_t Gecko_GetLookAndFeelInt(int32_t int_id
);
505 float Gecko_GetLookAndFeelFloat(int32_t float_id
);
507 void Gecko_AddPropertyToSet(nsCSSPropertyIDSet
*, nsCSSPropertyID
);
509 // Style-struct management.
510 #define STYLE_STRUCT(name) \
511 void Gecko_Construct_Default_nsStyle##name(nsStyle##name* ptr, \
512 const mozilla::dom::Document*); \
513 void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \
514 const nsStyle##name* other); \
515 void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr);
516 #include "nsStyleStructList.h"
519 bool Gecko_DocumentRule_UseForPresentation(
520 const mozilla::dom::Document
*, const nsACString
* aPattern
,
521 mozilla::css::DocumentMatchingFunction
);
523 // Allocator hinting.
524 void Gecko_SetJemallocThreadLocalArena(bool enabled
);
526 // Pseudo-element flags.
527 #define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
528 const uint32_t SERVO_CSS_PSEUDO_ELEMENT_FLAGS_##name_ = flags_;
529 #include "nsCSSPseudoElementList.h"
530 #undef CSS_PSEUDO_ELEMENT
532 bool Gecko_ErrorReportingEnabled(const mozilla::StyleSheet
* sheet
,
533 const mozilla::css::Loader
* loader
,
534 uint64_t* aOutWindowId
);
536 void Gecko_ReportUnexpectedCSSError(
537 uint64_t windowId
, nsIURI
* uri
, const char* message
, const char* param
,
538 uint32_t paramLen
, const char* prefix
, const char* prefixParam
,
539 uint32_t prefixParamLen
, const char* suffix
, const char* source
,
540 uint32_t sourceLen
, const char* selectors
, uint32_t selectorsLen
,
541 uint32_t lineNumber
, uint32_t colNumber
);
544 void Gecko_ContentList_AppendAll(nsSimpleContentList
* aContentList
,
545 const mozilla::dom::Element
** aElements
,
548 // FIXME(emilio): These two below should be a single function that takes a
549 // `const DocumentOrShadowRoot*`, but that doesn't make MSVC builds happy for a
550 // reason I haven't really dug into.
551 const nsTArray
<mozilla::dom::Element
*>* Gecko_Document_GetElementsWithId(
552 const mozilla::dom::Document
*, nsAtom
* aId
);
554 const nsTArray
<mozilla::dom::Element
*>* Gecko_ShadowRoot_GetElementsWithId(
555 const mozilla::dom::ShadowRoot
*, nsAtom
* aId
);
557 bool Gecko_ComputeBoolPrefMediaQuery(nsAtom
*);
559 // Check whether font format/tech is supported.
560 bool Gecko_IsFontFormatSupported(
561 mozilla::StyleFontFaceSourceFormatKeyword aFormat
);
562 bool Gecko_IsFontTechSupported(mozilla::StyleFontFaceSourceTechFlags aFlag
);
564 bool Gecko_IsKnownIconFontFamily(const nsAtom
* aFamilyName
);
566 // Returns true if we're currently performing the servo traversal.
567 bool Gecko_IsInServoTraversal();
569 // Returns true if we're currently on the main thread.
570 bool Gecko_IsMainThread();
572 // Returns true if we're currently on a DOM worker thread.
573 bool Gecko_IsDOMWorkerThread();
575 // Returns the preferred number of style threads to use, or -1 for no
577 int32_t Gecko_GetNumStyleThreads();
579 // Media feature helpers.
581 // Defined in nsMediaFeatures.cpp.
582 mozilla::StyleDisplayMode
Gecko_MediaFeatures_GetDisplayMode(
583 const mozilla::dom::Document
*);
585 bool Gecko_MediaFeatures_UseOverlayScrollbars(const mozilla::dom::Document
*);
586 int32_t Gecko_MediaFeatures_GetColorDepth(const mozilla::dom::Document
*);
587 int32_t Gecko_MediaFeatures_GetMonochromeBitsPerPixel(
588 const mozilla::dom::Document
*);
589 mozilla::dom::ScreenColorGamut
Gecko_MediaFeatures_ColorGamut(
590 const mozilla::dom::Document
*);
592 void Gecko_MediaFeatures_GetDeviceSize(const mozilla::dom::Document
*,
593 nscoord
* width
, nscoord
* height
);
595 float Gecko_MediaFeatures_GetResolution(const mozilla::dom::Document
*);
596 bool Gecko_MediaFeatures_PrefersReducedMotion(const mozilla::dom::Document
*);
597 bool Gecko_MediaFeatures_PrefersReducedTransparency(
598 const mozilla::dom::Document
*);
599 mozilla::StylePrefersContrast
Gecko_MediaFeatures_PrefersContrast(
600 const mozilla::dom::Document
*);
601 mozilla::StylePrefersColorScheme
Gecko_MediaFeatures_PrefersColorScheme(
602 const mozilla::dom::Document
*, bool aUseContent
);
603 bool Gecko_MediaFeatures_InvertedColors(const mozilla::dom::Document
*);
604 mozilla::StyleScripting
Gecko_MediaFeatures_Scripting(
605 const mozilla::dom::Document
*);
607 mozilla::StyleDynamicRange
Gecko_MediaFeatures_DynamicRange(
608 const mozilla::dom::Document
*);
609 mozilla::StyleDynamicRange
Gecko_MediaFeatures_VideoDynamicRange(
610 const mozilla::dom::Document
*);
612 mozilla::PointerCapabilities
Gecko_MediaFeatures_PrimaryPointerCapabilities(
613 const mozilla::dom::Document
*);
615 mozilla::PointerCapabilities
Gecko_MediaFeatures_AllPointerCapabilities(
616 const mozilla::dom::Document
*);
618 float Gecko_MediaFeatures_GetDevicePixelRatio(const mozilla::dom::Document
*);
620 bool Gecko_MediaFeatures_IsResourceDocument(const mozilla::dom::Document
*);
621 bool Gecko_MediaFeatures_MatchesPlatform(mozilla::StylePlatform
);
622 mozilla::StyleGtkThemeFamily
Gecko_MediaFeatures_GtkThemeFamily();
624 void Gecko_GetSafeAreaInsets(const nsPresContext
*, float*, float*, float*,
627 void Gecko_PrintfStderr(const nsCString
*);
631 #endif // mozilla_GeckoBindings_h