Line data Source code
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_MediaDocument_h
8 : #define mozilla_dom_MediaDocument_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "nsHTMLDocument.h"
12 : #include "nsGenericHTMLElement.h"
13 : #include "nsIStringBundle.h"
14 :
15 : #define NSMEDIADOCUMENT_PROPERTIES_URI "chrome://global/locale/layout/MediaDocument.properties"
16 :
17 : namespace mozilla {
18 : namespace dom {
19 :
20 : class MediaDocument : public nsHTMLDocument
21 : {
22 : public:
23 : MediaDocument();
24 : virtual ~MediaDocument();
25 :
26 : virtual nsresult Init() override;
27 :
28 : virtual nsresult StartDocumentLoad(const char* aCommand,
29 : nsIChannel* aChannel,
30 : nsILoadGroup* aLoadGroup,
31 : nsISupports* aContainer,
32 : nsIStreamListener** aDocListener,
33 : bool aReset = true,
34 : nsIContentSink* aSink = nullptr) override;
35 :
36 : virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) override;
37 :
38 0 : virtual bool WillIgnoreCharsetOverride() override
39 : {
40 0 : return true;
41 : }
42 :
43 : protected:
44 : void BecomeInteractive();
45 :
46 : virtual nsresult CreateSyntheticDocument();
47 :
48 : friend class MediaDocumentStreamListener;
49 : nsresult StartLayout();
50 :
51 : void GetFileName(nsAString& aResult, nsIChannel* aChannel);
52 :
53 : nsresult LinkStylesheet(const nsAString& aStylesheet);
54 : nsresult LinkScript(const nsAString& aScript);
55 :
56 : // |aFormatNames[]| needs to have four elements in the following order:
57 : // a format name with neither dimension nor file, a format name with
58 : // filename but w/o dimension, a format name with dimension but w/o filename,
59 : // a format name with both of them. For instance, it can have
60 : // "ImageTitleWithNeitherDimensionsNorFile", "ImageTitleWithoutDimensions",
61 : // "ImageTitleWithDimesions2", "ImageTitleWithDimensions2AndFile".
62 : //
63 : // Also see MediaDocument.properties if you want to define format names
64 : // for a new subclass. aWidth and aHeight are pixels for |ImageDocument|,
65 : // but could be in other units for other 'media', in which case you have to
66 : // define format names accordingly.
67 : void UpdateTitleAndCharset(const nsACString& aTypeStr,
68 : nsIChannel* aChannel,
69 : const char* const* aFormatNames = sFormatNames,
70 : int32_t aWidth = 0,
71 : int32_t aHeight = 0,
72 0 : const nsAString& aStatus = EmptyString());
73 :
74 : nsCOMPtr<nsIStringBundle> mStringBundle;
75 : static const char* const sFormatNames[4];
76 :
77 : private:
78 : enum {eWithNoInfo, eWithFile, eWithDim, eWithDimAndFile};
79 : bool mDocumentElementInserted;
80 : };
81 :
82 :
83 : class MediaDocumentStreamListener: public nsIStreamListener
84 : {
85 : protected:
86 : virtual ~MediaDocumentStreamListener();
87 :
88 : public:
89 : explicit MediaDocumentStreamListener(MediaDocument* aDocument);
90 : void SetStreamListener(nsIStreamListener *aListener);
91 :
92 : NS_DECL_ISUPPORTS
93 :
94 : NS_DECL_NSIREQUESTOBSERVER
95 :
96 : NS_DECL_NSISTREAMLISTENER
97 :
98 : RefPtr<MediaDocument> mDocument;
99 : nsCOMPtr<nsIStreamListener> mNextStream;
100 : };
101 :
102 : } // namespace dom
103 : } // namespace mozilla
104 :
105 : #endif /* mozilla_dom_MediaDocument_h */
|