2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
2013-03-19 12:26:39 +00:00
|
|
|
|
|
|
|
#include "mozilla/dom/HTMLAudioElement.h"
|
|
|
|
#include "mozilla/dom/HTMLAudioElementBinding.h"
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2008-07-09 08:22:20 +00:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsGkAtoms.h"
|
2019-01-02 13:05:23 +00:00
|
|
|
#include "mozilla/dom/Document.h"
|
2011-10-04 14:06:54 +00:00
|
|
|
#include "jsfriendapi.h"
|
2011-08-11 13:29:50 +00:00
|
|
|
#include "nsContentUtils.h"
|
2012-09-24 03:47:30 +00:00
|
|
|
#include "nsJSUtils.h"
|
2012-10-25 10:09:40 +00:00
|
|
|
#include "AudioSampleFormat.h"
|
2013-01-15 12:22:03 +00:00
|
|
|
#include <algorithm>
|
2013-09-06 17:50:24 +00:00
|
|
|
#include "nsComponentManagerUtils.h"
|
2013-10-21 21:23:33 +00:00
|
|
|
#include "nsIHttpChannel.h"
|
|
|
|
#include "mozilla/dom/TimeRanges.h"
|
|
|
|
#include "AudioStream.h"
|
2008-07-09 08:22:20 +00:00
|
|
|
|
2013-04-04 07:04:29 +00:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Audio)
|
2008-07-09 08:22:20 +00:00
|
|
|
|
2013-03-19 12:25:46 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2008-07-09 08:22:20 +00:00
|
|
|
|
2013-03-19 12:25:46 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLAudioElement)
|
2008-07-09 08:22:20 +00:00
|
|
|
|
2018-09-21 20:45:49 +00:00
|
|
|
HTMLAudioElement::HTMLAudioElement(already_AddRefed<NodeInfo>&& aNodeInfo)
|
|
|
|
: HTMLMediaElement(std::move(aNodeInfo)) {
|
Bug 1407810 - Use DDLogger in media stack - r=jwwang
Mostly-mechanical additions:
- Log constructions&destructions, usually by just inheriting from
DecoderDoctorLifeLogger, otherwise with explicit log commands (for internal
classes for which DecoderDoctorTraits can't be specialized),
- Log links between most objects, e.g.: Media element -> decoder -> state
machine -> reader -> demuxer -> resource, etc.
And logging some important properties and events (JS events, duration change,
frames being decoded, etc.)
More will be added later on, from just converting MOZ_LOGs, and as needed.
MozReview-Commit-ID: KgNhHSz35t0
--HG--
extra : rebase_source : dd7206e350e32671adc6f3b9e54ebf777251de2c
2017-10-10 06:55:27 +00:00
|
|
|
DecoderDoctorLogger::LogConstruction(this);
|
2008-07-09 08:22:20 +00:00
|
|
|
}
|
|
|
|
|
2013-03-19 12:25:46 +00:00
|
|
|
HTMLAudioElement::~HTMLAudioElement() {
|
Bug 1407810 - Use DDLogger in media stack - r=jwwang
Mostly-mechanical additions:
- Log constructions&destructions, usually by just inheriting from
DecoderDoctorLifeLogger, otherwise with explicit log commands (for internal
classes for which DecoderDoctorTraits can't be specialized),
- Log links between most objects, e.g.: Media element -> decoder -> state
machine -> reader -> demuxer -> resource, etc.
And logging some important properties and events (JS events, duration change,
frames being decoded, etc.)
More will be added later on, from just converting MOZ_LOGs, and as needed.
MozReview-Commit-ID: KgNhHSz35t0
--HG--
extra : rebase_source : dd7206e350e32671adc6f3b9e54ebf777251de2c
2017-10-10 06:55:27 +00:00
|
|
|
DecoderDoctorLogger::LogDestruction(this);
|
2008-07-09 08:22:20 +00:00
|
|
|
}
|
2009-05-19 05:18:41 +00:00
|
|
|
|
2015-03-17 20:42:14 +00:00
|
|
|
bool HTMLAudioElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const {
|
2015-03-23 09:02:33 +00:00
|
|
|
return HasAttr(kNameSpaceID_None, nsGkAtoms::controls) ||
|
|
|
|
HTMLMediaElement::IsInteractiveHTMLContent(aIgnoreTabindex);
|
2015-01-20 20:39:28 +00:00
|
|
|
}
|
|
|
|
|
2013-03-19 12:26:39 +00:00
|
|
|
already_AddRefed<HTMLAudioElement> HTMLAudioElement::Audio(
|
2013-04-12 19:35:46 +00:00
|
|
|
const GlobalObject& aGlobal, const Optional<nsAString>& aSrc,
|
|
|
|
ErrorResult& aRv) {
|
2016-01-30 17:05:36 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobal.GetAsSupports());
|
2019-01-02 13:05:23 +00:00
|
|
|
Document* doc;
|
2013-03-19 12:26:39 +00:00
|
|
|
if (!win || !(doc = win->GetExtantDoc())) {
|
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<mozilla::dom::NodeInfo> nodeInfo = doc->NodeInfoManager()->GetNodeInfo(
|
|
|
|
nsGkAtoms::audio, nullptr, kNameSpaceID_XHTML, ELEMENT_NODE);
|
|
|
|
|
2018-09-21 20:45:49 +00:00
|
|
|
RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(nodeInfo.forget());
|
2013-03-19 12:26:39 +00:00
|
|
|
audio->SetHTMLAttr(nsGkAtoms::preload, NS_LITERAL_STRING("auto"), aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-04-12 19:35:46 +00:00
|
|
|
if (aSrc.WasPassed()) {
|
2018-02-15 05:22:38 +00:00
|
|
|
audio->SetSrc(aSrc.Value(), aRv);
|
2013-03-19 12:26:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return audio.forget();
|
|
|
|
}
|
|
|
|
|
2013-03-19 12:25:46 +00:00
|
|
|
nsresult HTMLAudioElement::SetAcceptHeader(nsIHttpChannel* aChannel) {
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString value(
|
2010-07-29 04:58:07 +00:00
|
|
|
"audio/webm,"
|
|
|
|
"audio/ogg,"
|
|
|
|
"audio/wav,"
|
|
|
|
"audio/*;q=0.9,"
|
|
|
|
"application/ogg;q=0.7,"
|
|
|
|
"video/*;q=0.6,*/*;q=0.5");
|
|
|
|
|
|
|
|
return aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"), value, false);
|
|
|
|
}
|
2013-03-19 12:25:46 +00:00
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
JSObject* HTMLAudioElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-25 21:20:54 +00:00
|
|
|
return HTMLAudioElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-03-19 12:26:39 +00:00
|
|
|
}
|
|
|
|
|
2013-03-19 12:25:46 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|