2017-04-04 03:04:13 +03:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
|
|
|
/* thread-safe container of information for resolving url values */
|
|
|
|
|
|
|
|
#ifndef mozilla_URLExtraData_h
|
|
|
|
#define mozilla_URLExtraData_h
|
|
|
|
|
2017-07-31 12:57:56 +03:00
|
|
|
#include "mozilla/dom/URL.h"
|
2017-04-04 03:04:13 +03:00
|
|
|
#include "mozilla/Move.h"
|
2017-04-04 06:21:16 +03:00
|
|
|
#include "mozilla/StaticPtr.h"
|
2017-04-04 03:04:13 +03:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsIURI.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
struct URLExtraData
|
|
|
|
{
|
|
|
|
URLExtraData(already_AddRefed<nsIURI> aBaseURI,
|
|
|
|
already_AddRefed<nsIURI> aReferrer,
|
|
|
|
already_AddRefed<nsIPrincipal> aPrincipal)
|
2018-05-30 22:15:35 +03:00
|
|
|
: mBaseURI(std::move(aBaseURI))
|
|
|
|
, mReferrer(std::move(aReferrer))
|
|
|
|
, mPrincipal(std::move(aPrincipal))
|
2017-07-31 12:57:56 +03:00
|
|
|
// When we hold the URI data of a style sheet, mReferrer is always
|
|
|
|
// equal to the sheet URI.
|
|
|
|
, mIsChrome(mReferrer ? dom::IsChromeURI(mReferrer) : false)
|
2017-04-04 03:04:13 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mBaseURI);
|
|
|
|
}
|
|
|
|
|
|
|
|
URLExtraData(nsIURI* aBaseURI, nsIURI* aReferrer, nsIPrincipal* aPrincipal)
|
|
|
|
: URLExtraData(do_AddRef(aBaseURI),
|
|
|
|
do_AddRef(aReferrer),
|
|
|
|
do_AddRef(aPrincipal)) {}
|
|
|
|
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(URLExtraData)
|
|
|
|
|
|
|
|
nsIURI* BaseURI() const { return mBaseURI; }
|
|
|
|
nsIURI* GetReferrer() const { return mReferrer; }
|
|
|
|
nsIPrincipal* GetPrincipal() const { return mPrincipal; }
|
|
|
|
|
2017-04-04 06:21:16 +03:00
|
|
|
static URLExtraData* Dummy() {
|
|
|
|
MOZ_ASSERT(sDummy);
|
|
|
|
return sDummy;
|
|
|
|
}
|
|
|
|
static void InitDummy();
|
|
|
|
static void ReleaseDummy();
|
|
|
|
|
2017-04-04 03:04:13 +03:00
|
|
|
private:
|
|
|
|
~URLExtraData();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> mBaseURI;
|
|
|
|
nsCOMPtr<nsIURI> mReferrer;
|
|
|
|
nsCOMPtr<nsIPrincipal> mPrincipal;
|
2017-04-04 06:21:16 +03:00
|
|
|
|
2017-07-31 12:57:56 +03:00
|
|
|
// True if mReferrer is a chrome:// URI.
|
|
|
|
const bool mIsChrome;
|
|
|
|
|
2017-04-04 06:21:16 +03:00
|
|
|
static StaticRefPtr<URLExtraData> sDummy;
|
2017-04-04 03:04:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_URLExtraData_h
|