mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Add the HTMLTableCellElement::rowspan property
This commit is contained in:
parent
b77a0a89cf
commit
e982d6003f
10 changed files with 52 additions and 763 deletions
|
@ -324,6 +324,8 @@ pub trait LayoutElementHelpers {
|
|||
#[allow(unsafe_code)]
|
||||
unsafe fn get_colspan(self) -> u32;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_rowspan(self) -> u32;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn html_element_in_html_document_for_layout(&self) -> bool;
|
||||
fn id_attribute(&self) -> *const Option<Atom>;
|
||||
fn style_attribute(&self) -> *const Option<Arc<RwLock<PropertyDeclarationBlock>>>;
|
||||
|
@ -627,6 +629,17 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_rowspan(self) -> u32 {
|
||||
if let Some(this) = self.downcast::<HTMLTableCellElement>() {
|
||||
this.get_rowspan().unwrap_or(1)
|
||||
} else {
|
||||
// Don't panic since `display` can cause this to be called on arbitrary
|
||||
// elements.
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn html_element_in_html_document_for_layout(&self) -> bool {
|
||||
|
|
|
@ -18,6 +18,7 @@ use html5ever_atoms::LocalName;
|
|||
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
|
||||
|
||||
const DEFAULT_COLSPAN: u32 = 1;
|
||||
const DEFAULT_ROWSPAN: u32 = 1;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct HTMLTableCellElement {
|
||||
|
@ -47,6 +48,12 @@ impl HTMLTableCellElementMethods for HTMLTableCellElement {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-tdth-colspan
|
||||
make_uint_setter!(SetColSpan, "colspan", DEFAULT_COLSPAN);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-tdth-rowspan
|
||||
make_uint_getter!(RowSpan, "rowspan", DEFAULT_ROWSPAN);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-tdth-rowspan
|
||||
make_uint_setter!(SetRowSpan, "rowspan", DEFAULT_ROWSPAN);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-tdth-bgcolor
|
||||
make_getter!(BgColor, "bgcolor");
|
||||
|
||||
|
@ -80,6 +87,7 @@ impl HTMLTableCellElementMethods for HTMLTableCellElement {
|
|||
pub trait HTMLTableCellElementLayoutHelpers {
|
||||
fn get_background_color(&self) -> Option<RGBA>;
|
||||
fn get_colspan(&self) -> Option<u32>;
|
||||
fn get_rowspan(&self) -> Option<u32>;
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
|
@ -102,6 +110,14 @@ impl HTMLTableCellElementLayoutHelpers for LayoutJS<HTMLTableCellElement> {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_rowspan(&self) -> Option<u32> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("rowspan"))
|
||||
.map(AttrValue::as_uint)
|
||||
}
|
||||
}
|
||||
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
|
@ -121,6 +137,7 @@ impl VirtualMethods for HTMLTableCellElement {
|
|||
fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue {
|
||||
match *local_name {
|
||||
local_name!("colspan") => AttrValue::from_u32(value.into(), DEFAULT_COLSPAN),
|
||||
local_name!("rowspan") => AttrValue::from_u32(value.into(), DEFAULT_ROWSPAN),
|
||||
local_name!("bgcolor") => AttrValue::from_legacy_color(value.into()),
|
||||
local_name!("width") => AttrValue::from_nonzero_dimension(value.into()),
|
||||
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
// https://html.spec.whatwg.org/multipage/#htmltablecellelement
|
||||
[Abstract]
|
||||
interface HTMLTableCellElement : HTMLElement {
|
||||
attribute unsigned long colSpan;
|
||||
// attribute unsigned long rowSpan;
|
||||
attribute unsigned long colSpan;
|
||||
attribute unsigned long rowSpan;
|
||||
// attribute DOMString headers;
|
||||
readonly attribute long cellIndex;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue