mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-04 00:27:47 +00:00
LibWeb: Implement VTTCue.position
This commit is contained in:
parent
8204143b08
commit
73a05f9163
Notes:
github-actions[bot]
2025-08-13 21:06:54 +00:00
Author: https://github.com/jamierocks
Commit: 73a05f9163
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5840
Reviewed-by: https://github.com/gmta ✅
3 changed files with 30 additions and 2 deletions
|
@ -53,7 +53,8 @@ WebIDL::ExceptionOr<GC::Ref<VTTCue>> VTTCue::construct_impl(JS::Realm& realm, do
|
|||
// 11. Let cue’s WebVTT cue line alignment be start alignment.
|
||||
cue->m_line_alignment = Bindings::LineAlignSetting::Start;
|
||||
|
||||
// FIXME: 12. Let cue’s WebVTT cue position be auto.
|
||||
// 12. Let cue’s WebVTT cue position be auto.
|
||||
cue->m_position = Bindings::AutoKeyword::Auto;
|
||||
|
||||
// 13. Let cue’s WebVTT cue position alignment be auto.
|
||||
cue->m_position_alignment = Bindings::PositionAlignSetting::Auto;
|
||||
|
@ -156,6 +157,26 @@ double VTTCue::computed_line()
|
|||
return n;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webvtt/#cue-computed-position
|
||||
double VTTCue::computed_position()
|
||||
{
|
||||
// 1. If the position is numeric between 0 and 100, then return the value of the position and abort these steps.
|
||||
// (Otherwise, the position is the special value auto.)
|
||||
if (m_position.has<double>() && m_position.get<double>() >= 0 && m_position.get<double>() <= 100)
|
||||
return m_position.get<double>();
|
||||
|
||||
// 2. If the cue text alignment is left, return 0 and abort these steps.
|
||||
if (m_text_alignment == Bindings::AlignSetting::Left)
|
||||
return 0;
|
||||
|
||||
// 3. If the cue text alignment is right, return 100 and abort these steps.
|
||||
if (m_text_alignment == Bindings::AlignSetting::Right)
|
||||
return 100;
|
||||
|
||||
// 4. Otherwise, return 50 and abort these steps.
|
||||
return 50;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webvtt/#cue-computed-position-alignment
|
||||
Bindings::PositionAlignSetting VTTCue::computed_position_alignment()
|
||||
{
|
||||
|
|
|
@ -50,6 +50,9 @@ public:
|
|||
Bindings::LineAlignSetting line_align() const { return m_line_alignment; }
|
||||
void set_line_align(Bindings::LineAlignSetting line_align) { m_line_alignment = line_align; }
|
||||
|
||||
LineAndPositionSetting position() const { return m_position; }
|
||||
void set_position(LineAndPositionSetting position) { m_position = position; }
|
||||
|
||||
Bindings::PositionAlignSetting position_align() const { return m_position_alignment; }
|
||||
void set_position_align(Bindings::PositionAlignSetting position_align) { m_position_alignment = position_align; }
|
||||
|
||||
|
@ -64,6 +67,7 @@ public:
|
|||
|
||||
protected:
|
||||
double computed_line();
|
||||
double computed_position();
|
||||
Bindings::PositionAlignSetting computed_position_alignment();
|
||||
|
||||
private:
|
||||
|
@ -87,6 +91,9 @@ private:
|
|||
// https://w3c.github.io/webvtt/#webvtt-cue-line-alignment
|
||||
Bindings::LineAlignSetting m_line_alignment { Bindings::LineAlignSetting::Start };
|
||||
|
||||
// https://w3c.github.io/webvtt/#webvtt-cue-position
|
||||
LineAndPositionSetting m_position { Bindings::AutoKeyword::Auto };
|
||||
|
||||
// https://w3c.github.io/webvtt/#webvtt-cue-position-alignment
|
||||
Bindings::PositionAlignSetting m_position_alignment { Bindings::PositionAlignSetting::Auto };
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ interface VTTCue : TextTrackCue {
|
|||
attribute boolean snapToLines;
|
||||
attribute LineAndPositionSetting line;
|
||||
attribute LineAlignSetting lineAlign;
|
||||
[FIXME] attribute LineAndPositionSetting position;
|
||||
attribute LineAndPositionSetting position;
|
||||
attribute PositionAlignSetting positionAlign;
|
||||
attribute double size;
|
||||
attribute AlignSetting align;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue