/[suikacvs]/markup/html/whatpm/Whatpm/ContentChecker.pm
Suika

Diff of /markup/html/whatpm/Whatpm/ContentChecker.pm

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

revision 1.8 by wakaba, Sun May 13 10:40:07 2007 UTC revision 1.9 by wakaba, Sat May 19 03:49:58 2007 UTC
# Line 1  Line 1 
1  package Whatpm::ContentChecker;  package Whatpm::ContentChecker;
2  use strict;  use strict;
3    
4    my $XML_NS = q<http://www.w3.org/XML/1998/namespace>;
5    my $XMLNS_NS = q<http://www.w3.org/2000/xmlns/>;
6    
7    my $AttrChecker = {
8      $XML_NS => {
9        ## TODO: xml:space, xml:base, xml:lang, xml:id
10      },
11      $XMLNS_NS => {
12        '' => sub {}, ## TODO: implement
13        xmlns => sub {}, ## TODO: implement
14      },
15    };
16    
17  ## ANY  ## ANY
18  my $AnyChecker = sub {  my $AnyChecker = sub {
19    my ($self, $todo) = @_;    my ($self, $todo) = @_;
# Line 33  my $ElementDefault = { Line 46  my $ElementDefault = {
46      $self->{onerror}->(node => $todo->{node}, type => 'element not supported');      $self->{onerror}->(node => $todo->{node}, type => 'element not supported');
47      return $AnyChecker->($self, $todo);      return $AnyChecker->($self, $todo);
48    },    },
49      attrs_checker => sub {
50        my ($self, $todo) = @_;
51        for my $attr (@{$todo->{node}->attributes}) {
52          my $attr_ns = $attr->namespace_uri;
53          $attr_ns = '' unless defined $attr_ns;
54          my $attr_ln = $attr->manakai_local_name;
55          my $checker = $AttrChecker->{$attr_ns}->{$attr_ln}
56            || $AttrChecker->{$attr_ns}->{''};
57          if ($checker) {
58            $checker->($self, $attr);
59          }
60          ## Don't check otherwise, since "element type not supported" warning
61          ## will be reported by the element checker.
62        }
63      },
64  };  };
65    
66  my $Element = {};  my $Element = {};
# Line 505  my $GetHTMLZeroOrMoreThenBlockOrInlineCh Line 533  my $GetHTMLZeroOrMoreThenBlockOrInlineCh
533    
534  my $HTMLTransparentChecker = $HTMLBlockOrInlineChecker;  my $HTMLTransparentChecker = $HTMLBlockOrInlineChecker;
535    
536    my $HTMLAttrChecker = {
537    
538    };
539    
540    my $HTMLAttrsChecker = sub {
541      my ($self, $todo) = @_;
542      for my $attr (@{$todo->{node}->attributes}) {
543        my $attr_ns = $attr->namespace_uri;
544        $attr_ns = '' unless defined $attr_ns;
545        my $attr_ln = $attr->manakai_local_name;
546        my $checker = $attr_ns eq '' ? $HTMLAttrChecker->{$attr_ln} : undef
547          || $AttrChecker->{$attr_ns}->{$attr_ln}
548          || $AttrChecker->{$attr_ns}->{''};
549        if ($checker) {
550          $checker->($self, $attr);
551        } else {
552          $self->{onerror}->(node => $attr, type => 'attribute not supported');
553          ## ISSUE: No comformance createria for unknown attributes in the spec
554        }
555      }
556    }; # $HTMLAttrsChecker
557    
558    $Element->{$HTML_NS}->{''} = {
559      attrs_checker => $HTMLAttrsChecker,
560      checker => $ElementDefault->{checker},
561    };
562    
563  $Element->{$HTML_NS}->{html} = {  $Element->{$HTML_NS}->{html} = {
564      attrs_checker => $HTMLAttrsChecker,
565    checker => sub {    checker => sub {
566      my ($self, $todo) = @_;      my ($self, $todo) = @_;
567      my $el = $todo->{node};      my $el = $todo->{node};
# Line 570  $Element->{$HTML_NS}->{html} = { Line 626  $Element->{$HTML_NS}->{html} = {
626  };  };
627    
628  $Element->{$HTML_NS}->{head} = {  $Element->{$HTML_NS}->{head} = {
629      attrs_checker => $HTMLAttrsChecker,
630    checker => sub {    checker => sub {
631      my ($self, $todo) = @_;      my ($self, $todo) = @_;
632      my $el = $todo->{node};      my $el = $todo->{node};
# Line 638  $Element->{$HTML_NS}->{head} = { Line 695  $Element->{$HTML_NS}->{head} = {
695  };  };
696    
697  $Element->{$HTML_NS}->{title} = {  $Element->{$HTML_NS}->{title} = {
698      attrs_checker => $HTMLAttrsChecker,
699    checker => $HTMLTextChecker,    checker => $HTMLTextChecker,
700  };  };
701    
702  $Element->{$HTML_NS}->{base} = {  $Element->{$HTML_NS}->{base} = {
703      attrs_checker => $HTMLAttrsChecker,
704    checker => $HTMLEmptyChecker,    checker => $HTMLEmptyChecker,
705  };  };
706    
707  $Element->{$HTML_NS}->{link} = {  $Element->{$HTML_NS}->{link} = {
708      attrs_checker => $HTMLAttrsChecker,
709    checker => $HTMLEmptyChecker,    checker => $HTMLEmptyChecker,
710  };  };
711    
712  $Element->{$HTML_NS}->{meta} = {  $Element->{$HTML_NS}->{meta} = {
713      attrs_checker => $HTMLAttrsChecker,
714    checker => $HTMLEmptyChecker,    checker => $HTMLEmptyChecker,
715  };  };
716    
717  ## NOTE: |html:style| has no conformance creteria on content model  ## NOTE: |html:style| has no conformance creteria on content model
718  $Element->{$HTML_NS}->{style} = {  $Element->{$HTML_NS}->{style} = {
719      attrs_checker => $HTMLAttrsChecker,
720    checker => $AnyChecker,    checker => $AnyChecker,
721  };  };
722    
723  $Element->{$HTML_NS}->{body} = {  $Element->{$HTML_NS}->{body} = {
724      attrs_checker => $HTMLAttrsChecker,
725    checker => $HTMLBlockChecker,    checker => $HTMLBlockChecker,
726  };  };
727    
728  $Element->{$HTML_NS}->{section} = {  $Element->{$HTML_NS}->{section} = {
729      attrs_checker => $HTMLAttrsChecker,
730    checker => $HTMLStylableBlockChecker,    checker => $HTMLStylableBlockChecker,
731  };  };
732    
733  $Element->{$HTML_NS}->{nav} = {  $Element->{$HTML_NS}->{nav} = {
734      attrs_checker => $HTMLAttrsChecker,
735    checker => $HTMLBlockOrInlineChecker,    checker => $HTMLBlockOrInlineChecker,
736  };  };
737    
738  $Element->{$HTML_NS}->{article} = {  $Element->{$HTML_NS}->{article} = {
739      attrs_checker => $HTMLAttrsChecker,
740    checker => $HTMLStylableBlockChecker,    checker => $HTMLStylableBlockChecker,
741  };  };
742    
743  $Element->{$HTML_NS}->{blockquote} = {  $Element->{$HTML_NS}->{blockquote} = {
744      attrs_checker => $HTMLAttrsChecker,
745    checker => $HTMLBlockChecker,    checker => $HTMLBlockChecker,
746  };  };
747    
748  $Element->{$HTML_NS}->{aside} = {  $Element->{$HTML_NS}->{aside} = {
749      attrs_checker => $HTMLAttrsChecker,
750    checker => $GetHTMLZeroOrMoreThenBlockOrInlineChecker->($HTML_NS, 'style'),    checker => $GetHTMLZeroOrMoreThenBlockOrInlineChecker->($HTML_NS, 'style'),
751  };  };
752    
753  $Element->{$HTML_NS}->{h1} = {  $Element->{$HTML_NS}->{h1} = {
754      attrs_checker => $HTMLAttrsChecker,
755    checker => $HTMLSignificantStrictlyInlineChecker,    checker => $HTMLSignificantStrictlyInlineChecker,
756  };  };
757    
758  $Element->{$HTML_NS}->{h2} = {  $Element->{$HTML_NS}->{h2} = {
759      attrs_checker => $HTMLAttrsChecker,
760    checker => $HTMLSignificantStrictlyInlineChecker,    checker => $HTMLSignificantStrictlyInlineChecker,
761  };  };
762    
763  $Element->{$HTML_NS}->{h3} = {  $Element->{$HTML_NS}->{h3} = {
764      attrs_checker => $HTMLAttrsChecker,
765    checker => $HTMLSignificantStrictlyInlineChecker,    checker => $HTMLSignificantStrictlyInlineChecker,
766  };  };
767    
768  $Element->{$HTML_NS}->{h4} = {  $Element->{$HTML_NS}->{h4} = {
769      attrs_checker => $HTMLAttrsChecker,
770    checker => $HTMLSignificantStrictlyInlineChecker,    checker => $HTMLSignificantStrictlyInlineChecker,
771  };  };
772    
773  $Element->{$HTML_NS}->{h5} = {  $Element->{$HTML_NS}->{h5} = {
774      attrs_checker => $HTMLAttrsChecker,
775    checker => $HTMLSignificantStrictlyInlineChecker,    checker => $HTMLSignificantStrictlyInlineChecker,
776  };  };
777    
778  $Element->{$HTML_NS}->{h6} = {  $Element->{$HTML_NS}->{h6} = {
779      attrs_checker => $HTMLAttrsChecker,
780    checker => $HTMLSignificantStrictlyInlineChecker,    checker => $HTMLSignificantStrictlyInlineChecker,
781  };  };
782    
783  ## TODO: header  ## TODO: header
784    
785  $Element->{$HTML_NS}->{footer} = {  $Element->{$HTML_NS}->{footer} = {
786      attrs_checker => $HTMLAttrsChecker,
787    checker => sub { ## block -hn -header -footer -sectioning or inline    checker => sub { ## block -hn -header -footer -sectioning or inline
788      my ($self, $todo) = @_;      my ($self, $todo) = @_;
789      my $el = $todo->{node};      my $el = $todo->{node};
# Line 797  $Element->{$HTML_NS}->{footer} = { Line 872  $Element->{$HTML_NS}->{footer} = {
872  };  };
873    
874  $Element->{$HTML_NS}->{address} = {  $Element->{$HTML_NS}->{address} = {
875      attrs_checker => $HTMLAttrsChecker,
876    checker => $HTMLInlineChecker,    checker => $HTMLInlineChecker,
877  };  };
878    
879  $Element->{$HTML_NS}->{p} = {  $Element->{$HTML_NS}->{p} = {
880      attrs_checker => $HTMLAttrsChecker,
881    checker => $HTMLSignificantInlineChecker,    checker => $HTMLSignificantInlineChecker,
882  };  };
883    
884  $Element->{$HTML_NS}->{hr} = {  $Element->{$HTML_NS}->{hr} = {
885      attrs_checker => $HTMLAttrsChecker,
886    checker => $HTMLEmptyChecker,    checker => $HTMLEmptyChecker,
887  };  };
888    
889  $Element->{$HTML_NS}->{br} = {  $Element->{$HTML_NS}->{br} = {
890      attrs_checker => $HTMLAttrsChecker,
891    checker => $HTMLEmptyChecker,    checker => $HTMLEmptyChecker,
892  };  };
893    
894  $Element->{$HTML_NS}->{dialog} = {  $Element->{$HTML_NS}->{dialog} = {
895      attrs_checker => $HTMLAttrsChecker,
896    checker => sub {    checker => sub {
897      my ($self, $todo) = @_;      my ($self, $todo) = @_;
898      my $el = $todo->{node};      my $el = $todo->{node};
# Line 870  $Element->{$HTML_NS}->{dialog} = { Line 950  $Element->{$HTML_NS}->{dialog} = {
950  };  };
951    
952  $Element->{$HTML_NS}->{pre} = {  $Element->{$HTML_NS}->{pre} = {
953      attrs_checker => $HTMLAttrsChecker,
954    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
955  };  };
956    
957  $Element->{$HTML_NS}->{ol} = {  $Element->{$HTML_NS}->{ol} = {
958      attrs_checker => $HTMLAttrsChecker,
959    checker => sub {    checker => sub {
960      my ($self, $todo) = @_;      my ($self, $todo) = @_;
961      my $el = $todo->{node};      my $el = $todo->{node};
# Line 915  $Element->{$HTML_NS}->{ol} = { Line 997  $Element->{$HTML_NS}->{ol} = {
997  };  };
998    
999  $Element->{$HTML_NS}->{ul} = {  $Element->{$HTML_NS}->{ul} = {
1000      attrs_checker => $HTMLAttrsChecker,
1001    checker => $Element->{$HTML_NS}->{ol}->{checker},    checker => $Element->{$HTML_NS}->{ol}->{checker},
1002  };  };
1003    
1004    
1005  $Element->{$HTML_NS}->{li} = {  $Element->{$HTML_NS}->{li} = {
1006      attrs_checker => $HTMLAttrsChecker,
1007    checker => sub {    checker => sub {
1008      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1009      if ($todo->{inline}) {      if ($todo->{inline}) {
# Line 931  $Element->{$HTML_NS}->{li} = { Line 1015  $Element->{$HTML_NS}->{li} = {
1015  };  };
1016    
1017  $Element->{$HTML_NS}->{dl} = {  $Element->{$HTML_NS}->{dl} = {
1018      attrs_checker => $HTMLAttrsChecker,
1019    checker => sub {    checker => sub {
1020      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1021      my $el = $todo->{node};      my $el = $todo->{node};
# Line 1000  $Element->{$HTML_NS}->{dl} = { Line 1085  $Element->{$HTML_NS}->{dl} = {
1085  };  };
1086    
1087  $Element->{$HTML_NS}->{dt} = {  $Element->{$HTML_NS}->{dt} = {
1088      attrs_checker => $HTMLAttrsChecker,
1089    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
1090  };  };
1091    
1092  $Element->{$HTML_NS}->{dd} = {  $Element->{$HTML_NS}->{dd} = {
1093      attrs_checker => $HTMLAttrsChecker,
1094    checker => $Element->{$HTML_NS}->{li}->{checker},    checker => $Element->{$HTML_NS}->{li}->{checker},
1095  };  };
1096    
1097  $Element->{$HTML_NS}->{a} = {  $Element->{$HTML_NS}->{a} = {
1098      attrs_checker => $HTMLAttrsChecker,
1099    checker => sub {    checker => sub {
1100      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1101    
# Line 1020  $Element->{$HTML_NS}->{a} = { Line 1108  $Element->{$HTML_NS}->{a} = {
1108  };  };
1109    
1110  $Element->{$HTML_NS}->{q} = {  $Element->{$HTML_NS}->{q} = {
1111      attrs_checker => $HTMLAttrsChecker,
1112    checker => $HTMLInlineOrStrictlyInlineChecker,    checker => $HTMLInlineOrStrictlyInlineChecker,
1113  };  };
1114    
1115  $Element->{$HTML_NS}->{cite} = {  $Element->{$HTML_NS}->{cite} = {
1116      attrs_checker => $HTMLAttrsChecker,
1117    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
1118  };  };
1119    
1120  $Element->{$HTML_NS}->{em} = {  $Element->{$HTML_NS}->{em} = {
1121      attrs_checker => $HTMLAttrsChecker,
1122    checker => $HTMLInlineOrStrictlyInlineChecker,    checker => $HTMLInlineOrStrictlyInlineChecker,
1123  };  };
1124    
1125  $Element->{$HTML_NS}->{strong} = {  $Element->{$HTML_NS}->{strong} = {
1126      attrs_checker => $HTMLAttrsChecker,
1127    checker => $HTMLInlineOrStrictlyInlineChecker,    checker => $HTMLInlineOrStrictlyInlineChecker,
1128  };  };
1129    
1130  $Element->{$HTML_NS}->{small} = {  $Element->{$HTML_NS}->{small} = {
1131      attrs_checker => $HTMLAttrsChecker,
1132    checker => $HTMLInlineOrStrictlyInlineChecker,    checker => $HTMLInlineOrStrictlyInlineChecker,
1133  };  };
1134    
1135  $Element->{$HTML_NS}->{m} = {  $Element->{$HTML_NS}->{m} = {
1136      attrs_checker => $HTMLAttrsChecker,
1137    checker => $HTMLInlineOrStrictlyInlineChecker,    checker => $HTMLInlineOrStrictlyInlineChecker,
1138  };  };
1139    
1140  $Element->{$HTML_NS}->{dfn} = {  $Element->{$HTML_NS}->{dfn} = {
1141      attrs_checker => $HTMLAttrsChecker,
1142    checker => sub {    checker => sub {
1143      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1144    
# Line 1055  $Element->{$HTML_NS}->{dfn} = { Line 1150  $Element->{$HTML_NS}->{dfn} = {
1150  };  };
1151    
1152  $Element->{$HTML_NS}->{abbr} = {  $Element->{$HTML_NS}->{abbr} = {
1153      attrs_checker => $HTMLAttrsChecker,
1154    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
1155  };  };
1156    
1157  $Element->{$HTML_NS}->{time} = {  $Element->{$HTML_NS}->{time} = {
1158      attrs_checker => $HTMLAttrsChecker,
1159    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
1160  };  };
1161    
1162  $Element->{$HTML_NS}->{meter} = {  $Element->{$HTML_NS}->{meter} = {
1163      attrs_checker => $HTMLAttrsChecker,
1164    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
1165  };  };
1166    
1167  $Element->{$HTML_NS}->{progress} = {  $Element->{$HTML_NS}->{progress} = {
1168      attrs_checker => $HTMLAttrsChecker,
1169    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
1170  };  };
1171    
1172  $Element->{$HTML_NS}->{code} = {  $Element->{$HTML_NS}->{code} = {
1173      attrs_checker => $HTMLAttrsChecker,
1174    checker => $HTMLInlineOrStrictlyInlineChecker,    checker => $HTMLInlineOrStrictlyInlineChecker,
1175  };  };
1176    
1177  $Element->{$HTML_NS}->{var} = {  $Element->{$HTML_NS}->{var} = {
1178      attrs_checker => $HTMLAttrsChecker,
1179    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
1180  };  };
1181    
1182  $Element->{$HTML_NS}->{samp} = {  $Element->{$HTML_NS}->{samp} = {
1183      attrs_checker => $HTMLAttrsChecker,
1184    checker => $HTMLInlineOrStrictlyInlineChecker,    checker => $HTMLInlineOrStrictlyInlineChecker,
1185  };  };
1186    
1187  $Element->{$HTML_NS}->{kbd} = {  $Element->{$HTML_NS}->{kbd} = {
1188      attrs_checker => $HTMLAttrsChecker,
1189    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
1190  };  };
1191    
1192  $Element->{$HTML_NS}->{sub} = {  $Element->{$HTML_NS}->{sub} = {
1193      attrs_checker => $HTMLAttrsChecker,
1194    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
1195  };  };
1196    
1197  $Element->{$HTML_NS}->{sup} = {  $Element->{$HTML_NS}->{sup} = {
1198      attrs_checker => $HTMLAttrsChecker,
1199    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
1200  };  };
1201    
1202  $Element->{$HTML_NS}->{span} = {  $Element->{$HTML_NS}->{span} = {
1203      attrs_checker => $HTMLAttrsChecker,
1204    checker => $HTMLInlineOrStrictlyInlineChecker,    checker => $HTMLInlineOrStrictlyInlineChecker,
1205  };  };
1206    
1207  $Element->{$HTML_NS}->{i} = {  $Element->{$HTML_NS}->{i} = {
1208      attrs_checker => $HTMLAttrsChecker,
1209    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
1210  };  };
1211    
1212  $Element->{$HTML_NS}->{b} = {  $Element->{$HTML_NS}->{b} = {
1213      attrs_checker => $HTMLAttrsChecker,
1214    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
1215  };  };
1216    
1217  $Element->{$HTML_NS}->{bdo} = {  $Element->{$HTML_NS}->{bdo} = {
1218      attrs_checker => $HTMLAttrsChecker,
1219    checker => $HTMLStrictlyInlineChecker,    checker => $HTMLStrictlyInlineChecker,
1220  };  };
1221    
1222  $Element->{$HTML_NS}->{ins} = {  $Element->{$HTML_NS}->{ins} = {
1223      attrs_checker => $HTMLAttrsChecker,
1224    checker => $HTMLTransparentChecker,    checker => $HTMLTransparentChecker,
1225  };  };
1226    
1227  $Element->{$HTML_NS}->{del} = {  $Element->{$HTML_NS}->{del} = {
1228      attrs_checker => $HTMLAttrsChecker,
1229    checker => sub {    checker => sub {
1230      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1231    
# Line 1136  $Element->{$HTML_NS}->{del} = { Line 1247  $Element->{$HTML_NS}->{del} = {
1247  ## TODO: figure  ## TODO: figure
1248    
1249  $Element->{$HTML_NS}->{img} = {  $Element->{$HTML_NS}->{img} = {
1250      attrs_checker => $HTMLAttrsChecker,
1251    checker => $HTMLEmptyChecker,    checker => $HTMLEmptyChecker,
1252  };  };
1253    
1254  $Element->{$HTML_NS}->{iframe} = {  $Element->{$HTML_NS}->{iframe} = {
1255      attrs_checker => $HTMLAttrsChecker,
1256    checker => $HTMLTextChecker,    checker => $HTMLTextChecker,
1257  };  };
1258    
1259  $Element->{$HTML_NS}->{embed} = {  $Element->{$HTML_NS}->{embed} = {
1260      attrs_checker => $HTMLAttrsChecker,
1261    checker => $HTMLEmptyChecker,    checker => $HTMLEmptyChecker,
1262  };  };
1263    
1264  $Element->{$HTML_NS}->{param} = {  $Element->{$HTML_NS}->{param} = {
1265      attrs_checker => $HTMLAttrsChecker,
1266    checker => $HTMLEmptyChecker,    checker => $HTMLEmptyChecker,
1267  };  };
1268    
1269  ## TODO: object  ## TODO: object
1270    
1271  $Element->{$HTML_NS}->{video} = {  $Element->{$HTML_NS}->{video} = {
1272      attrs_checker => $HTMLAttrsChecker,
1273    checker => sub {    checker => sub {
1274      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1275    
# Line 1167  $Element->{$HTML_NS}->{video} = { Line 1283  $Element->{$HTML_NS}->{video} = {
1283  };  };
1284    
1285  $Element->{$HTML_NS}->{audio} = {  $Element->{$HTML_NS}->{audio} = {
1286      attrs_checker => $HTMLAttrsChecker,
1287    checker => $Element->{$HTML_NS}->{audio}->{checker},    checker => $Element->{$HTML_NS}->{audio}->{checker},
1288  };  };
1289    
1290  $Element->{$HTML_NS}->{source} = {  $Element->{$HTML_NS}->{source} = {
1291      attrs_checker => $HTMLAttrsChecker,
1292    checker => $HTMLEmptyChecker,    checker => $HTMLEmptyChecker,
1293  };  };
1294    
1295  $Element->{$HTML_NS}->{canvas} = {  $Element->{$HTML_NS}->{canvas} = {
1296      attrs_checker => $HTMLAttrsChecker,
1297    checker => $HTMLInlineChecker,    checker => $HTMLInlineChecker,
1298  };  };
1299    
1300  $Element->{$HTML_NS}->{map} = {  $Element->{$HTML_NS}->{map} = {
1301      attrs_checker => $HTMLAttrsChecker,
1302    checker => $HTMLBlockChecker,    checker => $HTMLBlockChecker,
1303  };  };
1304    
1305  $Element->{$HTML_NS}->{area} = {  $Element->{$HTML_NS}->{area} = {
1306      attrs_checker => $HTMLAttrsChecker,
1307    checker => $HTMLEmptyChecker,    checker => $HTMLEmptyChecker,
1308  };  };
1309  ## TODO: only in map  ## TODO: only in map
1310    
1311  $Element->{$HTML_NS}->{table} = {  $Element->{$HTML_NS}->{table} = {
1312      attrs_checker => $HTMLAttrsChecker,
1313    checker => sub {    checker => sub {
1314      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1315      my $el = $todo->{node};      my $el = $todo->{node};
# Line 1288  $Element->{$HTML_NS}->{table} = { Line 1410  $Element->{$HTML_NS}->{table} = {
1410  };  };
1411    
1412  $Element->{$HTML_NS}->{caption} = {  $Element->{$HTML_NS}->{caption} = {
1413      attrs_checker => $HTMLAttrsChecker,
1414    checker => $HTMLSignificantStrictlyInlineChecker,    checker => $HTMLSignificantStrictlyInlineChecker,
1415  };  };
1416    
1417  $Element->{$HTML_NS}->{colgroup} = {  $Element->{$HTML_NS}->{colgroup} = {
1418      attrs_checker => $HTMLAttrsChecker,
1419    checker => sub {    checker => sub {
1420      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1421      my $el = $todo->{node};      my $el = $todo->{node};
# Line 1327  $Element->{$HTML_NS}->{colgroup} = { Line 1451  $Element->{$HTML_NS}->{colgroup} = {
1451  };  };
1452    
1453  $Element->{$HTML_NS}->{col} = {  $Element->{$HTML_NS}->{col} = {
1454      attrs_checker => $HTMLAttrsChecker,
1455    checker => $HTMLEmptyChecker,    checker => $HTMLEmptyChecker,
1456  };  };
1457    
1458  $Element->{$HTML_NS}->{tbody} = {  $Element->{$HTML_NS}->{tbody} = {
1459      attrs_checker => $HTMLAttrsChecker,
1460    checker => sub {    checker => sub {
1461      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1462      my $el = $todo->{node};      my $el = $todo->{node};
# Line 1372  $Element->{$HTML_NS}->{tbody} = { Line 1498  $Element->{$HTML_NS}->{tbody} = {
1498  };  };
1499    
1500  $Element->{$HTML_NS}->{thead} = {  $Element->{$HTML_NS}->{thead} = {
1501      attrs_checker => $HTMLAttrsChecker,
1502    checker => $Element->{$HTML_NS}->{tbody},    checker => $Element->{$HTML_NS}->{tbody},
1503  };  };
1504    
1505  $Element->{$HTML_NS}->{tfoot} = {  $Element->{$HTML_NS}->{tfoot} = {
1506      attrs_checker => $HTMLAttrsChecker,
1507    checker => $Element->{$HTML_NS}->{tbody},    checker => $Element->{$HTML_NS}->{tbody},
1508  };  };
1509    
1510  $Element->{$HTML_NS}->{tr} = {  $Element->{$HTML_NS}->{tr} = {
1511      attrs_checker => $HTMLAttrsChecker,
1512    checker => sub {    checker => sub {
1513      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1514      my $el = $todo->{node};      my $el = $todo->{node};
# Line 1421  $Element->{$HTML_NS}->{tr} = { Line 1550  $Element->{$HTML_NS}->{tr} = {
1550  };  };
1551    
1552  $Element->{$HTML_NS}->{td} = {  $Element->{$HTML_NS}->{td} = {
1553      attrs_checker => $HTMLAttrsChecker,
1554    checker => $HTMLBlockOrInlineChecker,    checker => $HTMLBlockOrInlineChecker,
1555  };  };
1556    
1557  $Element->{$HTML_NS}->{th} = {  $Element->{$HTML_NS}->{th} = {
1558      attrs_checker => $HTMLAttrsChecker,
1559    checker => $HTMLBlockOrInlineChecker,    checker => $HTMLBlockOrInlineChecker,
1560  };  };
1561    
1562  ## TODO: forms  ## TODO: forms
1563    
1564  $Element->{$HTML_NS}->{script} = {  $Element->{$HTML_NS}->{script} = {
1565      attrs_checker => $HTMLAttrsChecker,
1566    checker => sub {    checker => sub {
1567      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1568    
# Line 1445  $Element->{$HTML_NS}->{script} = { Line 1577  $Element->{$HTML_NS}->{script} = {
1577    
1578  ## NOTE: When script is disabled.  ## NOTE: When script is disabled.
1579  $Element->{$HTML_NS}->{noscript} = {  $Element->{$HTML_NS}->{noscript} = {
1580      attrs_checker => $HTMLAttrsChecker,
1581    checker => sub {    checker => sub {
1582      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1583    
# Line 1456  $Element->{$HTML_NS}->{noscript} = { Line 1589  $Element->{$HTML_NS}->{noscript} = {
1589  };  };
1590    
1591  $Element->{$HTML_NS}->{'event-source'} = {  $Element->{$HTML_NS}->{'event-source'} = {
1592      attrs_checker => $HTMLAttrsChecker,
1593    checker => $HTMLEmptyChecker,    checker => $HTMLEmptyChecker,
1594  };  };
1595    
1596  $Element->{$HTML_NS}->{details} = {  $Element->{$HTML_NS}->{details} = {
1597      attrs_checker => $HTMLAttrsChecker,
1598    checker => sub {    checker => sub {
1599      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1600    
# Line 1473  $Element->{$HTML_NS}->{details} = { Line 1608  $Element->{$HTML_NS}->{details} = {
1608  };  };
1609    
1610  $Element->{$HTML_NS}->{datagrid} = {  $Element->{$HTML_NS}->{datagrid} = {
1611      attrs_checker => $HTMLAttrsChecker,
1612    checker => sub {    checker => sub {
1613      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1614    
# Line 1484  $Element->{$HTML_NS}->{datagrid} = { Line 1620  $Element->{$HTML_NS}->{datagrid} = {
1620  };  };
1621    
1622  $Element->{$HTML_NS}->{command} = {  $Element->{$HTML_NS}->{command} = {
1623      attrs_checker => $HTMLAttrsChecker,
1624    checker => $HTMLEmptyChecker,    checker => $HTMLEmptyChecker,
1625  };  };
1626    
1627  $Element->{$HTML_NS}->{menu} = {  $Element->{$HTML_NS}->{menu} = {
1628      attrs_checker => $HTMLAttrsChecker,
1629    checker => sub {    checker => sub {
1630      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1631      my $el = $todo->{node};      my $el = $todo->{node};
# Line 1545  $Element->{$HTML_NS}->{menu} = { Line 1683  $Element->{$HTML_NS}->{menu} = {
1683  };  };
1684    
1685  $Element->{$HTML_NS}->{legend} = {  $Element->{$HTML_NS}->{legend} = {
1686      attrs_checker => $HTMLAttrsChecker,
1687    checker => sub {    checker => sub {
1688      my ($self, $todo) = @_;      my ($self, $todo) = @_;
1689    
# Line 1568  $Element->{$HTML_NS}->{legend} = { Line 1707  $Element->{$HTML_NS}->{legend} = {
1707  };  };
1708    
1709  $Element->{$HTML_NS}->{div} = {  $Element->{$HTML_NS}->{div} = {
1710      attrs_checker => $HTMLAttrsChecker,
1711    checker => $GetHTMLZeroOrMoreThenBlockOrInlineChecker->($HTML_NS, 'style'),    checker => $GetHTMLZeroOrMoreThenBlockOrInlineChecker->($HTML_NS, 'style'),
1712  };  };
1713    
1714  $Element->{$HTML_NS}->{font} = {  $Element->{$HTML_NS}->{font} = {
1715      attrs_checker => $HTMLAttrsChecker,
1716    checker => $HTMLTransparentChecker,    checker => $HTMLTransparentChecker,
1717  };  };
1718    
 my $Attr = {  
   
 };  
   
1719  sub new ($) {  sub new ($) {
1720    return bless {}, shift;    return bless {}, shift;
1721  } # new  } # new
# Line 1599  sub check_element ($$$) { Line 1736  sub check_element ($$$) {
1736        my $eldef = $Element->{$nsuri}->{$ln} ||        my $eldef = $Element->{$nsuri}->{$ln} ||
1737          $Element->{$nsuri}->{''} ||          $Element->{$nsuri}->{''} ||
1738            $ElementDefault;            $ElementDefault;
1739          $eldef->{attrs_checker}->($self, $todo);
1740        my ($new_todos) = $eldef->{checker}->($self, $todo);        my ($new_todos) = $eldef->{checker}->($self, $todo);
1741        push @todo, @$new_todos;        push @todo, @$new_todos;
1742        } elsif ($todo->{type} eq 'element-attributes') {
1743          my $nsuri = $todo->{node}->namespace_uri;
1744          $nsuri = '' unless defined $nsuri;
1745          my $ln = $todo->{node}->manakai_local_name;
1746          my $eldef = $Element->{$nsuri}->{$ln} ||
1747            $Element->{$nsuri}->{''} ||
1748              $ElementDefault;
1749          $eldef->{attrs_checker}->($self, $todo);
1750      } elsif ($todo->{type} eq 'plus') {      } elsif ($todo->{type} eq 'plus') {
1751        $self->_remove_minuses ($todo);        $self->_remove_minuses ($todo);
1752      }      }
# Line 1649  sub _check_get_children ($$) { Line 1795  sub _check_get_children ($$) {
1795      }      }
1796      if ($HTMLTransparentElements->{$node_ns}->{$node_ln}) {      if ($HTMLTransparentElements->{$node_ns}->{$node_ln}) {
1797        unshift @$sib, @{$node->child_nodes};        unshift @$sib, @{$node->child_nodes};
1798          push @$new_todos, {type => 'element-attributes', node => $node};
1799        last TP;        last TP;
1800      }      }
1801      if ($node_ns eq $HTML_NS and ($node_ln eq 'video' or $node_ln eq 'audio')) {      if ($node_ns eq $HTML_NS and ($node_ln eq 'video' or $node_ln eq 'audio')) {
1802        if ($node->has_attribute_ns (undef, 'src')) {        if ($node->has_attribute_ns (undef, 'src')) {
1803          unshift @$sib, @{$node->child_nodes};          unshift @$sib, @{$node->child_nodes};
1804            push @$new_todos, {type => 'element-attributes', node => $node};
1805          last TP;          last TP;
1806        } else {        } else {
1807          my @cn = @{$node->child_nodes};          my @cn = @{$node->child_nodes};

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24