7 |
return bless \{}, $_[0]; |
return bless \{}, $_[0]; |
8 |
} # ____new |
} # ____new |
9 |
|
|
10 |
|
sub AUTOLOAD { |
11 |
|
my $method_name = our $AUTOLOAD; |
12 |
|
$method_name =~ s/.*:://; |
13 |
|
return if $method_name eq 'DESTROY'; |
14 |
|
|
15 |
|
require Whatpm::CSS::Parser; |
16 |
|
my $prop_def = $Whatpm::CSS::Parser::Attr->{$method_name}; |
17 |
|
|
18 |
|
if ($prop_def) { |
19 |
|
no strict 'refs'; |
20 |
|
*{ $method_name } = sub { |
21 |
|
## TODO: setter |
22 |
|
|
23 |
|
my $self = $_[0]; |
24 |
|
my $value = $$self->{$prop_def->{key}}; |
25 |
|
if ($value) { |
26 |
|
return $prop_def->{serialize}->($self, $prop_def->{css}, $value->[0]); |
27 |
|
} else { |
28 |
|
return undef; |
29 |
|
} |
30 |
|
## TODO: null? ""? ... if not set? |
31 |
|
}; |
32 |
|
goto &{ $AUTOLOAD }; |
33 |
|
} else { |
34 |
|
require Carp; |
35 |
|
Carp::croak (qq<Can't locate method "$AUTOLOAD">); |
36 |
|
} |
37 |
|
} # AUTOLOAD |
38 |
|
|
39 |
## |CSSStyleDeclaration| attributes |
## |CSSStyleDeclaration| attributes |
40 |
|
|
41 |
sub css_text ($;$) { |
sub css_text ($;$) { |
42 |
## TODO: Implement ... |
## TODO: setter |
43 |
return ''; |
|
44 |
|
require Whatpm::CSS::Parser; |
45 |
|
my $self = $_[0]; |
46 |
|
my $r = ''; |
47 |
|
for (grep {$$self->{$_}} keys %$$self) { |
48 |
|
my $prop_def = $Whatpm::CSS::Parser::Key->{$_}; |
49 |
|
next unless $prop_def; |
50 |
|
my $value = $$self->{$_}; |
51 |
|
my $s = $prop_def->{serialize}->($self, $prop_def->{css}, $value->[0]); |
52 |
|
if (defined $s) { |
53 |
|
$r .= ' ' . $prop_def->{css} . ': ' . $s; |
54 |
|
$r .= ' !' . $value->[1] if defined $value->[1]; |
55 |
|
$r .= ";\n"; |
56 |
|
} |
57 |
|
} |
58 |
|
## TODO: shorthands |
59 |
|
return $r; |
60 |
} # css_text |
} # css_text |
61 |
|
|
62 |
sub parent_rule ($) { |
sub parent_rule ($) { |