aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/layout/table_cell.rs5
-rw-r--r--components/layout/table_row.rs5
-rw-r--r--components/script/dom/element.rs13
-rw-r--r--components/script/dom/htmltablecellelement.rs17
-rw-r--r--components/script/dom/webidls/HTMLTableCellElement.webidl4
-rw-r--r--components/script/layout_wrapper.rs6
-rw-r--r--components/script_layout_interface/wrapper_traits.rs2
-rw-r--r--components/style/matching.rs4
8 files changed, 52 insertions, 4 deletions
diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs
index abdcf03cb2b..5e20f195078 100644
--- a/components/layout/table_cell.rs
+++ b/components/layout/table_cell.rs
@@ -41,6 +41,9 @@ pub struct TableCellFlow {
/// The column span of this cell.
pub column_span: u32,
+ /// The rows spanned by this cell.
+ pub row_span: u32,
+
/// Whether this cell is visible. If false, the value of `empty-cells` means that we must not
/// display this cell.
pub visible: bool,
@@ -52,6 +55,7 @@ impl TableCellFlow {
block_flow: BlockFlow::from_fragment(fragment),
collapsed_borders: CollapsedBordersForCell::new(),
column_span: 1,
+ row_span: 1,
visible: true,
}
}
@@ -62,6 +66,7 @@ impl TableCellFlow {
block_flow: BlockFlow::from_fragment(fragment),
collapsed_borders: CollapsedBordersForCell::new(),
column_span: node.get_colspan(),
+ row_span: node.get_rowspan(),
visible: visible,
}
}
diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs
index acb052a7134..4f8af643846 100644
--- a/components/layout/table_row.rs
+++ b/components/layout/table_row.rs
@@ -78,6 +78,8 @@ pub struct CellIntrinsicInlineSize {
pub column_size: ColumnIntrinsicInlineSize,
/// The column span of this cell.
pub column_span: u32,
+ /// The row span of this cell.
+ pub row_span: u32,
}
@@ -268,6 +270,7 @@ impl Flow for TableRowFlow {
// fixed and automatic table layout calculation.
let child_specified_inline_size;
let child_column_span;
+ let child_row_span;
{
let child_table_cell = kid.as_mut_table_cell();
child_specified_inline_size = child_table_cell.block_flow
@@ -275,6 +278,7 @@ impl Flow for TableRowFlow {
.style
.content_inline_size();
child_column_span = child_table_cell.column_span;
+ child_row_span = child_table_cell.row_span;
// Perform border collapse if necessary.
if collapsing_borders {
@@ -319,6 +323,7 @@ impl Flow for TableRowFlow {
self.cell_intrinsic_inline_sizes.push(CellIntrinsicInlineSize {
column_size: child_column_inline_size,
column_span: child_column_span,
+ row_span: child_row_span,
});
}
}
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index d9831d79a69..4a94f345b02 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -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 {
diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs
index 1ec389d9977..b4bd885d4ed 100644
--- a/components/script/dom/htmltablecellelement.rs
+++ b/components/script/dom/htmltablecellelement.rs
@@ -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),
diff --git a/components/script/dom/webidls/HTMLTableCellElement.webidl b/components/script/dom/webidls/HTMLTableCellElement.webidl
index 33863b3dc20..8ac135170ec 100644
--- a/components/script/dom/webidls/HTMLTableCellElement.webidl
+++ b/components/script/dom/webidls/HTMLTableCellElement.webidl
@@ -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;
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs
index 338edc19730..290ebeb2312 100644
--- a/components/script/layout_wrapper.rs
+++ b/components/script/layout_wrapper.rs
@@ -913,6 +913,12 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> {
self.get_jsmanaged().downcast::<Element>().unwrap().get_colspan()
}
}
+
+ fn get_rowspan(&self) -> u32 {
+ unsafe {
+ self.get_jsmanaged().downcast::<Element>().unwrap().get_rowspan()
+ }
+ }
}
pub struct ThreadSafeLayoutNodeChildrenIterator<ConcreteNode: ThreadSafeLayoutNode> {
diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs
index 1d1f32bf4b6..cf3e3e4c7c5 100644
--- a/components/script_layout_interface/wrapper_traits.rs
+++ b/components/script_layout_interface/wrapper_traits.rs
@@ -265,6 +265,8 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo
fn get_colspan(&self) -> u32;
+ fn get_rowspan(&self) -> u32;
+
fn fragment_type(&self) -> FragmentType {
match self.get_pseudo_element_type() {
PseudoElementType::Normal => FragmentType::FragmentBody,
diff --git a/components/style/matching.rs b/components/style/matching.rs
index 3b0a396507d..f88df07e980 100644
--- a/components/style/matching.rs
+++ b/components/style/matching.rs
@@ -266,8 +266,8 @@ pub fn common_style_affecting_attributes() -> [CommonStyleAffectingAttributeInfo
/// Attributes that, if present, disable style sharing. All legacy HTML attributes must be in
/// either this list or `common_style_affecting_attributes`. See the comment in
/// `synthesize_presentational_hints_for_legacy_attributes`.
-pub fn rare_style_affecting_attributes() -> [LocalName; 3] {
- [ local_name!("bgcolor"), local_name!("border"), local_name!("colspan") ]
+pub fn rare_style_affecting_attributes() -> [LocalName; 4] {
+ [local_name!("bgcolor"), local_name!("border"), local_name!("colspan"), local_name!("rowspan")]
}
fn have_same_class<E: TElement>(element: &E,