/[pub]/test/html-webhacc/cc.cgi
Suika

Diff of /test/html-webhacc/cc.cgi

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

revision 1.35 by wakaba, Sun Feb 10 04:08:04 2008 UTC revision 1.44 by wakaba, Mon Mar 17 13:52:48 2008 UTC
# Line 86  if (defined $input->{s}) { Line 86  if (defined $input->{s}) {
86      <dd>$char_length byte@{[$char_length == 1 ? '' : 's']}</dd>      <dd>$char_length byte@{[$char_length == 1 ? '' : 's']}</dd>
87  </dl>  </dl>
88  </div>  </div>
89    
90    <script src="../cc-script.js"></script>
91  ];  ];
92    
93    $input->{id_prefix} = '';    $input->{id_prefix} = '';
# Line 132  sub add_error ($$$) { Line 134  sub add_error ($$$) {
134      } elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') {      } elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') {
135        $result->{$layer}->{unsupported}++;        $result->{$layer}->{unsupported}++;
136        $result->{unsupported} = 1;        $result->{unsupported} = 1;
137        } elsif ($err->{level} eq 'i') {
138          #
139      } else {      } else {
140        $result->{$layer}->{must}++;        $result->{$layer}->{must}++;
141        $result->{$layer}->{score_max} -= 2;        $result->{$layer}->{score_max} -= 2;
# Line 213  sub check_and_print ($$) { Line 217  sub check_and_print ($$) {
217    } elsif (defined $cssom) {    } elsif (defined $cssom) {
218      print_structure_dump_cssom_section ($input, $cssom);      print_structure_dump_cssom_section ($input, $cssom);
219      ## TODO: CSSOM validation      ## TODO: CSSOM validation
220        add_error ('structure', {level => 'u'} => $result);
221    } elsif (defined $manifest) {    } elsif (defined $manifest) {
222      print_structure_dump_manifest_section ($input, $manifest);      print_structure_dump_manifest_section ($input, $manifest);
223      print_structure_error_manifest_section ($input, $manifest, $result);      print_structure_error_manifest_section ($input, $manifest, $result);
# Line 289  sub print_syntax_error_html_section ($$) Line 294  sub print_syntax_error_html_section ($$)
294  <div id="$input->{id_prefix}parse-errors" class="section">  <div id="$input->{id_prefix}parse-errors" class="section">
295  <h2>Parse Errors</h2>  <h2>Parse Errors</h2>
296    
297  <dl>];  <dl id="$input->{id_prefix}parse-errors-list">];
298    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested};    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested};
299    
300    my $onerror = sub {    my $onerror = sub {
301      my (%opt) = @_;      my (%opt) = @_;
302      my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level});      my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level});
303      if ($opt{column} > 0) {      print STDOUT qq[<dt class="$cls">], get_error_label ($input, \%opt),
304        print STDOUT qq[<dt class="$cls"><a href="#$input->{id_prefix}line-$opt{line}">Line $opt{line}</a> column $opt{column}</dt>\n];          qq[</dt>];
     } else {  
       $opt{line} = $opt{line} - 1 || 1;  
       print STDOUT qq[<dt class="$cls"><a href="#$input->{id_prefix}line-$opt{line}">Line $opt{line}</a></dt>\n];  
     }  
305      $type =~ tr/ /-/;      $type =~ tr/ /-/;
306      $type =~ s/\|/%7C/g;      $type =~ s/\|/%7C/g;
307      $msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]];      $msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]];
# Line 347  sub print_syntax_error_xml_section ($$) Line 348  sub print_syntax_error_xml_section ($$)
348  <div id="$input->{id_prefix}parse-errors" class="section">  <div id="$input->{id_prefix}parse-errors" class="section">
349  <h2>Parse Errors</h2>  <h2>Parse Errors</h2>
350    
351  <dl>];  <dl id="$input->{id_prefix}parse-errors-list">];
352    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{prefix};    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{prefix};
353    
354    my $onerror = sub {    my $onerror = sub {
# Line 387  sub get_css_parser () { Line 388  sub get_css_parser () {
388    require Whatpm::CSS::Parser;    require Whatpm::CSS::Parser;
389    my $p = Whatpm::CSS::Parser->new;    my $p = Whatpm::CSS::Parser->new;
390    
 #  if ($parse_mode eq 'q') {  
 #    $p->{unitless_px} = 1;  
 #    $p->{hashless_color} = 1;  
 #  }  
   
391    $p->{prop}->{$_} = 1 for qw/    $p->{prop}->{$_} = 1 for qw/
392        alignment-baseline
393      background background-attachment background-color background-image      background background-attachment background-color background-image
394      background-position background-position-x background-position-y      background-position background-position-x background-position-y
395      background-repeat border border-bottom border-bottom-color      background-repeat border border-bottom border-bottom-color
# Line 404  sub get_css_parser () { Line 401  sub get_css_parser () {
401      border-style border-top border-top-color border-top-style border-top-width      border-style border-top border-top-color border-top-style border-top-width
402      border-width bottom      border-width bottom
403      caption-side clear clip color content counter-increment counter-reset      caption-side clear clip color content counter-increment counter-reset
404      cursor direction display empty-cells float font      cursor direction display dominant-baseline empty-cells float font
405      font-family font-size font-size-adjust font-stretch      font-family font-size font-size-adjust font-stretch
406      font-style font-variant font-weight height left      font-style font-variant font-weight height left
407      letter-spacing line-height      letter-spacing line-height
# Line 416  sub get_css_parser () { Line 413  sub get_css_parser () {
413      padding padding-bottom padding-left padding-right padding-top      padding padding-bottom padding-left padding-right padding-top
414      page page-break-after page-break-before page-break-inside      page page-break-after page-break-before page-break-inside
415      position quotes right size table-layout      position quotes right size table-layout
416      text-align text-decoration text-indent text-transform      text-align text-anchor text-decoration text-indent text-transform
417      top unicode-bidi vertical-align visibility white-space width widows      top unicode-bidi vertical-align visibility white-space width widows
418      word-spacing z-index      word-spacing writing-mode z-index
419    /;    /;
420    $p->{prop_value}->{display}->{$_} = 1 for qw/    $p->{prop_value}->{display}->{$_} = 1 for qw/
421      block clip inline inline-block inline-table list-item none      block clip inline inline-block inline-table list-item none
# Line 493  sub get_css_parser () { Line 490  sub get_css_parser () {
490      capitalize uppercase lowercase none      capitalize uppercase lowercase none
491    /;    /;
492    $p->{prop_value}->{'white-space'}->{$_} = 1 for qw/    $p->{prop_value}->{'white-space'}->{$_} = 1 for qw/
493      normal pre nowrap pre-line pre-wrap      normal pre nowrap pre-line pre-wrap -moz-pre-wrap
494      /;
495      $p->{prop_value}->{'writing-mode'}->{$_} = 1 for qw/
496        lr rl tb lr-tb rl-tb tb-rl
497      /;
498      $p->{prop_value}->{'text-anchor'}->{$_} = 1 for qw/
499        start middle end
500      /;
501      $p->{prop_value}->{'dominant-baseline'}->{$_} = 1 for qw/
502        auto use-script no-change reset-size ideographic alphabetic
503        hanging mathematical central middle text-after-edge text-before-edge
504      /;
505      $p->{prop_value}->{'alignment-baseline'}->{$_} = 1 for qw/
506        auto baseline before-edge text-before-edge middle central
507        after-edge text-after-edge ideographic alphabetic hanging
508        mathematical
509    /;    /;
510    $p->{prop_value}->{'text-decoration'}->{$_} = 1 for qw/    $p->{prop_value}->{'text-decoration'}->{$_} = 1 for qw/
511      none blink underline overline line-through      none blink underline overline line-through
# Line 503  sub get_css_parser () { Line 515  sub get_css_parser () {
515    /;    /;
516    $p->{prop_value}->{'table-layout'}->{auto} = 1;    $p->{prop_value}->{'table-layout'}->{auto} = 1;
517    $p->{prop_value}->{'table-layout'}->{fixed} = 1;    $p->{prop_value}->{'table-layout'}->{fixed} = 1;
518    $p->{prop_value}->{'border-collapse'}->{collapase} = 1;    $p->{prop_value}->{'border-collapse'}->{collapse} = 1;
519    $p->{prop_value}->{'border-collapse'}->{separate} = 1;    $p->{prop_value}->{'border-collapse'}->{separate} = 1;
520    $p->{prop_value}->{'empty-cells'}->{show} = 1;    $p->{prop_value}->{'empty-cells'}->{show} = 1;
521    $p->{prop_value}->{'empty-cells'}->{hide} = 1;    $p->{prop_value}->{'empty-cells'}->{hide} = 1;
# Line 547  sub print_syntax_error_css_section ($$) Line 559  sub print_syntax_error_css_section ($$)
559  <div id="$input->{id_prefix}parse-errors" class="section">  <div id="$input->{id_prefix}parse-errors" class="section">
560  <h2>Parse Errors</h2>  <h2>Parse Errors</h2>
561    
562  <dl>];  <dl id="$input->{id_prefix}parse-errors-list">];
563    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested};    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested};
564    
565    my $p = get_css_parser ();    my $p = get_css_parser ();
566      $p->init;
567    $p->{onerror} = sub {    $p->{onerror} = sub {
568      my (%opt) = @_;      my (%opt) = @_;
569      my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level});      my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level});
# Line 575  sub print_syntax_error_css_section ($$) Line 588  sub print_syntax_error_css_section ($$)
588    $p->{href} = $input->{uri};    $p->{href} = $input->{uri};
589    $p->{base_uri} = $input->{base_uri};    $p->{base_uri} = $input->{base_uri};
590    
591    #  if ($parse_mode eq 'q') {
592    #    $p->{unitless_px} = 1;
593    #    $p->{hashless_color} = 1;
594    #  }
595    
596    ## TODO: Make $input->{s} a ref.
597    
598    my $s = \$input->{s};    my $s = \$input->{s};
599    my $charset;    my $charset;
600    unless ($input->{is_char_string}) {    unless ($input->{is_char_string}) {
# Line 605  sub print_syntax_error_manifest_section Line 625  sub print_syntax_error_manifest_section
625  <div id="$input->{id_prefix}parse-errors" class="section">  <div id="$input->{id_prefix}parse-errors" class="section">
626  <h2>Parse Errors</h2>  <h2>Parse Errors</h2>
627    
628  <dl>];  <dl id="$input->{id_prefix}parse-errors-list">];
629    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested};    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested};
630    
631    my $onerror = sub {    my $onerror = sub {
# Line 651  sub print_source_string_section ($$$) { Line 671  sub print_source_string_section ($$$) {
671  <h2>Document Source</h2>  <h2>Document Source</h2>
672  <ol lang="">\n];  <ol lang="">\n];
673    if (length $$s) {    if (length $$s) {
674      while ($$s =~ /\G([^\x0A]*?)\x0D?\x0A/gc) {      while ($$s =~ /\G([^\x0D\x0A]*?)(?>\x0D\x0A?|\x0A)/gc) {
675        print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1,        print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1,
676            "</li>\n";            "</li>\n";
677        $i++;        $i++;
678      }      }
679      if ($$s =~ /\G([^\x0A]+)/gc) {      if ($$s =~ /\G([^\x0D\x0A]+)/gc) {
680        print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1,        print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1,
681            "</li>\n";            "</li>\n";
682      }      }
683    } else {    } else {
684      print STDOUT q[<li id="$input->{id_prefix}line-1"></li>];      print STDOUT q[<li id="$input->{id_prefix}line-1"></li>];
685    }    }
686    print STDOUT "</ol></div>";    print STDOUT "</ol></div>
687    <script>
688      addSourceToParseErrorList ('$input->{id_prefix}', 'parse-errors-list');
689    </script>";
690  } # print_input_string_section  } # print_input_string_section
691    
692  sub print_document_tree ($$) {  sub print_document_tree ($$) {
# Line 801  sub print_structure_dump_manifest_sectio Line 824  sub print_structure_dump_manifest_sectio
824        unless $input->{nested};        unless $input->{nested};
825    
826    print STDOUT qq[<dl><dt>Explicit entries</dt>];    print STDOUT qq[<dl><dt>Explicit entries</dt>];
827      my $i = 0;
828    for my $uri (@{$manifest->[0]}) {    for my $uri (@{$manifest->[0]}) {
829      my $euri = htescape ($uri);      my $euri = htescape ($uri);
830      print STDOUT qq[<dd><code class=uri>&lt;<a href="$euri">$euri</a>></code></dd>];      print STDOUT qq[<dd id="$input->{id_prefix}index-@{[$i++]}"><code class=uri>&lt;<a href="$euri">$euri</a>></code></dd>];
831    }    }
832    
833    print STDOUT qq[<dt>Fallback entries</dt><dd>    print STDOUT qq[<dt>Fallback entries</dt><dd>
# Line 812  sub print_structure_dump_manifest_sectio Line 836  sub print_structure_dump_manifest_sectio
836    for my $uri (sort {$a cmp $b} keys %{$manifest->[1]}) {    for my $uri (sort {$a cmp $b} keys %{$manifest->[1]}) {
837      my $euri = htescape ($uri);      my $euri = htescape ($uri);
838      my $euri2 = htescape ($manifest->[1]->{$uri});      my $euri2 = htescape ($manifest->[1]->{$uri});
839      print STDOUT qq[<tr><td><code class=uri>&lt;<a href="$euri">$euri</a>></code></td>      print STDOUT qq[<tr><td id="$input->{id_prefix}index-@{[$i++]}"><code class=uri>&lt;<a href="$euri">$euri</a>></code></td>
840          <td><code class=uri>&lt;<a href="$euri2">$euri2</a>></code></td>];          <td id="$input->{id_prefix}index-@{[$i++]}"><code class=uri>&lt;<a href="$euri2">$euri2</a>></code></td>];
841    }    }
842    
843    print STDOUT qq[</table><dt>Online whitelist</dt>];    print STDOUT qq[</table><dt>Online whitelist</dt>];
844    for my $uri (@{$manifest->[2]}) {    for my $uri (@{$manifest->[2]}) {
845      my $euri = htescape ($uri);      my $euri = htescape ($uri);
846      print STDOUT qq[<dd><code class=uri>&lt;<a href="$euri">$euri</a>></code></dd>];      print STDOUT qq[<dd id="$input->{id_prefix}index-@{[$i++]}"><code class=uri>&lt;<a href="$euri">$euri</a>></code></dd>];
847    }    }
848    
849    print STDOUT qq[</dl></div>];    print STDOUT qq[</dl></div>];
# Line 831  sub print_structure_error_dom_section ($ Line 855  sub print_structure_error_dom_section ($
855    print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section">    print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section">
856  <h2>Document Errors</h2>  <h2>Document Errors</h2>
857    
858  <dl>];  <dl id=document-errors-list>];
859    push @nav, [qq[#$input->{id_prefix}document-errors] => 'Document Error']    push @nav, [qq[#$input->{id_prefix}document-errors] => 'Document Error']
860        unless $input->{nested};        unless $input->{nested};
861    
# Line 859  sub print_structure_error_dom_section ($ Line 883  sub print_structure_error_dom_section ($
883    }    }
884    $time{check} = time - $time1;    $time{check} = time - $time1;
885    
886    print STDOUT qq[</dl></div>];    print STDOUT qq[</dl>
887    <script>
888      addSourceToParseErrorList ('$input->{id_prefix}', 'document-errors-list');
889    </script></div>];
890    
891    return $elements;    return $elements;
892  } # print_structure_error_dom_section  } # print_structure_error_dom_section
# Line 1099  sub get_error_label ($$) { Line 1126  sub get_error_label ($$) {
1126    
1127    my $r = '';    my $r = '';
1128    
1129    if (defined $err->{line}) {    my $line;
1130      if ($err->{column} > 0) {    my $column;
1131        $r = qq[<a href="#$input->{id_prefix}line-$err->{line}">Line $err->{line}</a> column $err->{column}];      
1132      if (defined $err->{node}) {
1133        $line = $err->{node}->get_user_data ('manakai_source_line');
1134        if (defined $line) {
1135          $column = $err->{node}->get_user_data ('manakai_source_column');
1136        } else {
1137          if ($err->{node}->node_type == $err->{node}->ATTRIBUTE_NODE) {
1138            my $owner = $err->{node}->owner_element;
1139            $line = $owner->get_user_data ('manakai_source_line');
1140            $column = $owner->get_user_data ('manakai_source_column');
1141          } else {
1142            my $parent = $err->{node}->parent_node;
1143            if ($parent) {
1144              $line = $parent->get_user_data ('manakai_source_line');
1145              $column = $parent->get_user_data ('manakai_source_column');
1146            }
1147          }
1148        }
1149      }
1150      unless (defined $line) {
1151        if (defined $err->{token} and defined $err->{token}->{line}) {
1152          $line = $err->{token}->{line};
1153          $column = $err->{token}->{column};
1154        } elsif (defined $err->{line}) {
1155          $line = $err->{line};
1156          $column = $err->{column};
1157        }
1158      }
1159    
1160      if (defined $line) {
1161        if (defined $column and $column > 0) {
1162          $r = qq[<a href="#$input->{id_prefix}line-$line">Line $line</a> column $column];
1163      } else {      } else {
1164        $err->{line} = $err->{line} - 1 || 1;        $line = $line - 1 || 1;
1165        $r = qq[<a href="#$input->{id_prefix}line-$err->{line}">Line $err->{line}</a>];        $r = qq[<a href="#$input->{id_prefix}line-$line">Line $line</a>];
1166      }      }
1167    }    }
1168    
1169    if (defined $err->{node}) {    if (defined $err->{node}) {
1170      $r .= ' ' if length $r;      $r .= ' ' if length $r;
1171      $r = get_node_link ($input, $err->{node});      $r .= get_node_link ($input, $err->{node});
1172    }    }
1173    
1174    if (defined $err->{index}) {    if (defined $err->{index}) {
1175      $r .= ' ' if length $r;      if (length $r) {
1176      $r .= 'Index ' . (0+$err->{index});        $r .= ', Index ' . (0+$err->{index});
1177        } else {
1178          $r .= "<a href='#$input->{id_prefix}index-@{[0+$err->{index}]}'>Index "
1179              . (0+$err->{index}) . '</a>';
1180        }
1181    }    }
1182    
1183    if (defined $err->{value}) {    if (defined $err->{value}) {
# Line 1143  sub get_error_level_label ($) { Line 1205  sub get_error_level_label ($) {
1205    } elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') {    } elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') {
1206      $r = qq[<strong><a href="../error-description#level-u">Not      $r = qq[<strong><a href="../error-description#level-u">Not
1207          supported</a></strong>: ];          supported</a></strong>: ];
1208      } elsif ($err->{level} eq 'i') {
1209        $r = qq[<strong><a href="../error-description#level-i">Information</a></strong>: ];
1210    } else {    } else {
1211      my $elevel = htescape ($err->{level});      my $elevel = htescape ($err->{level});
1212      $r = qq[<strong><a href="../error-description#level-$elevel">$elevel</a></strong>:      $r = qq[<strong><a href="../error-description#level-$elevel">$elevel</a></strong>:

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.44

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24