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

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

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

revision 1.210 by wakaba, Sun Aug 30 03:51:05 2009 UTC revision 1.211 by wakaba, Sun Aug 30 07:20:42 2009 UTC
# Line 3763  $Element->{$HTML_NS}->{meter} = { ## TOD Line 3763  $Element->{$HTML_NS}->{meter} = { ## TOD
3763      min => FEATURE_HTML5_DEFAULT,      min => FEATURE_HTML5_DEFAULT,
3764      optimum => FEATURE_HTML5_DEFAULT,      optimum => FEATURE_HTML5_DEFAULT,
3765      value => FEATURE_HTML5_DEFAULT,      value => FEATURE_HTML5_DEFAULT,
3766    }),    }), # check_attrs
3767  };    check_end => sub {
3768        my ($self, $item, $element_state) = @_;
3769    
3770  $Element->{$HTML_NS}->{progress} = { ## TODO: recommended to use content      ## XXX Work in progress
3771    
3772        my $tc = $item->{node}->text_content;
3773        my $n1;
3774        my $denominator;
3775        my $n2;
3776        if ($tc =~ s/^([0-9.]+)//) {
3777          $n1 = $1;
3778    
3779          if ($tc =~ s/^[^0-9.]+([0-9.]+)//) {
3780            $n2 = $1;
3781          } elsif ($tc =~ s/^([\x{0025}\x{066A}\x{FE6A}\x{FF05}\x{2030}\x{2031}])//) {
3782            $denominator = $1;
3783          }
3784        }
3785    
3786        if ($tc =~ /[0-9.]/) {
3787          undef $n1;
3788          undef $n2;
3789        }
3790    
3791        $HTMLPhrasingContentChecker{check_end}->(@_);
3792      }, # check_end
3793    }; # meter
3794    
3795    $Element->{$HTML_NS}->{progress} = {
3796    %HTMLPhrasingContentChecker,    %HTMLPhrasingContentChecker,
3797    status => FEATURE_HTML5_WD,    status => FEATURE_HTML5_WD,
3798    check_attrs => $GetHTMLAttrsChecker->({    check_attrs => $GetHTMLAttrsChecker->({
3799      value => $GetHTMLFloatingPointNumberAttrChecker->(sub { shift >= 0 }),      value => sub { }, ## checked in |check_attrs2|
3800      max => $PositiveFloatingPointNumberAttrChecker,      max => sub { }, ## checked in |check_attrs2|
3801    }, {    }, {
3802      %HTMLAttrStatus,      %HTMLAttrStatus,
3803      max => FEATURE_HTML5_DEFAULT,      max => FEATURE_HTML5_DEFAULT,
3804      value => FEATURE_HTML5_DEFAULT,      value => FEATURE_HTML5_DEFAULT,
3805    }),    }), # check_attrs
3806  };    check_attrs2 => sub {
3807        my ($self, $item, $element_state) = @_;
3808    
3809        my $max = 1;
3810        my $max_attr = $item->{node}->get_attribute_node_ns (undef, 'max');
3811        if ($max_attr) {
3812          $GetHTMLFloatingPointNumberAttrChecker->(sub {
3813            my $num = $_[0];
3814            $max = $num;
3815            return $num > 0; ## >, not >=
3816          })->($self, $max_attr);
3817        }
3818    
3819        my $value_attr = $item->{node}->get_attribute_node_ns (undef, 'value');
3820        if ($value_attr) {
3821          $self->{onerror}->(node => $value_attr,
3822                             type => 'attribute not allowed',
3823                             text => 'value',
3824                             level => $self->{level}->{should}); # RECOMMENDED
3825    
3826          $GetHTMLFloatingPointNumberAttrChecker->(sub {
3827            my $num = $_[0];
3828    
3829            unless ($num <= $max) {
3830              $self->{onerror}->(node => $value_attr,
3831                                 type => 'progress value out of range',
3832                                 value => $max, # XXX document error type
3833                                 level => $self->{level}->{must});
3834            }
3835            
3836            return $num >= 0; ## >=, not >
3837          })->($self, $value_attr);
3838        }
3839      }, # check_attrs2
3840      # XXX warn if the value from the content is greater than |max|
3841      # attribute value.
3842      # XXX warn if the element content does not contain one or two numbers.
3843    }; # progress
3844    
3845  $Element->{$HTML_NS}->{code} = {  $Element->{$HTML_NS}->{code} = {
3846    %HTMLPhrasingContentChecker,    %HTMLPhrasingContentChecker,

Legend:
Removed from v.1.210  
changed lines
  Added in v.1.211

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24