File Coverage

lib/HTML/Object/DOM/Element/Object.pm
Criterion Covered Total %
statement 22 47 46.8
branch 0 8 0.0
condition 0 3 0.0
subroutine 8 23 34.7
pod 15 15 100.0
total 45 96 46.8


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