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

Diff of /messaging/manakai/lib/Message/DOM/Document.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.23 by wakaba, Mon Oct 8 07:17:18 2007 UTC revision 1.31 by wakaba, Tue Oct 21 07:51:59 2008 UTC
# Line 1  Line 1 
 ## NOTE: This module will be renamed as Document.pm.  
   
1  package Message::DOM::Document;  package Message::DOM::Document;
2  use strict;  use strict;
3  our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};  our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
# Line 39  sub AUTOLOAD { Line 37  sub AUTOLOAD {
37    
38    if ({    if ({
39      ## Read-only attributes (trivial accessors)      ## Read-only attributes (trivial accessors)
40        default_view => 1,
41      implementation => 1,      implementation => 1,
42    }->{$method_name}) {    }->{$method_name}) {
43      no strict 'refs';      no strict 'refs';
# Line 50  sub AUTOLOAD { Line 49  sub AUTOLOAD {
49      goto &{ $AUTOLOAD };      goto &{ $AUTOLOAD };
50    } elsif ({    } elsif ({
51      ## Read-write attributes (DOMString, trivial accessors)      ## Read-write attributes (DOMString, trivial accessors)
52        manakai_charset => 1,
53      document_uri => 1,      document_uri => 1,
54      input_encoding => 1,      input_encoding => 1,
55    }->{$method_name}) {    }->{$method_name}) {
# Line 77  sub AUTOLOAD { Line 77  sub AUTOLOAD {
77    } elsif ({    } elsif ({
78      ## Read-write attributes (boolean, trivial accessors)      ## Read-write attributes (boolean, trivial accessors)
79      all_declarations_processed => 1,      all_declarations_processed => 1,
80        manakai_has_bom => 1,
81    }->{$method_name}) {    }->{$method_name}) {
82      no strict 'refs';      no strict 'refs';
83      eval qq{      eval qq{
# Line 121  sub AUTOLOAD { Line 122  sub AUTOLOAD {
122      create_tree_walker => 'Message::DOM::TreeWalker',      create_tree_walker => 'Message::DOM::TreeWalker',
123      query_selector => 'Message::DOM::SelectorsAPI',      query_selector => 'Message::DOM::SelectorsAPI',
124      query_selector_all => 'Message::DOM::SelectorsAPI',      query_selector_all => 'Message::DOM::SelectorsAPI',
125        ___query_selector_all => 'Message::DOM::SelectorsAPI',
126    }->{$method_name}) {    }->{$method_name}) {
127      eval qq{ require $module_name } or die $@;      eval qq{ require $module_name } or die $@;
128      goto &{ $AUTOLOAD };      goto &{ $AUTOLOAD };
# Line 214  sub adopt_node ($$) { Line 216  sub adopt_node ($$) {
216          -object => $self,          -object => $self,
217          -type => 'NOT_SUPPORTED_ERR',          -type => 'NOT_SUPPORTED_ERR',
218          -subtype => 'ADOPT_NODE_TYPE_NOT_SUPPORTED_ERR';          -subtype => 'ADOPT_NODE_TYPE_NOT_SUPPORTED_ERR';
     ## ISSUE: Define ELEMENT_TYPE_DEFINITION_NODE and ATTRIBUTE_DEFINITION_NODE  
219    }    }
220    
221    my @change_od;    my @change_od;
# Line 814  sub replace_child ($$) { Line 815  sub replace_child ($$) {
815  ## NOTE: A manakai extension.  ## NOTE: A manakai extension.
816  sub all_declarations_processed ($;$);  sub all_declarations_processed ($;$);
817    
818    ## TODO: documentation
819    sub manakai_charset ($;$);
820    
821  sub doctype ($) {  sub doctype ($) {
822    my $self = $_[0];    my $self = $_[0];
823    for (@{$self->child_nodes}) {    for (@{$self->child_nodes}) {
# Line 866  sub manakai_entity_base_uri ($;$) { Line 870  sub manakai_entity_base_uri ($;$) {
870    }    }
871  } # manakai_entity_base_uri  } # manakai_entity_base_uri
872    
873    ## TODO: documentation
874    sub manakai_has_bom ($;$);
875    
876  sub input_encoding ($;$);  sub input_encoding ($;$);
877    
878  sub strict_error_checking ($;$) {  sub strict_error_checking ($;$) {
# Line 1076  sub manakai_create_serial_walker ($$;$$$ Line 1083  sub manakai_create_serial_walker ($$;$$$
1083    
1084  sub create_tree_walker ($$;$$$);  sub create_tree_walker ($$;$$$);
1085    
1086    ## |DocumentView| attribute
1087    
1088    sub default_view ($);
1089    
1090  ## |HTMLDocument| attributes  ## |HTMLDocument| attributes
1091    
1092  sub compat_mode ($) {  sub compat_mode ($) {
# Line 1100  sub manakai_compat_mode ($;$) { Line 1111  sub manakai_compat_mode ($;$) {
1111    }    }
1112  } # manakai_compat_mode  } # manakai_compat_mode
1113    
1114    ## TODO: documentation
1115    sub manakai_head ($) {
1116      local $Error::Depth = $Error::Depth + 1;
1117      my $html = $_[0]->manakai_html;
1118      return undef unless defined $html;
1119      for my $el (@{$html->child_nodes}) {
1120        next unless $el->node_type == 1; # ELEMENT_NODE
1121        my $nsuri = $el->namespace_uri;
1122        next unless defined $nsuri;
1123        next unless $nsuri eq q<http://www.w3.org/1999/xhtml>;
1124        next unless $el->manakai_local_name eq 'head';
1125        return $el;
1126      }
1127      return undef;
1128    } # manakai_head
1129    
1130    ## TODO: documentation
1131    sub manakai_html ($) {
1132      local $Error::Depth = $Error::Depth + 1;
1133      my $de = $_[0]->document_element;
1134      my $nsuri = $de->namespace_uri;
1135      if (defined $nsuri and $nsuri eq q<http://www.w3.org/1999/xhtml> and
1136          $de->manakai_local_name eq 'html') {
1137        return $de;
1138      } else {
1139        return undef;
1140      }
1141    } # manakai_html
1142    
1143  sub inner_html ($;$) {  sub inner_html ($;$) {
1144    my $self = $_[0];    my $self = $_[0];
1145    local $Error::Depth = $Error::Depth + 1;    local $Error::Depth = $Error::Depth + 1;
# Line 1126  sub inner_html ($;$) { Line 1166  sub inner_html ($;$) {
1166        return unless defined wantarray;        return unless defined wantarray;
1167      }      }
1168    
1169      return ${ Whatpm::HTML->get_inner_html ($self) };      require Whatpm::HTML::Serializer;
1170        return ${ Whatpm::HTML::Serializer->get_inner_html ($self) };
1171    } else {    } else {
1172      if (@_ > 1) {      if (@_ > 1) {
1173        ## Step 1        ## Step 1
1174        require Whatpm::XMLParser; # MUST        require Whatpm::XML::Parser; # MUST
1175        my $doc = $self->implementation->create_document;        my $doc = $self->implementation->create_document;
1176                
1177        ## Step 2        ## Step 2
1178        #        #
1179    
1180        ## Step 3        ## Step 3
1181        $doc = Whatpm::XMLParser->parse_string ($_[1] => $doc); # MUST        $doc = Whatpm::XML::Parser->parse_char_string ($_[1] => $doc); # MUST
1182    
1183        ## Step 4        ## Step 4
1184        #        #
# Line 1150  sub inner_html ($;$) { Line 1191  sub inner_html ($;$) {
1191        for (@cn) {        for (@cn) {
1192          $self->remove_child ($_);          $self->remove_child ($_);
1193        }        }
1194          ## TODO: strict-document-children option?
1195    
1196        ## Step 7, 8, 9, 10        ## Step 7, 8, 9, 10
1197        for my $node (@{$doc->child_nodes}) {        for my $node (@{$doc->child_nodes}) {
# Line 1162  sub inner_html ($;$) { Line 1204  sub inner_html ($;$) {
1204      ## TODO: This serializer is currently not conformant to HTML5 spec.      ## TODO: This serializer is currently not conformant to HTML5 spec.
1205      require Whatpm::XMLSerializer;      require Whatpm::XMLSerializer;
1206      my $r = '';      my $r = '';
1207      for (@{$self->child_nodes}) {      for my $node (@{$self->child_nodes}) {
1208        $r .= ${ Whatpm::XMLSerializer->get_outer_xml ($_, sub {        $r .= ${ Whatpm::XMLSerializer->get_outer_xml ($node, sub {
1209          ## TODO: INVALID_STATE_ERR          ## TODO: INVALID_STATE_ERR
1210        }) };        }) };
1211      }      }

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.31

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24