| 1419 |
## 'margin-left', 'top', 'right', 'bottom', 'left', 'padding-top', |
## 'margin-left', 'top', 'right', 'bottom', 'left', 'padding-top', |
| 1420 |
## 'padding-right', 'padding-bottom', 'padding-left', |
## 'padding-right', 'padding-bottom', 'padding-left', |
| 1421 |
## 'border-top-width', 'border-right-width', 'border-bottom-width', |
## 'border-top-width', 'border-right-width', 'border-bottom-width', |
| 1422 |
## 'border-left-width', and 'text-indent'. |
## 'border-left-width', 'text-indent', 'background-position-x', |
| 1423 |
|
## and 'background-position-y'. |
| 1424 |
|
|
| 1425 |
my $sign = 1; |
my $sign = 1; |
| 1426 |
if ($t->{type} == MINUS_TOKEN) { |
if ($t->{type} == MINUS_TOKEN) { |
| 1880 |
$Attr->{text_indent} = $Prop->{'text-indent'}; |
$Attr->{text_indent} = $Prop->{'text-indent'}; |
| 1881 |
$Key->{text_indent} = $Prop->{'text-indent'}; |
$Key->{text_indent} = $Prop->{'text-indent'}; |
| 1882 |
|
|
| 1883 |
|
$Prop->{'background-position-x'} = { |
| 1884 |
|
css => 'background-position-x', |
| 1885 |
|
dom => 'background_position_x', |
| 1886 |
|
key => 'background_position_x', |
| 1887 |
|
parse => $Prop->{'margin-top'}->{parse}, |
| 1888 |
|
allow_negative => 1, |
| 1889 |
|
keyword => {left => 1, center => 1, right => 1}, |
| 1890 |
|
serialize => $default_serializer, |
| 1891 |
|
initial => ['PERCENTAGE', 0], |
| 1892 |
|
#inherited => 0, |
| 1893 |
|
compute => sub { |
| 1894 |
|
my ($self, $element, $prop_name, $specified_value) = @_; |
| 1895 |
|
|
| 1896 |
|
if (defined $specified_value and $specified_value->[0] eq 'KEYWORD') { |
| 1897 |
|
my $v = { |
| 1898 |
|
left => 0, center => 50, right => 100, top => 0, bottom => 100, |
| 1899 |
|
}->{$specified_value->[1]}; |
| 1900 |
|
if (defined $v) { |
| 1901 |
|
return ['PERCENTAGE', $v]; |
| 1902 |
|
} else { |
| 1903 |
|
return $specified_value; |
| 1904 |
|
} |
| 1905 |
|
} else { |
| 1906 |
|
return $compute_length->(@_); |
| 1907 |
|
} |
| 1908 |
|
}, |
| 1909 |
|
serialize_multiple => sub { |
| 1910 |
|
my $self = shift; |
| 1911 |
|
|
| 1912 |
|
local $Error::Depth = $Error::Depth + 1; |
| 1913 |
|
my $x = $self->background_position_x; |
| 1914 |
|
my $y = $self->background_position_y; |
| 1915 |
|
my $xi = $self->get_property_priority ('background-position-x'); |
| 1916 |
|
my $yi = $self->get_property_priority ('background-position-y'); |
| 1917 |
|
$xi = ' !' . $xi if length $xi; |
| 1918 |
|
$yi = ' !' . $yi if length $yi; |
| 1919 |
|
if (defined $x) { |
| 1920 |
|
if (defined $y) { |
| 1921 |
|
if ($xi eq $yi) { |
| 1922 |
|
return {'background-position' => $x . ' ' . $y . $xi}; |
| 1923 |
|
} else { |
| 1924 |
|
return {'background-position-x' => $x . $xi, |
| 1925 |
|
'background-position-y' => $y . $yi}; |
| 1926 |
|
} |
| 1927 |
|
} else { |
| 1928 |
|
return {'background-position-x' => $x . $xi}; |
| 1929 |
|
} |
| 1930 |
|
} else { |
| 1931 |
|
if (defined $y) { |
| 1932 |
|
return {'background-position-y' => $y . $yi}; |
| 1933 |
|
} else { |
| 1934 |
|
return {}; |
| 1935 |
|
} |
| 1936 |
|
} |
| 1937 |
|
}, |
| 1938 |
|
}; |
| 1939 |
|
$Attr->{background_position_x} = $Prop->{'background-position-x'}; |
| 1940 |
|
$Key->{background_position_x} = $Prop->{'background-position-x'}; |
| 1941 |
|
|
| 1942 |
|
$Prop->{'background-position-y'} = { |
| 1943 |
|
css => 'background-position-y', |
| 1944 |
|
dom => 'background_position_y', |
| 1945 |
|
key => 'background_position_y', |
| 1946 |
|
parse => $Prop->{'margin-top'}->{parse}, |
| 1947 |
|
allow_negative => 1, |
| 1948 |
|
keyword => {top => 1, center => 1, bottom => 1}, |
| 1949 |
|
serialize => $default_serializer, |
| 1950 |
|
serialize_multiple => $Prop->{'background-position-x'}->{serialize_multiple}, |
| 1951 |
|
initial => ['PERCENTAGE', 0], |
| 1952 |
|
#inherited => 0, |
| 1953 |
|
compute => $Prop->{'background-position-x'}->{compute}, |
| 1954 |
|
}; |
| 1955 |
|
$Attr->{background_position_y} = $Prop->{'background-position-y'}; |
| 1956 |
|
$Key->{background_position_y} = $Prop->{'background-position-y'}; |
| 1957 |
|
|
| 1958 |
$Prop->{'padding-top'} = { |
$Prop->{'padding-top'} = { |
| 1959 |
css => 'padding-top', |
css => 'padding-top', |
| 1960 |
dom => 'padding_top', |
dom => 'padding_top', |
| 3265 |
}; |
}; |
| 3266 |
$Attr->{border_spacing} = $Prop->{'border-spacing'}; |
$Attr->{border_spacing} = $Prop->{'border-spacing'}; |
| 3267 |
|
|
| 3268 |
|
## NOTE: See <http://suika.fam.cx/gate/2005/sw/background-position> for |
| 3269 |
|
## browser compatibility problems. |
| 3270 |
|
$Prop->{'background-position'} = { |
| 3271 |
|
css => 'background-position', |
| 3272 |
|
dom => 'background_position', |
| 3273 |
|
parse => sub { |
| 3274 |
|
my ($self, $prop_name, $tt, $t, $onerror) = @_; |
| 3275 |
|
|
| 3276 |
|
my %prop_value; |
| 3277 |
|
|
| 3278 |
|
my $sign = 1; |
| 3279 |
|
if ($t->{type} == MINUS_TOKEN) { |
| 3280 |
|
$t = $tt->get_next_token; |
| 3281 |
|
$sign = -1; |
| 3282 |
|
} |
| 3283 |
|
|
| 3284 |
|
if ($t->{type} == DIMENSION_TOKEN) { |
| 3285 |
|
my $value = $t->{number} * $sign; |
| 3286 |
|
my $unit = lc $t->{value}; ## TODO: case |
| 3287 |
|
$t = $tt->get_next_token; |
| 3288 |
|
if ($length_unit->{$unit}) { |
| 3289 |
|
$prop_value{'background-position-x'} = ['DIMENSION', $value, $unit]; |
| 3290 |
|
$prop_value{'background-position-y'} = ['PERCENTAGE', 50]; |
| 3291 |
|
} else { |
| 3292 |
|
$onerror->(type => 'syntax error:'.$prop_name, |
| 3293 |
|
level => $self->{must_level}, |
| 3294 |
|
token => $t); |
| 3295 |
|
return ($t, undef); |
| 3296 |
|
} |
| 3297 |
|
} elsif ($t->{type} == PERCENTAGE_TOKEN) { |
| 3298 |
|
my $value = $t->{number} * $sign; |
| 3299 |
|
$t = $tt->get_next_token; |
| 3300 |
|
$prop_value{'background-position-x'} = ['PERCENTAGE', $value]; |
| 3301 |
|
$prop_value{'background-position-y'} = ['PERCENTAGE', 50]; |
| 3302 |
|
} elsif ($t->{type} == NUMBER_TOKEN and |
| 3303 |
|
($self->{unitless_px} or $t->{number} == 0)) { |
| 3304 |
|
my $value = $t->{number} * $sign; |
| 3305 |
|
$t = $tt->get_next_token; |
| 3306 |
|
$prop_value{'background-position-x'} = ['DIMENSION', $value, 'px']; |
| 3307 |
|
$prop_value{'background-position-y'} = ['PERCENTAGE', 50]; |
| 3308 |
|
} elsif ($sign > 0 and $t->{type} == IDENT_TOKEN) { |
| 3309 |
|
my $prop_value = lc $t->{value}; ## TODO: case folding |
| 3310 |
|
$t = $tt->get_next_token; |
| 3311 |
|
if ({left => 1, center => 1, right => 1}->{$prop_value}) { |
| 3312 |
|
$prop_value{'background-position-x'} = ['KEYWORD', $prop_value]; |
| 3313 |
|
$prop_value{'background-position-y'} = ['KEYWORD', 'center']; |
| 3314 |
|
} elsif ($prop_value eq 'top' or $prop_value eq 'bottom') { |
| 3315 |
|
$prop_value{'background-position-y'} = ['KEYWORD', $prop_value]; |
| 3316 |
|
|
| 3317 |
|
$t = $tt->get_next_token while $t->{type} == S_TOKEN; |
| 3318 |
|
if ($t->{type} == IDENT_TOKEN) { |
| 3319 |
|
my $prop_value = lc $t->{value}; ## TODO: case folding |
| 3320 |
|
if ({left => 1, center => 1, right => 1}->{$prop_value}) { |
| 3321 |
|
$prop_value{'background-position-x'} = ['KEYWORD', $prop_value]; |
| 3322 |
|
$t = $tt->get_next_token; |
| 3323 |
|
return ($t, \%prop_value); |
| 3324 |
|
} |
| 3325 |
|
} |
| 3326 |
|
$prop_value{'background-position-x'} = ['KEYWORD', 'center']; |
| 3327 |
|
return ($t, \%prop_value); |
| 3328 |
|
} elsif ($prop_value eq 'inherit') { |
| 3329 |
|
$prop_value{'background-position-x'} = ['INHERIT']; |
| 3330 |
|
$prop_value{'background-position-y'} = ['INHERIT']; |
| 3331 |
|
return ($t, \%prop_value); |
| 3332 |
|
} else { |
| 3333 |
|
$onerror->(type => 'syntax error:'.$prop_name, |
| 3334 |
|
level => $self->{must_level}, |
| 3335 |
|
token => $t); |
| 3336 |
|
return ($t, undef); |
| 3337 |
|
} |
| 3338 |
|
} else { |
| 3339 |
|
$onerror->(type => 'syntax error:'.$prop_name, |
| 3340 |
|
level => $self->{must_level}, |
| 3341 |
|
token => $t); |
| 3342 |
|
return ($t, undef); |
| 3343 |
|
} |
| 3344 |
|
|
| 3345 |
|
$t = $tt->get_next_token while $t->{type} == S_TOKEN; |
| 3346 |
|
$sign = 1; |
| 3347 |
|
if ($t->{type} == MINUS_TOKEN) { |
| 3348 |
|
$t = $tt->get_next_token; |
| 3349 |
|
$sign = -1; |
| 3350 |
|
} |
| 3351 |
|
|
| 3352 |
|
if ($t->{type} == DIMENSION_TOKEN) { |
| 3353 |
|
my $value = $t->{number} * $sign; |
| 3354 |
|
my $unit = lc $t->{value}; ## TODO: case |
| 3355 |
|
$t = $tt->get_next_token; |
| 3356 |
|
if ($length_unit->{$unit}) { |
| 3357 |
|
$prop_value{'background-position-y'} = ['DIMENSION', $value, $unit]; |
| 3358 |
|
} else { |
| 3359 |
|
$onerror->(type => 'syntax error:'.$prop_name, |
| 3360 |
|
level => $self->{must_level}, |
| 3361 |
|
token => $t); |
| 3362 |
|
return ($t, undef); |
| 3363 |
|
} |
| 3364 |
|
} elsif ($t->{type} == PERCENTAGE_TOKEN) { |
| 3365 |
|
my $value = $t->{number} * $sign; |
| 3366 |
|
$t = $tt->get_next_token; |
| 3367 |
|
$prop_value{'background-position-y'} = ['PERCENTAGE', $value]; |
| 3368 |
|
} elsif ($t->{type} == NUMBER_TOKEN and $self->{unitless_px}) { |
| 3369 |
|
my $value = $t->{number} * $sign; |
| 3370 |
|
$t = $tt->get_next_token; |
| 3371 |
|
$prop_value{'background-position-y'} = ['DIMENSION', $value, 'px']; |
| 3372 |
|
} elsif ($t->{type} == IDENT_TOKEN) { |
| 3373 |
|
my $value = lc $t->{value}; ## TODO: case |
| 3374 |
|
if ({top => 1, center => 1, bottom => 1}->{$value}) { |
| 3375 |
|
$prop_value{'background-position-y'} = ['KEYWORD', $value]; |
| 3376 |
|
$t = $tt->get_next_token; |
| 3377 |
|
} |
| 3378 |
|
} else { |
| 3379 |
|
if ($sign < 0) { |
| 3380 |
|
$onerror->(type => 'syntax error:'.$prop_name, |
| 3381 |
|
level => $self->{must_level}, |
| 3382 |
|
token => $t); |
| 3383 |
|
return ($t, undef); |
| 3384 |
|
} |
| 3385 |
|
return ($t, \%prop_value); |
| 3386 |
|
} |
| 3387 |
|
|
| 3388 |
|
return ($t, \%prop_value); |
| 3389 |
|
}, |
| 3390 |
|
serialize => sub { |
| 3391 |
|
my ($self, $prop_name, $value) = @_; |
| 3392 |
|
|
| 3393 |
|
local $Error::Depth = $Error::Depth + 1; |
| 3394 |
|
my $x = $self->background_position_x; |
| 3395 |
|
my $y = $self->background_position_y; |
| 3396 |
|
return $x . ' ' . $y if defined $x and defined $y; |
| 3397 |
|
return undef; |
| 3398 |
|
}, |
| 3399 |
|
serialize_multiple => $Prop->{'background-position-x'} |
| 3400 |
|
->{serialize_multiple}, |
| 3401 |
|
}; |
| 3402 |
|
$Attr->{background_position} = $Prop->{'background-position'}; |
| 3403 |
|
|
| 3404 |
$Prop->{'border-width'} = { |
$Prop->{'border-width'} = { |
| 3405 |
css => 'border-width', |
css => 'border-width', |
| 3406 |
dom => 'border_width', |
dom => 'border_width', |