File Coverage

lib/HTML/Object/DOM/Element/Area.pm
Criterion Covered Total %
statement 22 37 59.4
branch 0 6 0.0
condition n/a
subroutine 8 14 57.1
pod 5 5 100.0
total 35 62 56.4


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## HTML Object - ~/lib/HTML/Object/DOM/Element/Area.pm
3             ## Version v0.2.0
4             ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2021/12/26
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::Area;
15             BEGIN
16             {
17 1     1   1028 use strict;
  1         2  
  1         32  
18 1     1   4 use warnings;
  1         2  
  1         29  
19 1     1   6 use parent qw( HTML::Object::DOM::Element );
  1         1  
  1         5  
20 1     1   62 use vars qw( $VERSION );
  1         2  
  1         38  
21 1     1   6 use HTML::Object::DOM::Element::Shared qw( :area );
  1         1  
  1         162  
22 1     1   20 our $VERSION = 'v0.2.0';
23             };
24              
25 1     1   5 use strict;
  1         2  
  1         19  
26 1     1   4 use warnings;
  1         2  
  1         236  
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} = 'area' if( !$self->tag );
34 0           $self->{uri} = '';
35             $self->_set_get_internal_attribute_callback( rel => sub
36             {
37 0     0     my( $this, $val ) = @_;
38 0           my $list;
39 0 0         return if( !( $list = $this->{_rel_list} ) );
40             # $list->debug( $self->debug );
41 0           $list->update( $val );
42 0           });
43 0           return( $self );
44             }
45              
46             # Note: property accessKey inherited
47              
48             # Note: property alt inherited
49              
50             # Note: property
51 0     0 1   sub coords : lvalue { return( shift->_set_get_property( 'coords', @_ ) ); }
52              
53             # Note: property download inherited
54              
55             # Note: property hash inherited
56              
57             # Note: property host inherited
58              
59             # Note: property hostname inherited
60              
61             # Note: property href inherited
62              
63             # Note: property
64 0     0 1   sub noHref : lvalue { return( shift->_set_get_property( { attribute => 'nohref', is_boolean => 1 }, @_ ) ); }
65              
66             # Note: property origin inherited
67              
68             # Note: property password inherited
69              
70             # Note: property pathname inherited
71              
72             # Note: property port inherited
73              
74             # Note: property protocol inherited
75              
76             # Note: property referrerPolicy inherited
77              
78             # Note: property rel inherited
79              
80             # Note: property relList inherited
81              
82             # Note: property search inherited
83              
84             # Note: property
85 0     0 1   sub shape : lvalue { return( shift->_set_get_property( 'shape', @_ ) ); }
86              
87             # Note: tabIndex is inherited from HTML::Object::DOM::Element
88              
89             # Note: property target inherited
90              
91 0     0 1   sub toString { return( shift->attr( 'href' ) ); }
92              
93             # Note: property username inherited
94              
95             1;
96             # NOTE: POD
97             __END__
98              
99             =encoding utf-8
100              
101             =head1 NAME
102              
103             HTML::Object::DOM::Element::Area - HTML Object DOM Area Class
104              
105             =head1 SYNOPSIS
106              
107             use HTML::Object::DOM::Element::Area;
108             my $area = HTML::Object::DOM::Element::Area->new ||
109             die( HTML::Object::DOM::Element::Area->error, "\n" );
110              
111             =head1 VERSION
112              
113             v0.2.0
114              
115             =head1 DESCRIPTION
116              
117             This interface provides special properties and methods (beyond those of the regular object L<HTML::Object::Element> interface it also has available to it by inheritance) for manipulating the layout and presentation of C<<area>> elements.
118              
119             =head1 INHERITANCE
120              
121             +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +----------------------------------+
122             | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Area |
123             +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +----------------------------------+
124              
125             =head1 PROPERTIES
126              
127             Inherits properties from its parent L<HTML::Object::DOM::Element>
128              
129             =head2 accessKey
130              
131             Is a string containing a single character that switches input focus to the control.
132              
133             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/accessKey>
134              
135             =head2 alt
136              
137             Is a string that reflects the alt HTML attribute, containing alternative text for the element.
138              
139             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/alt>
140              
141             =head2 coords
142              
143             Is a string that reflects the coords HTML attribute, containing coordinates to define the hot-spot region.
144              
145             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/coords>
146              
147             =head2 download
148              
149             Is a string indicating that the linked resource is intended to be downloaded rather than displayed in the browser. The value represent the proposed name of the file. If the name is not a valid filename of the underlying OS, browser will adapt it.
150              
151             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/download>
152              
153             =head2 hash
154              
155             Is a string containing the fragment identifier (including the leading hash mark (#)), if any, in the referenced URL.
156              
157             Example:
158              
159             <map name="infographic">
160             <area id="circle" shape="circle" coords="130,136,60"
161             href="https://example.org/#ExampleSection" alt="Documentation" />
162             </map>
163              
164             <img usemap="#infographic" src="/some/where/info.png" alt="Infographic" />
165              
166             my $area = $doc->getElementById('circle');
167             $area->hash; # returns '#ExampleSection'
168              
169             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/hash>
170              
171             =head2 host
172              
173             Is a string containing the hostname and port (if it's not the default port) in the referenced URL.
174              
175             Example:
176              
177             my $area = $doc->createElement('area');
178              
179             $area->href = 'https://example.org/some/where';
180             $area->host == 'example.org';
181              
182             $area->href = "https://example.org:443/some/where";
183             $area->host == 'example.org';
184             # The port number is not included because 443 is the scheme's default port
185              
186             $area->href = "https://example.org:4097/some/where";
187             $area->host == 'example.org:4097';
188              
189             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/host>
190              
191             =head2 hostname
192              
193             Is a string containing the hostname in the referenced URL.
194              
195             Example:
196              
197             # An <area id="myArea" href="https://example.org/some/where"> element is in the document
198             my $area = $doc->getElementById('myArea');
199             $area->hostname; # returns 'example.org'
200              
201             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/hostname>
202              
203             =head2 href
204              
205             Is a string containing that reflects the href HTML attribute, containing a valid URL of a linked resource.
206              
207             Example:
208              
209             # An <area id="myArea" href="https://example.org/some/where"> element is in the document
210             my $area = $doc->getElementById("myArea");
211             $area->href; # returns 'https://example.org/some/where'
212              
213             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/href>
214              
215             =head2 noHref
216              
217             Is a boolean flag indicating if the area is inactive (true) or active (false). This is an HTML attribute.
218              
219             Example:
220              
221             <map name="SampleMap">
222             <area shape="rect" coords="1,1,83,125" alt="rectangle" nohref="">
223             <area shape="circle" coords="234,57,30" alt="circle" href="#">
224             <area shape="poly" coords="363,37,380,40,399,35,420,47,426,63,423,78,430,94,409,90,395,92,379,84,371,67,370,57" alt="polygon" href="#">
225             </map>
226            
227             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/noHref>
228              
229             =head2 origin
230              
231             Read-only.
232              
233             Returns a string containing the origin of the URL, that is its scheme, its domain and its port.
234              
235             Example:
236              
237             # An <area id="myArea" href="https://example.org/some/where"> element is in the document
238             my $area = $doc->getElementById("myArea");
239             $area->origin; # returns 'https://example.org'
240              
241             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/origin>
242              
243             =head2 password
244              
245             Is a string containing the password specified before the domain name.
246              
247             Example:
248              
249             # An <area id="myArea" href="https://anonymous:flabada@example.org/some/where"> is in the document
250             my $area = $doc->getElementByID("myArea");
251             $area->password; # returns 'flabada'
252              
253             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/password>
254              
255             =head2 pathname
256              
257             Is a string containing the path name component, if any, of the referenced URL.
258              
259             Example:
260              
261             # An <area id="myArea" href="/some/where"> element is in the document
262             my $area = $doc->getElementById("myArea");
263             $area->pathname; # returns '/some/where'
264              
265             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/pathname>
266              
267             =head2 port
268              
269             Is a string containing the port component, if any, of the referenced URL.
270              
271             Example:
272              
273             # An <area id="myArea" href="https://example.org:443/some/where"> element is in the document
274             my $area = $doc->getElementByID("myArea");
275             $area->port; # returns '443'
276              
277             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/port>
278              
279             =head2 protocol
280              
281             Is a string containing the protocol component (including trailing colon ':'), of the referenced URL.
282              
283             Example:
284              
285             # An <area id="myArea" href="https://example.org/some/where"> element is in the document
286             my $area = $doc->getElementById("myArea");
287             $area->protocol; # returns 'https:'
288              
289             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/protocol>
290              
291             =head2 referrerPolicy
292              
293             Is a string that reflects the referrerpolicy HTML attribute indicating which referrer to use when fetching the linked resource.
294              
295             Example:
296              
297             <img usemap="#mapAround" width="100" height="100" src="/img/logo@2x.png" />
298             <map id="myMap" name="mapAround" />>
299              
300             my $elt = $doc->createElement("area");
301             $elt->href = "/img2.png";
302             $elt->shape = "rect";
303             $elt->referrerPolicy = "no-referrer";
304             $elt->coords = "0,0,100,100";
305             my $map = $doc->getElementById("myMap");
306              
307             $map->appendChild($elt);
308             # When clicked, the area's link will not send a referrer header.
309              
310             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/referrerPolicy>
311              
312             =head2 rel
313              
314             Is a string that reflects the rel HTML attribute, indicating relationships of the current document to the linked resource.
315              
316             Example:
317              
318             my $areas = $doc->getElementsByTagName("area");
319             my $length = $areas->length;
320             for( my $i = 0; $i < $length; $i++ )
321             {
322             say("Rel: " + $areas->[$i]->rel);
323             }
324              
325             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/rel>
326              
327             =head2 relList
328              
329             Returns a L<HTML::Object::TokenList> that reflects the rel HTML attribute, indicating relationships of the current document to the linked resource, as a list of tokens.
330              
331             Example:
332              
333             my $areas = $doc->getElementsByTagName("area");
334             my $length = $areas->length;
335              
336             for( my $i = 0; $i < $length; $i++ )
337             {
338             my $list = $areas->[$i]->relList;
339             my $listLength = $list->length;
340             say( "New area found." );
341             for( my $j = 0; $j < $listLength; $j++ )
342             {
343             say( $list->[$j] );
344             }
345             }
346              
347             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/relList>
348              
349             =head2 search
350              
351             Is a string containing the search element (including leading question mark '?'), if any, of the referenced URL.
352              
353             Example:
354              
355             # An <area id="myArea" href="/some/where?q=123"> element is in the document
356             my $area = $doc->getElementById("myArea");
357             $area->search; # returns '?q=123'
358              
359             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/search>
360              
361             =head2 shape
362              
363             Is a string that reflects the shape HTML attribute, indicating the shape of the hot-spot, limited to known values.
364              
365             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/shape>
366              
367             =head2 tabIndex
368              
369             Is a long containing the element's position in the tabbing order.
370              
371             Example:
372              
373             my $b1 = $doc->getElementById('button1');
374             $b1->tabIndex = 1;
375              
376             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex>
377              
378             =head2 target
379              
380             Is a string that reflects the target HTML attribute, indicating the browsing context in which to open the linked resource.
381              
382             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/target>
383              
384             =head2 username
385              
386             Is a string containing the username specified before the domain name.
387              
388             Example:
389              
390             # An <area id="myArea" href="https://anonymous:flabada@example.org/some/where"> element is in the document
391             my $area = $doc->getElementByID("myArea");
392             $area->username; # returns 'anonymous'
393              
394             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/username>
395              
396             =head1 METHODS
397              
398             Inherits methods from its parent L<HTML::Object::DOM::Element>
399              
400             =head2 toString
401              
402             Returns a string containing the whole URL of the script executed in the Worker. It is a synonym for L<HTML::Object::DOM::Element::Area/href>.
403              
404             Example:
405              
406             # An <area id="myArea" href="/some/where"> element is in the document
407             my $area = $doc->getElementById("myArea");
408             $area->toString(); # returns 'https://example.org/some/where'
409              
410             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/toString>
411              
412             =head1 AUTHOR
413              
414             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
415              
416             =head1 SEE ALSO
417              
418             L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement>, L<Mozilla documentation on area element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/area>
419              
420             =head1 COPYRIGHT & LICENSE
421              
422             Copyright(c) 2021 DEGUEST Pte. Ltd.
423              
424             All rights reserved
425              
426             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
427              
428             =cut