line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::DOM::Rule::Import; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.16'; |
4
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
1943
|
use warnings; no warnings qw 'utf8 parenthesis'; |
|
8
|
|
|
8
|
|
18
|
|
|
8
|
|
|
|
|
290
|
|
|
8
|
|
|
|
|
43
|
|
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
292
|
|
6
|
8
|
|
|
8
|
|
44
|
use strict; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
182
|
|
7
|
|
|
|
|
|
|
|
8
|
8
|
|
|
8
|
|
785
|
use CSS::DOM; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
206
|
|
9
|
8
|
|
|
8
|
|
41
|
use CSS::DOM::Exception qw/ SYNTAX_ERR /; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
386
|
|
10
|
8
|
|
|
8
|
|
1119
|
use CSS::DOM::Rule; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
628
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = 'CSS::DOM::Rule'; |
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
|
|
749
|
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
|
|
45
|
}; |
|
8
|
|
|
|
|
164
|
|
21
|
8
|
|
|
8
|
|
49
|
{ no strict; delete @{__PACKAGE__.'::'}{_const => keys %{our $_const}} } |
|
8
|
|
|
|
|
28
|
|
|
8
|
|
|
|
|
5754
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# overrides: |
25
|
7
|
|
|
7
|
1
|
33
|
sub type { CSS::DOM::Rule::IMPORT_RULE } |
26
|
|
|
|
|
|
|
sub cssText { |
27
|
22
|
|
|
22
|
1
|
59
|
my $self = shift; |
28
|
22
|
|
|
|
|
31
|
my $old; |
29
|
22
|
100
|
|
|
|
62
|
if(defined wantarray) { |
30
|
3
|
100
|
|
|
|
19
|
$old = "\@import $self->[urlt][1]" . ( |
31
|
|
|
|
|
|
|
$self->[medi] ? ' '.$self->[medi]->mediaText : '' |
32
|
|
|
|
|
|
|
) . ";\n"; |
33
|
|
|
|
|
|
|
} |
34
|
22
|
100
|
|
|
|
60
|
if (@_) { |
35
|
|
|
|
|
|
|
@$self[hrfe,medi,shet,urlt] = |
36
|
20
|
|
|
|
|
29
|
@{$self->_parse(shift)}[hrfe,medi,shet,urlt]; |
|
20
|
|
|
|
|
72
|
|
37
|
|
|
|
|
|
|
#use DDS; Dump $self; |
38
|
|
|
|
|
|
|
} |
39
|
21
|
|
|
|
|
92
|
$old; |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# CSSImportRule interface: |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub href { |
46
|
34
|
|
|
34
|
1
|
74
|
my $self =shift; |
47
|
34
|
|
66
|
|
|
116
|
$self->[hrfe] ||= do { |
48
|
34
|
|
|
|
|
154
|
require CSS'DOM'Parser; |
49
|
34
|
100
|
|
|
|
96
|
if($self->[urlt][00] eq 'u') { |
50
|
|
|
|
|
|
|
# ~~~ I probably ought to put things like this in a |
51
|
|
|
|
|
|
|
# Parser::token_val function. |
52
|
12
|
|
|
|
|
26
|
my $url = $self->[urlt][1]; |
53
|
12
|
|
|
|
|
49
|
$url =~ s/^url\([ \t\r\n\f]*//; |
54
|
12
|
|
|
|
|
61
|
$url =~ s/[ \t\r\n\f]*\)\z//; |
55
|
12
|
100
|
|
|
|
54
|
$url =~ s/^['"]// and chop $url; |
56
|
12
|
|
|
|
|
38
|
CSS'DOM'Parser'unescape($url); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
22
|
|
|
|
|
103
|
CSS'DOM'Parser'unescape( |
60
|
|
|
|
|
|
|
substr $$self[urlt][1], 1, -1 |
61
|
|
|
|
|
|
|
) |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
sub _set_url_token { |
66
|
43
|
|
|
43
|
|
101
|
for(shift) { |
67
|
43
|
|
|
|
|
75
|
delete $_->[hrfe]; |
68
|
43
|
|
|
|
|
190
|
$_->[urlt] = \@_; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub media { |
73
|
12
|
50
|
66
|
12
|
1
|
7008
|
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
|
53
|
my $self = shift; |
86
|
13
|
100
|
|
|
|
45
|
unless( defined($self->[shet])) { |
87
|
11
|
|
|
|
|
49
|
my $fetcher = $self->parentStyleSheet->url_fetcher; |
88
|
|
|
|
|
|
|
# ~~~ What do we do about the charset? |
89
|
11
|
|
|
|
|
21
|
my($css,@args); |
90
|
11
|
100
|
|
|
|
43
|
($css,@args) = $fetcher->($self->href) if defined $fetcher; |
91
|
11
|
100
|
|
|
|
80
|
defined $css or $self->[shet]=0, return; |
92
|
9
|
|
|
|
|
39
|
require CSS::DOM::Parser; |
93
|
9
|
|
50
|
|
|
18
|
for(($self->[shet] = |
|
|
|
50
|
|
|
|
|
94
|
|
|
|
|
|
|
eval{CSS::DOM::Parser::parse($css,@args)}||0) |
95
|
|
|
|
|
|
|
|| return){ |
96
|
9
|
|
|
|
|
39
|
$_->_set_ownerRule($self); |
97
|
9
|
50
|
|
|
|
98
|
if(my$parent=$self->parentStyleSheet){ |
98
|
9
|
|
|
|
|
37
|
$_->_set_parentStyleSheet($parent); |
99
|
9
|
|
|
|
|
29
|
$_->url_fetcher($parent->url_fetcher); |
100
|
|
|
|
|
|
|
} |
101
|
9
|
|
|
|
|
50
|
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.16 |
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. It inherits |
134
|
|
|
|
|
|
|
from |
135
|
|
|
|
|
|
|
L 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 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 is not provided or if it returns |
157
|
|
|
|
|
|
|
undef). |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=back |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 SEE ALSO |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L |