line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
################################################################################################### |
2
|
|
|
|
|
|
|
# Copyright 2013/2014 by Marcel Greter |
3
|
|
|
|
|
|
|
# This file is part of OCBNET-CSS3 (GPL3) |
4
|
|
|
|
|
|
|
#################################################################################################### |
5
|
|
|
|
|
|
|
package OCBNET::CSS3::Property::Background; |
6
|
|
|
|
|
|
|
#################################################################################################### |
7
|
|
|
|
|
|
|
our $VERSION = '0.2.5'; |
8
|
|
|
|
|
|
|
#################################################################################################### |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
4645
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
11
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#################################################################################################### |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use OCBNET::CSS3::Regex::Colors; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
103
|
|
16
|
1
|
|
|
1
|
|
638
|
use OCBNET::CSS3::Regex::Background; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
184
|
|
17
|
1
|
|
|
1
|
|
6
|
use OCBNET::CSS3::Regex::Numbers qw($re_length); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
468
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#################################################################################################### |
20
|
|
|
|
|
|
|
# register longhand properties for backgrounds |
21
|
|
|
|
|
|
|
#################################################################################################### |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
OCBNET::CSS3::Styles::register('background-color', $re_color, 'transparent', 1); |
24
|
|
|
|
|
|
|
OCBNET::CSS3::Styles::register('background-image', $re_bg_image, 'none', 1); |
25
|
|
|
|
|
|
|
OCBNET::CSS3::Styles::register('background-repeat', $re_bg_repeat, 'repeat', 1); |
26
|
|
|
|
|
|
|
OCBNET::CSS3::Styles::register('background-size-x', $re_length, undef, 1); |
27
|
|
|
|
|
|
|
OCBNET::CSS3::Styles::register('background-size-y', $re_length, undef, 1); |
28
|
|
|
|
|
|
|
OCBNET::CSS3::Styles::register('background-position-y', $re_bg_position_y, 'top', 1); |
29
|
|
|
|
|
|
|
OCBNET::CSS3::Styles::register('background-position-x', $re_bg_position_x, 'left', 1); |
30
|
|
|
|
|
|
|
OCBNET::CSS3::Styles::register('background-attachment', $re_bg_attachment, 'scroll', 1); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#################################################################################################### |
33
|
|
|
|
|
|
|
# register shorthand property for background-size |
34
|
|
|
|
|
|
|
#################################################################################################### |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
OCBNET::CSS3::Styles::register('background-size', |
37
|
|
|
|
|
|
|
{ |
38
|
|
|
|
|
|
|
'ordered' => [ |
39
|
|
|
|
|
|
|
# always needed |
40
|
|
|
|
|
|
|
[ 'background-size-x' ], |
41
|
|
|
|
|
|
|
# additional optional values |
42
|
|
|
|
|
|
|
# may evaluate to other value |
43
|
|
|
|
|
|
|
[ 'background-size-y', 'background-size-x' ] |
44
|
|
|
|
|
|
|
], |
45
|
|
|
|
|
|
|
}, undef, 1); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#################################################################################################### |
48
|
|
|
|
|
|
|
# register shorthand property for background-position |
49
|
|
|
|
|
|
|
#################################################################################################### |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
OCBNET::CSS3::Styles::register('background-position', |
52
|
|
|
|
|
|
|
{ |
53
|
|
|
|
|
|
|
'prefix' => [ |
54
|
|
|
|
|
|
|
'background-position-x', |
55
|
|
|
|
|
|
|
'background-position-y' |
56
|
|
|
|
|
|
|
], |
57
|
|
|
|
|
|
|
'matcher' => $re_bg_positions |
58
|
|
|
|
|
|
|
}, 'top left', 1); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#################################################################################################### |
61
|
|
|
|
|
|
|
# register shorthand property for background |
62
|
|
|
|
|
|
|
#################################################################################################### |
63
|
|
|
|
|
|
|
OCBNET::CSS3::Styles::register('background', |
64
|
|
|
|
|
|
|
{ |
65
|
|
|
|
|
|
|
'prefix' => [ |
66
|
|
|
|
|
|
|
'background-color', |
67
|
|
|
|
|
|
|
'background-image', |
68
|
|
|
|
|
|
|
'background-repeat', |
69
|
|
|
|
|
|
|
'background-attachment', |
70
|
|
|
|
|
|
|
'background-position' |
71
|
|
|
|
|
|
|
] |
72
|
|
|
|
|
|
|
}, 'none', 1); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#################################################################################################### |
75
|
|
|
|
|
|
|
# register getters for virtual longhand properties |
76
|
|
|
|
|
|
|
#################################################################################################### |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
OCBNET::CSS3::Styles::getter('background-repeat-x', sub |
79
|
|
|
|
|
|
|
{ |
80
|
|
|
|
|
|
|
my ($self, $type, $name, $idx) = @_; |
81
|
|
|
|
|
|
|
my $repeat = $self->get($type, 'background-repeat', $idx) || return 1; |
82
|
|
|
|
|
|
|
return $repeat eq "repeat-x" || $repeat eq "repeat" ? 'repeat' : 0; |
83
|
|
|
|
|
|
|
}); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
OCBNET::CSS3::Styles::getter('background-repeat-y', sub |
86
|
|
|
|
|
|
|
{ |
87
|
|
|
|
|
|
|
my ($self, $type, $name, $idx) = @_; |
88
|
|
|
|
|
|
|
my $repeat = $self->get($type, 'background-repeat', $idx) || return 1; |
89
|
|
|
|
|
|
|
return $repeat eq "repeat-y" || $repeat eq "repeat" ? 'repeat' : 0; |
90
|
|
|
|
|
|
|
}); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
#################################################################################################### |
93
|
|
|
|
|
|
|
#################################################################################################### |
94
|
|
|
|
|
|
|
1; |