Bug 775302 - Stub out the implementation of mozAudioContext; r=bzbarsky,khuey

This commit is contained in:
Ehsan Akhgari 2012-08-31 16:59:37 -04:00
parent 55ec4303a5
commit 4ccf1a400c
11 changed files with 192 additions and 0 deletions

View File

@ -62,6 +62,8 @@ CPPSRCS += \
$(NULL)
endif
PARALLEL_DIRS += webaudio
ifdef MOZ_RAW
PARALLEL_DIRS += raw
endif

View File

@ -0,0 +1,56 @@
/* -*- 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 "AudioContext.h"
#include "nsContentUtils.h"
#include "nsIDOMWindow.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/AudioContextBinding.h"
namespace mozilla {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(AudioContext, mWindow)
NS_IMPL_CYCLE_COLLECTING_ADDREF(AudioContext)
NS_IMPL_CYCLE_COLLECTING_RELEASE(AudioContext)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AudioContext)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
AudioContext::AudioContext(nsIDOMWindow* aWindow)
: mWindow(aWindow)
{
SetIsDOMBinding();
}
AudioContext::~AudioContext()
{
}
JSObject*
AudioContext::WrapObject(JSContext* aCx, JSObject* aScope,
bool* aTriedToWrap)
{
return dom::mozAudioContextBinding::Wrap(aCx, aScope, this,
aTriedToWrap);
}
/* static */ already_AddRefed<AudioContext>
AudioContext::Constructor(nsISupports* aGlobal, ErrorResult& aRv)
{
nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(aGlobal);
if (!window) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
AudioContext* object = new AudioContext(window);
NS_ADDREF(object);
return object;
}
}

View File

@ -0,0 +1,46 @@
/* -*- 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 "nsWrapperCache.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/Attributes.h"
#include "nsCOMPtr.h"
class JSContext;
class nsIDOMWindow;
namespace mozilla {
class ErrorResult;
class AudioContext MOZ_FINAL : public nsISupports,
public nsWrapperCache
{
explicit AudioContext(nsIDOMWindow* aParentWindow);
public:
virtual ~AudioContext();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AudioContext)
nsIDOMWindow* GetParentObject() const
{
return mWindow;
}
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope,
bool* aTriedToWrap);
static already_AddRefed<AudioContext>
Constructor(nsISupports* aGlobal, ErrorResult& aRv);
private:
nsCOMPtr<nsIDOMWindow> mWindow;
};
}

View File

@ -0,0 +1,25 @@
# 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/.
DEPTH := @DEPTH@
topsrcdir := @top_srcdir@
srcdir := @srcdir@
VPATH := @srcdir@
FAIL_ON_WARNINGS := 1
include $(DEPTH)/config/autoconf.mk
MODULE := content
LIBRARY_NAME := gkconwebaudio_s
LIBXUL_LIBRARY := 1
CPPSRCS := \
AudioContext.cpp
$(NULL)
PARALLEL_DIRS := test
FORCE_STATIC_LIB := 1
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,17 @@
# 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/.
DEPTH := @DEPTH@
topsrcdir := @top_srcdir@
srcdir := @srcdir@
VPATH := @srcdir@
relativesrcdir := @relativesrcdir@
include $(DEPTH)/config/autoconf.mk
MOCHITEST_FILES := \
test_AudioContext.html \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,22 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test whether we can create an AudioContext interface</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">
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
var ac = new mozAudioContext();
ok(ac, "Create a mozAudioContext object");
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>

View File

@ -61,6 +61,11 @@
DOMInterfaces = {
'mozAudioContext': {
'nativeType': 'AudioContext',
'prefable': True,
},
'Blob': [
{
'headerFile': 'nsIDOMFile.h',

View File

@ -25,6 +25,7 @@ DOM_SRCDIRS = \
content/base/src \
content/html/content/src \
content/html/document/src \
content/media/webaudio \
content/svg/content/src \
layout/generic \
layout/style \

View File

@ -0,0 +1,16 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
[Constructor]
interface mozAudioContext {
};

View File

@ -9,6 +9,7 @@ generated_webidl_files = \
$(NULL)
webidl_files = \
AudioContext.webidl \
CanvasRenderingContext2D.webidl \
CSSStyleDeclaration.webidl \
Function.webidl \

View File

@ -134,6 +134,7 @@ endif #}
ifdef MOZ_MEDIA
SHARED_LIBRARY_LIBS += \
$(DEPTH)/content/media/$(LIB_PREFIX)gkconmedia_s.$(LIB_SUFFIX) \
$(DEPTH)/content/media/webaudio/$(LIB_PREFIX)gkconwebaudio_s.$(LIB_SUFFIX) \
$(DEPTH)/content/media/webrtc/$(LIB_PREFIX)gkconwebrtc_s.$(LIB_SUFFIX) \
$(NULL)
endif