aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/table/construct.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout/table/construct.rs')
-rw-r--r--components/layout/table/construct.rs27
1 files changed, 13 insertions, 14 deletions
diff --git a/components/layout/table/construct.rs b/components/layout/table/construct.rs
index f20360d3b56..56e11320be4 100644
--- a/components/layout/table/construct.rs
+++ b/components/layout/table/construct.rs
@@ -1019,15 +1019,16 @@ where
DisplayLayoutInternal::TableCell => {
// This value will already have filtered out rowspan=0
// in quirks mode, so we don't have to worry about that.
- //
- // The HTML specification limits the parsed value of `rowspan` to
- // 65534 and `colspan` to 1000, so we also enforce the same limits
- // when dealing with arbitrary DOM elements (perhaps created via
- // script).
let (rowspan, colspan) = if info.pseudo_element_type.is_none() {
let node = info.node.to_threadsafe();
- let rowspan = node.get_rowspan().unwrap_or(1).min(65534) as usize;
- let colspan = node.get_colspan().unwrap_or(1).min(1000) as usize;
+ let rowspan = node.get_rowspan().unwrap_or(1) as usize;
+ let colspan = node.get_colspan().unwrap_or(1) as usize;
+
+ // The HTML specification clamps value of `rowspan` to [0, 65534] and
+ // `colspan` to [1, 1000].
+ assert!((1..=1000).contains(&colspan));
+ assert!((0..=65534).contains(&rowspan));
+
(rowspan, colspan)
} else {
(1, 1)
@@ -1140,21 +1141,19 @@ fn add_column<'dom, Node: NodeExt<'dom>>(
is_anonymous: bool,
) -> ArcRefCell<TableTrack> {
let span = if column_info.pseudo_element_type.is_none() {
- column_info
- .node
- .to_threadsafe()
- .get_span()
- .unwrap_or(1)
- .min(1000) as usize
+ column_info.node.to_threadsafe().get_span().unwrap_or(1)
} else {
1
};
+ // The HTML specification clamps value of `span` for `<col>` to [1, 1000].
+ assert!((1..=1000).contains(&span));
+
let column = ArcRefCell::new(TableTrack {
base: LayoutBoxBase::new(column_info.into(), column_info.style.clone()),
group_index,
is_anonymous,
});
- collection.extend(repeat(column.clone()).take(span));
+ collection.extend(repeat(column.clone()).take(span as usize));
column
}