/[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.2 by wakaba, Sat Dec 22 06:57:46 2007 UTC revision 1.6 by wakaba, Mon Jan 14 03:55:23 2008 UTC
# Line 17  sub NAMESPACE_RULE () { 7 } Line 17  sub NAMESPACE_RULE () { 7 }
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 $_[0])."->css_text: Not implemented";
21  } # css_text  } # css_text
22    
23  sub parent_rule ($) {  sub parent_rule ($) {
# Line 42  sub parent_style_sheet ($) { Line 42  sub parent_style_sheet ($) {
42  } # parent_style_sheet  } # parent_style_sheet
43    
44  sub type ($) {  sub type ($) {
45    die "$0: ".(ref $self)."->type: Not implemented";    die "$0: ".(ref $_[0])."->type: Not implemented";
46  } # type  } # type
47    
48  package Message::DOM::CSSStyleRule;  package Message::DOM::CSSStyleRule;
49  push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSStyleRule';  push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSStyleRule';
50    
51  sub ____new ($$$) {  sub ____new ($$$) {
52    my $self = bless \{_selector => $_[1], style => $_[2]}, $_[0];    my $self = bless \{_selectors => $_[1], style => $_[2]}, $_[0];
53    ${$_[2]}->{parent_rule} = $self;    ${$_[2]}->{parent_rule} = $self;
54    Scalar::Util::weaken (${$_[2]}->{parent_rule});    Scalar::Util::weaken (${$_[2]}->{parent_rule});
55    return $self;    return $self;
# Line 57  sub ____new ($$$) { Line 57  sub ____new ($$$) {
57    
58  ## |CSSRule| attributes  ## |CSSRule| attributes
59    
60  ## TODO: |css_text|  sub css_text ($;$) {
61      ## TODO: setter
62    
63      ## TODO: Browser compatibility
64      local $Error::Depth = $Error::Depth + 1;
65      return $_[0]->selector_text . " {\n" . $_[0]->style->css_text . "}\n";
66    } # css_text
67    
68  sub type ($) { Message::DOM::CSSRule::STYLE_RULE }  sub type ($) { Message::DOM::CSSRule::STYLE_RULE }
69    
70  ## |CSSStyleRule| attributes  ## |CSSStyleRule| attributes
71    
72  ## TODO: |selector_text|  sub selector_text ($;$) {
73      ## TODO: setter
74    
75      ## TODO: Browser-compatible serializer
76      ## TODO: This code does not work for cases where default namespace
77      ## has no namespace prefix declared.
78      my $self = $_[0];
79      require Whatpm::CSS::SelectorsSerializer;
80      return Whatpm::CSS::SelectorsSerializer->serialize_selector_text
81          ($$self->{_selectors}, sub {
82            ## TODO: We should have some caching mechanism, otherwise
83            ## too many computation for complex selectors in long style sheet.
84            return $self->parent_style_sheet->manakai_lookup_namespace_prefix
85                ($_[0]);
86          });
87    } # selector_text
88    
89  sub style ($) {  sub style ($) {
90    return ${$_[0]}->{style};    return ${$_[0]}->{style};
# Line 78  sub ____new ($$) { Line 99  sub ____new ($$) {
99    
100  ## |CSSRule| attributes  ## |CSSRule| attributes
101    
102  ## TODO: |css_text|  sub css_text ($;$) {
103      ## TODO: setter
104    
105      ## NOTE: It will be broken if |encoding| contains |"| or |\|, but this
106      ## is what browsers do.
107      return '@charset "'.${$_[0]}->{encoding}.'";';
108    } # css_text
109    
110  sub type ($) { Message::DOM::CSSRule::CHARSET_RULE }  sub type ($) { Message::DOM::CSSRule::CHARSET_RULE }
111    
# Line 173  package Message::DOM::CSSPageRule; Line 200  package Message::DOM::CSSPageRule;
200  push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSPageRule';  push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSPageRule';
201    
202  sub ____new ($$$) {  sub ____new ($$$) {
203    my $self = bless \{_selector => $_[1], style => $_[2]}, $_[0];    my $self = bless \{_selectors => $_[1], style => $_[2]}, $_[0];
204    ${$_[2]}->{parent_rule} = $self;    ${$_[2]}->{parent_rule} = $self;
205    Scalar::Util::weaken (${$_[2]}->{parent_rule});    Scalar::Util::weaken (${$_[2]}->{parent_rule});
206    return $self;    return $self;
# Line 187  sub type ($) { Message::DOM::CSSRule::PA Line 214  sub type ($) { Message::DOM::CSSRule::PA
214    
215  ## |CSSPageRule| attributes  ## |CSSPageRule| attributes
216    
217  ## TODO: |selector_text|  sub selector_text ($;$) {
218      ## TODO: setter
219    
220      ## TODO: Browser-compatible serializer
221      require Whatpm::CSS::SelectorsSerializer;
222      return Whatpm::CSS::SelectorsSerializer->serialize_test (${$_[0]}->{_selectors});
223    } # selector_text
224    
225  sub style ($) {  sub style ($) {
226    return ${$_[0]}->{style};    return ${$_[0]}->{style};
# Line 202  sub ____new ($$$) { Line 235  sub ____new ($$$) {
235    
236  ## |CSSRule| attributes  ## |CSSRule| attributes
237    
238  ## TODO: |css_text|  sub css_text ($;$) {
239      ## TODO: Setter
240    
241      ## NOTE: Sometimes ugly, but this is what Firefox does.
242      my $prefix = ${$_[0]}->{prefix};
243      return '@namespace '.($prefix ne '' ? $prefix.' ' : '').
244          'url('.${$_[0]}->{namespace_uri}.');';
245    } # css_text
246    
247  sub type ($) { Message::DOM::CSSRule::NAMESPACE_RULE }  sub type ($) { Message::DOM::CSSRule::NAMESPACE_RULE }
248    

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24