Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"0" should not be an error in "rules for parsing dimension values" #201

Closed
zcorpan opened this issue Sep 28, 2015 · 7 comments
Closed

"0" should not be an error in "rules for parsing dimension values" #201

zcorpan opened this issue Sep 28, 2015 · 7 comments

Comments

@zcorpan
Copy link
Member

zcorpan commented Sep 28, 2015

https://html.spec.whatwg.org/multipage/rendering.html#dimRendering

The width and height attributes on applet, embed, iframe, img, object or video elements, and input elements with a type attribute in the Image Button state and that either represents an image or that the user expects will eventually represent an image, map to the dimension properties 'width' and 'height' on the element respectively.

https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-dimension-values

(6) Collect a sequence of characters that are U+0030 DIGIT ZERO (0) characters, and discard them.
(7) If position is past the end of input, return an error.

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3638
is different from
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3639
(at least in webkit/blink/gecko, haven't checked IE/Edge)

so this algorithm should be able to return 0 instead of error. But we need to check other uses and check if they want to apply 0 or not.

@zcorpan
Copy link
Member Author

zcorpan commented Sep 30, 2015

@zcorpan
Copy link
Member Author

zcorpan commented Sep 30, 2015

I'm tempted to make everything here support 0.

@dbaron do you happen to know if something here is known to break the Web if 0 is supported (e.g. <td width=0>)?

@dbaron
Copy link
Member

dbaron commented Sep 30, 2015

I think when I was rewriting table width calculation in Gecko, I discovered pretty quickly that width=0 needed to be ignored. So I suspect the Web does rely on that, although I'm not sure.

@dbaron
Copy link
Member

dbaron commented Sep 30, 2015

Then again, I'm clearly misremembering, since I didn't rewrite that part. I probably discovered it quickly while writing my own testcases.

@dbaron
Copy link
Member

dbaron commented Sep 30, 2015

(Though it might be that some browsers ignore the CSS 'width: 0px' on table cells, and some don't, leaving the quirkiness only in the HTML attribute parsing. So it might be Web-compatible in some browsers but not others.)

@zcorpan
Copy link
Member Author

zcorpan commented Oct 1, 2015

http://webdevdata.org/ data set 2015-01-08 (780 Mb) 87,000 pages.

$ find . -type f -print0 | xargs -0 -P 4 -n 40 grep -iEo "<(td|th|col|table|tr)\s([^>]+\s)?(width|height)=[\"']?0%?[\"']?(\s|>)" > ../width-height-0.txt

I inspected the matches in Nightly and applied width:0 or height:0 as appropriate in devtools to see if the rendered result was affected. 20 first URLs were unaffected (some had changed), then I found one that regressed its rendering:

http://magiran.com/

current rendering:
screen shot 2015-10-01 at 13 12 50

style="width:0"
screen shot 2015-10-01 at 13 13 12

So I suppose we should keep ignoring 0 and 0% for the table-related elements...

zcorpan added a commit that referenced this issue Oct 6, 2015
Browsers are case-insensitive for the attribute value of
`type` attribute selectors for all HTML elements, but they
should be case-sensitive for `ol` and `li` in the UA stylesheet.

Fixes #201.
@zcorpan
Copy link
Member Author

zcorpan commented Oct 6, 2015

(The above PR referenced this issue by mistake; now fixed.)

zcorpan added a commit that referenced this issue Oct 6, 2015
Browsers support `width="0"` for `img` and related elements
but in general not for table-related elements (e.g. `td`).

Fixes #201.
zcorpan added a commit that referenced this issue Oct 9, 2015
Browsers support `width="0"` for `img` and related elements
but in general not for table-related elements (e.g. `td`).

Fixes #201.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants