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"
|
2019-03-30 03:15:43 +03:00
|
|
|
#include "mozilla/UserAgentStyleSheetID.h"
|
2018-09-17 08:36:45 +03:00
|
|
|
#include "mozilla/net/ReferrerPolicy.h"
|
2017-04-04 03:04:13 +03:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsIURI.h"
|
|
|
|
|
2019-03-30 03:15:43 +03:00
|
|
|
class nsLayoutStylesheetCache;
|
|
|
|
|
2017-04-04 03:04:13 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
struct URLExtraData {
|
|
|
|
URLExtraData(already_AddRefed<nsIURI> aBaseURI,
|
|
|
|
already_AddRefed<nsIURI> aReferrer,
|
2018-09-17 08:36:45 +03:00
|
|
|
already_AddRefed<nsIPrincipal> aPrincipal,
|
|
|
|
net::ReferrerPolicy aReferrerPolicy)
|
2018-05-30 22:15:35 +03:00
|
|
|
: mBaseURI(std::move(aBaseURI)),
|
|
|
|
mReferrer(std::move(aReferrer)),
|
2018-09-17 08:36:45 +03:00
|
|
|
mReferrerPolicy(aReferrerPolicy),
|
2018-12-05 21:44:03 +03:00
|
|
|
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);
|
2018-10-10 06:10:07 +03:00
|
|
|
MOZ_ASSERT(mPrincipal);
|
2017-04-04 03:04:13 +03:00
|
|
|
}
|
|
|
|
|
2018-09-17 08:36:45 +03:00
|
|
|
URLExtraData(nsIURI* aBaseURI, nsIURI* aReferrer, nsIPrincipal* aPrincipal,
|
|
|
|
net::ReferrerPolicy aReferrerPolicy)
|
2017-04-04 03:04:13 +03:00
|
|
|
: URLExtraData(do_AddRef(aBaseURI), do_AddRef(aReferrer),
|
2018-09-17 08:36:45 +03:00
|
|
|
do_AddRef(aPrincipal), aReferrerPolicy) {}
|
2017-04-04 03:04:13 +03:00
|
|
|
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(URLExtraData)
|
|
|
|
|
|
|
|
nsIURI* BaseURI() const { return mBaseURI; }
|
|
|
|
nsIURI* GetReferrer() const { return mReferrer; }
|
2018-09-17 08:36:45 +03:00
|
|
|
net::ReferrerPolicy GetReferrerPolicy() const { return mReferrerPolicy; }
|
2018-10-10 06:10:07 +03:00
|
|
|
nsIPrincipal* Principal() const { return mPrincipal; }
|
2017-04-04 03:04:13 +03:00
|
|
|
|
2017-04-04 06:21:16 +03:00
|
|
|
static URLExtraData* Dummy() {
|
|
|
|
MOZ_ASSERT(sDummy);
|
|
|
|
return sDummy;
|
|
|
|
}
|
|
|
|
static void InitDummy();
|
|
|
|
static void ReleaseDummy();
|
|
|
|
|
2019-03-30 03:15:43 +03:00
|
|
|
// URLExtraData objects that shared style sheets use a sheet ID index to
|
|
|
|
// refer to.
|
|
|
|
static StaticRefPtr<URLExtraData>
|
|
|
|
sShared[size_t(UserAgentStyleSheetID::Count)];
|
|
|
|
|
2017-04-04 03:04:13 +03:00
|
|
|
private:
|
|
|
|
~URLExtraData();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> mBaseURI;
|
|
|
|
nsCOMPtr<nsIURI> mReferrer;
|
2018-09-17 08:36:45 +03:00
|
|
|
net::ReferrerPolicy mReferrerPolicy;
|
2017-04-04 03:04:13 +03:00
|
|
|
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
|