18 |
|
|
19 |
if ($prop_def) { |
if ($prop_def) { |
20 |
no strict 'refs'; |
no strict 'refs'; |
21 |
*{ $method_name } = sub { |
if ($prop_def->{serialize}) { |
22 |
## TODO: setter |
*{ $method_name } = sub { |
23 |
|
## TODO: setter |
24 |
my $self = $_[0]; |
|
25 |
my $value = $$self->{$prop_def->{key}}; |
my $self = $_[0]; |
26 |
if ($value) { |
my $value = $$self->{$prop_def->{key}}; |
27 |
return $prop_def->{serialize}->($self, $prop_def->{css}, $value->[0]); |
if ($value) { |
28 |
} else { |
return $prop_def->{serialize}->($self, $prop_def->{css}, $value->[0]); |
29 |
return ""; |
} else { |
30 |
} |
return ''; |
31 |
## ISSUE: If one of shorthand component properties is !important? |
} |
32 |
}; |
}; |
33 |
|
} elsif ($prop_def->{serialize_shorthand} or |
34 |
|
$prop_def->{serialize_multiple}) { |
35 |
|
*{ $method_name } = sub { |
36 |
|
## TODO: setter |
37 |
|
|
38 |
|
my $self = $_[0]; |
39 |
|
my $v = ($prop_def->{serialize_shorthand} or |
40 |
|
$prop_def->{serialize_multiple})->($self); |
41 |
|
if (defined $v->{$prop_def->{css}}) { |
42 |
|
return $v->{$prop_def->{css}}->[0]; |
43 |
|
} else { |
44 |
|
return ''; |
45 |
|
} |
46 |
|
## ISSUE: If one of shorthand component properties is !important? |
47 |
|
}; |
48 |
|
} else { |
49 |
|
die qq<Implementation error: Can't load serializer for "$AUTOLOAD">; |
50 |
|
} |
51 |
goto &{ $AUTOLOAD }; |
goto &{ $AUTOLOAD }; |
52 |
} else { |
} else { |
53 |
require Carp; |
require Carp; |
78 |
my $self = $_[0]; |
my $self = $_[0]; |
79 |
my $r = ''; |
my $r = ''; |
80 |
my %serialized; |
my %serialized; |
81 |
for (grep {$$self->{$_}} keys %$$self) { |
for (sort {$a cmp $b} grep {$$self->{$_}} keys %$$self) { |
82 |
my $prop_def = $Whatpm::CSS::Parser::Key->{$_}; |
my $prop_def = $Whatpm::CSS::Parser::Key->{$_}; |
83 |
next unless $prop_def; |
next unless $prop_def; |
84 |
|
|
87 |
$serialized{$prop_def->{serialize_multiple}} = 1; |
$serialized{$prop_def->{serialize_multiple}} = 1; |
88 |
my $v = $prop_def->{serialize_multiple}->($self); |
my $v = $prop_def->{serialize_multiple}->($self); |
89 |
for my $prop_name (sort {$a cmp $b} keys %$v) { |
for my $prop_name (sort {$a cmp $b} keys %$v) { |
90 |
$r .= ' ' . $prop_name . ': ' . $v->{$prop_name} . ";\n" |
$r .= ' ' . $prop_name . ': ' . $v->{$prop_name}->[0] |
91 |
|
. $v->{$prop_name}->[1] . ";\n" |
92 |
} |
} |
93 |
} |
} |
94 |
} else { |
} else { |
172 |
|
|
173 |
if ($prop_def) { |
if ($prop_def) { |
174 |
no strict 'refs'; |
no strict 'refs'; |
175 |
*{ $method_name } = sub { |
if ($prop_def->{compute} or $prop_def->{compute_multiple}) { |
176 |
## TODO: setter |
*{ $method_name } = sub { |
177 |
|
## TODO: setter |
178 |
my $self = $_[0]; |
|
179 |
if ($prop_def->{compute} or $prop_def->{compute_multiple}) { |
my $self = $_[0]; |
180 |
my $value = $$self->{cascade}->get_computed_value |
my $value = $$self->{cascade}->get_computed_value |
181 |
($$self->{element}, $prop_def->{css}); |
($$self->{element}, $prop_def->{css}); |
182 |
if ($value) { |
if ($value) { |
184 |
} else { |
} else { |
185 |
return ''; |
return ''; |
186 |
} |
} |
187 |
} elsif ($prop_def->{serialize_multiple}) { |
}; |
188 |
my $v = $prop_def->{serialize_multiple}->($self); |
} elsif ($prop_def->{serialize_shorthand} or |
189 |
|
$prop_def->{serialize_multiple}) { |
190 |
|
*{ $method_name } = sub { |
191 |
|
## TODO: setter |
192 |
|
my $self = shift; |
193 |
|
|
194 |
|
my $v = ($prop_def->{serialize_shorthand} or |
195 |
|
$prop_def->{serialize_multiple})->($self); |
196 |
if (defined $v->{$prop_def->{css}}) { |
if (defined $v->{$prop_def->{css}}) { |
197 |
return $v->{$prop_def->{css}}; |
return $v->{$prop_def->{css}}->[0]; |
198 |
} else { |
} else { |
199 |
return ''; |
return ''; |
200 |
} |
} |
201 |
} else { |
}; |
202 |
## TODO: This should be an error of the implementation. |
} else { |
203 |
## However, currently some shorthand properties does not have |
## TODO: This should be an error of the implementation. |
204 |
## serializer. |
## However, currently some shorthand properties does not have |
205 |
## TODO: Remove {serialize} from shorthand properties, since |
## serializer. |
206 |
## they have no effect. |
## TODO: Remove {serialize} from shorthand properties, since |
207 |
warn "$0: No computed value function for $method_name"; |
## they have no effect. |
208 |
#die "$0: No computed value function for $method_name"; |
warn "$0: No computed value function for $method_name"; |
209 |
} |
#die "$0: No computed value function for $method_name"; |
210 |
}; |
*{ $method_name } = sub { }; |
211 |
|
} |
212 |
goto &{ $AUTOLOAD }; |
goto &{ $AUTOLOAD }; |
213 |
} else { |
} else { |
214 |
require Carp; |
require Carp; |
251 |
$serialized{$prop_def->{serialize_multiple}} = 1; |
$serialized{$prop_def->{serialize_multiple}} = 1; |
252 |
my $v = $prop_def->{serialize_multiple}->($self); |
my $v = $prop_def->{serialize_multiple}->($self); |
253 |
for my $prop_name (sort {$a cmp $b} keys %$v) { |
for my $prop_name (sort {$a cmp $b} keys %$v) { |
254 |
$r .= ' ' . $prop_name . ': ' . $v->{$prop_name} . ";\n" |
$r .= ' ' . $prop_name . ': ' . $v->{$prop_name}->[0] |
255 |
|
. $v->{$prop_name}->[1] . ";\n" |
256 |
} |
} |
257 |
} |
} |
258 |
} else { |
} else { |