lib/HTML/Object/DOM/VideoTrackList.pm

filter: Statementstmt 38.8% 21 / 54 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 30.4% 7 / 23 Podpod 100% 10 / 10 totaltotal 32.7% 38 / 116 CC 12 SCAR 29.6
CC
12
Cov
27%
getTrackById
72.0
init
6.0
__ANON__
6.0
CRAP 19.2
« lib/HTML/Object/DOM/NodeIteratorShared.pm ↑ Summary blib/lib/HTML/Object/DOM/Document.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/VideoTrackList.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/28
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::VideoTrackList;
15 BEGIN
16 {
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' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶ use parent qw( HTML::Object::DOM::List );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 our $VERSION = 'v0.2.0';
23 };
24  
25 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 sub init
29 {
30 0 ▶ my $self = shift( @_ );
Subroutine init: not called CC=2 SCAR=17.9
Pod documented
31 0 $self->{selectedindex} = -1;
32 0 $self->{_init_strict_use_sub} = 1;
33 0 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 0 0 0
34 0 return( $self );
35 }
36  
37 sub addEventListener { return( shift->SUPER::addEventListener({
38 addtrack => {
39 add => { property => 'children', type => 'add', event => 'addtrack', callback => sub
40 {
41 0 ▶ my( $event, $ref ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
42 0 ▶ $event->track( $ref->{added} ) if( $ref->{added} );
Branch: 1 branch
BranchTrueFalseTotal
if $ref->{"added"} 0 0 0
43 }},
44 },
45 change => {
46 add => { property => 'selected', type => 'add', event => 'change' },
47 remove => { property => 'selected', type => 'remove', event => 'change' },
48 },
49 removetrack => {
50 remove => { property => 'children', type => 'remove', event => 'removetrack', callback => sub
51 {
52 0 ▶ my( $event, $ref ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
53 0 ▶ $event->track( $ref->{removed} ) if( $ref->{removed} );
Branch: 1 branch
BranchTrueFalseTotal
if $ref->{"removed"} 0 0 0
54 }},
55 },
56 0 ▶ }, @_ ) ); }
Subroutine addEventListener: not called CC=1 SCAR=6.9
Pod documented
57  
58 0 ▶sub children { return( shift->reset(@_)->_set_get_object_array_object({
Subroutine children: not called CC=1 SCAR=6.9
Pod documented
59 field => 'children',
60 callbacks =>
61 {
62 add => '_on_children_add',
63 remove => '_on_children_remove',
64 }
65 }, 'HTML::Object::Element', @_ ) ); }
66  
67 0 ▶sub forEach { return( shift->children->foreach( @_ ) ); }
Subroutine forEach: not called CC=1 SCAR=6.9
Pod documented
68  
69 sub getTrackById
70 {
71 0 ▶ my $self = shift( @_ );
Subroutine getTrackById: not called CC=8 SCAR=42.8
Pod documented
72 0 my $id = shift( @_ );
73 0 ▶ return if( !defined( $id ) || !CORE::length( "$id" ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id and length "$id" 0 0 0
Condition0%0/3
defined $id and length "$id"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $id and length "$id"
defined $id length "$id"
Truth table0%0/3
A and B
A= defined $idB= length "$id"
ABresult
0X0
100
111
74 0 foreach my $e ( @$self )
75 {
76 0 ▶ if( Scalar::Util::blessed( $e ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($e) and $e->isa("HTML::Object::DOM::Element::Track")) 0 0 0
Condition0%0/3
builtin::blessed($e) and $e->isa("HTML::Object::DOM::Element::Track")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($e) and $e->isa("HTML::Object::DOM::Element::Track")
builtin::blessed($e) $e->isa("HTML::Object::DOM::Element::Track")
Truth table0%0/3
A and B
A= builtin::blessed($e)B= $e->isa("HTML::Object::DOM::Element::Track")
ABresult
0X0
100
111
77 $e->isa( 'HTML::Object::DOM::Element::Track' ) )
78 {
79 0 my $e_id = $e->attr( 'id' );
80 0 ▶ return( $e ) if( defined( $e_id ) && $id eq $e_id );
Branch: 1 branch
BranchTrueFalseTotal
if defined $e_id and $id eq $e_id 0 0 0
Condition0%0/3
defined $e_id and $id eq $e_id
!ll&&!rl&&r
000
MC/DC0%0/2
defined $e_id and $id eq $e_id
defined $e_id $id eq $e_id
Truth table0%0/3
A and B
A= defined $e_idB= $id eq $e_id
ABresult
0X0
100
111
81 }
82 }
83 0 return;
84 }
85  
86 # Note: property length is inherited
87  
88 0 ▶sub onaddtrack : lvalue { return( shift->on( 'addtrack', @_ ) ); }
Subroutine onaddtrack: not called CC=1 SCAR=6.9
Pod documented
89  
90 0 ▶sub onchange : lvalue { return( shift->on( 'change', @_ ) ); }
Subroutine onchange: not called CC=1 SCAR=6.9
Pod documented
91  
92 0 ▶sub onremovetrack : lvalue { return( shift->on( 'removetrack', @_ ) ); }
Subroutine onremovetrack: not called CC=1 SCAR=6.9
Pod documented
93  
94 # Note: property
95 sub selectedIndex : lvalue { return( shift->_set_get_number({
96 0 ▶ field => 'selectedindex',
Subroutine selectedIndex: not called CC=1 SCAR=6.9
Pod documented
97 callbacks =>
98 {
99 add => '_on_selectedindex_change',
100 remove => '_on_selectedindex_change',
101 }
102 }, @_ ) ); }
103  
104 # Note: property selectedindex
105 0 ▶sub selectedindex : lvalue { return( shift->selectedIndex( @_ ) ); }
Subroutine selectedindex: not called CC=1 SCAR=6.9
Pod documented
106  
107 0 ▶sub _on_children_add { return( shift->_trigger_event_for( addtrack => 'HTML::Object::DOM::TrackEvent' ) ); }
Subroutine _on_children_add: not called CC=1 SCAR=6.9
108  
109 0 ▶sub _on_children_remove { return( shift->_trigger_event_for( removetrack => 'HTML::Object::DOM::TrackEvent' ) ); }
Subroutine _on_children_remove: not called CC=1 SCAR=6.9
110  
111 0 ▶sub _on_selectedindex_change { return( shift->_trigger_event_for( change => 'HTML::Object::DOM::TrackEvent' ) ); }
Subroutine _on_selectedindex_change: not called CC=1 SCAR=6.9
112  
113 # Get called by HTML::Object::DOM::VideoTrack->selected
114 sub _update_selected
115 {
116 0 ▶ my $self = shift( @_ );
Subroutine _update_selected: not called CC=2 SCAR=17.9
117 0 my $track = shift( @_ );
118 0 my $pos = $self->children->index( $track );
119 0 ▶ $self->selectedIndex( $pos ) if( defined( $pos ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $pos 0 0 0
120 0 return( $self );
121 }
122  
123 1 1;
124 # NOTE: POD
125 __END__
« lib/HTML/Object/DOM/NodeIteratorShared.pm ↑ Summary blib/lib/HTML/Object/DOM/Document.pm »