Bug 841493 - Convert HTMLVideoElement to WebIDL, r=Ms2ger

This commit is contained in:
Andrea Marchesini 2013-03-19 13:28:34 +01:00
Родитель a7e3b326ad
Коммит e85da75cfc
7 изменённых файлов: 157 добавлений и 21 удалений

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

@ -1447,7 +1447,7 @@ CanvasRenderingContext2D::CreatePattern(const HTMLImageOrCanvasOrVideoElement& e
} else if (element.IsHTMLImageElement()) {
htmlElement = &element.GetAsHTMLImageElement();
} else {
htmlElement = element.GetAsHTMLVideoElement();
htmlElement = &element.GetAsHTMLVideoElement();
}
// The canvas spec says that createPattern should use the first frame
@ -2940,7 +2940,7 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
HTMLImageElement* img = &image.GetAsHTMLImageElement();
element = img;
} else {
HTMLVideoElement* video = image.GetAsHTMLVideoElement();
HTMLVideoElement* video = &image.GetAsHTMLVideoElement();
element = video;
}

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

@ -59,6 +59,59 @@ public:
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
// WebIDL
uint32_t Width() const
{
return GetIntAttr(nsGkAtoms::width, 0);
}
void SetWidth(uint32_t aValue, ErrorResult& aRv)
{
SetHTMLIntAttr(nsGkAtoms::width, aValue, aRv);
}
uint32_t Height() const
{
return GetIntAttr(nsGkAtoms::height, 0);
}
void SetHeight(uint32_t aValue, ErrorResult& aRv)
{
SetHTMLIntAttr(nsGkAtoms::height, aValue, aRv);
}
uint32_t VideoWidth() const
{
return mMediaSize.width == -1 ? 0 : mMediaSize.width;
}
uint32_t VideoHeight() const
{
return mMediaSize.height == -1 ? 0 : mMediaSize.height;
}
// XPCOM GetPoster is OK
void SetPoster(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::poster, aValue, aRv);
}
uint32_t MozParsedFrames() const;
uint32_t MozDecodedFrames() const;
uint32_t MozPresentedFrames() const;
uint32_t MozPaintedFrames();
double MozFrameDelay();
bool MozHasAudio() const;
protected:
virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
};
} // namespace dom

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

@ -9,6 +9,7 @@
#include "nsIDOMHTMLVideoElement.h"
#include "nsIDOMHTMLSourceElement.h"
#include "mozilla/dom/HTMLVideoElement.h"
#include "mozilla/dom/HTMLVideoElementBinding.h"
#include "nsGenericHTMLElement.h"
#include "nsGkAtoms.h"
#include "nsSize.h"
@ -57,20 +58,21 @@ NS_IMPL_INT_ATTR(HTMLVideoElement, Height, height)
/* readonly attribute unsigned long videoWidth; */
NS_IMETHODIMP HTMLVideoElement::GetVideoWidth(uint32_t *aVideoWidth)
{
*aVideoWidth = mMediaSize.width == -1 ? 0 : mMediaSize.width;
*aVideoWidth = VideoWidth();
return NS_OK;
}
/* readonly attribute unsigned long videoHeight; */
NS_IMETHODIMP HTMLVideoElement::GetVideoHeight(uint32_t *aVideoHeight)
{
*aVideoHeight = mMediaSize.height == -1 ? 0 : mMediaSize.height;
*aVideoHeight = VideoHeight();
return NS_OK;
}
HTMLVideoElement::HTMLVideoElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: HTMLMediaElement(aNodeInfo)
{
SetIsDOMBinding();
}
HTMLVideoElement::~HTMLVideoElement()
@ -155,49 +157,84 @@ nsresult HTMLVideoElement::SetAcceptHeader(nsIHttpChannel* aChannel)
NS_IMPL_URI_ATTR(HTMLVideoElement, Poster, poster)
uint32_t HTMLVideoElement::MozParsedFrames() const
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
return mDecoder ? mDecoder->GetFrameStatistics().GetParsedFrames() : 0;
}
NS_IMETHODIMP HTMLVideoElement::GetMozParsedFrames(uint32_t *aMozParsedFrames)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
*aMozParsedFrames = mDecoder ? mDecoder->GetFrameStatistics().GetParsedFrames() : 0;
*aMozParsedFrames = MozParsedFrames();
return NS_OK;
}
uint32_t HTMLVideoElement::MozDecodedFrames() const
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
return mDecoder ? mDecoder->GetFrameStatistics().GetDecodedFrames() : 0;
}
NS_IMETHODIMP HTMLVideoElement::GetMozDecodedFrames(uint32_t *aMozDecodedFrames)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
*aMozDecodedFrames = mDecoder ? mDecoder->GetFrameStatistics().GetDecodedFrames() : 0;
*aMozDecodedFrames = MozDecodedFrames();
return NS_OK;
}
uint32_t HTMLVideoElement::MozPresentedFrames() const
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
return mDecoder ? mDecoder->GetFrameStatistics().GetPresentedFrames() : 0;
}
NS_IMETHODIMP HTMLVideoElement::GetMozPresentedFrames(uint32_t *aMozPresentedFrames)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
*aMozPresentedFrames = mDecoder ? mDecoder->GetFrameStatistics().GetPresentedFrames() : 0;
*aMozPresentedFrames = MozPresentedFrames();
return NS_OK;
}
uint32_t HTMLVideoElement::MozPaintedFrames()
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
layers::ImageContainer* container = GetImageContainer();
return container ? container->GetPaintCount() : 0;
}
NS_IMETHODIMP HTMLVideoElement::GetMozPaintedFrames(uint32_t *aMozPaintedFrames)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
layers::ImageContainer* container = GetImageContainer();
*aMozPaintedFrames = container ? container->GetPaintCount() : 0;
*aMozPaintedFrames = MozPaintedFrames();
return NS_OK;
}
double HTMLVideoElement::MozFrameDelay()
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
VideoFrameContainer* container = GetVideoFrameContainer();
return container ? container->GetFrameDelay() : 0;
}
NS_IMETHODIMP HTMLVideoElement::GetMozFrameDelay(double *aMozFrameDelay) {
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
VideoFrameContainer* container = GetVideoFrameContainer();
*aMozFrameDelay = container ? container->GetFrameDelay() : 0;
*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) {
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
*aHasAudio = mHasAudio;
*aHasAudio = MozHasAudio();
return NS_OK;
}
JSObject*
HTMLVideoElement::WrapNode(JSContext* aCx, JSObject* aScope)
{
return HTMLVideoElementBinding::Wrap(aCx, aScope, this);
}
} // namespace dom
} // namespace mozilla

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

@ -1338,7 +1338,6 @@ addExternalIface('DOMStringList')
addExternalIface('File')
addExternalIface('HitRegionOptions', nativeType='nsISupports')
addExternalIface('HTMLCanvasElement', nativeType='mozilla::dom::HTMLCanvasElement')
addExternalIface('HTMLVideoElement', nativeType='mozilla::dom::HTMLVideoElement')
addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
addExternalIface('LockedFile')

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

@ -15,7 +15,6 @@ interface CanvasGradient;
interface CanvasPattern;
interface HitRegionOptions;
interface HTMLCanvasElement;
interface HTMLVideoElement;
interface TextMetrics;
interface Window;

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

@ -0,0 +1,47 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/#the-video-element
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
interface HTMLVideoElement : HTMLMediaElement {
[SetterThrows]
attribute unsigned long width;
[SetterThrows]
attribute unsigned long height;
readonly attribute unsigned long videoWidth;
readonly attribute unsigned long videoHeight;
[SetterThrows]
attribute DOMString poster;
};
partial interface HTMLVideoElement {
// 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 boolean mozHasAudio;
};

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

@ -128,6 +128,7 @@ webidl_files = \
HTMLTimeElement.webidl \
HTMLTitleElement.webidl \
HTMLUListElement.webidl \
HTMLVideoElement.webidl \
IDBVersionChangeEvent.webidl \
ImageData.webidl \
InspectorUtils.webidl \