/[suikacvs]/messaging/manakai/lib/Message/DOM/CSSStyleSheet.pm
Suika

Contents of /messaging/manakai/lib/Message/DOM/CSSStyleSheet.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Sun Dec 23 08:18:59 2007 UTC (16 years, 11 months ago) by wakaba
Branch: MAIN
Changes since 1.2: +16 -4 lines
++ manakai/lib/Message/DOM/ChangeLog	23 Dec 2007 08:18:42 -0000
2007-12-23  Wakaba  <wakaba@suika.fam.cx>

	* CSSRule.pm (type, css_text): Typo fixed.
	(____new): s/_selector/_selectors/g;
	(CSSStyleRule.css_text, selectors_text): Ad hoc implementation.

	* CSSStyleDeclaration.pm (css_text): Ad hoc implementation.

	* CSSStyleSheet.pm (new): s/new/____new/.
	(css_text): New attribute.

1 package Message::DOM::CSSStyleSheet;
2 use strict;
3 our $VERSION=do{my @r=(q$Revision: 1.2 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
4 push our @ISA, 'Message::IF::CSSStyleSheet';
5 require Message::DOM::DOMException;
6 require Scalar::Util;
7
8 sub ____new ($;%) {
9 my $class = shift;
10 my $self = bless \{@_}, $class;
11 for (@{$$self->{css_rules}}) {
12 ${$_}->{parent_style_sheet} = $self;
13 Scalar::Util::weaken (${$_}->{parent_style_sheet});
14 }
15 return $self;
16 } # ____new
17
18 sub AUTOLOAD {
19 my $method_name = our $AUTOLOAD;
20 $method_name =~ s/.*:://;
21 return if $method_name eq 'DESTROY';
22
23 if ({
24 ## Read-only attributes (trivial accessors)
25 href => 1,
26 owner_node => 1,
27 owner_rule => 1,
28 parent_style_sheet => 1,
29 type => 1,
30 }->{$method_name}) {
31 no strict 'refs';
32 eval qq{
33 sub $method_name (\$) {
34 return \${\$_[0]}->{$method_name};
35 }
36 };
37 goto &{ $AUTOLOAD };
38 } else {
39 require Carp;
40 Carp::croak (qq<Can't locate method "$AUTOLOAD">);
41 }
42 } # AUTOLOAD
43
44 ## |StyleSheet| attributes
45
46 sub disabled ($;$) {
47 if (@_ > 1) {
48 if ($_[1]) {
49 ${$_[0]}->{disabled} = 1;
50 } else {
51 delete ${$_[0]}->{disabled};
52 }
53 }
54 return ${$_[0]}->{disabled};
55 } # disabled
56
57 sub href ($);
58
59 sub media ($;$) {
60 if (@_ > 1) {
61 local $Error::Depth = $Error::Depth + 1;
62 ${+shift}->{media}->media_text (@_);
63 }
64 return ${$_[0]}->{media};
65 } # media
66
67 sub owner_node ($);
68
69 sub parent_style_sheet ($);
70
71 sub title ($;$) {
72 if (@_ > 1) {
73 if (defined $_[1]) {
74 ${$_[0]}->{title} = ''.$_[1];
75 } else {
76 delete ${$_[0]}->{title};
77 }
78 }
79 return ${$_[0]}->{title};
80 } # title
81
82 sub type ($);
83
84 ## |CSSStyleSheet| attributes
85
86 sub css_rules ($) {
87 require Message::DOM::CSSRuleList;
88 return bless \\($_[0]), 'Message::DOM::CSSRuleList';
89 } # css_rules
90
91 ## NOTE: This is a manakai extension.
92 sub css_text ($;$) {
93 ## TODO: setter
94
95 my $r = '';
96 local $Error::Depth = $Error::Depth + 1;
97 for my $rule (@{$_[0]->css_rules}) {
98 $r .= $rule->css_text;
99 }
100 return $r;
101 } # css_text
102
103 sub owner_rule ($);
104
105 ## |CSSStyleSheet| methods
106
107 sub delete_rule ($$) {
108 if ($_[1] < 0 or $_[1] > @{${$_[0]}->{css_rules}}) {
109 report Message::DOM::DOMException
110 -object => $_[0],
111 -type => 'INDEX_SIZE_ERR',
112 -subtype => 'INDEX_OUT_OF_BOUND_ERR';
113 } else {
114 my $rule = ${$_[0]}->{css_rules}->[$_[1]];
115 delete $rule->{parent_rule};
116 delete ${$_[0]}->{css_rules}->[$_[1]];
117 }
118 } # delete_rule
119
120 ## TODO: insert_rule
121
122 package Message::IF::StyleSheet;
123 package Message::IF::CSSStyleSheet;
124
125 1;
126 ## $Date: 2007/12/22 06:57:46 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24