summaryrefslogtreecommitdiffstats
path: root/gfx/thebes/gfxFontSrcURI.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /gfx/thebes/gfxFontSrcURI.h
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--gfx/thebes/gfxFontSrcURI.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/gfx/thebes/gfxFontSrcURI.h b/gfx/thebes/gfxFontSrcURI.h
new file mode 100644
index 0000000000..994575d7fc
--- /dev/null
+++ b/gfx/thebes/gfxFontSrcURI.h
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * 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_GFX_FONTSRCURI_H
+#define MOZILLA_GFX_FONTSRCURI_H
+
+#include "nsCOMPtr.h"
+#include "nsTString.h"
+#include "PLDHashTable.h"
+
+class nsIURI;
+
+namespace mozilla {
+namespace net {
+class nsSimpleURI;
+} // namespace net
+} // namespace mozilla
+
+/**
+ * A wrapper for an nsIURI that can be used OMT, which has cached information
+ * useful for the gfxUserFontSet.
+ */
+class gfxFontSrcURI final {
+ public:
+ explicit gfxFontSrcURI(nsIURI* aURI);
+
+ NS_INLINE_DECL_THREADSAFE_REFCOUNTING(gfxFontSrcURI)
+
+ nsIURI* get() { return mURI; }
+
+ bool Equals(gfxFontSrcURI* aOther);
+ nsresult GetSpec(nsACString& aResult);
+ nsCString GetSpecOrDefault();
+
+ PLDHashNumber Hash() const { return mHash; }
+
+ bool InheritsSecurityContext() {
+ EnsureInitialized();
+ return mInheritsSecurityContext;
+ }
+
+ bool SyncLoadIsOK() {
+ EnsureInitialized();
+ return mSyncLoadIsOK;
+ }
+
+ private:
+ ~gfxFontSrcURI();
+
+ void EnsureInitialized();
+
+ // The URI.
+ nsCOMPtr<nsIURI> mURI;
+
+ // If the nsIURI is an nsSimpleURI for a data: URL, this is a pointer to it.
+ // (Just a weak reference since mURI holds the strong reference.)
+ //
+ // We store this so that we don't duplicate the URL spec for data: URLs,
+ // which can be much larger than other URLs.
+ mozilla::net::nsSimpleURI* mSimpleURI;
+
+ // If the nsIURI is not an nsSimpleURI, this is its spec.
+ nsCString mSpec;
+
+ // Precomputed hash for mURI.
+ PLDHashNumber mHash;
+
+ // Whether the font has been initialized on the main thread.
+ bool mInitialized = false;
+
+ // Whether the nsIURI's protocol handler has the URI_INHERITS_SECURITY_CONTEXT
+ // flag.
+ bool mInheritsSecurityContext = false;
+
+ // Whether the nsIURI's protocol handler has teh URI_SYNC_LOAD_IS_OK flag.
+ bool mSyncLoadIsOK = false;
+};
+
+#endif // MOZILLA_GFX_FONTSRCURI_H