зеркало из https://github.com/mozilla/gecko-dev.git
merge mozilla-inbound to mozilla-central
This commit is contained in:
Коммит
20a3d7ddce
|
@ -271,11 +271,6 @@ DocManager::HandleEvent(nsIDOMEvent* aEvent)
|
|||
logging::DocDestroy("received 'pagehide' event", document);
|
||||
#endif
|
||||
|
||||
// Ignore 'pagehide' on temporary documents since we ignore them entirely in
|
||||
// accessibility.
|
||||
if (document->IsInitialDocument())
|
||||
return NS_OK;
|
||||
|
||||
// Shutdown this one and sub document accessibles.
|
||||
|
||||
// We're allowed to not remove listeners when accessible document is
|
||||
|
@ -370,10 +365,8 @@ DocManager::RemoveListeners(nsIDocument* aDocument)
|
|||
DocAccessible*
|
||||
DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
|
||||
{
|
||||
// Ignore temporary, hiding, resource documents and documents without
|
||||
// docshell.
|
||||
if (aDocument->IsInitialDocument() ||
|
||||
!aDocument->IsVisibleConsideringAncestors() ||
|
||||
// Ignore hiding, resource documents and documents without docshell.
|
||||
if (!aDocument->IsVisibleConsideringAncestors() ||
|
||||
aDocument->IsResourceDoc() || !aDocument->IsActive())
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -70,13 +70,13 @@
|
|||
#include "nsWhitespaceTokenizer.h"
|
||||
#include "nsAttrName.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsEventStates.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#endif
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
@ -652,7 +652,7 @@ Accessible::NativeState()
|
|||
state |= states::STALE;
|
||||
|
||||
if (HasOwnContent() && mContent->IsElement()) {
|
||||
nsEventStates elementState = mContent->AsElement()->State();
|
||||
EventStates elementState = mContent->AsElement()->State();
|
||||
|
||||
if (elementState.HasState(NS_EVENT_STATE_INVALID))
|
||||
state |= states::INVALID;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsNameSpaceManager.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/DocumentType.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
|
@ -1145,7 +1146,7 @@ DocAccessible::ContentAppended(nsIDocument* aDocument,
|
|||
void
|
||||
DocAccessible::ContentStateChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent,
|
||||
nsEventStates aStateMask)
|
||||
EventStates aStateMask)
|
||||
{
|
||||
Accessible* accessible = GetAccessible(aContent);
|
||||
if (!accessible)
|
||||
|
@ -1184,7 +1185,7 @@ DocAccessible::ContentStateChanged(nsIDocument* aDocument,
|
|||
|
||||
void
|
||||
DocAccessible::DocumentStatesChanged(nsIDocument* aDocument,
|
||||
nsEventStates aStateMask)
|
||||
EventStates aStateMask)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "nsITextControlElement.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/Selection.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "gfxSkipChars.h"
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "nsNameSpaceManager.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
|
@ -231,7 +232,7 @@ HTMLButtonAccessible::NativeState()
|
|||
{
|
||||
uint64_t state = HyperTextAccessibleWrap::NativeState();
|
||||
|
||||
nsEventStates elmState = mContent->AsElement()->State();
|
||||
EventStates elmState = mContent->AsElement()->State();
|
||||
if (elmState.HasState(NS_EVENT_STATE_DEFAULT))
|
||||
state |= states::DEFAULT;
|
||||
|
||||
|
|
|
@ -11,9 +11,10 @@
|
|||
#include "States.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -48,7 +49,7 @@ HTMLLinkAccessible::NativeState()
|
|||
uint64_t
|
||||
HTMLLinkAccessible::NativeLinkState() const
|
||||
{
|
||||
nsEventStates eventState = mContent->AsElement()->State();
|
||||
EventStates eventState = mContent->AsElement()->State();
|
||||
if (eventState.HasState(NS_EVENT_STATE_UNVISITED))
|
||||
return states::LINKED;
|
||||
|
||||
|
@ -149,7 +150,7 @@ HTMLLinkAccessible::IsLinked()
|
|||
if (IsDefunct())
|
||||
return false;
|
||||
|
||||
nsEventStates state = mContent->AsElement()->State();
|
||||
EventStates state = mContent->AsElement()->State();
|
||||
return state.HasAtLeastOneOfStates(NS_EVENT_STATE_VISITED |
|
||||
NS_EVENT_STATE_UNVISITED);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ if CONFIG['MOZ_XUL']:
|
|||
|
||||
LOCAL_INCLUDES += [
|
||||
'../../../../content/base/src',
|
||||
'../../../../dom/events',
|
||||
'../../base',
|
||||
'../../generic',
|
||||
'../../html',
|
||||
|
|
|
@ -52,6 +52,24 @@
|
|||
}
|
||||
}
|
||||
|
||||
function browserReorderChecker()
|
||||
{
|
||||
this.type = EVENT_REORDER;
|
||||
|
||||
this.match = function browserReorderChecker_match(aEvent)
|
||||
{
|
||||
// Reorder event might be duped because of temporary document creation.
|
||||
if (aEvent.accessible == getAccessible(currentBrowser())) {
|
||||
this.cnt++;
|
||||
return this.cnt != 2;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
this.cnt = 0;
|
||||
}
|
||||
|
||||
function loadOneTab(aURI)
|
||||
{
|
||||
this.invoke = function loadOneTab_invoke()
|
||||
|
@ -60,7 +78,7 @@
|
|||
}
|
||||
|
||||
this.eventSeq = [
|
||||
new invokerChecker(EVENT_REORDER, currentBrowser)
|
||||
new browserReorderChecker()
|
||||
];
|
||||
|
||||
this.finalCheck = function loadURI_finalCheck()
|
||||
|
|
|
@ -37,6 +37,13 @@ MOZ_PACKAGER_MINIFY=1
|
|||
|
||||
include $(topsrcdir)/toolkit/mozapps/installer/packager.mk
|
||||
|
||||
# Note that JS_BINARY can be defined in packager.mk, so this test must come after
|
||||
# including that file. MOZ_PACKAGER_MINIFY_JS is used in packager.mk, but since
|
||||
# recipe evaluation is deferred, we can set it here after the inclusion.
|
||||
ifneq (,$(JS_BINARY))
|
||||
MOZ_PACKAGER_MINIFY_JS=1
|
||||
endif
|
||||
|
||||
ifeq (bundle, $(MOZ_FS_LAYOUT))
|
||||
BINPATH = $(_BINPATH)
|
||||
DEFINES += -DAPPNAME=$(_APPNAME)
|
||||
|
|
|
@ -12,7 +12,7 @@ Components.utils.import("resource://gre/modules/Geometry.jsm");
|
|||
// maximum drag distance in inches while axis locking can still be reverted
|
||||
const kAxisLockRevertThreshold = 0.8;
|
||||
|
||||
// Same as NS_EVENT_STATE_ACTIVE from nsIEventStateManager.h
|
||||
// Same as NS_EVENT_STATE_ACTIVE from mozilla/EventStates.h
|
||||
const kStateActive = 0x00000001;
|
||||
|
||||
// After a drag begins, kinetic panning is stopped if the drag doesn't become
|
||||
|
|
|
@ -31,6 +31,7 @@ SEARCH_PATHS = [
|
|||
'python/mozversioncontrol',
|
||||
'python/blessings',
|
||||
'python/configobj',
|
||||
'python/jsmin',
|
||||
'python/psutil',
|
||||
'python/which',
|
||||
'build/pymake',
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
marionette.pth:testing/marionette/client
|
||||
blessings.pth:python/blessings
|
||||
configobj.pth:python/configobj
|
||||
jsmin.pth:python/jsmin
|
||||
mach.pth:python/mach
|
||||
mozbuild.pth:python/mozbuild
|
||||
pymake.pth:build/pymake
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "mozilla/dom/FragmentOrElement.h" // for base class
|
||||
#include "nsChangeHint.h" // for enum
|
||||
#include "nsEventStates.h" // for member
|
||||
#include "mozilla/EventStates.h" // for member
|
||||
#include "mozilla/dom/DirectionalityUtils.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsILinkHandler.h"
|
||||
|
@ -138,10 +138,11 @@ public:
|
|||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
|
||||
/**
|
||||
* Method to get the full state of this element. See nsEventStates.h for
|
||||
* the possible bits that could be set here.
|
||||
* Method to get the full state of this element. See mozilla/EventStates.h
|
||||
* for the possible bits that could be set here.
|
||||
*/
|
||||
nsEventStates State() const {
|
||||
EventStates State() const
|
||||
{
|
||||
// mState is maintained by having whoever might have changed it
|
||||
// call UpdateState() or one of the other mState mutators.
|
||||
return mState;
|
||||
|
@ -162,7 +163,7 @@ public:
|
|||
/**
|
||||
* Method to update mState with link state information. This does not notify.
|
||||
*/
|
||||
void UpdateLinkState(nsEventStates aState);
|
||||
void UpdateLinkState(EventStates aState);
|
||||
|
||||
/**
|
||||
* Returns true if this element is either a full-screen element or an
|
||||
|
@ -177,7 +178,8 @@ public:
|
|||
* The style state of this element. This is the real state of the element
|
||||
* with any style locks applied for pseudo-class inspecting.
|
||||
*/
|
||||
nsEventStates StyleState() const {
|
||||
EventStates StyleState() const
|
||||
{
|
||||
if (!HasLockedStyleStates()) {
|
||||
return mState;
|
||||
}
|
||||
|
@ -187,17 +189,17 @@ public:
|
|||
/**
|
||||
* The style state locks applied to this element.
|
||||
*/
|
||||
nsEventStates LockedStyleStates() const;
|
||||
EventStates LockedStyleStates() const;
|
||||
|
||||
/**
|
||||
* Add a style state lock on this element.
|
||||
*/
|
||||
void LockStyleStates(nsEventStates aStates);
|
||||
void LockStyleStates(EventStates aStates);
|
||||
|
||||
/**
|
||||
* Remove a style state lock on this element.
|
||||
*/
|
||||
void UnlockStyleStates(nsEventStates aStates);
|
||||
void UnlockStyleStates(EventStates aStates);
|
||||
|
||||
/**
|
||||
* Clear all style state locks on this element.
|
||||
|
@ -346,10 +348,10 @@ protected:
|
|||
/**
|
||||
* Method to get the _intrinsic_ content state of this element. This is the
|
||||
* state that is independent of the element's presentation. To get the full
|
||||
* content state, use State(). See nsEventStates.h for
|
||||
* content state, use State(). See mozilla/EventStates.h for
|
||||
* the possible bits that could be set here.
|
||||
*/
|
||||
virtual nsEventStates IntrinsicState() const;
|
||||
virtual EventStates IntrinsicState() const;
|
||||
|
||||
/**
|
||||
* Method to add state bits. This should be called from subclass
|
||||
|
@ -357,7 +359,8 @@ protected:
|
|||
* time and other places where we don't want to notify a state
|
||||
* change.
|
||||
*/
|
||||
void AddStatesSilently(nsEventStates aStates) {
|
||||
void AddStatesSilently(EventStates aStates)
|
||||
{
|
||||
mState |= aStates;
|
||||
}
|
||||
|
||||
|
@ -367,7 +370,8 @@ protected:
|
|||
* time and other places where we don't want to notify a state
|
||||
* change.
|
||||
*/
|
||||
void RemoveStatesSilently(nsEventStates aStates) {
|
||||
void RemoveStatesSilently(EventStates aStates)
|
||||
{
|
||||
mState &= ~aStates;
|
||||
}
|
||||
|
||||
|
@ -381,24 +385,26 @@ private:
|
|||
// Also need to allow Link to call UpdateLinkState.
|
||||
friend class Link;
|
||||
|
||||
void NotifyStateChange(nsEventStates aStates);
|
||||
void NotifyStateChange(EventStates aStates);
|
||||
|
||||
void NotifyStyleStateChange(nsEventStates aStates);
|
||||
void NotifyStyleStateChange(EventStates aStates);
|
||||
|
||||
// Style state computed from element's state and style locks.
|
||||
nsEventStates StyleStateFromLocks() const;
|
||||
EventStates StyleStateFromLocks() const;
|
||||
|
||||
protected:
|
||||
// Methods for the ESM to manage state bits. These will handle
|
||||
// setting up script blockers when they notify, so no need to do it
|
||||
// in the callers unless desired.
|
||||
virtual void AddStates(nsEventStates aStates) {
|
||||
virtual void AddStates(EventStates aStates)
|
||||
{
|
||||
NS_PRECONDITION(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES),
|
||||
"Should only be adding ESM-managed states here");
|
||||
AddStatesSilently(aStates);
|
||||
NotifyStateChange(aStates);
|
||||
}
|
||||
virtual void RemoveStates(nsEventStates aStates) {
|
||||
virtual void RemoveStates(EventStates aStates)
|
||||
{
|
||||
NS_PRECONDITION(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES),
|
||||
"Should only be removing ESM-managed states here");
|
||||
RemoveStatesSilently(aStates);
|
||||
|
@ -1144,7 +1150,7 @@ private:
|
|||
bool aFlushLayout = true);
|
||||
|
||||
// Data members
|
||||
nsEventStates mState;
|
||||
EventStates mState;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(Element, NS_ELEMENT_IID)
|
||||
|
|
|
@ -28,7 +28,6 @@ DEPRECATED_OPERATION(MutationEvent)
|
|||
DEPRECATED_OPERATION(Components)
|
||||
DEPRECATED_OPERATION(PrefixedVisibilityAPI)
|
||||
DEPRECATED_OPERATION(NodeIteratorDetach)
|
||||
DEPRECATED_OPERATION(MozAudioData)
|
||||
DEPRECATED_OPERATION(LenientThis)
|
||||
DEPRECATED_OPERATION(GetPreventDefault)
|
||||
DEPRECATED_OPERATION(GetSetUserData)
|
||||
|
|
|
@ -33,7 +33,6 @@ class nsCSSStyleSheet;
|
|||
class nsIDocShell;
|
||||
class nsDocShell;
|
||||
class nsDOMNavigationTiming;
|
||||
class nsEventStates;
|
||||
class nsFrameLoader;
|
||||
class nsHTMLCSSStyleSheet;
|
||||
class nsHTMLDocument;
|
||||
|
@ -85,6 +84,7 @@ class nsCSSSelectorList;
|
|||
|
||||
namespace mozilla {
|
||||
class ErrorResult;
|
||||
class EventStates;
|
||||
|
||||
namespace css {
|
||||
class Loader;
|
||||
|
@ -1093,12 +1093,12 @@ public:
|
|||
// notify that a content node changed state. This must happen under
|
||||
// a scriptblocker but NOT within a begin/end update.
|
||||
virtual void ContentStateChanged(nsIContent* aContent,
|
||||
nsEventStates aStateMask) = 0;
|
||||
mozilla::EventStates aStateMask) = 0;
|
||||
|
||||
// Notify that a document state has changed.
|
||||
// This should only be called by callers whose state is also reflected in the
|
||||
// implementation of nsDocument::GetDocumentState.
|
||||
virtual void DocumentStatesChanged(nsEventStates aStateMask) = 0;
|
||||
virtual void DocumentStatesChanged(mozilla::EventStates aStateMask) = 0;
|
||||
|
||||
// Observation hooks for style data to propagate notifications
|
||||
// to document observers
|
||||
|
@ -1794,7 +1794,7 @@ public:
|
|||
* Document state bits have the form NS_DOCUMENT_STATE_* and are declared in
|
||||
* nsIDocument.h.
|
||||
*/
|
||||
virtual nsEventStates GetDocumentState() = 0;
|
||||
virtual mozilla::EventStates GetDocumentState() = 0;
|
||||
|
||||
virtual nsISupports* GetCurrentContentSink() = 0;
|
||||
|
||||
|
@ -1891,14 +1891,6 @@ public:
|
|||
|
||||
virtual Element* FindImageMap(const nsAString& aNormalizedMapName) = 0;
|
||||
|
||||
// Called to notify the document that a listener on the "mozaudioavailable"
|
||||
// event has been added. Media elements in the document need to ensure they
|
||||
// fire the event.
|
||||
virtual void NotifyAudioAvailableListener() = 0;
|
||||
|
||||
// Returns true if the document has "mozaudioavailable" event listeners.
|
||||
virtual bool HasAudioAvailableListeners() = 0;
|
||||
|
||||
// Add aLink to the set of links that need their status resolved.
|
||||
void RegisterPendingLinkUpdate(mozilla::dom::Link* aLink);
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#ifndef nsIDocumentObserver_h___
|
||||
#define nsIDocumentObserver_h___
|
||||
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIMutationObserver.h"
|
||||
#include "nsEventStates.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
*/
|
||||
virtual void ContentStateChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent,
|
||||
nsEventStates aStateMask) = 0;
|
||||
mozilla::EventStates aStateMask) = 0;
|
||||
|
||||
/**
|
||||
* Notification that the state of the document has changed.
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
* @param aStateMask the state that changed
|
||||
*/
|
||||
virtual void DocumentStatesChanged(nsIDocument* aDocument,
|
||||
nsEventStates aStateMask) = 0;
|
||||
mozilla::EventStates aStateMask) = 0;
|
||||
|
||||
/**
|
||||
* A StyleSheet has just been added to the document. This method is
|
||||
|
@ -209,11 +209,11 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
|
|||
#define NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED \
|
||||
virtual void ContentStateChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent, \
|
||||
nsEventStates aStateMask);
|
||||
mozilla::EventStates aStateMask);
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED \
|
||||
virtual void DocumentStatesChanged(nsIDocument* aDocument, \
|
||||
nsEventStates aStateMask);
|
||||
mozilla::EventStates aStateMask);
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED \
|
||||
virtual void StyleSheetAdded(nsIDocument* aDocument, \
|
||||
|
@ -286,14 +286,14 @@ _class::EndLoad(nsIDocument* aDocument) \
|
|||
#define NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(_class) \
|
||||
void \
|
||||
_class::ContentStateChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent, \
|
||||
nsEventStates aStateMask) \
|
||||
nsIContent* aContent, \
|
||||
mozilla::EventStates aStateMask) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
void \
|
||||
_class::DocumentStatesChanged(nsIDocument* aDocument, \
|
||||
nsEventStates aStateMask) \
|
||||
mozilla::EventStates aStateMask) \
|
||||
{ \
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/InternalMutationEvent.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
|
@ -148,7 +149,7 @@ Element::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
aInstancePtr);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
Element::IntrinsicState() const
|
||||
{
|
||||
return IsEditable() ? NS_EVENT_STATE_MOZ_READWRITE :
|
||||
|
@ -156,7 +157,7 @@ Element::IntrinsicState() const
|
|||
}
|
||||
|
||||
void
|
||||
Element::NotifyStateChange(nsEventStates aStates)
|
||||
Element::NotifyStateChange(EventStates aStates)
|
||||
{
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
if (doc) {
|
||||
|
@ -166,7 +167,7 @@ Element::NotifyStateChange(nsEventStates aStates)
|
|||
}
|
||||
|
||||
void
|
||||
Element::UpdateLinkState(nsEventStates aState)
|
||||
Element::UpdateLinkState(EventStates aState)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(!aState.HasAtLeastOneOfStates(~(NS_EVENT_STATE_VISITED |
|
||||
NS_EVENT_STATE_UNVISITED)),
|
||||
|
@ -179,10 +180,10 @@ Element::UpdateLinkState(nsEventStates aState)
|
|||
void
|
||||
Element::UpdateState(bool aNotify)
|
||||
{
|
||||
nsEventStates oldState = mState;
|
||||
EventStates oldState = mState;
|
||||
mState = IntrinsicState() | (oldState & ESM_MANAGED_STATES);
|
||||
if (aNotify) {
|
||||
nsEventStates changedStates = oldState ^ mState;
|
||||
EventStates changedStates = oldState ^ mState;
|
||||
if (!changedStates.IsEmpty()) {
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
if (doc) {
|
||||
|
@ -226,11 +227,11 @@ Element::UpdateEditableState(bool aNotify)
|
|||
}
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
Element::StyleStateFromLocks() const
|
||||
{
|
||||
nsEventStates locks = LockedStyleStates();
|
||||
nsEventStates state = mState | locks;
|
||||
EventStates locks = LockedStyleStates();
|
||||
EventStates state = mState | locks;
|
||||
|
||||
if (locks.HasState(NS_EVENT_STATE_VISITED)) {
|
||||
return state & ~NS_EVENT_STATE_UNVISITED;
|
||||
|
@ -241,19 +242,19 @@ Element::StyleStateFromLocks() const
|
|||
return state;
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
Element::LockedStyleStates() const
|
||||
{
|
||||
nsEventStates *locks =
|
||||
static_cast<nsEventStates*> (GetProperty(nsGkAtoms::lockedStyleStates));
|
||||
EventStates* locks =
|
||||
static_cast<EventStates*>(GetProperty(nsGkAtoms::lockedStyleStates));
|
||||
if (locks) {
|
||||
return *locks;
|
||||
}
|
||||
return nsEventStates();
|
||||
return EventStates();
|
||||
}
|
||||
|
||||
void
|
||||
Element::NotifyStyleStateChange(nsEventStates aStates)
|
||||
Element::NotifyStyleStateChange(EventStates aStates)
|
||||
{
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
if (doc) {
|
||||
|
@ -266,9 +267,9 @@ Element::NotifyStyleStateChange(nsEventStates aStates)
|
|||
}
|
||||
|
||||
void
|
||||
Element::LockStyleStates(nsEventStates aStates)
|
||||
Element::LockStyleStates(EventStates aStates)
|
||||
{
|
||||
nsEventStates *locks = new nsEventStates(LockedStyleStates());
|
||||
EventStates* locks = new EventStates(LockedStyleStates());
|
||||
|
||||
*locks |= aStates;
|
||||
|
||||
|
@ -280,16 +281,16 @@ Element::LockStyleStates(nsEventStates aStates)
|
|||
}
|
||||
|
||||
SetProperty(nsGkAtoms::lockedStyleStates, locks,
|
||||
nsINode::DeleteProperty<nsEventStates>);
|
||||
nsINode::DeleteProperty<EventStates>);
|
||||
SetHasLockedStyleStates();
|
||||
|
||||
NotifyStyleStateChange(aStates);
|
||||
}
|
||||
|
||||
void
|
||||
Element::UnlockStyleStates(nsEventStates aStates)
|
||||
Element::UnlockStyleStates(EventStates aStates)
|
||||
{
|
||||
nsEventStates *locks = new nsEventStates(LockedStyleStates());
|
||||
EventStates* locks = new EventStates(LockedStyleStates());
|
||||
|
||||
*locks &= ~aStates;
|
||||
|
||||
|
@ -300,7 +301,7 @@ Element::UnlockStyleStates(nsEventStates aStates)
|
|||
}
|
||||
else {
|
||||
SetProperty(nsGkAtoms::lockedStyleStates, locks,
|
||||
nsINode::DeleteProperty<nsEventStates>);
|
||||
nsINode::DeleteProperty<EventStates>);
|
||||
}
|
||||
|
||||
NotifyStyleStateChange(aStates);
|
||||
|
@ -309,7 +310,7 @@ Element::UnlockStyleStates(nsEventStates aStates)
|
|||
void
|
||||
Element::ClearStyleStateLocks()
|
||||
{
|
||||
nsEventStates locks = LockedStyleStates();
|
||||
EventStates locks = LockedStyleStates();
|
||||
|
||||
DeleteProperty(nsGkAtoms::lockedStyleStates);
|
||||
ClearHasLockedStyleStates();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/Attr.h"
|
||||
#include "nsDOMAttributeMap.h"
|
||||
#include "nsIAtom.h"
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#include "Link.h"
|
||||
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsISizeOf.h"
|
||||
|
||||
|
@ -66,7 +66,7 @@ Link::SetLinkState(nsLinkState aState)
|
|||
mElement->UpdateState(true);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
Link::LinkState() const
|
||||
{
|
||||
// We are a constant method, but we are just lazily doing things and have to
|
||||
|
@ -108,7 +108,7 @@ Link::LinkState() const
|
|||
return NS_EVENT_STATE_UNVISITED;
|
||||
}
|
||||
|
||||
return nsEventStates();
|
||||
return EventStates();
|
||||
}
|
||||
|
||||
nsIURI*
|
||||
|
@ -504,7 +504,7 @@ Link::ResetLinkState(bool aNotify, bool aHasHref)
|
|||
if (mLinkState == eLinkState_Unvisited) {
|
||||
mElement->UpdateLinkState(NS_EVENT_STATE_UNVISITED);
|
||||
} else {
|
||||
mElement->UpdateLinkState(nsEventStates());
|
||||
mElement->UpdateLinkState(EventStates());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,12 @@
|
|||
#include "mozilla/IHistory.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/dom/URLSearchParams.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EventStates;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class Element;
|
||||
|
@ -42,7 +44,7 @@ public:
|
|||
* NS_EVENT_STATE_UNVISTED if this link is not visited, or 0 if this
|
||||
* link is not actually a link.
|
||||
*/
|
||||
nsEventStates LinkState() const;
|
||||
EventStates LinkState() const;
|
||||
|
||||
/**
|
||||
* @return the URI this link is for, if available.
|
||||
|
|
|
@ -213,7 +213,6 @@ LOCAL_INCLUDES += [
|
|||
'/content/xul/document/src',
|
||||
'/docshell/base',
|
||||
'/dom/base',
|
||||
'/dom/events',
|
||||
'/dom/ipc',
|
||||
'/dom/workers',
|
||||
'/dom/xbl',
|
||||
|
|
|
@ -122,6 +122,7 @@
|
|||
#include "nsDateTimeFormatCID.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/InternalMutationEvent.h"
|
||||
#include "nsDOMCID.h"
|
||||
|
||||
|
@ -4936,7 +4937,7 @@ nsDocument::EndLoad()
|
|||
}
|
||||
|
||||
void
|
||||
nsDocument::ContentStateChanged(nsIContent* aContent, nsEventStates aStateMask)
|
||||
nsDocument::ContentStateChanged(nsIContent* aContent, EventStates aStateMask)
|
||||
{
|
||||
NS_PRECONDITION(!nsContentUtils::IsSafeToRunScript(),
|
||||
"Someone forgot a scriptblocker");
|
||||
|
@ -4945,7 +4946,7 @@ nsDocument::ContentStateChanged(nsIContent* aContent, nsEventStates aStateMask)
|
|||
}
|
||||
|
||||
void
|
||||
nsDocument::DocumentStatesChanged(nsEventStates aStateMask)
|
||||
nsDocument::DocumentStatesChanged(EventStates aStateMask)
|
||||
{
|
||||
// Invalidate our cached state.
|
||||
mGotDocumentState &= ~aStateMask;
|
||||
|
@ -9251,7 +9252,7 @@ nsDocument::MaybePreLoadImage(nsIURI* uri, const nsAString &aCrossOriginAttr)
|
|||
}
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
nsDocument::GetDocumentState()
|
||||
{
|
||||
if (!mGotDocumentState.HasState(NS_DOCUMENT_STATE_RTL_LOCALE)) {
|
||||
|
@ -9866,23 +9867,6 @@ nsDocument::AddImage(imgIRequest* aImage)
|
|||
return rv;
|
||||
}
|
||||
|
||||
static void
|
||||
NotifyAudioAvailableListener(nsIContent *aContent, void *aUnused)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLMediaElement> domMediaElem(do_QueryInterface(aContent));
|
||||
if (domMediaElem) {
|
||||
HTMLMediaElement* mediaElem = static_cast<HTMLMediaElement*>(aContent);
|
||||
mediaElem->NotifyAudioAvailableListener();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::NotifyAudioAvailableListener()
|
||||
{
|
||||
mHasAudioAvailableListener = true;
|
||||
EnumerateFreezableElements(::NotifyAudioAvailableListener, nullptr);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::RemoveImage(imgIRequest* aImage, uint32_t aFlags)
|
||||
{
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "nsIChannelEventSink.h"
|
||||
#include "imgIRequest.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/dom/DOMImplementation.h"
|
||||
#include "nsIDOMTouchEvent.h"
|
||||
|
@ -842,8 +843,10 @@ public:
|
|||
virtual void SetReadyStateInternal(ReadyState rs) MOZ_OVERRIDE;
|
||||
|
||||
virtual void ContentStateChanged(nsIContent* aContent,
|
||||
nsEventStates aStateMask) MOZ_OVERRIDE;
|
||||
virtual void DocumentStatesChanged(nsEventStates aStateMask) MOZ_OVERRIDE;
|
||||
mozilla::EventStates aStateMask)
|
||||
MOZ_OVERRIDE;
|
||||
virtual void DocumentStatesChanged(
|
||||
mozilla::EventStates aStateMask) MOZ_OVERRIDE;
|
||||
|
||||
virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aOldStyleRule,
|
||||
|
@ -1066,7 +1069,7 @@ public:
|
|||
|
||||
virtual nsISupports* GetCurrentContentSink() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsEventStates GetDocumentState() MOZ_OVERRIDE;
|
||||
virtual mozilla::EventStates GetDocumentState() MOZ_OVERRIDE;
|
||||
|
||||
virtual void RegisterHostObjectUri(const nsACString& aUri) MOZ_OVERRIDE;
|
||||
virtual void UnregisterHostObjectUri(const nsACString& aUri) MOZ_OVERRIDE;
|
||||
|
@ -1107,13 +1110,6 @@ public:
|
|||
|
||||
virtual Element* FindImageMap(const nsAString& aNormalizedMapName) MOZ_OVERRIDE;
|
||||
|
||||
virtual void NotifyAudioAvailableListener() MOZ_OVERRIDE;
|
||||
|
||||
bool HasAudioAvailableListeners() MOZ_OVERRIDE
|
||||
{
|
||||
return mHasAudioAvailableListener;
|
||||
}
|
||||
|
||||
virtual Element* GetFullScreenElement() MOZ_OVERRIDE;
|
||||
virtual void AsyncRequestFullScreen(Element* aElement) MOZ_OVERRIDE;
|
||||
virtual void RestorePreviousFullScreenState() MOZ_OVERRIDE;
|
||||
|
@ -1471,10 +1467,6 @@ public:
|
|||
// Whether we currently require our images to animate
|
||||
bool mAnimatingImages:1;
|
||||
|
||||
// Whether some node in this document has a listener for the
|
||||
// "mozaudioavailable" event.
|
||||
bool mHasAudioAvailableListener:1;
|
||||
|
||||
// Whether we're currently under a FlushPendingNotifications call to
|
||||
// our presshell. This is used to handle flush reentry correctly.
|
||||
bool mInFlush:1;
|
||||
|
@ -1534,8 +1526,8 @@ public:
|
|||
|
||||
nsCOMPtr<nsIContent> mFirstBaseNodeWithHref;
|
||||
|
||||
nsEventStates mDocumentState;
|
||||
nsEventStates mGotDocumentState;
|
||||
mozilla::EventStates mDocumentState;
|
||||
mozilla::EventStates mGotDocumentState;
|
||||
|
||||
nsRefPtr<nsDOMNavigationTiming> mTiming;
|
||||
private:
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
#include "nsXMLElement.h"
|
||||
#include "nsImageLoadingContent.h"
|
||||
#include "imgIRequest.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
nsIContent* aBindingParent,
|
||||
bool aCompileEventHandlers);
|
||||
virtual void UnbindFromTree(bool aDeep, bool aNullParent);
|
||||
virtual nsEventStates IntrinsicState() const;
|
||||
virtual EventStates IntrinsicState() const;
|
||||
|
||||
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor)
|
||||
{
|
||||
|
@ -111,12 +111,12 @@ nsGenConImageContent::UnbindFromTree(bool aDeep, bool aNullParent)
|
|||
nsXMLElement::UnbindFromTree(aDeep, aNullParent);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
nsGenConImageContent::IntrinsicState() const
|
||||
{
|
||||
nsEventStates state = nsXMLElement::IntrinsicState();
|
||||
EventStates state = nsXMLElement::IntrinsicState();
|
||||
|
||||
nsEventStates imageState = nsImageLoadingContent::ImageState();
|
||||
EventStates imageState = nsImageLoadingContent::ImageState();
|
||||
if (imageState.HasAtLeastOneOfStates(NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_USERDISABLED)) {
|
||||
// We should never be in an error state; if the image fails to load, we
|
||||
// just go to the suppressed state.
|
||||
|
|
|
@ -1919,7 +1919,6 @@ GK_ATOM(onended, "onended")
|
|||
GK_ATOM(onratechange, "onratechange")
|
||||
GK_ATOM(ondurationchange, "ondurationchange")
|
||||
GK_ATOM(onvolumechange, "onvolumechange")
|
||||
GK_ATOM(onMozAudioAvailable, "onMozAudioAvailable")
|
||||
GK_ATOM(onaddtrack, "onaddtrack")
|
||||
GK_ATOM(oncuechange, "oncuechange")
|
||||
GK_ATOM(onenter, "onenter")
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "nsImageFrame.h"
|
||||
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsEventStates.h"
|
||||
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
@ -44,6 +43,7 @@
|
|||
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
|
||||
|
@ -859,21 +859,22 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsImageLoadingContent::ForceImageState(bool aForce, nsEventStates::InternalType aState)
|
||||
nsImageLoadingContent::ForceImageState(bool aForce,
|
||||
EventStates::InternalType aState)
|
||||
{
|
||||
mIsImageStateForced = aForce;
|
||||
mForcedImageState = nsEventStates(aState);
|
||||
mForcedImageState = EventStates(aState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
nsImageLoadingContent::ImageState() const
|
||||
{
|
||||
if (mIsImageStateForced) {
|
||||
return mForcedImageState;
|
||||
}
|
||||
|
||||
nsEventStates states;
|
||||
EventStates states;
|
||||
|
||||
if (mBroken) {
|
||||
states |= NS_EVENT_STATE_BROKEN;
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#include "imgINotificationObserver.h"
|
||||
#include "imgIOnloadBlocker.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "nsIRequest.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
|
@ -96,7 +96,7 @@ protected:
|
|||
* be an image (eg an HTML <input> of type other than "image") should just
|
||||
* not call this method when computing their intrinsic state.
|
||||
*/
|
||||
nsEventStates ImageState() const;
|
||||
mozilla::EventStates ImageState() const;
|
||||
|
||||
/**
|
||||
* LoadImage is called by subclasses when the appropriate
|
||||
|
@ -378,7 +378,7 @@ private:
|
|||
* When mIsImageStateForced is true, this holds the ImageState that we'll
|
||||
* return in ImageState().
|
||||
*/
|
||||
nsEventStates mForcedImageState;
|
||||
mozilla::EventStates mForcedImageState;
|
||||
|
||||
int16_t mImageBlockingStatus;
|
||||
bool mLoadingEnabled : 1;
|
||||
|
|
|
@ -495,9 +495,6 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
|
|||
if (elm->MayHavePaintEventListener()) {
|
||||
window->SetHasPaintEventListeners();
|
||||
}
|
||||
if (elm->MayHaveAudioAvailableEventListener()) {
|
||||
window->SetHasAudioAvailableEventListeners();
|
||||
}
|
||||
if (elm->MayHaveTouchEventListener()) {
|
||||
window->SetHasTouchEventListeners();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "nsIDOMHTMLObjectElement.h"
|
||||
#include "nsIDOMHTMLAppletElement.h"
|
||||
#include "nsIExternalProtocolHandler.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsIObjectFrame.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsPluginHost.h"
|
||||
|
@ -81,6 +80,7 @@
|
|||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
|
@ -1201,7 +1201,7 @@ nsObjectLoadingContent::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
|
|||
}
|
||||
|
||||
// <public>
|
||||
nsEventStates
|
||||
EventStates
|
||||
nsObjectLoadingContent::ObjectState() const
|
||||
{
|
||||
switch (mType) {
|
||||
|
@ -1214,7 +1214,7 @@ nsObjectLoadingContent::ObjectState() const
|
|||
// These are OK. If documents start to load successfully, they display
|
||||
// something, and are thus not broken in this sense. The same goes for
|
||||
// plugins.
|
||||
return nsEventStates();
|
||||
return EventStates();
|
||||
case eType_Null:
|
||||
switch (mFallbackType) {
|
||||
case eFallbackSuppressed:
|
||||
|
@ -1904,7 +1904,7 @@ nsObjectLoadingContent::LoadObject(bool aNotify,
|
|||
}
|
||||
|
||||
// Save these for NotifyStateChanged();
|
||||
nsEventStates oldState = ObjectState();
|
||||
EventStates oldState = ObjectState();
|
||||
ObjectType oldType = mType;
|
||||
|
||||
ParameterUpdateFlags stateChange = UpdateObjectParameters();
|
||||
|
@ -2427,7 +2427,7 @@ nsObjectLoadingContent::UnloadObject(bool aResetState)
|
|||
|
||||
void
|
||||
nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
|
||||
nsEventStates aOldState,
|
||||
EventStates aOldState,
|
||||
bool aSync,
|
||||
bool aNotify)
|
||||
{
|
||||
|
@ -2458,12 +2458,12 @@ nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
|
|||
return; // Nothing to do
|
||||
}
|
||||
|
||||
nsEventStates newState = ObjectState();
|
||||
EventStates newState = ObjectState();
|
||||
|
||||
if (newState != aOldState) {
|
||||
// This will trigger frame construction
|
||||
NS_ASSERTION(InActiveDocument(thisContent), "Something is confused");
|
||||
nsEventStates changedBits = aOldState ^ newState;
|
||||
EventStates changedBits = aOldState ^ newState;
|
||||
|
||||
{
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
|
@ -2731,7 +2731,7 @@ DoDelayedStop(nsPluginInstanceOwner* aInstanceOwner,
|
|||
|
||||
void
|
||||
nsObjectLoadingContent::LoadFallback(FallbackType aType, bool aNotify) {
|
||||
nsEventStates oldState = ObjectState();
|
||||
EventStates oldState = ObjectState();
|
||||
ObjectType oldType = mType;
|
||||
|
||||
NS_ASSERTION(!mInstanceOwner && !mFrameLoader && !mChannel,
|
||||
|
|
|
@ -110,7 +110,7 @@ class nsObjectLoadingContent : public nsImageLoadingContent
|
|||
* Object state. This is a bitmask of NS_EVENT_STATEs epresenting the
|
||||
* current state of the object.
|
||||
*/
|
||||
nsEventStates ObjectState() const;
|
||||
mozilla::EventStates ObjectState() const;
|
||||
|
||||
ObjectType Type() const { return mType; }
|
||||
|
||||
|
@ -449,7 +449,8 @@ class nsObjectLoadingContent : public nsImageLoadingContent
|
|||
* the construction may either be sync or async.
|
||||
* @param aNotify if false, only need to update the state of our element.
|
||||
*/
|
||||
void NotifyStateChanged(ObjectType aOldType, nsEventStates aOldState,
|
||||
void NotifyStateChanged(ObjectType aOldType,
|
||||
mozilla::EventStates aOldState,
|
||||
bool aSync, bool aNotify);
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include "mozilla/dom/HTMLMediaElement.h"
|
||||
#include "mozilla/dom/TypedArray.h"
|
||||
|
||||
class nsITimer;
|
||||
|
||||
typedef uint16_t nsMediaNetworkState;
|
||||
typedef uint16_t nsMediaReadyState;
|
||||
|
||||
|
@ -20,7 +18,6 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
|
||||
class HTMLAudioElement MOZ_FINAL : public HTMLMediaElement,
|
||||
public nsITimerCallback,
|
||||
public nsIDOMHTMLAudioElement
|
||||
{
|
||||
public:
|
||||
|
@ -34,12 +31,6 @@ public:
|
|||
using HTMLMediaElement::GetPaused;
|
||||
NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(HTMLMediaElement::)
|
||||
|
||||
// nsIAudioChannelAgentCallback
|
||||
NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
|
||||
|
||||
// NS_DECL_NSITIMERCALLBACK
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
virtual nsresult SetAcceptHeader(nsIHttpChannel* aChannel);
|
||||
|
||||
|
@ -51,33 +42,9 @@ public:
|
|||
Audio(const GlobalObject& aGlobal,
|
||||
const Optional<nsAString>& aSrc, ErrorResult& aRv);
|
||||
|
||||
void MozSetup(uint32_t aChannels, uint32_t aRate, ErrorResult& aRv);
|
||||
|
||||
uint32_t MozWriteAudio(const Float32Array& aData, ErrorResult& aRv)
|
||||
{
|
||||
return MozWriteAudio(aData.Data(), aData.Length(), aRv);
|
||||
}
|
||||
uint32_t MozWriteAudio(const Sequence<float>& aData, ErrorResult& aRv)
|
||||
{
|
||||
return MozWriteAudio(aData.Elements(), aData.Length(), aRv);
|
||||
}
|
||||
uint32_t MozWriteAudio(const float* aData, uint32_t aLength,
|
||||
ErrorResult& aRv);
|
||||
|
||||
uint64_t MozCurrentSampleOffset(ErrorResult& aRv);
|
||||
|
||||
protected:
|
||||
virtual JSObject* WrapNode(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
// Update the audio channel playing state
|
||||
virtual void UpdateAudioChannelPlayingState() MOZ_OVERRIDE;
|
||||
|
||||
// Due to that audio data API doesn't indicate the timing of pause or end,
|
||||
// the timer is used to defer the timing of pause/stop after writing data.
|
||||
nsCOMPtr<nsITimer> mDeferStopPlayTimer;
|
||||
// To indicate mDeferStopPlayTimer is on fire or not.
|
||||
bool mTimerActivated;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -32,7 +32,6 @@ typedef uint16_t nsMediaNetworkState;
|
|||
typedef uint16_t nsMediaReadyState;
|
||||
|
||||
namespace mozilla {
|
||||
class AudioStream;
|
||||
class ErrorResult;
|
||||
class MediaResource;
|
||||
class MediaDecoder;
|
||||
|
@ -197,13 +196,6 @@ public:
|
|||
// suspended the channel.
|
||||
virtual void NotifySuspendedByCache(bool aIsSuspended) MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
// Called when a "MozAudioAvailable" event listener is added. The media
|
||||
// element will then notify its decoder that it needs to make a copy of
|
||||
// the audio data sent to hardware and dispatch it in "mozaudioavailable"
|
||||
// events. This allows us to not perform the copy and thus reduce overhead
|
||||
// in the common case where we don't have a "MozAudioAvailable" listener.
|
||||
void NotifyAudioAvailableListener();
|
||||
|
||||
// Called by the media decoder and the video frame to get the
|
||||
// ImageContainer containing the video data.
|
||||
virtual VideoFrameContainer* GetVideoFrameContainer() MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
@ -213,9 +205,6 @@ public:
|
|||
using nsGenericHTMLElement::DispatchEvent;
|
||||
virtual nsresult DispatchEvent(const nsAString& aName) MOZ_FINAL MOZ_OVERRIDE;
|
||||
virtual nsresult DispatchAsyncEvent(const nsAString& aName) MOZ_FINAL MOZ_OVERRIDE;
|
||||
nsresult DispatchAudioAvailableEvent(float* aFrameBuffer,
|
||||
uint32_t aFrameBufferLength,
|
||||
float aTime);
|
||||
|
||||
// Dispatch events that were raised while in the bfcache
|
||||
nsresult DispatchPendingMediaEvents();
|
||||
|
@ -279,12 +268,6 @@ public:
|
|||
*/
|
||||
void NotifyLoadError();
|
||||
|
||||
/**
|
||||
* Called when data has been written to the underlying audio stream.
|
||||
*/
|
||||
virtual void NotifyAudioAvailable(float* aFrameBuffer, uint32_t aFrameBufferLength,
|
||||
float aTime) MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
|
@ -506,14 +489,6 @@ public:
|
|||
return mAudioCaptured;
|
||||
}
|
||||
|
||||
uint32_t GetMozChannels(ErrorResult& aRv) const;
|
||||
|
||||
uint32_t GetMozSampleRate(ErrorResult& aRv) const;
|
||||
|
||||
uint32_t GetMozFrameBufferLength(ErrorResult& aRv) const;
|
||||
|
||||
void SetMozFrameBufferLength(uint32_t aValue, ErrorResult& aRv);
|
||||
|
||||
JSObject* MozGetMetadata(JSContext* aCx, ErrorResult& aRv);
|
||||
|
||||
double MozFragmentEnd();
|
||||
|
@ -871,7 +846,7 @@ protected:
|
|||
void Seek(double aTime, SeekTarget::Type aSeekType, ErrorResult& aRv);
|
||||
|
||||
// Update the audio channel playing state
|
||||
virtual void UpdateAudioChannelPlayingState();
|
||||
void UpdateAudioChannelPlayingState();
|
||||
|
||||
// Adds to the element's list of pending text tracks each text track
|
||||
// in the element's list of text tracks whose text track mode is not disabled
|
||||
|
@ -963,12 +938,6 @@ protected:
|
|||
// Current audio volume
|
||||
double mVolume;
|
||||
|
||||
// Current number of audio channels.
|
||||
uint32_t mChannels;
|
||||
|
||||
// Current audio sample rate.
|
||||
uint32_t mRate;
|
||||
|
||||
// Helper function to iterate over a hash table
|
||||
// and convert it to a JSObject.
|
||||
static PLDHashOperator BuildObjectFromTags(nsCStringHashKey::KeyType aKey,
|
||||
|
@ -1031,19 +1000,12 @@ protected:
|
|||
// This is the child source element which we're trying to load from.
|
||||
nsCOMPtr<nsIContent> mSourceLoadCandidate;
|
||||
|
||||
// An audio stream for writing audio directly from JS.
|
||||
nsAutoPtr<AudioStream> mAudioStream;
|
||||
|
||||
// Range of time played.
|
||||
nsRefPtr<TimeRanges> mPlayed;
|
||||
|
||||
// Stores the time at the start of the current 'played' range.
|
||||
double mCurrentPlayRangeStart;
|
||||
|
||||
// True if MozAudioAvailable events can be safely dispatched, based on
|
||||
// a media and element same-origin check.
|
||||
bool mAllowAudioData;
|
||||
|
||||
// If true then we have begun downloading the media content.
|
||||
// Set to false when completed, or not yet started.
|
||||
bool mBegun;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "mozilla/dom/HTMLAnchorElementBinding.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -429,7 +430,7 @@ HTMLAnchorElement::ParseAttribute(int32_t aNamespaceID,
|
|||
aResult);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLAnchorElement::IntrinsicState() const
|
||||
{
|
||||
return Link::LinkState() | nsGenericHTMLElement::IntrinsicState();
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
|
||||
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnDNSPrefetchDeferred();
|
||||
virtual void OnDNSPrefetchRequested();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/HTMLAreaElementBinding.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Area)
|
||||
|
@ -245,7 +246,7 @@ HTMLAreaElement::GetHrefURI() const
|
|||
return GetHrefURIForAnchors();
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLAreaElement::IntrinsicState() const
|
||||
{
|
||||
return Link::LinkState() | nsGenericHTMLElement::IntrinsicState();
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
|
||||
virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE;
|
||||
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
// WebIDL
|
||||
|
||||
|
|
|
@ -29,16 +29,14 @@ namespace dom {
|
|||
|
||||
extern bool IsAudioAPIEnabled();
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED4(HTMLAudioElement, HTMLMediaElement,
|
||||
nsIDOMHTMLMediaElement, nsIDOMHTMLAudioElement,
|
||||
nsITimerCallback, nsIAudioChannelAgentCallback)
|
||||
NS_IMPL_ISUPPORTS_INHERITED2(HTMLAudioElement, HTMLMediaElement,
|
||||
nsIDOMHTMLMediaElement, nsIDOMHTMLAudioElement)
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE(HTMLAudioElement)
|
||||
|
||||
|
||||
HTMLAudioElement::HTMLAudioElement(already_AddRefed<nsINodeInfo>& aNodeInfo)
|
||||
: HTMLMediaElement(aNodeInfo),
|
||||
mTimerActivated(false)
|
||||
: HTMLMediaElement(aNodeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -77,128 +75,6 @@ HTMLAudioElement::Audio(const GlobalObject& aGlobal,
|
|||
return audio.forget();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLAudioElement::MozSetup(uint32_t aChannels, uint32_t aRate, ErrorResult& aRv)
|
||||
{
|
||||
if (!IsAudioAPIEnabled()) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
OwnerDoc()->WarnOnceAbout(nsIDocument::eMozAudioData);
|
||||
|
||||
// If there is already a src provided, don't setup another stream
|
||||
if (mDecoder) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
// MozWriteAudio divides by mChannels, so validate now.
|
||||
if (0 == aChannels) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAudioStream) {
|
||||
mAudioStream->Shutdown();
|
||||
}
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
if (mTimerActivated) {
|
||||
mDeferStopPlayTimer->Cancel();
|
||||
mTimerActivated = false;
|
||||
UpdateAudioChannelPlayingState();
|
||||
}
|
||||
#endif
|
||||
|
||||
mAudioStream = new AudioStream();
|
||||
aRv = mAudioStream->Init(aChannels, aRate, mAudioChannelType, AudioStream::HighLatency);
|
||||
if (aRv.Failed()) {
|
||||
mAudioStream->Shutdown();
|
||||
mAudioStream = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
MetadataLoaded(aChannels, aRate, true, false, nullptr);
|
||||
mAudioStream->SetVolume(mMuted ? 0.0 : mVolume);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
HTMLAudioElement::MozWriteAudio(const float* aData, uint32_t aLength,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!IsAudioAPIEnabled()) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!mAudioStream) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make sure that we are going to write the correct amount of data based
|
||||
// on number of channels.
|
||||
if (aLength % mChannels != 0) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
if (!mDeferStopPlayTimer) {
|
||||
mDeferStopPlayTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
}
|
||||
|
||||
if (mTimerActivated) {
|
||||
mDeferStopPlayTimer->Cancel();
|
||||
}
|
||||
// The maximum buffer size of audio backend is 1 second, so waiting for 1
|
||||
// second is sufficient enough.
|
||||
mDeferStopPlayTimer->InitWithCallback(this, 1000, nsITimer::TYPE_ONE_SHOT);
|
||||
mTimerActivated = true;
|
||||
UpdateAudioChannelPlayingState();
|
||||
#endif
|
||||
|
||||
// Don't write more than can be written without blocking.
|
||||
uint32_t writeLen = std::min(mAudioStream->Available(), aLength / mChannels);
|
||||
|
||||
// Convert the samples back to integers as we are using fixed point audio in
|
||||
// the AudioStream.
|
||||
// This could be optimized to avoid allocation and memcpy when
|
||||
// AudioDataValue is 'float', but it's not worth it for this deprecated API.
|
||||
nsAutoArrayPtr<AudioDataValue> audioData(new AudioDataValue[writeLen * mChannels]);
|
||||
ConvertAudioSamples(aData, audioData.get(), writeLen * mChannels);
|
||||
aRv = mAudioStream->Write(audioData.get(), writeLen);
|
||||
if (aRv.Failed()) {
|
||||
return 0;
|
||||
}
|
||||
mAudioStream->Start();
|
||||
|
||||
// Return the actual amount written.
|
||||
return writeLen * mChannels;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
HTMLAudioElement::MozCurrentSampleOffset(ErrorResult& aRv)
|
||||
{
|
||||
if (!IsAudioAPIEnabled()) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!mAudioStream) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t position = mAudioStream->GetPositionInFrames();
|
||||
if (position < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return position * mChannels;
|
||||
}
|
||||
|
||||
nsresult HTMLAudioElement::SetAcceptHeader(nsIHttpChannel* aChannel)
|
||||
{
|
||||
nsAutoCString value(
|
||||
|
@ -224,78 +100,5 @@ HTMLAudioElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
|||
return HTMLAudioElementBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
/* void canPlayChanged (in boolean canPlay); */
|
||||
NS_IMETHODIMP
|
||||
HTMLAudioElement::CanPlayChanged(int32_t canPlay)
|
||||
{
|
||||
NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE);
|
||||
// Only Audio_Data API will initialize the mAudioStream, so we call the parent
|
||||
// one when this audio tag is not used by Audio_Data API.
|
||||
if (!mAudioStream) {
|
||||
return HTMLMediaElement::CanPlayChanged(canPlay);
|
||||
}
|
||||
#ifdef MOZ_B2G
|
||||
if (canPlay != AUDIO_CHANNEL_STATE_MUTED) {
|
||||
SetMutedInternal(mMuted & ~MUTED_BY_AUDIO_CHANNEL);
|
||||
} else {
|
||||
SetMutedInternal(mMuted | MUTED_BY_AUDIO_CHANNEL);
|
||||
}
|
||||
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLAudioElement::WindowVolumeChanged()
|
||||
{
|
||||
return HTMLMediaElement::WindowVolumeChanged();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLAudioElement::Notify(nsITimer* aTimer)
|
||||
{
|
||||
#ifdef MOZ_B2G
|
||||
mTimerActivated = false;
|
||||
UpdateAudioChannelPlayingState();
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLAudioElement::UpdateAudioChannelPlayingState()
|
||||
{
|
||||
if (!mAudioStream) {
|
||||
HTMLMediaElement::UpdateAudioChannelPlayingState();
|
||||
return;
|
||||
}
|
||||
// The HTMLAudioElement is registered to the AudioChannelService only on B2G.
|
||||
#ifdef MOZ_B2G
|
||||
if (mTimerActivated != mPlayingThroughTheAudioChannel) {
|
||||
mPlayingThroughTheAudioChannel = mTimerActivated;
|
||||
|
||||
if (!mAudioChannelAgent) {
|
||||
nsresult rv;
|
||||
mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1", &rv);
|
||||
if (!mAudioChannelAgent) {
|
||||
return;
|
||||
}
|
||||
// Use a weak ref so the audio channel agent can't leak |this|.
|
||||
mAudioChannelAgent->InitWithWeakCallback(OwnerDoc()->GetWindow(),
|
||||
mAudioChannelType, this);
|
||||
|
||||
mAudioChannelAgent->SetVisibilityState(!OwnerDoc()->Hidden());
|
||||
}
|
||||
|
||||
if (mPlayingThroughTheAudioChannel) {
|
||||
int32_t canPlay;
|
||||
mAudioChannelAgent->StartPlaying(&canPlay);
|
||||
CanPlayChanged(canPlay);
|
||||
} else {
|
||||
mAudioChannelAgent->StopPlaying();
|
||||
mAudioChannelAgent = nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "mozilla/ContentEvents.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
@ -526,10 +527,10 @@ HTMLButtonElement::RestoreState(nsPresState* aState)
|
|||
return false;
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLButtonElement::IntrinsicState() const
|
||||
{
|
||||
nsEventStates state = nsGenericHTMLFormElementWithState::IntrinsicState();
|
||||
EventStates state = nsGenericHTMLFormElementWithState::IntrinsicState();
|
||||
|
||||
if (mForm && !mForm->GetValidity() && IsSubmitControl()) {
|
||||
state |= NS_EVENT_STATE_MOZ_SUBMITINVALID;
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
virtual void DoneCreatingElement() MOZ_OVERRIDE;
|
||||
|
||||
// Element
|
||||
nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
/**
|
||||
* Called when an attribute is about to be changed
|
||||
*/
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/HTMLFieldSetElement.h"
|
||||
#include "mozilla/dom/HTMLFieldSetElementBinding.h"
|
||||
#include "nsContentList.h"
|
||||
|
@ -354,10 +355,10 @@ HTMLFieldSetElement::UpdateValidity(bool aElementValidity)
|
|||
return;
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLFieldSetElement::IntrinsicState() const
|
||||
{
|
||||
nsEventStates state = nsGenericHTMLFormElement::IntrinsicState();
|
||||
EventStates state = nsGenericHTMLFormElement::IntrinsicState();
|
||||
|
||||
if (mInvalidElementsCount) {
|
||||
state |= NS_EVENT_STATE_INVALID;
|
||||
|
|
|
@ -94,7 +94,7 @@ public:
|
|||
|
||||
// XPCOM SetCustomValidity is OK for us
|
||||
|
||||
virtual nsEventStates IntrinsicState() const;
|
||||
virtual EventStates IntrinsicState() const;
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
#include "mozilla/ContentEvents.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/HTMLFormControlsCollection.h"
|
||||
#include "mozilla/dom/HTMLFormElementBinding.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsPresContext.h"
|
||||
|
@ -2194,10 +2194,10 @@ HTMLFormElement::SetValueMissingState(const nsAString& aName, bool aValue)
|
|||
mValueMissingRadioGroups.Put(aName, aValue);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLFormElement::IntrinsicState() const
|
||||
{
|
||||
nsEventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
EventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
|
||||
if (mInvalidElementsCount) {
|
||||
state |= NS_EVENT_STATE_INVALID;
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
virtual bool GetValueMissingState(const nsAString& aName) const MOZ_OVERRIDE;
|
||||
virtual void SetValueMissingState(const nsAString& aName, bool aValue) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
// nsIContent
|
||||
virtual bool ParseAttribute(int32_t aNamespaceID,
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include "nsIDOMHTMLMapElement.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
|
||||
#include "nsLayoutUtils.h"
|
||||
|
||||
|
@ -526,7 +527,7 @@ HTMLImageElement::MaybeLoadImage()
|
|||
}
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLImageElement::IntrinsicState() const
|
||||
{
|
||||
return nsGenericHTMLElement::IntrinsicState() |
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
bool aCompileEventHandlers) MOZ_OVERRIDE;
|
||||
virtual void UnbindFromTree(bool aDeep, bool aNullParent) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
|
||||
|
||||
nsresult CopyInnerTo(Element* aDest);
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include "nsITextControlFrame.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsRangeFrame.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIEditor.h"
|
||||
|
@ -62,6 +61,7 @@
|
|||
#include "nsIDOMMutationEvent.h"
|
||||
#include "mozilla/ContentEvents.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/InternalMutationEvent.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/TouchEvents.h"
|
||||
|
@ -5727,13 +5727,13 @@ HTMLInputElement::DoneCreatingElement()
|
|||
mShouldInitChecked = false;
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLInputElement::IntrinsicState() const
|
||||
{
|
||||
// If you add states here, and they're type-dependent, you need to add them
|
||||
// to the type case in AfterSetAttr.
|
||||
|
||||
nsEventStates state = nsGenericHTMLFormElementWithState::IntrinsicState();
|
||||
EventStates state = nsGenericHTMLFormElementWithState::IntrinsicState();
|
||||
if (mType == NS_FORM_INPUT_CHECKBOX || mType == NS_FORM_INPUT_RADIO) {
|
||||
// Check current checked state (:checked)
|
||||
if (mChecked) {
|
||||
|
@ -5805,11 +5805,11 @@ HTMLInputElement::IntrinsicState() const
|
|||
}
|
||||
|
||||
void
|
||||
HTMLInputElement::AddStates(nsEventStates aStates)
|
||||
HTMLInputElement::AddStates(EventStates aStates)
|
||||
{
|
||||
if (mType == NS_FORM_INPUT_TEXT) {
|
||||
nsEventStates focusStates(aStates & (NS_EVENT_STATE_FOCUS |
|
||||
NS_EVENT_STATE_FOCUSRING));
|
||||
EventStates focusStates(aStates & (NS_EVENT_STATE_FOCUS |
|
||||
NS_EVENT_STATE_FOCUSRING));
|
||||
if (!focusStates.IsEmpty()) {
|
||||
HTMLInputElement* ownerNumberControl = GetOwnerNumberControl();
|
||||
if (ownerNumberControl) {
|
||||
|
@ -5821,11 +5821,11 @@ HTMLInputElement::AddStates(nsEventStates aStates)
|
|||
}
|
||||
|
||||
void
|
||||
HTMLInputElement::RemoveStates(nsEventStates aStates)
|
||||
HTMLInputElement::RemoveStates(EventStates aStates)
|
||||
{
|
||||
if (mType == NS_FORM_INPUT_TEXT) {
|
||||
nsEventStates focusStates(aStates & (NS_EVENT_STATE_FOCUS |
|
||||
NS_EVENT_STATE_FOCUSRING));
|
||||
EventStates focusStates(aStates & (NS_EVENT_STATE_FOCUS |
|
||||
NS_EVENT_STATE_FOCUSRING));
|
||||
if (!focusStates.IsEmpty()) {
|
||||
HTMLInputElement* ownerNumberControl = GetOwnerNumberControl();
|
||||
if (ownerNumberControl) {
|
||||
|
|
|
@ -169,12 +169,13 @@ public:
|
|||
|
||||
virtual void DoneCreatingElement() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
// Element
|
||||
private:
|
||||
virtual void AddStates(nsEventStates aStates);
|
||||
virtual void RemoveStates(nsEventStates aStates);
|
||||
virtual void AddStates(EventStates aStates);
|
||||
virtual void RemoveStates(EventStates aStates);
|
||||
|
||||
public:
|
||||
|
||||
// nsITextControlElement
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/dom/HTMLLinkElementBinding.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/dom/HTMLLinkElementBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsGkAtoms.h"
|
||||
|
@ -418,7 +419,7 @@ HTMLLinkElement::GetCORSMode() const
|
|||
return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLLinkElement::IntrinsicState() const
|
||||
{
|
||||
return Link::LinkState() | nsGenericHTMLElement::IntrinsicState();
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
const nsAString& aValue,
|
||||
nsAttrValue& aResult) MOZ_OVERRIDE;
|
||||
virtual void GetLinkTarget(nsAString& aTarget) MOZ_OVERRIDE;
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
void CreateAndDispatchEvent(nsIDocument* aDoc, const nsAString& aEventName);
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIDOMNotifyAudioAvailableEvent.h"
|
||||
#include "nsMediaFragmentURIParser.h"
|
||||
#include "nsURIHashKey.h"
|
||||
#include "nsJSUtils.h"
|
||||
|
@ -624,10 +623,6 @@ void HTMLMediaElement::AbortExistingLoads()
|
|||
mMediaSource->Detach();
|
||||
mMediaSource = nullptr;
|
||||
}
|
||||
if (mAudioStream) {
|
||||
mAudioStream->Shutdown();
|
||||
mAudioStream = nullptr;
|
||||
}
|
||||
|
||||
mLoadingSrc = nullptr;
|
||||
|
||||
|
@ -648,8 +643,6 @@ void HTMLMediaElement::AbortExistingLoads()
|
|||
mDownloadSuspendedByCache = false;
|
||||
mSourcePointer = nullptr;
|
||||
|
||||
mChannels = 0;
|
||||
mRate = 0;
|
||||
mTags = nullptr;
|
||||
|
||||
if (mNetworkState != nsIDOMHTMLMediaElement::NETWORK_EMPTY) {
|
||||
|
@ -864,27 +857,6 @@ void HTMLMediaElement::NotifyLoadError()
|
|||
}
|
||||
}
|
||||
|
||||
void HTMLMediaElement::NotifyAudioAvailable(float* aFrameBuffer,
|
||||
uint32_t aFrameBufferLength,
|
||||
float aTime)
|
||||
{
|
||||
// Auto manage the memory for the frame buffer, so that if we add an early
|
||||
// return-on-error here in future, we won't forget to release the memory.
|
||||
// Otherwise we hand ownership of the memory over to the event created by
|
||||
// DispatchAudioAvailableEvent().
|
||||
nsAutoArrayPtr<float> frameBuffer(aFrameBuffer);
|
||||
// Do same-origin check on element and media before allowing MozAudioAvailable events.
|
||||
if (!mMediaSecurityVerified) {
|
||||
nsCOMPtr<nsIPrincipal> principal = GetCurrentPrincipal();
|
||||
nsresult rv = NodePrincipal()->Subsumes(principal, &mAllowAudioData);
|
||||
if (NS_FAILED(rv)) {
|
||||
mAllowAudioData = false;
|
||||
}
|
||||
}
|
||||
|
||||
DispatchAudioAvailableEvent(frameBuffer.forget(), aFrameBufferLength, aTime);
|
||||
}
|
||||
|
||||
void HTMLMediaElement::LoadFromSourceChildren()
|
||||
{
|
||||
NS_ASSERTION(mDelayingLoadEvent,
|
||||
|
@ -1013,12 +985,6 @@ static bool UseAudioChannelService()
|
|||
return Preferences::GetBool("media.useAudioChannelService");
|
||||
}
|
||||
|
||||
// Not static because it's used in HTMLAudioElement.
|
||||
bool IsAudioAPIEnabled()
|
||||
{
|
||||
return mozilla::Preferences::GetBool("media.audio_data.enabled", false);
|
||||
}
|
||||
|
||||
void HTMLMediaElement::UpdatePreloadAction()
|
||||
{
|
||||
PreloadAction nextAction = PRELOAD_UNDEFINED;
|
||||
|
@ -1673,54 +1639,6 @@ NS_IMETHODIMP HTMLMediaElement::SetVolume(double aVolume)
|
|||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
HTMLMediaElement::GetMozChannels(ErrorResult& aRv) const
|
||||
{
|
||||
if (!IsAudioAPIEnabled()) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!mDecoder && !mAudioStream) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mChannels;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLMediaElement::GetMozChannels(uint32_t* aMozChannels)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aMozChannels = GetMozChannels(rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
HTMLMediaElement::GetMozSampleRate(ErrorResult& aRv) const
|
||||
{
|
||||
if (!IsAudioAPIEnabled()) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!mDecoder && !mAudioStream) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mRate;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLMediaElement::GetMozSampleRate(uint32_t* aMozSampleRate)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aMozSampleRate = GetMozSampleRate(rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
// Helper struct with arguments for our hash iterator.
|
||||
typedef struct MOZ_STACK_CLASS {
|
||||
JSContext* cx;
|
||||
|
@ -1793,56 +1711,6 @@ HTMLMediaElement::MozGetMetadata(JSContext* cx, JS::MutableHandle<JS::Value> aVa
|
|||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
HTMLMediaElement::GetMozFrameBufferLength(ErrorResult& aRv) const
|
||||
{
|
||||
if (!IsAudioAPIEnabled()) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The framebuffer (via MozAudioAvailable events) is only available
|
||||
// when reading vs. writing audio directly.
|
||||
if (!mDecoder) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mDecoder->GetFrameBufferLength();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLMediaElement::GetMozFrameBufferLength(uint32_t* aMozFrameBufferLength)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aMozFrameBufferLength = GetMozFrameBufferLength(rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMediaElement::SetMozFrameBufferLength(uint32_t aMozFrameBufferLength, ErrorResult& aRv)
|
||||
{
|
||||
if (!IsAudioAPIEnabled()) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mDecoder) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
aRv = mDecoder->RequestFrameBufferLength(aMozFrameBufferLength);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLMediaElement::SetMozFrameBufferLength(uint32_t aMozFrameBufferLength)
|
||||
{
|
||||
ErrorResult rv;
|
||||
SetMozFrameBufferLength(aMozFrameBufferLength, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
/* attribute boolean muted; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetMuted(bool* aMuted)
|
||||
{
|
||||
|
@ -1877,8 +1745,6 @@ void HTMLMediaElement::SetVolumeInternal()
|
|||
|
||||
if (mDecoder) {
|
||||
mDecoder->SetVolume(effectiveVolume);
|
||||
} else if (mAudioStream) {
|
||||
mAudioStream->SetVolume(effectiveVolume);
|
||||
} else if (mSrcStream) {
|
||||
GetSrcMediaStream()->SetAudioOutputVolume(this, effectiveVolume);
|
||||
}
|
||||
|
@ -2105,8 +1971,6 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<nsINodeInfo>& aNodeInfo)
|
|||
mReadyState(nsIDOMHTMLMediaElement::HAVE_NOTHING),
|
||||
mLoadWaitStatus(NOT_WAITING),
|
||||
mVolume(1.0),
|
||||
mChannels(0),
|
||||
mRate(0),
|
||||
mPreloadAction(PRELOAD_UNDEFINED),
|
||||
mMediaSize(-1,-1),
|
||||
mLastCurrentTime(0.0),
|
||||
|
@ -2117,7 +1981,6 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<nsINodeInfo>& aNodeInfo)
|
|||
mPreservesPitch(true),
|
||||
mPlayed(new TimeRanges),
|
||||
mCurrentPlayRangeStart(-1.0),
|
||||
mAllowAudioData(false),
|
||||
mBegun(false),
|
||||
mLoadedFirstFrame(false),
|
||||
mAutoplaying(true),
|
||||
|
@ -2189,9 +2052,6 @@ HTMLMediaElement::~HTMLMediaElement()
|
|||
if (mChannel) {
|
||||
mChannel->Cancel(NS_BINDING_ABORTED);
|
||||
}
|
||||
if (mAudioStream) {
|
||||
mAudioStream->Shutdown();
|
||||
}
|
||||
|
||||
WakeLockRelease();
|
||||
}
|
||||
|
@ -2591,13 +2451,6 @@ nsresult HTMLMediaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParen
|
|||
// The preload action depends on the value of the autoplay attribute.
|
||||
// It's value may have changed, so update it.
|
||||
UpdatePreloadAction();
|
||||
|
||||
if (aDocument->HasAudioAvailableListeners()) {
|
||||
// The document already has listeners for the "MozAudioAvailable"
|
||||
// event, so the decoder must be notified so it initiates
|
||||
// "MozAudioAvailable" event dispatch.
|
||||
NotifyAudioAvailableListener();
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -2798,10 +2651,6 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder,
|
|||
}
|
||||
}
|
||||
|
||||
if (OwnerDoc()->HasAudioAvailableListeners()) {
|
||||
NotifyAudioAvailableListener();
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
ShutdownDecoder();
|
||||
}
|
||||
|
@ -3001,8 +2850,6 @@ void HTMLMediaElement::MetadataLoaded(int aChannels,
|
|||
bool aHasVideo,
|
||||
const MetadataTags* aTags)
|
||||
{
|
||||
mChannels = aChannels;
|
||||
mRate = aRate;
|
||||
mHasAudio = aHasAudio;
|
||||
mTags = aTags;
|
||||
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA);
|
||||
|
@ -3401,39 +3248,6 @@ VideoFrameContainer* HTMLMediaElement::GetVideoFrameContainer()
|
|||
return mVideoFrameContainer;
|
||||
}
|
||||
|
||||
nsresult HTMLMediaElement::DispatchAudioAvailableEvent(float* aFrameBuffer,
|
||||
uint32_t aFrameBufferLength,
|
||||
float aTime)
|
||||
{
|
||||
// Auto manage the memory for the frame buffer. If we fail and return
|
||||
// an error, this ensures we free the memory in the frame buffer. Otherwise
|
||||
// we hand off ownership of the frame buffer to the audioavailable event,
|
||||
// which frees the memory when it's destroyed.
|
||||
nsAutoArrayPtr<float> frameBuffer(aFrameBuffer);
|
||||
|
||||
if (!IsAudioAPIEnabled()) {
|
||||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(OwnerDoc());
|
||||
nsRefPtr<HTMLMediaElement> kungFuDeathGrip = this;
|
||||
NS_ENSURE_TRUE(domDoc, NS_ERROR_INVALID_ARG);
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
nsresult rv = domDoc->CreateEvent(NS_LITERAL_STRING("MozAudioAvailableEvent"),
|
||||
getter_AddRefs(event));
|
||||
nsCOMPtr<nsIDOMNotifyAudioAvailableEvent> audioavailableEvent(do_QueryInterface(event));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = audioavailableEvent->InitAudioAvailableEvent(NS_LITERAL_STRING("MozAudioAvailable"),
|
||||
false, false, frameBuffer.forget(), aFrameBufferLength,
|
||||
aTime, mAllowAudioData);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool dummy;
|
||||
return DispatchEvent(event, &dummy);
|
||||
}
|
||||
|
||||
nsresult HTMLMediaElement::DispatchEvent(const nsAString& aName)
|
||||
{
|
||||
LOG_EVENT(PR_LOG_DEBUG, ("%p Dispatching event %s", this,
|
||||
|
@ -3884,14 +3698,6 @@ NS_IMETHODIMP HTMLMediaElement::GetMozFragmentEnd(double* aTime)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void HTMLMediaElement::NotifyAudioAvailableListener()
|
||||
{
|
||||
OwnerDoc()->WarnOnceAbout(nsIDocument::eMozAudioData);
|
||||
if (mDecoder) {
|
||||
mDecoder->NotifyAudioAvailableListener();
|
||||
}
|
||||
}
|
||||
|
||||
static double ClampPlaybackRate(double aPlaybackRate)
|
||||
{
|
||||
if (aPlaybackRate == 0.0) {
|
||||
|
@ -3944,7 +3750,7 @@ HTMLMediaElement::SetPlaybackRate(double aPlaybackRate, ErrorResult& aRv)
|
|||
{
|
||||
// Changing the playback rate of a media that has more than two channels is
|
||||
// not supported.
|
||||
if (aPlaybackRate < 0 || (mChannels > 2 && aPlaybackRate != 1.0)) {
|
||||
if (aPlaybackRate < 0) {
|
||||
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "HTMLMeterElement.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/HTMLMeterElementBinding.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Meter)
|
||||
|
@ -27,10 +28,10 @@ HTMLMeterElement::~HTMLMeterElement()
|
|||
|
||||
NS_IMPL_ELEMENT_CLONE(HTMLMeterElement)
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLMeterElement::IntrinsicState() const
|
||||
{
|
||||
nsEventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
EventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
|
||||
state |= GetOptimumState();
|
||||
|
||||
|
@ -211,7 +212,7 @@ HTMLMeterElement::Optimum() const
|
|||
return std::min(optimum, max);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLMeterElement::GetOptimumState() const
|
||||
{
|
||||
/*
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
HTMLMeterElement(already_AddRefed<nsINodeInfo>& aNodeInfo);
|
||||
virtual ~HTMLMeterElement();
|
||||
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE;
|
||||
|
||||
|
@ -91,7 +91,7 @@ private:
|
|||
*
|
||||
* @return the optimum state of the element.
|
||||
*/
|
||||
nsEventStates GetOptimumState() const;
|
||||
EventStates GetOptimumState() const;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* 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 "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/HTMLObjectElement.h"
|
||||
#include "mozilla/dom/HTMLObjectElementBinding.h"
|
||||
#include "mozilla/dom/ElementInlines.h"
|
||||
|
@ -408,7 +409,7 @@ HTMLObjectElement::StartObjectLoad(bool aNotify)
|
|||
SetIsNetworkCreated(false);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLObjectElement::IntrinsicState() const
|
||||
{
|
||||
return nsGenericHTMLFormElement::IntrinsicState() | ObjectState();
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
nsAttrValue &aResult) MOZ_OVERRIDE;
|
||||
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const MOZ_OVERRIDE;
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom *aAttribute) const MOZ_OVERRIDE;
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual void DestroyContent() MOZ_OVERRIDE;
|
||||
|
||||
// nsObjectLoadingContent
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/HTMLOptGroupElement.h"
|
||||
#include "mozilla/dom/HTMLOptGroupElementBinding.h"
|
||||
#include "mozilla/dom/HTMLSelectElement.h" // SafeOptionListMutation
|
||||
|
@ -11,7 +12,6 @@
|
|||
#include "nsStyleConsts.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
#include "nsEventStates.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(OptGroup)
|
||||
|
||||
|
@ -125,10 +125,10 @@ HTMLOptGroupElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|||
aNotify);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLOptGroupElement::IntrinsicState() const
|
||||
{
|
||||
nsEventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
EventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
|
||||
if (HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)) {
|
||||
state |= NS_EVENT_STATE_DISABLED;
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
// nsIContent
|
||||
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsTextNode.h"
|
||||
|
@ -299,10 +299,10 @@ HTMLOptionElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
|||
UpdateState(false);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLOptionElement::IntrinsicState() const
|
||||
{
|
||||
nsEventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
EventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
if (Selected()) {
|
||||
state |= NS_EVENT_STATE_CHECKED;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
bool aNullParent = true) MOZ_OVERRIDE;
|
||||
|
||||
// nsIContent
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE;
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "mozilla/dom/HTMLSelectElement.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsError.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsFormSubmission.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIComboboxControlFrame.h"
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
#include "mozilla/dom/HTMLOutputElement.h"
|
||||
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/HTMLFormElement.h"
|
||||
#include "mozilla/dom/HTMLOutputElementBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMSettableTokenList.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsFormSubmission.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Output)
|
||||
|
@ -93,10 +93,10 @@ HTMLOutputElement::ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
|
|||
aValue, aResult);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLOutputElement::IntrinsicState() const
|
||||
{
|
||||
nsEventStates states = nsGenericHTMLFormElement::IntrinsicState();
|
||||
EventStates states = nsGenericHTMLFormElement::IntrinsicState();
|
||||
|
||||
// We don't have to call IsCandidateForConstraintValidation()
|
||||
// because <output> can't be barred from constraint validation.
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
|
||||
const nsAString& aValue, nsAttrValue& aResult) MOZ_OVERRIDE;
|
||||
|
||||
nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* 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 "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/HTMLProgressElement.h"
|
||||
#include "mozilla/dom/HTMLProgressElementBinding.h"
|
||||
|
||||
|
@ -30,10 +31,10 @@ HTMLProgressElement::~HTMLProgressElement()
|
|||
NS_IMPL_ELEMENT_CLONE(HTMLProgressElement)
|
||||
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLProgressElement::IntrinsicState() const
|
||||
{
|
||||
nsEventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
EventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
|
||||
if (IsIndeterminate()) {
|
||||
state |= NS_EVENT_STATE_INDETERMINATE;
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
HTMLProgressElement(already_AddRefed<nsINodeInfo>& aNodeInfo);
|
||||
virtual ~HTMLProgressElement();
|
||||
|
||||
nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/HTMLOptGroupElement.h"
|
||||
#include "mozilla/dom/HTMLOptionElement.h"
|
||||
|
@ -16,7 +17,6 @@
|
|||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsContentList.h"
|
||||
#include "nsError.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsFormSubmission.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIComboboxControlFrame.h"
|
||||
|
@ -1511,10 +1511,10 @@ HTMLSelectElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
|||
return nsGenericHTMLFormElementWithState::PostHandleEvent(aVisitor);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLSelectElement::IntrinsicState() const
|
||||
{
|
||||
nsEventStates state = nsGenericHTMLFormElementWithState::IntrinsicState();
|
||||
EventStates state = nsGenericHTMLFormElementWithState::IntrinsicState();
|
||||
|
||||
if (IsCandidateForConstraintValidation()) {
|
||||
if (IsValid()) {
|
||||
|
|
|
@ -284,7 +284,7 @@ public:
|
|||
|
||||
virtual void FieldSetDisabledChanged(bool aNotify) MOZ_OVERRIDE;
|
||||
|
||||
nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* To be called when stuff is added under a child of the select--but *before*
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* 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 "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/HTMLSharedObjectElement.h"
|
||||
#include "mozilla/dom/HTMLEmbedElementBinding.h"
|
||||
#include "mozilla/dom/HTMLAppletElementBinding.h"
|
||||
|
@ -304,7 +305,7 @@ HTMLSharedObjectElement::StartObjectLoad(bool aNotify)
|
|||
SetIsNetworkCreated(false);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLSharedObjectElement::IntrinsicState() const
|
||||
{
|
||||
return nsGenericHTMLElement::IntrinsicState() | ObjectState();
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
nsAttrValue &aResult) MOZ_OVERRIDE;
|
||||
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const MOZ_OVERRIDE;
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom *aAttribute) const MOZ_OVERRIDE;
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual void DestroyContent() MOZ_OVERRIDE;
|
||||
|
||||
// nsObjectLoadingContent
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/HTMLTextAreaElementBinding.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "nsAttrValueInlines.h"
|
||||
#include "nsContentCID.h"
|
||||
|
@ -1098,10 +1099,10 @@ HTMLTextAreaElement::RestoreState(nsPresState* aState)
|
|||
return false;
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
HTMLTextAreaElement::IntrinsicState() const
|
||||
{
|
||||
nsEventStates state = nsGenericHTMLFormElementWithState::IntrinsicState();
|
||||
EventStates state = nsGenericHTMLFormElementWithState::IntrinsicState();
|
||||
|
||||
if (HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
|
||||
state |= NS_EVENT_STATE_REQUIRED;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "nsIDOMNSEditableElement.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsStubMutationObserver.h"
|
||||
#include "nsIConstraintValidation.h"
|
||||
#include "mozilla/dom/HTMLFormElement.h"
|
||||
|
@ -32,6 +31,7 @@ namespace mozilla {
|
|||
|
||||
class EventChainPostVisitor;
|
||||
class EventChainPreVisitor;
|
||||
class EventStates;
|
||||
|
||||
namespace dom {
|
||||
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
|
||||
virtual void FieldSetDisabledChanged(bool aNotify) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
// nsITextControlElemet
|
||||
NS_IMETHOD SetValueChanged(bool aValueChanged) MOZ_OVERRIDE;
|
||||
|
|
|
@ -172,7 +172,6 @@ LOCAL_INCLUDES += [
|
|||
'/content/media/',
|
||||
'/content/xul/content/src',
|
||||
'/dom/base',
|
||||
'/dom/events',
|
||||
'/dom/xbl',
|
||||
'/editor/libeditor/base',
|
||||
'/editor/libeditor/text',
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/Likely.h"
|
||||
|
||||
|
@ -507,10 +508,10 @@ nsGenericHTMLElement::UpdateEditableState(bool aNotify)
|
|||
nsStyledElement::UpdateEditableState(aNotify);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
nsGenericHTMLElement::IntrinsicState() const
|
||||
{
|
||||
nsEventStates state = nsGenericHTMLElementBase::IntrinsicState();
|
||||
EventStates state = nsGenericHTMLElementBase::IntrinsicState();
|
||||
|
||||
if (GetDirectionality() == eDir_RTL) {
|
||||
state |= NS_EVENT_STATE_RTL;
|
||||
|
@ -2300,13 +2301,13 @@ nsGenericHTMLFormElement::IsHTMLFocusable(bool aWithMouse,
|
|||
return false;
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
nsGenericHTMLFormElement::IntrinsicState() const
|
||||
{
|
||||
// If you add attribute-dependent states here, you need to add them them to
|
||||
// AfterSetAttr too. And add them to AfterSetAttr for all subclasses that
|
||||
// implement IntrinsicState() and are affected by that attribute.
|
||||
nsEventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
EventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
|
||||
if (CanBeDisabled()) {
|
||||
// :enabled/:disabled
|
||||
|
|
|
@ -34,6 +34,7 @@ class EventChainPostVisitor;
|
|||
class EventChainPreVisitor;
|
||||
class EventChainVisitor;
|
||||
class EventListenerManager;
|
||||
class EventStates;
|
||||
namespace dom {
|
||||
class HTMLFormElement;
|
||||
class HTMLPropertiesCollection;
|
||||
|
@ -595,7 +596,7 @@ public:
|
|||
|
||||
virtual void UpdateEditableState(bool aNotify) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual mozilla::EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
// Helper for setting our editable flag and notifying
|
||||
void DoSetEditableFlag(bool aEditable, bool aNotify) {
|
||||
|
@ -1321,7 +1322,7 @@ public:
|
|||
virtual void UnbindFromTree(bool aDeep = true,
|
||||
bool aNullParent = true) MOZ_OVERRIDE;
|
||||
virtual IMEState GetDesiredIMEState() MOZ_OVERRIDE;
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual mozilla::EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult PreHandleEvent(
|
||||
mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "nsRadioVisitor.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/dom/HTMLInputElement.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsIConstraintValidation.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
|
|
@ -37,7 +37,6 @@ LOCAL_INCLUDES += [
|
|||
'/content/base/src',
|
||||
'/docshell/base',
|
||||
'/dom/base',
|
||||
'/dom/events',
|
||||
'/layout/style',
|
||||
]
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "nsMappedAttributes.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
|
@ -23,6 +22,7 @@
|
|||
#include "nsIURI.h"
|
||||
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/ElementBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
@ -914,11 +914,12 @@ nsMathMLElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
|||
|
||||
NS_IMPL_ELEMENT_CLONE(nsMathMLElement)
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
nsMathMLElement::IntrinsicState() const
|
||||
{
|
||||
return Link::LinkState() | nsMathMLElementBase::IntrinsicState() |
|
||||
(mIncrementScriptLevel ? NS_EVENT_STATE_INCREMENT_SCRIPT_LEVEL : nsEventStates());
|
||||
(mIncrementScriptLevel ?
|
||||
NS_EVENT_STATE_INCREMENT_SCRIPT_LEVEL : EventStates());
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
virtual nsresult PostHandleEvent(
|
||||
mozilla::EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
|
||||
nsresult Clone(nsINodeInfo*, nsINode**) const MOZ_OVERRIDE;
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual mozilla::EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE;
|
||||
|
||||
// Set during reflow as necessary. Does a style change notification,
|
||||
|
|
|
@ -1,249 +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 "AudioAvailableEventManager.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "nsIRunnable.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
static const nsTArray< nsCOMPtr<nsIRunnable> >::size_type MAX_PENDING_EVENTS = 100;
|
||||
|
||||
class nsAudioAvailableEventRunner : public nsRunnable
|
||||
{
|
||||
private:
|
||||
nsRefPtr<MediaDecoder> mDecoder;
|
||||
nsAutoArrayPtr<float> mFrameBuffer;
|
||||
public:
|
||||
nsAudioAvailableEventRunner(MediaDecoder* aDecoder, float* aFrameBuffer,
|
||||
uint32_t aFrameBufferLength, float aTime) :
|
||||
mDecoder(aDecoder),
|
||||
mFrameBuffer(aFrameBuffer),
|
||||
mFrameBufferLength(aFrameBufferLength),
|
||||
mTime(aTime)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsAudioAvailableEventRunner);
|
||||
}
|
||||
|
||||
~nsAudioAvailableEventRunner() {
|
||||
MOZ_COUNT_DTOR(nsAudioAvailableEventRunner);
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
mDecoder->AudioAvailable(mFrameBuffer.forget(), mFrameBufferLength, mTime);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const uint32_t mFrameBufferLength;
|
||||
|
||||
// Start time of the buffer data (in seconds).
|
||||
const float mTime;
|
||||
};
|
||||
|
||||
|
||||
AudioAvailableEventManager::AudioAvailableEventManager(MediaDecoder* aDecoder) :
|
||||
mDecoder(aDecoder),
|
||||
mSignalBuffer(new float[mDecoder->GetFrameBufferLength()]),
|
||||
mSignalBufferLength(mDecoder->GetFrameBufferLength()),
|
||||
mNewSignalBufferLength(mSignalBufferLength),
|
||||
mSignalBufferPosition(0),
|
||||
mReentrantMonitor("media.audioavailableeventmanager"),
|
||||
mHasListener(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(AudioAvailableEventManager);
|
||||
}
|
||||
|
||||
AudioAvailableEventManager::~AudioAvailableEventManager()
|
||||
{
|
||||
MOZ_COUNT_DTOR(AudioAvailableEventManager);
|
||||
}
|
||||
|
||||
void AudioAvailableEventManager::Init(uint32_t aChannels, uint32_t aRate)
|
||||
{
|
||||
NS_ASSERTION(aChannels != 0 && aRate != 0, "Audio metadata not known.");
|
||||
mSamplesPerSecond = static_cast<float>(aChannels * aRate);
|
||||
}
|
||||
|
||||
void AudioAvailableEventManager::DispatchPendingEvents(uint64_t aCurrentTime)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
if (!mHasListener) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (mPendingEvents.Length() > 0) {
|
||||
nsAudioAvailableEventRunner* e =
|
||||
(nsAudioAvailableEventRunner*)mPendingEvents[0].get();
|
||||
if (e->mTime * USECS_PER_S > aCurrentTime) {
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIRunnable> event = mPendingEvents[0];
|
||||
mPendingEvents.RemoveElementAt(0);
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
void AudioAvailableEventManager::QueueWrittenAudioData(AudioDataValue* aAudioData,
|
||||
uint32_t aAudioDataLength,
|
||||
uint64_t aEndTimeSampleOffset)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
if (!mHasListener) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t currentBufferSize = mNewSignalBufferLength;
|
||||
if (currentBufferSize == 0) {
|
||||
NS_WARNING("Decoder framebuffer length not set.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mSignalBuffer ||
|
||||
(mSignalBufferPosition == 0 && mSignalBufferLength != currentBufferSize)) {
|
||||
if (!mSignalBuffer || (mSignalBufferLength < currentBufferSize)) {
|
||||
// Only resize if buffer is empty or smaller.
|
||||
mSignalBuffer = new float[currentBufferSize];
|
||||
}
|
||||
mSignalBufferLength = currentBufferSize;
|
||||
}
|
||||
AudioDataValue* audioData = aAudioData;
|
||||
uint32_t audioDataLength = aAudioDataLength;
|
||||
uint32_t signalBufferTail = mSignalBufferLength - mSignalBufferPosition;
|
||||
|
||||
// Group audio samples into optimal size for event dispatch, and queue.
|
||||
while (signalBufferTail <= audioDataLength) {
|
||||
float time = 0.0;
|
||||
// Guard against unsigned number overflow during first frame time calculation.
|
||||
if (aEndTimeSampleOffset > mSignalBufferPosition + audioDataLength) {
|
||||
time = (aEndTimeSampleOffset - mSignalBufferPosition - audioDataLength) /
|
||||
mSamplesPerSecond;
|
||||
}
|
||||
|
||||
// Fill the signalBuffer.
|
||||
uint32_t i;
|
||||
float *signalBuffer = mSignalBuffer.get() + mSignalBufferPosition;
|
||||
if (audioData) {
|
||||
for (i = 0; i < signalBufferTail; ++i) {
|
||||
signalBuffer[i] = AudioSampleToFloat(audioData[i]);
|
||||
}
|
||||
} else {
|
||||
memset(signalBuffer, 0, signalBufferTail*sizeof(signalBuffer[0]));
|
||||
}
|
||||
if (audioData) {
|
||||
audioData += signalBufferTail;
|
||||
}
|
||||
|
||||
NS_ASSERTION(audioDataLength >= signalBufferTail,
|
||||
"audioDataLength about to wrap past zero to +infinity!");
|
||||
audioDataLength -= signalBufferTail;
|
||||
|
||||
if (mPendingEvents.Length() > 0) {
|
||||
// Check last event timecode to make sure that all queued events
|
||||
// are in non-descending sequence.
|
||||
nsAudioAvailableEventRunner* lastPendingEvent =
|
||||
(nsAudioAvailableEventRunner*)mPendingEvents[mPendingEvents.Length() - 1].get();
|
||||
if (lastPendingEvent->mTime > time) {
|
||||
// Clear the queue to start a fresh sequence.
|
||||
mPendingEvents.Clear();
|
||||
} else if (mPendingEvents.Length() >= MAX_PENDING_EVENTS) {
|
||||
NS_WARNING("Hit audio event queue max.");
|
||||
mPendingEvents.RemoveElementsAt(0, mPendingEvents.Length() - MAX_PENDING_EVENTS + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Inform the element that we've written audio data.
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
new nsAudioAvailableEventRunner(mDecoder, mSignalBuffer.forget(),
|
||||
mSignalBufferLength, time);
|
||||
mPendingEvents.AppendElement(event);
|
||||
|
||||
// Reset the buffer
|
||||
mSignalBufferLength = currentBufferSize;
|
||||
mSignalBuffer = new float[currentBufferSize];
|
||||
mSignalBufferPosition = 0;
|
||||
signalBufferTail = currentBufferSize;
|
||||
}
|
||||
|
||||
NS_ASSERTION(mSignalBufferPosition + audioDataLength < mSignalBufferLength,
|
||||
"Intermediate signal buffer must fit at least one more item.");
|
||||
|
||||
if (audioDataLength > 0) {
|
||||
// Add data to the signalBuffer.
|
||||
uint32_t i;
|
||||
float *signalBuffer = mSignalBuffer.get() + mSignalBufferPosition;
|
||||
if (audioData) {
|
||||
for (i = 0; i < audioDataLength; ++i) {
|
||||
signalBuffer[i] = AudioSampleToFloat(audioData[i]);
|
||||
}
|
||||
} else {
|
||||
memset(signalBuffer, 0, audioDataLength*sizeof(signalBuffer[0]));
|
||||
}
|
||||
mSignalBufferPosition += audioDataLength;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioAvailableEventManager::Clear()
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
mPendingEvents.Clear();
|
||||
mSignalBufferPosition = 0;
|
||||
}
|
||||
|
||||
void AudioAvailableEventManager::Drain(uint64_t aEndTime)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
if (!mHasListener) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Force all pending events to go now.
|
||||
for (uint32_t i = 0; i < mPendingEvents.Length(); ++i) {
|
||||
nsCOMPtr<nsIRunnable> event = mPendingEvents[i];
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
mPendingEvents.Clear();
|
||||
|
||||
// If there is anything left in the signal buffer, put it in an event and fire.
|
||||
if (0 == mSignalBufferPosition)
|
||||
return;
|
||||
|
||||
// Zero-pad the end of the signal buffer so it's complete.
|
||||
memset(mSignalBuffer.get() + mSignalBufferPosition, 0,
|
||||
(mSignalBufferLength - mSignalBufferPosition) * sizeof(float));
|
||||
|
||||
// Force this last event to go now.
|
||||
float time = (aEndTime / static_cast<float>(USECS_PER_S)) -
|
||||
(mSignalBufferPosition / mSamplesPerSecond);
|
||||
nsCOMPtr<nsIRunnable> lastEvent =
|
||||
new nsAudioAvailableEventRunner(mDecoder, mSignalBuffer.forget(),
|
||||
mSignalBufferLength, time);
|
||||
NS_DispatchToMainThread(lastEvent, NS_DISPATCH_NORMAL);
|
||||
|
||||
mSignalBufferPosition = 0;
|
||||
}
|
||||
|
||||
void AudioAvailableEventManager::SetSignalBufferLength(uint32_t aLength)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
mNewSignalBufferLength = aLength;
|
||||
}
|
||||
|
||||
void AudioAvailableEventManager::NotifyAudioAvailableListener()
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
mHasListener = true;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
@ -1,97 +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/. */
|
||||
|
||||
#ifndef AudioAvailableEventManager_h__
|
||||
#define AudioAvailableEventManager_h__
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsTArray.h"
|
||||
#include "AudioSampleFormat.h"
|
||||
#include "mozilla/ReentrantMonitor.h"
|
||||
|
||||
class nsIRunnable;
|
||||
template <class T> class nsCOMPtr;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class MediaDecoder;
|
||||
|
||||
class AudioAvailableEventManager
|
||||
{
|
||||
public:
|
||||
AudioAvailableEventManager(MediaDecoder* aDecoder);
|
||||
~AudioAvailableEventManager();
|
||||
|
||||
// Initialize the event manager with audio metadata. Called before
|
||||
// audio begins to get queued or events are dispatched.
|
||||
void Init(uint32_t aChannels, uint32_t aRate);
|
||||
|
||||
// Dispatch pending MozAudioAvailable events in the queue. Called
|
||||
// from the state machine thread.
|
||||
void DispatchPendingEvents(uint64_t aCurrentTime);
|
||||
|
||||
// Queues audio sample data and re-packages it into equal sized
|
||||
// framebuffers. Called from the audio thread.
|
||||
void QueueWrittenAudioData(AudioDataValue* aAudioData,
|
||||
uint32_t aAudioDataLength,
|
||||
uint64_t aEndTimeSampleOffset);
|
||||
|
||||
// Clears the queue of any existing events. Called from both the state
|
||||
// machine and audio threads.
|
||||
void Clear();
|
||||
|
||||
// Fires one last event for any extra samples that didn't fit in a whole
|
||||
// framebuffer. This is meant to be called only once when the audio finishes.
|
||||
// Called from the state machine thread.
|
||||
void Drain(uint64_t aTime);
|
||||
|
||||
// Sets the size of the signal buffer.
|
||||
// Called from the main and the state machine thread.
|
||||
void SetSignalBufferLength(uint32_t aLength);
|
||||
|
||||
// Called by the media element to notify the manager that there is a
|
||||
// listener on the "MozAudioAvailable" event, and that we need to dispatch
|
||||
// such events. Called from the main thread.
|
||||
void NotifyAudioAvailableListener();
|
||||
|
||||
private:
|
||||
// The decoder associated with the event manager. The event manager shares
|
||||
// the same lifetime as the decoder (the decoder holds a reference to the
|
||||
// manager).
|
||||
MediaDecoder* mDecoder;
|
||||
|
||||
// The number of samples per second.
|
||||
float mSamplesPerSecond;
|
||||
|
||||
// A buffer for audio data to be dispatched in DOM events.
|
||||
nsAutoArrayPtr<float> mSignalBuffer;
|
||||
|
||||
// The current size of the signal buffer, may change due to DOM calls.
|
||||
uint32_t mSignalBufferLength;
|
||||
|
||||
// The size of the new signal buffer, may change due to DOM calls.
|
||||
uint32_t mNewSignalBufferLength;
|
||||
|
||||
// The position of the first available item in mSignalBuffer
|
||||
uint32_t mSignalBufferPosition;
|
||||
|
||||
// The MozAudioAvailable events to be dispatched. This queue is shared
|
||||
// between the state machine and audio threads.
|
||||
nsTArray< nsCOMPtr<nsIRunnable> > mPendingEvents;
|
||||
|
||||
// ReentrantMonitor for shared access to mPendingEvents queue or
|
||||
// buffer length.
|
||||
ReentrantMonitor mReentrantMonitor;
|
||||
|
||||
// True if something in the owning document has a listener on the
|
||||
// "MozAudioAvailable" event. If not, we don't need to bother copying played
|
||||
// audio data and dispatching the event. Synchronized by mReentrantMonitor.
|
||||
bool mHasListener;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
|
@ -424,7 +424,6 @@ MediaDecoder::MediaDecoder() :
|
|||
mIgnoreProgressData(false),
|
||||
mInfiniteStream(false),
|
||||
mOwner(nullptr),
|
||||
mFrameBufferLength(0),
|
||||
mPinnedForSeek(false),
|
||||
mShuttingDown(false),
|
||||
mPausedForPlaybackRateNull(false),
|
||||
|
@ -555,10 +554,6 @@ nsresult MediaDecoder::InitializeStateMachine(MediaDecoder* aCloneDonor)
|
|||
if (mMinimizePreroll) {
|
||||
mDecoderStateMachine->SetMinimizePrerollUntilPlaybackStarts();
|
||||
}
|
||||
if (mFrameBufferLength > 0) {
|
||||
// The valid mFrameBufferLength value was specified earlier
|
||||
mDecoderStateMachine->SetFrameBufferLength(mFrameBufferLength);
|
||||
}
|
||||
}
|
||||
|
||||
ChangeState(PLAY_STATE_LOADING);
|
||||
|
@ -572,20 +567,6 @@ void MediaDecoder::SetMinimizePrerollUntilPlaybackStarts()
|
|||
mMinimizePreroll = true;
|
||||
}
|
||||
|
||||
nsresult MediaDecoder::RequestFrameBufferLength(uint32_t aLength)
|
||||
{
|
||||
if (aLength < FRAMEBUFFER_LENGTH_MIN || aLength > FRAMEBUFFER_LENGTH_MAX) {
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
mFrameBufferLength = aLength;
|
||||
|
||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||
if (mDecoderStateMachine) {
|
||||
mDecoderStateMachine->SetFrameBufferLength(aLength);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult MediaDecoder::ScheduleStateMachineThread()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -668,21 +649,6 @@ already_AddRefed<nsIPrincipal> MediaDecoder::GetCurrentPrincipal()
|
|||
return mResource ? mResource->GetCurrentPrincipal() : nullptr;
|
||||
}
|
||||
|
||||
void MediaDecoder::AudioAvailable(float* aFrameBuffer,
|
||||
uint32_t aFrameBufferLength,
|
||||
float aTime)
|
||||
{
|
||||
// Auto manage the frame buffer's memory. If we return due to an error
|
||||
// here, this ensures we free the memory. Otherwise, we pass off ownership
|
||||
// to HTMLMediaElement::NotifyAudioAvailable().
|
||||
nsAutoArrayPtr<float> frameBuffer(aFrameBuffer);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (mShuttingDown || !mOwner) {
|
||||
return;
|
||||
}
|
||||
mOwner->NotifyAudioAvailable(frameBuffer.forget(), aFrameBufferLength, aTime);
|
||||
}
|
||||
|
||||
void MediaDecoder::QueueMetadata(int64_t aPublishTime,
|
||||
int aChannels,
|
||||
int aRate,
|
||||
|
@ -1435,15 +1401,6 @@ bool MediaDecoder::OnStateMachineThread() const
|
|||
return mDecoderStateMachine->OnStateMachineThread();
|
||||
}
|
||||
|
||||
void MediaDecoder::NotifyAudioAvailableListener()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (mDecoderStateMachine) {
|
||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||
mDecoderStateMachine->NotifyAudioAvailableListener();
|
||||
}
|
||||
}
|
||||
|
||||
void MediaDecoder::SetPlaybackRate(double aPlaybackRate)
|
||||
{
|
||||
if (aPlaybackRate == 0) {
|
||||
|
|
|
@ -210,16 +210,6 @@ class VideoFrameContainer;
|
|||
class MediaDecoderStateMachine;
|
||||
class MediaDecoderOwner;
|
||||
|
||||
// The size to use for audio data frames in MozAudioAvailable events.
|
||||
// This value is per channel, and is chosen to give ~43 fps of events,
|
||||
// for example, 44100 with 2 channels, 2*1024 = 2048.
|
||||
static const uint32_t FRAMEBUFFER_LENGTH_PER_CHANNEL = 1024;
|
||||
|
||||
// The total size of the framebuffer used for MozAudioAvailable events
|
||||
// has to be within the following range.
|
||||
static const uint32_t FRAMEBUFFER_LENGTH_MIN = 512;
|
||||
static const uint32_t FRAMEBUFFER_LENGTH_MAX = 16384;
|
||||
|
||||
// GetCurrentTime is defined in winbase.h as zero argument macro forwarding to
|
||||
// GetTickCount() and conflicts with MediaDecoder::GetCurrentTime implementation.
|
||||
#ifdef GetCurrentTime
|
||||
|
@ -659,12 +649,6 @@ public:
|
|||
// Returns a weak reference to the media decoder owner.
|
||||
MediaDecoderOwner* GetMediaOwner() const;
|
||||
|
||||
// Returns the current size of the framebuffer used in
|
||||
// MozAudioAvailable events.
|
||||
uint32_t GetFrameBufferLength() { return mFrameBufferLength; }
|
||||
|
||||
void AudioAvailable(float* aFrameBuffer, uint32_t aFrameBufferLength, float aTime);
|
||||
|
||||
// Called by the state machine to notify the decoder that the duration
|
||||
// has changed.
|
||||
void DurationChanged();
|
||||
|
@ -695,10 +679,6 @@ public:
|
|||
}
|
||||
layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE;
|
||||
|
||||
// Sets the length of the framebuffer used in MozAudioAvailable events.
|
||||
// The new size must be between 512 and 16384.
|
||||
virtual nsresult RequestFrameBufferLength(uint32_t aLength);
|
||||
|
||||
// Return the current state. Can be called on any thread. If called from
|
||||
// a non-main thread, the decoder monitor must be held.
|
||||
PlayState GetState() {
|
||||
|
@ -841,11 +821,6 @@ public:
|
|||
// Drop reference to state machine. Only called during shutdown dance.
|
||||
virtual void ReleaseStateMachine();
|
||||
|
||||
// Called when a "MozAudioAvailable" event listener is added. This enables
|
||||
// the decoder to only dispatch "MozAudioAvailable" events when a
|
||||
// handler exists, reducing overhead. Called on the main thread.
|
||||
virtual void NotifyAudioAvailableListener();
|
||||
|
||||
// Notifies the element that decoding has failed.
|
||||
virtual void DecodeError();
|
||||
|
||||
|
@ -1211,9 +1186,6 @@ protected:
|
|||
// time of the last decoded video frame).
|
||||
MediaChannelStatistics mPlaybackStatistics;
|
||||
|
||||
// The framebuffer size to use for audioavailable events.
|
||||
uint32_t mFrameBufferLength;
|
||||
|
||||
// True when our media stream has been pinned. We pin the stream
|
||||
// while seeking.
|
||||
bool mPinnedForSeek;
|
||||
|
|
|
@ -46,12 +46,6 @@ public:
|
|||
// Return true if decoding should be paused
|
||||
virtual bool GetPaused() = 0;
|
||||
|
||||
/**
|
||||
* Called when data has been written to the underlying audio stream.
|
||||
*/
|
||||
virtual void NotifyAudioAvailable(float* aFrameBuffer, uint32_t aFrameBufferLength,
|
||||
float aTime) = 0;
|
||||
|
||||
// Called by the video decoder object, on the main thread,
|
||||
// when it has read the metadata containing video dimensions,
|
||||
// etc.
|
||||
|
|
|
@ -195,7 +195,6 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
|
|||
mMinimizePreroll(false),
|
||||
mDecodeThreadWaiting(false),
|
||||
mRealTime(aRealTime),
|
||||
mEventManager(aDecoder),
|
||||
mLastFrameStatus(MediaDecoderOwner::NEXT_FRAME_UNINITIALIZED)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MediaDecoderStateMachine);
|
||||
|
@ -943,8 +942,6 @@ void MediaDecoderStateMachine::AudioLoop()
|
|||
ReentrantMonitorAutoExit exit(mDecoder->GetReentrantMonitor());
|
||||
mAudioStream->Drain();
|
||||
}
|
||||
// Fire one last event for any extra frames that didn't fill a framebuffer.
|
||||
mEventManager.Drain(mAudioEndTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -955,7 +952,6 @@ void MediaDecoderStateMachine::AudioLoop()
|
|||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mAudioStream->Shutdown();
|
||||
mAudioStream = nullptr;
|
||||
mEventManager.Clear();
|
||||
if (!mAudioCaptured) {
|
||||
mAudioCompleted = true;
|
||||
UpdateReadyState();
|
||||
|
@ -977,9 +973,6 @@ uint32_t MediaDecoderStateMachine::PlaySilence(uint32_t aFrames,
|
|||
uint32_t maxFrames = SILENCE_BYTES_CHUNK / aChannels / sizeof(AudioDataValue);
|
||||
uint32_t frames = std::min(aFrames, maxFrames);
|
||||
WriteSilence(mAudioStream, frames);
|
||||
// Dispatch events to the DOM for the audio just written.
|
||||
mEventManager.QueueWrittenAudioData(nullptr, frames * aChannels,
|
||||
(aFrameOffset + frames) * aChannels);
|
||||
return frames;
|
||||
}
|
||||
|
||||
|
@ -1012,10 +1005,6 @@ uint32_t MediaDecoderStateMachine::PlayFromAudioQueue(uint64_t aFrameOffset,
|
|||
offset = audio->mOffset;
|
||||
frames = audio->mFrames;
|
||||
|
||||
// Dispatch events to the DOM for the audio just written.
|
||||
mEventManager.QueueWrittenAudioData(audio->mAudioData.get(),
|
||||
audio->mFrames * aChannels,
|
||||
(aFrameOffset + frames) * aChannels);
|
||||
if (offset != -1) {
|
||||
mDecoder->UpdatePlaybackOffset(offset);
|
||||
}
|
||||
|
@ -1146,9 +1135,6 @@ void MediaDecoderStateMachine::UpdatePlaybackPosition(int64_t aTime)
|
|||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
// Notify DOM of any queued up audioavailable events
|
||||
mEventManager.DispatchPendingEvents(GetMediaTime());
|
||||
|
||||
mMetadataManager.DispatchMetadataIfNeeded(mDecoder, aTime);
|
||||
|
||||
if (fragmentEnded) {
|
||||
|
@ -1780,14 +1766,6 @@ bool MediaDecoderStateMachine::HasLowUndecodedData(double aUsecs) const
|
|||
return stream->GetCachedDataEnd(currentPos) < requiredPos;
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::SetFrameBufferLength(uint32_t aLength)
|
||||
{
|
||||
NS_ASSERTION(aLength >= 512 && aLength <= 16384,
|
||||
"The length must be between 512 and 16384");
|
||||
AssertCurrentThreadInMonitor();
|
||||
mEventManager.SetSignalBufferLength(aLength);
|
||||
}
|
||||
|
||||
void
|
||||
MediaDecoderStateMachine::DecodeError()
|
||||
{
|
||||
|
@ -1891,19 +1869,7 @@ nsresult MediaDecoderStateMachine::DecodeMetadata()
|
|||
mLowAudioThresholdUsecs /= NO_VIDEO_AMPLE_AUDIO_DIVISOR;
|
||||
}
|
||||
|
||||
// Inform the element that we've loaded the metadata and the first frame,
|
||||
// setting the default framebuffer size for audioavailable events. Also,
|
||||
// if there is audio, let the MozAudioAvailable event manager know about
|
||||
// the metadata.
|
||||
if (HasAudio()) {
|
||||
mEventManager.Init(mInfo.mAudio.mChannels, mInfo.mAudio.mRate);
|
||||
// Set the buffer length at the decoder level to be able, to be able
|
||||
// to retrive the value via media element method. The RequestFrameBufferLength
|
||||
// will call the MediaDecoderStateMachine::SetFrameBufferLength().
|
||||
uint32_t frameBufferLength = mInfo.mAudio.mChannels * FRAMEBUFFER_LENGTH_PER_CHANNEL;
|
||||
mDecoder->RequestFrameBufferLength(frameBufferLength);
|
||||
}
|
||||
|
||||
// Inform the element that we've loaded the metadata and the first frame.
|
||||
nsCOMPtr<nsIRunnable> metadataLoadedEvent =
|
||||
new AudioMetadataEventRunner(mDecoder,
|
||||
mInfo.mAudio.mChannels,
|
||||
|
@ -2791,12 +2757,6 @@ nsIEventTarget* MediaDecoderStateMachine::GetStateMachineThread()
|
|||
return mStateMachineThreadPool->GetEventTarget();
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::NotifyAudioAvailableListener()
|
||||
{
|
||||
AssertCurrentThreadInMonitor();
|
||||
mEventManager.NotifyAudioAvailableListener();
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::SetPlaybackRate(double aPlaybackRate)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||
|
|
|
@ -79,7 +79,6 @@ hardware (via AudioStream).
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "AudioAvailableEventManager.h"
|
||||
#include "mozilla/ReentrantMonitor.h"
|
||||
#include "MediaDecoderReader.h"
|
||||
#include "MediaDecoderOwner.h"
|
||||
|
@ -295,10 +294,6 @@ public:
|
|||
return mMediaSeekable;
|
||||
}
|
||||
|
||||
// Sets the current frame buffer length for the MozAudioAvailable event.
|
||||
// Accessed on the main and state machine threads.
|
||||
void SetFrameBufferLength(uint32_t aLength);
|
||||
|
||||
// Returns the shared state machine thread.
|
||||
nsIEventTarget* GetStateMachineThread();
|
||||
|
||||
|
@ -334,10 +329,6 @@ public:
|
|||
void SetSyncPointForMediaStream();
|
||||
int64_t GetCurrentTimeViaMediaStreamSync();
|
||||
|
||||
// Called when a "MozAudioAvailable" event listener is added to the media
|
||||
// element. Called on the main thread.
|
||||
void NotifyAudioAvailableListener();
|
||||
|
||||
// Copy queued audio/video data in the reader to any output MediaStreams that
|
||||
// need it.
|
||||
void SendStreamData();
|
||||
|
@ -510,8 +501,7 @@ private:
|
|||
uint64_t aFrameOffset);
|
||||
|
||||
// Pops an audio chunk from the front of the audio queue, and pushes its
|
||||
// audio data to the audio hardware. MozAudioAvailable data is also queued
|
||||
// here. Called on the audio thread.
|
||||
// audio data to the audio hardware.
|
||||
uint32_t PlayFromAudioQueue(uint64_t aFrameOffset, uint32_t aChannels);
|
||||
|
||||
// Stops the audio thread. The decoder monitor must be held with exactly
|
||||
|
@ -940,11 +930,6 @@ private:
|
|||
// True is we are decoding a realtime stream, like a camera stream
|
||||
bool mRealTime;
|
||||
|
||||
// Manager for queuing and dispatching MozAudioAvailable events. The
|
||||
// event manager is accessed from the state machine and audio threads,
|
||||
// and takes care of synchronizing access to its internal queue.
|
||||
AudioAvailableEventManager mEventManager;
|
||||
|
||||
// Stores presentation info required for playback. The decoder monitor
|
||||
// must be held when accessing this.
|
||||
MediaInfo mInfo;
|
||||
|
|
|
@ -51,14 +51,14 @@ namespace mozilla {
|
|||
TimedMetadata* metadata = mMetadataQueue.getFirst();
|
||||
while (metadata && aCurrentTime >= static_cast<double>(metadata->mPublishTime) / USECS_PER_S) {
|
||||
nsCOMPtr<nsIRunnable> metadataUpdatedEvent =
|
||||
new mozilla::AudioMetadataEventRunner(aDecoder,
|
||||
metadata->mChannels,
|
||||
metadata->mRate,
|
||||
metadata->mHasAudio,
|
||||
metadata->mHasVideo,
|
||||
metadata->mTags.forget());
|
||||
new AudioMetadataEventRunner(aDecoder,
|
||||
metadata->mChannels,
|
||||
metadata->mRate,
|
||||
metadata->mHasAudio,
|
||||
metadata->mHasVideo,
|
||||
metadata->mTags.forget());
|
||||
NS_DispatchToMainThread(metadataUpdatedEvent, NS_DISPATCH_NORMAL);
|
||||
mMetadataQueue.popFirst();
|
||||
delete mMetadataQueue.popFirst();
|
||||
metadata = mMetadataQueue.getFirst();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ TEST_DIRS += [
|
|||
|
||||
EXPORTS += [
|
||||
'AbstractMediaDecoder.h',
|
||||
'AudioAvailableEventManager.h',
|
||||
'AudioChannelFormat.h',
|
||||
'AudioCompactor.h',
|
||||
'AudioEventTimeline.h',
|
||||
|
@ -111,7 +110,6 @@ EXPORTS.mozilla.dom += [
|
|||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'AudioAvailableEventManager.cpp',
|
||||
'AudioChannelFormat.cpp',
|
||||
'AudioCompactor.cpp',
|
||||
'AudioNodeEngine.cpp',
|
||||
|
|
Двоичные данные
content/media/test/file_a4_tone.ogg
Двоичные данные
content/media/test/file_a4_tone.ogg
Двоичный файл не отображается.
|
@ -1 +0,0 @@
|
|||
Cache-Control: no-store
|
|
@ -1,16 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function audioAvailable(e) {
|
||||
document.getElementById("wasAudioAvailableCalled").checked = true;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<audio id="a1" src="sound.ogg" controls></audio>
|
||||
<script>
|
||||
document.getElementById("a1").addEventListener("MozAudioAvailable", audioAvailable, false);
|
||||
</script>
|
||||
<input id="wasAudioAvailableCalled" type="checkbox" readonly />
|
||||
</body>
|
||||
</html>
|
|
@ -142,10 +142,7 @@ support-files =
|
|||
dirac.ogg^headers^
|
||||
dynamic_redirect.sjs
|
||||
dynamic_resource.sjs
|
||||
file_a4_tone.ogg
|
||||
file_a4_tone.ogg^headers^
|
||||
file_access_controls.html
|
||||
file_audio_event_adopt_iframe.html
|
||||
fragment_noplay.js
|
||||
fragment_play.js
|
||||
gizmo.mp4
|
||||
|
@ -295,12 +292,10 @@ support-files =
|
|||
wavedata_u8.wav
|
||||
wavedata_u8.wav^headers^
|
||||
|
||||
[test_a4_tone.html]
|
||||
[test_access_control.html]
|
||||
[test_aspectratio_mp4.html]
|
||||
[test_audio1.html]
|
||||
[test_audio2.html]
|
||||
[test_audio_event_adopt.html]
|
||||
[test_autoplay.html]
|
||||
[test_bug448534.html]
|
||||
skip-if = buildapp == 'b2g' # b2g(Timed out, bug 894922? Bug 902677 is for the timing out of a lot of media tests) b2g-debug(Timed out, bug 894922? Bug 902677 is for the timing out of a lot of media tests) b2g-desktop(Timed out, bug 894922? Bug 902677 is for the timing out of a lot of media tests)
|
||||
|
@ -311,7 +306,6 @@ skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) # b2g-debug(timed
|
|||
skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug))
|
||||
[test_bug654550.html]
|
||||
skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) # b2g-debug(timed out) b2g-desktop(timed out)
|
||||
[test_bug686137.html]
|
||||
[test_bug686942.html]
|
||||
skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) # b2g-debug(timed out) b2g-desktop(timed out)
|
||||
# [test_bug726904.html] # disabled - See bug 754860
|
||||
|
@ -348,8 +342,6 @@ skip-if = buildapp == 'b2g' # b2g(6 failures) b2g-debug(6 failures) b2g-desktop(
|
|||
[test_error_on_404.html]
|
||||
skip-if = buildapp == 'b2g' && (toolkit != 'gonk' || debug)) # b2g-debug(timed out) b2g-desktop(timed out)
|
||||
[test_fastSeek.html]
|
||||
[test_framebuffer.html]
|
||||
skip-if = buildapp == 'b2g' # b2g(timed out) b2g-debug(timed out) b2g-desktop(timed out)
|
||||
[test_info_leak.html]
|
||||
skip-if = buildapp == 'b2g' # b2g(2 failures) b2g-debug(2 failures) b2g-desktop(2 failures)
|
||||
[test_invalid_reject.html]
|
||||
|
@ -399,7 +391,6 @@ skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug))
|
|||
[test_standalone.html]
|
||||
[test_volume.html]
|
||||
[test_video_to_canvas.html]
|
||||
[test_audiowrite.html]
|
||||
[test_mediarecorder_creation.html]
|
||||
[test_mediarecorder_creation_fail.html]
|
||||
[test_mediarecorder_avoid_recursion.html]
|
||||
|
@ -504,7 +495,3 @@ skip-if = wave
|
|||
run-if = wave
|
||||
[test_fragment_play.html]
|
||||
run-if = wave
|
||||
[test_wave_data_s16.html]
|
||||
run-if = wave
|
||||
[test_wave_data_u8.html]
|
||||
run-if = wave
|
||||
|
|
|
@ -1,263 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!-- 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/. -->
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=490705
|
||||
-->
|
||||
|
||||
<head>
|
||||
<title>Media test: simple audioAvalailable event checks</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=490705">Mozilla Bug 490705</a>
|
||||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/**
|
||||
* FFT is a class for calculating the Discrete Fourier Transform of a signal
|
||||
* with the Fast Fourier Transform algorithm.
|
||||
*
|
||||
* Source: github.com/corbanbrook/dsp.js; License: MIT; Copyright: Corban Brook
|
||||
*
|
||||
* @param {Number} bufferSize The size of the sample buffer to be computed. Must be power of 2
|
||||
* @param {Number} sampleRate The sampleRate of the buffer (eg. 44100)
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
FFT = function(bufferSize, sampleRate) {
|
||||
this.bufferSize = bufferSize;
|
||||
this.sampleRate = sampleRate;
|
||||
this.spectrum = new Float32Array(bufferSize/2);
|
||||
this.real = new Float32Array(bufferSize);
|
||||
this.imag = new Float32Array(bufferSize);
|
||||
|
||||
this.reverseTable = new Uint32Array(bufferSize);
|
||||
|
||||
var limit = 1;
|
||||
var bit = bufferSize >> 1;
|
||||
|
||||
while ( limit < bufferSize ) {
|
||||
for ( var i = 0; i < limit; i++ ) {
|
||||
this.reverseTable[i + limit] = this.reverseTable[i] + bit;
|
||||
}
|
||||
|
||||
limit = limit << 1;
|
||||
bit = bit >> 1;
|
||||
}
|
||||
|
||||
this.sinTable = new Float32Array(bufferSize);
|
||||
this.cosTable = new Float32Array(bufferSize);
|
||||
|
||||
for ( var i = 0; i < bufferSize; i++ ) {
|
||||
this.sinTable[i] = Math.sin(-Math.PI/i);
|
||||
this.cosTable[i] = Math.cos(-Math.PI/i);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Performs a forward tranform on the sample buffer.
|
||||
* Converts a time domain signal to frequency domain spectra.
|
||||
*
|
||||
* @param {Array} buffer The sample buffer. Buffer Length must be power of 2
|
||||
*
|
||||
* @returns The frequency spectrum array
|
||||
*/
|
||||
FFT.prototype.forward = function(buffer) {
|
||||
// Locally scope variables for speed up
|
||||
var bufferSize = this.bufferSize,
|
||||
cosTable = this.cosTable,
|
||||
sinTable = this.sinTable,
|
||||
reverseTable = this.reverseTable,
|
||||
real = this.real,
|
||||
imag = this.imag,
|
||||
spectrum = this.spectrum;
|
||||
|
||||
var k = Math.floor(Math.log(bufferSize) / Math.LN2);
|
||||
if ( Math.pow(2, k) !== bufferSize ) {
|
||||
throw "Invalid buffer size, must be a power of 2.";
|
||||
}
|
||||
if ( bufferSize !== buffer.length ) {
|
||||
throw "Supplied buffer is not the same size as defined FFT. FFT Size: " + bufferSize + " Buffer Size: " + buffer.length;
|
||||
}
|
||||
|
||||
for ( var i = 0; i < bufferSize; i++ ) {
|
||||
real[i] = buffer[reverseTable[i]];
|
||||
imag[i] = 0;
|
||||
}
|
||||
|
||||
var halfSize = 1,
|
||||
phaseShiftStepReal,
|
||||
phaseShiftStepImag,
|
||||
currentPhaseShiftReal,
|
||||
currentPhaseShiftImag,
|
||||
off,
|
||||
tr,
|
||||
ti,
|
||||
tmpReal,
|
||||
i;
|
||||
|
||||
while ( halfSize < bufferSize ) {
|
||||
phaseShiftStepReal = cosTable[halfSize];
|
||||
phaseShiftStepImag = sinTable[halfSize];
|
||||
currentPhaseShiftReal = 1;
|
||||
currentPhaseShiftImag = 0;
|
||||
|
||||
for ( var fftStep = 0; fftStep < halfSize; fftStep++ ) {
|
||||
i = fftStep;
|
||||
|
||||
while ( i < bufferSize ) {
|
||||
off = i + halfSize;
|
||||
tr = (currentPhaseShiftReal * real[off]) - (currentPhaseShiftImag * imag[off]);
|
||||
ti = (currentPhaseShiftReal * imag[off]) + (currentPhaseShiftImag * real[off]);
|
||||
|
||||
real[off] = real[i] - tr;
|
||||
imag[off] = imag[i] - ti;
|
||||
real[i] += tr;
|
||||
imag[i] += ti;
|
||||
|
||||
i += halfSize << 1;
|
||||
}
|
||||
|
||||
tmpReal = currentPhaseShiftReal;
|
||||
currentPhaseShiftReal = (tmpReal * phaseShiftStepReal) - (currentPhaseShiftImag * phaseShiftStepImag);
|
||||
currentPhaseShiftImag = (tmpReal * phaseShiftStepImag) + (currentPhaseShiftImag * phaseShiftStepReal);
|
||||
}
|
||||
|
||||
halfSize = halfSize << 1;
|
||||
}
|
||||
|
||||
i = bufferSize/2;
|
||||
while(i--) {
|
||||
spectrum[i] = 2 * Math.sqrt(real[i] * real[i] + imag[i] * imag[i]) / bufferSize;
|
||||
}
|
||||
|
||||
return spectrum;
|
||||
};
|
||||
/* end of FFT */
|
||||
|
||||
|
||||
var testFile = "file_a4_tone.ogg";
|
||||
var testFileDuration = 3.0;
|
||||
var testFileChannelCount = 1;
|
||||
var testFileSampleRate = 44100;
|
||||
var testFileFrameBufferLength = 1024;
|
||||
var signal = [{start:1.1, end: 1.9, fftBin: 10 } ];
|
||||
var noSignal = [{start:0.1, end: 0.9 }, {start:2.1, end: 2.9 } ];
|
||||
|
||||
var undef;
|
||||
var fft, fftBufferSize;
|
||||
var currentSampleOffset = 0;
|
||||
var spectrumMaxs = [];
|
||||
var isTimePropertyValid = true;
|
||||
|
||||
function audioAvailable(event) {
|
||||
var buffer = event.frameBuffer;
|
||||
|
||||
if(fft === undef) {
|
||||
fftBufferSize = buffer.length;
|
||||
fft = new FFT(fftBufferSize, testFileSampleRate);
|
||||
}
|
||||
|
||||
fft.forward(buffer);
|
||||
|
||||
var spectrum = fft.spectrum;
|
||||
// Finding pick frequency
|
||||
var maxIndex = 0, maxValue = spectrum[0];
|
||||
for(var i=0;i<spectrum.length;i++) {
|
||||
if(maxValue < spectrum[i]) {
|
||||
maxValue = spectrum[maxIndex = i];
|
||||
}
|
||||
}
|
||||
|
||||
spectrumMaxs.push({ value: maxValue, index: maxIndex, time: (currentSampleOffset / testFileSampleRate) });
|
||||
|
||||
if( (typeof event.time !== "number") ||
|
||||
(Math.abs(event.time - currentSampleOffset / testFileSampleRate) >= 0.001) ) {
|
||||
isTimePropertyValid = false;
|
||||
}
|
||||
|
||||
currentSampleOffset += buffer.length;
|
||||
}
|
||||
|
||||
var loadedMetadataCalled = false;
|
||||
function loadedMetadata() {
|
||||
loadedMetadataCalled = true;
|
||||
var a1 = document.getElementById('a1');
|
||||
is(a1.mozChannels, testFileChannelCount, "mozChannels should be " + testFileChannelCount + ".");
|
||||
is(a1.mozSampleRate, testFileSampleRate, "mozSampleRate should be " + testFileSampleRate + ".");
|
||||
is(a1.mozFrameBufferLength, testFileFrameBufferLength, "mozFrameBufferLength should be " + testFileFrameBufferLength + ".");
|
||||
}
|
||||
|
||||
function checkResults() {
|
||||
ok(loadedMetadataCalled, "loadedmetadata event not dispatched.");
|
||||
ok(isTimePropertyValid, "The audioAvailable event's time attribute was invalid.");
|
||||
|
||||
var expectedOffset = Math.ceil(testFileDuration * testFileSampleRate);
|
||||
if(expectedOffset % fftBufferSize !== 0) { expectedOffset += (fftBufferSize - (expectedOffset % fftBufferSize)); }
|
||||
is(currentSampleOffset, expectedOffset, "Check amount of signal data processed");
|
||||
|
||||
var i, j;
|
||||
var signalPresent = true;
|
||||
for(i=0;i<signal.length;++i) {
|
||||
var signalAnalysed = false;
|
||||
for(j=0;j<spectrumMaxs.length;++j) {
|
||||
if(signal[i].start <= spectrumMaxs[j].time && spectrumMaxs[j].time < signal[i].end) {
|
||||
signalAnalysed = true;
|
||||
signalPresent = spectrumMaxs[j].index == signal[i].fftBin;
|
||||
}
|
||||
if(!signalPresent) break;
|
||||
}
|
||||
if(!signalAnalysed) signalPresent = false;;
|
||||
if(!signalPresent) break;
|
||||
}
|
||||
is(signalPresent, true, "Check signal present");
|
||||
|
||||
var noSignalPresent = true;
|
||||
for(i=0;i<noSignal.length;++i) {
|
||||
var signalAnalysed = false;
|
||||
for(j=0;j<spectrumMaxs.length;++j) {
|
||||
if(noSignal[i].start <= spectrumMaxs[j].time && spectrumMaxs[j].time < noSignal[i].end) {
|
||||
signalAnalysed = true;
|
||||
noSignalPresent = spectrumMaxs[j].index == 0;
|
||||
}
|
||||
if(!noSignalPresent) break;
|
||||
}
|
||||
if(!signalAnalysed) noSignalPresent = false;;
|
||||
if(!noSignalPresent) break;
|
||||
}
|
||||
is(signalPresent, true, "Check mute fragments present");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function audioEnded() {
|
||||
checkResults();
|
||||
}
|
||||
|
||||
function initTest() {
|
||||
var a1 = document.createElement("audio");
|
||||
a1.id = "a1";
|
||||
a1.addEventListener("ended", audioEnded, false);
|
||||
a1.addEventListener("loadedmetadata", loadedMetadata, false);
|
||||
a1.addEventListener("MozAudioAvailable", audioAvailable, false);
|
||||
a1.src = testFile;
|
||||
a1.muted = true;
|
||||
a1.play();
|
||||
document.body.appendChild(a1);
|
||||
}
|
||||
|
||||
window.addEventListener("load", function(e) {
|
||||
SpecialPowers.pushPrefEnv({"set": [["media.audio_data.enabled", true]]}, initTest);
|
||||
}, false);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,42 +0,0 @@
|
|||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=490705
|
||||
-->
|
||||
<head>
|
||||
<title>Media test: addEventListener optimization and adoptNode</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
|
||||
<script>
|
||||
function adopt() {
|
||||
var a1Node = document.getElementById("f1").contentDocument.getElementById("a1");
|
||||
var adopted = document.adoptNode(a1Node);
|
||||
document.body.appendChild(adopted);
|
||||
return adopted;
|
||||
}
|
||||
function wasAudioAvailableCalled() {
|
||||
var resultNode = document.getElementById("f1").contentDocument.getElementById("wasAudioAvailableCalled");
|
||||
return document.adoptNode(resultNode).checked;
|
||||
}
|
||||
function endTest() {
|
||||
is(wasAudioAvailableCalled(), true, "audioAvailable was not called");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
function startTest() {
|
||||
SpecialPowers.pushPrefEnv({"set": [["media.audio_data.enabled", true]]}, function () {
|
||||
var audio = adopt();
|
||||
audio.addEventListener("ended", endTest, false);
|
||||
audio.play();
|
||||
});
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=490705">Mozilla Bug 490705</a>
|
||||
<iframe id="f1" src="file_audio_event_adopt_iframe.html" onload="startTest()"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -1,79 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=490705
|
||||
-->
|
||||
|
||||
<head>
|
||||
<title>Media test: simple audio write checks</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=490705">Mozilla Bug 490705</a>
|
||||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var channels = 2;
|
||||
var rate = 44100;
|
||||
|
||||
function runTests() {
|
||||
var a1 = new Audio();
|
||||
|
||||
ok("mozSetup" in a1, "mozSetup should be supported");
|
||||
ok("mozWriteAudio" in a1, "mozWriteAudio should be supported");
|
||||
ok("mozCurrentSampleOffset" in a1, "mozCurrentSampleOffset should be supported");
|
||||
|
||||
try {
|
||||
a1.mozSetup(channels, rate);
|
||||
} catch (ex) {
|
||||
todo(false, "Audio hardware is disabled, can't test audio write API");
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
is(a1.mozChannels, channels, "mozChannels should be " + channels + ".");
|
||||
is(a1.mozSampleRate, rate, "mozSampleRate should be " + rate + ".");
|
||||
is(a1.volume, 1.0, "volume should be 1.0 by default.");
|
||||
|
||||
// Make sure changing volume on audio changes write audio stream.
|
||||
a1.volume = 0.5;
|
||||
is(a1.volume, 0.5, "volume should have been changed to 0.5.");
|
||||
a1.muted = true;
|
||||
ok(a1.muted, "volume should be muted.");
|
||||
|
||||
is(a1.mozCurrentSampleOffset(), 0, "mozCurrentSampleOffset() not working.");
|
||||
|
||||
// Test writing with js array
|
||||
var samples1 = [.5, .5];
|
||||
var written = sampleOffset = a1.mozWriteAudio(samples1);
|
||||
is(written, samples1.length, "Not all samples in JS Array written.");
|
||||
|
||||
// Test writing with Float32Array
|
||||
var samples2 = new Float32Array([.2, .3, .2, .3]);
|
||||
written = a1.mozWriteAudio(samples2);
|
||||
is(written, samples2.length, "Not all samples in Float32Array written.");
|
||||
|
||||
// Test passing the wrong arguments to mozWriteAudio.
|
||||
var writeArgsOK = false;
|
||||
try {
|
||||
// incorrect, should throw
|
||||
written = a1.mozWriteAudio(samples2.length, samples2);
|
||||
} catch(e) {
|
||||
writeArgsOK = true;
|
||||
}
|
||||
ok(writeArgsOK, "mozWriteAudio args test failed.");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
window.addEventListener("load", function(e) {
|
||||
SpecialPowers.pushPrefEnv({"set": [["media.audio_data.enabled", true]]}, runTests);
|
||||
}, false);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,47 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=686137
|
||||
-->
|
||||
|
||||
<head>
|
||||
<title>Media test: changing mozFrameBufferLength</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=686137">Mozilla Bug 686137</a>
|
||||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [["media.audio_data.enabled", true]]}, function () {
|
||||
var a1 = document.createElement("audio");
|
||||
a1.controls = true;
|
||||
a1.muted = true;
|
||||
a1.preload = "metadata";
|
||||
a1.addEventListener("loadedmetadata", metaDataLoaded, false);
|
||||
a1.src = "bug495794.ogg";
|
||||
a1.load();
|
||||
});
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function audioAvailable(event) {
|
||||
var a1 = event.target;
|
||||
a1.removeEventListener("MozAudioAvailable", audioAvailable);
|
||||
is( event.frameBuffer.length, 9001, "event.frameBuffer.length should be 9001.");
|
||||
is( event.frameBuffer.length, a1.mozFrameBufferLength, "event.frameBuffer.length should be " + a1.mozFrameBufferLength + ".");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function metaDataLoaded(event){
|
||||
var a1 = event.target;
|
||||
a1.addEventListener("MozAudioAvailable", audioAvailable, false);
|
||||
a1.mozFrameBufferLength = 9001;
|
||||
a1.play();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,112 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=490705
|
||||
-->
|
||||
|
||||
<head>
|
||||
<title>Media test: framebuffer size checks</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=490705">Mozilla Bug 490705</a>
|
||||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var testFile = "bug495794.ogg";
|
||||
var testFileDuration = 0.30;
|
||||
var testFileChannelCount = 6;
|
||||
var testFileSampleRate = 48000;
|
||||
var testFileFrameBufferLength = testFileChannelCount * 1024;
|
||||
|
||||
var undef;
|
||||
|
||||
var currentSampleOffset = 0;
|
||||
var isTimePropertyValid = true;
|
||||
|
||||
function audioAvailable(event) {
|
||||
var buffer = event.frameBuffer;
|
||||
|
||||
if ( (typeof event.time !== "number") ||
|
||||
(Math.abs(event.time - currentSampleOffset / testFileSampleRate / testFileChannelCount) > testFileDuration) ) {
|
||||
isTimePropertyValid = false;
|
||||
}
|
||||
|
||||
currentSampleOffset += buffer.length;
|
||||
}
|
||||
|
||||
var loadedMetadataCalled = false;
|
||||
function loadedMetadata() {
|
||||
loadedMetadataCalled = true;
|
||||
var a1 = document.getElementById('a1');
|
||||
is(a1.mozChannels, testFileChannelCount, "mozChannels should be " + testFileChannelCount + ".");
|
||||
is(a1.mozSampleRate, testFileSampleRate, "mozSampleRate should be " + testFileSampleRate + ".");
|
||||
is(a1.mozFrameBufferLength, testFileFrameBufferLength, "default mozFrameBufferLength should be " + testFileFrameBufferLength + ".");
|
||||
|
||||
var minFailed = false;
|
||||
try {
|
||||
a1.mozFrameBufferLength = 4;
|
||||
} catch(e) {
|
||||
minFailed = true;
|
||||
}
|
||||
ok(minFailed, "mozFrameBufferLength min fail check");
|
||||
|
||||
var maxFailed = false;
|
||||
try {
|
||||
a1.mozFrameBufferLength = 44444;
|
||||
} catch(e) {
|
||||
maxFailed = true;
|
||||
}
|
||||
ok(maxFailed, "mozFrameBufferLength max fail check");
|
||||
|
||||
a1.mozFrameBufferLength = testFileFrameBufferLength;
|
||||
}
|
||||
|
||||
function checkResults() {
|
||||
ok(loadedMetadataCalled, "loadedmetadata event not dispatched.");
|
||||
ok(isTimePropertyValid, "The audioAvailable event's time attribute was invalid.");
|
||||
|
||||
var expectedOffset = Math.ceil(testFileDuration * testFileSampleRate * testFileChannelCount);
|
||||
if (expectedOffset % testFileFrameBufferLength !== 0) {
|
||||
expectedOffset += (testFileFrameBufferLength - (expectedOffset % testFileFrameBufferLength));
|
||||
}
|
||||
is(currentSampleOffset, expectedOffset, "Check amount of signal data processed");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function audioEnded() {
|
||||
checkResults();
|
||||
}
|
||||
|
||||
function initTest() {
|
||||
var a1 = document.createElement("audio");
|
||||
a1.id = "a1";
|
||||
a1.preload = "metadata";
|
||||
a1.controls = true;
|
||||
document.body.appendChild(a1);
|
||||
|
||||
a1.addEventListener("ended", audioEnded, false);
|
||||
a1.addEventListener("loadedmetadata", loadedMetadata, false);
|
||||
a1.addEventListener("MozAudioAvailable", audioAvailable, false);
|
||||
a1.src = testFile;
|
||||
a1.muted = true;
|
||||
a1.play();
|
||||
}
|
||||
|
||||
window.addEventListener("load", function(e) {
|
||||
if (SpecialPowers.getBoolPref("media.audio_data.enabled")) {
|
||||
initTest();
|
||||
} else {
|
||||
ok(true, "old audio data api behind a pref");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}, false);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,54 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Wave Media test: ended</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Test if the ended event works correctly.
|
||||
var endPassed = false;
|
||||
var completed = false;
|
||||
|
||||
function audioavailable(e) {
|
||||
if (completed)
|
||||
return;
|
||||
|
||||
completed = true;
|
||||
var samples = e.frameBuffer;
|
||||
var time = e.time;
|
||||
|
||||
ok(samples.length >= 3, "Must be 3 or more samples. There were " + samples.length);
|
||||
if (samples.length >= 3) {
|
||||
ok(samples[0] > 0.99 && samples[0] < 1.01, "First sound sample should be close to 1.0. It was " + samples[0]);
|
||||
ok(samples[1] > -1.01 && samples [1] < -0.99, "Second sound sample should be close to -1.0. It was " + samples[1]);
|
||||
ok(samples[2] > -0.01 && samples[2] < 0.01, "Third sound sample should be close to 0. It was " + samples[2]);
|
||||
}
|
||||
|
||||
// Only care about the first few samples
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return;
|
||||
SpecialPowers.pushPrefEnv({"set": [["media.audio_data.enabled", true]]},
|
||||
function () {
|
||||
var v = document.getElementById('v');
|
||||
v.addEventListener('MozAudioAvailable', audioavailable, false);
|
||||
v.play();
|
||||
});
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<audio id='v'
|
||||
preload="metadata"
|
||||
onloadedmetadata='return startTest();'>
|
||||
<source type='audio/x-wav' src='wavedata_s16.wav'>
|
||||
</audio>
|
||||
</body>
|
||||
</html>
|
|
@ -1,54 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Wave Media test: ended</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Test if the ended event works correctly.
|
||||
var endPassed = false;
|
||||
var completed = false;
|
||||
|
||||
function audioavailable(e) {
|
||||
if (completed)
|
||||
return;
|
||||
|
||||
completed = true;
|
||||
var samples = e.frameBuffer;
|
||||
var time = e.time;
|
||||
|
||||
ok(samples.length >= 3, "Must be 3 or more samples. There were " + samples.length);
|
||||
if (samples.length >= 3) {
|
||||
ok(samples[0] > 0.99 && samples[0] < 1.01, "First sound sample should be close to 1.0. It was " + samples[0]);
|
||||
ok(samples[1] > -1.01 && samples [1] < -0.99, "Second sound sample should be close to -1.0. It was " + samples[1]);
|
||||
ok(samples[2] > -0.01 && samples[2] < 0.01, "Third sound sample should be close to 0. It was " + samples[2]);
|
||||
}
|
||||
|
||||
// Only care about the first few samples
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return;
|
||||
SpecialPowers.pushPrefEnv({"set": [["media.audio_data.enabled", true]]},
|
||||
function () {
|
||||
var v = document.getElementById('v');
|
||||
v.addEventListener('MozAudioAvailable', audioavailable, false);
|
||||
v.play();
|
||||
});
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<audio id='v'
|
||||
preload="metadata"
|
||||
onloadedmetadata='return startTest();'>
|
||||
<source type='audio/x-wav' src='wavedata_u8.wav'>
|
||||
</audio>
|
||||
</body>
|
||||
</html>
|
|
@ -605,7 +605,6 @@ bool WebMReader::DecodeAudioPacket(nestegg_packet* aPacket, int64_t aOffset)
|
|||
CheckedInt64 time = total_duration + tstamp_usecs;
|
||||
if (!time.isValid()) {
|
||||
NS_WARNING("Int overflow adding total_duration and tstamp_usecs");
|
||||
nestegg_free_packet(aPacket);
|
||||
return false;
|
||||
};
|
||||
|
||||
|
@ -733,7 +732,6 @@ bool WebMReader::DecodeAudioPacket(nestegg_packet* aPacket, int64_t aOffset)
|
|||
CheckedInt64 time = startTime - mCodecDelay;
|
||||
if (!time.isValid()) {
|
||||
NS_WARNING("Int overflow shifting tstamp by codec delay");
|
||||
nestegg_free_packet(aPacket);
|
||||
return false;
|
||||
};
|
||||
AudioQueue().Push(new AudioData(mDecoder->GetResource()->Tell(),
|
||||
|
@ -867,22 +865,20 @@ bool WebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||
// end of the resource, use the file's duration as the end time of this
|
||||
// video frame.
|
||||
uint64_t next_tstamp = 0;
|
||||
{
|
||||
nsAutoRef<NesteggPacketHolder> next_holder(NextPacket(VIDEO));
|
||||
if (next_holder) {
|
||||
r = nestegg_packet_tstamp(next_holder->mPacket, &next_tstamp);
|
||||
if (r == -1) {
|
||||
return false;
|
||||
}
|
||||
PushVideoPacket(next_holder.disown());
|
||||
} else {
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
int64_t endTime = mDecoder->GetEndMediaTime();
|
||||
if (endTime == -1) {
|
||||
return false;
|
||||
}
|
||||
next_tstamp = endTime * NS_PER_USEC;
|
||||
nsAutoRef<NesteggPacketHolder> next_holder(NextPacket(VIDEO));
|
||||
if (next_holder) {
|
||||
r = nestegg_packet_tstamp(next_holder->mPacket, &next_tstamp);
|
||||
if (r == -1) {
|
||||
return false;
|
||||
}
|
||||
PushVideoPacket(next_holder.disown());
|
||||
} else {
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
int64_t endTime = mDecoder->GetEndMediaTime();
|
||||
if (endTime == -1) {
|
||||
return false;
|
||||
}
|
||||
next_tstamp = endTime * NS_PER_USEC;
|
||||
}
|
||||
|
||||
int64_t tstamp_usecs = tstamp / NS_PER_USEC;
|
||||
|
|
|
@ -167,8 +167,8 @@ protected:
|
|||
// audio queue. Returns true when there's more audio to decode,
|
||||
// false if the audio is finished, end of file has been reached,
|
||||
// or an un-recoverable read error has occured. The reader's monitor
|
||||
// must be held during this call. This function will free the packet
|
||||
// so the caller must not use the packet after calling.
|
||||
// must be held during this call. The caller is responsible for freeing
|
||||
// aPacket.
|
||||
bool DecodeAudioPacket(nestegg_packet* aPacket, int64_t aOffset);
|
||||
|
||||
// Release context and set to null. Called when an error occurs during
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/SVGAElementBinding.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -268,7 +269,7 @@ SVGAElement::GetLinkTarget(nsAString& aTarget)
|
|||
}
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
EventStates
|
||||
SVGAElement::IntrinsicState() const
|
||||
{
|
||||
return Link::LinkState() | SVGAElementBase::IntrinsicState();
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
virtual bool IsLink(nsIURI** aURI) const MOZ_OVERRIDE;
|
||||
virtual void GetLinkTarget(nsAString& aTarget) MOZ_OVERRIDE;
|
||||
virtual already_AddRefed<nsIURI> GetHrefURI() const MOZ_OVERRIDE;
|
||||
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
||||
nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue, bool aNotify)
|
||||
{
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче