| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
|
2
|
|
|
|
|
|
|
## CSS Object Oriented - ~/lib/CSS/Object/Element.pm |
|
3
|
|
|
|
|
|
|
## Version v0.1.0 |
|
4
|
|
|
|
|
|
|
## Copyright(c) 2020 DEGUEST Pte. Ltd. |
|
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <@sitael.local> |
|
6
|
|
|
|
|
|
|
## Created 2020/06/21 |
|
7
|
|
|
|
|
|
|
## Modified 2020/06/21 |
|
8
|
|
|
|
|
|
|
## |
|
9
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
|
10
|
|
|
|
|
|
|
package CSS::Object::Element; |
|
11
|
|
|
|
|
|
|
BEGIN |
|
12
|
|
|
|
|
|
|
{ |
|
13
|
6
|
|
|
6
|
|
2666
|
use strict; |
|
|
6
|
|
|
|
|
12
|
|
|
|
6
|
|
|
|
|
189
|
|
|
14
|
6
|
|
|
6
|
|
31
|
use warnings; |
|
|
6
|
|
|
|
|
13
|
|
|
|
6
|
|
|
|
|
176
|
|
|
15
|
6
|
|
|
6
|
|
30
|
use parent qw( Module::Generic ); |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
47
|
|
|
16
|
6
|
|
|
6
|
|
3221
|
use CSS::Object::Format; |
|
|
6
|
|
|
|
|
22
|
|
|
|
6
|
|
|
|
|
95
|
|
|
17
|
6
|
|
|
6
|
|
1972
|
use Devel::Confess; |
|
|
6
|
|
|
|
|
13
|
|
|
|
6
|
|
|
|
|
31
|
|
|
18
|
6
|
|
|
6
|
|
2706
|
our $VERSION = 'v0.1.0'; |
|
19
|
|
|
|
|
|
|
}; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub init |
|
22
|
|
|
|
|
|
|
{ |
|
23
|
175
|
|
|
175
|
1
|
319
|
my $self = shift( @_ ); |
|
24
|
175
|
|
|
|
|
373
|
$self->{format} = ''; |
|
25
|
175
|
|
|
|
|
342
|
$self->{_init_strict_use_sub} = 1; |
|
26
|
175
|
|
|
|
|
621
|
$self->SUPER::init( @_ ); |
|
27
|
175
|
100
|
|
|
|
2454
|
unless( $self->_is_a( $self->{format}, 'CSS::Object::Format' ) ) |
|
28
|
|
|
|
|
|
|
{ |
|
29
|
7
|
|
|
|
|
74
|
my $format = CSS::Object::Format->new( |
|
30
|
|
|
|
|
|
|
debug => $self->debug |
|
31
|
|
|
|
|
|
|
); |
|
32
|
7
|
|
|
|
|
37
|
$self->format( $format ); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
175
|
|
|
|
|
2296
|
return( $self ); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub add_to |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
0
|
|
|
0
|
1
|
0
|
my $self = shift( @_ ); |
|
40
|
0
|
|
0
|
|
|
0
|
my $css = shift( @_ ) || return( $self->error( "No css object was provided to add our element to it." ) ); |
|
41
|
0
|
0
|
|
|
|
0
|
return( $self->error( "CSS object provided (", overload::StrVal( $css ), ") is not actually a CSS::Object object." ) ) if( !$self->_is_a( $css, 'CSS::Object' ) ); |
|
42
|
0
|
|
|
|
|
0
|
$self->format->indent( $css->format->indent ); |
|
43
|
0
|
|
|
|
|
0
|
$css->add_element( $self ); |
|
44
|
0
|
|
|
|
|
0
|
return( $self ); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
1
|
0
|
sub as_string { return( shift->error( "This method has not been implemented in this class." ) ); } |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
0
|
0
|
0
|
sub class { return( ref( $_[0] ) ); } |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub format |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
800
|
|
|
800
|
1
|
8841
|
my $self = shift( @_ ); |
|
54
|
800
|
|
|
|
|
1340
|
my $format; |
|
55
|
800
|
100
|
|
|
|
1935
|
if( @_ ) |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
|
|
|
|
|
|
# $format = $self->_set_get_object( 'format', 'CSS::Object::Format', @_ ) || return; |
|
58
|
161
|
|
|
|
|
282
|
my $val = shift( @_ ); |
|
59
|
|
|
|
|
|
|
# $self->message( 3, "Setting new formatter '$val' for our class '", $self->class, "'." ); |
|
60
|
161
|
|
|
|
|
261
|
my $format; |
|
61
|
161
|
50
|
0
|
|
|
525
|
if( $self->_is_a( $val, 'CSS::Object::Format' ) ) |
|
|
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
{ |
|
63
|
161
|
|
|
|
|
2592
|
my $clone = $val->clone; |
|
64
|
|
|
|
|
|
|
## Make a copy for ourself |
|
65
|
161
|
100
|
|
|
|
15065
|
if( $self->format ) |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
30
|
|
|
|
|
629
|
my( $p, $f, $l ) = caller(); |
|
68
|
|
|
|
|
|
|
# $self->message( 3, "New formatter provided for our class '", $self->class, "' called from package $p at line $l in file $f to set indent from '", $self->format->indent->scalar, "' to '", $clone->indent->scalar, "'." ); |
|
69
|
30
|
|
|
|
|
89
|
$clone->copy_parameters_from( $self->format ); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
161
|
|
50
|
|
|
10127
|
$format = $self->_set_get_object( 'format', 'CSS::Object::Format', $clone ) || return; |
|
72
|
|
|
|
|
|
|
# die( "Provided value (", overload::StrVal( $val ), " and stored value (", overload::StrVal( $format ), ") are the same. It should have been cloned.\n" ) if( overload::StrVal( $val ) eq overload::StrVal( $format ) ); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
## format as a class name |
|
75
|
|
|
|
|
|
|
elsif( !ref( $val ) && CORE::index( $val, '::' ) != -1 ) |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
0
|
0
|
|
|
|
0
|
$self->_load_class( $val ) || return; |
|
78
|
0
|
|
0
|
|
|
0
|
$format = $val->new( debug => $self->debug ) || return( $self->pass_error( $val->error ) ); |
|
79
|
0
|
|
|
|
|
0
|
$self->_set_get_object( 'format', 'CSS::Object::Format', $format ); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
else |
|
82
|
|
|
|
|
|
|
{ |
|
83
|
0
|
|
|
|
|
0
|
return( $self->error( "Unknown format \"$val\". I do not know what to do with it." ) ); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
161
|
|
|
|
|
4647
|
return( $format ); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
639
|
|
|
|
|
1739
|
return( $self->_set_get_object( 'format', 'CSS::Object::Format' ) ); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=encoding utf-8 |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 NAME |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
CSS::Object::Element - CSS Object Oriented Element |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
package CSS::Object::Comment; |
|
103
|
|
|
|
|
|
|
use parent qw( CSS::Object::Element ); |
|
104
|
|
|
|
|
|
|
my $cmt = CSS::Object::Comment->new( "No comment" ) || |
|
105
|
|
|
|
|
|
|
die( CSS::Object::Comment->error ); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 VERSION |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
v0.1.0 |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L<CSS::Object::Element> is a base class for all L<CSS::Object> elements that get added to the style sheet. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 new |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This is the base method to instantiate object. It takes by default the following arguments and instantiate an L<CSS::Object::Format> object if none was provided. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=over 4 |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item I<debug> |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This is an integer. The bigger it is and the more verbose is the output. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item I<format> |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This is a L<CSS::Object::Format> object or one of its child modules. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=back |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 METHODS |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 add_to |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Provided with a L<CSS::Object> and this add our object to the css object array of elements by calling L<CSS::Object/add_element>. Elements here are top level elements which are css rules. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 as_string |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This method must be overridden by the child class. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 format |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This is a L<CSS::Object::Format> object or one of its child modules. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
head1 AUTHOR |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
L<CSS::Object> |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Copyright (c) 2020 DEGUEST Pte. Ltd. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
You can use, copy, modify and redistribute this package and associated |
|
160
|
|
|
|
|
|
|
files under the same terms as Perl itself. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |