File Coverage

lib/HTML/Object/DOM/Element/Canvas.pm
Criterion Covered Total %
statement 22 37 59.4
branch 0 4 0.0
condition n/a
subroutine 8 19 42.1
pod 8 11 72.7
total 38 71 53.5


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## HTML Object - ~/lib/HTML/Object/DOM/Element/Canvas.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::Canvas;
15             BEGIN
16             {
17 1     1   1096 use strict;
  1         3  
  1         29  
18 1     1   4 use warnings;
  1         4  
  1         39  
19 1     1   4 use parent qw( HTML::Object::DOM::Element );
  1         2  
  1         8  
20 1     1   77 use vars qw( $VERSION );
  1         15  
  1         47  
21 1     1   6 use HTML::Object::DOM::Element::Shared qw( :canvas );
  1         2  
  1         141  
22 1     1   18 our $VERSION = 'v0.2.0';
23             };
24              
25 1     1   11 use strict;
  1         2  
  1         36  
26 1     1   6 use warnings;
  1         9  
  1         455  
27              
28             sub init
29             {
30 0     0 1   my $self = shift( @_ );
31 0           $self->{_init_strict_use_sub} = 1;
32 0 0         $self->SUPER::init( @_ ) || return( $self->pass_error );
33 0 0         $self->{tag} = 'canvas' if( !CORE::length( "$self->{tag}" ) );
34 0           return( $self );
35             }
36              
37 0     0 1   sub captureStream { return; }
38              
39 0     0 1   sub getContext { return; }
40              
41             # Note: property height is inherited
42              
43             # Note: property
44 0     0 1   sub mozOpaque : lvalue { return( shift->_set_get_property( { attribute => 'moz-opaque', is_boolean => 1 }, @_ ) ); }
45              
46             # Note: property
47 0     0 1   sub mozPrintCallback : lvalue { return( shift->_set_get_code( 'mozprintcallback', @_ ) ); }
48              
49 0     0 0   sub onwebglcontextcreationerror : lvalue { return( shift->on( 'webglcontextcreationerror', @_ ) ); }
50              
51 0     0 0   sub onwebglcontextlost : lvalue { return( shift->on( 'webglcontextlost', @_ ) ); }
52              
53 0     0 0   sub onwebglcontextrestored : lvalue { return( shift->on( 'webglcontextrestored', @_ ) ); }
54              
55 0     0 1   sub toBlob { return; }
56              
57 0     0 1   sub toDataURL { return; }
58              
59 0     0 1   sub transferControlToOffscreen { return; }
60              
61             # Note: property width is inherited
62              
63             1;
64             # NOTE: POD
65             __END__
66              
67             =encoding utf-8
68              
69             =head1 NAME
70              
71             HTML::Object::DOM::Element::Canvas - HTML Object DOM Canvas Class
72              
73             =head1 SYNOPSIS
74              
75             use HTML::Object::DOM::Element::Canvas;
76             my $canvas = HTML::Object::DOM::Element::Canvas->new ||
77             die( HTML::Object::DOM::Element::Canvas->error, "\n" );
78              
79             =head1 VERSION
80              
81             v0.2.0
82              
83             =head1 DESCRIPTION
84              
85             This interface provides properties and methods that are used for the C<<canvas>> element. However, since this is a perl framework, there is no such capability and it is provided here only to implement the properties and methods as accessors.
86              
87             This interface also inherits the properties and methods of the L<HTML::Object::Element> interface.
88              
89             =head1 INHERITANCE
90              
91             +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
92             | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Canvas |
93             +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
94              
95             =head1 PROPERTIES
96              
97             Inherits properties from its parent L<HTML::Object::DOM::Element>
98              
99             The description provided here is from Mozilla documentation.
100              
101             =head2 height
102              
103             The height HTML attribute of the C<<canvas>> element is a positive integer reflecting the number of logical pixels (or RGBA values) going down one column of the canvas. When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 150 is used. If no [separate] CSS height is assigned to the C<<canvas>>, then this value will also be used as the height of the canvas in the length-unit CSS Pixel.
104              
105             Example:
106              
107             <canvas id="canvas" width="300" height="300"></canvas>
108              
109             my $canvas = $doc->getElementById('$canvas');
110             say( $canvas->height ); # 300
111              
112             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/height>
113              
114             =head2 mozOpaque
115              
116             Is a boolean value reflecting the moz-opaque HTML attribute of the <canvas> element. It lets the canvas know whether or not translucency will be a factor. If the canvas knows there's no translucency, painting performance can be optimized. This is only supported in Mozilla-based browsers; use the standardized canvas.getContext('2d', { alpha: false }) instead.
117              
118             Example:
119              
120             <canvas id="canvas" width="300" height="300" moz-opaque></canvas>
121              
122             my $canvas = $doc->getElementById('$canvas');
123             say( $canvas->mozOpaque ); # true
124             # deactivate it
125             $canvas->mozOpaque = 0;
126              
127             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/mozOpaque>
128              
129             =head2 mozPrintCallback
130              
131             Is a function that is initially C<undef>. Web content can set this to a JavaScript function that will be called when the canvas is to be redrawn while the page is being printed. When called, the callback is passed a C<printState> object that implements the C<MozCanvasPrintState> interface. The callback can get the context to draw to from the C<printState> object and must then call C<done()> on it when finished. The purpose of C<mozPrintCallback> is to obtain a higher resolution rendering of the canvas at the resolution of the printer being used. L<See this blog post|https://blog.mozilla.org/labs/2012/09/a-new-way-to-control-printing-output/>.
132              
133             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/mozPrintCallback>
134              
135             =head2 width
136              
137             The width HTML attribute of the <canvas> element is a positive integer reflecting the number of logical pixels (or RGBA values) going across one row of the canvas. When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 300 is used. If no [separate] CSS width is assigned to the <canvas>, then this value will also be used as the width of the canvas in the length-unit CSS Pixel.
138              
139             Example:
140              
141             <canvas id="canvas" width="300" height="300"></canvas>
142              
143             my $canvas = $doc->getElementById('$canvas');
144             say( $canvas->width ); # 300
145              
146             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/width>
147              
148             =head1 METHODS
149              
150             Inherits methods from its parent L<HTML::Object::DOM::Element>
151              
152             Keep in mind that none of those methods do anything and they all return C<undef>. The description provided here is from Mozilla documentation.
153              
154             =head2 captureStream
155              
156             Returns C<undef> since this feature is unavailable under perl.
157              
158             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/captureStream>
159              
160             =head2 getContext
161              
162             Returns C<undef> since this feature is unavailable under perl.
163              
164             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext>
165              
166             =head2 toBlob
167              
168             Returns C<undef> since this feature is unavailable under perl.
169              
170             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob>
171              
172             =head2 toDataURL
173              
174             Returns C<undef> since this feature is unavailable under perl.
175              
176             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL>
177              
178             =head2 transferControlToOffscreen
179              
180             Returns C<undef> since this feature is unavailable under perl.
181              
182             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen>
183              
184             =head1 AUTHOR
185              
186             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
187              
188             =head1 SEE ALSO
189              
190             L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement>, L<Mozilla documentation on canvas element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas>
191              
192             =head1 COPYRIGHT & LICENSE
193              
194             Copyright(c) 2021 DEGUEST Pte. Ltd.
195              
196             All rights reserved
197              
198             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
199              
200             =cut