Auto merge of #9054 - frewsxcv:parse-non-zero-dimension, r=eefriedman

Implement non-zero dimension attribute parsing

Fixes #8445

The only attributes I found that we have implemented that uses non-zero
dimenion attributes:

* `width` for `<td>` and `<th>` (table cells)
* `width` for `<table>`

I updated these implementations to use the new non-zero dimension
attribute parsing and added associated regression tests.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9054)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-12-30 05:26:56 +05:30
commit 0d52170f35
13 changed files with 227 additions and 291 deletions

View file

@ -4589,6 +4589,16 @@
],
"url": "/html/rendering/non-replaced-elements/tables/table-border-2.html"
},
{
"path": "html/rendering/non-replaced-elements/tables/table-cell-width.html",
"references": [
[
"/html/rendering/non-replaced-elements/tables/table-cell-width-ref.html",
"=="
]
],
"url": "/html/rendering/non-replaced-elements/tables/table-cell-width.html"
},
{
"path": "html/rendering/non-replaced-elements/tables/table-layout.html",
"references": [
@ -4609,6 +4619,16 @@
],
"url": "/html/rendering/non-replaced-elements/tables/table-width-150percent.html"
},
{
"path": "html/rendering/non-replaced-elements/tables/table-width.html",
"references": [
[
"/html/rendering/non-replaced-elements/tables/table-width-ref.html",
"=="
]
],
"url": "/html/rendering/non-replaced-elements/tables/table-width.html"
},
{
"path": "html/rendering/non-replaced-elements/the-fieldset-element-0/min-width-not-important.html",
"references": [
@ -32277,6 +32297,18 @@
"url": "/html/rendering/non-replaced-elements/tables/table-border-2.html"
}
],
"html/rendering/non-replaced-elements/tables/table-cell-width.html": [
{
"path": "html/rendering/non-replaced-elements/tables/table-cell-width.html",
"references": [
[
"/html/rendering/non-replaced-elements/tables/table-cell-width-ref.html",
"=="
]
],
"url": "/html/rendering/non-replaced-elements/tables/table-cell-width.html"
}
],
"html/rendering/non-replaced-elements/tables/table-layout.html": [
{
"path": "html/rendering/non-replaced-elements/tables/table-layout.html",
@ -32301,6 +32333,18 @@
"url": "/html/rendering/non-replaced-elements/tables/table-width-150percent.html"
}
],
"html/rendering/non-replaced-elements/tables/table-width.html": [
{
"path": "html/rendering/non-replaced-elements/tables/table-width.html",
"references": [
[
"/html/rendering/non-replaced-elements/tables/table-width-ref.html",
"=="
]
],
"url": "/html/rendering/non-replaced-elements/tables/table-width.html"
}
],
"html/rendering/non-replaced-elements/the-fieldset-element-0/min-width-not-important.html": [
{
"path": "html/rendering/non-replaced-elements/the-fieldset-element-0/min-width-not-important.html",

View file

@ -4683,9 +4683,6 @@
[HTMLTableCellElement interface: document.createElement("td") must inherit property "height" with the proper type (6)]
expected: FAIL
[HTMLTableCellElement interface: document.createElement("td") must inherit property "width" with the proper type (7)]
expected: FAIL
[HTMLTableCellElement interface: document.createElement("td") must inherit property "ch" with the proper type (8)]
expected: FAIL
@ -4740,9 +4737,6 @@
[HTMLTableCellElement interface: document.createElement("th") must inherit property "height" with the proper type (6)]
expected: FAIL
[HTMLTableCellElement interface: document.createElement("th") must inherit property "width" with the proper type (7)]
expected: FAIL
[HTMLTableCellElement interface: document.createElement("th") must inherit property "ch" with the proper type (8)]
expected: FAIL
@ -4773,9 +4767,6 @@
[HTMLTableCellElement interface: attribute height]
expected: FAIL
[HTMLTableCellElement interface: attribute width]
expected: FAIL
[HTMLTableCellElement interface: attribute ch]
expected: FAIL

View file

@ -11721,135 +11721,6 @@
[td.height: IDL set to object "test-valueOf" followed by IDL get]
expected: FAIL
[td.width: typeof IDL attribute]
expected: FAIL
[td.width: IDL get with DOM attribute unset]
expected: FAIL
[td.width: setAttribute() to "" followed by IDL get]
expected: FAIL
[td.width: setAttribute() to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo " followed by IDL get]
expected: FAIL
[td.width: setAttribute() to undefined followed by IDL get]
expected: FAIL
[td.width: setAttribute() to 7 followed by IDL get]
expected: FAIL
[td.width: setAttribute() to 1.5 followed by IDL get]
expected: FAIL
[td.width: setAttribute() to true followed by IDL get]
expected: FAIL
[td.width: setAttribute() to false followed by IDL get]
expected: FAIL
[td.width: setAttribute() to object "[object Object\]" followed by IDL get]
expected: FAIL
[td.width: setAttribute() to NaN followed by IDL get]
expected: FAIL
[td.width: setAttribute() to Infinity followed by IDL get]
expected: FAIL
[td.width: setAttribute() to -Infinity followed by IDL get]
expected: FAIL
[td.width: setAttribute() to "\\0" followed by IDL get]
expected: FAIL
[td.width: setAttribute() to null followed by IDL get]
expected: FAIL
[td.width: setAttribute() to object "test-toString" followed by IDL get]
expected: FAIL
[td.width: setAttribute() to object "test-valueOf" followed by IDL get]
expected: FAIL
[td.width: IDL set to "" followed by getAttribute()]
expected: FAIL
[td.width: IDL set to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo " followed by getAttribute()]
expected: FAIL
[td.width: IDL set to undefined followed by getAttribute()]
expected: FAIL
[td.width: IDL set to undefined followed by IDL get]
expected: FAIL
[td.width: IDL set to 7 followed by getAttribute()]
expected: FAIL
[td.width: IDL set to 7 followed by IDL get]
expected: FAIL
[td.width: IDL set to 1.5 followed by getAttribute()]
expected: FAIL
[td.width: IDL set to 1.5 followed by IDL get]
expected: FAIL
[td.width: IDL set to true followed by getAttribute()]
expected: FAIL
[td.width: IDL set to true followed by IDL get]
expected: FAIL
[td.width: IDL set to false followed by getAttribute()]
expected: FAIL
[td.width: IDL set to false followed by IDL get]
expected: FAIL
[td.width: IDL set to object "[object Object\]" followed by getAttribute()]
expected: FAIL
[td.width: IDL set to object "[object Object\]" followed by IDL get]
expected: FAIL
[td.width: IDL set to NaN followed by getAttribute()]
expected: FAIL
[td.width: IDL set to NaN followed by IDL get]
expected: FAIL
[td.width: IDL set to Infinity followed by getAttribute()]
expected: FAIL
[td.width: IDL set to Infinity followed by IDL get]
expected: FAIL
[td.width: IDL set to -Infinity followed by getAttribute()]
expected: FAIL
[td.width: IDL set to -Infinity followed by IDL get]
expected: FAIL
[td.width: IDL set to "\\0" followed by getAttribute()]
expected: FAIL
[td.width: IDL set to null followed by getAttribute()]
expected: FAIL
[td.width: IDL set to null followed by IDL get]
expected: FAIL
[td.width: IDL set to object "test-toString" followed by getAttribute()]
expected: FAIL
[td.width: IDL set to object "test-toString" followed by IDL get]
expected: FAIL
[td.width: IDL set to object "test-valueOf" followed by IDL get]
expected: FAIL
[td.ch (<td char>): typeof IDL attribute]
expected: FAIL
@ -13776,135 +13647,6 @@
[th.height: IDL set to object "test-valueOf" followed by IDL get]
expected: FAIL
[th.width: typeof IDL attribute]
expected: FAIL
[th.width: IDL get with DOM attribute unset]
expected: FAIL
[th.width: setAttribute() to "" followed by IDL get]
expected: FAIL
[th.width: setAttribute() to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo " followed by IDL get]
expected: FAIL
[th.width: setAttribute() to undefined followed by IDL get]
expected: FAIL
[th.width: setAttribute() to 7 followed by IDL get]
expected: FAIL
[th.width: setAttribute() to 1.5 followed by IDL get]
expected: FAIL
[th.width: setAttribute() to true followed by IDL get]
expected: FAIL
[th.width: setAttribute() to false followed by IDL get]
expected: FAIL
[th.width: setAttribute() to object "[object Object\]" followed by IDL get]
expected: FAIL
[th.width: setAttribute() to NaN followed by IDL get]
expected: FAIL
[th.width: setAttribute() to Infinity followed by IDL get]
expected: FAIL
[th.width: setAttribute() to -Infinity followed by IDL get]
expected: FAIL
[th.width: setAttribute() to "\\0" followed by IDL get]
expected: FAIL
[th.width: setAttribute() to null followed by IDL get]
expected: FAIL
[th.width: setAttribute() to object "test-toString" followed by IDL get]
expected: FAIL
[th.width: setAttribute() to object "test-valueOf" followed by IDL get]
expected: FAIL
[th.width: IDL set to "" followed by getAttribute()]
expected: FAIL
[th.width: IDL set to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo " followed by getAttribute()]
expected: FAIL
[th.width: IDL set to undefined followed by getAttribute()]
expected: FAIL
[th.width: IDL set to undefined followed by IDL get]
expected: FAIL
[th.width: IDL set to 7 followed by getAttribute()]
expected: FAIL
[th.width: IDL set to 7 followed by IDL get]
expected: FAIL
[th.width: IDL set to 1.5 followed by getAttribute()]
expected: FAIL
[th.width: IDL set to 1.5 followed by IDL get]
expected: FAIL
[th.width: IDL set to true followed by getAttribute()]
expected: FAIL
[th.width: IDL set to true followed by IDL get]
expected: FAIL
[th.width: IDL set to false followed by getAttribute()]
expected: FAIL
[th.width: IDL set to false followed by IDL get]
expected: FAIL
[th.width: IDL set to object "[object Object\]" followed by getAttribute()]
expected: FAIL
[th.width: IDL set to object "[object Object\]" followed by IDL get]
expected: FAIL
[th.width: IDL set to NaN followed by getAttribute()]
expected: FAIL
[th.width: IDL set to NaN followed by IDL get]
expected: FAIL
[th.width: IDL set to Infinity followed by getAttribute()]
expected: FAIL
[th.width: IDL set to Infinity followed by IDL get]
expected: FAIL
[th.width: IDL set to -Infinity followed by getAttribute()]
expected: FAIL
[th.width: IDL set to -Infinity followed by IDL get]
expected: FAIL
[th.width: IDL set to "\\0" followed by getAttribute()]
expected: FAIL
[th.width: IDL set to null followed by getAttribute()]
expected: FAIL
[th.width: IDL set to null followed by IDL get]
expected: FAIL
[th.width: IDL set to object "test-toString" followed by getAttribute()]
expected: FAIL
[th.width: IDL set to object "test-toString" followed by IDL get]
expected: FAIL
[th.width: IDL set to object "test-valueOf" followed by IDL get]
expected: FAIL
[th.ch (<th char>): typeof IDL attribute]
expected: FAIL

View file

@ -0,0 +1,37 @@
<style>
body {
margin: 0;
}
.row {
clear: both;
}
.row div {
float: left;
}
.red {
background-color: red;
}
</style>
<div class="row">
<div class="red" style="width: 200px">a</div>
<div style="width: 200px">a</div>
</div>
<div class="row">
<div class="red" style="width: 200px">a</div>
<div style="width: 200px">a</div>
</div>
<div class="row">
<div class="red" style="width: 100px">a</div>
<div style="width: 300px">a</div>
</div>
<div class="row">
<div class="red" style="width: 100px">a</div>
<div style="width: 300px">a</div>
</div>

View file

@ -0,0 +1,54 @@
<link rel="match" href="table-cell-width-ref.html">
<style>
body {
margin: 0;
}
table {
width: 400px;
border-collapse: collapse;
}
th {
font-weight: normal;
text-align: left;
}
td, th {
padding: 0;
}
td:first-child, th:first-child {
background-color: red;
}
</style>
<!-- width=0 should be treated as 'auto' -->
<table>
<tr>
<th width=0>a</th>
<th>a</th>
</tr>
</table>
<table>
<tr>
<td width=0>a</td>
<td>a</td>
</tr>
</table>
<!-- test valid width attribute value-->
<table>
<tr>
<th width=100>a</th>
<th>a</th>
</tr>
</table>
<table>
<tr>
<td width=100>a</td>
<td>a</td>
</tr>
</table>

View file

@ -0,0 +1,13 @@
<style>
p {
padding: 0;
margin: 0;
}
</style>
<p>a b</p>
<hr>
<p>a</p>
<p>b</p>

View file

@ -0,0 +1,30 @@
<link rel="match" href="table-width-ref.html">
<style>
table {
border-collapse: collapse;
}
td {
padding: 0;
}
</style>
<!-- width=0 should be treated as 'auto' -->
<table width=0>
<tr>
<td>
a b
</td>
</tr>
</table>
<hr>
<table width=1>
<tr>
<td>
a b
</td>
</tr>
</table>