116 |
package Message::DOM::CSSImportRule; |
package Message::DOM::CSSImportRule; |
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], |
121 |
${$_[3]}->{owner_rule} = $self; |
base_uri => $_[2], ## Ref to base URI |
122 |
Scalar::Util::weaken (${$_[3]}->{owner_rule}); |
media => \$_[3], |
123 |
|
style_sheet => $_[4]}, $_[0]; |
124 |
|
require Message::DOM::MediaList; |
125 |
|
bless $$self->{media}, 'Message::DOM::MediaList'; |
126 |
|
${$_[4]}->{owner_rule} = $self; |
127 |
|
Scalar::Util::weaken (${$_[4]}->{owner_rule}); |
128 |
return $self; |
return $self; |
129 |
} # ____new |
} # ____new |
130 |
|
|
131 |
## |CSSRule| attributes |
## |CSSRule| attributes |
132 |
|
|
133 |
## TODO: |css_text| |
sub css_text ($;$) { |
134 |
|
## TODO: setter |
135 |
|
|
136 |
|
my $self = shift; |
137 |
|
my $r = '@import url(' . $self->href . ')'; |
138 |
|
my $media = ''.$self->media; |
139 |
|
if ($media) { |
140 |
|
$r .= ' ' . $media; |
141 |
|
} |
142 |
|
$r .= ';'; |
143 |
|
return $r; |
144 |
|
} # css_text |
145 |
|
|
146 |
sub type ($) { Message::DOM::CSSRule::IMPORT_RULE } |
sub type ($) { Message::DOM::CSSRule::IMPORT_RULE } |
147 |
|
|
163 |
push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSMediaRule'; |
push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSMediaRule'; |
164 |
|
|
165 |
sub ____new ($$$) { |
sub ____new ($$$) { |
166 |
my $self = bless \{media => $_[1], css_rules => $_[2]}, $_[0]; |
my $self = bless \{media => \$_[1], css_rules => $_[2]}, $_[0]; |
167 |
|
require Message::DOM::MediaList; |
168 |
|
bless $$self->{media}, 'Message::DOM::MediaList'; |
169 |
for (@{$_[2]}) { |
for (@{$_[2]}) { |
170 |
${$_}->{parent_rule} = $self; |
${$_}->{parent_rule} = $self; |
171 |
Scalar::Util::weaken (${$_}->{parent_rule}); |
Scalar::Util::weaken (${$_}->{parent_rule}); |
175 |
|
|
176 |
## |CSSRule| attributes |
## |CSSRule| attributes |
177 |
|
|
178 |
## TODO: |css_text| |
sub css_text ($;$) { |
179 |
|
## TODO: setter |
180 |
|
my $v = '@media ' . $_[0]->media . " {\n"; |
181 |
|
for (@{${$_[0]}->{css_rules}}) { |
182 |
|
$v .= $_->css_text . "\n"; |
183 |
|
## BUG: Browsers do indent. |
184 |
|
} |
185 |
|
$v .= "}"; |
186 |
|
return $v; |
187 |
|
} # css_text |
188 |
|
|
189 |
sub type ($) { Message::DOM::CSSRule::MEDIA_RULE } |
sub type ($) { Message::DOM::CSSRule::MEDIA_RULE } |
190 |
|
|