6 use Syntax::Keyword::Gather;
11 die "Can't import CSS::Declare into a scope when already compiling one that uses it"
13 my ($class, @args) = @_;
14 my $opts = shift(@args) if ref($args[0]) eq 'HASH';
15 my $target = $class->_find_target(0, $opts);
16 my $unex = $class->_export_tags_into($target);
17 $class->_install_unexporter($unex);
22 my ($class, $extra_levels, $opts) = @_;
23 return $opts->{into} if defined($opts->{into});
24 my $level = ($opts->{into_level} || 1) + $extra_levels;
25 return (caller($level))[0];
91 layer_background_color
92 layer_background_image
96 layout_grid_char_spacing
157 scrollbar_arrow_color
159 scrollbar_dark_shadow_color
161 scrollbar_highlight_color
162 scrollbar_shadow_color
163 scrollbar_3d_light_color
164 scrollbar_track_color
176 text_underline_position
194 sub _export_tags_into {
195 my ($class, $into) = @_;
196 for my $property (@properties) {
197 my $property_name = $property;
198 $property_name =~ tr/_/-/;
200 *{"$into\::$property"} = sub ($) { return ($property_name => $_[0]) };
203 foreach my $property (@properties) {
205 delete ${"${into}::"}{$property}
211 sub _install_unexporter {
212 my ($class, $unex) = @_;
213 $^H |= 0x20000; # localize %^H
214 $^H{'CSS::Declare::Unex'} = bless($unex, 'CSS::Declare::Unex');
219 return join q{ }, gather {
220 while (my ($selector, $declarations) = splice(@css, 0, 2)) {
221 take "$selector "._generate_declarations($declarations)
226 sub _generate_declarations {
227 my $declarations = shift;
229 return '{'.join(q{;}, gather {
230 while (my ($property, $value) = splice(@{$declarations}, 0, 2)) {
231 take "$property:$value"
236 package CSS::Declare::Unex;
238 sub DESTROY { local $@; eval { $_[0]->(); 1 } || warn "ARGH: $@" }