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

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