Add support for cellpadding attribute (#31201)

This commit is contained in:
Oriol Brufau 2024-01-29 12:51:30 +01:00 committed by GitHub
parent 091653417a
commit 7d1b19c865
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 58 additions and 68 deletions

View file

@ -33,6 +33,7 @@ use crate::dom::virtualmethods::VirtualMethods;
pub struct HTMLTableElement {
htmlelement: HTMLElement,
border: Cell<Option<u32>>,
cellpadding: Cell<Option<u32>>,
cellspacing: Cell<Option<u32>>,
tbodies: MutNullableDom<HTMLCollection>,
}
@ -62,6 +63,7 @@ impl HTMLTableElement {
HTMLTableElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
border: Cell::new(None),
cellpadding: Cell::new(None),
cellspacing: Cell::new(None),
tbodies: Default::default(),
}
@ -425,6 +427,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
pub trait HTMLTableElementLayoutHelpers {
fn get_background_color(self) -> Option<RGBA>;
fn get_border(self) -> Option<u32>;
fn get_cellpadding(self) -> Option<u32>;
fn get_cellspacing(self) -> Option<u32>;
fn get_width(self) -> LengthOrPercentageOrAuto;
}
@ -442,6 +445,11 @@ impl HTMLTableElementLayoutHelpers for LayoutDom<'_, HTMLTableElement> {
unsafe { (*self.unsafe_get()).border.get() }
}
#[allow(unsafe_code)]
fn get_cellpadding(self) -> Option<u32> {
unsafe { (*self.unsafe_get()).cellpadding.get() }
}
#[allow(unsafe_code)]
fn get_cellspacing(self) -> Option<u32> {
unsafe { (*self.unsafe_get()).cellspacing.get() }
@ -472,6 +480,13 @@ impl VirtualMethods for HTMLTableElement {
.map(|value| parse_unsigned_integer(value.chars()).unwrap_or(1)),
);
},
local_name!("cellpadding") => {
self.cellpadding.set(
mutation
.new_value(attr)
.and_then(|value| parse_unsigned_integer(value.chars()).ok()),
);
},
local_name!("cellspacing") => {
self.cellspacing.set(
mutation