mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-01 08:48:49 +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
|
@ -1,12 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2020, the SerenityOS developers.
|
||||
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/HTMLTrackElementPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/HTMLTrackElement.h>
|
||||
#include <LibWeb/HTML/TextTrack.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -15,6 +18,7 @@ JS_DEFINE_ALLOCATOR(HTMLTrackElement);
|
|||
HTMLTrackElement::HTMLTrackElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: HTMLElement(document, move(qualified_name))
|
||||
{
|
||||
m_track = TextTrack::create(document.realm());
|
||||
}
|
||||
|
||||
HTMLTrackElement::~HTMLTrackElement() = default;
|
||||
|
@ -25,4 +29,19 @@ void HTMLTrackElement::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLTrackElement);
|
||||
}
|
||||
|
||||
void HTMLTrackElement::attribute_changed(FlyString const& name, Optional<String> const& value)
|
||||
{
|
||||
HTMLElement::attribute_changed(name, value);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#sourcing-out-of-band-text-tracks
|
||||
// As the kind, label, and srclang attributes are set, changed, or removed, the text track must update accordingly, as per the definitions above.
|
||||
if (name.equals_ignoring_ascii_case("kind"sv)) {
|
||||
m_track->set_kind(text_track_kind_from_string(value.value_or({})));
|
||||
} else if (name.equals_ignoring_ascii_case("label"sv)) {
|
||||
m_track->set_label(value.value_or({}));
|
||||
} else if (name.equals_ignoring_ascii_case("srclang"sv)) {
|
||||
m_track->set_language(value.value_or({}));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue