line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::DOM::Rule::Import; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.17'; |
4
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
1629
|
use warnings; no warnings qw 'utf8 parenthesis'; |
|
8
|
|
|
8
|
|
12
|
|
|
8
|
|
|
|
|
225
|
|
|
8
|
|
|
|
|
30
|
|
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
203
|
|
6
|
8
|
|
|
8
|
|
31
|
use strict; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
120
|
|
7
|
|
|
|
|
|
|
|
8
|
8
|
|
|
8
|
|
424
|
use CSS::DOM; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
149
|
|
9
|
8
|
|
|
8
|
|
31
|
use CSS::DOM::Exception qw/ SYNTAX_ERR /; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
270
|
|
10
|
8
|
|
|
8
|
|
780
|
use CSS::DOM::Rule; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
457
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = 'CSS::DOM::Rule'; |
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
|
|
524
|
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
|
|
41
|
}; |
|
8
|
|
|
|
|
101
|
|
21
|
8
|
|
|
8
|
|
39
|
{ no strict; delete @{__PACKAGE__.'::'}{_const => keys %{our $_const}} } |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
4264
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# overrides: |
25
|
7
|
|
|
7
|
1
|
25
|
sub type { CSS::DOM::Rule::IMPORT_RULE } |
26
|
|
|
|
|
|
|
sub cssText { |
27
|
22
|
|
|
22
|
1
|
42
|
my $self = shift; |
28
|
22
|
|
|
|
|
23
|
my $old; |
29
|
22
|
100
|
|
|
|
41
|
if(defined wantarray) { |
30
|
3
|
100
|
|
|
|
12
|
$old = "\@import $self->[urlt][1]" . ( |
31
|
|
|
|
|
|
|
$self->[medi] ? ' '.$self->[medi]->mediaText : '' |
32
|
|
|
|
|
|
|
) . ";\n"; |
33
|
|
|
|
|
|
|
} |
34
|
22
|
100
|
|
|
|
40
|
if (@_) { |
35
|
|
|
|
|
|
|
@$self[hrfe,medi,shet,urlt] = |
36
|
20
|
|
|
|
|
23
|
@{$self->_parse(shift)}[hrfe,medi,shet,urlt]; |
|
20
|
|
|
|
|
44
|
|
37
|
|
|
|
|
|
|
#use DDS; Dump $self; |
38
|
|
|
|
|
|
|
} |
39
|
21
|
|
|
|
|
55
|
$old; |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# CSSImportRule interface: |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub href { |
46
|
34
|
|
|
34
|
1
|
84
|
my $self =shift; |
47
|
34
|
|
66
|
|
|
80
|
$self->[hrfe] ||= do { |
48
|
34
|
|
|
|
|
111
|
require CSS'DOM'Parser; |
49
|
34
|
100
|
|
|
|
94
|
if($self->[urlt][00] eq 'u') { |
50
|
|
|
|
|
|
|
# ~~~ I probably ought to put things like this in a |
51
|
|
|
|
|
|
|
# Parser::token_val function. |
52
|
12
|
|
|
|
|
16
|
my $url = $self->[urlt][1]; |
53
|
12
|
|
|
|
|
44
|
$url =~ s/^url\([ \t\r\n\f]*//; |
54
|
12
|
|
|
|
|
51
|
$url =~ s/[ \t\r\n\f]*\)\z//; |
55
|
12
|
100
|
|
|
|
38
|
$url =~ s/^['"]// and chop $url; |
56
|
12
|
|
|
|
|
25
|
CSS'DOM'Parser'unescape($url); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
22
|
|
|
|
|
56
|
CSS'DOM'Parser'unescape( |
60
|
|
|
|
|
|
|
substr $$self[urlt][1], 1, -1 |
61
|
|
|
|
|
|
|
) |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
sub _set_url_token { |
66
|
43
|
|
|
43
|
|
76
|
for(shift) { |
67
|
43
|
|
|
|
|
60
|
delete $_->[hrfe]; |
68
|
43
|
|
|
|
|
117
|
$_->[urlt] = \@_; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub media { |
73
|
12
|
50
|
66
|
12
|
1
|
969
|
wantarray ? @{$_[0]->[medi]||return} : |
|
1
|
100
|
|
|
|
7
|
|
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
|
26
|
my $self = shift; |
86
|
13
|
100
|
|
|
|
28
|
unless( defined($self->[shet])) { |
87
|
11
|
|
|
|
|
29
|
my $fetcher = $self->parentStyleSheet->url_fetcher; |
88
|
|
|
|
|
|
|
# ~~~ What do we do about the charset? |
89
|
11
|
|
|
|
|
14
|
my($css,@args); |
90
|
11
|
100
|
|
|
|
27
|
($css,@args) = $fetcher->($self->href) if defined $fetcher; |
91
|
11
|
100
|
|
|
|
56
|
defined $css or $self->[shet]=0, return; |
92
|
9
|
|
|
|
|
25
|
require CSS::DOM::Parser; |
93
|
9
|
|
50
|
|
|
15
|
for(($self->[shet] = |
|
|
|
50
|
|
|
|
|
94
|
|
|
|
|
|
|
eval{CSS::DOM::Parser::parse($css,@args)}||0) |
95
|
|
|
|
|
|
|
|| return){ |
96
|
9
|
|
|
|
|
28
|
$_->_set_ownerRule($self); |
97
|
9
|
50
|
|
|
|
31
|
if(my$parent=$self->parentStyleSheet){ |
98
|
9
|
|
|
|
|
43
|
$_->_set_parentStyleSheet($parent); |
99
|
9
|
|
|
|
|
19
|
$_->url_fetcher($parent->url_fetcher); |
100
|
|
|
|
|
|
|
} |
101
|
9
|
|
|
|
|
29
|
return $_; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
2
|
|
66
|
|
|
10
|
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.17 |
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 |