mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 08:56:40 +00:00
LibWeb: Stub AudioContext constructor
This is enough to make Discord not throw up "Well this is awkward" on login.
This commit is contained in:
parent
78db4e683f
commit
a5936864d9
|
@ -3114,6 +3114,7 @@ using namespace Web::UIEvents;
|
|||
using namespace Web::URL;
|
||||
using namespace Web::XHR;
|
||||
using namespace Web::WebAssembly;
|
||||
using namespace Web::WebAudio;
|
||||
using namespace Web::WebGL;
|
||||
using namespace Web::WebIDL;
|
||||
|
||||
|
@ -3330,6 +3331,7 @@ using namespace Web::UserTiming;
|
|||
using namespace Web::URL;
|
||||
using namespace Web::XHR;
|
||||
using namespace Web::WebAssembly;
|
||||
using namespace Web::WebAudio;
|
||||
using namespace Web::WebGL;
|
||||
using namespace Web::WebIDL;
|
||||
|
||||
|
@ -3713,6 +3715,7 @@ using namespace Web::UserTiming;
|
|||
using namespace Web::WebSockets;
|
||||
using namespace Web::XHR;
|
||||
using namespace Web::WebAssembly;
|
||||
using namespace Web::WebAudio;
|
||||
using namespace Web::WebGL;
|
||||
using namespace Web::WebIDL;
|
||||
|
||||
|
@ -3843,6 +3846,7 @@ using namespace Web::XHR;
|
|||
using namespace Web::UIEvents;
|
||||
using namespace Web::URL;
|
||||
using namespace Web::UserTiming;
|
||||
using namespace Web::WebAudio;
|
||||
using namespace Web::WebGL;
|
||||
using namespace Web::WebIDL;
|
||||
|
||||
|
@ -3994,6 +3998,7 @@ using namespace Web::SVG;
|
|||
using namespace Web::UIEvents;
|
||||
using namespace Web::URL;
|
||||
using namespace Web::UserTiming;
|
||||
using namespace Web::WebAudio;
|
||||
using namespace Web::WebSockets;
|
||||
using namespace Web::XHR;
|
||||
using namespace Web::WebGL;
|
||||
|
|
|
@ -31,6 +31,7 @@ static constexpr Array libweb_interface_namespaces = {
|
|||
"Selection"sv,
|
||||
"UIEvents"sv,
|
||||
"URL"sv,
|
||||
"WebAudio"sv,
|
||||
"WebGL"sv,
|
||||
"WebIDL"sv,
|
||||
"WebSockets"sv,
|
||||
|
|
|
@ -540,6 +540,8 @@ set(SOURCES
|
|||
WebAssembly/Module.cpp
|
||||
WebAssembly/Table.cpp
|
||||
WebAssembly/WebAssembly.cpp
|
||||
WebAudio/AudioContext.cpp
|
||||
WebAudio/BaseAudioContext.cpp
|
||||
WebDriver/Capabilities.cpp
|
||||
WebDriver/Client.cpp
|
||||
WebDriver/Contexts.cpp
|
||||
|
|
|
@ -577,6 +577,11 @@ class Module;
|
|||
class Table;
|
||||
}
|
||||
|
||||
namespace Web::WebAudio {
|
||||
class AudioContext;
|
||||
class BaseAudioContext;
|
||||
}
|
||||
|
||||
namespace Web::WebGL {
|
||||
class WebGLContextEvent;
|
||||
class WebGLRenderingContext;
|
||||
|
|
34
Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp
Normal file
34
Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/WebAudio/AudioContext.h>
|
||||
|
||||
namespace Web::WebAudio {
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audiocontext-audiocontext
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AudioContext>> AudioContext::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
dbgln("(STUBBED) new AudioContext()");
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<AudioContext>(realm, realm));
|
||||
}
|
||||
|
||||
AudioContext::AudioContext(JS::Realm& realm)
|
||||
: BaseAudioContext(realm)
|
||||
{
|
||||
}
|
||||
|
||||
AudioContext::~AudioContext() = default;
|
||||
|
||||
JS::ThrowCompletionOr<void> AudioContext::initialize(JS::Realm& realm)
|
||||
{
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::AudioContextPrototype>(realm, "AudioContext"));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
28
Userland/Libraries/LibWeb/WebAudio/AudioContext.h
Normal file
28
Userland/Libraries/LibWeb/WebAudio/AudioContext.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/WebAudio/BaseAudioContext.h>
|
||||
|
||||
namespace Web::WebAudio {
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#AudioContext
|
||||
class AudioContext final : public BaseAudioContext {
|
||||
WEB_PLATFORM_OBJECT(AudioContext, BaseAudioContext);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<AudioContext>> construct_impl(JS::Realm&);
|
||||
|
||||
virtual ~AudioContext() override;
|
||||
|
||||
private:
|
||||
explicit AudioContext(JS::Realm&);
|
||||
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
8
Userland/Libraries/LibWeb/WebAudio/AudioContext.idl
Normal file
8
Userland/Libraries/LibWeb/WebAudio/AudioContext.idl
Normal file
|
@ -0,0 +1,8 @@
|
|||
#import <WebAudio/BaseAudioContext.idl>
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#AudioContext
|
||||
[Exposed=Window]
|
||||
interface AudioContext : BaseAudioContext {
|
||||
// FIXME: Should be constructor (optional AudioContextOptions contextOptions = {});
|
||||
constructor();
|
||||
};
|
27
Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp
Normal file
27
Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/WebAudio/BaseAudioContext.h>
|
||||
|
||||
namespace Web::WebAudio {
|
||||
|
||||
BaseAudioContext::BaseAudioContext(JS::Realm& realm)
|
||||
: DOM::EventTarget(realm)
|
||||
{
|
||||
}
|
||||
|
||||
BaseAudioContext::~BaseAudioContext() = default;
|
||||
|
||||
JS::ThrowCompletionOr<void> BaseAudioContext::initialize(JS::Realm& realm)
|
||||
{
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::BaseAudioContextPrototype>(realm, "BaseAudioContext"));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
26
Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.h
Normal file
26
Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
|
||||
namespace Web::WebAudio {
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#BaseAudioContext
|
||||
class BaseAudioContext : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(BaseAudioContext, DOM::EventTarget);
|
||||
|
||||
public:
|
||||
virtual ~BaseAudioContext() override;
|
||||
|
||||
protected:
|
||||
explicit BaseAudioContext(JS::Realm&);
|
||||
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
6
Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.idl
Normal file
6
Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.idl
Normal file
|
@ -0,0 +1,6 @@
|
|||
#import <DOM/EventTarget.idl>
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#BaseAudioContext
|
||||
[Exposed=Window]
|
||||
interface BaseAudioContext : EventTarget {
|
||||
};
|
|
@ -227,6 +227,8 @@ libweb_js_bindings(WebAssembly/Memory)
|
|||
libweb_js_bindings(WebAssembly/Module)
|
||||
libweb_js_bindings(WebAssembly/Table)
|
||||
libweb_js_bindings(WebAssembly/WebAssembly NAMESPACE)
|
||||
libweb_js_bindings(WebAudio/AudioContext)
|
||||
libweb_js_bindings(WebAudio/BaseAudioContext)
|
||||
libweb_js_bindings(WebGL/WebGLContextEvent)
|
||||
libweb_js_bindings(WebGL/WebGLRenderingContext)
|
||||
libweb_js_bindings(WebIDL/DOMException)
|
||||
|
|
Loading…
Reference in a new issue