line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## HTML Object - ~/lib/HTML/Object/DOM/Space.pm |
3
|
|
|
|
|
|
|
## Version v0.2.0 |
4
|
|
|
|
|
|
|
## Copyright(c) 2021 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <jack@deguest.jp> |
6
|
|
|
|
|
|
|
## Created 2021/12/13 |
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::Space; |
15
|
|
|
|
|
|
|
BEGIN |
16
|
|
|
|
|
|
|
{ |
17
|
28
|
|
|
28
|
|
216
|
use strict; |
|
28
|
|
|
|
|
67
|
|
|
28
|
|
|
|
|
988
|
|
18
|
28
|
|
|
28
|
|
218
|
use warnings; |
|
28
|
|
|
|
|
73
|
|
|
28
|
|
|
|
|
924
|
|
19
|
28
|
|
|
28
|
|
167
|
use parent qw( HTML::Object::Space HTML::Object::DOM::CharacterData ); |
|
28
|
|
|
|
|
80
|
|
|
28
|
|
|
|
|
180
|
|
20
|
28
|
|
|
28
|
|
2634
|
use vars qw( $VERSION ); |
|
28
|
|
|
|
|
90
|
|
|
28
|
|
|
|
|
1272
|
|
21
|
28
|
|
|
28
|
|
562
|
our $VERSION = 'v0.2.0'; |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
28
|
|
|
28
|
|
147
|
use strict; |
|
28
|
|
|
|
|
96
|
|
|
28
|
|
|
|
|
604
|
|
25
|
28
|
|
|
28
|
|
143
|
use warnings; |
|
28
|
|
|
|
|
65
|
|
|
28
|
|
|
|
|
10315
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub init |
28
|
|
|
|
|
|
|
{ |
29
|
333
|
|
|
333
|
1
|
29349
|
my $self = shift( @_ ); |
30
|
333
|
|
|
|
|
3432
|
$self->{_init_strict_use_sub} = 1; |
31
|
333
|
50
|
|
|
|
3024
|
$self->HTML::Object::Space::init( @_ ) || return( $self->pass_error ); |
32
|
333
|
|
|
|
|
1387
|
return( $self ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
0
|
1
|
0
|
sub getAttributes { return( wantarray() ? () : [] ); } |
36
|
|
|
|
|
|
|
|
37
|
641
|
100
|
|
641
|
1
|
1843
|
sub getChildNodes { return( wantarray() ? () : [] ); } |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
1
|
0
|
sub getElementById { return; } |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
0
|
1
|
0
|
sub getFirstChild { return; } |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
1
|
0
|
sub getLastChild { return; } |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
1
|
0
|
sub getRootNode { return( shift->parent->getRootNode ); } |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
1
|
0
|
sub isAttributeNode { return(0); } |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
0
|
1
|
0
|
sub isCommentNode { return(0); } |
50
|
|
|
|
|
|
|
|
51
|
500
|
|
|
500
|
1
|
1670
|
sub isElementNode { return(0); } |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
0
|
1
|
0
|
sub isNamespaceNode { return(0); } |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
0
|
sub isPINode { return(0); } |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
1
|
0
|
sub isProcessingInstructionNode { return(0); } |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
0
|
1
|
0
|
sub isTextNode { return(0); } |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub isEqualNode |
62
|
|
|
|
|
|
|
{ |
63
|
0
|
|
|
0
|
1
|
0
|
my $self = shift( @_ ); |
64
|
0
|
|
0
|
|
|
0
|
my $e = shift( @_ ) || return( $self->error( "No html element was provided to insert." ) ); |
65
|
0
|
0
|
|
|
|
0
|
return( $self->error( "Element provided (", overload::StrVal( $e ), ") is not an HTML::Object::Element." ) ) if( !$self->_is_a( $e => 'HTML::Object::Element' ) ); |
66
|
0
|
0
|
|
|
|
0
|
return(0) if( !$self->_is_a( $e => 'HTML::Object::Space' ) ); |
67
|
0
|
|
|
|
|
0
|
return( $self->value eq $e->value ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Note: Property |
71
|
0
|
|
|
0
|
1
|
0
|
sub nodeValue : lvalue { return( shift->_set_get_lvalue( 'value', @_ ) ); } |
72
|
|
|
|
|
|
|
|
73
|
792
|
|
|
792
|
1
|
5300279
|
sub parent { return( shift->_set_get_object_without_init( 'parent', 'HTML::Object::DOM::Node', @_ ) ); } |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
1
|
|
sub string_value { return( shift->value ); } |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
# NOTE: POD |
79
|
|
|
|
|
|
|
__END__ |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=encoding utf-8 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 NAME |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
HTML::Object::DOM::Space - HTML Object DOM Space Class |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SYNOPSIS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
use HTML::Object::DOM::Space; |
90
|
|
|
|
|
|
|
my $sp = HTML::Object::DOM::Space->new( value => $some_space ) || |
91
|
|
|
|
|
|
|
die( HTML::Object::DOM::Space->error, "\n" ); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 VERSION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
v0.2.0 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 DESCRIPTION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This implements the representation of a space-only chunk of data. This is a divergence from the DOM standard which treats space as text. Thus, any data chunk comprised only of spaces between tags would all be space nodes. Spaces includes space, tabulation, carriage return, new line, and any other horizontal and vertical spaces. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
It inherits from L<HTML::Object::Space> and L<HTML::Object::DOM::CharacterData> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 INHERITANCE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------------+ +--------------------------+ |
106
|
|
|
|
|
|
|
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::CharacterData | --> | HTML::Object::DOM::Space | |
107
|
|
|
|
|
|
|
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------------+ +--------------------------+ |
108
|
|
|
|
|
|
|
| ^ |
109
|
|
|
|
|
|
|
| | |
110
|
|
|
|
|
|
|
v | |
111
|
|
|
|
|
|
|
+-----------------------+ | |
112
|
|
|
|
|
|
|
| HTML::Object::Space | -----------------------------------------------------------------------------------------------------------------+ |
113
|
|
|
|
|
|
|
+-----------------------+ |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 PROPERTIES |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 nodeValue |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Sets or gets the value of this space node. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 METHODS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 getAttributes |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Returns an empty list in list context or an empty array reference in scalar context. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 getChildNodes |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Returns an empty list in list context or an empty array reference in scalar context. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 getElementById |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Returns an empty list in list context or C<undef> in scalar context. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 getFirstChild |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Returns an empty list in list context or C<undef> in scalar context. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 getLastChild |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns an empty list in list context or C<undef> in scalar context. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 getRootNode |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Returns the value from the parent's C<getRootNode> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 isAttributeNode |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Returns false. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 isCommentNode |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Returns false. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 isElementNode |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Returns false. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 isNamespaceNode |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Returns false. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 isPINode |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Returns false. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 isProcessingInstructionNode |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Returns false. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 isTextNode |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Returns false. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 isEqualNode |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Returns true if both nodes are space nodes of equivalent value. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 parent |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Sets or gets the object value of this space node's parent. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 string_value |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Read-only. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Returns the value of this space node. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 AUTHOR |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 SEE ALSO |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Whitespace> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Copyright(c) 2021 DEGUEST Pte. Ltd. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
All rights reserved |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=cut |