2015-05-03 22:32:37 +03: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 15:12:37 +04: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 16:26:39 +04:00
|
|
|
|
|
|
|
#include "mozilla/dom/HTMLAudioElement.h"
|
|
|
|
#include "mozilla/dom/HTMLAudioElementBinding.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2008-07-09 12:22:20 +04:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsGkAtoms.h"
|
2019-01-02 16:05:23 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
2011-10-04 18:06:54 +04:00
|
|
|
#include "jsfriendapi.h"
|
2011-08-11 17:29:50 +04:00
|
|
|
#include "nsContentUtils.h"
|
2012-09-24 07:47:30 +04:00
|
|
|
#include "nsJSUtils.h"
|
2012-10-25 14:09:40 +04:00
|
|
|
#include "AudioSampleFormat.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2013-09-06 21:50:24 +04:00
|
|
|
#include "nsComponentManagerUtils.h"
|
2013-10-22 01:23:33 +04:00
|
|
|
#include "nsIHttpChannel.h"
|
|
|
|
#include "mozilla/dom/TimeRanges.h"
|
|
|
|
#include "AudioStream.h"
|
2019-02-28 08:52:37 +03:00
|
|
|
|
2019-02-28 22:02:55 +03:00
|
|
|
nsGenericHTMLElement* NS_NewHTMLAudioElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
|
|
|
mozilla::dom::FromParser aFromParser) {
|
|
|
|
mozilla::dom::HTMLAudioElement* element =
|
|
|
|
new mozilla::dom::HTMLAudioElement(std::move(aNodeInfo));
|
|
|
|
element->Init();
|
|
|
|
return element;
|
|
|
|
}
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2013-03-19 16:25:46 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2019-02-28 22:02:55 +03:00
|
|
|
nsresult HTMLAudioElement::Clone(mozilla::dom::NodeInfo* aNodeInfo,
|
|
|
|
nsINode** aResult) const {
|
|
|
|
*aResult = nullptr;
|
|
|
|
RefPtr<mozilla::dom::NodeInfo> ni(aNodeInfo);
|
|
|
|
HTMLAudioElement* it = new HTMLAudioElement(ni.forget());
|
|
|
|
it->Init();
|
|
|
|
nsCOMPtr<nsINode> kungFuDeathGrip = it;
|
|
|
|
nsresult rv = const_cast<HTMLAudioElement*>(this)->CopyInnerTo(it);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
kungFuDeathGrip.swap(*aResult);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2018-09-21 23:45:49 +03: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 09:55:27 +03:00
|
|
|
DecoderDoctorLogger::LogConstruction(this);
|
2008-07-09 12:22:20 +04:00
|
|
|
}
|
|
|
|
|
2013-03-19 16:25:46 +04: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 09:55:27 +03:00
|
|
|
DecoderDoctorLogger::LogDestruction(this);
|
2008-07-09 12:22:20 +04:00
|
|
|
}
|
2009-05-19 09:18:41 +04:00
|
|
|
|
2015-03-17 23:42:14 +03:00
|
|
|
bool HTMLAudioElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const {
|
2015-03-23 12:02:33 +03:00
|
|
|
return HasAttr(kNameSpaceID_None, nsGkAtoms::controls) ||
|
|
|
|
HTMLMediaElement::IsInteractiveHTMLContent(aIgnoreTabindex);
|
2015-01-20 23:39:28 +03:00
|
|
|
}
|
|
|
|
|
2013-03-19 16:26:39 +04:00
|
|
|
already_AddRefed<HTMLAudioElement> HTMLAudioElement::Audio(
|
2013-04-12 23:35:46 +04:00
|
|
|
const GlobalObject& aGlobal, const Optional<nsAString>& aSrc,
|
|
|
|
ErrorResult& aRv) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobal.GetAsSupports());
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* doc;
|
2013-03-19 16:26:39 +04: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);
|
|
|
|
|
2019-02-28 22:02:55 +03:00
|
|
|
RefPtr<HTMLAudioElement> audio =
|
|
|
|
static_cast<HTMLAudioElement*>(NS_NewHTMLAudioElement(nodeInfo.forget()));
|
2013-03-19 16:26:39 +04:00
|
|
|
audio->SetHTMLAttr(nsGkAtoms::preload, NS_LITERAL_STRING("auto"), aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-04-12 23:35:46 +04:00
|
|
|
if (aSrc.WasPassed()) {
|
2018-02-15 08:22:38 +03:00
|
|
|
audio->SetSrc(aSrc.Value(), aRv);
|
2013-03-19 16:26:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return audio.forget();
|
|
|
|
}
|
|
|
|
|
2013-03-19 16:25:46 +04:00
|
|
|
nsresult HTMLAudioElement::SetAcceptHeader(nsIHttpChannel* aChannel) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString value(
|
2010-07-29 08:58:07 +04: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 16:25:46 +04: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 17:13:33 +03:00
|
|
|
JSObject* HTMLAudioElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return HTMLAudioElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-03-19 16:26:39 +04:00
|
|
|
}
|
|
|
|
|
2013-03-19 16:25:46 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|