/* -*- 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 https://mozilla.org/MPL/2.0/. */ #ifndef mozilla_dom_PrototypeDocumentContentSink_h__ #define mozilla_dom_PrototypeDocumentContentSink_h__ #include "mozilla/Attributes.h" #include "nsIContentSink.h" #include "nsTArray.h" #include "nsCOMPtr.h" #include "nsCRT.h" #include "nsCycleCollectionParticipant.h" #include "nsIDTD.h" #include "mozilla/dom/FromParser.h" #include "nsXULPrototypeDocument.h" #include "nsIStreamLoader.h" #include "nsIScriptContext.h" #include "nsICSSLoaderObserver.h" #include "mozilla/Logging.h" class nsIURI; class nsIChannel; class nsIContent; class nsIParser; class nsTextNode; class nsINode; class nsXULPrototypeElement; class nsXULPrototypePI; class nsXULPrototypeScript; namespace mozilla { namespace dom { class Element; class ScriptLoader; class Document; class XMLStylesheetProcessingInstruction; } // namespace dom } // namespace mozilla nsresult NS_NewPrototypeDocumentContentSink(nsIContentSink** aResult, mozilla::dom::Document* aDoc, nsIURI* aURI, nsISupports* aContainer, nsIChannel* aChannel); namespace mozilla { namespace dom { class PrototypeDocumentContentSink final : public nsIStreamLoaderObserver, public nsIContentSink, public nsICSSLoaderObserver, public nsIOffThreadScriptReceiver { public: PrototypeDocumentContentSink(); nsresult Init(Document* aDoc, nsIURI* aURL, nsISupports* aContainer, nsIChannel* aChannel); // nsISupports NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_NSISTREAMLOADEROBSERVER NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(PrototypeDocumentContentSink, nsIContentSink) // nsIContentSink NS_IMETHOD WillParse(void) override { return NS_OK; }; NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) override { return NS_OK; }; NS_IMETHOD DidBuildModel(bool aTerminated) override { return NS_OK; }; NS_IMETHOD WillInterrupt(void) override { return NS_OK; }; NS_IMETHOD WillResume(void) override { return NS_OK; }; NS_IMETHOD SetParser(nsParserBase* aParser) override; virtual void InitialTranslationCompleted() override; virtual void FlushPendingNotifications(FlushType aType) override{}; virtual void SetDocumentCharset(NotNull aEncoding) override; virtual nsISupports* GetTarget() override; virtual bool IsScriptExecuting() override; virtual void ContinueInterruptedParsingAsync() override; // nsICSSLoaderObserver NS_IMETHOD StyleSheetLoaded(StyleSheet* aSheet, bool aWasDeferred, nsresult aStatus) override; // nsIOffThreadScriptReceiver NS_IMETHOD OnScriptCompileComplete(JSScript* aScript, nsresult aStatus) override; nsresult OnPrototypeLoadDone(nsXULPrototypeDocument* aPrototype); protected: virtual ~PrototypeDocumentContentSink(); static LazyLogModule gLog; nsIParser* GetParser(); void ContinueInterruptedParsingIfEnabled(); void StartLayout(); virtual nsresult AddAttributes(nsXULPrototypeElement* aPrototype, Element* aElement); RefPtr mParser; nsCOMPtr mDocumentURI; RefPtr mDocument; RefPtr mScriptLoader; PrototypeDocumentContentSink* mNextSrcLoadWaiter; // [OWNER] but not COMPtr /** * The prototype-script of the current transcluded script that is being * loaded. For document.write('