lib/HTML/Object/DOM/Element/Source.pm

filter: Statementstmt 75.0% 24 / 32 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 8 / 12 Podpod 100% 4 / 4 totaltotal 69.2% 36 / 52 CC 3 SCAR 12.7
CC
3
Cov
67%
init
12.0
media
2.0
sizes
2.0
CRAP 3.6
« lib/HTML/Object/DOM/Element/Meter.pm ↑ Summary lib/HTML/Object/DOM/Element/Dialog.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/Element/Source.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/23
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::Element::Source;
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::Element );
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::DOM::Element::Shared qw( :source );
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 {
31 0 ▶ my $self = shift( @_ );
Subroutine init: not called CC=3 SCAR=24.8
Pod documented
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 ▶ $self->{tag} = 'source' if( !CORE::length( "$self->{tag}" ) );
Branch: 1 branch
BranchTrueFalseTotal
unless length qq[$self->{"tag"}] 0 0 0
35 0 return( $self );
36 }
37  
38 # Note: property media
39 0 ▶sub media : lvalue { return( shift->_set_get_property( 'media', @_ ) ); }
Subroutine media: not called CC=1 SCAR=6.9
Pod documented
40  
41 # Note: property sizes
42 0 ▶sub sizes : lvalue { return( shift->_set_get_property( 'sizes', @_ ) ); }
Subroutine sizes: not called CC=1 SCAR=6.9
Pod documented
43  
44 # Note: property src inherited
45  
46 # Note: property srcset
47 0 ▶sub srcset : lvalue { return( shift->_set_get_property( 'srcset', @_ ) ); }
Subroutine srcset: not called CC=1 SCAR=6.9
Pod documented
48  
49 # Note: property type inherited
50  
51 1 1;
52 # NOTE: POD
53 __END__
54  
55 =encoding utf-8
56  
57 =head1 NAME
58  
59 HTML::Object::DOM::Element::Source - HTML Object DOM Source Class
60  
61 =head1 SYNOPSIS
62  
63 use HTML::Object::DOM::Element::Source;
64 my $source = HTML::Object::DOM::Element::Source->new ||
65 die( HTML::Object::DOM::Element::Source->error, "\n" );
66  
67 =head1 VERSION
68  
69 v0.2.0
70  
71 =head1 DESCRIPTION
72  
73 This interface provides special properties (beyond the regular L<HTML::Object::DOM::Element> object interface it also has available to it by inheritance) for manipulating <source> elements.
74  
75 =head1 INHERITANCE
76  
77 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
78 | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Source |
79 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
80  
81 =head1 PROPERTIES
82  
83 Inherits properties from its parent L<HTML::Object::DOM::Element>
84  
85 =head2 media
86  
87 Is a string reflecting the media L<HTML attribute|HTML::Object::DOM::Attribute>, containing the intended type of the media resource.
88  
89 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLSourceElement/media>
90  
91 =head2 sizes
92  
93 The sizes HTML attribute on an C<source> element specifies different image widths.
94  
95 These widths are tied to browser conditions which helps create responsive images.
96  
97 Example:
98  
99 <picture>
100 <source srcset="/some/where/image-sm.jpg 120w,
101 /some/where/image.jpg 193w,
102 /some/where/image-lg.jpg 278w"
103 sizes="(max-width: 710px) 120px,
104 (max-width: 991px) 193px,
105 278px" />
106 <img src="/some/where/image-lg.jpg" alt="Some image" />
107 </picture>
108  
109 This means that:
110  
111 =over 4
112  
113 =item * A small image is used with a screen between 0 - 710px. The layout width is 120px.
114  
115 =item * A medium image is used with a screen between 711px - 991px. The layout width is 193px.
116  
117 =item * A large image is used with a screen 992px and larger. The layout width is 278px.
118  
119 =back
120  
121 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLSourceElement/sizes>
122  
123 =head2 src
124  
125 Is a string reflecting the src L<HTML attribute|HTML::Object::DOM::Attribute>, containing the URL for the media resource. The C<src> property has a meaning only when the associated C<source> element is nested in a media element that is a L<video|HTML::Object::DOM::Element::Video> or an L<audio|HTML::Object::DOM::Element::Audio> element. It has no meaning and is ignored when it is nested in a C<picture> element.
126  
127 Note: If the C<src> property is updated (along with any siblings), the parent L<HTML::Object::DOM::Element::Media>'s load method should be called when done, since C<source> elements are not re-scanned automatically.
128  
129 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLSourceElement/src>
130  
131 =head2 srcset
132  
133 Is a string reflecting the srcset L<HTML attribute|HTML::Object::DOM::Attribute>, containing a list of candidate images, separated by a comma (',', U+002C COMMA). A candidate image is a URL followed by a 'w' with the width of the images, or an 'x' followed by the pixel density.
134  
135 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLSourceElement/srcset>
136  
137 =head2 type
138  
139 Is a string reflecting the type L<HTML attribute|HTML::Object::DOM::Attribute>, containing the type of the media resource.
140  
141 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLSourceElement/type>
142  
143 =head1 METHODS
144  
145 Inherits methods from its parent L<HTML::Object::DOM::Element>
146  
147 =head1 AUTHOR
148  
149 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
150  
151 =head1 SEE ALSO
152  
153 L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLSourceElement>, L<Mozilla documentation on source element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source>
154  
155 =head1 COPYRIGHT & LICENSE
156  
157 Copyright(c) 2021 DEGUEST Pte. Ltd.
158  
159 All rights reserved
160  
161 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
162  
163 =cut
« lib/HTML/Object/DOM/Element/Meter.pm ↑ Summary lib/HTML/Object/DOM/Element/Dialog.pm »