/[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.2 - (hide annotations) (download)
Sat Dec 22 06:57:46 2007 UTC (16 years, 11 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +31 -6 lines
++ manakai/lib/Message/DOM/ChangeLog	22 Dec 2007 06:57:35 -0000
	* MediaList.pm: New placeholder for a CSSOM interface.

	* CSSRule.pm, CSSStyleSheet.pm: Implementing the initial
	setting of owner* and parent* attributes; support
	for the |delete_rule| method.

2007-12-22  Wakaba  <wakaba@suika.fam.cx>

1 wakaba 1.1 package Message::DOM::CSSStyleSheet;
2     use strict;
3 wakaba 1.2 our $VERSION=do{my @r=(q$Revision: 1.1 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
4 wakaba 1.1 push our @ISA, 'Message::IF::CSSStyleSheet';
5 wakaba 1.2 require Message::DOM::DOMException;
6     require Scalar::Util;
7 wakaba 1.1
8 wakaba 1.2 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 wakaba 1.1 } # 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 wakaba 1.2 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 wakaba 1.1
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     sub owner_rule ($);
92    
93     ## |CSSStyleSheet| methods
94    
95 wakaba 1.2 sub delete_rule ($$) {
96     if ($_[1] < 0 or $_[1] > @{${$_[0]}->{css_rules}}) {
97     report Message::DOM::DOMException
98     -object => $_[0],
99     -type => 'INDEX_SIZE_ERR',
100     -subtype => 'INDEX_OUT_OF_BOUND_ERR';
101     } else {
102     my $rule = ${$_[0]}->{css_rules}->[$_[1]];
103     delete $rule->{parent_rule};
104     delete ${$_[0]}->{css_rules}->[$_[1]];
105     }
106     } # delete_rule
107 wakaba 1.1
108     ## TODO: insert_rule
109    
110     package Message::IF::StyleSheet;
111     package Message::IF::CSSStyleSheet;
112    
113     1;
114 wakaba 1.2 ## $Date: 2007/12/22 06:29:32 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24