URLPattern.h (2362B)
1 /* -*- Mode: IDL; 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 file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 */ 6 7 #ifndef mozilla_dom_URLPattern_h 8 #define mozilla_dom_URLPattern_h 9 10 #include "mozilla/dom/URLPatternBinding.h" 11 #include "mozilla/net/URLPatternGlue.h" 12 #include "nsCycleCollectionParticipant.h" 13 #include "nsWrapperCache.h" 14 15 namespace mozilla::dom { 16 17 class URLPattern final : public nsISupports, public nsWrapperCache { 18 public: 19 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 20 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(URLPattern) 21 22 explicit URLPattern(nsISupports* aParent, UrlpPattern aPattern, 23 bool aIgnoreCase) 24 : mParent(aParent), 25 mPattern(std::move(aPattern)), 26 mIgnoreCase(aIgnoreCase) {} 27 28 nsISupports* GetParentObject() const { return mParent; } 29 30 JSObject* WrapObject(JSContext* aCx, 31 JS::Handle<JSObject*> aGivenProto) override; 32 33 bool Test(const UTF8StringOrURLPatternInit& aInput, 34 const Optional<nsACString>& aBase, ErrorResult& rv); 35 36 void Exec(const UTF8StringOrURLPatternInit& aInput, 37 const Optional<nsACString>& aBaseUrl, 38 Nullable<URLPatternResult>& aResult, ErrorResult& rv); 39 40 static already_AddRefed<URLPattern> Constructor( 41 const GlobalObject& aGlobal, const UTF8StringOrURLPatternInit& aInput, 42 const URLPatternOptions& aOptions, ErrorResult& rv); 43 44 static already_AddRefed<URLPattern> Constructor( 45 const GlobalObject& aGlobal, const UTF8StringOrURLPatternInit& aInput, 46 const nsACString& aBase, const URLPatternOptions& aOptions, 47 ErrorResult& rv); 48 49 void GetProtocol(nsACString& aProtocol) const; 50 void GetUsername(nsACString& aUsername) const; 51 void GetPassword(nsACString& aPassword) const; 52 void GetHostname(nsACString& aHostname) const; 53 void GetPort(nsACString& aPort) const; 54 void GetPathname(nsACString& aPathname) const; 55 void GetSearch(nsACString& aSearch) const; 56 void GetHash(nsACString& aHash) const; 57 bool HasRegExpGroups() const; 58 59 private: 60 ~URLPattern(); 61 nsCOMPtr<nsISupports> mParent; 62 UrlpPattern mPattern; 63 bool mIgnoreCase; 64 }; 65 66 } // namespace mozilla::dom 67 68 #endif // mozilla_dom_URLPattern_h