2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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 http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-05-26 01:06:31 -07:00
|
|
|
#ifndef mozilla_dom_MediaDocument_h
|
|
|
|
#define mozilla_dom_MediaDocument_h
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsHTMLDocument.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsIStringBundle.h"
|
|
|
|
|
|
|
|
#define NSMEDIADOCUMENT_PROPERTIES_URI "chrome://global/locale/layout/MediaDocument.properties"
|
|
|
|
|
2011-05-26 01:06:31 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class MediaDocument : public nsHTMLDocument
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-05-06 06:42:00 -07:00
|
|
|
MediaDocument();
|
2011-05-26 01:06:31 -07:00
|
|
|
virtual ~MediaDocument();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual nsresult Init() MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual nsresult StartDocumentLoad(const char* aCommand,
|
|
|
|
nsIChannel* aChannel,
|
|
|
|
nsILoadGroup* aLoadGroup,
|
|
|
|
nsISupports* aContainer,
|
|
|
|
nsIStreamListener** aDocListener,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aReset = true,
|
2013-05-29 13:43:41 -07:00
|
|
|
nsIContentSink* aSink = nullptr) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) MOZ_OVERRIDE;
|
2011-12-15 07:10:36 -08:00
|
|
|
|
2013-11-25 23:31:52 -08:00
|
|
|
virtual bool WillIgnoreCharsetOverride()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2012-07-27 06:35:09 -07:00
|
|
|
void BecomeInteractive();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual nsresult CreateSyntheticDocument();
|
|
|
|
|
2011-05-26 01:06:31 -07:00
|
|
|
friend class MediaDocumentStreamListener;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult StartLayout();
|
|
|
|
|
2014-10-29 22:08:00 -07:00
|
|
|
void GetFileName(nsAString& aResult, nsIChannel* aChannel);
|
2009-01-16 01:07:26 -08:00
|
|
|
|
2011-11-10 15:08:07 -08:00
|
|
|
nsresult LinkStylesheet(const nsAString& aStylesheet);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// |aFormatNames[]| needs to have four elements in the following order:
|
|
|
|
// a format name with neither dimension nor file, a format name with
|
|
|
|
// filename but w/o dimension, a format name with dimension but w/o filename,
|
|
|
|
// a format name with both of them. For instance, it can have
|
|
|
|
// "ImageTitleWithNeitherDimensionsNorFile", "ImageTitleWithoutDimensions",
|
2013-09-04 09:52:25 -07:00
|
|
|
// "ImageTitleWithDimesions2", "ImageTitleWithDimensions2AndFile".
|
2007-03-22 10:30:00 -07:00
|
|
|
//
|
|
|
|
// Also see MediaDocument.properties if you want to define format names
|
2011-05-26 01:06:31 -07:00
|
|
|
// for a new subclass. aWidth and aHeight are pixels for |ImageDocument|,
|
2007-03-22 10:30:00 -07:00
|
|
|
// but could be in other units for other 'media', in which case you have to
|
|
|
|
// define format names accordingly.
|
|
|
|
void UpdateTitleAndCharset(const nsACString& aTypeStr,
|
2014-10-29 22:08:00 -07:00
|
|
|
nsIChannel* aChannel,
|
2007-03-22 10:30:00 -07:00
|
|
|
const char* const* aFormatNames = sFormatNames,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aWidth = 0,
|
|
|
|
int32_t aHeight = 0,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsAString& aStatus = EmptyString());
|
|
|
|
|
|
|
|
nsCOMPtr<nsIStringBundle> mStringBundle;
|
|
|
|
static const char* const sFormatNames[4];
|
2011-12-15 07:10:36 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
enum {eWithNoInfo, eWithFile, eWithDim, eWithDimAndFile};
|
2011-12-15 07:10:36 -08:00
|
|
|
bool mDocumentElementInserted;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-05-26 01:06:31 -07:00
|
|
|
class MediaDocumentStreamListener: public nsIStreamListener
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-06-24 19:09:15 -07:00
|
|
|
protected:
|
|
|
|
virtual ~MediaDocumentStreamListener();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit MediaDocumentStreamListener(MediaDocument* aDocument);
|
2007-03-22 10:30:00 -07:00
|
|
|
void SetStreamListener(nsIStreamListener *aListener);
|
|
|
|
|
2014-02-16 18:26:56 -08:00
|
|
|
NS_DECL_ISUPPORTS
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
|
|
|
|
|
|
|
NS_DECL_NSISTREAMLISTENER
|
|
|
|
|
2011-05-26 01:06:31 -07:00
|
|
|
nsRefPtr<MediaDocument> mDocument;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIStreamListener> mNextStream;
|
|
|
|
};
|
|
|
|
|
2011-05-26 01:06:31 -07:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-05-26 01:06:31 -07:00
|
|
|
#endif /* mozilla_dom_MediaDocument_h */
|