tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

GeckoBindings.h (28425B)


      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/. */
      6 
      7 /* FFI functions for Servo to call into Gecko */
      8 
      9 #ifndef mozilla_GeckoBindings_h
     10 #define mozilla_GeckoBindings_h
     11 
     12 #include <stdint.h>
     13 
     14 #include "COLRFonts.h"
     15 #include "mozilla/EffectCompositor.h"
     16 #include "mozilla/PreferenceSheet.h"
     17 #include "mozilla/ServoBindingTypes.h"
     18 #include "mozilla/ServoTypes.h"
     19 #include "mozilla/css/DocumentMatchingFunction.h"
     20 #include "mozilla/css/SheetLoadData.h"
     21 #include "mozilla/dom/Document.h"
     22 #include "nsStyleStruct.h"
     23 #include "nsStyleStructList.h"
     24 
     25 class nsAtom;
     26 class nsIURI;
     27 class nsSimpleContentList;
     28 struct nsFont;
     29 class ServoComputedData;
     30 
     31 namespace mozilla {
     32 class ComputedStyle;
     33 class SeenPtrs;
     34 class ServoElementSnapshot;
     35 class ServoElementSnapshotTable;
     36 class StyleSheet;
     37 enum class PseudoStyleType : uint8_t;
     38 enum class PointerCapabilities : uint8_t;
     39 enum class UpdateAnimationsTasks : uint8_t;
     40 enum class StyleColorGamut : uint8_t;
     41 struct Keyframe;
     42 struct StyleStylesheetContents;
     43 
     44 namespace css {
     45 class LoaderReusableStyleSheets;
     46 }
     47 namespace dom {
     48 enum class CompositeOperationOrAuto : uint8_t;
     49 }  // namespace dom
     50 }  // namespace mozilla
     51 
     52 #ifdef NIGHTLY_BUILD
     53 const bool GECKO_IS_NIGHTLY = true;
     54 #else
     55 const bool GECKO_IS_NIGHTLY = false;
     56 #endif
     57 
     58 template <typename T>
     59 struct RustSpan {
     60  T* begin;
     61  size_t length;
     62 };
     63 
     64 template struct RustSpan<const mozilla::dom::Element* const>;
     65 template struct RustSpan<const nsINode* const>;
     66 
     67 #define NS_DECL_THREADSAFE_FFI_REFCOUNTING(class_, name_)  \
     68  void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr); \
     69  void Gecko_Release##name_##ArbitraryThread(class_* aPtr);
     70 #define NS_IMPL_THREADSAFE_FFI_REFCOUNTING(class_, name_)                      \
     71  static_assert(class_::HasThreadSafeRefCnt::value,                            \
     72                "NS_DECL_THREADSAFE_FFI_REFCOUNTING can only be used with "    \
     73                "classes that have thread-safe refcounting");                  \
     74  void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr) { NS_ADDREF(aPtr); } \
     75  void Gecko_Release##name_##ArbitraryThread(class_* aPtr) { NS_RELEASE(aPtr); }
     76 
     77 extern "C" {
     78 
     79 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsIURI, nsIURI);
     80 
     81 // Debugging stuff.
     82 void Gecko_Element_DebugListAttributes(const mozilla::dom::Element*,
     83                                       nsCString*);
     84 
     85 void Gecko_Snapshot_DebugListAttributes(const mozilla::ServoElementSnapshot*,
     86                                        nsCString*);
     87 
     88 bool Gecko_IsSignificantChild(const nsINode*, bool whitespace_is_significant);
     89 
     90 const nsINode* Gecko_GetLastChild(const nsINode*);
     91 const nsINode* Gecko_GetFlattenedTreeParentNode(const nsINode*);
     92 void Gecko_GetAnonymousContentForElement(const mozilla::dom::Element*,
     93                                         nsTArray<nsIContent*>*);
     94 
     95 RustSpan<const nsINode* const> Gecko_GetAssignedNodes(
     96    const mozilla::dom::Element*);
     97 
     98 void Gecko_GetQueryContainerSize(const mozilla::dom::Element*,
     99                                 nscoord* aOutWidth, nscoord* aOutHeight);
    100 
    101 void Gecko_ComputedStyle_Init(mozilla::ComputedStyle* context,
    102                              const ServoComputedData* values,
    103                              mozilla::PseudoStyleType pseudo_type);
    104 
    105 void Gecko_ComputedStyle_Destroy(mozilla::ComputedStyle* context);
    106 
    107 // By default, Servo walks the DOM by traversing the siblings of the DOM-view
    108 // first child. This generally works, but misses anonymous children, which we
    109 // want to traverse during styling. To support these cases, we create an
    110 // optional stack-allocated iterator in aIterator for nodes that need it.
    111 void Gecko_ConstructStyleChildrenIterator(const mozilla::dom::Element*,
    112                                          mozilla::dom::StyleChildrenIterator*);
    113 
    114 void Gecko_DestroyStyleChildrenIterator(mozilla::dom::StyleChildrenIterator*);
    115 
    116 const nsINode* Gecko_GetNextStyleChild(mozilla::dom::StyleChildrenIterator*);
    117 
    118 nsAtom* Gecko_Element_ImportedPart(const nsAttrValue*, nsAtom*);
    119 nsAtom** Gecko_Element_ExportedParts(const nsAttrValue*, nsAtom*,
    120                                     size_t* aOutLength);
    121 uint64_t Gecko_Element_GetSubtreeBloomFilter(const mozilla::dom::Element*);
    122 
    123 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::SheetLoadDataHolder,
    124                                   SheetLoadDataHolder);
    125 
    126 void Gecko_StyleSheet_FinishAsyncParse(
    127    mozilla::css::SheetLoadDataHolder* data,
    128    mozilla::StyleStrong<mozilla::StyleStylesheetContents> sheet_contents);
    129 
    130 mozilla::StyleSheet* Gecko_LoadStyleSheet(
    131    mozilla::css::Loader* loader, mozilla::StyleSheet* parent,
    132    mozilla::css::SheetLoadData* parent_load_data,
    133    mozilla::css::LoaderReusableStyleSheets* reusable_sheets,
    134    const mozilla::StyleCssUrl* url,
    135    mozilla::StyleStrong<mozilla::StyleLockedMediaList> media_list);
    136 
    137 void Gecko_LoadStyleSheetAsync(
    138    mozilla::css::SheetLoadDataHolder* parent_data,
    139    const mozilla::StyleCssUrl* url,
    140    mozilla::StyleStrong<mozilla::StyleLockedMediaList>,
    141    mozilla::StyleStrong<mozilla::StyleLockedImportRule>);
    142 
    143 // Selector Matching.
    144 uint64_t Gecko_ElementState(const mozilla::dom::Element*);
    145 bool Gecko_IsRootElement(const mozilla::dom::Element*);
    146 
    147 bool Gecko_MatchLang(const mozilla::dom::Element*, nsAtom* override_lang,
    148                     bool has_override_lang, const char16_t* value);
    149 
    150 bool Gecko_MatchViewTransitionClass(const mozilla::dom::Element*,
    151                                    const nsTArray<mozilla::StyleAtom>*);
    152 
    153 nsAtom* Gecko_GetXMLLangValue(const mozilla::dom::Element*);
    154 
    155 const mozilla::PreferenceSheet::Prefs* Gecko_GetPrefSheetPrefs(
    156    const mozilla::dom::Document*);
    157 
    158 bool Gecko_IsTableBorderNonzero(const mozilla::dom::Element* element);
    159 bool Gecko_IsSelectListBox(const mozilla::dom::Element* element);
    160 bool Gecko_HasActiveViewTransitionTypes(
    161    const mozilla::dom::Document*, const nsTArray<mozilla::StyleCustomIdent>*);
    162 
    163 // Attributes.
    164 #define SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_) \
    165  nsAtom* prefix_##LangValue(implementor_ element);
    166 
    167 bool Gecko_LookupAttrValue(const mozilla::dom::Element* aElement,
    168                           const nsAtom& aName, nsAString& aResult);
    169 bool Gecko_AttrEquals(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
    170 bool Gecko_AttrDashEquals(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
    171 bool Gecko_AttrIncludes(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
    172 bool Gecko_AttrHasSubstring(const nsAttrValue*, const nsAtom*,
    173                            bool aIgnoreCase);
    174 bool Gecko_AttrHasPrefix(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
    175 bool Gecko_AttrHasSuffix(const nsAttrValue*, const nsAtom*, bool aIgnoreCase);
    176 
    177 bool Gecko_AssertClassAttrValueIsSane(const nsAttrValue*);
    178 const nsAttrValue* Gecko_GetSVGAnimatedClass(const mozilla::dom::Element*);
    179 
    180 SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_,
    181                                              const mozilla::dom::Element*)
    182 
    183 SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(
    184    Gecko_Snapshot, const mozilla::ServoElementSnapshot*)
    185 
    186 #undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS
    187 
    188 // Style attributes.
    189 const mozilla::StyleLockedDeclarationBlock* Gecko_GetStyleAttrDeclarationBlock(
    190    const mozilla::dom::Element* element);
    191 
    192 void Gecko_UnsetDirtyStyleAttr(const mozilla::dom::Element* element);
    193 
    194 const mozilla::StyleLockedDeclarationBlock* Gecko_GetViewTransitionDynamicRule(
    195    const mozilla::dom::Element* element);
    196 
    197 const mozilla::StyleLockedDeclarationBlock*
    198 Gecko_GetHTMLPresentationAttrDeclarationBlock(
    199    const mozilla::dom::Element* element);
    200 
    201 const mozilla::StyleLockedDeclarationBlock*
    202 Gecko_GetExtraContentStyleDeclarations(const mozilla::dom::Element* element);
    203 
    204 const mozilla::StyleLockedDeclarationBlock*
    205 Gecko_GetUnvisitedLinkAttrDeclarationBlock(
    206    const mozilla::dom::Element* element);
    207 
    208 const mozilla::StyleLockedDeclarationBlock*
    209 Gecko_GetVisitedLinkAttrDeclarationBlock(const mozilla::dom::Element* element);
    210 
    211 const mozilla::StyleLockedDeclarationBlock*
    212 Gecko_GetActiveLinkAttrDeclarationBlock(const mozilla::dom::Element* element);
    213 
    214 // Visited handling.
    215 
    216 // Returns whether visited styles are enabled for a given document.
    217 bool Gecko_VisitedStylesEnabled(const mozilla::dom::Document*);
    218 
    219 // Animations
    220 bool Gecko_GetAnimationRule(
    221    const mozilla::dom::Element* aElementOrPseudo,
    222    mozilla::EffectCompositor::CascadeLevel aCascadeLevel,
    223    mozilla::StyleAnimationValueMap* aAnimationValues);
    224 
    225 bool Gecko_StyleAnimationsEquals(
    226    const nsStyleAutoArray<mozilla::StyleAnimation>*,
    227    const nsStyleAutoArray<mozilla::StyleAnimation>*);
    228 
    229 bool Gecko_StyleScrollTimelinesEquals(
    230    const nsStyleAutoArray<mozilla::StyleScrollTimeline>*,
    231    const nsStyleAutoArray<mozilla::StyleScrollTimeline>*);
    232 
    233 bool Gecko_StyleViewTimelinesEquals(
    234    const nsStyleAutoArray<mozilla::StyleViewTimeline>*,
    235    const nsStyleAutoArray<mozilla::StyleViewTimeline>*);
    236 
    237 void Gecko_UpdateAnimations(const mozilla::dom::Element* aElementOrPseudo,
    238                            const mozilla::ComputedStyle* aOldComputedValues,
    239                            const mozilla::ComputedStyle* aComputedValues,
    240                            mozilla::UpdateAnimationsTasks aTasks);
    241 
    242 size_t Gecko_GetAnimationEffectCount(
    243    const mozilla::dom::Element* aElementOrPseudo);
    244 bool Gecko_ElementHasAnimations(const mozilla::dom::Element* aElementOrPseudo);
    245 bool Gecko_ElementHasCSSAnimations(
    246    const mozilla::dom::Element* aElementOrPseudo);
    247 bool Gecko_ElementHasCSSTransitions(
    248    const mozilla::dom::Element* aElementOrPseudo);
    249 bool Gecko_ElementHasWebAnimations(
    250    const mozilla::dom::Element* aElementOrPseudo);
    251 size_t Gecko_ElementTransitions_Length(
    252    const mozilla::dom::Element* aElementOrPseudo);
    253 
    254 NonCustomCSSPropertyId Gecko_ElementTransitions_PropertyAt(
    255    const mozilla::dom::Element* aElementOrPseudo, size_t aIndex);
    256 
    257 const mozilla::StyleAnimationValue* Gecko_ElementTransitions_EndValueAt(
    258    const mozilla::dom::Element* aElementOrPseudo, size_t aIndex);
    259 
    260 double Gecko_GetProgressFromComputedTiming(const mozilla::ComputedTiming*);
    261 
    262 double Gecko_GetPositionInSegment(const mozilla::AnimationPropertySegment*,
    263                                  double aProgress, bool aBeforeFlag);
    264 
    265 // Get servo's AnimationValue for |aProperty| from the cached base style
    266 // |aBaseStyles|.
    267 // |aBaseStyles| is nsRefPtrHashtable<nsGenericHashKey<CSSPropertyId>,
    268 // StyleAnimationValue>.
    269 // We use RawServoAnimationValueTableBorrowed to avoid exposing
    270 // nsRefPtrHashtable in FFI.
    271 const mozilla::StyleAnimationValue* Gecko_AnimationGetBaseStyle(
    272    const RawServoAnimationValueTable* aBaseStyles,
    273    const mozilla::CSSPropertyId* aProperty);
    274 
    275 void Gecko_StyleTransition_SetUnsupportedProperty(
    276    mozilla::StyleTransition* aTransition, nsAtom* aAtom);
    277 
    278 // Atoms.
    279 nsAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
    280 nsAtom* Gecko_Atomize16(const nsAString* aString);
    281 void Gecko_AddRefAtom(nsAtom* aAtom);
    282 void Gecko_ReleaseAtom(nsAtom* aAtom);
    283 
    284 // will not run destructors on dst, give it uninitialized memory
    285 // font_id is LookAndFeel::FontID
    286 void Gecko_nsFont_InitSystem(nsFont* dst, mozilla::StyleSystemFont font_id,
    287                             const nsStyleFont* font,
    288                             const mozilla::dom::Document*);
    289 
    290 void Gecko_nsFont_Destroy(nsFont* dst);
    291 
    292 // The gfxFontFeatureValueSet returned from this function has zero reference.
    293 gfxFontFeatureValueSet* Gecko_ConstructFontFeatureValueSet();
    294 
    295 nsTArray<uint32_t>* Gecko_AppendFeatureValueHashEntry(
    296    gfxFontFeatureValueSet* value_set, nsAtom* family, uint32_t alternate,
    297    nsAtom* name);
    298 
    299 // Font variant alternates
    300 void Gecko_ClearAlternateValues(nsFont* font, size_t length);
    301 
    302 void Gecko_AppendAlternateValues(nsFont* font, uint32_t alternate_name,
    303                                 nsAtom* atom);
    304 
    305 void Gecko_CopyAlternateValuesFrom(nsFont* dest, const nsFont* src);
    306 
    307 // The FontPaletteValueSet returned from this function has zero reference.
    308 mozilla::gfx::FontPaletteValueSet* Gecko_ConstructFontPaletteValueSet();
    309 
    310 mozilla::gfx::FontPaletteValueSet::PaletteValues*
    311 Gecko_AppendPaletteValueHashEntry(
    312    mozilla::gfx::FontPaletteValueSet* aPaletteValueSet, nsAtom* aFamily,
    313    nsAtom* aName);
    314 
    315 void Gecko_SetFontPaletteBase(
    316    mozilla::gfx::FontPaletteValueSet::PaletteValues* aValues,
    317    int32_t aBasePaletteIndex);
    318 
    319 void Gecko_SetFontPaletteOverride(
    320    mozilla::gfx::FontPaletteValueSet::PaletteValues* aValues, int32_t aIndex,
    321    mozilla::StyleAbsoluteColor* aColor);
    322 
    323 // Visibility style
    324 void Gecko_SetImageOrientation(nsStyleVisibility* aVisibility,
    325                               uint8_t aOrientation, bool aFlip);
    326 
    327 void Gecko_SetImageOrientationAsFromImage(nsStyleVisibility* aVisibility);
    328 
    329 void Gecko_CopyImageOrientationFrom(nsStyleVisibility* aDst,
    330                                    const nsStyleVisibility* aSrc);
    331 
    332 // list-style-image style.
    333 void Gecko_SetListStyleImageNone(nsStyleList* style_struct);
    334 
    335 void Gecko_SetListStyleImageImageValue(nsStyleList* style_struct,
    336                                       const mozilla::StyleComputedUrl* url);
    337 
    338 void Gecko_CopyListStyleImageFrom(nsStyleList* dest, const nsStyleList* src);
    339 
    340 // Dirtiness tracking.
    341 void Gecko_NoteDirtyElement(const mozilla::dom::Element*);
    342 void Gecko_NoteDirtySubtreeForInvalidation(const mozilla::dom::Element*);
    343 void Gecko_NoteAnimationOnlyDirtyElement(const mozilla::dom::Element*);
    344 void Gecko_InvalidatePositionTry(const mozilla::dom::Element*);
    345 
    346 bool Gecko_AnimationNameMayBeReferencedFromStyle(const nsPresContext*,
    347                                                 nsAtom* name);
    348 
    349 float Gecko_GetScrollbarInlineSize(const nsPresContext*);
    350 
    351 // Retrive pseudo type from an element.
    352 mozilla::PseudoStyleType Gecko_GetImplementedPseudoType(
    353    const mozilla::dom::Element*);
    354 // Retrive pseudo identifier from an element if any.
    355 nsAtom* Gecko_GetImplementedPseudoIdentifier(const mozilla::dom::Element*);
    356 
    357 // We'd like to return `nsChangeHint` here, but bindgen bitfield enums don't
    358 // work as return values with the Linux 32-bit ABI at the moment because
    359 // they wrap the value in a struct.
    360 uint32_t Gecko_CalcStyleDifference(const mozilla::ComputedStyle* old_style,
    361                                   const mozilla::ComputedStyle* new_style,
    362                                   bool* any_style_struct_changed,
    363                                   bool* reset_only_changed);
    364 
    365 nscoord Gecko_CalcLineHeight(const mozilla::StyleLineHeight*,
    366                             const nsPresContext*, bool aVertical,
    367                             const nsStyleFont* aAgainstFont,
    368                             const mozilla::dom::Element* aElement);
    369 
    370 // Get an element snapshot for a given element from the table.
    371 const mozilla::ServoElementSnapshot* Gecko_GetElementSnapshot(
    372    const mozilla::ServoElementSnapshotTable* table,
    373    const mozilla::dom::Element*);
    374 
    375 // Have we seen this pointer before?
    376 bool Gecko_HaveSeenPtr(mozilla::SeenPtrs* table, const void* ptr);
    377 
    378 void Gecko_EnsureImageLayersLength(nsStyleImageLayers* layers, size_t len,
    379                                   nsStyleImageLayers::LayerType layer_type);
    380 
    381 void Gecko_EnsureStyleAnimationArrayLength(void* array, size_t len);
    382 void Gecko_EnsureStyleTransitionArrayLength(void* array, size_t len);
    383 void Gecko_EnsureStyleScrollTimelineArrayLength(void* array, size_t len);
    384 void Gecko_EnsureStyleViewTimelineArrayLength(void* array, size_t len);
    385 
    386 // Searches from the beginning of |keyframes| for a Keyframe object with the
    387 // specified offset and timing function. If none is found, a new Keyframe object
    388 // with the specified |offset| and |timingFunction| will be prepended to
    389 // |keyframes|.
    390 //
    391 // @param keyframes  An array of Keyframe objects, sorted by offset.
    392 //                   The first Keyframe in the array, if any, MUST have an
    393 //                   offset greater than or equal to |offset|.
    394 // @param offset  The offset to search for, or, if no suitable Keyframe is
    395 //                found, the offset to use for the created Keyframe.
    396 //                Must be a floating point number in the range [0.0, 1.0].
    397 // @param timingFunction  The timing function to match, or, if no suitable
    398 //                        Keyframe is found, to set on the created Keyframe.
    399 // @param composition  The composition to match, or, if no suitable Keyframe is
    400 //                     found, to set on the created Keyframe.
    401 //
    402 // @returns  The matching or created Keyframe.
    403 mozilla::Keyframe* Gecko_GetOrCreateKeyframeAtStart(
    404    nsTArray<mozilla::Keyframe>* keyframes, float offset,
    405    const mozilla::StyleComputedTimingFunction* timingFunction,
    406    const mozilla::dom::CompositeOperationOrAuto composition);
    407 
    408 // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
    409 // from the beginning of |keyframes| for a Keyframe with matching timing
    410 // function, composition, and an offset of 0.0.
    411 // Furthermore, if a matching Keyframe is not found, a new Keyframe will be
    412 // inserted after the *last* Keyframe in |keyframes| with offset 0.0.
    413 mozilla::Keyframe* Gecko_GetOrCreateInitialKeyframe(
    414    nsTArray<mozilla::Keyframe>* keyframes,
    415    const mozilla::StyleComputedTimingFunction* timingFunction,
    416    const mozilla::dom::CompositeOperationOrAuto composition);
    417 
    418 // As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
    419 // from the *end* of |keyframes| for a Keyframe with matching timing function,
    420 // composition, and an offset of 1.0. If a matching Keyframe is not found, a new
    421 // Keyframe will be appended to the end of |keyframes|.
    422 mozilla::Keyframe* Gecko_GetOrCreateFinalKeyframe(
    423    nsTArray<mozilla::Keyframe>* keyframes,
    424    const mozilla::StyleComputedTimingFunction* timingFunction,
    425    const mozilla::dom::CompositeOperationOrAuto composition);
    426 
    427 void Gecko_ResetFilters(nsStyleEffects* effects, size_t new_len);
    428 
    429 void Gecko_CopyFiltersFrom(nsStyleEffects* aSrc, nsStyleEffects* aDest);
    430 
    431 void Gecko_nsStyleSVG_SetDashArrayLength(nsStyleSVG* svg, uint32_t len);
    432 
    433 void Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG* dst, const nsStyleSVG* src);
    434 
    435 void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* svg, uint32_t len);
    436 
    437 void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* dst,
    438                                            const nsStyleSVG* src);
    439 
    440 void Gecko_GetComputedURLSpec(const mozilla::StyleComputedUrl* url,
    441                              nsCString* spec);
    442 
    443 // Return true if the given image MIME type is supported
    444 bool Gecko_IsSupportedImageMimeType(const uint8_t* mime_type,
    445                                    const uint32_t len);
    446 
    447 void Gecko_nsIURI_Debug(nsIURI*, nsCString* spec);
    448 
    449 void Gecko_nsIReferrerInfo_Debug(nsIReferrerInfo* aReferrerInfo,
    450                                 nsCString* aOut);
    451 
    452 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::URLExtraData, URLExtraData);
    453 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsIReferrerInfo, nsIReferrerInfo);
    454 
    455 void Gecko_FillAllImageLayers(nsStyleImageLayers* layers, uint32_t max_len);
    456 
    457 void Gecko_LoadData_Drop(mozilla::StyleLoadData*);
    458 
    459 void Gecko_nsStyleFont_SetLang(nsStyleFont* font, nsAtom* atom);
    460 
    461 void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont,
    462                                    const nsStyleFont* aSource);
    463 
    464 mozilla::Length Gecko_nsStyleFont_ComputeMinSize(const nsStyleFont*,
    465                                                 const mozilla::dom::Document*);
    466 
    467 // Computes the default generic font for a language.
    468 mozilla::StyleGenericFontFamily
    469 Gecko_nsStyleFont_ComputeFallbackFontTypeForLanguage(
    470    const mozilla::dom::Document*, nsAtom* language);
    471 
    472 mozilla::Length Gecko_GetBaseSize(const mozilla::dom::Document*,
    473                                  nsAtom* language,
    474                                  mozilla::StyleGenericFontFamily);
    475 
    476 struct GeckoFontMetrics {
    477  mozilla::Length mXSize;
    478  mozilla::Length mChSize;     // negatives indicate not found.
    479  mozilla::Length mCapHeight;  // negatives indicate not found.
    480  mozilla::Length mIcWidth;    // negatives indicate not found.
    481  mozilla::Length mAscent;
    482  mozilla::Length mComputedEmSize;
    483  float mScriptPercentScaleDown;        // zero is invalid or means not found.
    484  float mScriptScriptPercentScaleDown;  // zero is invalid or means not found.
    485 };
    486 
    487 GeckoFontMetrics Gecko_GetFontMetrics(
    488    const nsPresContext*, bool is_vertical, const nsStyleFont* font,
    489    mozilla::Length font_size, mozilla::StyleQueryFontMetricsFlags flags);
    490 
    491 mozilla::StyleSheet* Gecko_StyleSheet_Clone(const mozilla::StyleSheet* aSheet);
    492 
    493 void Gecko_StyleSheet_AddRef(const mozilla::StyleSheet* aSheet);
    494 void Gecko_StyleSheet_Release(const mozilla::StyleSheet* aSheet);
    495 
    496 struct GeckoImplicitScopeRoot {
    497  const mozilla::dom::Element* mHost;
    498  const mozilla::dom::Element* mRoot;
    499  bool mConstructed;
    500 };
    501 GeckoImplicitScopeRoot Gecko_StyleSheet_ImplicitScopeRoot(
    502    const mozilla::StyleSheet* aSheet);
    503 
    504 bool Gecko_IsDocumentBody(const mozilla::dom::Element* element);
    505 
    506 bool Gecko_IsDarkColorScheme(const mozilla::dom::Document*,
    507                             const mozilla::StyleColorSchemeFlags*);
    508 nscolor Gecko_ComputeSystemColor(mozilla::StyleSystemColor,
    509                                 const mozilla::dom::Document*,
    510                                 const mozilla::StyleColorSchemeFlags*);
    511 
    512 // We use an int32_t here instead of a LookAndFeel::IntID/FloatID because
    513 // forward-declaring a nested enum/struct is impossible.
    514 int32_t Gecko_GetLookAndFeelInt(int32_t int_id);
    515 float Gecko_GetLookAndFeelFloat(int32_t float_id);
    516 
    517 void Gecko_AddPropertyToSet(nsCSSPropertyIDSet*, NonCustomCSSPropertyId);
    518 
    519 // Style-struct management.
    520 #define DECLARE_GECKO_FUNCTIONS(name)                                        \
    521  void Gecko_Construct_Default_nsStyle##name(nsStyle##name* ptr,             \
    522                                             const mozilla::dom::Document*); \
    523  void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr,                 \
    524                                         const nsStyle##name* other);        \
    525  void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr);
    526 FOR_EACH_STYLE_STRUCT(DECLARE_GECKO_FUNCTIONS, DECLARE_GECKO_FUNCTIONS)
    527 #undef DECLARE_GECKO_FUNCTIONS
    528 
    529 bool Gecko_DocumentRule_UseForPresentation(
    530    const mozilla::dom::Document*, const nsACString* aPattern,
    531    mozilla::css::DocumentMatchingFunction);
    532 
    533 // Allocator hinting.
    534 void Gecko_SetJemallocThreadLocalArena(bool enabled);
    535 
    536 // Pseudo-element flags.
    537 #define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
    538  const uint32_t SERVO_CSS_PSEUDO_ELEMENT_FLAGS_##name_ = flags_;
    539 #include "nsCSSPseudoElementList.h"
    540 #undef CSS_PSEUDO_ELEMENT
    541 
    542 bool Gecko_ErrorReportingEnabled(const mozilla::StyleSheet* sheet,
    543                                 const mozilla::css::Loader* loader,
    544                                 uint64_t* aOutWindowId);
    545 
    546 void Gecko_ReportUnexpectedCSSError(
    547    uint64_t windowId, nsIURI* uri, const char* message, const char* param,
    548    uint32_t paramLen, const char* prefix, const char* prefixParam,
    549    uint32_t prefixParamLen, const char* suffix, const char* selectors,
    550    uint32_t selectorsLen, uint32_t lineNumber, uint32_t colNumber);
    551 
    552 // DOM APIs.
    553 void Gecko_ContentList_AppendAll(nsSimpleContentList* aContentList,
    554                                 const mozilla::dom::Element** aElements,
    555                                 size_t aLength);
    556 
    557 // FIXME(emilio): These two below should be a single function that takes a
    558 // `const DocumentOrShadowRoot*`, but that doesn't make MSVC builds happy for a
    559 // reason I haven't really dug into.
    560 RustSpan<const mozilla::dom::Element* const> Gecko_Document_GetElementsWithId(
    561    const mozilla::dom::Document*, nsAtom* aId);
    562 
    563 RustSpan<const mozilla::dom::Element* const> Gecko_ShadowRoot_GetElementsWithId(
    564    const mozilla::dom::ShadowRoot*, nsAtom* aId);
    565 
    566 bool Gecko_EvalMozPrefFeature(nsAtom*,
    567                              const mozilla::StyleComputedMozPrefFeatureValue*);
    568 
    569 // Check whether font format/tech is supported.
    570 bool Gecko_IsFontFormatSupported(
    571    mozilla::StyleFontFaceSourceFormatKeyword aFormat);
    572 bool Gecko_IsFontTechSupported(mozilla::StyleFontFaceSourceTechFlags aFlag);
    573 
    574 bool Gecko_IsKnownIconFontFamily(const nsAtom* aFamilyName);
    575 
    576 // Returns true if we're currently performing the servo traversal.
    577 bool Gecko_IsInServoTraversal();
    578 
    579 // Returns true if we're currently on the main thread.
    580 bool Gecko_IsMainThread();
    581 
    582 // Returns true if we're currently on a DOM worker thread.
    583 bool Gecko_IsDOMWorkerThread();
    584 
    585 // Returns the preferred number of style threads to use, or -1 for no
    586 // preference.
    587 int32_t Gecko_GetNumStyleThreads();
    588 
    589 // Media feature helpers.
    590 //
    591 // Defined in nsMediaFeatures.cpp.
    592 mozilla::StyleDisplayMode Gecko_MediaFeatures_GetDisplayMode(
    593    const mozilla::dom::Document*);
    594 
    595 bool Gecko_MediaFeatures_UseOverlayScrollbars(const mozilla::dom::Document*);
    596 int32_t Gecko_MediaFeatures_GetColorDepth(const mozilla::dom::Document*);
    597 int32_t Gecko_MediaFeatures_GetMonochromeBitsPerPixel(
    598    const mozilla::dom::Document*);
    599 mozilla::StyleColorGamut Gecko_MediaFeatures_ColorGamut(
    600    const mozilla::dom::Document*);
    601 
    602 void Gecko_MediaFeatures_GetDeviceSize(const mozilla::dom::Document*,
    603                                       nscoord* width, nscoord* height);
    604 
    605 float Gecko_MediaFeatures_GetResolution(const mozilla::dom::Document*);
    606 bool Gecko_MediaFeatures_PrefersReducedMotion(const mozilla::dom::Document*);
    607 bool Gecko_MediaFeatures_PrefersReducedTransparency(
    608    const mozilla::dom::Document*);
    609 bool Gecko_MediaFeatures_MacRTL(const mozilla::dom::Document*);
    610 mozilla::StylePrefersContrast Gecko_MediaFeatures_PrefersContrast(
    611    const mozilla::dom::Document*);
    612 mozilla::StylePrefersColorScheme Gecko_MediaFeatures_PrefersColorScheme(
    613    const mozilla::dom::Document*, bool aUseContent);
    614 bool Gecko_MediaFeatures_InvertedColors(const mozilla::dom::Document*);
    615 mozilla::StyleScripting Gecko_MediaFeatures_Scripting(
    616    const mozilla::dom::Document*);
    617 
    618 mozilla::StyleDynamicRange Gecko_MediaFeatures_DynamicRange(
    619    const mozilla::dom::Document*);
    620 mozilla::StyleDynamicRange Gecko_MediaFeatures_VideoDynamicRange(
    621    const mozilla::dom::Document*);
    622 
    623 mozilla::PointerCapabilities Gecko_MediaFeatures_PrimaryPointerCapabilities(
    624    const mozilla::dom::Document*);
    625 
    626 mozilla::PointerCapabilities Gecko_MediaFeatures_AllPointerCapabilities(
    627    const mozilla::dom::Document*);
    628 
    629 float Gecko_MediaFeatures_GetDevicePixelRatio(const mozilla::dom::Document*);
    630 
    631 bool Gecko_MediaFeatures_IsResourceDocument(const mozilla::dom::Document*);
    632 bool Gecko_MediaFeatures_InAndroidPipMode(const mozilla::dom::Document*);
    633 bool Gecko_MediaFeatures_MatchesPlatform(mozilla::StylePlatform);
    634 mozilla::StyleGtkThemeFamily Gecko_MediaFeatures_GtkThemeFamily();
    635 
    636 void Gecko_GetSafeAreaInsets(const nsPresContext*, float*, float*, float*,
    637                             float*);
    638 
    639 void Gecko_PrintfStderr(const nsCString*);
    640 
    641 bool Gecko_GetAnchorPosOffset(
    642    const AnchorPosOffsetResolutionParams* aParams, const nsAtom* aAnchorName,
    643    mozilla::StylePhysicalSide aPropSide,
    644    mozilla::StyleAnchorSideKeyword aAnchorSideKeyword, float aPercentage,
    645    mozilla::Length* aOut);
    646 
    647 /**
    648 * Resolve the anchor size for a positioned element, given the anchor name.
    649 *
    650 * @param aParams  Parameters required to resolve anchor size.
    651 * @param aAnchorName  Name of the anchor to use. If null, it will try to use
    652 *                     the position-anchor property of the positioned frame (In
    653 *                     |aParams|). If the property is not set, the lookup fails.
    654 * @param aPropAxis  Axis of the property the anchor size is being resolved for.
    655 *                   Used when |aAnchorSizeKeyword| is None
    656 * @param aAnchorSizeKeyword  Which size value to use as the output.
    657 * @param aLength  Location to write the resolved anchor size. Only set if the
    658 *                 resolution is valid.
    659 *
    660 * @returns  True if the lookup succeeded.
    661 */
    662 bool Gecko_GetAnchorPosSize(const AnchorPosResolutionParams* aParams,
    663                            const nsAtom* aAnchorName,
    664                            mozilla::StylePhysicalAxis aPropAxis,
    665                            mozilla::StyleAnchorSizeKeyword aAnchorSizeKeyword,
    666                            mozilla::Length* aOut);
    667 
    668 }  // extern "C"
    669 
    670 #endif  // mozilla_GeckoBindings_h