mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-13 04:52:23 +00:00
LibWeb: Add stub IDL interface for PeriodicWave
PeriodicWave represents an arbitrary periodic waveform to be used with an OscillatorNode.
This commit is contained in:
parent
5cb127819c
commit
b1b7e2324a
Notes:
sideshowbarker
2024-07-17 00:47:29 +09:00
Author: https://github.com/shannonbooth
Commit: b1b7e2324a
Pull-request: https://github.com/SerenityOS/serenity/pull/24143
7 changed files with 100 additions and 0 deletions
|
@ -34,6 +34,7 @@ static bool is_platform_object(Type const& type)
|
|||
"AnimationTimeline"sv,
|
||||
"Attr"sv,
|
||||
"AudioTrack"sv,
|
||||
"BaseAudioContext"sv,
|
||||
"Blob"sv,
|
||||
"CanvasGradient"sv,
|
||||
"CanvasPattern"sv,
|
||||
|
@ -63,6 +64,7 @@ static bool is_platform_object(Type const& type)
|
|||
"Path2D"sv,
|
||||
"PerformanceEntry"sv,
|
||||
"PerformanceMark"sv,
|
||||
"PeriodicWave"sv,
|
||||
"PointerEvent"sv,
|
||||
"ReadableStreamBYOBReader"sv,
|
||||
"ReadableStreamDefaultReader"sv,
|
||||
|
|
|
@ -661,6 +661,7 @@ set(SOURCES
|
|||
WebAudio/AudioContext.cpp
|
||||
WebAudio/BaseAudioContext.cpp
|
||||
WebAudio/OfflineAudioContext.cpp
|
||||
WebAudio/PeriodicWave.cpp
|
||||
WebDriver/Capabilities.cpp
|
||||
WebDriver/Client.cpp
|
||||
WebDriver/Contexts.cpp
|
||||
|
|
|
@ -682,6 +682,8 @@ class Table;
|
|||
namespace Web::WebAudio {
|
||||
class AudioContext;
|
||||
class BaseAudioContext;
|
||||
class OfflineAudioContext;
|
||||
class PeriodicWave;
|
||||
|
||||
enum class AudioContextState;
|
||||
|
||||
|
|
35
Userland/Libraries/LibWeb/WebAudio/PeriodicWave.cpp
Normal file
35
Userland/Libraries/LibWeb/WebAudio/PeriodicWave.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/PeriodicWavePrototype.h>
|
||||
#include <LibWeb/WebAudio/PeriodicWave.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::WebAudio {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(PeriodicWave);
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-periodicwave-periodicwave
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<PeriodicWave>> PeriodicWave::construct_impl(JS::Realm& realm, JS::NonnullGCPtr<BaseAudioContext>, PeriodicWaveOptions const&)
|
||||
{
|
||||
return WebIDL::NotSupportedError::create(realm, "FIXME: Implement PeriodicWave::construct_impl"_fly_string);
|
||||
}
|
||||
|
||||
PeriodicWave::~PeriodicWave() = default;
|
||||
|
||||
void PeriodicWave::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(PeriodicWave);
|
||||
}
|
||||
|
||||
void PeriodicWave::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
}
|
||||
|
||||
}
|
41
Userland/Libraries/LibWeb/WebAudio/PeriodicWave.h
Normal file
41
Userland/Libraries/LibWeb/WebAudio/PeriodicWave.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Vector.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
|
||||
namespace Web::WebAudio {
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#PeriodicWaveConstraints
|
||||
struct PeriodicWaveConstraints {
|
||||
bool disable_normalization { false };
|
||||
};
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#PeriodicWaveOptions
|
||||
struct PeriodicWaveOptions : PeriodicWaveConstraints {
|
||||
Optional<Vector<float>> real;
|
||||
Optional<Vector<float>> imag;
|
||||
};
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#PeriodicWave
|
||||
class PeriodicWave : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(PeriodicWave, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(PeriodicWave);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PeriodicWave>> construct_impl(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>, PeriodicWaveOptions const&);
|
||||
|
||||
virtual ~PeriodicWave() override;
|
||||
|
||||
protected:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
};
|
||||
|
||||
}
|
18
Userland/Libraries/LibWeb/WebAudio/PeriodicWave.idl
Normal file
18
Userland/Libraries/LibWeb/WebAudio/PeriodicWave.idl
Normal file
|
@ -0,0 +1,18 @@
|
|||
#import <WebAudio/BaseAudioContext.idl>
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#PeriodicWaveConstraints
|
||||
dictionary PeriodicWaveConstraints {
|
||||
boolean disableNormalization = false;
|
||||
};
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#PeriodicWaveOptions
|
||||
dictionary PeriodicWaveOptions : PeriodicWaveConstraints {
|
||||
sequence<float> real;
|
||||
sequence<float> imag;
|
||||
};
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#PeriodicWave
|
||||
[Exposed=Window]
|
||||
interface PeriodicWave {
|
||||
constructor(BaseAudioContext context, optional PeriodicWaveOptions options = {});
|
||||
};
|
|
@ -297,6 +297,7 @@ libweb_js_bindings(WebAudio/AudioBuffer)
|
|||
libweb_js_bindings(WebAudio/AudioContext)
|
||||
libweb_js_bindings(WebAudio/BaseAudioContext)
|
||||
libweb_js_bindings(WebAudio/OfflineAudioContext)
|
||||
libweb_js_bindings(WebAudio/PeriodicWave)
|
||||
libweb_js_bindings(WebGL/WebGLContextEvent)
|
||||
libweb_js_bindings(WebGL/WebGLRenderingContext)
|
||||
libweb_js_bindings(WebIDL/DOMException)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue