line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::DOM::Text; |
2
|
|
|
|
|
|
|
|
3
|
24
|
|
|
24
|
|
85
|
use warnings; |
|
24
|
|
|
|
|
27
|
|
|
24
|
|
|
|
|
608
|
|
4
|
24
|
|
|
24
|
|
75
|
use strict; |
|
24
|
|
|
|
|
30
|
|
|
24
|
|
|
|
|
422
|
|
5
|
|
|
|
|
|
|
|
6
|
24
|
|
|
24
|
|
69
|
use HTML::DOM::Node qw 'TEXT_NODE ATTRIBUTE_NODE'; |
|
24
|
|
|
|
|
27
|
|
|
24
|
|
|
|
|
6087
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require HTML::DOM::CharacterData; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = 'HTML::DOM::CharacterData'; |
11
|
|
|
|
|
|
|
our $VERSION = '0.057'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
HTML::DOM::Text - A Perl class for representing text nodes in an HTML DOM tree |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 VERSION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Version 0.057 |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use HTML::DOM; |
25
|
|
|
|
|
|
|
$doc = HTML::DOM->new; |
26
|
|
|
|
|
|
|
$text_node = $doc->createTextNode('the text goes here, I think'); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$text_node->data; # 'the text goes here, I think' |
29
|
|
|
|
|
|
|
$text_node->length; # 27 |
30
|
|
|
|
|
|
|
$text_node->substringData(22); # 'think' |
31
|
|
|
|
|
|
|
# etc. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This class implements the Text interface for L. It inherits from |
36
|
|
|
|
|
|
|
L, which inherits from L. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 HTML::DOM::Text's Own Methods |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=over 4 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item $text->splitText($offset) |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Splits the node into two separate sibling text nodes at the given offset. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item $text->splitText16($offset) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This is just like C except that the offset is given in UTF-16, |
51
|
|
|
|
|
|
|
rather than Unicode. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item $text->nodeName |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This returns '#text'. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item $text->nodeType |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This returns the constant HTML::DOM::Node::TEXT_NODE. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub new { # $_[1] contains the text |
65
|
608
|
|
|
608
|
0
|
1730
|
$_[0]->SUPER::new('~text', text => "$_[1]"); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub splitText { |
69
|
3
|
|
|
3
|
1
|
699
|
my($self,$setoff) = @_; |
70
|
3
|
|
|
|
|
14
|
my $new_node = __PACKAGE__->new( |
71
|
|
|
|
|
|
|
# subtstringData takes care of throwing the right errors |
72
|
|
|
|
|
|
|
$self->substringData($setoff) |
73
|
|
|
|
|
|
|
); |
74
|
1
|
|
|
|
|
7
|
$self->deleteData($setoff); |
75
|
1
|
|
|
|
|
6
|
$self->postinsert($new_node); |
76
|
1
|
|
|
|
|
2
|
$new_node; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub splitText16 { # UTF-16 version |
80
|
3
|
|
|
3
|
1
|
347
|
my($self,$setoff) = @_; |
81
|
3
|
|
|
|
|
10
|
my $new_node = __PACKAGE__->new( |
82
|
|
|
|
|
|
|
$self->substringData16($setoff) |
83
|
|
|
|
|
|
|
); |
84
|
1
|
|
|
|
|
6
|
$self->deleteData16(($setoff,)); |
85
|
1
|
|
|
|
|
3
|
$self->postinsert($new_node); |
86
|
1
|
|
|
|
|
2
|
$new_node; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# ---------------- NODE METHODS ---------- # |
90
|
|
|
|
|
|
|
|
91
|
54
|
|
|
54
|
1
|
151
|
sub nodeName { '#text' } |
92
|
|
|
|
|
|
|
*nodeType = \&TEXT_NODE; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# --------- OVERRIDDEN EVENT TARGET METHOD -------- # |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub trigger_event { |
98
|
234
|
|
|
234
|
1
|
302
|
my ($n,$evnt) = (shift,shift); |
99
|
234
|
|
|
|
|
476
|
my $p = $n->parent; |
100
|
|
|
|
|
|
|
$n->SUPER::trigger_event( |
101
|
|
|
|
|
|
|
$evnt, |
102
|
|
|
|
|
|
|
$p && $p->nodeType == ATTRIBUTE_NODE |
103
|
|
|
|
|
|
|
?( |
104
|
|
|
|
|
|
|
DOMCharacterDataModified_default =>sub { |
105
|
6
|
|
|
6
|
|
17
|
$_[0]->target->parent->_text_node_modified( |
106
|
|
|
|
|
|
|
$_[0] |
107
|
|
|
|
|
|
|
) |
108
|
|
|
|
|
|
|
}, |
109
|
234
|
100
|
66
|
|
|
1270
|
):(), |
110
|
|
|
|
|
|
|
@_, |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1 |
115
|
|
|
|
|
|
|
__END__ |