mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
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:
parent
37ab4b9825
commit
4839cdf176
16 changed files with 65 additions and 228 deletions
|
@ -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 super::bindings::root::LayoutDom;
|
||||
use super::element::Element;
|
||||
|
@ -66,6 +66,7 @@ impl HTMLTableColElementMethods for HTMLTableColElement {
|
|||
|
||||
pub trait HTMLTableColElementLayoutHelpers<'dom> {
|
||||
fn get_span(self) -> Option<u32>;
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl<'dom> HTMLTableColElementLayoutHelpers<'dom> for LayoutDom<'dom, HTMLTableColElement> {
|
||||
|
@ -74,6 +75,14 @@ impl<'dom> HTMLTableColElementLayoutHelpers<'dom> for LayoutDom<'dom, HTMLTableC
|
|||
.get_attr_for_layout(&ns!(), &local_name!("span"))
|
||||
.map(AttrValue::as_uint)
|
||||
}
|
||||
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"))
|
||||
.map(AttrValue::as_dimension)
|
||||
.cloned()
|
||||
.unwrap_or(LengthOrPercentageOrAuto::Auto)
|
||||
}
|
||||
}
|
||||
|
||||
impl VirtualMethods for HTMLTableColElement {
|
||||
|
@ -92,6 +101,7 @@ impl VirtualMethods for HTMLTableColElement {
|
|||
}
|
||||
attr
|
||||
},
|
||||
local_name!("width") => AttrValue::from_nonzero_dimension(value.into()),
|
||||
_ => self
|
||||
.super_type()
|
||||
.unwrap()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue