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/ComputedTimingFunction.h"
21 #include "mozilla/PreferenceSheet.h"
22 #include "nsStyleStruct.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
;
44 } // namespace mozilla
47 const bool GECKO_IS_NIGHTLY
= true;
49 const bool GECKO_IS_NIGHTLY
= false;
52 #define NS_DECL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \
53 void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr); \
54 void Gecko_Release##name_##ArbitraryThread(class_* aPtr);
55 #define NS_IMPL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \
56 static_assert(class_::HasThreadSafeRefCnt::value, \
57 "NS_DECL_THREADSAFE_FFI_REFCOUNTING can only be used with " \
58 "classes that have thread-safe refcounting"); \
59 void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr) { NS_ADDREF(aPtr); } \
60 void Gecko_Release##name_##ArbitraryThread(class_* aPtr) { NS_RELEASE(aPtr); }
64 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsIURI
, nsIURI
);
67 void Gecko_Element_DebugListAttributes(const mozilla::dom::Element
*,
70 void Gecko_Snapshot_DebugListAttributes(const mozilla::ServoElementSnapshot
*,
73 bool Gecko_IsSignificantChild(const nsINode
*, bool whitespace_is_significant
);
75 const nsINode
* Gecko_GetLastChild(const nsINode
*);
76 const nsINode
* Gecko_GetFlattenedTreeParentNode(const nsINode
*);
77 const mozilla::dom::Element
* Gecko_GetBeforeOrAfterPseudo(
78 const mozilla::dom::Element
*, bool is_before
);
79 const mozilla::dom::Element
* Gecko_GetMarkerPseudo(
80 const mozilla::dom::Element
*);
82 nsTArray
<nsIContent
*>* Gecko_GetAnonymousContentForElement(
83 const mozilla::dom::Element
*);
84 void Gecko_DestroyAnonymousContentList(nsTArray
<nsIContent
*>* anon_content
);
86 const nsTArray
<RefPtr
<nsINode
>>* Gecko_GetAssignedNodes(
87 const mozilla::dom::Element
*);
89 void Gecko_ComputedStyle_Init(mozilla::ComputedStyle
* context
,
90 const ServoComputedData
* values
,
91 mozilla::PseudoStyleType pseudo_type
);
93 void Gecko_ComputedStyle_Destroy(mozilla::ComputedStyle
* context
);
95 // By default, Servo walks the DOM by traversing the siblings of the DOM-view
96 // first child. This generally works, but misses anonymous children, which we
97 // want to traverse during styling. To support these cases, we create an
98 // optional stack-allocated iterator in aIterator for nodes that need it.
99 void Gecko_ConstructStyleChildrenIterator(const mozilla::dom::Element
*,
100 mozilla::dom::StyleChildrenIterator
*);
102 void Gecko_DestroyStyleChildrenIterator(mozilla::dom::StyleChildrenIterator
*);
104 const nsINode
* Gecko_GetNextStyleChild(mozilla::dom::StyleChildrenIterator
*);
106 nsAtom
* Gecko_Element_ImportedPart(const nsAttrValue
*, nsAtom
*);
107 nsAtom
** Gecko_Element_ExportedParts(const nsAttrValue
*, nsAtom
*,
110 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::SheetLoadDataHolder
,
111 SheetLoadDataHolder
);
113 void Gecko_StyleSheet_FinishAsyncParse(
114 mozilla::css::SheetLoadDataHolder
* data
,
115 mozilla::StyleStrong
<RawServoStyleSheetContents
> sheet_contents
,
116 mozilla::StyleOwnedOrNull
<StyleUseCounters
> use_counters
);
118 mozilla::StyleSheet
* Gecko_LoadStyleSheet(
119 mozilla::css::Loader
* loader
, mozilla::StyleSheet
* parent
,
120 mozilla::css::SheetLoadData
* parent_load_data
,
121 mozilla::css::LoaderReusableStyleSheets
* reusable_sheets
,
122 const mozilla::StyleCssUrl
* url
,
123 mozilla::StyleStrong
<RawServoMediaList
> media_list
);
125 void Gecko_LoadStyleSheetAsync(mozilla::css::SheetLoadDataHolder
* parent_data
,
126 const mozilla::StyleCssUrl
* url
,
127 mozilla::StyleStrong
<RawServoMediaList
>,
128 mozilla::StyleStrong
<RawServoImportRule
>);
130 // Selector Matching.
131 uint64_t Gecko_ElementState(const mozilla::dom::Element
*);
132 bool Gecko_IsRootElement(const mozilla::dom::Element
*);
134 bool Gecko_MatchLang(const mozilla::dom::Element
*, nsAtom
* override_lang
,
135 bool has_override_lang
, const char16_t
* value
);
137 nsAtom
* Gecko_GetXMLLangValue(const mozilla::dom::Element
*);
139 mozilla::dom::Document::DocumentTheme
Gecko_GetDocumentLWTheme(
140 const mozilla::dom::Document
*);
142 const mozilla::PreferenceSheet::Prefs
* Gecko_GetPrefSheetPrefs(
143 const mozilla::dom::Document
*);
145 bool Gecko_IsTableBorderNonzero(const mozilla::dom::Element
* element
);
146 bool Gecko_IsBrowserFrame(const mozilla::dom::Element
* element
);
147 bool Gecko_IsSelectListBox(const mozilla::dom::Element
* element
);
150 #define SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_) \
151 nsAtom* prefix_##LangValue(implementor_ element); \
152 bool prefix_##HasAttr(implementor_ element, nsAtom* ns, nsAtom* name); \
153 bool prefix_##AttrEquals(implementor_ element, nsAtom* ns, nsAtom* name, \
154 nsAtom* str, bool ignoreCase); \
155 bool prefix_##AttrDashEquals(implementor_ element, nsAtom* ns, nsAtom* name, \
156 nsAtom* str, bool ignore_case); \
157 bool prefix_##AttrIncludes(implementor_ element, nsAtom* ns, nsAtom* name, \
158 nsAtom* str, bool ignore_case); \
159 bool prefix_##AttrHasSubstring(implementor_ element, nsAtom* ns, \
160 nsAtom* name, nsAtom* str, bool ignore_case); \
161 bool prefix_##AttrHasPrefix(implementor_ element, nsAtom* ns, nsAtom* name, \
162 nsAtom* str, bool ignore_case); \
163 bool prefix_##AttrHasSuffix(implementor_ element, nsAtom* ns, nsAtom* name, \
164 nsAtom* str, bool ignore_case);
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::StyleStrong
<RawServoDeclarationBlock
>*
179 Gecko_GetStyleAttrDeclarationBlock(const mozilla::dom::Element
* element
);
181 void Gecko_UnsetDirtyStyleAttr(const mozilla::dom::Element
* element
);
183 const mozilla::StyleStrong
<RawServoDeclarationBlock
>*
184 Gecko_GetHTMLPresentationAttrDeclarationBlock(
185 const mozilla::dom::Element
* element
);
187 const mozilla::StyleStrong
<RawServoDeclarationBlock
>*
188 Gecko_GetExtraContentStyleDeclarations(const mozilla::dom::Element
* element
);
190 const mozilla::StyleStrong
<RawServoDeclarationBlock
>*
191 Gecko_GetUnvisitedLinkAttrDeclarationBlock(
192 const mozilla::dom::Element
* element
);
194 const mozilla::StyleStrong
<RawServoDeclarationBlock
>*
195 Gecko_GetVisitedLinkAttrDeclarationBlock(const mozilla::dom::Element
* element
);
197 const mozilla::StyleStrong
<RawServoDeclarationBlock
>*
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 RawServoAnimationValueMap
* aAnimationValues
);
211 bool Gecko_StyleAnimationsEquals(
212 const nsStyleAutoArray
<mozilla::StyleAnimation
>*,
213 const nsStyleAutoArray
<mozilla::StyleAnimation
>*);
215 void Gecko_CopyAnimationNames(
216 nsStyleAutoArray
<mozilla::StyleAnimation
>* aDest
,
217 const nsStyleAutoArray
<mozilla::StyleAnimation
>* aSrc
);
219 // This function takes an already addrefed nsAtom
220 void Gecko_SetAnimationName(mozilla::StyleAnimation
* aStyleAnimation
,
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 RawServoAnimationValue
* Gecko_ElementTransitions_EndValueAt(
244 const mozilla::dom::Element
* aElementOrPseudo
, size_t aIndex
);
246 double Gecko_GetProgressFromComputedTiming(const mozilla::ComputedTiming
*);
248 double Gecko_GetPositionInSegment(
249 const mozilla::AnimationPropertySegment
*, double aProgress
,
250 mozilla::ComputedTimingFunction::BeforeFlag aBeforeFlag
);
252 // Get servo's AnimationValue for |aProperty| from the cached base style
254 // |aBaseStyles| is nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>.
255 // We use RawServoAnimationValueTableBorrowed to avoid exposing
256 // nsRefPtrHashtable in FFI.
257 const RawServoAnimationValue
* Gecko_AnimationGetBaseStyle(
258 const RawServoAnimationValueTable
* aBaseStyles
, nsCSSPropertyID aProperty
);
260 void Gecko_StyleTransition_SetUnsupportedProperty(
261 mozilla::StyleTransition
* aTransition
, nsAtom
* aAtom
);
264 nsAtom
* Gecko_Atomize(const char* aString
, uint32_t aLength
);
265 nsAtom
* Gecko_Atomize16(const nsAString
* aString
);
266 void Gecko_AddRefAtom(nsAtom
* aAtom
);
267 void Gecko_ReleaseAtom(nsAtom
* aAtom
);
269 // will not run destructors on dst, give it uninitialized memory
270 // font_id is LookAndFeel::FontID
271 void Gecko_nsFont_InitSystem(nsFont
* dst
, mozilla::StyleSystemFont font_id
,
272 const nsStyleFont
* font
,
273 const mozilla::dom::Document
*);
275 void Gecko_nsFont_Destroy(nsFont
* dst
);
277 // The gfxFontFeatureValueSet returned from this function has zero reference.
278 gfxFontFeatureValueSet
* Gecko_ConstructFontFeatureValueSet();
280 nsTArray
<uint32_t>* Gecko_AppendFeatureValueHashEntry(
281 gfxFontFeatureValueSet
* value_set
, nsAtom
* family
, uint32_t alternate
,
284 // Font variant alternates
285 void Gecko_ClearAlternateValues(nsFont
* font
, size_t length
);
287 void Gecko_AppendAlternateValues(nsFont
* font
, uint32_t alternate_name
,
290 void Gecko_CopyAlternateValuesFrom(nsFont
* dest
, const nsFont
* src
);
293 void Gecko_SetImageOrientation(nsStyleVisibility
* aVisibility
,
294 uint8_t aOrientation
, bool aFlip
);
296 void Gecko_SetImageOrientationAsFromImage(nsStyleVisibility
* aVisibility
);
298 void Gecko_CopyImageOrientationFrom(nsStyleVisibility
* aDst
,
299 const nsStyleVisibility
* aSrc
);
302 void Gecko_CounterStyle_ToPtr(const mozilla::StyleCounterStyle
*,
303 mozilla::CounterStylePtr
*);
305 void Gecko_SetCounterStyleToNone(mozilla::CounterStylePtr
*);
307 void Gecko_SetCounterStyleToString(mozilla::CounterStylePtr
* ptr
,
308 const nsACString
* symbol
);
310 void Gecko_CopyCounterStyle(mozilla::CounterStylePtr
* dst
,
311 const mozilla::CounterStylePtr
* src
);
313 nsAtom
* Gecko_CounterStyle_GetName(const mozilla::CounterStylePtr
* ptr
);
315 const mozilla::AnonymousCounterStyle
* Gecko_CounterStyle_GetAnonymous(
316 const mozilla::CounterStylePtr
* ptr
);
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_SetNodeFlags(const nsINode
* node
, uint32_t flags
);
328 void Gecko_UnsetNodeFlags(const nsINode
* node
, uint32_t flags
);
329 void Gecko_NoteDirtyElement(const mozilla::dom::Element
*);
330 void Gecko_NoteDirtySubtreeForInvalidation(const mozilla::dom::Element
*);
331 void Gecko_NoteAnimationOnlyDirtyElement(const mozilla::dom::Element
*);
333 bool Gecko_AnimationNameMayBeReferencedFromStyle(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 // Get an element snapshot for a given element from the table.
349 const mozilla::ServoElementSnapshot
* Gecko_GetElementSnapshot(
350 const mozilla::ServoElementSnapshotTable
* table
,
351 const mozilla::dom::Element
*);
353 // Have we seen this pointer before?
354 bool Gecko_HaveSeenPtr(mozilla::SeenPtrs
* table
, const void* ptr
);
356 // `array` must be an nsTArray
357 // If changing this signature, please update the
358 // friend function declaration in nsTArray.h
359 void Gecko_EnsureTArrayCapacity(void* array
, size_t capacity
, size_t elem_size
);
361 // Same here, `array` must be an nsTArray<T>, for some T.
363 // Important note: Only valid for POD types, since destructors won't be run
364 // otherwise. This is ensured with rust traits for the relevant structs.
365 void Gecko_ClearPODTArray(void* array
, size_t elem_size
, size_t elem_align
);
367 void Gecko_ResizeTArrayForStrings(nsTArray
<nsString
>* array
, uint32_t length
);
368 void Gecko_ResizeAtomArray(nsTArray
<RefPtr
<nsAtom
>>* array
, uint32_t length
);
370 void Gecko_EnsureImageLayersLength(nsStyleImageLayers
* layers
, size_t len
,
371 nsStyleImageLayers::LayerType layer_type
);
373 void Gecko_EnsureStyleAnimationArrayLength(void* array
, size_t len
);
374 void Gecko_EnsureStyleTransitionArrayLength(void* array
, size_t len
);
376 // Searches from the beginning of |keyframes| for a Keyframe object with the
377 // specified offset and timing function. If none is found, a new Keyframe object
378 // with the specified |offset| and |timingFunction| will be prepended to
381 // @param keyframes An array of Keyframe objects, sorted by offset.
382 // The first Keyframe in the array, if any, MUST have an
383 // offset greater than or equal to |offset|.
384 // @param offset The offset to search for, or, if no suitable Keyframe is
385 // found, the offset to use for the created Keyframe.
386 // Must be a floating point number in the range [0.0, 1.0].
387 // @param timingFunction The timing function to match, or, if no suitable
388 // Keyframe is found, to set on the created Keyframe.
390 // @returns The matching or created Keyframe.
391 mozilla::Keyframe
* Gecko_GetOrCreateKeyframeAtStart(
392 nsTArray
<mozilla::Keyframe
>* keyframes
, float offset
,
393 const nsTimingFunction
* timingFunction
);
395 // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
396 // from the beginning of |keyframes| for a Keyframe with matching timing
397 // function and an offset of 0.0.
398 // Furthermore, if a matching Keyframe is not found, a new Keyframe will be
399 // inserted after the *last* Keyframe in |keyframes| with offset 0.0.
400 mozilla::Keyframe
* Gecko_GetOrCreateInitialKeyframe(
401 nsTArray
<mozilla::Keyframe
>* keyframes
,
402 const nsTimingFunction
* timingFunction
);
404 // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
405 // from the *end* of |keyframes| for a Keyframe with matching timing function
406 // and an offset of 1.0. If a matching Keyframe is not found, a new Keyframe
407 // will be appended to the end of |keyframes|.
408 mozilla::Keyframe
* Gecko_GetOrCreateFinalKeyframe(
409 nsTArray
<mozilla::Keyframe
>* keyframes
,
410 const nsTimingFunction
* timingFunction
);
412 // Appends and returns a new PropertyValuePair to |aProperties| initialized with
413 // its mProperty member set to |aProperty| and all other members initialized to
414 // their default values.
415 mozilla::PropertyValuePair
* Gecko_AppendPropertyValuePair(
416 nsTArray
<mozilla::PropertyValuePair
>*, nsCSSPropertyID aProperty
);
418 void Gecko_ResetFilters(nsStyleEffects
* effects
, size_t new_len
);
420 void Gecko_CopyFiltersFrom(nsStyleEffects
* aSrc
, nsStyleEffects
* aDest
);
422 void Gecko_nsStyleSVG_SetDashArrayLength(nsStyleSVG
* svg
, uint32_t len
);
424 void Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG
* dst
, const nsStyleSVG
* src
);
426 void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG
* svg
, uint32_t len
);
428 void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG
* dst
,
429 const nsStyleSVG
* src
);
431 void Gecko_GetComputedURLSpec(const mozilla::StyleComputedUrl
* url
,
434 void Gecko_GetComputedImageURLSpec(const mozilla::StyleComputedUrl
* url
,
437 // Return true if the given image MIME type is supported
438 bool Gecko_IsSupportedImageMimeType(const uint8_t* mime_type
,
441 void Gecko_nsIURI_Debug(nsIURI
*, nsCString
* spec
);
443 void Gecko_nsIReferrerInfo_Debug(nsIReferrerInfo
* aReferrerInfo
,
446 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::URLExtraData
, URLExtraData
);
447 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsIReferrerInfo
, nsIReferrerInfo
);
449 void Gecko_FillAllImageLayers(nsStyleImageLayers
* layers
, uint32_t max_len
);
451 float Gecko_FontStretch_ToFloat(mozilla::FontStretch aStretch
);
453 void Gecko_FontStretch_SetFloat(mozilla::FontStretch
* aStretch
,
456 void Gecko_LoadData_Drop(mozilla::StyleLoadData
*);
458 float Gecko_FontSlantStyle_ToFloat(mozilla::FontSlantStyle aStyle
);
459 void Gecko_FontSlantStyle_SetNormal(mozilla::FontSlantStyle
*);
460 void Gecko_FontSlantStyle_SetItalic(mozilla::FontSlantStyle
*);
462 void Gecko_FontSlantStyle_SetOblique(mozilla::FontSlantStyle
*,
463 float angle_degrees
);
465 void Gecko_FontSlantStyle_Get(mozilla::FontSlantStyle
, bool* normal
,
466 bool* italic
, float* oblique_angle
);
468 float Gecko_FontWeight_ToFloat(mozilla::FontWeight aWeight
);
470 void Gecko_FontWeight_SetFloat(mozilla::FontWeight
* aWeight
, float aFloatValue
);
472 void Gecko_nsStyleFont_SetLang(nsStyleFont
* font
, nsAtom
* atom
);
474 void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont
* aFont
,
475 const nsStyleFont
* aSource
);
477 mozilla::Length
Gecko_nsStyleFont_ComputeMinSize(const nsStyleFont
*,
478 const mozilla::dom::Document
*);
480 // Computes the default generic font for a generic family and language.
481 mozilla::StyleGenericFontFamily
Gecko_nsStyleFont_ComputeDefaultFontType(
482 const mozilla::dom::Document
*,
483 mozilla::StyleGenericFontFamily generic_family
, nsAtom
* language
);
485 mozilla::StyleDefaultFontSizes
Gecko_GetBaseSize(nsAtom
* lang
);
487 struct GeckoFontMetrics
{
488 mozilla::Length mXSize
;
489 mozilla::Length mChSize
; // negatives indicate not found.
492 GeckoFontMetrics
Gecko_GetFontMetrics(const nsPresContext
*, bool is_vertical
,
493 const nsStyleFont
* font
,
494 mozilla::Length font_size
,
495 bool use_user_font_set
);
497 mozilla::StyleSheet
* Gecko_StyleSheet_Clone(
498 const mozilla::StyleSheet
* aSheet
,
499 const mozilla::StyleSheet
* aNewParentSheet
);
501 void Gecko_StyleSheet_AddRef(const mozilla::StyleSheet
* aSheet
);
502 void Gecko_StyleSheet_Release(const mozilla::StyleSheet
* aSheet
);
503 bool Gecko_IsDocumentBody(const mozilla::dom::Element
* element
);
505 // We use an int32_t here instead of a LookAndFeel::ColorID
506 // because forward-declaring a nested enum/struct is impossible
507 nscolor
Gecko_GetLookAndFeelSystemColor(int32_t color_id
,
508 const mozilla::dom::Document
*,
509 mozilla::StyleSystemColorScheme
,
510 const mozilla::StyleColorScheme
*);
512 int32_t Gecko_GetLookAndFeelInt(int32_t int_id
);
514 void Gecko_AddPropertyToSet(nsCSSPropertyIDSet
*, nsCSSPropertyID
);
516 // Style-struct management.
517 #define STYLE_STRUCT(name) \
518 void Gecko_Construct_Default_nsStyle##name(nsStyle##name* ptr, \
519 const mozilla::dom::Document*); \
520 void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \
521 const nsStyle##name* other); \
522 void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr);
523 #include "nsStyleStructList.h"
526 bool Gecko_DocumentRule_UseForPresentation(
527 const mozilla::dom::Document
*, const nsACString
* aPattern
,
528 mozilla::css::DocumentMatchingFunction
);
530 // Allocator hinting.
531 void Gecko_SetJemallocThreadLocalArena(bool enabled
);
533 // Pseudo-element flags.
534 #define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
535 const uint32_t SERVO_CSS_PSEUDO_ELEMENT_FLAGS_##name_ = flags_;
536 #include "nsCSSPseudoElementList.h"
537 #undef CSS_PSEUDO_ELEMENT
539 bool Gecko_ErrorReportingEnabled(const mozilla::StyleSheet
* sheet
,
540 const mozilla::css::Loader
* loader
,
541 uint64_t* aOutWindowId
);
543 void Gecko_ReportUnexpectedCSSError(
544 uint64_t windowId
, nsIURI
* uri
, const char* message
, const char* param
,
545 uint32_t paramLen
, const char* prefix
, const char* prefixParam
,
546 uint32_t prefixParamLen
, const char* suffix
, const char* source
,
547 uint32_t sourceLen
, const char* selectors
, uint32_t selectorsLen
,
548 uint32_t lineNumber
, uint32_t colNumber
);
551 void Gecko_ContentList_AppendAll(nsSimpleContentList
* aContentList
,
552 const mozilla::dom::Element
** aElements
,
555 // FIXME(emilio): These two below should be a single function that takes a
556 // `const DocumentOrShadowRoot*`, but that doesn't make MSVC builds happy for a
557 // reason I haven't really dug into.
558 const nsTArray
<mozilla::dom::Element
*>* Gecko_Document_GetElementsWithId(
559 const mozilla::dom::Document
*, nsAtom
* aId
);
561 const nsTArray
<mozilla::dom::Element
*>* Gecko_ShadowRoot_GetElementsWithId(
562 const mozilla::dom::ShadowRoot
*, nsAtom
* aId
);
564 // Check the value of the given bool preference. The pref name needs to
565 // be null-terminated.
566 bool Gecko_GetBoolPrefValue(const char* pref_name
);
568 // Returns true if we're currently performing the servo traversal.
569 bool Gecko_IsInServoTraversal();
571 // Returns true if we're currently on the main thread.
572 bool Gecko_IsMainThread();
574 // Media feature helpers.
576 // Defined in nsMediaFeatures.cpp.
577 mozilla::StyleDisplayMode
Gecko_MediaFeatures_GetDisplayMode(
578 const mozilla::dom::Document
*);
580 bool Gecko_MediaFeatures_ShouldAvoidNativeTheme(const mozilla::dom::Document
*);
581 uint32_t Gecko_MediaFeatures_GetColorDepth(const mozilla::dom::Document
*);
582 uint32_t Gecko_MediaFeatures_GetMonochromeBitsPerPixel(
583 const mozilla::dom::Document
*);
585 void Gecko_MediaFeatures_GetDeviceSize(const mozilla::dom::Document
*,
586 nscoord
* width
, nscoord
* height
);
588 float Gecko_MediaFeatures_GetResolution(const mozilla::dom::Document
*);
589 bool Gecko_MediaFeatures_PrefersReducedMotion(const mozilla::dom::Document
*);
590 mozilla::StylePrefersContrast
Gecko_MediaFeatures_PrefersContrast(
591 const mozilla::dom::Document
*);
592 mozilla::StylePrefersColorScheme
Gecko_MediaFeatures_PrefersColorScheme(
593 const mozilla::dom::Document
*);
595 mozilla::PointerCapabilities
Gecko_MediaFeatures_PrimaryPointerCapabilities(
596 const mozilla::dom::Document
*);
598 mozilla::PointerCapabilities
Gecko_MediaFeatures_AllPointerCapabilities(
599 const mozilla::dom::Document
*);
601 float Gecko_MediaFeatures_GetDevicePixelRatio(const mozilla::dom::Document
*);
603 bool Gecko_MediaFeatures_IsResourceDocument(const mozilla::dom::Document
*);
604 nsAtom
* Gecko_MediaFeatures_GetOperatingSystemVersion(
605 const mozilla::dom::Document
*);
607 void Gecko_GetSafeAreaInsets(const nsPresContext
*, float*, float*, float*,
610 void Gecko_PrintfStderr(const nsCString
*);
614 #endif // mozilla_GeckoBindings_h