This file is indexed.

/usr/share/perl5/CSS/DOM/Style.pm is in libcss-dom-perl 0.16-1.

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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
package CSS::DOM::Style;

$VERSION = '0.16';

use warnings; no warnings qw' utf8';
use strict;

use CSS::DOM::Exception 'SYNTAX_ERR';
use CSS::DOM::Util qw 'escape_ident unescape';
use Scalar::Util 'weaken';

# ~~~ use overload fallback => 1, '@{}' => 

# Internal object structure
#
# Each style object is a hash ref:
# {
#    owner       => $owner_rule,
#    parser      => $property_parser,
#    mod_handler => sub { ... },  # undef initially
#    names       => [...],
#    props       => {...},
#    pri         => {...},  # property priorities
# }
#
# The value of an element in the props hash can be one of three things
#  1) a CSSValue object
#  2) an array ref that is a blueprint for a CSSValue object:
#     [ $css_code, $class, @constructor_args]
#  3) a string of css code
# Item (3) is only used when there is no property parser.

sub parse {
	require CSS::DOM::Parser;
	goto &CSS::DOM::Parser::parse_style_declaration;
}

sub new {
	my($class) = shift;

	my $self = bless {}, $class;
	if(@_ == 1) {
		$self->{owner} = shift;
	}
	else {
		my %args = @_;
		$self->{owner} = delete $args{owner};
		$self->{parser}
		 = delete $args{property_parser};
	}
	{
		$self->{parser} ||= (
		    ($self->{owner} || next)->parentStyleSheet || next
		   )->property_parser;
	}
	weaken $self->{owner};
	return $self
}

sub cssText {
	my $self = shift;
	my $out;
	if (defined wantarray) {
		$out = join "; ", map {
			my $pri = $self->getPropertyPriority($_);
			"$_: ".$self->getPropertyValue($_)." !"x!!$pri
				. escape_ident($pri)
		} @{$$self{names}};
	}
	if(@_) {
		my $css = shift;
		!defined $css || !length $css and
			@$self{'props','names'} = (), return $out;

		require CSS::DOM::Parser;
		my $new =CSS::DOM::Parser::parse_style_declaration(
		 $css, property_parser => $$self{parser}
		);

		@$self{'props','names'} = @$new{'props','names'};
		_m($self);
	}
	return $out;
}

sub getPropertyValue { # ~~~ Later I plan to make this return lists of
                       #     scalars in list context (for list properties).
	my $self = shift;
	my $props = $self->{props} || return '';
	my $name = lc$_[0];

	if(my $spec = $self->{parser}) { serialise: {
		if(my $p = $spec->get_property($name)) {
		 if(exists $p->{serialise} and my $s = $p->{serialise}) {
		   my @p = $spec->subproperty_names($name);
		   my %p;
		   for(@p) {
		    my $v = $self->getPropertyValue($_) ;
		    length $v or last serialise;
		    $p{$_}
		     = $spec->get_property($_)->{default} eq $v ?'':$v;
		   }
		   return $s->(\%p);
		 }
		}
	}}

	exists $props->{$name}
		or return return '';
	my $val = $props->{$name};
	return ref $val eq 'ARRAY' ? $$val[0]
	     : !ref $val           ? $val
	     :                       $val->cssText;
}

sub getPropertyCSSValue {
	my $self = shift;
	$self->{parser} or return;
	exists +(my $props = $self->{props} || return)->{
	  my $name = lc$_[0]
	}	or return return;
	my $valref = \$props->{$name};
	return ref $$valref eq 'ARRAY'
		? scalar (
			$$$valref[1]->can('new')
			 || do {
			     (my $pack = $$$valref[1]) =~ s e::e/egg;
			     require "$pack.pm";
			    },
			$$valref =
			  $$$valref[1]->new(
			   owner => $self, property => $name,
			   @$$valref[2..$#$$valref],
			  )
		) : $$valref;
}

sub removeProperty {
	my $self = shift;
	my $name = lc shift;

	# Get the value so we can return it
	my $val;
	$val = $self->getPropertyValue($name)
	 if defined wantarray;

	# Get names of subprops if we are dealing with a shorthand prop
	my @to_delete;
	if(my $spec = $self->{parser}) {
		@to_delete = $spec->subproperty_names($name);
	}
	@to_delete or @to_delete = $name;

	# Delete the properties
	for my $name(@to_delete) {
		delete +($self->{props} || return $val)->{$name};
		@{$$self{names}} = grep $_ ne $name,
			@{$$self{names} || return $val};
	}

	$val;
}

sub getPropertyPriority {
	return ${shift->{pri}||return ''}{lc shift} || ''
}

sub setProperty {
	my ($self, $name, $value, $priority) = @_;

	# short-circuit for the common case
	length $value or $self->removeProperty($name),return;

	require CSS'DOM'Parser;
	my @tokens = eval { CSS'DOM'Parser'tokenise_value($value); }
		or die CSS::DOM'Exception->new( SYNTAX_ERR, $@);

	# check for whitespace/comment assignment
	$tokens[0] =~ /^s+\z/ and $self->removeProperty($name),return;

	my $props = $$self{props} ||= {};
	my $pri = $$self{pri} ||= {};

	my $val;
	if(my $spec = $self->{parser}) {
		my(@args) = $spec->match($name, @tokens)
			or return;
		if(@args == 1) { # shorthand
			while(my($k,$v) = each %{ $args[0] }) {
				$self->removeProperty($k), next
				 if $v eq "";
				exists $$props{$k=lc$k}
				 or push @{$$self{names}}, $k;
				$$props{$k} = $v;
				$$pri{$k} = $priority;
			}
			return;
		}
		else {
			$val = \@args;
		}
	}

	exists $$props{$name=lc$name} or push @{$$self{names}}, $name;
	$$props{$name} = $val || join "", @{ $tokens[1] };
	$$pri{$name} = $priority;

	_m($self);
	return
}

sub item {
	my $ret = shift->{names}[shift];
	return defined $ret ? $ret : ''
}

sub parentRule {
	shift->{owner}
}

sub _set_property_tokens { # private
	my ($self,$name,$types,$tokens) = @_;

	# Parse out the priority first
	my $priority;
	if($types =~ /(s?(ds?))i\z/ and $tokens->[$-[2]] eq '!') {
		$types =~ s///;
		$priority = unescape pop @$tokens;
		pop @$tokens for 1..length $1;
	} else {
		$priority = '';
	}

	# Get the prop & priority hashes
	my $props = $$self{props} ||= {};
	my $pri = $$self{pri} ||={};

	# See if we need to parse the value
	my $val;
	if(my $spec = $self->{parser}) {
		my(@args) = $spec->match($name,$types,$tokens)
			or return;
		if(@args == 1) {
			while(my($k,$v) = each %{ $args[0] }) {
				$self->removeProperty($k), next
				 if $v eq "";
				exists $$props{$k=lc$k}
				 or push @{$$self{names}}, $k;
				$$props{$k} = $v;
				$$pri{$k} = $priority;
			}
			return;
		}
		else {
			$val = \@args;
		}
	}
	else { $val = join "", @$tokens }

	# Assign the value & priority
	exists $$props{$name=lc$name} or push @{$$self{names}}, $name;
	$$props{$name} = $val;
	$$pri{$name} = $priority;
}


{ my $prop_re = qr/[a-z]+(?:[A-Z][a-z]+)*/;
sub can {
	SUPER::can { shift } @_ or
		$_[0] =~ /^$prop_re\z/o ? \&{+shift} : undef;
}
sub AUTOLOAD {
	my $self = shift;
	if(our $AUTOLOAD =~ /(?<=:)($prop_re)\z/o) {
		(my $prop = $1) =~ s/([A-Z])/-\l$1/g;
		my $val;
		defined wantarray
			and $val = $self->getPropertyValue($prop);
		@_ and $self->setProperty($prop, shift);
		return $val;
	} else {
		die "Undefined subroutine $AUTOLOAD called at ",
			join(" line ", (caller)[1,2]), ".\n";
	}
}
sub DESTROY{}
}
*cssFloat = \&float;

sub modification_handler {
	my $old = (my $self = shift)->{mod_handler};
	$self->{mod_handler} = shift if @_;
	$old;
}

sub _m#odified
{
	&{$_[0]->{mod_handler} or return}($_[0]);
}

sub property_parser { shift->{parser} }

sub length { # We put this one last to avoid having to say CORE::length
             # elsewhere.
	scalar @{shift->{names}||return 0}
}



                              !()__END__()!

=head1 NAME

CSS::DOM::Style - CSS style declaration class for CSS::DOM

=head1 VERSION

Version 0.16

=head1 SYNOPSIS

  use CSS::DOM::Style;
  
  $style = CSS::DOM::Style::parse(' text-decoration: none ');
  
  $style->cssText; # returns 'text-decoration: none'
  $style->cssText('color: blue'); # replace contents
  
  $style->getPropertyValue('color'); # 'blue'
  $style->color;                     # same
  $style->setProperty(color=>'green'); # change it
  $style->color('green');              # same

=head1 DESCRIPTION

This module provides the CSS style declaration class for L<CSS::DOM>. (A
style declaration is what comes between the braces in C<p { margin: 0 }>.)
It 
implements
the CSSStyleDeclaration DOM interface.

=head1 CONSTRUCTORS

=over 4

=item CSS::DOM::Style::parse( $string )

=item CSS::DOM::Style::parse( $string, property_parser => $parser )

This parses the C<$string> and returns a new style declaration 
object. This is useful if you have text from an HTML C<style> attribute,
for instance.

For details on C<$property_parser>, see L<CSS::DOM::PropertyParser>.

=item new CSS::DOM::Style $owner_rule

=item new CSS::DOM::Style owner => $owner_rule, property_parser => $p

You don't normally need to call this, but, in case you do, here it is.
C<$owner_rule>, which is optional, is expected to be a L<CSS::DOM::Rule>
object, or a subclass like L<CSS::DOM::Rule::Style>.

=back

=head1 METHODS

=over 4

=item cssText ( $new_value )

Returns the body of this style declaration (without the braces). If you
pass an argument, it will parsed and replace the existing CSS data.

=item getPropertyValue ( $name )

Returns the value of the named CSS property as a string.

=item getPropertyCSSValue ( $name )

Returns an object representing the property's value. 
(See L<CSS::DOM::Value>.)

=item removeProperty ( $name )

Removes the named property, returning its value.

=item getPropertyPriority

Returns the property's priority. This is usually the empty string or the
word 'important'.

=item setProperty ( $name, $value, $priority )

Sets the CSS property named C<$name>, giving it a value of C<$value> and
setting the priority to C<$priority>.

=item length

Returns the number of properties

=item item ( $index )

Returns the name of the property at the given index.

=item parentRule

Returns the rule to which this declaration belongs.

=item modification_handler ( $coderef )

This method, not part of the DOM, allows you to attach a call-back routine
that is run whenever a change occurs to the style object (with the style
object as its only argument). If you call it
without an argument it returns the current handler. With an argument, it
returns the old value after setting it.

=item property_parser

This returns the parser that was passed to the constructor.

=back

This module also has methods for accessing each CSS property directly.
Simply capitalise each letter in a CSS property name that follows a hyphen,
then remove the hyphens, and you'll have the method name. E.g., call the
C<borderBottomWidth> method to get/set the border-bottom-width property.
One exception to this is that C<cssFloat> is the method used to access the
'float' property. (But you can also use the C<float> method, though it's
not part of the DOM standard.)

=head1 SEE ALSO

L<CSS::DOM>

L<CSS::DOM::Rule::Style>

L<CSS::DOM::PropertyParser>

L<HTML::DOM::Element>