| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
################################################################################################### |
|
2
|
|
|
|
|
|
|
# Copyright 2013/2014 by Marcel Greter |
|
3
|
|
|
|
|
|
|
# This file is part of OCBNET-CSS3 (GPL3) |
|
4
|
|
|
|
|
|
|
#################################################################################################### |
|
5
|
|
|
|
|
|
|
package OCBNET::CSS3::DOM::Property; |
|
6
|
|
|
|
|
|
|
#################################################################################################### |
|
7
|
|
|
|
|
|
|
our $VERSION = '0.2.5'; |
|
8
|
|
|
|
|
|
|
#################################################################################################### |
|
9
|
|
|
|
|
|
|
|
|
10
|
11
|
|
|
11
|
|
63
|
use strict; |
|
|
11
|
|
|
|
|
24
|
|
|
|
11
|
|
|
|
|
386
|
|
|
11
|
11
|
|
|
11
|
|
58
|
use warnings; |
|
|
11
|
|
|
|
|
21
|
|
|
|
11
|
|
|
|
|
419
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#################################################################################################### |
|
14
|
11
|
|
|
11
|
|
55
|
use base 'OCBNET::CSS3'; |
|
|
11
|
|
|
|
|
24
|
|
|
|
11
|
|
|
|
|
1045
|
|
|
15
|
11
|
|
|
11
|
|
61
|
use Scalar::Util 'blessed'; |
|
|
11
|
|
|
|
|
19
|
|
|
|
11
|
|
|
|
|
591
|
|
|
16
|
|
|
|
|
|
|
#################################################################################################### |
|
17
|
|
|
|
|
|
|
|
|
18
|
11
|
|
|
11
|
|
59
|
use OCBNET::CSS3::Regex::Comments; |
|
|
11
|
|
|
|
|
19
|
|
|
|
11
|
|
|
|
|
6162
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#################################################################################################### |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# static getter |
|
23
|
|
|
|
|
|
|
#************************************************************************************************** |
|
24
|
2
|
|
|
2
|
0
|
10
|
sub type { return 'property' } |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# advanced getters |
|
27
|
|
|
|
|
|
|
#************************************************************************************************** |
|
28
|
55
|
|
|
55
|
0
|
163
|
sub key { uncomment $_[0]->{'key'} } |
|
29
|
55
|
|
|
55
|
0
|
180
|
sub value { uncomment $_[0]->{'value'} } |
|
30
|
1
|
|
|
1
|
0
|
5
|
sub comment { comments $_[0]->{'value'} } |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#################################################################################################### |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# set the readed text |
|
35
|
|
|
|
|
|
|
# parse key and value |
|
36
|
|
|
|
|
|
|
sub set |
|
37
|
|
|
|
|
|
|
{ |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# get input arguments |
|
40
|
57
|
|
|
57
|
0
|
105
|
my ($self, $text) = @_; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# call super class method |
|
43
|
57
|
|
|
|
|
205
|
$self->SUPER::set($text); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# split the key and the value |
|
46
|
|
|
|
|
|
|
# leave whitespace to save later |
|
47
|
57
|
|
|
|
|
176
|
my ($key, $value) = split(':', $text, 2); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# remove whitespace |
|
50
|
57
|
100
|
|
|
|
2586
|
my $whitespace = |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
{ |
|
52
|
|
|
|
|
|
|
'key-prefix' => $key =~ s/\A((?:\s+|$re_comment)+)//s ? $1 : '', |
|
53
|
|
|
|
|
|
|
'key-postfix' => $key =~ s/\A((?:\s+|$re_comment)+)//s ? $1 : '', |
|
54
|
|
|
|
|
|
|
'value-prefix' => $value =~ s/((?:\s+|$re_comment)+)\z//s ? $1 : '', |
|
55
|
|
|
|
|
|
|
'value-postfix' => $value =~ s/((?:\s+|$re_comment)+)\z//s ? $1 : '', |
|
56
|
|
|
|
|
|
|
}; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# store whitespace for rendering |
|
59
|
57
|
|
|
|
|
207
|
$self->{'whitespace'} = $whitespace; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# store key and value |
|
62
|
|
|
|
|
|
|
# as parsed (with comments) |
|
63
|
57
|
|
|
|
|
124
|
$self->{'key'} = $key; |
|
64
|
57
|
|
|
|
|
99
|
$self->{'value'} = $value; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# only parse if parent is a valid block |
|
67
|
57
|
100
|
66
|
|
|
186
|
if ($self->parent && $self->parent->styles) |
|
68
|
|
|
|
|
|
|
{ |
|
69
|
|
|
|
|
|
|
# uncomment key/value pair |
|
70
|
55
|
|
|
|
|
127
|
$key = $self->key; $value = $self->value; |
|
|
55
|
|
|
|
|
135
|
|
|
71
|
|
|
|
|
|
|
# parse key/value pairs into parent styles |
|
72
|
55
|
|
|
|
|
153
|
$self->parent->styles->set($key, $value); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# instance |
|
76
|
57
|
|
|
|
|
223
|
return $self; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
# EO sub set |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#################################################################################################### |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub render |
|
84
|
|
|
|
|
|
|
{ |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# get input arguments |
|
87
|
4
|
|
|
4
|
0
|
7
|
my ($self, $comments, $indent) = @_; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# declare string |
|
90
|
4
|
|
|
|
|
8
|
my $code = ''; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# init default indent |
|
93
|
4
|
50
|
|
|
|
26
|
$indent = 0 unless $indent; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# print to debug the css "dom" tree |
|
96
|
|
|
|
|
|
|
# print " " x $indent, $self, "\n"; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# put back the original code |
|
99
|
4
|
|
|
|
|
9
|
$code .= $self->{'whitespace'}->{'key-prefix'}; |
|
100
|
4
|
|
|
|
|
11
|
$code .= $self->{'key'}; |
|
101
|
4
|
|
|
|
|
8
|
$code .= $self->{'whitespace'}->{'key-postfix'}; |
|
102
|
4
|
|
|
|
|
6
|
$code .= ':'; |
|
103
|
4
|
|
|
|
|
8
|
$code .= $self->{'whitespace'}->{'value-prefix'}; |
|
104
|
4
|
|
|
|
|
6
|
$code .= $self->{'value'}; |
|
105
|
4
|
|
|
|
|
8
|
$code .= $self->{'whitespace'}->{'value-postfix'}; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# re-add suffix if one has been parsed |
|
108
|
4
|
50
|
|
|
|
13
|
$code .= $self->suffix if $self->suffix; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# return code |
|
111
|
4
|
|
|
|
|
15
|
return $code; |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
# EO sub render |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
#################################################################################################### |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# load regex for vendor prefixes |
|
119
|
|
|
|
|
|
|
#************************************************************************************************** |
|
120
|
11
|
|
|
11
|
|
66
|
use OCBNET::CSS3::Regex::Base qw($re_identifier); |
|
|
11
|
|
|
|
|
19
|
|
|
|
11
|
|
|
|
|
1655
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# add basic extended type with highest priority |
|
123
|
|
|
|
|
|
|
#************************************************************************************************** |
|
124
|
|
|
|
|
|
|
unshift @OCBNET::CSS3::types, [ |
|
125
|
|
|
|
|
|
|
qr/\A\s*$re_identifier\s*\:/is, |
|
126
|
|
|
|
|
|
|
'OCBNET::CSS3::DOM::Property', |
|
127
|
|
|
|
|
|
|
sub { ! $_[1] } |
|
128
|
|
|
|
|
|
|
]; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
#################################################################################################### |
|
131
|
|
|
|
|
|
|
#################################################################################################### |
|
132
|
|
|
|
|
|
|
1; |