line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::DOM::Rule::Page; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.15'; |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
1016
|
use warnings; no warnings qw 'utf8 parenthesis'; |
|
3
|
|
|
3
|
|
7
|
|
|
3
|
|
|
|
|
139
|
|
|
3
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
135
|
|
6
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
113
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
522
|
use CSS::DOM::Exception qw/ SYNTAX_ERR /; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
181
|
|
9
|
3
|
|
|
3
|
|
583
|
use CSS::DOM::Rule; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
208
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = 'CSS::DOM::Rule'; |
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
|
|
174
|
use constant 1.03 our $_const = { |
14
|
|
|
|
|
|
|
# Don't let this conflict with the superclass. |
15
|
|
|
|
|
|
|
styl => 2, |
16
|
|
|
|
|
|
|
selc => 3, |
17
|
3
|
|
|
3
|
|
18
|
}; |
|
3
|
|
|
|
|
78
|
|
18
|
3
|
|
|
3
|
|
15
|
{ no strict; delete @{__PACKAGE__.'::'}{_const => keys %{our $_const}} } |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1365
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# overrides: |
21
|
|
|
|
|
|
|
|
22
|
8
|
|
|
8
|
1
|
47
|
sub type { CSS::DOM::Rule::PAGE_RULE } |
23
|
|
|
|
|
|
|
sub cssText { |
24
|
11
|
|
|
11
|
1
|
33
|
my $self = shift; |
25
|
11
|
|
|
|
|
15
|
my $old; |
26
|
11
|
100
|
|
|
|
41
|
if(defined wantarray) { |
27
|
10
|
|
|
|
|
107
|
$old = "$self->[selc] { " |
28
|
|
|
|
|
|
|
. $self->[styl]->cssText ." }\n"; |
29
|
|
|
|
|
|
|
} |
30
|
11
|
100
|
|
|
|
34
|
if (@_) { |
31
|
2
|
|
|
|
|
11
|
require CSS::DOM::Parser; |
32
|
2
|
|
|
|
|
12
|
my $new_rule = $self->_parse(shift); |
33
|
1
|
|
|
|
|
14
|
@$self[styl,selc] = @$new_rule[styl,selc]; |
34
|
|
|
|
|
|
|
} |
35
|
10
|
|
|
|
|
504
|
$old; |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# CSSPageRule interface: |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub selectorText { |
42
|
16
|
|
|
16
|
1
|
38
|
my $old = (my $self = shift)->[selc]; |
43
|
16
|
100
|
|
|
|
55
|
if(@_){ |
44
|
|
|
|
|
|
|
# ~~~ I need to make this use the parserâs tokenise func. |
45
|
|
|
|
|
|
|
# need tests as well; this shouldnât accept anything |
46
|
|
|
|
|
|
|
# that would make it technically an unknown rule. |
47
|
14
|
100
|
|
|
|
93
|
(my $sel = shift) =~ |
48
|
|
|
|
|
|
|
/^[ \t\r\n\f]*\@page(?![_a-z\200-\377]|\\[^\r\n\f])/ |
49
|
|
|
|
|
|
|
or die CSS::DOM::Exception->new(SYNTAX_ERR, |
50
|
|
|
|
|
|
|
'@page selectors must begin with "@page"'); |
51
|
13
|
|
|
|
|
33
|
$self->[selc] = $sel ; |
52
|
|
|
|
|
|
|
} |
53
|
15
|
|
|
|
|
43
|
$old; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# ~~~ Do we need this? |
57
|
|
|
|
|
|
|
#sub _set_selector_tokens { |
58
|
|
|
|
|
|
|
# |
59
|
|
|
|
|
|
|
#} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub style { |
62
|
16
|
|
66
|
16
|
1
|
700
|
$_[0]->[styl] ||= do { |
63
|
14
|
|
|
|
|
73
|
require CSS::DOM::Style; |
64
|
14
|
|
|
|
|
132
|
new CSS::DOM::Style shift |
65
|
|
|
|
|
|
|
}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
!()__END__()! |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
CSS::DOM::Rule::Page - CSS @page rule class for CSS::DOM |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 VERSION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Version 0.15 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SYNOPSIS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
use CSS::DOM; |
81
|
|
|
|
|
|
|
my $page_rule = CSS::DOM->parse( |
82
|
|
|
|
|
|
|
'@page :first { stuff: other stuff }' |
83
|
|
|
|
|
|
|
)->cssRules->[0]; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$page_rule->selectorText; # '@page :first' |
86
|
|
|
|
|
|
|
$page_rule->style; # a CSS::DOM::Style object |
87
|
|
|
|
|
|
|
$page_rule->style->stuff; # 'other stuff' |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 DESCRIPTION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This module implements CSS @page rules for L<CSS::DOM>. It inherits |
92
|
|
|
|
|
|
|
from |
93
|
|
|
|
|
|
|
L<CSS::DOM::Rule> and implements |
94
|
|
|
|
|
|
|
the CSSPageRule DOM interface. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 METHODS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over 4 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item selectorText |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns a string representing the selector(s). Pass an argument to set it. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item style |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns the CSS::DOM::Style object representing the declaration block |
107
|
|
|
|
|
|
|
of this rule. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=back |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 SEE ALSO |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L<CSS::DOM> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L<CSS::DOM::Style> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L<CSS::DOM::Rule> |