michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_MediaDocument_h michael@0: #define mozilla_dom_MediaDocument_h michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsHTMLDocument.h" michael@0: #include "nsGenericHTMLElement.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsIStringBundle.h" michael@0: michael@0: #define NSMEDIADOCUMENT_PROPERTIES_URI "chrome://global/locale/layout/MediaDocument.properties" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class MediaDocument : public nsHTMLDocument michael@0: { michael@0: public: michael@0: MediaDocument(); michael@0: virtual ~MediaDocument(); michael@0: michael@0: virtual nsresult Init() MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult StartDocumentLoad(const char* aCommand, michael@0: nsIChannel* aChannel, michael@0: nsILoadGroup* aLoadGroup, michael@0: nsISupports* aContainer, michael@0: nsIStreamListener** aDocListener, michael@0: bool aReset = true, michael@0: nsIContentSink* aSink = nullptr) MOZ_OVERRIDE; michael@0: michael@0: virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) MOZ_OVERRIDE; michael@0: michael@0: virtual bool WillIgnoreCharsetOverride() michael@0: { michael@0: return true; michael@0: } michael@0: michael@0: protected: michael@0: void BecomeInteractive(); michael@0: michael@0: virtual nsresult CreateSyntheticDocument(); michael@0: michael@0: friend class MediaDocumentStreamListener; michael@0: nsresult StartLayout(); michael@0: michael@0: void GetFileName(nsAString& aResult); michael@0: michael@0: nsresult LinkStylesheet(const nsAString& aStylesheet); michael@0: michael@0: // |aFormatNames[]| needs to have four elements in the following order: michael@0: // a format name with neither dimension nor file, a format name with michael@0: // filename but w/o dimension, a format name with dimension but w/o filename, michael@0: // a format name with both of them. For instance, it can have michael@0: // "ImageTitleWithNeitherDimensionsNorFile", "ImageTitleWithoutDimensions", michael@0: // "ImageTitleWithDimesions2", "ImageTitleWithDimensions2AndFile". michael@0: // michael@0: // Also see MediaDocument.properties if you want to define format names michael@0: // for a new subclass. aWidth and aHeight are pixels for |ImageDocument|, michael@0: // but could be in other units for other 'media', in which case you have to michael@0: // define format names accordingly. michael@0: void UpdateTitleAndCharset(const nsACString& aTypeStr, michael@0: const char* const* aFormatNames = sFormatNames, michael@0: int32_t aWidth = 0, michael@0: int32_t aHeight = 0, michael@0: const nsAString& aStatus = EmptyString()); michael@0: michael@0: nsCOMPtr mStringBundle; michael@0: static const char* const sFormatNames[4]; michael@0: michael@0: private: michael@0: enum {eWithNoInfo, eWithFile, eWithDim, eWithDimAndFile}; michael@0: bool mDocumentElementInserted; michael@0: }; michael@0: michael@0: michael@0: class MediaDocumentStreamListener: public nsIStreamListener michael@0: { michael@0: public: michael@0: MediaDocumentStreamListener(MediaDocument *aDocument); michael@0: virtual ~MediaDocumentStreamListener(); michael@0: void SetStreamListener(nsIStreamListener *aListener); michael@0: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: NS_DECL_NSIREQUESTOBSERVER michael@0: michael@0: NS_DECL_NSISTREAMLISTENER michael@0: michael@0: nsRefPtr mDocument; michael@0: nsCOMPtr mNextStream; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif /* mozilla_dom_MediaDocument_h */