blib/lib/HTML/Object/DOM/Element/Object.pm untested

filter: Statementstmt 0.0% 0 / 52 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 23 Podpod 0.0% 0 / 16 totaltotal 0.0% 0 / 102 CC 4 SCAR 12.4
CC
4
Cov
0%
form
12.0
init
6.0
BEGIN
2.0
CRAP 3.5
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/Element/Object.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::Object;
15 BEGIN
16 {
17 use strict;
18 use warnings;
19 warnings::register_categories( 'HTML::Object' );
20 use parent qw( HTML::Object::DOM::Element );
21 use vars qw( $VERSION );
22 use HTML::Object::DOM::Element::Shared qw( :object );
23 our $VERSION = 'v0.2.0';
24 };
25  
26 use strict;
27 use warnings;
28  
29 sub init
30 {
31 my $self = shift( @_ );
32 $self->{_init_strict_use_sub} = 1;
33 $self->SUPER::init( @_ ) || return( $self->pass_error );
34 $self->{tag} = 'object' if( !CORE::length( "$self->{tag}" ) );
35 return( $self );
36 }
37  
38 # Note: property align inherited
39  
40 # Note: property archive
41 sub archive : lvalue { return( shift->_set_get_property( 'archive', @_ ) ); }
42  
43 # Note: property border
44 sub border : lvalue { return( shift->_set_get_property( 'border', @_ ) ); }
45  
46 # Note: object method checkValidity inherited
47  
48 # Note: property code
49 sub code : lvalue { return( shift->_set_get_property( 'code', @_ ) ); }
50  
51 # Note: property codeBase
52 sub codeBase : lvalue { return( shift->_set_get_property( 'codebase', @_ ) ); }
53  
54 # Note: property codeType
55 sub codeType : lvalue { return( shift->_set_get_property( 'codetype', @_ ) ); }
56  
57 # Note: property contentDocument read-only
58 sub contentDocument : lvalue { return( shift->_set_get_object_lvalue( 'contentdocument', 'HTML::Object::DOM::Document', @_ ) ); }
59  
60 # Note: property contentWindow read-only
61 sub contentWindow : lvalue { return( shift->_set_get_object_lvalue( 'contentwindow', 'HTML::Object::DOM::WindowProxy', @_ ) ); }
62  
63 # Note: property data
64 sub data : lvalue { return( shift->_set_get_property( { attribute => 'data', is_uri => 1 }, @_ ) ); }
65  
66 # Note: property declare
67 sub declare : lvalue { return( shift->_set_get_property( { attribute => 'declare', is_boolean => 1 }, @_ ) ); }
68  
69 # Note: property form read-only
70 sub form
71 {
72 my $self = shift( @_ );
73 my $id = $self->attr( 'form' );
74 return if( !defined( $id ) || !CORE::length( "$id" ) );
75 my $root = $self->root;
76 return if( !$root );
77 my $form = $root->getElementById( $id );
78 return( $form );
79 }
80  
81 # Note: property height inherited
82  
83 # Note: property hspace
84 sub hspace : lvalue { return( shift->_set_get_property( 'hspace', @_ ) ); }
85  
86 # Note: property name inherited
87  
88 # Note: method setCustomValidity inherited
89  
90 # Note: property standby
91 sub standby : lvalue { return( shift->_set_get_property( 'standby', @_ ) ); }
92  
93 # Note: property type inherited
94  
95 # Note: property typemustmatch
96 sub typemustmatch : lvalue { return( shift->_set_get_property( { attribute => 'type', is_boolean => 1 }, @_ ) ); }
97  
98 # Note: property useMap inherited
99  
100 # Note: property validationMessage read-only inherited
101  
102 # Note: property validity read-only inherited
103  
104 # Note: property vspace
105 sub vspace : lvalue { return( shift->_set_get_property( 'vspace', @_ ) ); }
106  
107 # Note: property width inherited
108  
109 # Note: property willValidate read-only inherited
110  
111 1;
112 # NOTE: POD
113 __END__
114  
115 =encoding utf-8
116  
117 =head1 NAME
118  
119 HTML::Object::DOM::Element::Object - HTML Object DOM Object Class
120  
121 =head1 SYNOPSIS
122  
123 use HTML::Object::DOM::Element::Object;
124 my $object = HTML::Object::DOM::Element::Object->new ||
125 die( HTML::Object::DOM::Element::Object->error, "\n" );
126  
127 =head1 VERSION
128  
129 v0.2.0
130  
131 =head1 DESCRIPTION
132  
133 This interface provides special properties and methods (beyond those on the L<HTML::Object::Element> interface it also has available to it by inheritance) for manipulating the layout and presentation of C<<object>> element, representing external resources.
134  
135 It is now deprecated and similarly to L<<video>|HTML::Object::DOM::Element::Video> and L<<audio>|HTML::Object::DOM::Element::Audio> tags, HTML object tag was used to enable embedding multimedia files into the web page, such as audio, video, Flash, PDF, ActiveX, and Java Applets.
136  
137 <object width="300" height="200" data="https://example.org/some/where/image.png" type="image/png">Image not found.</object>
138  
139 <object data="document.pdf" width="500" height="350" type="application/pdf"></object>
140  
141 =head1 INHERITANCE
142  
143 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
144 | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Object |
145 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
146  
147 =head1 PROPERTIES
148  
149 Inherits properties from its parent L<HTML::Object::DOM::Element>
150  
151 =head2 align
152  
153 Is a string representing an enumerated property indicating alignment of the element's contents with respect to the surrounding context. The possible values are C<left>, C<right>, C<justify>, and C<center>.
154  
155 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/align>
156  
157 =head2 archive
158  
159 Is a string that reflects the archive HTML attribute, containing a list of archives for resources for this object.
160  
161 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/archive>
162  
163 =head2 border
164  
165 Is a string that reflects the border HTML attribute, specifying the width of a border around the object.
166  
167 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/border>
168  
169 =head2 code
170  
171 Is a string representing the name of an applet class file, containing either the applet's subclass, or the path to get to the class, including the class file itself.
172  
173 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/code>
174  
175 =head2 codeBase
176  
177 Is a string that reflects the codebase HTML attribute, specifying the base path to use to resolve relative URIs.
178  
179 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/codeBase>
180  
181 =head2 codeType
182  
183 Is a string that reflects the codetype HTML attribute, specifying the content type of the data.
184  
185 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/codeType>
186  
187 =head2 contentDocument
188  
189 Normally this is a read-only property, but under perl, you can set or get a L<HTML::Object::DOM::Document> object.
190  
191 Under JavaScript, this returns a L<Document|HTML::Object::DOM::Document> representing the active document of the object element's nested browsing context, if any; otherwise C<undef>.
192  
193 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/contentDocument>
194  
195 =head2 contentWindow
196  
197 Normally this returns C<undef> under perl, but you can set it to a L<HTML::Object::DOM::WindowProxy> object.
198  
199 Under JavaScript, this is a read-only property that returns a C<WindowProxy> representing the window proxy of the object element's nested browsing context, if any; otherwise C<undef>.
200  
201 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/contentWindow>
202  
203 =head2 data
204  
205 Sets or gets an L<URI> object.
206  
207 This returns a string, turned into an L<URI>, that reflects the data HTML attribute, specifying the address of a resource's data.
208  
209 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/data>
210  
211 =head2 declare
212  
213 Is a boolean value that reflects the declare HTML attribute, indicating that this is a declaration, not an instantiation, of the object.
214  
215 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/declare>
216  
217 =head2 form
218  
219 Read-only.
220  
221 Returns a L<HTML::Object::DOM::Element::Form> representing the object element's form owner, or C<undef> if there is not one.
222  
223 Example:
224  
225 <form action="/some/where/script.pl" id="form1">
226 Email: <input type="text" name="email" /><br />
227 <input type="submit" value="Submit" />
228 </form>
229  
230 <object form="form1" width="300" height="200" data="https://example.org/some/where/image.png" type="image/png">Image not found.</object>
231  
232 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/form>
233  
234 =head2 height
235  
236 Returns a string that reflects the height HTML attribute, specifying the displayed height of the resource in CSS pixels.
237  
238 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/height>
239  
240 =head2 hspace
241  
242 Is a long representing the horizontal space in pixels around the control.
243  
244 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/hspace>
245  
246 =head2 name
247  
248 Returns a string that reflects the name HTML attribute, specifying the name of the browsing context.
249  
250 Example:
251  
252 <object data="document.pdf" width="300" height="200" name="board_resolution">Alternate text.</object>
253  
254 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/name>
255  
256 =head2 standby
257  
258 Is a string that reflects the standby HTML attribute, specifying a message to display while the object loads.
259  
260 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/standby>
261  
262 =head2 type
263  
264 Is a string that reflects the type HTML attribute, specifying the MIME type of the resource.
265  
266 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/type>
267  
268 =head2 typemustmatch
269  
270 C<typemustmatch> indicates that the resource should only be embedded if the value of the type attribute matches with the type of the resource provided in the data attribute.
271  
272 <object data="flashFile.swf" type="image/png" width="550" height="450" typemustmatch></object>
273  
274 =head2 useMap
275  
276 Is a string that reflects the usemap HTML attribute, specifying a <map> element to use.
277  
278 Example:
279  
280 <img src="image.png" width="320" height="320" alt="Dinosaurs" usemap="#dinosaursmap" />
281  
282 <map name="dinosaursmap">
283 <area shape="rect" coords="34,44,270,350" alt="Pterodactyl" href="https://example.org/tag/Pterodactyl" />
284 <area shape="rect" coords="290,172,333,250" alt="Triceratop" href="https://example.org/tag/Triceratop" />
285 <area shape="circle" coords="337,300,44" alt="Tyrannosaurus" href="https://example.org/tag/Tyrannosaurus" />
286 </map>
287  
288 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/useMap>
289  
290 =head2 validationMessage
291  
292 Normally this is read-only, but under perl you can set whatever string value you want.
293  
294 Under JavaScript, this returns a string representing a localized message that describes the validation constraints that the control does not satisfy (if any). This is the empty string if the control is not a candidate for constraint validation (willValidate is false), or it satisfies its constraints.
295  
296 Example:
297  
298 my $String = HTMLObjectElement->validationMessage;
299  
300 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validationMessage>
301  
302 =head2 validity
303  
304 Read-only.
305  
306 Returns a L<HTML::Object::DOM::ValidityState> with the validity states that this element is in.
307  
308 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity>
309  
310 =head2 vspace
311  
312 Is a long representing the horizontal space in pixels around the control.
313  
314 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/vspace>
315  
316 =head2 width
317  
318 Is a string that reflects the width HTML attribute, specifying the displayed width of the resource in CSS pixels.
319  
320 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/width>
321  
322 =head2 willValidate
323  
324 Normally this is read-only, but under perl you can set whatever boolean value you want.
325  
326 Under JavaScript, this returns a boolean value that indicates whether the element is a candidate for constraint validation. Always false for L<HTML::Object::DOM::Element::Object> objects.
327  
328 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/willValidate>
329  
330 =head1 METHODS
331  
332 Inherits methods from its parent L<HTML::Object::DOM::Element>
333  
334 =head2 checkValidity
335  
336 Normally this is read-only, but under perl you can set whatever boolean value you want.
337  
338 Under JavaScript, this returns a boolean value that always is true, because object objects are never candidates for constraint validation.
339  
340 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/checkValidity>
341  
342 =head2 setCustomValidity
343  
344 Sets a custom validity message for the element. If this message is not the empty string, then the element is suffering from a custom validity error, and does not validate.
345  
346 Returns a L<scalar object|Module::Generic::Scalar>
347  
348 Example:
349  
350 use feature 'signatures';
351 sub validate( $inputID )
352 {
353 my $input = $doc->getElementById( $inputID );
354 my $validityState = $input->validity;
355  
356 if( $validityState->valueMissing )
357 {
358 $input->setCustomValidity( 'You gotta fill this out, yo!' );
359 }
360 elsif( $validityState->rangeUnderflow )
361 {
362 $input->setCustomValidity( 'We need a higher number!' );
363 }
364 elsif( $validityState->rangeOverflow )
365 {
366 $input->setCustomValidity( 'Thats too high!' );
367 }
368 else
369 {
370 $input->setCustomValidity( '' );
371 }
372 $input->reportValidity();
373 }
374  
375 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity>
376  
377 =head1 AUTHOR
378  
379 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
380  
381 =head1 SEE ALSO
382  
383 L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement>, L<Mozilla documentation on object element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object>
384  
385 =head1 COPYRIGHT & LICENSE
386  
387 Copyright(c) 2021 DEGUEST Pte. Ltd.
388  
389 All rights reserved
390  
391 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
392  
393 =cut