tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

gfxFontSrcURI.h (2093B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef MOZILLA_GFX_FONTSRCURI_H
      7 #define MOZILLA_GFX_FONTSRCURI_H
      8 
      9 #include "nsCOMPtr.h"
     10 #include "nsTString.h"
     11 #include "PLDHashTable.h"
     12 
     13 class nsIURI;
     14 
     15 namespace mozilla {
     16 namespace net {
     17 class nsSimpleURI;
     18 }  // namespace net
     19 }  // namespace mozilla
     20 
     21 /**
     22 * A wrapper for an nsIURI that can be used OMT, which has cached information
     23 * useful for the gfxUserFontSet.
     24 */
     25 class gfxFontSrcURI final {
     26 public:
     27  explicit gfxFontSrcURI(nsIURI* aURI);
     28 
     29  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(gfxFontSrcURI)
     30 
     31  nsIURI* get() { return mURI; }
     32 
     33  bool Equals(gfxFontSrcURI* aOther);
     34  nsresult GetSpec(nsACString& aResult);
     35  nsCString GetSpecOrDefault();
     36 
     37  PLDHashNumber Hash() const { return mHash; }
     38 
     39  bool InheritsSecurityContext() {
     40    EnsureInitialized();
     41    return mInheritsSecurityContext;
     42  }
     43 
     44  bool SyncLoadIsOK() {
     45    EnsureInitialized();
     46    return mSyncLoadIsOK;
     47  }
     48 
     49 private:
     50  ~gfxFontSrcURI();
     51 
     52  void EnsureInitialized();
     53 
     54  // The URI.
     55  nsCOMPtr<nsIURI> mURI;
     56 
     57  // If the nsIURI is an nsSimpleURI for a data: URL, this is a pointer to it.
     58  // (Just a weak reference since mURI holds the strong reference.)
     59  //
     60  // We store this so that we don't duplicate the URL spec for data: URLs,
     61  // which can be much larger than other URLs.
     62  mozilla::net::nsSimpleURI* mSimpleURI;
     63 
     64  // If the nsIURI is not an nsSimpleURI, this is its spec.
     65  nsCString mSpec;
     66 
     67  // Precomputed hash for mURI.
     68  PLDHashNumber mHash;
     69 
     70  // Whether the font has been initialized on the main thread.
     71  bool mInitialized = false;
     72 
     73  // Whether the nsIURI's protocol handler has the URI_INHERITS_SECURITY_CONTEXT
     74  // flag.
     75  bool mInheritsSecurityContext = false;
     76 
     77  // Whether the nsIURI's protocol handler has teh URI_SYNC_LOAD_IS_OK flag.
     78  bool mSyncLoadIsOK = false;
     79 };
     80 
     81 #endif  // MOZILLA_GFX_FONTSRCURI_H