From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- layout/style/FontFaceSetDocumentImpl.h | 123 +++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 layout/style/FontFaceSetDocumentImpl.h (limited to 'layout/style/FontFaceSetDocumentImpl.h') 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&& aFunc) override; + + void RefreshStandardFontLoadPrincipal() override; + + dom::Document* GetDocument() const override { return mDocument; } + + already_AddRefed GetURLExtraData() override; + + // gfxUserFontSet + + nsresult StartLoad(gfxUserFontEntry* aUserFontEntry, + uint32_t aSrcIndex) override; + + bool IsFontLoadAllowed(const gfxFontFaceSrc&) override; + + nsPresContext* GetPresContext() const override; + + bool UpdateRules(const nsTArray& 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& aMatchingFaces, + nsTArray& aFontFaces) override; + + void InsertRuleFontFace(FontFaceImpl* aFontFace, FontFace* aFontFaceOwner, + StyleOrigin aOrigin, + nsTArray& 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 mDocument; + + // The @font-face rule backed FontFace objects in the FontFaceSet. + nsTArray mRuleFaces; +}; + +} // namespace mozilla::dom + +#endif // !defined(mozilla_dom_FontFaceSetDocumentImpl_h) -- cgit v1.2.3