1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_ModuleScript_h 8 #define mozilla_dom_ModuleScript_h 9 10 #include "nsCOMPtr.h" 11 #include "nsCycleCollectionParticipant.h" 12 #include "jsapi.h" 13 14 class nsIURI; 15 16 namespace mozilla { 17 namespace dom { 18 19 class ScriptLoader; 20 21 class ModuleScript final : public nsISupports { 22 RefPtr<ScriptLoader> mLoader; 23 nsCOMPtr<nsIURI> mBaseURL; 24 JS::Heap<JSObject*> mModuleRecord; 25 JS::Heap<JS::Value> mParseError; 26 JS::Heap<JS::Value> mErrorToRethrow; 27 bool mSourceElementAssociated; 28 29 ~ModuleScript(); 30 31 public: 32 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 33 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ModuleScript) 34 35 ModuleScript(ScriptLoader* aLoader, nsIURI* aBaseURL); 36 37 void SetModuleRecord(JS::Handle<JSObject*> aModuleRecord); 38 void SetParseError(const JS::Value& aError); 39 void SetErrorToRethrow(const JS::Value& aError); 40 void SetSourceElementAssociated(); 41 Loader()42 ScriptLoader* Loader() const { return mLoader; } ModuleRecord()43 JSObject* ModuleRecord() const { return mModuleRecord; } BaseURL()44 nsIURI* BaseURL() const { return mBaseURL; } ParseError()45 JS::Value ParseError() const { return mParseError; } ErrorToRethrow()46 JS::Value ErrorToRethrow() const { return mErrorToRethrow; } HasParseError()47 bool HasParseError() const { return !mParseError.isUndefined(); } HasErrorToRethrow()48 bool HasErrorToRethrow() const { return !mErrorToRethrow.isUndefined(); } SourceElementAssociated()49 bool SourceElementAssociated() const { return mSourceElementAssociated; } 50 51 void UnlinkModuleRecord(); 52 }; 53 54 } // namespace dom 55 } // namespace mozilla 56 57 #endif // mozilla_dom_ModuleScript_h 58