2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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/. */
|
2003-03-22 05:22:03 +03:00
|
|
|
|
2011-05-26 12:06:31 +04:00
|
|
|
#ifndef mozilla_dom_MediaDocument_h
|
|
|
|
#define mozilla_dom_MediaDocument_h
|
2003-03-22 05:22:03 +03:00
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2003-03-22 05:22:03 +03:00
|
|
|
#include "nsHTMLDocument.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
2003-04-13 04:40:26 +04:00
|
|
|
#include "nsIStringBundle.h"
|
2018-06-28 21:07:27 +03:00
|
|
|
#include "nsIThreadRetargetableStreamListener.h"
|
2003-04-13 04:40:26 +04:00
|
|
|
|
2005-02-23 19:53:28 +03:00
|
|
|
#define NSMEDIADOCUMENT_PROPERTIES_URI \
|
|
|
|
"chrome://global/locale/layout/MediaDocument.properties"
|
2003-03-22 05:22:03 +03:00
|
|
|
|
2019-11-04 19:56:27 +03:00
|
|
|
#define NSMEDIADOCUMENT_PROPERTIES_URI_en_US \
|
|
|
|
"resource://gre/res/locale/layout/MediaDocument.properties"
|
|
|
|
|
2011-05-26 12:06:31 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class MediaDocument : public nsHTMLDocument {
|
2003-03-22 05:22:03 +03:00
|
|
|
public:
|
2013-05-06 17:42:00 +04:00
|
|
|
MediaDocument();
|
2011-05-26 12:06:31 +04:00
|
|
|
virtual ~MediaDocument();
|
2003-03-22 05:22:03 +03:00
|
|
|
|
2018-07-19 14:36:20 +03:00
|
|
|
// Subclasses need to override this.
|
|
|
|
enum MediaDocumentKind MediaDocumentKind() const override = 0;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult Init() override;
|
2003-04-13 04:40:26 +04:00
|
|
|
|
2004-01-10 02:54:21 +03:00
|
|
|
virtual nsresult StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
|
|
|
|
nsILoadGroup* aLoadGroup,
|
|
|
|
nsISupports* aContainer,
|
|
|
|
nsIStreamListener** aDocListener,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aReset = true,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIContentSink* aSink = nullptr) override;
|
2003-03-22 05:22:03 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool WillIgnoreCharsetOverride() override { return true; }
|
2013-11-26 11:31:52 +04:00
|
|
|
|
2003-03-22 05:22:03 +03:00
|
|
|
protected:
|
2018-05-23 18:06:34 +03:00
|
|
|
// Hook to be called once our initial document setup is done. Subclasses
|
|
|
|
// should call this from SetScriptGlobalObject when setup hasn't been done
|
|
|
|
// yet, a non-null script global is being set, and they have finished whatever
|
|
|
|
// setup work they plan to do for an initial load.
|
|
|
|
void InitialSetupDone();
|
|
|
|
|
|
|
|
// Check whether initial setup has been done.
|
|
|
|
MOZ_MUST_USE bool InitialSetupHasBeenDone() const {
|
|
|
|
return mDidInitialDocumentSetup;
|
|
|
|
}
|
2012-07-27 17:35:09 +04:00
|
|
|
|
2003-03-22 05:22:03 +03:00
|
|
|
virtual nsresult CreateSyntheticDocument();
|
|
|
|
|
2011-05-26 12:06:31 +04:00
|
|
|
friend class MediaDocumentStreamListener;
|
2019-05-14 07:27:49 +03:00
|
|
|
virtual nsresult StartLayout();
|
2003-04-13 04:40:26 +04:00
|
|
|
|
2014-10-30 08:08:00 +03:00
|
|
|
void GetFileName(nsAString& aResult, nsIChannel* aChannel);
|
2009-01-16 12:07:26 +03:00
|
|
|
|
2011-11-11 03:08:07 +04:00
|
|
|
nsresult LinkStylesheet(const nsAString& aStylesheet);
|
2015-10-04 14:04:55 +03:00
|
|
|
nsresult LinkScript(const nsAString& aScript);
|
2011-11-11 03:08:07 +04:00
|
|
|
|
2019-11-04 19:56:27 +03:00
|
|
|
void FormatStringFromName(const char* aName,
|
|
|
|
const nsTArray<nsString>& aParams,
|
|
|
|
nsAString& aResult);
|
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
// |aFormatNames[]| needs to have four elements in the following order:
|
2003-04-13 04:40:26 +04:00
|
|
|
// 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 20:52:25 +04:00
|
|
|
// "ImageTitleWithDimesions2", "ImageTitleWithDimensions2AndFile".
|
2003-04-13 04:40:26 +04:00
|
|
|
//
|
|
|
|
// Also see MediaDocument.properties if you want to define format names
|
2011-05-26 12:06:31 +04:00
|
|
|
// for a new subclass. aWidth and aHeight are pixels for |ImageDocument|,
|
2017-07-06 15:00:35 +03:00
|
|
|
// but could be in other units for other 'media', in which case you have to
|
|
|
|
// define format names accordingly.
|
2003-04-22 02:45:28 +04:00
|
|
|
void UpdateTitleAndCharset(const nsACString& aTypeStr, nsIChannel* aChannel,
|
2003-04-13 04:40:26 +04:00
|
|
|
const char* const* aFormatNames = sFormatNames,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aWidth = 0, int32_t aHeight = 0,
|
2004-01-30 01:04:45 +03:00
|
|
|
const nsAString& aStatus = EmptyString());
|
2003-04-13 04:40:26 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIStringBundle> mStringBundle;
|
2019-11-04 19:56:27 +03:00
|
|
|
nsCOMPtr<nsIStringBundle> mStringBundleEnglish;
|
2003-04-22 02:45:28 +04:00
|
|
|
static const char* const sFormatNames[4];
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2003-04-13 04:40:26 +04:00
|
|
|
private:
|
|
|
|
enum { eWithNoInfo, eWithFile, eWithDim, eWithDimAndFile };
|
2018-05-23 18:06:34 +03:00
|
|
|
|
|
|
|
// A boolean that indicates whether we did our initial document setup. This
|
|
|
|
// will be false initially, become true when we finish setting up the document
|
|
|
|
// during initial load and stay true thereafter.
|
|
|
|
bool mDidInitialDocumentSetup;
|
2003-03-22 05:22:03 +03:00
|
|
|
};
|
|
|
|
|
2018-06-28 21:07:27 +03:00
|
|
|
class MediaDocumentStreamListener : public nsIStreamListener,
|
|
|
|
public nsIThreadRetargetableStreamListener {
|
2014-06-25 06:09:15 +04:00
|
|
|
protected:
|
|
|
|
virtual ~MediaDocumentStreamListener();
|
|
|
|
|
2003-03-22 05:22:03 +03:00
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit MediaDocumentStreamListener(MediaDocument* aDocument);
|
2003-03-22 05:22:03 +03:00
|
|
|
void SetStreamListener(nsIStreamListener* aListener);
|
|
|
|
|
2018-06-28 21:07:27 +03:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2003-03-22 05:22:03 +03:00
|
|
|
|
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
|
|
|
|
|
|
|
NS_DECL_NSISTREAMLISTENER
|
|
|
|
|
2018-06-28 21:07:27 +03:00
|
|
|
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
|
|
|
|
|
2017-12-07 08:10:51 +03:00
|
|
|
void DropDocumentRef() { mDocument = nullptr; }
|
|
|
|
|
|
|
|
RefPtr<MediaDocument> mDocument;
|
|
|
|
nsCOMPtr<nsIStreamListener> mNextStream;
|
2003-03-22 05:22:03 +03:00
|
|
|
};
|
|
|
|
|
2011-05-26 12:06:31 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2003-03-22 05:22:03 +03:00
|
|
|
|
2011-05-26 12:06:31 +04:00
|
|
|
#endif /* mozilla_dom_MediaDocument_h */
|