diff options
author | Oriol Brufau <obrufau@igalia.com> | 2024-09-12 15:34:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-12 13:34:20 +0000 |
commit | 4839cdf1764eac2b520692d2b9c3da002b509d01 (patch) | |
tree | 2bd7c2a1402a35d62106741aaa829de75bd3a34e /components/script/dom/htmltablerowelement.rs | |
parent | 37ab4b98259d45c9efd3645ebc961ca518adb5c6 (diff) | |
download | servo-4839cdf1764eac2b520692d2b9c3da002b509d01.tar.gz servo-4839cdf1764eac2b520692d2b9c3da002b509d01.zip |
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>
Diffstat (limited to 'components/script/dom/htmltablerowelement.rs')
-rw-r--r-- | components/script/dom/htmltablerowelement.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs index 4545eab9f8c..6179c1fe063 100644 --- a/components/script/dom/htmltablerowelement.rs +++ b/components/script/dom/htmltablerowelement.rs @@ -5,7 +5,7 @@ use dom_struct::dom_struct; use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; use js::rust::HandleObject; -use style::attr::AttrValue; +use style::attr::{AttrValue, LengthOrPercentageOrAuto}; use style::color::AbsoluteColor; use crate::dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; @@ -154,6 +154,7 @@ impl HTMLTableRowElementMethods for HTMLTableRowElement { pub trait HTMLTableRowElementLayoutHelpers { fn get_background_color(self) -> Option<AbsoluteColor>; + fn get_height(self) -> LengthOrPercentageOrAuto; } impl HTMLTableRowElementLayoutHelpers for LayoutDom<'_, HTMLTableRowElement> { @@ -163,6 +164,14 @@ impl HTMLTableRowElementLayoutHelpers for LayoutDom<'_, HTMLTableRowElement> { .and_then(AttrValue::as_color) .cloned() } + + fn get_height(self) -> LengthOrPercentageOrAuto { + self.upcast::<Element>() + .get_attr_for_layout(&ns!(), &local_name!("height")) + .map(AttrValue::as_dimension) + .cloned() + .unwrap_or(LengthOrPercentageOrAuto::Auto) + } } impl VirtualMethods for HTMLTableRowElement { @@ -173,6 +182,7 @@ impl VirtualMethods for HTMLTableRowElement { fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue { match *local_name { local_name!("bgcolor") => AttrValue::from_legacy_color(value.into()), + local_name!("height") => AttrValue::from_nonzero_dimension(value.into()), _ => self .super_type() .unwrap() |