mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
919a7bbc39
- Bug 1241764: Replace nsPIDOMWindow with nsPIDOMWindowInner/Outer. r=mrbkap,smaug (ed606e368d) - Bug 1212720 - Part 1: Implement Document.getAnimations(). r=heycam, r=smaug (8c3951b318) - Bug 1212720 - Part 2: Tests for document.getAnimations. r=heycam (8e6660abe1) - Bug 1212720 - Part 3: Remove AnimationTimeline.getAnimations. r=heycam, r=smaug (a663e7e79b) - Bug 1212720 - Part 4: Remove all cancelAllAnimationsOnEnd. It is not needed any more. r=bbirtles (8c9b92f2d4) - Bug 1218258 - Fix -Wimplicit-fallthrough warnings in toolkit/components/downloads. r=paolo (1962eee4fc) - Bug 1218258 - Fix -Wshadow warnings in toolkit/components/downloads. r=paolo (6cf1d464bb) - Bug 1244726 - Include mozIDOMWindow.h for nsDownloadManager. r=khuey (b01f8d6e44) - Bug 1212323: P1. Use a 640x360 SPS to test for HW decoding support. r=cpearce (ed67910d9c) - Bug 1212323: P2. Have IsVideoAccelerated return a Promise. r=cpearce (824e543945) - Bug 1241764: Merge bug 1212323. r=me CLOSED TREE (e5ed1ad65d) - Bug 1240365 - FileReader should use the global scope correctly in ChromeWorkers, r=smaug, r=khuey (bf40380947) - Bug 1239210 - Don't process WebIDL files when not compiling; r=glandium (5a55f23b2e) - Bug 1242210 - Mark RootedTypedArray as final; r=baku (e9c594fbc8) - more palemoon getSelection revert (443f0d9a7d) - Bug 1213818 - Align document.title for SVG documents with HTML spec; r=bz (fb60e8c048) - Bug 1245182: Move a few event handling functions to nsPIDOMWindowInner. r=smaug (02aadac27e) - Bug 1245124 - window.open() should open a new tab in the same container, r=gijs, r=smaug (808bdd8f9f) - Bug 1168161 - Mark nsPIDOMWindow::mDocShell as MOZ_NON_OWNING_REF. r=ehsan (0b36dbbcb2) - Bug 1234170 - WebSocket should check if the channel has been opened before send the 'close' notification to the WebSocketEventService, r=jduell (4bfd6f3f3f) - Bug 1245261 - Use an atomic to safely access gcTriggerBytes; r=jonco (f9c80d47e1) - Bug 1243001 part 1. Remove the dead WrappedWorkerRunnable class from Promise code. r=peterv (9f8c758723) - Bug 1243001 part 2. Make Promise an empty [NoInterfaceObject] interface when SPIDERMONKEY_PROMISE is defined. r=peterv (6be034ee59) - Bug 1243001 part 3. Turn off the IDL bits of PromiseDebugging when SPIDERMONKEY_PROMISE is defined. r=peterv (114241ddd6) - Bug 1243001 part 4. Switch to using MaybeResolve/MaybeReject instead of ResolveInternal/RejectInternal for PromiseWorkerProxy. r=peterv (ca8faf02f8) - Bug 1243114 - Convert PromiseCapability::mPromise to a rooted JSObject* instead of a rooted JS::Value. r=bz (e4c907e5c2) - Bug 1243001 part 5. Get rid of most of the dom::Promise methods when SPIDERMONKEY_PROMISE is defined, and reimplement the rest in terms of SpiderMonkey Promise. r=peterv (693a61e5a2) - Bug 1242054. Get rid of AbortablePromise, so we can move Promise into SpiderMonkey more easily. r=khuey (6a0200e625) - Bug 1243001 part 6. Implement Promise::AppendNativeHandler in the SPIDERMONKEY_PROMISE world. r=peterv (7c3a6390f9) - Bug 1243001 part 7. Stop wrappercaching dom::Promise when SPIDERMONKEY_PROMISE is defined. r=peterv (be1bd9b33f) - Bug 1243001 part 8. Tell SpiderMonkey to put its promise jobs into the CycleCollectedJSRuntime job queue. r=peterv (192e6a551c) - Bug 1156880 - Null check the prescontext in nsDOMWindowUtils::AdvanceTimeAndRefresh; r=mstange (11f1a39f22) - Bug 1191597 part 1 - Add head.js and dummy page for browser chrome test. r=smaug (5257870dd3) - Bug 1191597 part 2 - Convert fullscreen-esc-context-menu to a browser chrome test. r=smaug (e1c0fe84a4)
306 lines
8.0 KiB
C++
306 lines
8.0 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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 "nsIDOMHTMLSourceElement.h"
|
|
#include "mozilla/dom/HTMLVideoElement.h"
|
|
#include "mozilla/dom/HTMLVideoElementBinding.h"
|
|
#include "nsGenericHTMLElement.h"
|
|
#include "nsGkAtoms.h"
|
|
#include "nsSize.h"
|
|
#include "nsError.h"
|
|
#include "nsNodeInfoManager.h"
|
|
#include "plbase64.h"
|
|
#include "nsXPCOMStrings.h"
|
|
#include "prlock.h"
|
|
#include "nsThreadUtils.h"
|
|
#include "ImageContainer.h"
|
|
|
|
#include "nsIScriptSecurityManager.h"
|
|
#include "nsIXPConnect.h"
|
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "MediaError.h"
|
|
#include "MediaDecoder.h"
|
|
#include "mozilla/Preferences.h"
|
|
#include "mozilla/dom/WakeLock.h"
|
|
#include "mozilla/dom/power/PowerManagerService.h"
|
|
#include "nsPerformance.h"
|
|
#include "mozilla/dom/VideoPlaybackQuality.h"
|
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Video)
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
static bool sVideoStatsEnabled;
|
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLVideoElement)
|
|
|
|
HTMLVideoElement::HTMLVideoElement(already_AddRefed<NodeInfo>& aNodeInfo)
|
|
: HTMLMediaElement(aNodeInfo)
|
|
, mUseScreenWakeLock(true)
|
|
{
|
|
}
|
|
|
|
HTMLVideoElement::~HTMLVideoElement()
|
|
{
|
|
}
|
|
|
|
nsresult HTMLVideoElement::GetVideoSize(nsIntSize* size)
|
|
{
|
|
if (!mMediaInfo.HasVideo()) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
if (mDisableVideo) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
switch (mMediaInfo.mVideo.mRotation) {
|
|
case VideoInfo::Rotation::kDegree_90:
|
|
case VideoInfo::Rotation::kDegree_270: {
|
|
size->width = mMediaInfo.mVideo.mDisplay.height;
|
|
size->height = mMediaInfo.mVideo.mDisplay.width;
|
|
break;
|
|
}
|
|
case VideoInfo::Rotation::kDegree_0:
|
|
case VideoInfo::Rotation::kDegree_180:
|
|
default: {
|
|
size->height = mMediaInfo.mVideo.mDisplay.height;
|
|
size->width = mMediaInfo.mVideo.mDisplay.width;
|
|
break;
|
|
}
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
bool
|
|
HTMLVideoElement::ParseAttribute(int32_t aNamespaceID,
|
|
nsIAtom* aAttribute,
|
|
const nsAString& aValue,
|
|
nsAttrValue& aResult)
|
|
{
|
|
if (aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height) {
|
|
return aResult.ParseSpecialIntValue(aValue);
|
|
}
|
|
|
|
return HTMLMediaElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
aResult);
|
|
}
|
|
|
|
void
|
|
HTMLVideoElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
nsRuleData* aData)
|
|
{
|
|
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
|
}
|
|
|
|
NS_IMETHODIMP_(bool)
|
|
HTMLVideoElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
|
{
|
|
static const MappedAttributeEntry attributes[] = {
|
|
{ &nsGkAtoms::width },
|
|
{ &nsGkAtoms::height },
|
|
{ nullptr }
|
|
};
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
attributes,
|
|
sCommonAttributeMap
|
|
};
|
|
|
|
return FindAttributeDependence(aAttribute, map);
|
|
}
|
|
|
|
nsMapRuleToAttributesFunc
|
|
HTMLVideoElement::GetAttributeMappingFunction() const
|
|
{
|
|
return &MapAttributesIntoRule;
|
|
}
|
|
|
|
nsresult HTMLVideoElement::SetAcceptHeader(nsIHttpChannel* aChannel)
|
|
{
|
|
nsAutoCString value(
|
|
"video/webm,"
|
|
"video/ogg,"
|
|
"video/*;q=0.9,"
|
|
"application/ogg;q=0.7,"
|
|
"audio/*;q=0.6,*/*;q=0.5");
|
|
|
|
return aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
|
|
value,
|
|
false);
|
|
}
|
|
|
|
bool
|
|
HTMLVideoElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const
|
|
{
|
|
return HasAttr(kNameSpaceID_None, nsGkAtoms::controls) ||
|
|
HTMLMediaElement::IsInteractiveHTMLContent(aIgnoreTabindex);
|
|
}
|
|
|
|
uint32_t HTMLVideoElement::MozParsedFrames() const
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
|
if (!sVideoStatsEnabled) {
|
|
return 0;
|
|
}
|
|
return mDecoder ? mDecoder->GetFrameStatistics().GetParsedFrames() : 0;
|
|
}
|
|
|
|
uint32_t HTMLVideoElement::MozDecodedFrames() const
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
|
if (!sVideoStatsEnabled) {
|
|
return 0;
|
|
}
|
|
return mDecoder ? mDecoder->GetFrameStatistics().GetDecodedFrames() : 0;
|
|
}
|
|
|
|
uint32_t HTMLVideoElement::MozPresentedFrames() const
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
|
if (!sVideoStatsEnabled) {
|
|
return 0;
|
|
}
|
|
return mDecoder ? mDecoder->GetFrameStatistics().GetPresentedFrames() : 0;
|
|
}
|
|
|
|
uint32_t HTMLVideoElement::MozPaintedFrames()
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
|
if (!sVideoStatsEnabled) {
|
|
return 0;
|
|
}
|
|
layers::ImageContainer* container = GetImageContainer();
|
|
return container ? container->GetPaintCount() : 0;
|
|
}
|
|
|
|
double HTMLVideoElement::MozFrameDelay()
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
|
VideoFrameContainer* container = GetVideoFrameContainer();
|
|
// Hide negative delays. Frame timing tweaks in the compositor (e.g.
|
|
// adding a bias value to prevent multiple dropped/duped frames when
|
|
// frame times are aligned with composition times) may produce apparent
|
|
// negative delay, but we shouldn't report that.
|
|
return container ? std::max(0.0, container->GetFrameDelay()) : 0.0;
|
|
}
|
|
|
|
bool HTMLVideoElement::MozHasAudio() const
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
|
return HasAudio();
|
|
}
|
|
|
|
bool HTMLVideoElement::MozUseScreenWakeLock() const
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
|
return mUseScreenWakeLock;
|
|
}
|
|
|
|
void HTMLVideoElement::SetMozUseScreenWakeLock(bool aValue)
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
|
mUseScreenWakeLock = aValue;
|
|
UpdateScreenWakeLock();
|
|
}
|
|
|
|
JSObject*
|
|
HTMLVideoElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return HTMLVideoElementBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
bool
|
|
HTMLVideoElement::NotifyOwnerDocumentActivityChangedInternal()
|
|
{
|
|
bool pauseElement = HTMLMediaElement::NotifyOwnerDocumentActivityChangedInternal();
|
|
UpdateScreenWakeLock();
|
|
return pauseElement;
|
|
}
|
|
|
|
already_AddRefed<VideoPlaybackQuality>
|
|
HTMLVideoElement::GetVideoPlaybackQuality()
|
|
{
|
|
DOMHighResTimeStamp creationTime = 0;
|
|
uint64_t totalFrames = 0;
|
|
uint64_t droppedFrames = 0;
|
|
uint64_t corruptedFrames = 0;
|
|
|
|
if (sVideoStatsEnabled) {
|
|
if (nsPIDOMWindowInner* window = OwnerDoc()->GetInnerWindow()) {
|
|
nsPerformance* perf = window->GetPerformance();
|
|
if (perf) {
|
|
creationTime = perf->Now();
|
|
}
|
|
}
|
|
|
|
if (mDecoder) {
|
|
FrameStatistics& stats = mDecoder->GetFrameStatistics();
|
|
totalFrames = stats.GetParsedFrames();
|
|
droppedFrames = stats.GetDroppedFrames();
|
|
corruptedFrames = 0;
|
|
}
|
|
}
|
|
|
|
RefPtr<VideoPlaybackQuality> playbackQuality =
|
|
new VideoPlaybackQuality(this, creationTime, totalFrames, droppedFrames,
|
|
corruptedFrames);
|
|
return playbackQuality.forget();
|
|
}
|
|
|
|
void
|
|
HTMLVideoElement::WakeLockCreate()
|
|
{
|
|
HTMLMediaElement::WakeLockCreate();
|
|
UpdateScreenWakeLock();
|
|
}
|
|
|
|
void
|
|
HTMLVideoElement::WakeLockRelease()
|
|
{
|
|
UpdateScreenWakeLock();
|
|
HTMLMediaElement::WakeLockRelease();
|
|
}
|
|
|
|
void
|
|
HTMLVideoElement::UpdateScreenWakeLock()
|
|
{
|
|
bool hidden = OwnerDoc()->Hidden();
|
|
|
|
if (mScreenWakeLock && (mPaused || hidden || !mUseScreenWakeLock)) {
|
|
ErrorResult rv;
|
|
mScreenWakeLock->Unlock(rv);
|
|
rv.SuppressException();
|
|
mScreenWakeLock = nullptr;
|
|
return;
|
|
}
|
|
|
|
if (!mScreenWakeLock && !mPaused && !hidden &&
|
|
mUseScreenWakeLock && HasVideo()) {
|
|
RefPtr<power::PowerManagerService> pmService =
|
|
power::PowerManagerService::GetInstance();
|
|
NS_ENSURE_TRUE_VOID(pmService);
|
|
|
|
ErrorResult rv;
|
|
mScreenWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("screen"),
|
|
OwnerDoc()->GetInnerWindow(),
|
|
rv);
|
|
}
|
|
}
|
|
|
|
void
|
|
HTMLVideoElement::Init()
|
|
{
|
|
Preferences::AddBoolVarCache(&sVideoStatsEnabled, "media.video_stats.enabled");
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|