aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-12-26 10:09:09 -0800
committerGitHub <noreply@github.com>2016-12-26 10:09:09 -0800
commit9d320d5a34fe9911266940eb1ce96204d345b678 (patch)
tree479398cf64639acf645f0cfc08bb0b8fcd21ca03 /components/script/dom
parent37a5e29147f0dc489888377d6f7bb53282dc04f9 (diff)
parentef7bdaa3e37cb00091a19c30a405327d3091c6ff (diff)
downloadservo-9d320d5a34fe9911266940eb1ce96204d345b678.tar.gz
servo-9d320d5a34fe9911266940eb1ce96204d345b678.zip
Auto merge of #14518 - mbrubeck:rowspan2, r=notriddle
Fix inline layout of table cells impacted by rowspan This is part of the fix for #11297. This PR fixes the inline layout of table cells impacted by row-spanning cells from previous rows. A separate PR to follow will fix the table block size calculations to account for rowspan. This PR doesn't yet include any test changes. If it doesn't cause any existing tests to pass, I will add a new test to it. r? @pcwalton <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14518) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom')
-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
3 files changed, 32 insertions, 2 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index f01c51513ec..d9c2f6907e7 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -325,6 +325,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>>>;
@@ -628,6 +630,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 6790c2a4ea0..4a6ca5ca9b1 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 {
@@ -42,6 +43,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");
@@ -75,6 +82,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;
}
@@ -97,6 +105,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())
@@ -116,6 +132,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;