line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Tag; |
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
1081956
|
use strict; |
|
14
|
|
|
|
|
39
|
|
|
14
|
|
|
|
|
588
|
|
4
|
14
|
|
|
14
|
|
79
|
use warnings; |
|
14
|
|
|
|
|
1383
|
|
|
14
|
|
|
|
|
521
|
|
5
|
|
|
|
|
|
|
|
6
|
14
|
|
|
14
|
|
11104
|
use Tie::IxHash; |
|
14
|
|
|
|
|
70038
|
|
|
14
|
|
|
|
|
435
|
|
7
|
14
|
|
|
14
|
|
20627
|
use Class::AutoAccess; |
|
14
|
|
|
|
|
7852
|
|
|
14
|
|
|
|
|
450
|
|
8
|
14
|
|
|
14
|
|
86
|
use base qw(Class::AutoAccess); |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
3506
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.08'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BEGIN { |
14
|
14
|
|
|
14
|
|
2198
|
our $class_def = { |
15
|
|
|
|
|
|
|
element => 'SPAN', |
16
|
|
|
|
|
|
|
name => '', |
17
|
|
|
|
|
|
|
id => '', |
18
|
|
|
|
|
|
|
has_end_tag => 1, |
19
|
|
|
|
|
|
|
tabindex => '', |
20
|
|
|
|
|
|
|
onafterupdate => '', onblur => '', onchange => '', onclick => '', |
21
|
|
|
|
|
|
|
ondblclick => '', onerrorupdate => '', onfilterchange => '', |
22
|
|
|
|
|
|
|
onfocus => '', onhelp => '', onkeydown => '', onkeypress => '', |
23
|
|
|
|
|
|
|
onkeyup => '', onmousedown => '', onmousemove => '', |
24
|
|
|
|
|
|
|
onmouseout => '', onmouseover => '', onmouseup => '', |
25
|
|
|
|
|
|
|
onresize => '', |
26
|
|
|
|
|
|
|
style => '', class => '', |
27
|
|
|
|
|
|
|
attributes => ['name','id','tabindex','onafterupdate', 'onblur', |
28
|
|
|
|
|
|
|
'onchange', 'onclick', 'ondblclick', 'onerrorupdate', |
29
|
|
|
|
|
|
|
'onfilterchange', 'onfocus', 'onhelp', 'onkeydown', |
30
|
|
|
|
|
|
|
'onkeypress', 'onkeyup', 'onmousedown', 'onmousemove', |
31
|
|
|
|
|
|
|
'onmouseout', 'onmouseover', 'onmouseup', 'onresize', |
32
|
|
|
|
|
|
|
'style','class'], |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new { |
37
|
54
|
|
|
54
|
0
|
4012
|
my $class = shift; |
38
|
54
|
|
|
|
|
221
|
my %values = @_; |
39
|
54
|
|
|
|
|
74
|
my $self; |
40
|
54
|
100
|
|
|
|
167
|
if ($class eq __PACKAGE__) { |
41
|
|
|
|
|
|
|
# call the true class |
42
|
27
|
|
100
|
|
|
118
|
my $element = $values{element} || 'SPAN'; |
43
|
27
|
|
|
|
|
13871
|
require 'HTML/Tag/' . $element . '.pm'; |
44
|
27
|
|
|
|
|
369
|
$self = "HTML::Tag::$element"->new(%values); |
45
|
27
|
50
|
|
|
|
198
|
die "Unable to create HTML::Tag::$element object" unless ($self); |
46
|
|
|
|
|
|
|
} else { |
47
|
14
|
|
|
14
|
|
85
|
no strict "refs"; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
8721
|
|
48
|
27
|
|
|
|
|
55
|
$self = {}; |
49
|
27
|
|
|
|
|
50
|
my $opt_child = ${$class . "::class_def"}; |
|
27
|
|
|
|
|
103
|
|
50
|
27
|
|
|
|
|
44
|
my $opt_parent = ${__PACKAGE__ . "::class_def"}; |
|
27
|
|
|
|
|
81
|
|
51
|
27
|
|
|
|
|
118
|
__PACKAGE__->merge_attributes($opt_child,$opt_parent); |
52
|
27
|
|
|
|
|
318
|
__PACKAGE__->push_hashref($self,$opt_parent); |
53
|
27
|
|
|
|
|
146
|
__PACKAGE__->push_hashref($self,$opt_child); |
54
|
27
|
|
|
|
|
109
|
__PACKAGE__->push_hashref($self,\%values); |
55
|
27
|
|
|
|
|
314
|
bless $self,$class; |
56
|
|
|
|
|
|
|
} |
57
|
54
|
|
|
|
|
172
|
return $self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub html { |
61
|
33
|
|
|
33
|
0
|
6467
|
my $self = shift; |
62
|
33
|
50
|
|
|
|
145
|
return $self->_build_start_tag . ($self->can('inner') ? $self->inner : '') . $self->_build_end_tag; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _build_start_tag { |
66
|
33
|
|
|
33
|
|
50
|
my $self = shift; |
67
|
33
|
|
|
|
|
48
|
my $ret = ''; |
68
|
33
|
|
|
|
|
205
|
$ret .= "<" . lc($self->tag); |
69
|
33
|
|
|
|
|
591
|
foreach (@{$self->attributes}) { |
|
33
|
|
|
|
|
164
|
|
70
|
803
|
|
|
|
|
4204
|
my @attr_value = $self->$_; |
71
|
803
|
|
|
|
|
31009
|
my $attr_value = $attr_value[0]; |
72
|
803
|
100
|
|
|
|
2119
|
if ("$attr_value" ne '') { |
73
|
57
|
|
|
|
|
273
|
$ret .= " " . $self->_build_attribute($_,$attr_value); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
33
|
100
|
|
|
|
181
|
$ret .= $self->has_end_tag ? '>' : ' />'; |
77
|
33
|
|
|
|
|
674
|
return $ret; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _build_end_tag { |
81
|
33
|
|
|
33
|
|
94
|
my $self = shift; |
82
|
33
|
100
|
|
|
|
91
|
return '' unless $self->has_end_tag; |
83
|
20
|
|
|
|
|
130
|
return "" . lc($self->tag) . ">"; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _build_attribute { |
87
|
63
|
|
|
63
|
|
80
|
my $self = shift; |
88
|
63
|
|
|
|
|
93
|
my $name = shift; |
89
|
63
|
|
|
|
|
86
|
my $value = shift; |
90
|
63
|
|
|
|
|
280
|
return qq|$name="$value"|; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub inner { |
94
|
15
|
|
|
15
|
0
|
79
|
return ''; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub push_hashref { |
98
|
81
|
|
|
81
|
0
|
141
|
my $self = shift; |
99
|
81
|
|
|
|
|
124
|
my $dst = shift; |
100
|
81
|
|
|
|
|
99
|
my $src = shift; |
101
|
81
|
|
|
|
|
769
|
@$dst{keys %$src} = values %$src; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub merge_attributes { |
105
|
|
|
|
|
|
|
# union of two arrayref |
106
|
27
|
|
|
27
|
0
|
52
|
my $self = shift; |
107
|
27
|
|
|
|
|
44
|
my $dst = shift; |
108
|
27
|
|
|
|
|
1873
|
my $src = shift; |
109
|
27
|
|
50
|
|
|
115
|
$src->{attributes} ||= [] ; |
110
|
27
|
|
100
|
|
|
835
|
$dst->{attributes} ||= [] ; |
111
|
27
|
|
|
|
|
195
|
tie my %union, 'Tie::IxHash'; |
112
|
27
|
|
|
|
|
395
|
$union{$_} = 1 for (@{$src->{attributes}},@{$dst->{attributes}}); |
|
27
|
|
|
|
|
68
|
|
|
27
|
|
|
|
|
233
|
|
113
|
27
|
|
|
|
|
14331
|
@{$dst->{attributes}} = keys %union; |
|
27
|
|
|
|
|
3195
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# vim: set ts=2: |