LibWeb: Implement the MediaError IDL interface
This commit is contained in:
parent
22572c39e0
commit
73a80b7047
Notes:
sideshowbarker
2024-07-17 14:36:19 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/73a80b7047 Pull-request: https://github.com/SerenityOS/serenity/pull/18468 Reviewed-by: https://github.com/awesomekling
6 changed files with 84 additions and 0 deletions
|
@ -309,6 +309,7 @@ set(SOURCES
|
|||
HTML/HTMLVideoElement.cpp
|
||||
HTML/ImageData.cpp
|
||||
HTML/Location.cpp
|
||||
HTML/MediaError.cpp
|
||||
HTML/MessageChannel.cpp
|
||||
HTML/MessageEvent.cpp
|
||||
HTML/MessagePort.cpp
|
||||
|
|
|
@ -365,6 +365,7 @@ class HTMLUnknownElement;
|
|||
class HTMLVideoElement;
|
||||
class ImageData;
|
||||
class Location;
|
||||
class MediaError;
|
||||
class MessageChannel;
|
||||
class MessageEvent;
|
||||
class MessagePort;
|
||||
|
|
29
Userland/Libraries/LibWeb/HTML/MediaError.cpp
Normal file
29
Userland/Libraries/LibWeb/HTML/MediaError.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/MediaErrorPrototype.h>
|
||||
#include <LibWeb/HTML/MediaError.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
MediaError::MediaError(JS::Realm& realm, Code code, String message)
|
||||
: Base(realm)
|
||||
, m_code(code)
|
||||
, m_message(move(message))
|
||||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<void> MediaError::initialize(JS::Realm& realm)
|
||||
{
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::MediaErrorPrototype>(realm, "MediaError"));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
41
Userland/Libraries/LibWeb/HTML/MediaError.h
Normal file
41
Userland/Libraries/LibWeb/HTML/MediaError.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
class MediaError final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(MediaError, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
enum class Code : u16 {
|
||||
Aborted = 1,
|
||||
Network = 2,
|
||||
Decode = 3,
|
||||
SrcNotSupported = 4,
|
||||
};
|
||||
|
||||
Code code() const { return m_code; }
|
||||
String const& message() const { return m_message; }
|
||||
|
||||
private:
|
||||
MediaError(JS::Realm&, Code code, String message);
|
||||
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#dom-mediaerror-code
|
||||
Code m_code;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#dom-mediaerror-message
|
||||
String m_message;
|
||||
};
|
||||
|
||||
}
|
11
Userland/Libraries/LibWeb/HTML/MediaError.idl
Normal file
11
Userland/Libraries/LibWeb/HTML/MediaError.idl
Normal file
|
@ -0,0 +1,11 @@
|
|||
// https://html.spec.whatwg.org/multipage/media.html#mediaerror
|
||||
[Exposed=Window]
|
||||
interface MediaError {
|
||||
const unsigned short MEDIA_ERR_ABORTED = 1;
|
||||
const unsigned short MEDIA_ERR_NETWORK = 2;
|
||||
const unsigned short MEDIA_ERR_DECODE = 3;
|
||||
const unsigned short MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
|
||||
|
||||
readonly attribute unsigned short code;
|
||||
readonly attribute DOMString message;
|
||||
};
|
|
@ -152,6 +152,7 @@ libweb_js_bindings(HTML/HTMLUnknownElement)
|
|||
libweb_js_bindings(HTML/HTMLVideoElement)
|
||||
libweb_js_bindings(HTML/ImageData)
|
||||
libweb_js_bindings(HTML/Location)
|
||||
libweb_js_bindings(HTML/MediaError)
|
||||
libweb_js_bindings(HTML/MessageChannel)
|
||||
libweb_js_bindings(HTML/MessageEvent)
|
||||
libweb_js_bindings(HTML/MessagePort)
|
||||
|
|
Loading…
Add table
Reference in a new issue