CSS-DOM
view release on metacpan or search on metacpan
lib/CSS/DOM/PropertyParser.pm view on Meta::CPAN
]
$prop_parser->match('counter-reset','Lucida Grande');
'Lucida Grande', $list,
separator => ' ',
values => [
[ type => CSS_IDENT, value => 'Lucida' ],
[ type => CSS_IDENT, value => 'Grande' ],
]
$prop_parser->match('font','bold 13px Lucida Grande');
{
'font-style' => [
'normal', $prim, type => CSS_IDENT, value => 'normal'
],
'font-variant' => [
'normal', $prim, type => CSS_IDENT, value => 'normal'
],
'font-weight' => [
'bold', $prim, type => CSS_IDENT, value => 'bold'
],
'font-size' => [ '13px', $prim, type => CSS_PX, value => 13 ],
'line-height' => [
'normal', $prim, type => CSS_IDENT, value => 'normal'
],
'font-family' => [ 'Lucida Grande', $list,
separator => ', ',
values => [
[ type => CSS_STRING, value => 'Lucida Grande' ],
]
lib/CSS/DOM/PropertyParser.pm view on Meta::CPAN
inherit => 1,
},
'font-variant' => {
format => 'normal | small-caps',
default => 'normal',
inherit => 1,
},
'font-weight' => {
format => 'normal|bold|bolder|lighter|
100|200|300|400|500|600|700|800|900',
default => 'normal',
inherit => 1,
},
font => {
format => "[ 'font-style' || 'font-variant' || 'font-weight' ]?
'font-size' [ / 'line-height' ]? 'font-family'",
special_values => {
caption => '13px Lucida Grande, sans-serif',
lib/CSS/DOM/Rule/Style.pm view on Meta::CPAN
CSS::DOM::Rule::Style - CSS style rule class for CSS::DOM
=head1 VERSION
Version 0.17
=head1 SYNOPSIS
use CSS::DOM;
my $ruleset = CSS::DOM->parse(
'p:firstline, h3 { font-weight: bold }'
)->cssRules->[0];
$ruleset->selectorText; # 'p:firstline, h3'
$ruleset->style; # a CSS::DOM::Style object
$ruleset->style->fontWeight; # 'bold'
=head1 DESCRIPTION
This module implements CSS style rules for L<CSS::DOM>. It inherits
from
L<CSS::DOM::Rule> and implements
the CSSStyleRule DOM interface.
=head1 METHODS
t/CSSMediaRule.t view on Meta::CPAN
use tests 13; # insertRule
{
my $rule = (
my $ss = CSS::DOM::parse(
'@media print {
a{text-decoration: none} p { margin: 0 }
}'
)
)-> cssRules->[0];
is $rule->insertRule('b { font-weight: bold }', 0), 0,
'retval of insertRule';
is_deeply [map $_->selectorText, $rule->cssRules], [qw/ b a p /],
'result of insertRule with 0 for the index';
is $rule->cssRules->[0]->style->cssText, 'font-weight: bold',
'Are the contents of insertRule\'s new rule present?';
isa_ok $rule->cssRules->[0], 'CSS::DOM::Rule';
is $rule->insertRule('i {}', -1), 2,
'retval of insertRule with negative index';
is_deeply [map $_->selectorText, $rule->cssRules], [qw/ b a i p /],
'result of insertRule with negative index';
{
local $SIG{__WARN__} = sub{};
t/CSSStyleDeclaration.t view on Meta::CPAN
property_parser =>$CSS::DOM::PropertyParser::Default
);
is $decl->property_parser, $CSS::DOM::PropertyParser::Default,
'property_parser';
ok $decl->getPropertyCSSValue('text-decoration')->DOES('CSS::DOM::Value'),
'retval of getPropertyCSSValue with property parser';
ok $decl->getPropertyCSSValue('text-decoration')->DOES('CSS::DOM::Value'),
'retval of getPropertyCSSValue (2nd time)'; # weird caching bug in 0.06
is +()=$decl->getPropertyCSSValue('background-color'), '0',
'retval of getPropertyCSSValue when the prop doesn\'t exist';
$decl->font(" bold 13px Times ");
is +()=$decl->getPropertyCSSValue('font'), 0,
'getPropertyCSSValue always returns null for shorthand properties';
}
use tests 3; # removeProperty
is $decl->removeProperty('azimuth'), '',
'removal of a non-existent property returns the empty string';
is $decl->removeProperty('text-decorAtion'), 'underline',
'removeProperty returns the propertyâs value';
unlike $decl->cssText, qr/text-decoration/i,
t/CSSStyleSheet.t view on Meta::CPAN
$ss = CSS::DOM'parse( 'a{text-decoration: none} p { margin: 0 }');
is +()=$ss->cssRules, 2, 'cssRules in list context';
isa_ok my $rules = cssRules $ss, 'CSS::DOM::RuleList',
'cssRules in scalar context';
}
use tests 11; # insertRule
{
$ss = CSS::DOM'parse ('a{text-decoration: none} p { margin: 0 }');
is $ss->insertRule('b { font-weight: bold }', 0), 0,
'retval of insertRule';
is_deeply [map $_->selectorText, $ss->cssRules], [qw/ b a p /],
'result of insertRule with 0 for the index';
is $ss->cssRules->[0]->style->cssText, 'font-weight: bold',
'Are the contents of insertRule\'s new rule present?';
isa_ok $ss->cssRules->[0], 'CSS::DOM::Rule';
is $ss->insertRule('i {}', -1), 2,
'retval of insertRule with negative index';
is_deeply [map $_->selectorText, $ss->cssRules], [qw/ b a i p /],
'result of insertRule with negative index';
{
local $SIG{__WARN__} = sub{};
t/property-parser.t view on Meta::CPAN
is $s->fontSize, $_, "font-size value: \L$_"
}
use tests 2; # font-variant
for(qw/ normal small-caps /) {
$s->fontVariant($_);
is $s->fontVariant, $_, "font-variant value: \L$_"
}
use tests 13; # font-weight
for(qw/ normal bold bolder lighter 100 200 300 400 500 600 700 800 900 /) {
$s->fontWeight($_);
is $s->fontWeight, $_, "font-weight value: \L$_"
}
use tests 25; # font
{
my $props = sub {
return join ",", map $s->getPropertyValue($_),
qw(
font-style font-variant font-weight font-size line-height font-family
t/property-parser.t view on Meta::CPAN
$s->font('100 medium foo');
is $s->font, '100 medium foo',
"font: weight size typeface";
is &$props, 'normal,normal,100,medium,normal,foo',
"other sub-properties after setting font to weight/size/typeface";
$s->font('medium/13px foo');
is $s->font, 'medium/13px foo',
"font: size/leading typeface";
is &$props, 'normal,normal,normal,medium,13px,foo',
"other sub-properties after setting font to size/leading/typeface";
$s->font('normal bold italic 0 foo');
is $s->font, 'italic bold 0 foo',
"font with first three sub-props out of order and normal variant";
is &$props, 'italic,normal,bold,0,normal,foo',
"result of setting font with normal variant & props out of order";
$s->font('small-caps normal 0 foo');
is $s->font, 'small-caps 0 foo',
"font with first 2/3 sub-props & explicit variant (normal applies to 2)";
is &$props, 'normal,small-caps,normal,0,normal,foo',
"result of setting font with small-caps normal";
$s->font('bold italic small-caps 0/5px Times, serif');
is $s->font, 'italic small-caps bold 0/5px Times, serif',
"font with all sub props and comma in typeface";
is &$props, 'italic,small-caps,bold,0,5px,Times, serif',
"result of setting font with all sub-props";
$s->font('caption');
is &$props,
'normal,normal,normal,13px,normal,Lucida Grande, sans-serif',
"sub-props after setting font to caption";
$s->font('');$s->font('icon');
is &$props,
'normal,normal,normal,13px,normal,Lucida Grande, sans-serif',
"sub-props after setting font to icon";
( run in 1.021 second using v1.01-cache-2.11-cpan-39bf76dae61 )