Files
ladybird/Libraries/LibWeb/HTML/TextTrackCue.cpp
Shannon Booth fd44da6829 LibWeb/Bindings: Emit one bindings header and cpp per IDL
Previously, the LibWeb bindings generator would output multiple per
interface files like Prototype/Constructor/Namespace/GlobalMixin
depending on the contents of that IDL file.

This complicates the build system as it means that it does not know
what files will be generated without knowledge of the contents of that
IDL file.

Instead, for each IDL file only generate a single Bindings/<IDLFile>.h
and Bindings/<IDLFile>.cpp.
2026-04-21 07:36:13 +02:00

90 lines
3.0 KiB
C++

/*
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Math.h>
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/TextTrackCue.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/HTML/TextTrackCue.h>
namespace Web::HTML {
GC_DEFINE_ALLOCATOR(TextTrackCue);
TextTrackCue::TextTrackCue(JS::Realm& realm, GC::Ptr<TextTrack> track)
: DOM::EventTarget(realm)
, m_track(track)
{
}
TextTrackCue::~TextTrackCue() = default;
void TextTrackCue::initialize(JS::Realm& realm)
{
WEB_SET_PROTOTYPE_FOR_INTERFACE(TextTrackCue);
Base::initialize(realm);
}
void TextTrackCue::visit_edges(JS::Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_track);
}
// https://html.spec.whatwg.org/multipage/media.html#dom-texttrackcue-starttime
void TextTrackCue::set_start_time(double start_time)
{
// On setting, the text track cue start time must be set to the new value, interpreted in seconds;
m_start_time = start_time;
// FIXME: then, if the TextTrackCue object's text track cue is in a text track's list of cues, and that text track is in a media
// element's list of text tracks, and the media element's show poster flag is not set, then run the time marches on steps
// for that media element.
}
// https://html.spec.whatwg.org/multipage/media.html#dom-texttrackcue-endtime
WebIDL::ExceptionOr<void> TextTrackCue::set_end_time(double end_time)
{
// On setting, if the new value is negative Infinity or a Not-a-Number (NaN) value, then throw a TypeError exception.
if (end_time == -AK::Infinity<double> || isnan(end_time))
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Value is negative infinity or NaN"_string };
// Otherwise, the text track cue end time must be set to the new value.
m_end_time = end_time;
// FIXME: Then, if the TextTrackCue object's text track cue is in a text track's list of cues, and that text track is in a media
// element's list of text tracks, and the media element's show poster flag is not set, then run the time marches on steps
// for that media element.
return {};
}
// https://html.spec.whatwg.org/multipage/media.html#handler-texttrackcue-onenter
WebIDL::CallbackType* TextTrackCue::onenter()
{
return event_handler_attribute(HTML::EventNames::enter);
}
// https://html.spec.whatwg.org/multipage/media.html#handler-texttrackcue-onenter
void TextTrackCue::set_onenter(WebIDL::CallbackType* event_handler)
{
set_event_handler_attribute(HTML::EventNames::enter, event_handler);
}
// https://html.spec.whatwg.org/multipage/media.html#handler-texttrackcue-onexit
WebIDL::CallbackType* TextTrackCue::onexit()
{
return event_handler_attribute(HTML::EventNames::exit);
}
// https://html.spec.whatwg.org/multipage/media.html#handler-texttrackcue-onexit
void TextTrackCue::set_onexit(WebIDL::CallbackType* event_handler)
{
set_event_handler_attribute(HTML::EventNames::exit, event_handler);
}
}