mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb/HTML: Stub TextTrack IDL interface
This commit is contained in:
parent
a9669639ce
commit
67e3ac8916
Notes:
sideshowbarker
2024-07-17 08:45:34 +09:00
Author: https://github.com/jamierocks
Commit: 67e3ac8916
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/333
Reviewed-by: https://github.com/awesomekling
12 changed files with 217 additions and 1 deletions
102
Userland/Libraries/LibWeb/HTML/TextTrack.cpp
Normal file
102
Userland/Libraries/LibWeb/HTML/TextTrack.cpp
Normal file
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/HTML/TextTrack.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(TextTrack);
|
||||
|
||||
JS::NonnullGCPtr<TextTrack> TextTrack::create(JS::Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<TextTrack>(realm, realm);
|
||||
}
|
||||
|
||||
TextTrack::TextTrack(JS::Realm& realm)
|
||||
: DOM::EventTarget(realm)
|
||||
{
|
||||
}
|
||||
|
||||
TextTrack::~TextTrack() = default;
|
||||
|
||||
void TextTrack::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(TextTrack);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#dom-texttrack-kind
|
||||
Bindings::TextTrackKind TextTrack::kind()
|
||||
{
|
||||
return m_kind;
|
||||
}
|
||||
|
||||
void TextTrack::set_kind(Bindings::TextTrackKind kind)
|
||||
{
|
||||
m_kind = kind;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#dom-texttrack-label
|
||||
String TextTrack::label()
|
||||
{
|
||||
return m_label;
|
||||
}
|
||||
|
||||
void TextTrack::set_label(String label)
|
||||
{
|
||||
m_label = label;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#dom-texttrack-language
|
||||
String TextTrack::language()
|
||||
{
|
||||
return m_language;
|
||||
}
|
||||
|
||||
void TextTrack::set_language(String language)
|
||||
{
|
||||
m_language = language;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#handler-texttrack-oncuechange
|
||||
void TextTrack::set_oncuechange(WebIDL::CallbackType* event_handler)
|
||||
{
|
||||
set_event_handler_attribute(HTML::EventNames::cuechange, event_handler);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#handler-texttrack-oncuechange
|
||||
WebIDL::CallbackType* TextTrack::oncuechange()
|
||||
{
|
||||
return event_handler_attribute(HTML::EventNames::cuechange);
|
||||
}
|
||||
|
||||
Bindings::TextTrackKind text_track_kind_from_string(String value)
|
||||
{
|
||||
// https://html.spec.whatwg.org/multipage/media.html#attr-track-kind
|
||||
|
||||
if (value.is_empty() || value.equals_ignoring_ascii_case("subtitles"sv)) {
|
||||
return Bindings::TextTrackKind::Subtitles;
|
||||
}
|
||||
if (value.equals_ignoring_ascii_case("captions"sv)) {
|
||||
return Bindings::TextTrackKind::Captions;
|
||||
}
|
||||
if (value.equals_ignoring_ascii_case("descriptions"sv)) {
|
||||
return Bindings::TextTrackKind::Descriptions;
|
||||
}
|
||||
if (value.equals_ignoring_ascii_case("chapters"sv)) {
|
||||
return Bindings::TextTrackKind::Chapters;
|
||||
}
|
||||
if (value.equals_ignoring_ascii_case("metadata"sv)) {
|
||||
return Bindings::TextTrackKind::Metadata;
|
||||
}
|
||||
|
||||
return Bindings::TextTrackKind::Metadata;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue