60 |
sub css_text ($;$) { |
sub css_text ($;$) { |
61 |
## TODO: setter |
## TODO: setter |
62 |
|
|
63 |
## TODO: Browser compatibility |
## NOTE: Where and how white space characters are inserted are |
64 |
|
## intentionally changed from those in browsers so that properties are |
65 |
|
## more prettily printed. |
66 |
|
## See <http://suika.fam.cx/gate/2005/sw/cssText> for what browsers do. |
67 |
local $Error::Depth = $Error::Depth + 1; |
local $Error::Depth = $Error::Depth + 1; |
68 |
return $_[0]->selector_text . " {\n" . $_[0]->style->css_text . "}\n"; |
return $_[0]->selector_text . " {\n" . $_[0]->style->css_text . '}'; |
69 |
} # css_text |
} # css_text |
70 |
|
|
71 |
sub type ($) { Message::DOM::CSSRule::STYLE_RULE } |
sub type ($) { Message::DOM::CSSRule::STYLE_RULE } |
76 |
## TODO: setter |
## TODO: setter |
77 |
|
|
78 |
## TODO: Browser-compatible serializer |
## TODO: Browser-compatible serializer |
79 |
|
## TODO: This code does not work for cases where default namespace |
80 |
|
## has no namespace prefix declared. |
81 |
|
my $self = $_[0]; |
82 |
require Whatpm::CSS::SelectorsSerializer; |
require Whatpm::CSS::SelectorsSerializer; |
83 |
return Whatpm::CSS::SelectorsSerializer->serialize_test |
return Whatpm::CSS::SelectorsSerializer->serialize_selector_text |
84 |
(${$_[0]}->{_selectors}); |
($$self->{_selectors}, ${$self->parent_style_sheet}->{_nsmap}); |
85 |
} # selector_text |
} # selector_text |
86 |
|
|
87 |
sub style ($) { |
sub style ($) { |
97 |
|
|
98 |
## |CSSRule| attributes |
## |CSSRule| attributes |
99 |
|
|
100 |
## TODO: |css_text| |
sub css_text ($;$) { |
101 |
|
## TODO: setter |
102 |
|
|
103 |
|
## NOTE: It will be broken if |encoding| contains |"| or |\|, but this |
104 |
|
## is what browsers do. |
105 |
|
return '@charset "'.${$_[0]}->{encoding}.'";'; |
106 |
|
} # css_text |
107 |
|
|
108 |
sub type ($) { Message::DOM::CSSRule::CHARSET_RULE } |
sub type ($) { Message::DOM::CSSRule::CHARSET_RULE } |
109 |
|
|
117 |
push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSImportRule'; |
push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSImportRule'; |
118 |
|
|
119 |
sub ____new ($$$$) { |
sub ____new ($$$$) { |
120 |
my $self = bless \{href => $_[1], media => $_[2], style_sheet => $_[3]}, $_[0]; |
my $self = bless \{href => $_[1], media => \$_[2], |
121 |
|
style_sheet => $_[3]}, $_[0]; |
122 |
|
require Message::DOM::MediaList; |
123 |
|
bless $$self->{media}, 'Message::DOM::MediaList'; |
124 |
${$_[3]}->{owner_rule} = $self; |
${$_[3]}->{owner_rule} = $self; |
125 |
Scalar::Util::weaken (${$_[3]}->{owner_rule}); |
Scalar::Util::weaken (${$_[3]}->{owner_rule}); |
126 |
return $self; |
return $self; |
150 |
push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSMediaRule'; |
push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSMediaRule'; |
151 |
|
|
152 |
sub ____new ($$$) { |
sub ____new ($$$) { |
153 |
my $self = bless \{media => $_[1], css_rules => $_[2]}, $_[0]; |
my $self = bless \{media => \$_[1], css_rules => $_[2]}, $_[0]; |
154 |
|
require Message::DOM::MediaList; |
155 |
|
bless $$self->{media}, 'Message::DOM::MediaList'; |
156 |
for (@{$_[2]}) { |
for (@{$_[2]}) { |
157 |
${$_}->{parent_rule} = $self; |
${$_}->{parent_rule} = $self; |
158 |
Scalar::Util::weaken (${$_}->{parent_rule}); |
Scalar::Util::weaken (${$_}->{parent_rule}); |
162 |
|
|
163 |
## |CSSRule| attributes |
## |CSSRule| attributes |
164 |
|
|
165 |
## TODO: |css_text| |
sub css_text ($;$) { |
166 |
|
## TODO: setter |
167 |
|
my $v = '@media ' . $_[0]->media . " {\n"; |
168 |
|
for (@{${$_[0]}->{css_rules}}) { |
169 |
|
$v .= $_->css_text . "\n"; |
170 |
|
## BUG: Browsers do indent. |
171 |
|
} |
172 |
|
$v .= "}"; |
173 |
|
return $v; |
174 |
|
} # css_text |
175 |
|
|
176 |
sub type ($) { Message::DOM::CSSRule::MEDIA_RULE } |
sub type ($) { Message::DOM::CSSRule::MEDIA_RULE } |
177 |
|
|
247 |
|
|
248 |
## |CSSRule| attributes |
## |CSSRule| attributes |
249 |
|
|
250 |
## TODO: |css_text| |
sub css_text ($;$) { |
251 |
|
## TODO: Setter |
252 |
|
|
253 |
|
## NOTE: Sometimes ugly, but this is what Firefox does. |
254 |
|
my $prefix = ${$_[0]}->{prefix}; |
255 |
|
return '@namespace '.($prefix ne '' ? $prefix.' ' : ''). |
256 |
|
'url('.${$_[0]}->{namespace_uri}.');'; |
257 |
|
} # css_text |
258 |
|
|
259 |
sub type ($) { Message::DOM::CSSRule::NAMESPACE_RULE } |
sub type ($) { Message::DOM::CSSRule::NAMESPACE_RULE } |
260 |
|
|