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

Diff of /messaging/manakai/lib/Message/DOM/CSSRule.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by wakaba, Sat Dec 22 06:29:32 2007 UTC revision 1.2 by wakaba, Sat Dec 22 06:57:46 2007 UTC
# Line 2  package Message::DOM::CSSRule; Line 2  package Message::DOM::CSSRule;
2  use strict;  use strict;
3  our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};  our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
4  push our @ISA, 'Message::IF::CSSRule';  push our @ISA, 'Message::IF::CSSRule';
5    require Scalar::Util;
6    
7  ## |CSSRule| constants  ## |CSSRule| constants
8    
# Line 13  sub FONT_FACE_RULE () { 5 } Line 14  sub FONT_FACE_RULE () { 5 }
14  sub PAGE_RULE () { 6 }  sub PAGE_RULE () { 6 }
15  sub NAMESPACE_RULE () { 7 }  sub NAMESPACE_RULE () { 7 }
16    
 sub AUTOLOAD {  
   my $method_name = our $AUTOLOAD;  
   $method_name =~ s/.*:://;  
   return if $method_name eq 'DESTROY';  
   
   if ({  
     ## Read-only attributes (trivial accessors)  
     parent_rule => 1,  
     parent_style_sheet => 1,  
   }->{$method_name}) {  
     no strict 'refs';  
     eval qq{  
       sub $method_name (\$) {  
         return \${\$_[0]}->{$method_name};  
       }  
     };  
     goto &{ $AUTOLOAD };  
   } else {  
     require Carp;  
     Carp::croak (qq<Can't locate method "$AUTOLOAD">);  
   }  
 } # AUTOLOAD  
   
17  ## |CSSRule| attributes  ## |CSSRule| attributes
18    
19  sub css_text ($) {  sub css_text ($) {
20    die "$0: ".(ref $self)."->css_text: Not implemented";    die "$0: ".(ref $self)."->css_text: Not implemented";
21  } # css_text  } # css_text
22    
23  sub parent_rule ($);  sub parent_rule ($) {
24      return ${$_[0]}->{parent_rule};
25  sub parent_style_sheet ($);  } # parent_rule
26    
27    sub parent_style_sheet ($) {
28      if (${$_[0]}->{parent_style_sheet}) {
29        return ${$_[0]}->{parent_style_sheet};
30      } elsif (${$_[0]}->{parent_rule}) {
31        local $Error::Depth = $Error::Depth + 1;
32        return ${$_[0]}->{parent_rule}->parent_style_sheet;
33      } else {
34        ## NOTE: Not in the CSSOM ED: If the |CSSRule| object is not
35        ## yet associated to any CSS style sheet.  Such object should not be
36        ## returned to applications - that is, the intention is that only
37        ## modules belonging to manakai may get |undef| from the
38        ## |parent_style_sheet| attribute during the construction of CSSOM.
39        ## Therefore, this is not counted as a manakai extension to CSSOM spec.
40        return undef;
41      }
42    } # parent_style_sheet
43    
44  sub type ($) {  sub type ($) {
45    die "$0: ".(ref $self)."->type: Not implemented";    die "$0: ".(ref $self)."->type: Not implemented";
# Line 55  push our @ISA, 'Message::DOM::CSSRule', Line 50  push our @ISA, 'Message::DOM::CSSRule',
50    
51  sub ____new ($$$) {  sub ____new ($$$) {
52    my $self = bless \{_selector => $_[1], style => $_[2]}, $_[0];    my $self = bless \{_selector => $_[1], style => $_[2]}, $_[0];
53    ## TODO: style -> owner    ${$_[2]}->{parent_rule} = $self;
54      Scalar::Util::weaken (${$_[2]}->{parent_rule});
55    return $self;    return $self;
56  } # ____new  } # ____new
57    
# Line 97  push our @ISA, 'Message::DOM::CSSRule', Line 93  push our @ISA, 'Message::DOM::CSSRule',
93    
94  sub ____new ($$$$) {  sub ____new ($$$$) {
95    my $self = bless \{href => $_[1], media => $_[2], style_sheet => $_[3]}, $_[0];    my $self = bless \{href => $_[1], media => $_[2], style_sheet => $_[3]}, $_[0];
96    ## TODO: $_[3] owner_style_sheet    ${$_[3]}->{owner_rule} = $self;
97      Scalar::Util::weaken (${$_[3]}->{owner_rule});
98    return $self;    return $self;
99  } # ____new  } # ____new
100    
# Line 127  push our @ISA, 'Message::DOM::CSSRule', Line 124  push our @ISA, 'Message::DOM::CSSRule',
124  sub ____new ($$$) {  sub ____new ($$$) {
125    my $self = bless \{media => $_[1], css_rules => $_[2]}, $_[0];    my $self = bless \{media => $_[1], css_rules => $_[2]}, $_[0];
126    for (@{$_[2]}) {    for (@{$_[2]}) {
127      ## TODO: owner_rule      ${$_}->{parent_rule} = $self;
128        Scalar::Util::weaken (${$_}->{parent_rule});
129    }    }
130    return $self;    return $self;
131  } # ____new  } # ____new
# Line 154  push our @ISA, 'Message::DOM::CSSRule', Line 152  push our @ISA, 'Message::DOM::CSSRule',
152    
153  sub ____new ($$) {  sub ____new ($$) {
154    my $self = bless \{style => $_[1]}, $_[0];    my $self = bless \{style => $_[1]}, $_[0];
155      ${$_[2]}->{parent_rule} = $self;
156      Scalar::Util::weaken (${$_[2]}->{parent_rule});
157      return $self;
158  } # ____new  } # ____new
159    
160  ## |CSSRule| attributes  ## |CSSRule| attributes
# Line 173  push our @ISA, 'Message::DOM::CSSRule', Line 174  push our @ISA, 'Message::DOM::CSSRule',
174    
175  sub ____new ($$$) {  sub ____new ($$$) {
176    my $self = bless \{_selector => $_[1], style => $_[2]}, $_[0];    my $self = bless \{_selector => $_[1], style => $_[2]}, $_[0];
177    ## TODO: style -> owner    ${$_[2]}->{parent_rule} = $self;
178      Scalar::Util::weaken (${$_[2]}->{parent_rule});
179    return $self;    return $self;
180  } # ____new  } # ____new
181    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24