| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
15
|
|
|
15
|
|
6297
|
use strict; |
|
|
15
|
|
|
|
|
23
|
|
|
|
15
|
|
|
|
|
473
|
|
|
2
|
15
|
|
|
15
|
|
53
|
use warnings; |
|
|
15
|
|
|
|
|
17
|
|
|
|
15
|
|
|
|
|
514
|
|
|
3
|
|
|
|
|
|
|
package HTML::Widget::Plugin; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: base class for HTML widgets |
|
5
|
|
|
|
|
|
|
$HTML::Widget::Plugin::VERSION = '0.203'; |
|
6
|
15
|
|
|
15
|
|
62
|
use Carp (); |
|
|
15
|
|
|
|
|
20
|
|
|
|
15
|
|
|
|
|
223
|
|
|
7
|
15
|
|
|
15
|
|
7642
|
use List::MoreUtils qw(uniq); |
|
|
15
|
|
|
|
|
13971
|
|
|
|
15
|
|
|
|
|
1263
|
|
|
8
|
15
|
|
|
15
|
|
85
|
use MRO::Compat; |
|
|
15
|
|
|
|
|
19
|
|
|
|
15
|
|
|
|
|
340
|
|
|
9
|
15
|
|
|
15
|
|
64
|
use Scalar::Util qw(reftype); |
|
|
15
|
|
|
|
|
23
|
|
|
|
15
|
|
|
|
|
972
|
|
|
10
|
15
|
|
|
15
|
|
7085
|
use Sub::Install; |
|
|
15
|
|
|
|
|
21079
|
|
|
|
15
|
|
|
|
|
374
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
13
|
|
|
|
|
|
|
#pod |
|
14
|
|
|
|
|
|
|
#pod This class provides a simple way to write plugins for HTML::Widget::Factory. |
|
15
|
|
|
|
|
|
|
#pod |
|
16
|
|
|
|
|
|
|
#pod =head1 METHODS |
|
17
|
|
|
|
|
|
|
#pod |
|
18
|
|
|
|
|
|
|
#pod =head2 new |
|
19
|
|
|
|
|
|
|
#pod |
|
20
|
|
|
|
|
|
|
#pod my $plugin = Plugin->new( \%arg ); |
|
21
|
|
|
|
|
|
|
#pod |
|
22
|
|
|
|
|
|
|
#pod The default plugin constructor is really simple. It requires that the argument |
|
23
|
|
|
|
|
|
|
#pod is either a hashref or not given. |
|
24
|
|
|
|
|
|
|
#pod |
|
25
|
|
|
|
|
|
|
#pod =cut |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
|
28
|
200
|
|
|
200
|
1
|
8987
|
my ($class, $arg) = @_; |
|
29
|
200
|
100
|
|
|
|
354
|
$arg = {} unless defined $arg; |
|
30
|
|
|
|
|
|
|
|
|
31
|
200
|
50
|
33
|
|
|
907
|
Carp::confess("illegal argument to $class->new: $arg") |
|
32
|
|
|
|
|
|
|
unless ref $arg and reftype $arg eq 'HASH'; |
|
33
|
|
|
|
|
|
|
|
|
34
|
200
|
|
|
|
|
159
|
my @attribute_args; |
|
35
|
200
|
|
|
|
|
153
|
for (@{ mro::get_linear_isa($class) }) { |
|
|
200
|
|
|
|
|
583
|
|
|
36
|
449
|
50
|
|
|
|
2141
|
next unless $_->can('_attribute_args'); |
|
37
|
449
|
|
|
|
|
874
|
push @attribute_args, $_->_attribute_args(@_); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
200
|
|
|
|
|
1511
|
@attribute_args = uniq @attribute_args; |
|
40
|
|
|
|
|
|
|
|
|
41
|
200
|
|
|
|
|
402
|
my @boolean_args; |
|
42
|
200
|
|
|
|
|
153
|
for ($class, @{ mro::get_linear_isa($class) }) { |
|
|
200
|
|
|
|
|
526
|
|
|
43
|
649
|
50
|
|
|
|
2250
|
next unless $_->can('_boolean_args'); |
|
44
|
649
|
|
|
|
|
1101
|
push @boolean_args, $_->_boolean_args(@_); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
200
|
|
|
|
|
543
|
@boolean_args = uniq @boolean_args; |
|
47
|
|
|
|
|
|
|
|
|
48
|
200
|
|
|
|
|
1977
|
bless { |
|
49
|
|
|
|
|
|
|
%$arg, |
|
50
|
|
|
|
|
|
|
_attribute_args => \@attribute_args, |
|
51
|
|
|
|
|
|
|
_boolean_args => \@boolean_args, |
|
52
|
|
|
|
|
|
|
}, $class; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#pod =head2 rewrite_arg |
|
56
|
|
|
|
|
|
|
#pod |
|
57
|
|
|
|
|
|
|
#pod $arg = $plugin->rewrite_arg($arg); |
|
58
|
|
|
|
|
|
|
#pod |
|
59
|
|
|
|
|
|
|
#pod This method returns a reference to a hash of arguments, rewriting the given |
|
60
|
|
|
|
|
|
|
#pod hash reference to place arguments that are intended to become element |
|
61
|
|
|
|
|
|
|
#pod attributes into the C parameter. |
|
62
|
|
|
|
|
|
|
#pod |
|
63
|
|
|
|
|
|
|
#pod It moves attributes listed in the results of the C method. |
|
64
|
|
|
|
|
|
|
#pod |
|
65
|
|
|
|
|
|
|
#pod =cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub rewrite_arg { |
|
68
|
57
|
|
|
57
|
1
|
69
|
my ($class, $given_arg) = @_; |
|
69
|
57
|
100
|
|
|
|
268
|
my $arg = { $given_arg ? %$given_arg : () }; |
|
70
|
|
|
|
|
|
|
|
|
71
|
57
|
|
|
|
|
167
|
my %bool = map { $_ => 1 } $class->boolean_args; |
|
|
49
|
|
|
|
|
140
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
57
|
|
|
|
|
155
|
for ($class->attribute_args) { |
|
74
|
353
|
100
|
|
|
|
664
|
if (exists $arg->{$_}) { |
|
75
|
82
|
|
|
|
|
199
|
$arg->{attr}{$_} = delete $arg->{$_}; |
|
76
|
82
|
50
|
|
|
|
200
|
$arg->{attr}{$_} = $arg->{attr}{$_} ? $_ : undef if $bool{$_}; |
|
|
|
100
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
57
|
|
|
|
|
176
|
return $arg; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#pod =head2 C< attribute_args > |
|
84
|
|
|
|
|
|
|
#pod |
|
85
|
|
|
|
|
|
|
#pod This method returns a list of argument names, the values of which should be |
|
86
|
|
|
|
|
|
|
#pod used as HTML element attributes. |
|
87
|
|
|
|
|
|
|
#pod |
|
88
|
|
|
|
|
|
|
#pod The default implementation climbs the plugin's inheritance tree, calling |
|
89
|
|
|
|
|
|
|
#pod C<_attribute_args> and pushing all the results onto a list from which unique |
|
90
|
|
|
|
|
|
|
#pod results are then returned. |
|
91
|
|
|
|
|
|
|
#pod |
|
92
|
|
|
|
|
|
|
#pod =cut |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub attribute_args { |
|
95
|
57
|
|
|
57
|
1
|
71
|
my ($self) = shift; |
|
96
|
57
|
|
|
|
|
66
|
return @{ $self->{_attribute_args} }; |
|
|
57
|
|
|
|
|
247
|
|
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
219
|
|
|
219
|
|
608
|
sub _attribute_args { qw(id name class tabindex) } |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
#pod =head2 C< boolean_args > |
|
102
|
|
|
|
|
|
|
#pod |
|
103
|
|
|
|
|
|
|
#pod This method returns a list of argument names, the values of which should be |
|
104
|
|
|
|
|
|
|
#pod treated as booleans. |
|
105
|
|
|
|
|
|
|
#pod |
|
106
|
|
|
|
|
|
|
#pod The default implementation climbs the plugin's inheritance tree, calling |
|
107
|
|
|
|
|
|
|
#pod C<_boolean_args> and pushing all the results onto a list from which unique |
|
108
|
|
|
|
|
|
|
#pod results are then returned. |
|
109
|
|
|
|
|
|
|
#pod |
|
110
|
|
|
|
|
|
|
#pod =cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub boolean_args { |
|
113
|
57
|
|
|
57
|
1
|
73
|
my ($self) = shift; |
|
114
|
57
|
|
|
|
|
64
|
return @{ $self->{_boolean_args} }; |
|
|
57
|
|
|
|
|
243
|
|
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
302
|
|
|
302
|
|
366
|
sub _boolean_args { () } |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
#pod =head2 C< provided_widgets > |
|
120
|
|
|
|
|
|
|
#pod |
|
121
|
|
|
|
|
|
|
#pod This method should be implemented by any plugin. It returns a list of method |
|
122
|
|
|
|
|
|
|
#pod names which a factor should delegate to this plugin. |
|
123
|
|
|
|
|
|
|
#pod |
|
124
|
|
|
|
|
|
|
#pod =cut |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub provided_widgets { |
|
127
|
0
|
|
|
0
|
1
|
|
Carp::croak |
|
128
|
|
|
|
|
|
|
"something called abstract provided_widgets in HTML::Widget::Plugin"; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |