mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:57:35 +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
11 changed files with 144 additions and 0 deletions
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 {
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue