Bug 577138 - Move nsMediaDocument and subclasses into the mozilla::dom namespace; r=jst

--HG--
rename : content/html/document/src/nsImageDocument.cpp => content/html/document/src/ImageDocument.cpp
rename : content/html/document/src/nsMediaDocument.cpp => content/html/document/src/MediaDocument.cpp
rename : content/html/document/src/nsMediaDocument.h => content/html/document/src/MediaDocument.h
rename : content/html/document/src/nsPluginDocument.cpp => content/html/document/src/PluginDocument.cpp
rename : content/html/document/src/nsVideoDocument.cpp => content/html/document/src/VideoDocument.cpp
This commit is contained in:
Ms2ger 2011-05-26 10:06:31 +02:00
Родитель 868c2847e9
Коммит 39c72cc360
6 изменённых файлов: 220 добавлений и 208 удалений

Просмотреть файл

@ -38,6 +38,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "MediaDocument.h"
#include "nsRect.h"
#include "nsHTMLDocument.h"
#include "nsIImageDocument.h"
@ -57,7 +58,6 @@
#include "nsPresContext.h"
#include "nsStyleContext.h"
#include "nsAutoPtr.h"
#include "nsMediaDocument.h"
#include "nsStyleSet.h"
#include "nsIChannel.h"
#include "nsIContentPolicy.h"
@ -76,34 +76,34 @@
#include "mozilla/dom/Element.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
using namespace mozilla::dom;
#define AUTOMATIC_IMAGE_RESIZING_PREF "browser.enable_automatic_image_resizing"
#define CLICK_IMAGE_RESIZING_PREF "browser.enable_click_image_resizing"
//XXX A hack needed for Firefox's site specific zoom.
#define SITE_SPECIFIC_ZOOM "browser.zoom.siteSpecific"
class nsImageDocument;
namespace mozilla {
namespace dom {
class ImageDocument;
class ImageListener: public nsMediaDocumentStreamListener
class ImageListener : public MediaDocumentStreamListener
{
public:
ImageListener(nsImageDocument* aDocument);
ImageListener(ImageDocument* aDocument);
virtual ~ImageListener();
/* nsIRequestObserver */
NS_IMETHOD OnStartRequest(nsIRequest* request, nsISupports *ctxt);
};
class nsImageDocument : public nsMediaDocument,
public nsIImageDocument,
public nsStubImageDecoderObserver,
public nsIDOMEventListener
class ImageDocument : public MediaDocument
, public nsIImageDocument
, public nsStubImageDecoderObserver
, public nsIDOMEventListener
{
public:
nsImageDocument();
virtual ~nsImageDocument();
ImageDocument();
virtual ~ImageDocument();
NS_DECL_ISUPPORTS_INHERITED
@ -131,7 +131,7 @@ public:
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsImageDocument, nsMediaDocument)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ImageDocument, MediaDocument)
friend class ImageListener;
@ -178,8 +178,8 @@ protected:
float mOriginalZoomLevel;
};
ImageListener::ImageListener(nsImageDocument* aDocument)
: nsMediaDocumentStreamListener(aDocument)
ImageListener::ImageListener(ImageDocument* aDocument)
: MediaDocumentStreamListener(aDocument)
{
}
@ -192,7 +192,7 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
{
NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
nsImageDocument *imgDoc = (nsImageDocument*)mDocument.get();
ImageDocument *imgDoc = static_cast<ImageDocument*>(mDocument.get());
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
if (!channel) {
return NS_ERROR_FAILURE;
@ -238,56 +238,51 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
imgDoc->mObservingImageLoader = PR_TRUE;
imageLoader->LoadImageWithChannel(channel, getter_AddRefs(mNextStream));
return nsMediaDocumentStreamListener::OnStartRequest(request, ctxt);
return MediaDocumentStreamListener::OnStartRequest(request, ctxt);
}
// NOTE! nsDocument::operator new() zeroes out all members, so don't
// bother initializing members to 0.
nsImageDocument::nsImageDocument() : mOriginalZoomLevel(1.0)
ImageDocument::ImageDocument()
: mOriginalZoomLevel(1.0)
{
// NOTE! nsDocument::operator new() zeroes out all members, so don't
// bother initializing members to 0.
}
nsImageDocument::~nsImageDocument()
ImageDocument::~ImageDocument()
{
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsImageDocument)
NS_IMPL_CYCLE_COLLECTION_CLASS(ImageDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsImageDocument, nsMediaDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ImageDocument, MediaDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mImageContent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsImageDocument, nsMediaDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ImageDocument, MediaDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mImageContent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_ADDREF_INHERITED(nsImageDocument, nsMediaDocument)
NS_IMPL_RELEASE_INHERITED(nsImageDocument, nsMediaDocument)
NS_IMPL_ADDREF_INHERITED(ImageDocument, MediaDocument)
NS_IMPL_RELEASE_INHERITED(ImageDocument, MediaDocument)
DOMCI_NODE_DATA(ImageDocument, nsImageDocument)
DOMCI_NODE_DATA(ImageDocument, ImageDocument)
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsImageDocument)
NS_HTML_DOCUMENT_INTERFACE_TABLE_BEGIN(nsImageDocument)
NS_INTERFACE_TABLE_ENTRY(nsImageDocument, nsIImageDocument)
NS_INTERFACE_TABLE_ENTRY(nsImageDocument, imgIDecoderObserver)
NS_INTERFACE_TABLE_ENTRY(nsImageDocument, imgIContainerObserver)
NS_INTERFACE_TABLE_ENTRY(nsImageDocument, nsIDOMEventListener)
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(ImageDocument)
NS_HTML_DOCUMENT_INTERFACE_TABLE_BEGIN(ImageDocument)
NS_INTERFACE_TABLE_ENTRY(ImageDocument, nsIImageDocument)
NS_INTERFACE_TABLE_ENTRY(ImageDocument, imgIDecoderObserver)
NS_INTERFACE_TABLE_ENTRY(ImageDocument, imgIContainerObserver)
NS_INTERFACE_TABLE_ENTRY(ImageDocument, nsIDOMEventListener)
NS_OFFSET_AND_INTERFACE_TABLE_END
NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ImageDocument)
NS_INTERFACE_MAP_END_INHERITING(nsMediaDocument)
NS_INTERFACE_MAP_END_INHERITING(MediaDocument)
nsresult
nsImageDocument::Init()
ImageDocument::Init()
{
nsresult rv = nsMediaDocument::Init();
nsresult rv = MediaDocument::Init();
NS_ENSURE_SUCCESS(rv, rv);
mResizeImageByDefault = Preferences::GetBool(AUTOMATIC_IMAGE_RESIZING_PREF);
@ -299,18 +294,17 @@ nsImageDocument::Init()
}
nsresult
nsImageDocument::StartDocumentLoad(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
nsIStreamListener** aDocListener,
PRBool aReset,
nsIContentSink* aSink)
ImageDocument::StartDocumentLoad(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
nsIStreamListener** aDocListener,
PRBool aReset,
nsIContentSink* aSink)
{
nsresult rv =
nsMediaDocument::StartDocumentLoad(aCommand, aChannel, aLoadGroup,
aContainer, aDocListener, aReset,
aSink);
MediaDocument::StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer,
aDocListener, aReset, aSink);
if (NS_FAILED(rv)) {
return rv;
}
@ -320,15 +314,13 @@ nsImageDocument::StartDocumentLoad(const char* aCommand,
NS_ASSERTION(aDocListener, "null aDocListener");
*aDocListener = new ImageListener(this);
if (!*aDocListener)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aDocListener);
return NS_OK;
}
void
nsImageDocument::Destroy()
ImageDocument::Destroy()
{
if (mImageContent) {
// Remove our event listener from the image content.
@ -351,11 +343,11 @@ nsImageDocument::Destroy()
mImageContent = nsnull;
}
nsMediaDocument::Destroy();
MediaDocument::Destroy();
}
void
nsImageDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject)
ImageDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject)
{
// If the script global object is changing, we need to unhook our event
// listeners on the window.
@ -392,39 +384,39 @@ nsImageDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObjec
}
void
nsImageDocument::OnPageShow(PRBool aPersisted,
nsIDOMEventTarget* aDispatchStartTarget)
ImageDocument::OnPageShow(PRBool aPersisted,
nsIDOMEventTarget* aDispatchStartTarget)
{
if (aPersisted) {
mOriginalZoomLevel =
Preferences::GetBool(SITE_SPECIFIC_ZOOM, PR_FALSE) ? 1.0 : GetZoomLevel();
}
nsMediaDocument::OnPageShow(aPersisted, aDispatchStartTarget);
MediaDocument::OnPageShow(aPersisted, aDispatchStartTarget);
}
NS_IMETHODIMP
nsImageDocument::GetImageResizingEnabled(PRBool* aImageResizingEnabled)
ImageDocument::GetImageResizingEnabled(PRBool* aImageResizingEnabled)
{
*aImageResizingEnabled = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
nsImageDocument::GetImageIsOverflowing(PRBool* aImageIsOverflowing)
ImageDocument::GetImageIsOverflowing(PRBool* aImageIsOverflowing)
{
*aImageIsOverflowing = mImageIsOverflowing;
return NS_OK;
}
NS_IMETHODIMP
nsImageDocument::GetImageIsResized(PRBool* aImageIsResized)
ImageDocument::GetImageIsResized(PRBool* aImageIsResized)
{
*aImageIsResized = mImageIsResized;
return NS_OK;
}
NS_IMETHODIMP
nsImageDocument::GetImageRequest(imgIRequest** aImageRequest)
ImageDocument::GetImageRequest(imgIRequest** aImageRequest)
{
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mImageContent);
if (imageLoader) {
@ -437,7 +429,7 @@ nsImageDocument::GetImageRequest(imgIRequest** aImageRequest)
}
NS_IMETHODIMP
nsImageDocument::ShrinkToFit()
ImageDocument::ShrinkToFit()
{
if (!mImageContent) {
return NS_OK;
@ -468,13 +460,13 @@ nsImageDocument::ShrinkToFit()
}
NS_IMETHODIMP
nsImageDocument::RestoreImageTo(PRInt32 aX, PRInt32 aY)
ImageDocument::RestoreImageTo(PRInt32 aX, PRInt32 aY)
{
return ScrollImageTo(aX, aY, PR_TRUE);
}
nsresult
nsImageDocument::ScrollImageTo(PRInt32 aX, PRInt32 aY, PRBool restoreImage)
ImageDocument::ScrollImageTo(PRInt32 aX, PRInt32 aY, PRBool restoreImage)
{
float ratio = GetRatio();
@ -499,7 +491,7 @@ nsImageDocument::ScrollImageTo(PRInt32 aX, PRInt32 aY, PRBool restoreImage)
}
NS_IMETHODIMP
nsImageDocument::RestoreImage()
ImageDocument::RestoreImage()
{
if (!mImageContent) {
return NS_OK;
@ -525,7 +517,7 @@ nsImageDocument::RestoreImage()
}
NS_IMETHODIMP
nsImageDocument::ToggleImageSize()
ImageDocument::ToggleImageSize()
{
mShouldResize = PR_TRUE;
if (mImageIsResized) {
@ -542,12 +534,12 @@ nsImageDocument::ToggleImageSize()
}
NS_IMETHODIMP
nsImageDocument::OnStartContainer(imgIRequest* aRequest, imgIContainer* aImage)
ImageDocument::OnStartContainer(imgIRequest* aRequest, imgIContainer* aImage)
{
aImage->GetWidth(&mImageWidth);
aImage->GetHeight(&mImageHeight);
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &nsImageDocument::DefaultCheckOverflowing);
NS_NewRunnableMethod(this, &ImageDocument::DefaultCheckOverflowing);
nsContentUtils::AddScriptRunner(runnable);
UpdateTitleAndCharset();
@ -555,9 +547,9 @@ nsImageDocument::OnStartContainer(imgIRequest* aRequest, imgIContainer* aImage)
}
NS_IMETHODIMP
nsImageDocument::OnStopDecode(imgIRequest *aRequest,
nsresult aStatus,
const PRUnichar *aStatusArg)
ImageDocument::OnStopDecode(imgIRequest *aRequest,
nsresult aStatus,
const PRUnichar *aStatusArg)
{
UpdateTitleAndCharset();
@ -585,7 +577,7 @@ nsImageDocument::OnStopDecode(imgIRequest *aRequest,
}
NS_IMETHODIMP
nsImageDocument::HandleEvent(nsIDOMEvent* aEvent)
ImageDocument::HandleEvent(nsIDOMEvent* aEvent)
{
nsAutoString eventType;
aEvent->GetType(eventType);
@ -645,10 +637,10 @@ nsImageDocument::HandleEvent(nsIDOMEvent* aEvent)
}
nsresult
nsImageDocument::CreateSyntheticDocument()
ImageDocument::CreateSyntheticDocument()
{
// Synthesize an html document that refers to the image
nsresult rv = nsMediaDocument::CreateSyntheticDocument();
nsresult rv = MediaDocument::CreateSyntheticDocument();
NS_ENSURE_SUCCESS(rv, rv);
Element* body = GetBodyElement();
@ -691,7 +683,7 @@ nsImageDocument::CreateSyntheticDocument()
}
nsresult
nsImageDocument::CheckOverflowing(PRBool changeState)
ImageDocument::CheckOverflowing(PRBool changeState)
{
/* Create a scope so that the style context gets destroyed before we might
* call RebuildStyleData. Also, holding onto pointers to the
@ -747,7 +739,7 @@ nsImageDocument::CheckOverflowing(PRBool changeState)
}
void
nsImageDocument::UpdateTitleAndCharset()
ImageDocument::UpdateTitleAndCharset()
{
nsCAutoString typeStr;
nsCOMPtr<imgIRequest> imageRequest;
@ -805,12 +797,12 @@ nsImageDocument::UpdateTitleAndCharset()
"ImageTitleWithDimensionsAndFile",
};
nsMediaDocument::UpdateTitleAndCharset(typeStr, formatNames,
mImageWidth, mImageHeight, status);
MediaDocument::UpdateTitleAndCharset(typeStr, formatNames,
mImageWidth, mImageHeight, status);
}
void
nsImageDocument::ResetZoomLevel()
ImageDocument::ResetZoomLevel()
{
nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mDocumentContainer);
if (docShell) {
@ -828,7 +820,7 @@ nsImageDocument::ResetZoomLevel()
}
float
nsImageDocument::GetZoomLevel()
ImageDocument::GetZoomLevel()
{
float zoomLevel = mOriginalZoomLevel;
nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mDocumentContainer);
@ -843,17 +835,18 @@ nsImageDocument::GetZoomLevel()
return zoomLevel;
}
} // namespace dom
} // namespace mozilla
DOMCI_DATA(ImageDocument, mozilla::dom::ImageDocument)
nsresult
NS_NewImageDocument(nsIDocument** aResult)
{
nsImageDocument* doc = new nsImageDocument();
if (!doc) {
return NS_ERROR_OUT_OF_MEMORY;
}
mozilla::dom::ImageDocument* doc = new mozilla::dom::ImageDocument();
NS_ADDREF(doc);
nsresult rv = doc->Init();
nsresult rv = doc->Init();
if (NS_FAILED(rv)) {
NS_RELEASE(doc);
}

Просмотреть файл

@ -51,13 +51,13 @@ CPPSRCS = \
nsHTMLContentSink.cpp \
nsHTMLFragmentContentSink.cpp \
nsHTMLDocument.cpp \
nsImageDocument.cpp \
nsMediaDocument.cpp \
nsPluginDocument.cpp \
ImageDocument.cpp \
MediaDocument.cpp \
PluginDocument.cpp \
$(NULL)
ifdef MOZ_MEDIA
CPPSRCS += nsVideoDocument.cpp
CPPSRCS += VideoDocument.cpp
endif
EXPORTS = \
@ -73,10 +73,10 @@ INCLUDES += \
-I$(srcdir)/../../../base/src \
-I$(srcdir)/../../../events/src \
-I$(srcdir)/../../content/src \
-I$(srcdir)/../../../../layout/style \
-I$(srcdir)/../../../../dom/base \
-I$(srcdir)/../../../../xpcom/io \
-I$(srcdir)/../../../../caps/include \
-I$(topsrcdir)/layout/style \
-I$(topsrcdir)/dom/base \
-I$(topsrcdir)/xpcom/io \
-I$(topsrcdir)/caps/include \
$(NULL)
DEFINES += -D_IMPL_NS_LAYOUT

Просмотреть файл

@ -36,7 +36,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsMediaDocument.h"
#include "MediaDocument.h"
#include "nsGkAtoms.h"
#include "nsRect.h"
#include "nsPresContext.h"
@ -53,29 +53,32 @@
#include "nsIDocumentCharsetInfo.h"
#include "nsNodeInfoManager.h"
nsMediaDocumentStreamListener::nsMediaDocumentStreamListener(nsMediaDocument *aDocument)
namespace mozilla {
namespace dom {
MediaDocumentStreamListener::MediaDocumentStreamListener(MediaDocument *aDocument)
{
mDocument = aDocument;
}
nsMediaDocumentStreamListener::~nsMediaDocumentStreamListener()
MediaDocumentStreamListener::~MediaDocumentStreamListener()
{
}
NS_IMPL_THREADSAFE_ISUPPORTS2(nsMediaDocumentStreamListener,
NS_IMPL_THREADSAFE_ISUPPORTS2(MediaDocumentStreamListener,
nsIRequestObserver,
nsIStreamListener)
void
nsMediaDocumentStreamListener::SetStreamListener(nsIStreamListener *aListener)
MediaDocumentStreamListener::SetStreamListener(nsIStreamListener *aListener)
{
mNextStream = aListener;
}
NS_IMETHODIMP
nsMediaDocumentStreamListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
MediaDocumentStreamListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
{
NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
@ -89,9 +92,9 @@ nsMediaDocumentStreamListener::OnStartRequest(nsIRequest* request, nsISupports *
}
NS_IMETHODIMP
nsMediaDocumentStreamListener::OnStopRequest(nsIRequest* request,
nsISupports *ctxt,
nsresult status)
MediaDocumentStreamListener::OnStopRequest(nsIRequest* request,
nsISupports *ctxt,
nsresult status)
{
nsresult rv = NS_OK;
if (mNextStream) {
@ -105,11 +108,11 @@ nsMediaDocumentStreamListener::OnStopRequest(nsIRequest* request,
}
NS_IMETHODIMP
nsMediaDocumentStreamListener::OnDataAvailable(nsIRequest* request,
nsISupports *ctxt,
nsIInputStream *inStr,
PRUint32 sourceOffset,
PRUint32 count)
MediaDocumentStreamListener::OnDataAvailable(nsIRequest* request,
nsISupports *ctxt,
nsIInputStream *inStr,
PRUint32 sourceOffset,
PRUint32 count)
{
if (mNextStream) {
return mNextStream->OnDataAvailable(request, ctxt, inStr, sourceOffset, count);
@ -118,8 +121,8 @@ nsMediaDocumentStreamListener::OnDataAvailable(nsIRequest* request,
return NS_OK;
}
// default format names for nsMediaDocument.
const char* const nsMediaDocument::sFormatNames[4] =
// default format names for MediaDocument.
const char* const MediaDocument::sFormatNames[4] =
{
"MediaTitleWithNoInfo", // eWithNoInfo
"MediaTitleWithFile", // eWithFile
@ -127,15 +130,15 @@ const char* const nsMediaDocument::sFormatNames[4] =
"" // eWithDimAndFile
};
nsMediaDocument::nsMediaDocument()
MediaDocument::MediaDocument()
{
}
nsMediaDocument::~nsMediaDocument()
MediaDocument::~MediaDocument()
{
}
nsresult
nsMediaDocument::Init()
MediaDocument::Init()
{
nsresult rv = nsHTMLDocument::Init();
NS_ENSURE_SUCCESS(rv, rv);
@ -152,13 +155,13 @@ nsMediaDocument::Init()
}
nsresult
nsMediaDocument::StartDocumentLoad(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
nsIStreamListener** aDocListener,
PRBool aReset,
nsIContentSink* aSink)
MediaDocument::StartDocumentLoad(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
nsIStreamListener** aDocListener,
PRBool aReset,
nsIContentSink* aSink)
{
nsresult rv = nsDocument::StartDocumentLoad(aCommand, aChannel, aLoadGroup,
aContainer, aDocListener, aReset,
@ -227,7 +230,7 @@ nsMediaDocument::StartDocumentLoad(const char* aCommand,
}
nsresult
nsMediaDocument::CreateSyntheticDocument()
MediaDocument::CreateSyntheticDocument()
{
// Synthesize an empty html document
nsresult rv;
@ -273,7 +276,7 @@ nsMediaDocument::CreateSyntheticDocument()
}
nsresult
nsMediaDocument::StartLayout()
MediaDocument::StartLayout()
{
mMayStartLayout = PR_TRUE;
nsCOMPtr<nsIPresShell> shell = GetShell();
@ -289,7 +292,7 @@ nsMediaDocument::StartLayout()
}
void
nsMediaDocument::GetFileName(nsAString& aResult)
MediaDocument::GetFileName(nsAString& aResult)
{
aResult.Truncate();
@ -329,10 +332,10 @@ nsMediaDocument::GetFileName(nsAString& aResult)
}
void
nsMediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
const char* const* aFormatNames,
PRInt32 aWidth, PRInt32 aHeight,
const nsAString& aStatus)
MediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
const char* const* aFormatNames,
PRInt32 aWidth, PRInt32 aHeight,
const nsAString& aStatus)
{
nsXPIDLString fileStr;
GetFileName(fileStr);
@ -394,3 +397,6 @@ nsMediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
SetTitle(titleWithStatus);
}
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -35,8 +35,8 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsMediaDocument_h___
#define nsMediaDocument_h___
#ifndef mozilla_dom_MediaDocument_h
#define mozilla_dom_MediaDocument_h
#include "nsHTMLDocument.h"
#include "nsGenericHTMLElement.h"
@ -45,11 +45,14 @@
#define NSMEDIADOCUMENT_PROPERTIES_URI "chrome://global/locale/layout/MediaDocument.properties"
class nsMediaDocument : public nsHTMLDocument
namespace mozilla {
namespace dom {
class MediaDocument : public nsHTMLDocument
{
public:
nsMediaDocument();
virtual ~nsMediaDocument();
MediaDocument();
virtual ~MediaDocument();
virtual nsresult Init();
@ -64,7 +67,7 @@ public:
protected:
virtual nsresult CreateSyntheticDocument();
friend class nsMediaDocumentStreamListener;
friend class MediaDocumentStreamListener;
nsresult StartLayout();
void GetFileName(nsAString& aResult);
@ -77,7 +80,7 @@ protected:
// "ImageTitleWithDimesions", "ImageTitleWithDimensionsAndFile".
//
// Also see MediaDocument.properties if you want to define format names
// for a new subclass. aWidth and aHeight are pixels for |nsImageDocument|,
// for a new subclass. aWidth and aHeight are pixels for |ImageDocument|,
// but could be in other units for other 'media', in which case you have to
// define format names accordingly.
void UpdateTitleAndCharset(const nsACString& aTypeStr,
@ -94,11 +97,11 @@ private:
};
class nsMediaDocumentStreamListener: public nsIStreamListener
class MediaDocumentStreamListener: public nsIStreamListener
{
public:
nsMediaDocumentStreamListener(nsMediaDocument *aDocument);
virtual ~nsMediaDocumentStreamListener();
MediaDocumentStreamListener(MediaDocument *aDocument);
virtual ~MediaDocumentStreamListener();
void SetStreamListener(nsIStreamListener *aListener);
NS_DECL_ISUPPORTS
@ -107,9 +110,11 @@ public:
NS_DECL_NSISTREAMLISTENER
nsRefPtr<nsMediaDocument> mDocument;
nsRefPtr<MediaDocument> mDocument;
nsCOMPtr<nsIStreamListener> mNextStream;
};
} // namespace dom
} // namespace mozilla
#endif /* nsMediaDocument_h___ */
#endif /* mozilla_dom_MediaDocument_h */

Просмотреть файл

@ -35,7 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsMediaDocument.h"
#include "MediaDocument.h"
#include "nsIPluginDocument.h"
#include "nsGkAtoms.h"
#include "nsIPresShell.h"
@ -48,14 +48,15 @@
#include "nsIPropertyBag2.h"
#include "mozilla/dom/Element.h"
using namespace mozilla::dom;
namespace mozilla {
namespace dom {
class nsPluginDocument : public nsMediaDocument,
public nsIPluginDocument
class PluginDocument : public MediaDocument
, public nsIPluginDocument
{
public:
nsPluginDocument();
virtual ~nsPluginDocument();
PluginDocument();
virtual ~PluginDocument();
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIPLUGINDOCUMENT
@ -78,14 +79,14 @@ public:
mWillHandleInstantiation = PR_FALSE;
}
void StartLayout() { nsMediaDocument::StartLayout(); }
void StartLayout() { MediaDocument::StartLayout(); }
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsPluginDocument, nsMediaDocument)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PluginDocument, MediaDocument)
protected:
nsresult CreateSyntheticPluginDocument();
nsCOMPtr<nsIContent> mPluginContent;
nsRefPtr<nsMediaDocumentStreamListener> mStreamListener;
nsRefPtr<MediaDocumentStreamListener> mStreamListener;
nsCString mMimeType;
// Hack to handle the fact that plug-in loading lives in frames and that the
@ -94,21 +95,23 @@ protected:
PRBool mWillHandleInstantiation;
};
class nsPluginStreamListener : public nsMediaDocumentStreamListener
class PluginStreamListener : public MediaDocumentStreamListener
{
public:
nsPluginStreamListener(nsPluginDocument* doc) :
nsMediaDocumentStreamListener(doc), mPluginDoc(doc) {}
PluginStreamListener(PluginDocument* doc)
: MediaDocumentStreamListener(doc)
, mPluginDoc(doc)
{}
NS_IMETHOD OnStartRequest(nsIRequest* request, nsISupports *ctxt);
private:
nsresult SetupPlugin();
nsRefPtr<nsPluginDocument> mPluginDoc;
nsRefPtr<PluginDocument> mPluginDoc;
};
NS_IMETHODIMP
nsPluginStreamListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
PluginStreamListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
{
// Have to set up our plugin stuff before we call OnStartRequest, so
// that the plugin listener can get that call.
@ -116,12 +119,12 @@ nsPluginStreamListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
NS_ASSERTION(NS_FAILED(rv) || mNextStream,
"We should have a listener by now");
nsresult rv2 = nsMediaDocumentStreamListener::OnStartRequest(request, ctxt);
nsresult rv2 = MediaDocumentStreamListener::OnStartRequest(request, ctxt);
return NS_SUCCEEDED(rv) ? rv2 : rv;
}
nsresult
nsPluginStreamListener::SetupPlugin()
PluginStreamListener::SetupPlugin()
{
NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
mPluginDoc->StartLayout();
@ -170,38 +173,38 @@ nsPluginStreamListener::SetupPlugin()
// NOTE! nsDocument::operator new() zeroes out all members, so don't
// bother initializing members to 0.
nsPluginDocument::nsPluginDocument()
PluginDocument::PluginDocument()
: mWillHandleInstantiation(PR_TRUE)
{
}
nsPluginDocument::~nsPluginDocument()
PluginDocument::~PluginDocument()
{
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsPluginDocument)
NS_IMPL_CYCLE_COLLECTION_CLASS(PluginDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsPluginDocument, nsMediaDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PluginDocument, MediaDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPluginContent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsPluginDocument, nsMediaDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PluginDocument, MediaDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mPluginContent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_ADDREF_INHERITED(nsPluginDocument, nsMediaDocument)
NS_IMPL_RELEASE_INHERITED(nsPluginDocument, nsMediaDocument)
NS_IMPL_ADDREF_INHERITED(PluginDocument, MediaDocument)
NS_IMPL_RELEASE_INHERITED(PluginDocument, MediaDocument)
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsPluginDocument)
NS_INTERFACE_TABLE_INHERITED1(nsPluginDocument, nsIPluginDocument)
NS_INTERFACE_TABLE_TAIL_INHERITING(nsMediaDocument)
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(PluginDocument)
NS_INTERFACE_TABLE_INHERITED1(PluginDocument, nsIPluginDocument)
NS_INTERFACE_TABLE_TAIL_INHERITING(MediaDocument)
void
nsPluginDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject)
PluginDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject)
{
// Set the script global object on the superclass before doing
// anything that might require it....
nsMediaDocument::SetScriptGlobalObject(aScriptGlobalObject);
MediaDocument::SetScriptGlobalObject(aScriptGlobalObject);
if (aScriptGlobalObject) {
if (!mPluginContent) {
@ -219,7 +222,7 @@ nsPluginDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObje
PRBool
nsPluginDocument::CanSavePresentation(nsIRequest *aNewRequest)
PluginDocument::CanSavePresentation(nsIRequest *aNewRequest)
{
// Full-page plugins cannot be cached, currently, because we don't have
// the stream listener data to feed to the plugin instance.
@ -228,13 +231,13 @@ nsPluginDocument::CanSavePresentation(nsIRequest *aNewRequest)
nsresult
nsPluginDocument::StartDocumentLoad(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
nsIStreamListener** aDocListener,
PRBool aReset,
nsIContentSink* aSink)
PluginDocument::StartDocumentLoad(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
nsIStreamListener** aDocListener,
PRBool aReset,
nsIContentSink* aSink)
{
// do not allow message panes to host full-page plugins
// returning an error causes helper apps to take over
@ -248,9 +251,8 @@ nsPluginDocument::StartDocumentLoad(const char* aCommand,
}
nsresult rv =
nsMediaDocument::StartDocumentLoad(aCommand, aChannel, aLoadGroup,
aContainer, aDocListener, aReset,
aSink);
MediaDocument::StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer,
aDocListener, aReset, aSink);
if (NS_FAILED(rv)) {
return rv;
}
@ -260,7 +262,7 @@ nsPluginDocument::StartDocumentLoad(const char* aCommand,
return rv;
}
mStreamListener = new nsPluginStreamListener(this);
mStreamListener = new PluginStreamListener(this);
if (!mStreamListener) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -271,13 +273,13 @@ nsPluginDocument::StartDocumentLoad(const char* aCommand,
}
nsresult
nsPluginDocument::CreateSyntheticPluginDocument()
PluginDocument::CreateSyntheticPluginDocument()
{
NS_ASSERTION(!GetShell() || !GetShell()->DidInitialReflow(),
"Creating synthetic plugin document content too late");
// make our generic document
nsresult rv = nsMediaDocument::CreateSyntheticDocument();
nsresult rv = MediaDocument::CreateSyntheticDocument();
NS_ENSURE_SUCCESS(rv, rv);
// then attach our plugin
@ -333,19 +335,19 @@ nsPluginDocument::CreateSyntheticPluginDocument()
}
NS_IMETHODIMP
nsPluginDocument::SetStreamListener(nsIStreamListener *aListener)
PluginDocument::SetStreamListener(nsIStreamListener *aListener)
{
if (mStreamListener) {
mStreamListener->SetStreamListener(aListener);
}
nsMediaDocument::UpdateTitleAndCharset(mMimeType);
MediaDocument::UpdateTitleAndCharset(mMimeType);
return NS_OK;
}
NS_IMETHODIMP
nsPluginDocument::Print()
PluginDocument::Print()
{
NS_ENSURE_TRUE(mPluginContent, NS_ERROR_FAILURE);
@ -369,16 +371,19 @@ nsPluginDocument::Print()
}
NS_IMETHODIMP
nsPluginDocument::GetWillHandleInstantiation(PRBool* aWillHandle)
PluginDocument::GetWillHandleInstantiation(PRBool* aWillHandle)
{
*aWillHandle = mWillHandleInstantiation;
return NS_OK;
}
} // namespace dom
} // namespace mozilla
nsresult
NS_NewPluginDocument(nsIDocument** aResult)
{
nsPluginDocument* doc = new nsPluginDocument();
mozilla::dom::PluginDocument* doc = new mozilla::dom::PluginDocument();
if (!doc) {
return NS_ERROR_OUT_OF_MEMORY;
}

Просмотреть файл

@ -35,7 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsMediaDocument.h"
#include "MediaDocument.h"
#include "nsGkAtoms.h"
#include "nsNodeInfoManager.h"
#include "nsContentCreatorFunctions.h"
@ -43,9 +43,10 @@
#include "nsIDocShellTreeItem.h"
#include "mozilla/dom/Element.h"
using namespace mozilla::dom;
namespace mozilla {
namespace dom {
class nsVideoDocument : public nsMediaDocument
class VideoDocument : public MediaDocument
{
public:
virtual nsresult StartDocumentLoad(const char* aCommand,
@ -64,25 +65,24 @@ protected:
nsresult CreateSyntheticVideoDocument(nsIChannel* aChannel,
nsIStreamListener** aListener);
nsRefPtr<nsMediaDocumentStreamListener> mStreamListener;
nsRefPtr<MediaDocumentStreamListener> mStreamListener;
};
nsresult
nsVideoDocument::StartDocumentLoad(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
nsIStreamListener** aDocListener,
PRBool aReset,
nsIContentSink* aSink)
VideoDocument::StartDocumentLoad(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
nsIStreamListener** aDocListener,
PRBool aReset,
nsIContentSink* aSink)
{
nsresult rv =
nsMediaDocument::StartDocumentLoad(aCommand, aChannel, aLoadGroup,
aContainer, aDocListener, aReset,
aSink);
MediaDocument::StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer,
aDocListener, aReset, aSink);
NS_ENSURE_SUCCESS(rv, rv);
mStreamListener = new nsMediaDocumentStreamListener(this);
mStreamListener = new MediaDocumentStreamListener(this);
if (!mStreamListener)
return NS_ERROR_OUT_OF_MEMORY;
@ -96,11 +96,11 @@ nsVideoDocument::StartDocumentLoad(const char* aCommand,
}
nsresult
nsVideoDocument::CreateSyntheticVideoDocument(nsIChannel* aChannel,
nsIStreamListener** aListener)
VideoDocument::CreateSyntheticVideoDocument(nsIChannel* aChannel,
nsIStreamListener** aListener)
{
// make our generic document
nsresult rv = nsMediaDocument::CreateSyntheticDocument();
nsresult rv = MediaDocument::CreateSyntheticDocument();
NS_ENSURE_SUCCESS(rv, rv);
Element* body = GetBodyElement();
@ -137,7 +137,7 @@ nsVideoDocument::CreateSyntheticVideoDocument(nsIChannel* aChannel,
}
void
nsVideoDocument::UpdateTitle(nsIChannel* aChannel)
VideoDocument::UpdateTitle(nsIChannel* aChannel)
{
if (!aChannel)
return;
@ -147,10 +147,13 @@ nsVideoDocument::UpdateTitle(nsIChannel* aChannel)
SetTitle(fileName);
}
} // namespace dom
} // namespace mozilla
nsresult
NS_NewVideoDocument(nsIDocument** aResult)
{
nsVideoDocument* doc = new nsVideoDocument();
mozilla::dom::VideoDocument* doc = new mozilla::dom::VideoDocument();
if (!doc) {
return NS_ERROR_OUT_OF_MEMORY;
}