| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CSS::DOM::Rule::Import; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.15'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
1718
|
use warnings; no warnings qw 'utf8 parenthesis'; |
|
|
8
|
|
|
8
|
|
17
|
|
|
|
8
|
|
|
|
|
401
|
|
|
|
8
|
|
|
|
|
44
|
|
|
|
8
|
|
|
|
|
14
|
|
|
|
8
|
|
|
|
|
315
|
|
|
6
|
8
|
|
|
8
|
|
44
|
use strict; |
|
|
8
|
|
|
|
|
17
|
|
|
|
8
|
|
|
|
|
274
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
8
|
|
|
8
|
|
704
|
use CSS::DOM; |
|
|
8
|
|
|
|
|
20
|
|
|
|
8
|
|
|
|
|
262
|
|
|
9
|
8
|
|
|
8
|
|
45
|
use CSS::DOM::Exception qw/ SYNTAX_ERR /; |
|
|
8
|
|
|
|
|
15
|
|
|
|
8
|
|
|
|
|
490
|
|
|
10
|
8
|
|
|
8
|
|
1174
|
use CSS::DOM::Rule; |
|
|
8
|
|
|
|
|
19
|
|
|
|
8
|
|
|
|
|
733
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = 'CSS::DOM::Rule'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
8
|
|
|
|
|
715
|
use constant 1.03 our $_const = { |
|
15
|
|
|
|
|
|
|
# Don't let this conflict with the superclass. |
|
16
|
|
|
|
|
|
|
hrfe => 2, |
|
17
|
|
|
|
|
|
|
medi => 3, |
|
18
|
|
|
|
|
|
|
shet => 4, |
|
19
|
|
|
|
|
|
|
urlt => 5, # url token |
|
20
|
8
|
|
|
8
|
|
48
|
}; |
|
|
8
|
|
|
|
|
252
|
|
|
21
|
8
|
|
|
8
|
|
56
|
{ no strict; delete @{__PACKAGE__.'::'}{_const => keys %{our $_const}} } |
|
|
8
|
|
|
|
|
17
|
|
|
|
8
|
|
|
|
|
7058
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# overrides: |
|
25
|
7
|
|
|
7
|
1
|
40
|
sub type { CSS::DOM::Rule::IMPORT_RULE } |
|
26
|
|
|
|
|
|
|
sub cssText { |
|
27
|
22
|
|
|
22
|
1
|
54
|
my $self = shift; |
|
28
|
22
|
|
|
|
|
32
|
my $old; |
|
29
|
22
|
100
|
|
|
|
63
|
if(defined wantarray) { |
|
30
|
3
|
100
|
|
|
|
18
|
$old = "\@import $self->[urlt][1]" . ( |
|
31
|
|
|
|
|
|
|
$self->[medi] ? ' '.$self->[medi]->mediaText : '' |
|
32
|
|
|
|
|
|
|
) . ";\n"; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
22
|
100
|
|
|
|
53
|
if (@_) { |
|
35
|
20
|
|
|
|
|
73
|
@$self[hrfe,medi,shet,urlt] = |
|
36
|
20
|
|
|
|
|
26
|
@{$self->_parse(shift)}[hrfe,medi,shet,urlt]; |
|
37
|
|
|
|
|
|
|
#use DDS; Dump $self; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
21
|
|
|
|
|
98
|
$old; |
|
40
|
|
|
|
|
|
|
}; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# CSSImportRule interface: |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub href { |
|
46
|
34
|
|
|
34
|
1
|
74
|
my $self =shift; |
|
47
|
34
|
|
66
|
|
|
165
|
$self->[hrfe] ||= do { |
|
48
|
34
|
|
|
|
|
179
|
require CSS'DOM'Parser; |
|
49
|
34
|
100
|
|
|
|
109
|
if($self->[urlt][00] eq 'u') { |
|
50
|
|
|
|
|
|
|
# ~~~ I probably ought to put things like this in a |
|
51
|
|
|
|
|
|
|
# Parser::token_val function. |
|
52
|
12
|
|
|
|
|
25
|
my $url = $self->[urlt][1]; |
|
53
|
12
|
|
|
|
|
61
|
$url =~ s/^url\([ \t\r\n\f]*//; |
|
54
|
12
|
|
|
|
|
68
|
$url =~ s/[ \t\r\n\f]*\)\z//; |
|
55
|
12
|
100
|
|
|
|
60
|
$url =~ s/^['"]// and chop $url; |
|
56
|
12
|
|
|
|
|
43
|
CSS'DOM'Parser'unescape($url); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
else { |
|
59
|
22
|
|
|
|
|
111
|
CSS'DOM'Parser'unescape( |
|
60
|
|
|
|
|
|
|
substr $$self[urlt][1], 1, -1 |
|
61
|
|
|
|
|
|
|
) |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
sub _set_url_token { |
|
66
|
43
|
|
|
43
|
|
98
|
for(shift) { |
|
67
|
43
|
|
|
|
|
86
|
delete $_->[hrfe]; |
|
68
|
43
|
|
|
|
|
233
|
$_->[urlt] = \@_; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub media { |
|
73
|
12
|
50
|
66
|
12
|
1
|
1385
|
wantarray ? @{$_[0]->[medi]||return} : |
|
|
1
|
100
|
|
|
|
11
|
|
|
74
|
|
|
|
|
|
|
($_[0]->[medi] ||= ( |
|
75
|
|
|
|
|
|
|
require CSS::DOM::MediaList, |
|
76
|
|
|
|
|
|
|
CSS::DOM::MediaList->new |
|
77
|
|
|
|
|
|
|
)) |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub styleSheet{ |
|
81
|
|
|
|
|
|
|
# I use 0 instead of undef for a non-existent style sheet. undef is |
|
82
|
|
|
|
|
|
|
# used to mean that we havenât even considered loading it yet. |
|
83
|
|
|
|
|
|
|
# Using existence of the element as the criterion makes the code |
|
84
|
|
|
|
|
|
|
# too unmaintainable. |
|
85
|
13
|
|
|
13
|
1
|
61
|
my $self = shift; |
|
86
|
13
|
100
|
|
|
|
46
|
unless( defined($self->[shet])) { |
|
87
|
11
|
|
|
|
|
66
|
my $fetcher = $self->parentStyleSheet->url_fetcher; |
|
88
|
|
|
|
|
|
|
# ~~~ What do we do about the charset? |
|
89
|
11
|
|
|
|
|
17
|
my($css,@args); |
|
90
|
11
|
100
|
|
|
|
48
|
($css,@args) = $fetcher->($self->href) if defined $fetcher; |
|
91
|
11
|
100
|
|
|
|
82
|
defined $css or $self->[shet]=0, return; |
|
92
|
9
|
|
|
|
|
41
|
require CSS::DOM::Parser; |
|
93
|
9
|
|
50
|
|
|
19
|
for(($self->[shet] = |
|
|
|
|
50
|
|
|
|
|
|
94
|
|
|
|
|
|
|
eval{CSS::DOM::Parser::parse($css,@args)}||0) |
|
95
|
|
|
|
|
|
|
|| return){ |
|
96
|
9
|
|
|
|
|
38
|
$_->_set_ownerRule($self); |
|
97
|
9
|
50
|
|
|
|
112
|
if(my$parent=$self->parentStyleSheet){ |
|
98
|
9
|
|
|
|
|
36
|
$_->_set_parentStyleSheet($parent); |
|
99
|
9
|
|
|
|
|
34
|
$_->url_fetcher($parent->url_fetcher); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
9
|
|
|
|
|
51
|
return $_; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
} |
|
104
|
2
|
|
66
|
|
|
16
|
return $self->[shet]||(); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
!()__END__()! |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 NAME |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
CSS::DOM::Rule::Import - CSS @import rule class for CSS::DOM |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 VERSION |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Version 0.15 |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
use CSS::DOM; |
|
120
|
|
|
|
|
|
|
my $import_rule = CSS::DOM->parse( |
|
121
|
|
|
|
|
|
|
'@import "print.css" print;', |
|
122
|
|
|
|
|
|
|
url_fetcher => sub { |
|
123
|
|
|
|
|
|
|
# ... code to get the url in $_[0] ... |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
)->cssRules->[0]; |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
$import_rule->href; # 'print.css' |
|
128
|
|
|
|
|
|
|
$import_rule->media; # a CSS::DOM::MediaList (array ref) |
|
129
|
|
|
|
|
|
|
$import_rule->styleSheet; # a CSS::DOM object |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This module implements CSS C<@import> rules for L<CSS::DOM>. It inherits |
|
134
|
|
|
|
|
|
|
from |
|
135
|
|
|
|
|
|
|
L<CSS::DOM::Rule> and implements |
|
136
|
|
|
|
|
|
|
the CSSImportRule DOM interface. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 METHODS |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=over 4 |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item href |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Returns the @import rule's URL. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item media |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Returns the MediaList associated with the @import rule (or a plain list in |
|
149
|
|
|
|
|
|
|
list context). This defaults to an |
|
150
|
|
|
|
|
|
|
empty list. You can pass a comma-delimited string to the MediaList's |
|
151
|
|
|
|
|
|
|
C<mediaText> method to set it. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item styleSheet |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This returns the style sheet object, if available. Otherwise it returns an |
|
156
|
|
|
|
|
|
|
empty list (this occurs if C<url_fetcher> is not provided or if it returns |
|
157
|
|
|
|
|
|
|
undef). |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=back |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L<CSS::DOM> |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L<CSS::DOM::Rule> |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L<CSS::DOM::MediaList> |