| 1 | ##---------------------------------------------------------------------------- | ||||||||||||
| 2 | ## HTML Object - ~/lib/HTML/Object/DOM/TextTrack.pm | ||||||||||||
| 3 | ## Version v0.2.0 | ||||||||||||
| 4 | ## Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||
| 6 | ## Created 2021/12/27 | ||||||||||||
| 7 | ## Modified 2022/09/18 | ||||||||||||
| 8 | ## All rights reserved. | ||||||||||||
| 9 | ## | ||||||||||||
| 10 | ## | ||||||||||||
| 11 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||||
| 12 | ## under the same terms as Perl itself. | ||||||||||||
| 13 | ##---------------------------------------------------------------------------- | ||||||||||||
| 14 | package HTML::Object::DOM::TextTrack; | ||||||||||||
| 15 | BEGIN | ||||||||||||
| 16 | 1 | ▶ | { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | 1 | warnings::register_categories( 'HTML::Object' ); | |||||||||||
| 20 | 1 | ▶ | use parent qw( HTML::Object::DOM::MediaTrack ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 21 | 1 | ▶ | use vars qw( $VERSION ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | 1 | ▶ | use HTML::Object::Exception; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 23 | 1 | our $VERSION = 'v0.2.0'; | |||||||||||
| 24 | }; | ||||||||||||
| 25 | |||||||||||||
| 26 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 27 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 28 | |||||||||||||
| 29 | sub init | ||||||||||||
| 30 | 0 | ▶ | { | ||||||||||
|
Subroutine
init: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||
| 31 | 0 | my $self = shift( @_ ); | |||||||||||
| 32 | 0 | ▶ | return( $self->error({ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 33 | message => sprintf( "At least 1 argument required, but only %d passed", scalar( @_ ) ), | ||||||||||||
| 34 | class => 'HML::Object::TypeError', | ||||||||||||
| 35 | }) ) if( scalar( @_ ) < 3 ); | ||||||||||||
| 36 | 0 | my $kind = shift( @_ ); | |||||||||||
| 37 | 0 | my $label = shift( @_ ); | |||||||||||
| 38 | 0 | my $lang = shift( @_ ); | |||||||||||
| 39 | 0 | ▶ | return( $self->error({ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 40 | message => "kind argument provided is not a string", | ||||||||||||
| 41 | class => 'HML::Object::TypeError', | ||||||||||||
| 42 | }) ) if( $kind !~ /^\w+$/ ); | ||||||||||||
| 43 | 0 | $self->{cues} = []; | |||||||||||
| 44 | # If set, this should be the same as the id in HTML::Object::DOM::Element::Track | ||||||||||||
| 45 | 0 | $self->{id} = undef; | |||||||||||
| 46 | 0 | $self->{kind} = $kind; | |||||||||||
| 47 | 0 | $self->{label} = $label; | |||||||||||
| 48 | 0 | $self->{language} = $lang; | |||||||||||
| 49 | 0 | $self->{mode} = 'hidden'; | |||||||||||
| 50 | 0 | $self->{_init_strict_use_sub} = 1; | |||||||||||
| 51 | 0 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 52 | 0 | return( $self ); | |||||||||||
| 53 | } | ||||||||||||
| 54 | |||||||||||||
| 55 | # Note: property | ||||||||||||
| 56 | 0 | ▶ | sub activeCues { return( shift->_set_get_object( 'activecues', 'HTML::Object::DOM::TextTrackCueList', @_ ) ); } | ||||||||||
|
Subroutine
activeCues: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 57 | |||||||||||||
| 58 | sub addCue | ||||||||||||
| 59 | 0 | ▶ | { | ||||||||||
|
Subroutine
addCue: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||
| 60 | 0 | my $self = shift( @_ ); | |||||||||||
| 61 | 0 | ▶ | my $cue = shift( @_ ) || return( $self->error({ | ||||||||||
|
Condition0%0/2
shift @_ || (return $self->error({'message', 'No cue object was provided.', 'class', 'HTML::Object::TypeError'}))
MC/DC0%0/1
shift @_ || (return $self->error({'message', 'No cue object was provided.', 'class', 'HTML::Object::TypeError'}))
shift @_
Truth table0%0/2
A
A= shift @_
| |||||||||||||
| 62 | message => "No cue object was provided.", | ||||||||||||
| 63 | class => 'HTML::Object::TypeError', | ||||||||||||
| 64 | }) ); | ||||||||||||
| 65 | # HTML::Object::DOM::VTTCue inherits from HTML::Object::DOM::TextTrackCue | ||||||||||||
| 66 | 0 | ▶ | return( $self->error({ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 67 | message => "Cue provided is not a HTML::Object::DOM::TextTrackCue object.", | ||||||||||||
| 68 | class => 'HTML::Object::TypeError', | ||||||||||||
| 69 | }) ) if( !$self->_is_a( $cue => 'HTML::Object::DOM::TextTrackCue' ) ); | ||||||||||||
| 70 | 0 | my $cues = $self->cues; | |||||||||||
| 71 | 0 | my $pos = $cues->pos( $cue ); | |||||||||||
| 72 | 0 | ▶ | if( !defined( $cue ) ) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 73 | { | ||||||||||||
| 74 | 0 | $cue->track( $self ); | |||||||||||
| 75 | 0 | $cues->push( $cue ); | |||||||||||
| 76 | } | ||||||||||||
| 77 | 0 | return( $self ); | |||||||||||
| 78 | } | ||||||||||||
| 79 | |||||||||||||
| 80 | # Note: property | ||||||||||||
| 81 | 0 | ▶ | sub cues { return( shift->_set_get_object_array_object( 'cues', 'HTML::Object::DOM::TextTrackCueList', @_ ) ); } | ||||||||||
|
Subroutine
cues: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 82 | |||||||||||||
| 83 | # Note: property id inherited | ||||||||||||
| 84 | |||||||||||||
| 85 | # Note: property | ||||||||||||
| 86 | 0 | ▶ | sub inBandMetadataTrackDispatchType : lvalue { return( shift->_set_get_scalar_as_object( 'inbandmetadatatrackdispatchtype', @_ ) ); } | ||||||||||
|
Subroutine
inBandMetadataTrackDispatchType: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 87 | |||||||||||||
| 88 | # Note: property kind inherited | ||||||||||||
| 89 | |||||||||||||
| 90 | # Note: property label inherited | ||||||||||||
| 91 | |||||||||||||
| 92 | # Note: property language inherited | ||||||||||||
| 93 | |||||||||||||
| 94 | # Note: property | ||||||||||||
| 95 | 0 | ▶ | sub mode : lvalue { return( shift->_set_get_scalar_as_object( 'mode', @_ ) ); } | ||||||||||
|
Subroutine
mode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 96 | |||||||||||||
| 97 | # Note: method parent is used and inherited from HTML::Object::Element via HTML::Object::EventTarget | ||||||||||||
| 98 | |||||||||||||
| 99 | sub removeCue | ||||||||||||
| 100 | 0 | ▶ | { | ||||||||||
|
Subroutine
removeCue: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||
| 101 | 0 | my $self = shift( @_ ); | |||||||||||
| 102 | 0 | ▶ | my $cue = shift( @_ ) || return( $self->error({ | ||||||||||
|
Condition0%0/2
shift @_ || (return $self->error({'message', 'No cue object was provided.', 'class', 'HTML::Object::TypeError'}))
MC/DC0%0/1
shift @_ || (return $self->error({'message', 'No cue object was provided.', 'class', 'HTML::Object::TypeError'}))
shift @_
Truth table0%0/2
A
A= shift @_
| |||||||||||||
| 103 | message => "No cue object was provided.", | ||||||||||||
| 104 | class => 'HTML::Object::TypeError', | ||||||||||||
| 105 | }) ); | ||||||||||||
| 106 | 0 | ▶ | return( $self->error({ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 107 | message => "Cue provided is not a HTML::Object::DOM::TextTrackCue object.", | ||||||||||||
| 108 | class => 'HTML::Object::TypeError', | ||||||||||||
| 109 | }) ) if( !$self->_is_a( $cue => 'HTML::Object::DOM::TextTrackCue' ) ); | ||||||||||||
| 110 | 0 | my $cues = $self->cues; | |||||||||||
| 111 | 0 | my $pos = $cues->pos( $cue ); | |||||||||||
| 112 | 0 | ▶ | if( defined( $pos ) ) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 113 | { | ||||||||||||
| 114 | 0 | $cues->splice( $pos, 1 ); | |||||||||||
| 115 | 0 | $cue->track( undef ); | |||||||||||
| 116 | 0 | return( $cue ); | |||||||||||
| 117 | } | ||||||||||||
| 118 | 0 | return; | |||||||||||
| 119 | } | ||||||||||||
| 120 | |||||||||||||
| 121 | 1 | 1; | |||||||||||
| 122 | # NOTE: POD | ||||||||||||
| 123 | __END__ | ||||||||||||