/[suikacvs]/messaging/manakai/lib/Message/DOM/CSSStyleDeclaration.pm
Suika

Contents of /messaging/manakai/lib/Message/DOM/CSSStyleDeclaration.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Mon Dec 31 03:02:29 2007 UTC (16 years, 10 months ago) by wakaba
Branch: MAIN
Changes since 1.2: +49 -4 lines
++ manakai/lib/Message/DOM/ChangeLog	31 Dec 2007 03:02:21 -0000
2007-12-31  Wakaba  <wakaba@suika.fam.cx>

	* CSSStyleDeclaration.pm (AUTOLOAD): Getter for attributes
	reflecting CSS property is implemented.
	(css_text): Getter is implemented.

1 wakaba 1.1 package Message::DOM::CSSStyleDeclaration;
2     use strict;
3 wakaba 1.3 our $VERSION=do{my @r=(q$Revision: 1.2 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
4 wakaba 1.1 push our @ISA, 'Message::IF::CSSStyleDeclaration';
5    
6     sub ____new ($) {
7     return bless \{}, $_[0];
8     } # ____new
9    
10 wakaba 1.3 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 wakaba 1.1 ## |CSSStyleDeclaration| attributes
40    
41 wakaba 1.2 sub css_text ($;$) {
42 wakaba 1.3 ## TODO: setter
43    
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 wakaba 1.2 } # css_text
61    
62 wakaba 1.1 sub parent_rule ($) {
63     return ${$_[0]}->{parent_rule};
64     } # parent_rule
65    
66     ## TODO: Implement other methods and attributes
67    
68     package Message::IF::CSSStyleDeclaration;
69    
70     1;
71 wakaba 1.3 ## $Date: 2007/12/23 08:18:59 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24