| 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::Regex::Background; |
|
6
|
|
|
|
|
|
|
#################################################################################################### |
|
7
|
|
|
|
|
|
|
our $VERSION = '0.2.5'; |
|
8
|
|
|
|
|
|
|
#################################################################################################### |
|
9
|
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
1747
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
77
|
|
|
11
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
323
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT; |
|
13
|
|
|
|
|
|
|
our @EXPORT_OK; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#################################################################################################### |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# load exporter and inherit from it |
|
18
|
2
|
|
|
2
|
|
12
|
use Exporter qw(); our @ISA = qw(Exporter); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
166
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# define our functions that will be exported |
|
21
|
|
|
|
|
|
|
push @EXPORT, qw($re_bg_position fromPosition); |
|
22
|
|
|
|
|
|
|
push @EXPORT, qw($re_bg_image $re_bg_attachment $re_bg_repeat); |
|
23
|
|
|
|
|
|
|
push @EXPORT, qw($re_bg_positions $re_bg_position_y $re_bg_position_x); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#################################################################################################### |
|
26
|
|
|
|
|
|
|
|
|
27
|
2
|
|
|
2
|
|
13
|
use OCBNET::CSS3::Regex::Base; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
295
|
|
|
28
|
2
|
|
|
2
|
|
14
|
use OCBNET::CSS3::Regex::Numbers; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
525
|
|
|
29
|
2
|
|
|
2
|
|
936
|
use OCBNET::CSS3::Regex::Comments; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
215
|
|
|
30
|
2
|
|
|
2
|
|
11
|
use OCBNET::CSS3::Regex::Base qw($re_url); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1488
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#################################################################################################### |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# regular expression for background options |
|
35
|
|
|
|
|
|
|
#************************************************************************************************** |
|
36
|
|
|
|
|
|
|
our $re_bg_image = qr/(?:none|$re_url|inherit)/i; |
|
37
|
|
|
|
|
|
|
our $re_bg_attachment = qr/(?:scroll|fixed|inherit)/i; |
|
38
|
|
|
|
|
|
|
our $re_bg_repeat = qr/(?:no-repeat|repeat(?:\-[xy])?)/i; |
|
39
|
|
|
|
|
|
|
our $re_bg_position_y = qr/(?:top|bottom|center|$re_length)/i; |
|
40
|
|
|
|
|
|
|
our $re_bg_position_x = qr/(?:left|right|center|$re_length)/i; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# regular expression for background position matching |
|
43
|
|
|
|
|
|
|
#************************************************************************************************** |
|
44
|
|
|
|
|
|
|
our $re_bg_position = qr/(?:left|right|top|bottom|center|$re_length)/i; |
|
45
|
|
|
|
|
|
|
our $re_bg_positions = qr/$re_bg_position(?:\s+$re_bg_position)?/i; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#################################################################################################### |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# parse background position |
|
50
|
|
|
|
|
|
|
#************************************************************************************************** |
|
51
|
|
|
|
|
|
|
sub fromPosition |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# get position string |
|
55
|
14
|
|
|
14
|
0
|
5550
|
my ($position) = @_; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# default to left/top position |
|
58
|
14
|
100
|
|
|
|
64
|
return 0 unless (defined $position); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# allow keywords for left and top position |
|
61
|
13
|
100
|
|
|
|
65
|
return 0 if ($position =~ m/^(?:top|left)$/i); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# return the parsed pixel number if matched |
|
64
|
11
|
100
|
|
|
|
1227
|
return $1 if ($position =~ m/^($re_number)(?:px)?$/i); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# right/bottom are the only valid keywords |
|
67
|
|
|
|
|
|
|
# for the position for most other functions |
|
68
|
9
|
100
|
|
|
|
28
|
return 'right' if ($position =~ m/^right$/i); |
|
69
|
8
|
100
|
|
|
|
23
|
return 'bottom' if ($position =~ m/^bottom$/i); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# die with a fatal error for invalid positions |
|
72
|
7
|
|
|
|
|
74
|
die "unknown background position: <$position>"; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
#################################################################################################### |
|
77
|
|
|
|
|
|
|
#################################################################################################### |
|
78
|
|
|
|
|
|
|
1; |