From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- layout/style/FontFace.h | 126 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 layout/style/FontFace.h (limited to 'layout/style/FontFace.h') diff --git a/layout/style/FontFace.h b/layout/style/FontFace.h new file mode 100644 index 0000000000..bdb33a0449 --- /dev/null +++ b/layout/style/FontFace.h @@ -0,0 +1,126 @@ +/* -*- 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_FontFace_h +#define mozilla_dom_FontFace_h + +#include "mozilla/dom/FontFaceBinding.h" +#include "mozilla/FontPropertyTypes.h" +#include "mozilla/Maybe.h" +#include "mozilla/ServoStyleConsts.h" +#include "gfxUserFontSet.h" +#include "nsCSSPropertyID.h" +#include "nsCSSValue.h" +#include "nsWrapperCache.h" + +class gfxFontFaceBufferSource; +class nsIGlobalObject; + +namespace mozilla { +struct CSSFontFaceDescriptors; +class PostTraversalTask; +struct StyleLockedFontFaceRule; + +namespace dom { +class CSSFontFaceRule; +class FontFaceBufferSource; +struct FontFaceDescriptors; +class FontFaceImpl; +class FontFaceSet; +class FontFaceSetImpl; +class Promise; +class UTF8StringOrArrayBufferOrArrayBufferView; +} // namespace dom +} // namespace mozilla + +namespace mozilla::dom { + +class FontFace final : public nsISupports, public nsWrapperCache { + friend class mozilla::PostTraversalTask; + + public: + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(FontFace) + + nsIGlobalObject* GetParentObject() const { return mParent; } + JSObject* WrapObject(JSContext*, JS::Handle aGivenProto) override; + + static already_AddRefed CreateForRule( + nsIGlobalObject* aGlobal, FontFaceSet* aFontFaceSet, + StyleLockedFontFaceRule* aRule); + + // Web IDL + static already_AddRefed Constructor( + const GlobalObject& aGlobal, const nsACString& aFamily, + const UTF8StringOrArrayBufferOrArrayBufferView& aSource, + const FontFaceDescriptors& aDescriptors, ErrorResult& aRV); + + void GetFamily(nsACString& aResult); + void SetFamily(const nsACString& aValue, ErrorResult& aRv); + void GetStyle(nsACString& aResult); + void SetStyle(const nsACString& aValue, ErrorResult& aRv); + void GetWeight(nsACString& aResult); + void SetWeight(const nsACString& aValue, ErrorResult& aRv); + void GetStretch(nsACString& aResult); + void SetStretch(const nsACString& aValue, ErrorResult& aRv); + void GetUnicodeRange(nsACString& aResult); + void SetUnicodeRange(const nsACString& aValue, ErrorResult& aRv); + void GetVariant(nsACString& aResult); + void SetVariant(const nsACString& aValue, ErrorResult& aRv); + void GetFeatureSettings(nsACString& aResult); + void SetFeatureSettings(const nsACString& aValue, ErrorResult& aRv); + void GetVariationSettings(nsACString& aResult); + void SetVariationSettings(const nsACString& aValue, ErrorResult& aRv); + void GetDisplay(nsACString& aResult); + void SetDisplay(const nsACString& aValue, ErrorResult& aRv); + void GetAscentOverride(nsACString& aResult); + void SetAscentOverride(const nsACString& aValue, ErrorResult& aRv); + void GetDescentOverride(nsACString& aResult); + void SetDescentOverride(const nsACString& aValue, ErrorResult& aRv); + void GetLineGapOverride(nsACString& aResult); + void SetLineGapOverride(const nsACString& aValue, ErrorResult& aRv); + void GetSizeAdjust(nsACString& aResult); + void SetSizeAdjust(const nsACString& aValue, ErrorResult& aRv); + + FontFaceLoadStatus Status(); + Promise* Load(ErrorResult& aRv); + Promise* GetLoaded(ErrorResult& aRv); + + FontFaceImpl* GetImpl() const { return mImpl; } + + void Destroy(); + void MaybeResolve(); + void MaybeReject(nsresult aResult); + + private: + explicit FontFace(nsIGlobalObject* aParent); + ~FontFace(); + + /** + * Returns and takes ownership of the buffer storing the font data. + */ + void TakeBuffer(uint8_t*& aBuffer, uint32_t& aLength); + + // Creates mLoaded if it doesn't already exist. It may immediately resolve or + // reject mLoaded based on mStatus and mLoadedRejection. + void EnsurePromise(); + + nsCOMPtr mParent; + + RefPtr mImpl; + + // A Promise that is fulfilled once the font represented by this FontFace is + // loaded, and is rejected if the load fails. This promise is created lazily + // when JS asks for it. + RefPtr mLoaded; + + // Saves the rejection code for mLoaded if mLoaded hasn't been created yet. + nsresult mLoadedRejection; +}; + +} // namespace mozilla::dom + +#endif // !defined(mozilla_dom_FontFace_h) -- cgit v1.2.3