Bug 1879449 [wpt PR 44489] - [wptrunner] Add `infrastructure/expected-fail/` test...
[gecko.git] / layout / style / FontFaceSetDocumentImpl.h
blobd32103e203ea8ea964f12a91e75b7770806e0353
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 #ifndef mozilla_dom_FontFaceSetDocumentImpl_h
8 #define mozilla_dom_FontFaceSetDocumentImpl_h
10 #include "mozilla/dom/FontFaceSetImpl.h"
11 #include "nsICSSLoaderObserver.h"
12 #include "nsIDOMEventListener.h"
14 namespace mozilla::dom {
16 class FontFaceSetDocumentImpl final : public FontFaceSetImpl,
17 public nsIDOMEventListener,
18 public nsICSSLoaderObserver {
19 NS_DECL_ISUPPORTS_INHERITED
21 public:
22 NS_DECL_NSIDOMEVENTLISTENER
24 FontFaceSetDocumentImpl(FontFaceSet* aOwner, dom::Document* aDocument);
26 void Initialize();
27 void Destroy() override;
29 bool IsOnOwningThread() override;
30 #ifdef DEBUG
31 void AssertIsOnOwningThread() override;
32 #endif
33 void DispatchToOwningThread(const char* aName,
34 std::function<void()>&& aFunc) override;
36 void RefreshStandardFontLoadPrincipal() override;
38 dom::Document* GetDocument() const override { return mDocument; }
40 already_AddRefed<URLExtraData> GetURLExtraData() override;
42 // gfxUserFontSet
44 nsresult StartLoad(gfxUserFontEntry* aUserFontEntry,
45 uint32_t aSrcIndex) override;
47 bool IsFontLoadAllowed(const gfxFontFaceSrc&) override;
49 nsPresContext* GetPresContext() const override;
51 bool UpdateRules(const nsTArray<nsFontFaceRuleContainer>& aRules) override;
53 StyleLockedFontFaceRule* FindRuleForEntry(gfxFontEntry* aFontEntry) override;
55 /**
56 * Notification method called by the nsPresContext to indicate that the
57 * refresh driver ticked and flushed style and layout.
58 * were just flushed.
60 void DidRefresh() override;
62 // nsICSSLoaderObserver
63 NS_IMETHOD StyleSheetLoaded(StyleSheet* aSheet, bool aWasDeferred,
64 nsresult aStatus) override;
66 // For ServoStyleSet to know ahead of time whether a font is loadable.
67 void CacheFontLoadability() override;
69 void EnsureReady() override;
71 bool Add(FontFaceImpl* aFontFace, ErrorResult& aRv) override;
73 void FlushUserFontSet() override;
74 void MarkUserFontSetDirty() override;
76 private:
77 ~FontFaceSetDocumentImpl() override;
79 uint64_t GetInnerWindowID() override;
81 void RemoveDOMContentLoadedListener();
83 nsresult CreateChannelForSyncLoadFontData(
84 nsIChannel** aOutChannel, gfxUserFontEntry* aFontToLoad,
85 const gfxFontFaceSrc* aFontFaceSrc) override;
87 // search for @font-face rule that matches a userfont font entry
88 StyleLockedFontFaceRule* FindRuleForUserFontEntry(
89 gfxUserFontEntry* aUserFontEntry) override;
91 void FindMatchingFontFaces(const nsTHashSet<FontFace*>& aMatchingFaces,
92 nsTArray<FontFace*>& aFontFaces) override;
94 void InsertRuleFontFace(FontFaceImpl* aFontFace, FontFace* aFontFaceOwner,
95 StyleOrigin aOrigin,
96 nsTArray<FontFaceRecord>& aOldRecords,
97 bool& aFontSetModified);
99 // Helper function for HasLoadingFontFaces.
100 void UpdateHasLoadingFontFaces() override;
103 * Returns whether there might be any pending font loads, which should cause
104 * the mReady Promise not to be resolved yet.
106 bool MightHavePendingFontLoads() override;
108 #ifdef DEBUG
109 bool HasRuleFontFace(FontFaceImpl* aFontFace);
110 #endif
112 TimeStamp GetNavigationStartTimeStamp() override;
114 // The document this is a FontFaceSet for.
115 RefPtr<dom::Document> mDocument;
117 // The @font-face rule backed FontFace objects in the FontFaceSet.
118 nsTArray<FontFaceRecord> mRuleFaces;
121 } // namespace mozilla::dom
123 #endif // !defined(mozilla_dom_FontFaceSetDocumentImpl_h)