diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /layout/style/FontFaceSetDocumentImpl.h | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | layout/style/FontFaceSetDocumentImpl.h | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/layout/style/FontFaceSetDocumentImpl.h b/layout/style/FontFaceSetDocumentImpl.h new file mode 100644 index 0000000000..d32103e203 --- /dev/null +++ b/layout/style/FontFaceSetDocumentImpl.h @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_FontFaceSetDocumentImpl_h +#define mozilla_dom_FontFaceSetDocumentImpl_h + +#include "mozilla/dom/FontFaceSetImpl.h" +#include "nsICSSLoaderObserver.h" +#include "nsIDOMEventListener.h" + +namespace mozilla::dom { + +class FontFaceSetDocumentImpl final : public FontFaceSetImpl, + public nsIDOMEventListener, + public nsICSSLoaderObserver { + NS_DECL_ISUPPORTS_INHERITED + + public: + NS_DECL_NSIDOMEVENTLISTENER + + FontFaceSetDocumentImpl(FontFaceSet* aOwner, dom::Document* aDocument); + + void Initialize(); + void Destroy() override; + + bool IsOnOwningThread() override; +#ifdef DEBUG + void AssertIsOnOwningThread() override; +#endif + void DispatchToOwningThread(const char* aName, + std::function<void()>&& aFunc) override; + + void RefreshStandardFontLoadPrincipal() override; + + dom::Document* GetDocument() const override { return mDocument; } + + already_AddRefed<URLExtraData> GetURLExtraData() override; + + // gfxUserFontSet + + nsresult StartLoad(gfxUserFontEntry* aUserFontEntry, + uint32_t aSrcIndex) override; + + bool IsFontLoadAllowed(const gfxFontFaceSrc&) override; + + nsPresContext* GetPresContext() const override; + + bool UpdateRules(const nsTArray<nsFontFaceRuleContainer>& aRules) override; + + StyleLockedFontFaceRule* FindRuleForEntry(gfxFontEntry* aFontEntry) override; + + /** + * Notification method called by the nsPresContext to indicate that the + * refresh driver ticked and flushed style and layout. + * were just flushed. + */ + void DidRefresh() override; + + // nsICSSLoaderObserver + NS_IMETHOD StyleSheetLoaded(StyleSheet* aSheet, bool aWasDeferred, + nsresult aStatus) override; + + // For ServoStyleSet to know ahead of time whether a font is loadable. + void CacheFontLoadability() override; + + void EnsureReady() override; + + bool Add(FontFaceImpl* aFontFace, ErrorResult& aRv) override; + + void FlushUserFontSet() override; + void MarkUserFontSetDirty() override; + + private: + ~FontFaceSetDocumentImpl() override; + + uint64_t GetInnerWindowID() override; + + void RemoveDOMContentLoadedListener(); + + nsresult CreateChannelForSyncLoadFontData( + nsIChannel** aOutChannel, gfxUserFontEntry* aFontToLoad, + const gfxFontFaceSrc* aFontFaceSrc) override; + + // search for @font-face rule that matches a userfont font entry + StyleLockedFontFaceRule* FindRuleForUserFontEntry( + gfxUserFontEntry* aUserFontEntry) override; + + void FindMatchingFontFaces(const nsTHashSet<FontFace*>& aMatchingFaces, + nsTArray<FontFace*>& aFontFaces) override; + + void InsertRuleFontFace(FontFaceImpl* aFontFace, FontFace* aFontFaceOwner, + StyleOrigin aOrigin, + nsTArray<FontFaceRecord>& aOldRecords, + bool& aFontSetModified); + + // Helper function for HasLoadingFontFaces. + void UpdateHasLoadingFontFaces() override; + + /** + * Returns whether there might be any pending font loads, which should cause + * the mReady Promise not to be resolved yet. + */ + bool MightHavePendingFontLoads() override; + +#ifdef DEBUG + bool HasRuleFontFace(FontFaceImpl* aFontFace); +#endif + + TimeStamp GetNavigationStartTimeStamp() override; + + // The document this is a FontFaceSet for. + RefPtr<dom::Document> mDocument; + + // The @font-face rule backed FontFace objects in the FontFaceSet. + nsTArray<FontFaceRecord> mRuleFaces; +}; + +} // namespace mozilla::dom + +#endif // !defined(mozilla_dom_FontFaceSetDocumentImpl_h) |