~ubuntu-branches/ubuntu/quantal/libcss-dom-perl/quantal

« back to all changes in this revision

Viewing changes to lib/CSS/DOM/Rule/Charset.pm

  • Committer: Bazaar Package Importer
  • Author(s): Nicholas Bamber
  • Date: 2011-02-10 21:51:03 UTC
  • Revision ID: james.westby@ubuntu.com-20110210215103-vaalgfelzvw4bar4
Tags: upstream-0.14
ImportĀ upstreamĀ versionĀ 0.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package CSS::DOM::Rule::Charset;
 
2
 
 
3
$VERSION = '0.14';
 
4
 
 
5
use warnings; no warnings qw 'utf8 parenthesis';
 
6
use strict;
 
7
 
 
8
use CSS::DOM::Util 'escape';
 
9
 use        CSS::DOM::Rule;
 
10
 
 
11
our @ISA = 'CSS::DOM::Rule';
 
12
 
 
13
use constant # Don't let this conflict with the superclass.
 
14
        cset => 2;
 
15
{ no strict 'refs'; delete ${__PACKAGE__.'::'}{cset} }
 
16
 
 
17
# overrides:
 
18
 
 
19
sub type { CSS::DOM::Rule::CHARSET_RULE }
 
20
sub cssText {
 
21
        my $self = shift;
 
22
        my $old;
 
23
        if(defined wantarray) {
 
24
                $old = "\@charset \""
 
25
                        . escape($self->[cset],'"') ."\";\n";
 
26
        }
 
27
        if (@_) {
 
28
                require CSS::DOM::Parser;
 
29
                my $new_rule  =  $self->_parse(shift);
 
30
                @$self[cset] = @$new_rule[cset];
 
31
        }
 
32
        $old;
 
33
};
 
34
 
 
35
 
 
36
# CSSCharsetRule interface:
 
37
 
 
38
sub encoding {
 
39
        my $old = (my $self = shift)->[cset];
 
40
        @_ and $$self[cset] = shift;
 
41
        $old
 
42
}
 
43
 
 
44
                              !()__END__()!
 
45
 
 
46
=head1 NAME
 
47
 
 
48
CSS::DOM::Rule::FontFace - CSS @font-face rule class for CSS::DOM
 
49
 
 
50
=head1 VERSION
 
51
 
 
52
Version 0.14
 
53
 
 
54
=head1 SYNOPSIS
 
55
 
 
56
  use CSS::DOM;
 
57
  my $font_face_rule = CSS::DOM->parse(
 
58
      '@font-face { font-family: "bm"; src: url(blackmoor.ttf) }'
 
59
  )->cssRules->[0];
 
60
 
 
61
  $page_rule->style;        # a CSS::DOM::Style object
 
62
  $page_rule->style->src;   # 'url(blackmoor.ttf)'
 
63
 
 
64
=head1 DESCRIPTION
 
65
 
 
66
This module implements CSS @font-face rules for L<CSS::DOM>. It inherits 
 
67
from
 
68
L<CSS::DOM::Rule> and implements
 
69
the CSSFontFaceRule DOM interface.
 
70
 
 
71
=head1 THE METHOD
 
72
 
 
73
=over 4
 
74
 
 
75
=item style
 
76
 
 
77
Returns the CSS::DOM::Style object representing the declaration block
 
78
of this rule.
 
79
 
 
80
=back
 
81
 
 
82
=head1 SEE ALSO
 
83
 
 
84
L<CSS::DOM>
 
85
 
 
86
L<CSS::DOM::Style>
 
87
 
 
88
L<CSS::DOM::Rule>