| 1 | ##---------------------------------------------------------------------------- | ||||||||||
| 2 | ## HTML Object - ~/lib/HTML/Object/DOM/Element/Body.pm | ||||||||||
| 3 | ## Version v0.2.0 | ||||||||||
| 4 | ## Copyright(c) 2022 DEGUEST Pte. Ltd. | ||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||
| 6 | ## Created 2022/01/05 | ||||||||||
| 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::Body; | ||||||||||
| 15 | BEGIN | ||||||||||
| 16 | { | ||||||||||
| 17 | 17 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 17 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 17 | ▶ | warnings::register_categories( 'HTML::Object' ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 17 | ▶ | use parent qw( HTML::Object::DOM::Element ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 17 | ▶ | use vars qw( $VERSION ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 17 | our $VERSION = 'v0.2.0'; | |||||||||
| 23 | }; | ||||||||||
| 24 | |||||||||||
| 25 | 17 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 17 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | sub init | ||||||||||
| 29 | { | ||||||||||
| 30 | 27 | ▶ | my $self = shift( @_ ); | ||||||||
|
Subroutine
init: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||
| 31 | 27 | $self->{_init_strict_use_sub} = 1; | |||||||||
| 32 | 27 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 27 | ▶ | $self->{tag} = 'body' if( !CORE::length( "$self->{tag}" ) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 27 | return( $self ); | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | # Note: property aLink obsolete | ||||||||||
| 38 | 0 | ▶ | sub aLink { return; } | ||||||||
|
Subroutine
aLink: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 39 | |||||||||||
| 40 | # Note: property background obsolete | ||||||||||
| 41 | 0 | ▶ | sub background { return; } | ||||||||
|
Subroutine
background: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 42 | |||||||||||
| 43 | # Note: property bgColor obsolete | ||||||||||
| 44 | 0 | ▶ | sub bgColor { return; } | ||||||||
|
Subroutine
bgColor: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 45 | |||||||||||
| 46 | # Note: property link obsolete | ||||||||||
| 47 | 0 | ▶ | sub link { return; } | ||||||||
|
Subroutine
link: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | sub onafterprint : lvalue { return( shift->on( 'afterprint', @_ ) ); } | ||||||||
|
Subroutine
onafterprint: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 50 | |||||||||||
| 51 | 0 | ▶ | sub onbeforeprint : lvalue { return( shift->on( 'beforeprint', @_ ) ); } | ||||||||
|
Subroutine
onbeforeprint: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 52 | |||||||||||
| 53 | 0 | ▶ | sub onbeforeunload : lvalue { return( shift->on( 'beforeunload', @_ ) ); } | ||||||||
|
Subroutine
onbeforeunload: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | sub onhashchange : lvalue { return( shift->on( 'hashchange', @_ ) ); } | ||||||||
|
Subroutine
onhashchange: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | sub onlanguagechange : lvalue { return( shift->on( 'languagechange', @_ ) ); } | ||||||||
|
Subroutine
onlanguagechange: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 58 | |||||||||||
| 59 | 0 | ▶ | sub onmessage : lvalue { return( shift->on( 'message', @_ ) ); } | ||||||||
|
Subroutine
onmessage: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | sub onmessageerror : lvalue { return( shift->on( 'messageerror', @_ ) ); } | ||||||||
|
Subroutine
onmessageerror: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | sub onoffline : lvalue { return( shift->on( 'offline', @_ ) ); } | ||||||||
|
Subroutine
onoffline: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 64 | |||||||||||
| 65 | 0 | ▶ | sub ononline : lvalue { return( shift->on( 'online', @_ ) ); } | ||||||||
|
Subroutine
ononline: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 66 | |||||||||||
| 67 | 0 | ▶ | sub onpagehide : lvalue { return( shift->on( 'pagehide', @_ ) ); } | ||||||||
|
Subroutine
onpagehide: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | sub onpageshow : lvalue { return( shift->on( 'pageshow', @_ ) ); } | ||||||||
|
Subroutine
onpageshow: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 70 | |||||||||||
| 71 | 0 | ▶ | sub onpopstate : lvalue { return( shift->on( 'popstate', @_ ) ); } | ||||||||
|
Subroutine
onpopstate: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | sub onrejectionhandled : lvalue { return( shift->on( 'rejectionhandled', @_ ) ); } | ||||||||
|
Subroutine
onrejectionhandled: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 74 | |||||||||||
| 75 | 0 | ▶ | sub onresize : lvalue { return( shift->on( 'resize', @_ ) ); } | ||||||||
|
Subroutine
onresize: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 76 | |||||||||||
| 77 | 0 | ▶ | sub onstorage : lvalue { return( shift->on( 'storage', @_ ) ); } | ||||||||
|
Subroutine
onstorage: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 78 | |||||||||||
| 79 | 0 | ▶ | sub onunhandledrejection : lvalue { return( shift->on( 'unhandledrejection', @_ ) ); } | ||||||||
|
Subroutine
onunhandledrejection: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 80 | |||||||||||
| 81 | 0 | ▶ | sub onunload : lvalue { return( shift->on( 'unload', @_ ) ); } | ||||||||
|
Subroutine
onunload: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 82 | |||||||||||
| 83 | # Note: property text obsolete | ||||||||||
| 84 | 0 | ▶ | sub text { return; } | ||||||||
|
Subroutine
text: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 85 | |||||||||||
| 86 | # Note: property vLink obsolete | ||||||||||
| 87 | 0 | ▶ | sub vLink { return; } | ||||||||
|
Subroutine
vLink: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 88 | |||||||||||
| 89 | 17 | 1; | |||||||||
| 90 | # NOTE: POD | ||||||||||
| 91 | __END__ | ||||||||||
| 92 | |||||||||||
| 93 | =encoding utf-8 | ||||||||||
| 94 | |||||||||||
| 95 | =head1 NAME | ||||||||||
| 96 | |||||||||||
| 97 | HTML::Object::DOM::Element::Body - HTML Object DOM Body Class | ||||||||||
| 98 | |||||||||||
| 99 | =head1 SYNOPSIS | ||||||||||
| 100 | |||||||||||
| 101 | use HTML::Object::DOM::Element::Body; | ||||||||||
| 102 | my $body = HTML::Object::DOM::Element::Body->new || | ||||||||||
| 103 | die( HTML::Object::DOM::Element::Body->error, "\n" ); | ||||||||||
| 104 | |||||||||||
| 105 | =head1 VERSION | ||||||||||
| 106 | |||||||||||
| 107 | v0.2.0 | ||||||||||
| 108 | |||||||||||
| 109 | =head1 INHERITANCE | ||||||||||
| 110 | |||||||||||
| 111 | +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +----------------------------------+ | ||||||||||
| 112 | | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Body | | ||||||||||
| 113 | +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +----------------------------------+ | ||||||||||
| 114 | |||||||||||
| 115 | =head1 DESCRIPTION | ||||||||||
| 116 | |||||||||||
| 117 | The L<HTML::Object::DOM::Element::Body> interface provides special properties (beyond those inherited from the regular L<HTML::Object::DOM::Element> interface) for manipulating C<<body>> elements. | ||||||||||
| 118 | |||||||||||
| 119 | =head1 PROPERTIES | ||||||||||
| 120 | |||||||||||
| 121 | Inherits properties from its parent L<HTML::Object::DOM::Element> | ||||||||||
| 122 | |||||||||||
| 123 | =head1 OBSOLETE PROPERTIES | ||||||||||
| 124 | |||||||||||
| 125 | Those properties all return C<undef> | ||||||||||
| 126 | |||||||||||
| 127 | =head2 aLink | ||||||||||
| 128 | |||||||||||
| 129 | Is a string that represents the color of active hyperlinks. | ||||||||||
| 130 | |||||||||||
| 131 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/aLink> | ||||||||||
| 132 | |||||||||||
| 133 | =head2 background | ||||||||||
| 134 | |||||||||||
| 135 | Is a string that represents the description of the location of the background image resource. Note that this is not an URI, though some older version of some browsers do expect it. | ||||||||||
| 136 | |||||||||||
| 137 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/background> | ||||||||||
| 138 | |||||||||||
| 139 | =head2 bgColor | ||||||||||
| 140 | |||||||||||
| 141 | Is a string that represents the background color for the document. | ||||||||||
| 142 | |||||||||||
| 143 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/bgColor> | ||||||||||
| 144 | |||||||||||
| 145 | =head2 link | ||||||||||
| 146 | |||||||||||
| 147 | Is a string that represents the color of unvisited links. | ||||||||||
| 148 | |||||||||||
| 149 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/link> | ||||||||||
| 150 | |||||||||||
| 151 | =head2 text | ||||||||||
| 152 | |||||||||||
| 153 | Is a string that represents the foreground color of text. | ||||||||||
| 154 | |||||||||||
| 155 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/text> | ||||||||||
| 156 | |||||||||||
| 157 | =head2 vLink | ||||||||||
| 158 | |||||||||||
| 159 | Is a string that represents the color of visited links. | ||||||||||
| 160 | |||||||||||
| 161 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/vLink> | ||||||||||
| 162 | |||||||||||
| 163 | =head1 METHODS | ||||||||||
| 164 | |||||||||||
| 165 | Inherits methods from its parent L<HTML::Object::DOM::Element> | ||||||||||
| 166 | |||||||||||
| 167 | =head1 EVENT HANDLERS | ||||||||||
| 168 | |||||||||||
| 169 | Below are the event handlers you can use and that are implemented in this interface. However, it is up to you to fire those related events. | ||||||||||
| 170 | |||||||||||
| 171 | =head2 onafterprint | ||||||||||
| 172 | |||||||||||
| 173 | Is an event handler representing the code to be called when the afterprint event is raised. | ||||||||||
| 174 | |||||||||||
| 175 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onafterprint> | ||||||||||
| 176 | |||||||||||
| 177 | =head2 onbeforeprint | ||||||||||
| 178 | |||||||||||
| 179 | Is an event handler representing the code to be called when the beforeprint event is raised. | ||||||||||
| 180 | |||||||||||
| 181 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeprint> | ||||||||||
| 182 | |||||||||||
| 183 | =head2 onbeforeunload | ||||||||||
| 184 | |||||||||||
| 185 | Is an event handler representing the code to be called when the beforeunload event is raised. | ||||||||||
| 186 | |||||||||||
| 187 | Example: | ||||||||||
| 188 | |||||||||||
| 189 | use HTML::Object::DOM qw( window ); | ||||||||||
| 190 | window->addEventListener( beforeunload => sub | ||||||||||
| 191 | { | ||||||||||
| 192 | # Cancel the event | ||||||||||
| 193 | # If you prevent default behavior in Mozilla Firefox prompt will always be shown | ||||||||||
| 194 | $e->preventDefault(); | ||||||||||
| 195 | # Chrome requires returnValue to be set | ||||||||||
| 196 | $e->returnValue = ''; | ||||||||||
| 197 | }); | ||||||||||
| 198 | |||||||||||
| 199 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload> | ||||||||||
| 200 | |||||||||||
| 201 | =head2 onhashchange | ||||||||||
| 202 | |||||||||||
| 203 | Is an event handler representing the code to be called when the hashchange event is raised. | ||||||||||
| 204 | |||||||||||
| 205 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onhashchange> | ||||||||||
| 206 | |||||||||||
| 207 | =head2 onlanguagechange | ||||||||||
| 208 | |||||||||||
| 209 | Is an event handler representing the code to be called when the languagechange event is raised. | ||||||||||
| 210 | |||||||||||
| 211 | Example: | ||||||||||
| 212 | |||||||||||
| 213 | object->onlanguagechange = function; | ||||||||||
| 214 | |||||||||||
| 215 | window->onlanguagechange = sub | ||||||||||
| 216 | { | ||||||||||
| 217 | say( 'languagechange event detected!' ); | ||||||||||
| 218 | }; | ||||||||||
| 219 | |||||||||||
| 220 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onlanguagechange> | ||||||||||
| 221 | |||||||||||
| 222 | =head2 onmessage | ||||||||||
| 223 | |||||||||||
| 224 | Is an event handler called whenever an object receives a message event. | ||||||||||
| 225 | |||||||||||
| 226 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onmessage> | ||||||||||
| 227 | |||||||||||
| 228 | =head2 onmessageerror | ||||||||||
| 229 | |||||||||||
| 230 | Is an event handler called whenever an object receives a messageerror event. | ||||||||||
| 231 | |||||||||||
| 232 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onmessageerror> | ||||||||||
| 233 | |||||||||||
| 234 | =head2 onoffline | ||||||||||
| 235 | |||||||||||
| 236 | Is an event handler representing the code to be called when the offline event is raised. | ||||||||||
| 237 | |||||||||||
| 238 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/onoffline> | ||||||||||
| 239 | |||||||||||
| 240 | =head2 ononline | ||||||||||
| 241 | |||||||||||
| 242 | Is an event handler representing the code to be called when the online event is raised. | ||||||||||
| 243 | |||||||||||
| 244 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/ononline> | ||||||||||
| 245 | |||||||||||
| 246 | =head2 onpagehide | ||||||||||
| 247 | |||||||||||
| 248 | Is an event handler representing the code to be called when the pagehide event is raised. | ||||||||||
| 249 | |||||||||||
| 250 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/onpagehide> | ||||||||||
| 251 | |||||||||||
| 252 | =head2 onpageshow | ||||||||||
| 253 | |||||||||||
| 254 | Is an event handler representing the code to be called when the pageshow event is raised. | ||||||||||
| 255 | |||||||||||
| 256 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/onpageshow> | ||||||||||
| 257 | |||||||||||
| 258 | =head2 onpopstate | ||||||||||
| 259 | |||||||||||
| 260 | Is an event handler representing the code to be called when the popstate event is raised. | ||||||||||
| 261 | |||||||||||
| 262 | Example: | ||||||||||
| 263 | |||||||||||
| 264 | window->onpopstate = sub | ||||||||||
| 265 | { | ||||||||||
| 266 | my $event = shift( @_ ); | ||||||||||
| 267 | say( "location: " . $doc->location . ", state: " . JSON->new->encode( $event->state ) ); | ||||||||||
| 268 | }; | ||||||||||
| 269 | |||||||||||
| 270 | $history->pushState({page => 1}, "title 1", "?page=1"); | ||||||||||
| 271 | $history->pushState({page => 2}, "title 2", "?page=2"); | ||||||||||
| 272 | $history->replaceState({page => 3}, "title 3", "?page=3"); | ||||||||||
| 273 | $history->back(); # alerts "location: https://example.org/example.html?page=1, state => {"page" => 1}" | ||||||||||
| 274 | $history->back(); # alerts "location: https://example.org/example.html, state: null | ||||||||||
| 275 | $history->go(2); # alerts "location: https://example.org/example.html?page=3, state => {"page" =>3} | ||||||||||
| 276 | |||||||||||
| 277 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate> | ||||||||||
| 278 | |||||||||||
| 279 | =head2 onrejectionhandled | ||||||||||
| 280 | |||||||||||
| 281 | An event handler representing the code executed when the C<rejectionhandled> event is raised, indicating that a C<Promise> was rejected and the rejection has been handled. | ||||||||||
| 282 | |||||||||||
| 283 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onrejectionhandled> | ||||||||||
| 284 | |||||||||||
| 285 | =head2 onresize | ||||||||||
| 286 | |||||||||||
| 287 | Is an event handler representing the code to be called when the C<resize> event is raised. | ||||||||||
| 288 | |||||||||||
| 289 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onresize> | ||||||||||
| 290 | |||||||||||
| 291 | =head2 onstorage | ||||||||||
| 292 | |||||||||||
| 293 | Is an event handler representing the code to be called when the storage event is raised. | ||||||||||
| 294 | |||||||||||
| 295 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onstorage> | ||||||||||
| 296 | |||||||||||
| 297 | =head2 onunhandledrejection | ||||||||||
| 298 | |||||||||||
| 299 | An event handler representing the code executed when the unhandledrejection event is raised, indicating that a Promise was rejected but the rejection was not handled. | ||||||||||
| 300 | |||||||||||
| 301 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onunhandledrejection> | ||||||||||
| 302 | |||||||||||
| 303 | =head2 onunload | ||||||||||
| 304 | |||||||||||
| 305 | Is an event handler representing the code to be called when the unload event is raised. | ||||||||||
| 306 | |||||||||||
| 307 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onunload> | ||||||||||
| 308 | |||||||||||
| 309 | =head1 AUTHOR | ||||||||||
| 310 | |||||||||||
| 311 | Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> | ||||||||||
| 312 | |||||||||||
| 313 | =head1 SEE ALSO | ||||||||||
| 314 | |||||||||||
| 315 | L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement>, L<Mozilla documentation on anchor element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body> | ||||||||||
| 316 | |||||||||||
| 317 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 318 | |||||||||||
| 319 | Copyright(c) 2022 DEGUEST Pte. Ltd. | ||||||||||
| 320 | |||||||||||
| 321 | All rights reserved | ||||||||||
| 322 | |||||||||||
| 323 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||
| 324 | |||||||||||
| 325 | =cut | ||||||||||