author Sandor Molnar <>
Fri, 24 Sep 2021 00:43:42 +0300
changeset 593102 4eda9eb8926bdd50f4b80128ce3475eb7c6d9a4d
parent 561872 5336c1f5a1b94d72271bb96a03b526e8a6e8d708
permissions -rw-r--r--
Merge autoland to mozilla-central. a=merge

/* -*- 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 */


#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 {
  explicit gfxFontSrcURI(nsIURI* aURI);


  nsIURI* get() { return mURI; }

  bool Equals(gfxFontSrcURI* aOther);
  nsresult GetSpec(nsACString& aResult);
  nsCString GetSpecOrDefault();

  PLDHashNumber Hash() const { return mHash; }
  bool InheritsSecurityContext() const { return mInheritsSecurityContext; }
  bool SyncLoadIsOK() const { return mSyncLoadIsOK; }


  // 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 nsIURI's protocol handler has the URI_INHERITS_SECURITY_CONTEXT
  // flag.
  bool mInheritsSecurityContext;

  // Whether the nsIURI's protocol handler has teh URI_SYNC_LOAD_IS_OK flag.
  bool mSyncLoadIsOK;