/usr/share/perl5/CSS/Style.pm is in libcss-perl 1.08-1+nmu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | package CSS::Style;
$VERSION = 1.02;
use strict;
use warnings;
use overload '""' => 'to_string';
# create a new CSS::Style object
sub new {
my $class = shift;
my $self = bless {}, $class;
$self->{options} = shift;
$self->{selectors} = [];
$self->{properties} = [];
$self->{adaptor} = $self->{options}->{adaptor} || 'CSS::Adaptor';
return $self;
}
sub add_selector {
my $self = shift;
my $selector = shift;
push @{$self->{selectors}}, $selector;
$selector->set_adaptor($self->{adaptor});
}
sub add_property {
my $self = shift;
my $property = shift;
push @{$self->{properties}}, $property;
$property->set_adaptor($self->{adaptor});
}
sub set_adaptor {
my $self = shift;
my $adaptor = shift;
# set adaptor
$self->{adaptor} = $adaptor;
# recurse adaptor
$_->set_adaptor($adaptor) for(@{$self->{selectors}});
$_->set_adaptor($adaptor) for(@{$self->{properties}});
}
sub selectors {
my $self = shift;
eval "use $self->{adaptor}";
my $adaptor_obj = new $self->{adaptor};
return $adaptor_obj->output_selectors($self->{selectors});
}
sub properties {
my $self = shift;
eval "use $self->{adaptor}";
my $adaptor_obj = new $self->{adaptor};
return $adaptor_obj->output_properties($self->{properties});
}
sub to_string {
my $self = shift;
eval "use $self->{adaptor}";
my $adaptor_obj = new $self->{adaptor};
return $adaptor_obj->output_rule($self);
}
sub get_property_by_name {
my ($self, $prop_name) = @_;
for my $prop (@{$self->{properties}}){
if ($prop->{property} eq $prop_name){
return $prop;
}
}
return 0;
}
1;
__END__
=head1 NAME
CSS::Style - A ruleset in a CSS object tree
=head1 SYNOPSIS
use CSS;
=head1 DESCRIPTION
This module represents a ruleset in a CSS object tree.
Read the CSS.pm pod for information about the CSS object tree.
=head1 METHODS
=head2 CONSTRUCTORS
=over 4
=item C<new()> or C<new( { ..options.. } )>
This constructor returns a new C<CSS::Style> object, with
an optional hash of options.
adaptor adaptor to use for serialization
=back
=head2 ACCESSORS
=over 4
=item C<add_selector( $selector )>
This method adds a selector to the selector list for the object.
C<$selector> is a reference to a CSS::Selector object.
=item C<add_property( $property )>
This method adds a selector to the property list for the object.
C<$property> is a reference to a CSS::Property object.
=item C<set_adaptor( 'CSS::Adaptor::Foo' )>
This method sets the current adaptor for the object.
=item C<selectors()>
This method is used to serialize the ruleset's selectors, using the current
adaptor. It returns a string which come from the adaptor's C<output_selectors()>
method.
=item C<properties()>
This method is used to serialize the ruleset's properties, using the current
adaptor. It returns a string which come from the adaptor's C<output_properties()>
method.
=item C<to_string()>
This method is used to serialize the ruleset, using the current adaptor. It returns
a string which comes from the adaptor's output_rules() method.
=item C<get_property_by_name( 'property_name' )>
Returns the first CSS::Property object with the specified name. Returns
zero on failure.
=back
=head1 AUTHOR
Copyright (C) 2003-2004, Cal Henderson <cal@iamcal.com>
=head1 SEE ALSO
L<CSS>, http://www.w3.org/TR/REC-CSS1
=cut
|