71 lines
2.3 KiB
C++
71 lines
2.3 KiB
C++
/* 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_dom_URLPattern_h
|
|
#define mozilla_dom_URLPattern_h
|
|
|
|
#include "mozilla/dom/URLPatternBinding.h"
|
|
#include "nsCycleCollectionParticipant.h"
|
|
#include "nsWrapperCache.h"
|
|
|
|
using UrlPatternGlue = void*;
|
|
|
|
namespace mozilla::dom {
|
|
|
|
class URLPattern final : public nsISupports, public nsWrapperCache {
|
|
public:
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS_FINAL
|
|
NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(URLPattern)
|
|
|
|
explicit URLPattern(nsISupports* aParent, UrlPatternGlue aPattern,
|
|
bool aIgnoreCase)
|
|
: mParent(aParent),
|
|
mPattern(std::move(aPattern)),
|
|
mIgnoreCase(aIgnoreCase) {}
|
|
|
|
nsISupports* GetParentObject() const { return mParent; }
|
|
|
|
JSObject* WrapObject(JSContext* aCx,
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
bool Test(const UTF8StringOrURLPatternInit& aInput,
|
|
const Optional<nsACString>& aBase, ErrorResult& rv);
|
|
|
|
void Exec(const UTF8StringOrURLPatternInit& aInput,
|
|
const Optional<nsACString>& aBaseUrl,
|
|
Nullable<URLPatternResult>& aResult, ErrorResult& rv);
|
|
|
|
static already_AddRefed<URLPattern> Constructor(
|
|
const GlobalObject& aGlobal, const UTF8StringOrURLPatternInit& aInput,
|
|
const URLPatternOptions& aOptions, ErrorResult& rv);
|
|
|
|
static already_AddRefed<URLPattern> Constructor(
|
|
const GlobalObject& aGlobal, const UTF8StringOrURLPatternInit& aInput,
|
|
const nsACString& aBase, const URLPatternOptions& aOptions,
|
|
ErrorResult& rv);
|
|
|
|
void GetProtocol(nsACString& aProtocol) const;
|
|
void GetUsername(nsACString& aUsername) const;
|
|
void GetPassword(nsACString& aPassword) const;
|
|
void GetHostname(nsACString& aHostname) const;
|
|
void GetPort(nsACString& aPort) const;
|
|
void GetPathname(nsACString& aPathname) const;
|
|
void GetSearch(nsACString& aSearch) const;
|
|
void GetHash(nsACString& aHash) const;
|
|
bool HasRegExpGroups() const;
|
|
|
|
private:
|
|
~URLPattern();
|
|
nsCOMPtr<nsISupports> mParent;
|
|
|
|
// dom holds onto opaque pointer to urlpattern::UrlPattern (lib.rs)
|
|
UrlPatternGlue mPattern;
|
|
bool mIgnoreCase;
|
|
};
|
|
|
|
} // namespace mozilla::dom
|
|
|
|
#endif // mozilla_dom_URLPattern_h
|