Bug 1034304: Remove nsIDOMHTMLAudio/VideoElement. r=smaug

This commit is contained in:
Kyle Huey 2014-07-12 19:20:42 -07:00
parent 43235043e4
commit 3076eaa115
13 changed files with 49 additions and 192 deletions

View File

@ -7,7 +7,6 @@
#define mozilla_dom_HTMLAudioElement_h
#include "mozilla/Attributes.h"
#include "nsIDOMHTMLAudioElement.h"
#include "mozilla/dom/HTMLMediaElement.h"
#include "mozilla/dom/TypedArray.h"
@ -17,21 +16,18 @@ typedef uint16_t nsMediaReadyState;
namespace mozilla {
namespace dom {
class HTMLAudioElement MOZ_FINAL : public HTMLMediaElement,
public nsIDOMHTMLAudioElement
class HTMLAudioElement MOZ_FINAL : public HTMLMediaElement
{
public:
HTMLAudioElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
typedef mozilla::dom::NodeInfo NodeInfo;
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
HTMLAudioElement(already_AddRefed<NodeInfo>& aNodeInfo);
// nsIDOMHTMLMediaElement
using HTMLMediaElement::GetPaused;
NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(HTMLMediaElement::)
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsresult SetAcceptHeader(nsIHttpChannel* aChannel);
virtual nsresult Clone(NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
virtual nsresult SetAcceptHeader(nsIHttpChannel* aChannel) MOZ_OVERRIDE;
virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; }

View File

@ -72,6 +72,7 @@ class AudioTrackList;
class VideoTrackList;
class HTMLMediaElement : public nsGenericHTMLElement,
public nsIDOMHTMLMediaElement,
public nsIObserver,
public MediaDecoderOwner,
public nsIAudioChannelAgentCallback

View File

@ -8,7 +8,6 @@
#define mozilla_dom_HTMLVideoElement_h
#include "mozilla/Attributes.h"
#include "nsIDOMHTMLVideoElement.h"
#include "mozilla/dom/HTMLMediaElement.h"
namespace mozilla {
@ -17,41 +16,38 @@ namespace dom {
class WakeLock;
class VideoPlaybackQuality;
class HTMLVideoElement MOZ_FINAL : public HTMLMediaElement,
public nsIDOMHTMLVideoElement
class HTMLVideoElement MOZ_FINAL : public HTMLMediaElement
{
public:
HTMLVideoElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
typedef mozilla::dom::NodeInfo NodeInfo;
HTMLVideoElement(already_AddRefed<NodeInfo>& aNodeInfo);
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLVideoElement, video)
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMHTMLMediaElement
using HTMLMediaElement::GetPaused;
NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(HTMLMediaElement::)
// nsIDOMHTMLVideoElement
NS_DECL_NSIDOMHTMLVIDEOELEMENT
NS_IMETHOD_(bool) IsVideo() MOZ_OVERRIDE {
return true;
}
virtual bool ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult) MOZ_OVERRIDE;
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE;
static void Init();
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const MOZ_OVERRIDE;
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
virtual nsresult Clone(NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
// Set size with the current video frame's height and width.
// If there is no video frame, returns NS_ERROR_FAILURE.
nsresult GetVideoSize(nsIntSize* size);
virtual nsresult SetAcceptHeader(nsIHttpChannel* aChannel);
virtual nsresult SetAcceptHeader(nsIHttpChannel* aChannel) MOZ_OVERRIDE;
// WebIDL
@ -85,7 +81,10 @@ public:
return mMediaSize.height == -1 ? 0 : mMediaSize.height;
}
// XPCOM GetPoster is OK
void GetPoster(nsAString& aValue)
{
GetURIAttr(nsGkAtoms::poster, nullptr, aValue);
}
void SetPoster(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::poster, aValue, aRv);

View File

@ -7,7 +7,6 @@
#include "mozilla/dom/HTMLAudioElement.h"
#include "mozilla/dom/HTMLAudioElementBinding.h"
#include "nsError.h"
#include "nsIDOMHTMLAudioElement.h"
#include "nsGenericHTMLElement.h"
#include "nsGkAtoms.h"
#include "nsIDocument.h"
@ -29,13 +28,10 @@ namespace dom {
extern bool IsAudioAPIEnabled();
NS_IMPL_ISUPPORTS_INHERITED(HTMLAudioElement, HTMLMediaElement,
nsIDOMHTMLMediaElement, nsIDOMHTMLAudioElement)
NS_IMPL_ELEMENT_CLONE(HTMLAudioElement)
HTMLAudioElement::HTMLAudioElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
HTMLAudioElement::HTMLAudioElement(already_AddRefed<NodeInfo>& aNodeInfo)
: HTMLMediaElement(aNodeInfo)
{
}
@ -44,7 +40,6 @@ HTMLAudioElement::~HTMLAudioElement()
{
}
already_AddRefed<HTMLAudioElement>
HTMLAudioElement::Audio(const GlobalObject& aGlobal,
const Optional<nsAString>& aSrc,

View File

@ -48,7 +48,6 @@
#include "nsICategoryManager.h"
#include "MediaResource.h"
#include "nsIDOMHTMLVideoElement.h"
#include "nsIContentPolicy.h"
#include "nsContentPolicyUtils.h"
#include "nsCrossSiteListenerProxy.h"
@ -458,6 +457,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLMediaElement, nsGenericHTMLE
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(HTMLMediaElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLMediaElement)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsIAudioChannelAgentCallback)
NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
@ -488,6 +488,12 @@ HTMLMediaElement::SetMozAudioChannelType(const nsAString& aValue)
return SetAttrHelper(nsGkAtoms::mozaudiochannel, aValue);
}
NS_IMETHODIMP_(bool)
HTMLMediaElement::IsVideo()
{
return false;
}
already_AddRefed<DOMMediaStream>
HTMLMediaElement::GetMozSrcObject() const
{
@ -1820,8 +1826,7 @@ HTMLMediaElement::CaptureStreamInternal(bool aFinishWhenEnded)
// holistically.
uint8_t hints = 0;
if (Preferences::GetBool("media.capturestream_hints.enabled")) {
nsCOMPtr<nsIDOMHTMLVideoElement> video = do_QueryObject(this);
if (video && GetVideoFrameContainer()) {
if (IsVideo() && GetVideoFrameContainer()) {
hints = DOMMediaStream::HINT_CONTENTS_VIDEO | DOMMediaStream::HINT_CONTENTS_AUDIO;
} else {
hints = DOMMediaStream::HINT_CONTENTS_AUDIO;
@ -3275,9 +3280,9 @@ VideoFrameContainer* HTMLMediaElement::GetVideoFrameContainer()
return mVideoFrameContainer;
// Only video frames need an image container.
nsCOMPtr<nsIDOMHTMLVideoElement> video = do_QueryObject(this);
if (!video)
if (!IsVideo()) {
return nullptr;
}
mVideoFrameContainer =
new VideoFrameContainer(this, LayerManager::CreateAsynchronousImageContainer());
@ -3884,9 +3889,8 @@ void HTMLMediaElement::UpdateAudioChannelPlayingState()
if (!mAudioChannelAgent) {
return;
}
nsCOMPtr<nsIDOMHTMLVideoElement> video = do_QueryObject(this);
// Use a weak ref so the audio channel agent can't leak |this|.
if (AudioChannel::Normal == mAudioChannel && video) {
if (AudioChannel::Normal == mAudioChannel && IsVideo()) {
mAudioChannelAgent->InitWithVideo(OwnerDoc()->GetWindow(),
static_cast<int32_t>(mAudioChannel),
this, true);

View File

@ -4,7 +4,6 @@
* 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/. */
#include "nsIDOMHTMLVideoElement.h"
#include "nsIDOMHTMLSourceElement.h"
#include "mozilla/dom/HTMLVideoElement.h"
#include "mozilla/dom/HTMLVideoElementBinding.h"
@ -40,31 +39,9 @@ namespace dom {
static bool sVideoStatsEnabled;
NS_IMPL_ISUPPORTS_INHERITED(HTMLVideoElement, HTMLMediaElement,
nsIDOMHTMLMediaElement, nsIDOMHTMLVideoElement)
NS_IMPL_ELEMENT_CLONE(HTMLVideoElement)
// nsIDOMHTMLVideoElement
NS_IMPL_INT_ATTR(HTMLVideoElement, Width, width)
NS_IMPL_INT_ATTR(HTMLVideoElement, Height, height)
// nsIDOMHTMLVideoElement
/* readonly attribute unsigned long videoWidth; */
NS_IMETHODIMP HTMLVideoElement::GetVideoWidth(uint32_t *aVideoWidth)
{
*aVideoWidth = VideoWidth();
return NS_OK;
}
/* readonly attribute unsigned long videoHeight; */
NS_IMETHODIMP HTMLVideoElement::GetVideoHeight(uint32_t *aVideoHeight)
{
*aVideoHeight = VideoHeight();
return NS_OK;
}
HTMLVideoElement::HTMLVideoElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
HTMLVideoElement::HTMLVideoElement(already_AddRefed<NodeInfo>& aNodeInfo)
: HTMLMediaElement(aNodeInfo)
{
}
@ -149,8 +126,6 @@ nsresult HTMLVideoElement::SetAcceptHeader(nsIHttpChannel* aChannel)
false);
}
NS_IMPL_URI_ATTR(HTMLVideoElement, Poster, poster)
uint32_t HTMLVideoElement::MozParsedFrames() const
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
@ -160,12 +135,6 @@ uint32_t HTMLVideoElement::MozParsedFrames() const
return mDecoder ? mDecoder->GetFrameStatistics().GetParsedFrames() : 0;
}
NS_IMETHODIMP HTMLVideoElement::GetMozParsedFrames(uint32_t *aMozParsedFrames)
{
*aMozParsedFrames = MozParsedFrames();
return NS_OK;
}
uint32_t HTMLVideoElement::MozDecodedFrames() const
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
@ -175,12 +144,6 @@ uint32_t HTMLVideoElement::MozDecodedFrames() const
return mDecoder ? mDecoder->GetFrameStatistics().GetDecodedFrames() : 0;
}
NS_IMETHODIMP HTMLVideoElement::GetMozDecodedFrames(uint32_t *aMozDecodedFrames)
{
*aMozDecodedFrames = MozDecodedFrames();
return NS_OK;
}
uint32_t HTMLVideoElement::MozPresentedFrames() const
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
@ -190,12 +153,6 @@ uint32_t HTMLVideoElement::MozPresentedFrames() const
return mDecoder ? mDecoder->GetFrameStatistics().GetPresentedFrames() : 0;
}
NS_IMETHODIMP HTMLVideoElement::GetMozPresentedFrames(uint32_t *aMozPresentedFrames)
{
*aMozPresentedFrames = MozPresentedFrames();
return NS_OK;
}
uint32_t HTMLVideoElement::MozPaintedFrames()
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
@ -206,12 +163,6 @@ uint32_t HTMLVideoElement::MozPaintedFrames()
return container ? container->GetPaintCount() : 0;
}
NS_IMETHODIMP HTMLVideoElement::GetMozPaintedFrames(uint32_t *aMozPaintedFrames)
{
*aMozPaintedFrames = MozPaintedFrames();
return NS_OK;
}
double HTMLVideoElement::MozFrameDelay()
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
@ -219,23 +170,12 @@ double HTMLVideoElement::MozFrameDelay()
return container ? container->GetFrameDelay() : 0;
}
NS_IMETHODIMP HTMLVideoElement::GetMozFrameDelay(double *aMozFrameDelay) {
*aMozFrameDelay = MozFrameDelay();
return NS_OK;
}
/* readonly attribute bool mozHasAudio */
bool HTMLVideoElement::MozHasAudio() const
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
return mHasAudio;
}
NS_IMETHODIMP HTMLVideoElement::GetMozHasAudio(bool *aHasAudio) {
*aHasAudio = MozHasAudio();
return NS_OK;
}
JSObject*
HTMLVideoElement::WrapNode(JSContext* aCx)
{
@ -324,5 +264,6 @@ HTMLVideoElement::Init()
{
Preferences::AddBoolVarCache(&sVideoStatsEnabled, "media.video_stats.enabled");
}
} // namespace dom
} // namespace mozilla

View File

@ -8,7 +8,6 @@ XPIDL_SOURCES += [
'nsIDOMHTMLAnchorElement.idl',
'nsIDOMHTMLAppletElement.idl',
'nsIDOMHTMLAreaElement.idl',
'nsIDOMHTMLAudioElement.idl',
'nsIDOMHTMLBaseElement.idl',
'nsIDOMHTMLBodyElement.idl',
'nsIDOMHTMLBRElement.idl',
@ -58,7 +57,6 @@ XPIDL_SOURCES += [
'nsIDOMHTMLTextAreaElement.idl',
'nsIDOMHTMLTitleElement.idl',
'nsIDOMHTMLUListElement.idl',
'nsIDOMHTMLVideoElement.idl',
'nsIDOMMediaError.idl',
'nsIDOMMozBrowserFrame.idl',
'nsIDOMTimeRanges.idl',

View File

@ -1,22 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#include "nsIDOMHTMLMediaElement.idl"
/**
* The nsIDOMHTMLAudioElement interface is the interface to a HTML
* <audio> element.
*
* For more information on this interface, please see
* http://www.whatwg.org/specs/web-apps/current-work/#audio
*
* @status UNDER_DEVELOPMENT
*/
[uuid(75a7f3ca-0761-4b63-863b-6fd6a87ed51c)]
interface nsIDOMHTMLAudioElement : nsIDOMHTMLMediaElement
{
};

View File

@ -27,7 +27,7 @@ interface nsIDOMMediaStream;
#endif
%}
[uuid(1f9393e8-2df0-4072-87b9-c26999b09acc)]
[uuid(0e14e6ad-2074-48b7-a247-e545a3a15131)]
interface nsIDOMHTMLMediaElement : nsISupports
{
// error state
@ -133,4 +133,6 @@ interface nsIDOMHTMLMediaElement : nsISupports
// * onmozinterruptbegin - called when the media element is interrupted
// because of the audiochannel manager.
// * onmozinterruptend - called when the interruption is concluded
[notxpcom] boolean isVideo();
};

View File

@ -1,50 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#include "nsIDOMHTMLMediaElement.idl"
/**
* The nsIDOMHTMLVideoElement interface is the interface to a HTML
* <video> element.
*
* For more information on this interface, please see
* http://www.whatwg.org/specs/web-apps/current-work/#video
*
* @status UNDER_DEVELOPMENT
*/
[uuid(185a3e8f-56a7-4bda-8dc7-2cff6ed07d1d)]
interface nsIDOMHTMLVideoElement : nsIDOMHTMLMediaElement
{
attribute long width;
attribute long height;
readonly attribute unsigned long videoWidth;
readonly attribute unsigned long videoHeight;
attribute DOMString poster;
// A count of the number of video frames that have demuxed from the media
// resource. If we were playing perfectly, we'd be able to paint this many
// frames.
readonly attribute unsigned long mozParsedFrames;
// A count of the number of frames that have been decoded. We may drop
// frames if the decode is taking too much time.
readonly attribute unsigned long mozDecodedFrames;
// A count of the number of frames that have been presented to the rendering
// pipeline. We may drop frames if they arrive late at the renderer.
readonly attribute unsigned long mozPresentedFrames;
// Number of presented frames which were painted on screen.
readonly attribute unsigned long mozPaintedFrames;
// Time which the last painted video frame was late by, in seconds.
readonly attribute double mozFrameDelay;
// True if the video has an audio track available.
readonly attribute bool mozHasAudio;
};

View File

@ -12,7 +12,6 @@
#include "nsGkAtoms.h"
#include "mozilla/dom/HTMLVideoElement.h"
#include "nsIDOMHTMLVideoElement.h"
#include "nsIDOMHTMLImageElement.h"
#include "nsDisplayList.h"
#include "nsGenericHTMLElement.h"
@ -618,8 +617,8 @@ nsVideoFrame::AttributeChanged(int32_t aNameSpaceID,
}
bool nsVideoFrame::HasVideoElement() {
nsCOMPtr<nsIDOMHTMLVideoElement> videoDomElement = do_QueryInterface(mContent);
return videoDomElement != nullptr;
nsCOMPtr<nsIDOMHTMLMediaElement> mediaDomElement = do_QueryInterface(mContent);
return mediaDomElement->IsVideo();
}
bool nsVideoFrame::HasVideoData()

View File

@ -4884,14 +4884,14 @@ var BrowserEventHandler = {
* <video>, <object>, <embed>, <applet>, <canvas>, <img>, <media>, <pre>
*/
_shouldSuppressReflowOnZoom: function(aElement) {
if (aElement instanceof Ci.nsIDOMHTMLVideoElement ||
aElement instanceof Ci.nsIDOMHTMLObjectElement ||
aElement instanceof Ci.nsIDOMHTMLEmbedElement ||
aElement instanceof Ci.nsIDOMHTMLAppletElement ||
aElement instanceof Ci.nsIDOMHTMLCanvasElement ||
aElement instanceof Ci.nsIDOMHTMLImageElement ||
aElement instanceof Ci.nsIDOMHTMLMediaElement ||
aElement instanceof Ci.nsIDOMHTMLPreElement) {
if (aElement instanceof HTMLVideoElement ||
aElement instanceof HTMLObjectElement ||
aElement instanceof HTMLEmbedElement ||
aElement instanceof HTMLAppletElement ||
aElement instanceof HTMLCanvasElement ||
aElement instanceof HTMLImageElement ||
aElement instanceof HTMLMediaElement ||
aElement instanceof HTMLPreElement) {
return true;
}

View File

@ -51,7 +51,6 @@
#include "nsIDOMHTMLAnchorElement.h"
#include "nsIDOMHTMLAppletElement.h"
#include "nsIDOMHTMLAreaElement.h"
#include "nsIDOMHTMLAudioElement.h"
#include "nsIDOMHTMLBRElement.h"
#include "nsIDOMHTMLBaseElement.h"
#include "nsIDOMHTMLBodyElement.h"
@ -100,7 +99,6 @@
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsIDOMHTMLTitleElement.h"
#include "nsIDOMHTMLUListElement.h"
#include "nsIDOMHTMLVideoElement.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMMediaError.h"
#include "nsIDOMMediaList.h"
@ -190,7 +188,6 @@
#include "mozilla/dom/HTMLAnchorElementBinding.h"
#include "mozilla/dom/HTMLAppletElementBinding.h"
#include "mozilla/dom/HTMLAreaElementBinding.h"
#include "mozilla/dom/HTMLAudioElementBinding.h"
#include "mozilla/dom/HTMLBRElementBinding.h"
#include "mozilla/dom/HTMLBaseElementBinding.h"
#include "mozilla/dom/HTMLBodyElementBinding.h"
@ -239,7 +236,6 @@
#include "mozilla/dom/HTMLTextAreaElementBinding.h"
#include "mozilla/dom/HTMLTitleElementBinding.h"
#include "mozilla/dom/HTMLUListElementBinding.h"
#include "mozilla/dom/HTMLVideoElementBinding.h"
#include "mozilla/dom/KeyEventBinding.h"
#include "mozilla/dom/LocalMediaStreamBinding.h"
#include "mozilla/dom/MediaErrorBinding.h"
@ -381,7 +377,6 @@ const ComponentsInterfaceShimEntry kComponentsInterfaceShimMap[] =
DEFINE_SHIM(HTMLAnchorElement),
DEFINE_SHIM(HTMLAppletElement),
DEFINE_SHIM(HTMLAreaElement),
DEFINE_SHIM(HTMLAudioElement),
DEFINE_SHIM(HTMLBRElement),
DEFINE_SHIM(HTMLBaseElement),
DEFINE_SHIM(HTMLBodyElement),
@ -430,7 +425,6 @@ const ComponentsInterfaceShimEntry kComponentsInterfaceShimMap[] =
DEFINE_SHIM(HTMLTextAreaElement),
DEFINE_SHIM(HTMLTitleElement),
DEFINE_SHIM(HTMLUListElement),
DEFINE_SHIM(HTMLVideoElement),
DEFINE_SHIM(KeyEvent),
DEFINE_SHIM(LocalMediaStream),
DEFINE_SHIM(MediaError),