| 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 | 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::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 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 34 | 0 | return( $self ); | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub addEventListener { return( shift->SUPER::addEventListener({ | ||||||||||||||||||||||||||
|
Subroutine
addEventListener: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | addtrack => { | ||||||||||||||||||||||||||||
| 39 | add => { property => 'children', type => 'add', event => 'addtrack', callback => sub | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 41 | 0 | my( $event, $ref ) = @_; | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | $event->track( $ref->{added} ) if( $ref->{added} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 52 | 0 | my( $event, $ref ) = @_; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | $event->track( $ref->{removed} ) if( $ref->{removed} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | }}, | ||||||||||||||||||||||||||||
| 55 | }, | ||||||||||||||||||||||||||||
| 56 | 0 | }, @_ ) ); } | |||||||||||||||||||||||||||
| 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 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getTrackById: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||
| 72 | 0 | my $id = shift( @_ ); | |||||||||||||||||||||||||||
| 73 | 0 | ▶ | return if( !defined( $id ) || !CORE::length( "$id" ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $id and length "$id"
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"
| |||||||||||||||||||||||||||||
| 74 | 0 | foreach my $e ( @$self ) | |||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if( Scalar::Util::blessed( $e ) && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($e) and $e->isa("HTML::Object::DOM::Element::Track")
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")
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
defined $e_id and $id eq $e_id
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
| |||||||||||||||||||||||||||||
| 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 | 0 | ▶ | sub selectedIndex : lvalue { return( shift->_set_get_number({ | ||||||||||||||||||||||||||
|
Subroutine
selectedIndex: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | 0 | field => 'selectedindex', | |||||||||||||||||||||||||||
| 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 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_update_selected: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 116 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||
| 117 | 0 | my $track = shift( @_ ); | |||||||||||||||||||||||||||
| 118 | 0 | my $pos = $self->children->index( $track ); | |||||||||||||||||||||||||||
| 119 | 0 | ▶ | $self->selectedIndex( $pos ) if( defined( $pos ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 0 | return( $self ); | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 1 | 1; | |||||||||||||||||||||||||||
| 124 | # NOTE: POD | ||||||||||||||||||||||||||||
| 125 | __END__ | ||||||||||||||||||||||||||||