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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Thu Jan 24 11:25:19 2008 UTC (16 years, 10 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +6 -3 lines
++ manakai/lib/Message/DOM/ChangeLog	24 Jan 2008 11:22:46 -0000
2008-01-24  Wakaba  <wakaba@suika.fam.cx>

	* Window.pm (manakai_get_computed_style): Renamed
	from |get_computed_style|.

	* Element.pm (manakai_computed_style): Renamed from |current_style|.

1 wakaba 1.1 package Message::DOM::Window;
2     use strict;
3     require Scalar::Util;
4     push our @ISA, 'Message::IF::AbstractView',
5     'Message::IF::Window',
6     'Message::IF::ViewCSS';
7    
8     ## NOTE: We don't support multiple views - all the views are
9     ## the default views.
10    
11     ## NOTE: The current implementation does not support non-CSS views.
12    
13     sub ___new ($$) {
14     my $self = bless \{
15     #___css
16     #___css_options => {},
17     ___user_style_sheets => [], ___ua_style_sheets => [],
18     }, shift;
19     $$self->{___implementation} = shift;
20    
21     my $doc = $$self->{document} = $$self->{___implementation}->create_document;
22     $$doc->{default_view} = $self;
23     Scalar::Util::weaken ($$doc->{default_view});
24    
25     $doc->manakai_is_html (1);
26     $doc->inner_html (q[<!DOCTYPE HTML><title></title><body>]);
27     $self->___reset_css;
28    
29     return $self;
30     } # ___new
31    
32     ## |AbstractView| attribute
33    
34     sub document ($) { ${$_[0]}->{document} }
35    
36     ## |ViewCSS| methods
37    
38 wakaba 1.3 ## TODO: implement other methods
39    
40     ## TODO: Documentation.
41     sub manakai_get_computed_style ($$;$) {
42 wakaba 1.1 my $css = ${$_[0]}->{___css};
43    
44     ## TODO: pseudo element
45     ## TODO: element not part of this document or not part of document tree
46     ## TODO: Sameness of return values of multiple invocations.
47    
48     require Message::DOM::CSSStyleDeclaration;
49     return Message::DOM::CSSComputedStyleDeclaration->____new ($css, $_[1]);
50 wakaba 1.3 } # manakai_get_computed_style
51 wakaba 1.1
52     sub ___set_css_options ($$) {
53     ${$_[0]}->{___css_options} = $_[1];
54     } # ___set_css_options
55    
56     sub ___set_ua_style_sheets ($$) {
57     ${$_[0]}->{___ua_style_sheets} = $_[1];
58     } # ___set_ua_style_sheets
59    
60     sub ___set_user_style_sheets ($$) {
61     ${$_[0]}->{___user_style_sheets} = $_[1];
62     } # ___set_user_style_sheets
63    
64     sub ___reset_css ($) {
65     my $self = shift;
66     require Whatpm::CSS::Cascade;
67 wakaba 1.2 my $cas = Whatpm::CSS::Cascade->new ($$self->{document});
68 wakaba 1.1 $cas->{has_invert}
69     = $$self->{___css_options}->{prop_value}->{'outline-color'}->{invert};
70    
71     ## TODO: ...
72     $cas->add_style_sheets ([@{$$self->{___user_style_sheets}},
73     @{$$self->{___ua_style_sheets}}]);
74    
75     $cas->___associate_rules;
76     $$self->{___css} = $cas;
77     } # ___reset_css
78    
79     ## |Window| methods
80    
81     ## NOTE: An Opera extension.
82     sub set_document ($$) {
83     ## NOTE: See <http://suika.fam.cx/gate/2005/sw/setDocument>.
84    
85     my $self = shift;
86    
87     my $new_doc = shift;
88     return if $new_doc->default_view;
89    
90     ## NOTE: When $new_doc eq $self->document, only re-rendering
91     ## should be happen.
92    
93     my $old_doc = $$self->{document};
94     if ($old_doc) {
95     delete $$old_doc->{default_view};
96     }
97    
98     $$self->{document} = $new_doc;
99     $$new_doc->{default_view} = $self;
100     Scalar::Util::weaken ($$new_doc->{default_view});
101    
102     $self->___reset_css;
103     } # set_document
104    
105     package Message::IF::AbstractView;
106     package Message::IF::ViewCSS;
107     package Message::IF::Window;
108    
109     1;
110 wakaba 1.3 ## $Date: 2008/01/14 11:33:48 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24