Re: [html-tests] HTML: Fix various bugs in new colSpan/rowSpan tests (#5707)

I got these errors in Gecko too, but when I reviewed the spec closely I found that the test is correct per the spec.  The "parse an integer" algorithm in HTML handles arbitrarily large integers.  (I think -- tell me if I'm wrong.)  I like the specced behavior because wrapping on overflow is unintuitive for users.

You can see our code for [parsing integers per HTML](https://reviewboard-hg.mozilla.org/gecko/file/3e468dc5d5e8/dom/base/nsContentUtils.cpp#l1097) and the code that calls it to [parse clamped integers](https://reviewboard-hg.mozilla.org/gecko/file/3e468dc5d5e8/dom/base/nsAttrValue.cpp#l1537).  It uses a [CheckedInt class](https://reviewboard-hg.mozilla.org/gecko/file/3e468dc5d5e8/mfbt/CheckedInt.h), but the same basic algorithm would work with regular types.  Basically, when parsing the string we check for overflow, and return a special flag with the result if it overflowed.  I adjusted it to also return a flag if it's negative, so underflow and overflow can be distinguished.  The clamped-int code special-cases the overflow cases.

This is definitely more complicated, but not terribly so, and it matches what users would expect, so I'm in favor of keeping it.

View on GitHub: https://github.com/w3c/web-platform-tests/pull/5707#issuecomment-297662286

Received on Thursday, 27 April 2017 09:26:19 UTC