Add width and height presentational hints for table-related elements (#33405)

We were only parsing the `width` attribute as a presentation hint for
`<table>`, `<td>` and `<th>`. This patch also handles `<colgroup>` and
`<col>`.

Also, we weren't parsing `height` at all, now we do it for `<table>`,
`<td>`, `<th>`, `<tr>`, `<tbody>`, `<thead>` and `<tfoot>`.

One test is now crashing, but this was an existing issue: #33423

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Oriol Brufau 2024-09-12 15:34:20 +02:00 committed by GitHub
parent 37ab4b9825
commit 4839cdf176
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 65 additions and 228 deletions

View file

@ -850,6 +850,8 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
this.get_width()
} else if let Some(this) = self.downcast::<HTMLTableCellElement>() {
this.get_width()
} else if let Some(this) = self.downcast::<HTMLTableColElement>() {
this.get_width()
} else if let Some(this) = self.downcast::<HTMLHRElement>() {
// https://html.spec.whatwg.org/multipage/#the-hr-element-2:attr-hr-width
this.get_width()
@ -886,6 +888,14 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
this.get_height()
} else if let Some(this) = self.downcast::<HTMLImageElement>() {
this.get_height()
} else if let Some(this) = self.downcast::<HTMLTableElement>() {
this.get_height()
} else if let Some(this) = self.downcast::<HTMLTableCellElement>() {
this.get_height()
} else if let Some(this) = self.downcast::<HTMLTableRowElement>() {
this.get_height()
} else if let Some(this) = self.downcast::<HTMLTableSectionElement>() {
this.get_height()
} else {
LengthOrPercentageOrAuto::Auto
};