Auto merge of #21856 - zcorpan:zcorpan/remove-td-th-interfaces, r=jdm

Remove the HTMLTable{Header,Data}CellElement interfaces

Fixes #17222.

<!-- Please describe your changes on the following line: -->
This removes the `HTMLTableHeaderCellElement` and `HTMLTableDataCellElement` interfaces and uses the `HTMLTableCellElement` interface for both `th` and `td` elements, as per the spec.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #17222.

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/21856)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-10-12 09:30:41 -04:00 committed by GitHub
commit 69e5243810
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 42 additions and 191 deletions

View file

@ -55,10 +55,9 @@ use dom::bindings::codegen::Bindings::HTMLSourceElementBinding;
use dom::bindings::codegen::Bindings::HTMLSpanElementBinding;
use dom::bindings::codegen::Bindings::HTMLStyleElementBinding;
use dom::bindings::codegen::Bindings::HTMLTableCaptionElementBinding;
use dom::bindings::codegen::Bindings::HTMLTableCellElementBinding;
use dom::bindings::codegen::Bindings::HTMLTableColElementBinding;
use dom::bindings::codegen::Bindings::HTMLTableDataCellElementBinding;
use dom::bindings::codegen::Bindings::HTMLTableElementBinding;
use dom::bindings::codegen::Bindings::HTMLTableHeaderCellElementBinding;
use dom::bindings::codegen::Bindings::HTMLTableRowElementBinding;
use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding;
use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding;
@ -310,11 +309,11 @@ pub fn get_constructor_object_from_local_name(
local_name!("sup") => get_constructor!(HTMLElementBinding),
local_name!("table") => get_constructor!(HTMLTableElementBinding),
local_name!("tbody") => get_constructor!(HTMLTableSectionElementBinding),
local_name!("td") => get_constructor!(HTMLTableDataCellElementBinding),
local_name!("td") => get_constructor!(HTMLTableCellElementBinding),
local_name!("template") => get_constructor!(HTMLTemplateElementBinding),
local_name!("textarea") => get_constructor!(HTMLTextAreaElementBinding),
local_name!("tfoot") => get_constructor!(HTMLTableSectionElementBinding),
local_name!("th") => get_constructor!(HTMLTableHeaderCellElementBinding),
local_name!("th") => get_constructor!(HTMLTableCellElementBinding),
local_name!("thead") => get_constructor!(HTMLTableSectionElementBinding),
local_name!("time") => get_constructor!(HTMLTimeElementBinding),
local_name!("title") => get_constructor!(HTMLTitleElementBinding),

View file

@ -64,10 +64,9 @@ use dom::htmlsourceelement::HTMLSourceElement;
use dom::htmlspanelement::HTMLSpanElement;
use dom::htmlstyleelement::HTMLStyleElement;
use dom::htmltablecaptionelement::HTMLTableCaptionElement;
use dom::htmltablecellelement::HTMLTableCellElement;
use dom::htmltablecolelement::HTMLTableColElement;
use dom::htmltabledatacellelement::HTMLTableDataCellElement;
use dom::htmltableelement::HTMLTableElement;
use dom::htmltableheadercellelement::HTMLTableHeaderCellElement;
use dom::htmltablerowelement::HTMLTableRowElement;
use dom::htmltablesectionelement::HTMLTableSectionElement;
use dom::htmltemplateelement::HTMLTemplateElement;
@ -346,12 +345,12 @@ pub fn create_native_html_element(
local_name!("sup") => make!(HTMLElement),
local_name!("table") => make!(HTMLTableElement),
local_name!("tbody") => make!(HTMLTableSectionElement),
local_name!("td") => make!(HTMLTableDataCellElement),
local_name!("td") => make!(HTMLTableCellElement),
local_name!("template") => make!(HTMLTemplateElement),
local_name!("textarea") => make!(HTMLTextAreaElement),
// https://html.spec.whatwg.org/multipage/#the-tfoot-element:concept-element-dom
local_name!("tfoot") => make!(HTMLTableSectionElement),
local_name!("th") => make!(HTMLTableHeaderCellElement),
local_name!("th") => make!(HTMLTableCellElement),
// https://html.spec.whatwg.org/multipage/#the-thead-element:concept-element-dom
local_name!("thead") => make!(HTMLTableSectionElement),
local_name!("time") => make!(HTMLTimeElement),

View file

@ -3,9 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::RGBA;
use dom::bindings::codegen::Bindings::HTMLTableCellElementBinding;
use dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethods;
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::root::DomRoot;
use dom::bindings::root::LayoutDom;
use dom::bindings::str::DOMString;
use dom::document::Document;
@ -28,15 +30,30 @@ pub struct HTMLTableCellElement {
}
impl HTMLTableCellElement {
pub fn new_inherited(
tag_name: LocalName,
fn new_inherited(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> HTMLTableCellElement {
HTMLTableCellElement {
htmlelement: HTMLElement::new_inherited(tag_name, prefix, document),
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
}
}
#[allow(unrooted_must_root)]
pub fn new(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> DomRoot<HTMLTableCellElement> {
Node::reflect_node(
Box::new(HTMLTableCellElement::new_inherited(
local_name, prefix, document,
)),
document,
HTMLTableCellElementBinding::Wrap,
)
}
}
impl HTMLTableCellElementMethods for HTMLTableCellElement {

View file

@ -1,43 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLTableDataCellElementBinding;
use dom::bindings::root::DomRoot;
use dom::document::Document;
use dom::htmltablecellelement::HTMLTableCellElement;
use dom::node::Node;
use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
#[dom_struct]
pub struct HTMLTableDataCellElement {
htmltablecellelement: HTMLTableCellElement,
}
impl HTMLTableDataCellElement {
fn new_inherited(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> HTMLTableDataCellElement {
HTMLTableDataCellElement {
htmltablecellelement: HTMLTableCellElement::new_inherited(local_name, prefix, document),
}
}
#[allow(unrooted_must_root)]
pub fn new(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> DomRoot<HTMLTableDataCellElement> {
Node::reflect_node(
Box::new(HTMLTableDataCellElement::new_inherited(
local_name, prefix, document,
)),
document,
HTMLTableDataCellElementBinding::Wrap,
)
}
}

View file

@ -1,43 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLTableHeaderCellElementBinding;
use dom::bindings::root::DomRoot;
use dom::document::Document;
use dom::htmltablecellelement::HTMLTableCellElement;
use dom::node::Node;
use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
#[dom_struct]
pub struct HTMLTableHeaderCellElement {
htmltablecellelement: HTMLTableCellElement,
}
impl HTMLTableHeaderCellElement {
fn new_inherited(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> HTMLTableHeaderCellElement {
HTMLTableHeaderCellElement {
htmltablecellelement: HTMLTableCellElement::new_inherited(local_name, prefix, document),
}
}
#[allow(unrooted_must_root)]
pub fn new(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> DomRoot<HTMLTableHeaderCellElement> {
Node::reflect_node(
Box::new(HTMLTableHeaderCellElement::new_inherited(
local_name, prefix, document,
)),
document,
HTMLTableHeaderCellElementBinding::Wrap,
)
}
}

View file

@ -15,9 +15,8 @@ use dom::document::Document;
use dom::element::{Element, RawLayoutElementHelpers};
use dom::htmlcollection::{CollectionFilter, HTMLCollection};
use dom::htmlelement::HTMLElement;
use dom::htmltabledatacellelement::HTMLTableDataCellElement;
use dom::htmltablecellelement::HTMLTableCellElement;
use dom::htmltableelement::HTMLTableElement;
use dom::htmltableheadercellelement::HTMLTableHeaderCellElement;
use dom::htmltablesectionelement::HTMLTableSectionElement;
use dom::node::{Node, window_from_node};
use dom::virtualmethods::VirtualMethods;
@ -29,7 +28,7 @@ use style::attr::AttrValue;
struct CellsFilter;
impl CollectionFilter for CellsFilter {
fn filter(&self, elem: &Element, root: &Node) -> bool {
(elem.is::<HTMLTableHeaderCellElement>() || elem.is::<HTMLTableDataCellElement>()) &&
(elem.is::<HTMLTableCellElement>()) &&
elem.upcast::<Node>().GetParentNode().r() == Some(root)
}
}
@ -99,7 +98,7 @@ impl HTMLTableRowElementMethods for HTMLTableRowElement {
node.insert_cell_or_row(
index,
|| self.Cells(),
|| HTMLTableDataCellElement::new(local_name!("td"), None, &node.owner_doc()),
|| HTMLTableCellElement::new(local_name!("td"), None, &node.owner_doc()),
)
}
@ -109,7 +108,7 @@ impl HTMLTableRowElementMethods for HTMLTableRowElement {
node.delete_cell_or_row(
index,
|| self.Cells(),
|n| n.is::<HTMLTableDataCellElement>(),
|n| n.is::<HTMLTableCellElement>(),
)
}

View file

@ -372,9 +372,7 @@ pub mod htmlstyleelement;
pub mod htmltablecaptionelement;
pub mod htmltablecellelement;
pub mod htmltablecolelement;
pub mod htmltabledatacellelement;
pub mod htmltableelement;
pub mod htmltableheadercellelement;
pub mod htmltablerowelement;
pub mod htmltablesectionelement;
pub mod htmltemplateelement;

View file

@ -2930,7 +2930,7 @@ impl Into<LayoutElementType> for ElementTypeId {
ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLParagraphElement) => {
LayoutElementType::HTMLParagraphElement
},
ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableCellElement(_)) => {
ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableCellElement) => {
LayoutElementType::HTMLTableCellElement
},
ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableColElement) => {

View file

@ -242,7 +242,7 @@ pub fn vtable_for(node: &Node) -> &VirtualMethods {
node.downcast::<HTMLTableElement>().unwrap() as &VirtualMethods
},
NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLTableCellElement(_),
HTMLElementTypeId::HTMLTableCellElement,
)) => node.downcast::<HTMLTableCellElement>().unwrap() as &VirtualMethods,
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableRowElement)) => {
node.downcast::<HTMLTableRowElement>().unwrap() as &VirtualMethods

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://html.spec.whatwg.org/multipage/#htmltablecellelement
[HTMLConstructor, Abstract]
[HTMLConstructor]
interface HTMLTableCellElement : HTMLElement {
[CEReactions]
attribute unsigned long colSpan;
@ -13,6 +13,11 @@ interface HTMLTableCellElement : HTMLElement {
// attribute DOMString headers;
readonly attribute long cellIndex;
// [CEReactions]
// attribute DOMString scope; // only conforming for th elements
// [CEReactions]
// attribute DOMString abbr; // only conforming for th elements
// also has obsolete members
};

View file

@ -1,15 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://html.spec.whatwg.org/multipage/#htmltabledatacellelement
[HTMLConstructor]
interface HTMLTableDataCellElement : HTMLTableCellElement {
// also has obsolete members
};
// https://html.spec.whatwg.org/multipage/#HTMLTableDataCellElement-partial
partial interface HTMLTableDataCellElement {
// [CEReactions]
// attribute DOMString abbr;
};

View file

@ -1,15 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://html.spec.whatwg.org/multipage/#htmltableheadercellelement
[HTMLConstructor]
interface HTMLTableHeaderCellElement : HTMLTableCellElement {
// [CEReactions]
// attribute DOMString scope;
// [CEReactions]
// attribute DOMString abbr;
// [CEReactions]
// attribute DOMString sorted;
// void sort();
};

View file

@ -1,5 +1,4 @@
[builtin-coverage.html]
expected: ERROR
[Untitled]
expected: FAIL
@ -385,8 +384,6 @@
expected: FAIL
[td: Operator 'new' should instantiate a customized built-in element]
expected: FAIL
[td: document.createElement() should instantiate a customized built-in element]
expected: FAIL
[td: innerHTML should instantiate a customized built-in element]
expected: FAIL
[template: Operator 'new' should instantiate a customized built-in element]
@ -403,8 +400,6 @@
expected: FAIL
[th: Operator 'new' should instantiate a customized built-in element]
expected: FAIL
[th: document.createElement() should instantiate a customized built-in element]
expected: FAIL
[th: innerHTML should instantiate a customized built-in element]
expected: FAIL
[thead: Operator 'new' should instantiate a customized built-in element]

View file

@ -3,9 +3,3 @@
[document.all cannot find applet]
expected: FAIL
[HTMLTableHeaderCellElement interface is removed]
expected: FAIL
[HTMLTableDataCellElement interface is removed]
expected: FAIL

View file

@ -2231,12 +2231,6 @@
[HTMLTableCellElement interface: attribute vAlign]
expected: FAIL
[HTMLTableCellElement must be primary interface of document.createElement("td")]
expected: FAIL
[Stringification of document.createElement("td")]
expected: FAIL
[HTMLTableCellElement interface: document.createElement("td") must inherit property "headers" with the proper type]
expected: FAIL
@ -2267,12 +2261,6 @@
[HTMLTableCellElement interface: document.createElement("td") must inherit property "vAlign" with the proper type]
expected: FAIL
[HTMLTableCellElement must be primary interface of document.createElement("th")]
expected: FAIL
[Stringification of document.createElement("th")]
expected: FAIL
[HTMLTableCellElement interface: document.createElement("th") must inherit property "headers" with the proper type]
expected: FAIL
@ -7569,12 +7557,6 @@
[HTMLTableCellElement interface: attribute vAlign]
expected: FAIL
[HTMLTableCellElement must be primary interface of document.createElement("td")]
expected: FAIL
[Stringification of document.createElement("td")]
expected: FAIL
[HTMLTableCellElement interface: document.createElement("td") must inherit property "headers" with the proper type]
expected: FAIL
@ -7605,12 +7587,6 @@
[HTMLTableCellElement interface: document.createElement("td") must inherit property "vAlign" with the proper type]
expected: FAIL
[HTMLTableCellElement must be primary interface of document.createElement("th")]
expected: FAIL
[Stringification of document.createElement("th")]
expected: FAIL
[HTMLTableCellElement interface: document.createElement("th") must inherit property "headers" with the proper type]
expected: FAIL

View file

@ -53,16 +53,3 @@
[Interfaces for SLOT]
expected: FAIL
[Interfaces for td]
expected: FAIL
[Interfaces for TD]
expected: FAIL
[Interfaces for th]
expected: FAIL
[Interfaces for TH]
expected: FAIL

View file

@ -26638,7 +26638,7 @@
"testharness"
],
"mozilla/collections.html": [
"4011ee6bf322eaacafafd98238c4261084397fde",
"8e06ffcc0933719b4b79ea6656d6635cc121d900",
"testharness"
],
"mozilla/createEvent-storageevent.html": [
@ -27038,7 +27038,7 @@
"testharness"
],
"mozilla/interfaces.html": [
"4863f4d1036e945cfaae1f112981fac3367b2e49",
"8bbde3b46a8e9d5ead6f9a2bf372d9647ad059be",
"testharness"
],
"mozilla/interfaces.js": [

View file

@ -123,8 +123,8 @@ test(function() {
check_tag("caption", 1, [HTMLTableCaptionElement]);
check_tag("textarea", 1, [HTMLTextAreaElement]);
check_tag("q", 1, [HTMLQuoteElement]);
check_tag("th", 1, [HTMLTableCellElement, HTMLTableHeaderCellElement]);
check_tag("td", 1, [HTMLTableCellElement, HTMLTableDataCellElement]);
check_tag("th", 1, [HTMLTableCellElement]);
check_tag("td", 1, [HTMLTableCellElement]);
check_tag("col", 1, [HTMLTableColElement]);
check_tag("colgroup", 1, [HTMLTableColElement]);
check_tag("input", 2, [HTMLInputElement]);

View file

@ -139,9 +139,7 @@ test_interfaces([
"HTMLTableCaptionElement",
"HTMLTableCellElement",
"HTMLTableColElement",
"HTMLTableDataCellElement",
"HTMLTableElement",
"HTMLTableHeaderCellElement",
"HTMLTableRowElement",
"HTMLTableSectionElement",
"HTMLTemplateElement",