Fix for bug 824907 (Convert HTML table elements to WebIDL) - convert HTMLTableSectionElement to WebIDL. r=bz.

--HG--
rename : content/html/content/src/nsHTMLTableRowElement.cpp => content/html/content/src/HTMLTableRowElement.cpp
rename : content/html/content/src/nsHTMLTableSectionElement.cpp => content/html/content/src/HTMLTableSectionElement.cpp
rename : content/html/content/src/nsHTMLTableSectionElement.cpp => content/html/content/src/HTMLTableSectionElement.h
rename : dom/interfaces/html/nsIDOMHTMLTableSectionElem.idl => dom/interfaces/html/nsIDOMHTMLTableSectionElement.idl
extra : rebase_source : b9c1d7dea38653452b44b2033cf2c0140f7b39b1
This commit is contained in:
Peter Van der Beken 2012-12-29 15:07:48 +01:00
parent 8d553dd587
commit 0a9ff23dea
16 changed files with 238 additions and 114 deletions

View File

@ -28,7 +28,7 @@
#include "nsIDOMHTMLTableCellElement.h"
#include "nsIDOMHTMLTableElement.h"
#include "nsIDOMHTMLTableRowElement.h"
#include "nsIDOMHTMLTableSectionElem.h"
#include "nsIDOMHTMLTableSectionElement.h"
#include "nsIDocument.h"
#include "nsIMutableArray.h"
#include "nsIPresShell.h"

View File

@ -45,8 +45,8 @@ function testVariablesFiltering()
"There should be 0 variables displayed in the test scope");
is(loadScope.querySelectorAll(".variable:not([non-match])").length, 1,
"There should be 1 variable displayed in the load scope");
is(globalScope.querySelectorAll(".variable:not([non-match])").length, 4,
"There should be 4 variables displayed in the global scope");
is(globalScope.querySelectorAll(".variable:not([non-match])").length, 5,
"There should be 5 variables displayed in the global scope");
is(innerScope.querySelectorAll(".property:not([non-match])").length, 0,
"There should be 0 properties displayed in the inner scope");

View File

@ -6,7 +6,7 @@
#include "mozilla/Util.h"
#include "mozilla/dom/HTMLTableElement.h"
#include "nsIDOMHTMLTableSectionElem.h"
#include "nsIDOMHTMLTableSectionElement.h"
#include "nsAttrValueInlines.h"
#include "nsRuleData.h"
#include "nsHTMLStyleSheet.h"
@ -117,9 +117,9 @@ NS_INTERFACE_MAP_END
if (mParent) { \
/* THead */ \
HTMLTableSectionElement* rowGroup = mParent->GetTHead(); \
nsCOMPtr<nsIDOMHTMLCollection> rows; \
nsIHTMLCollection* rows; \
if (rowGroup) { \
rowGroup->GetRows(getter_AddRefs(rows)); \
rows = rowGroup->Rows(); \
do { /* gives scoping */ \
_code \
} while (0); \
@ -129,7 +129,7 @@ NS_INTERFACE_MAP_END
_node; _node = _node->GetNextSibling()) { \
if (_node->IsHTML(nsGkAtoms::tbody)) { \
rowGroup = static_cast<HTMLTableSectionElement*>(_node); \
rowGroup->GetRows(getter_AddRefs(rows)); \
rows = rowGroup->Rows(); \
do { /* gives scoping */ \
_code \
} while (0); \
@ -142,9 +142,9 @@ NS_INTERFACE_MAP_END
} while (0); \
/* TFoot */ \
rowGroup = mParent->GetTFoot(); \
rows = nullptr; \
rows = nullptr; \
if (rowGroup) { \
rowGroup->GetRows(getter_AddRefs(rows)); \
rows = rowGroup->Rows(); \
do { /* gives scoping */ \
_code \
} while (0); \
@ -540,8 +540,10 @@ HTMLTableElement::GetTHead(nsIDOMHTMLTableSectionElement** aValue)
NS_IMETHODIMP
HTMLTableElement::SetTHead(nsIDOMHTMLTableSectionElement* aValue)
{
HTMLTableSectionElement* section =
static_cast<HTMLTableSectionElement*>(aValue);
ErrorResult rv;
SetTHead(aValue, rv);
SetTHead(section, rv);
return rv.ErrorCode();
}
@ -556,8 +558,10 @@ HTMLTableElement::GetTFoot(nsIDOMHTMLTableSectionElement** aValue)
NS_IMETHODIMP
HTMLTableElement::SetTFoot(nsIDOMHTMLTableSectionElement* aValue)
{
HTMLTableSectionElement* section =
static_cast<HTMLTableSectionElement*>(aValue);
ErrorResult rv;
SetTFoot(aValue, rv);
SetTFoot(section, rv);
return rv.ErrorCode();
}
@ -821,11 +825,8 @@ HTMLTableElement::InsertRow(int32_t aIndex, ErrorResult& aError)
if (newRow) {
HTMLTableSectionElement* section =
static_cast<HTMLTableSectionElement*>(rowGroup.get());
nsCOMPtr<nsIDOMHTMLCollection> rows;
section->GetRows(getter_AddRefs(rows));
rowGroup->InsertBefore(*newRow,
static_cast<nsIHTMLCollection*>(rows.get())->Item(0),
aError);
nsIHTMLCollection* rows = section->Rows();
rowGroup->InsertBefore(*newRow, rows->Item(0), aError);
}
}
}

View File

@ -58,19 +58,16 @@ public:
{
return static_cast<HTMLTableSectionElement*>(GetChild(nsGkAtoms::thead));
}
void SetTHead(nsIDOMHTMLTableSectionElement* aTHead, ErrorResult& aError)
void SetTHead(HTMLTableSectionElement* aTHead, ErrorResult& aError)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aTHead);
if (!content || !content->IsHTML(nsGkAtoms::thead)) {
if (!aTHead->IsHTML(nsGkAtoms::thead)) {
aError.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR);
return;
}
HTMLTableSectionElement* thead =
static_cast<HTMLTableSectionElement*>(aTHead);
DeleteTHead();
if (thead) {
nsINode::InsertBefore(*thead, nsINode::GetFirstChild(), aError);
if (aTHead) {
nsINode::InsertBefore(*aTHead, nsINode::GetFirstChild(), aError);
}
}
already_AddRefed<nsGenericHTMLElement> CreateTHead();
@ -79,19 +76,16 @@ public:
{
return static_cast<HTMLTableSectionElement*>(GetChild(nsGkAtoms::tfoot));
}
void SetTFoot(nsIDOMHTMLTableSectionElement* aTFoot, ErrorResult& aError)
void SetTFoot(HTMLTableSectionElement* aTFoot, ErrorResult& aError)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aTFoot);
if (!content || !content->IsHTML(nsGkAtoms::tfoot)) {
if (!aTFoot->IsHTML(nsGkAtoms::tfoot)) {
aError.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR);
return;
}
HTMLTableSectionElement* tfoot =
static_cast<HTMLTableSectionElement*>(aTFoot);
DeleteTFoot();
if (tfoot) {
nsINode::AppendChild(*tfoot, aError);
if (aTFoot) {
nsINode::AppendChild(*aTFoot, aError);
}
}
already_AddRefed<nsGenericHTMLElement> CreateTFoot();

View File

@ -7,7 +7,7 @@
#include "mozilla/dom/HTMLTableRowElement.h"
#include "nsIDOMHTMLTableElement.h"
#include "nsIDOMHTMLTableSectionElem.h"
#include "nsIDOMHTMLTableSectionElement.h"
#include "nsIDOMHTMLTableCellElement.h"
#include "nsMappedAttributes.h"
#include "nsAttrValueInlines.h"

View File

@ -8,13 +8,9 @@
#include "mozilla/dom/HTMLTableSectionElement.h"
#include "nsMappedAttributes.h"
#include "nsAttrValueInlines.h"
#include "nsGkAtoms.h"
#include "nsHTMLParts.h"
#include "nsStyleConsts.h"
#include "nsContentList.h"
#include "nsRuleData.h"
#include "nsError.h"
#include "nsContentUtils.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/HTMLTableSectionElementBinding.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(TableSection)
DOMCI_NODE_DATA(HTMLTableSectionElement, mozilla::dom::HTMLTableSectionElement)
@ -24,9 +20,11 @@ namespace dom {
// you will see the phrases "rowgroup" and "section" used interchangably
HTMLTableSectionElement::HTMLTableSectionElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
JSObject*
HTMLTableSectionElement::WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap)
{
return HTMLTableSectionElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLTableSectionElement)
@ -49,15 +47,76 @@ NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableSectionElement)
NS_IMPL_ELEMENT_CLONE(HTMLTableSectionElement)
NS_IMPL_STRING_ATTR(HTMLTableSectionElement, Align, align)
NS_IMPL_STRING_ATTR(HTMLTableSectionElement, VAlign, valign)
NS_IMPL_STRING_ATTR(HTMLTableSectionElement, Ch, _char)
NS_IMPL_STRING_ATTR(HTMLTableSectionElement, ChOff, charoff)
NS_IMETHODIMP
HTMLTableSectionElement::SetAlign(const nsAString& aAlign)
{
ErrorResult rv;
SetAlign(aAlign, rv);
return rv.ErrorCode();
}
NS_IMETHODIMP
HTMLTableSectionElement::GetRows(nsIDOMHTMLCollection** aValue)
HTMLTableSectionElement::GetAlign(nsAString& aAlign)
{
nsString align;
GetAlign(align);
aAlign = align;
return NS_OK;
}
NS_IMETHODIMP
HTMLTableSectionElement::SetVAlign(const nsAString& aVAlign)
{
ErrorResult rv;
SetVAlign(aVAlign, rv);
return rv.ErrorCode();
}
NS_IMETHODIMP
HTMLTableSectionElement::GetVAlign(nsAString& aVAlign)
{
nsString vAlign;
GetVAlign(vAlign);
aVAlign = vAlign;
return NS_OK;
}
NS_IMETHODIMP
HTMLTableSectionElement::SetCh(const nsAString& aCh)
{
ErrorResult rv;
SetCh(aCh, rv);
return rv.ErrorCode();
}
NS_IMETHODIMP
HTMLTableSectionElement::GetCh(nsAString& aCh)
{
nsString ch;
GetCh(ch);
aCh = ch;
return NS_OK;
}
NS_IMETHODIMP
HTMLTableSectionElement::SetChOff(const nsAString& aChOff)
{
ErrorResult rv;
SetChOff(aChOff, rv);
return rv.ErrorCode();
}
NS_IMETHODIMP
HTMLTableSectionElement::GetChOff(nsAString& aChOff)
{
nsString chOff;
GetChOff(chOff);
aChOff = chOff;
return NS_OK;
}
nsIHTMLCollection*
HTMLTableSectionElement::Rows()
{
if (!mRows) {
mRows = new nsContentList(this,
@ -67,29 +126,30 @@ HTMLTableSectionElement::GetRows(nsIDOMHTMLCollection** aValue)
false);
}
NS_ADDREF(*aValue = mRows);
return mRows;
}
NS_IMETHODIMP
HTMLTableSectionElement::GetRows(nsIDOMHTMLCollection** aValue)
{
NS_ADDREF(*aValue = Rows());
return NS_OK;
}
NS_IMETHODIMP
HTMLTableSectionElement::InsertRow(int32_t aIndex,
nsIDOMHTMLElement** aValue)
already_AddRefed<nsGenericHTMLElement>
HTMLTableSectionElement::InsertRow(int32_t aIndex, ErrorResult& aError)
{
*aValue = nullptr;
if (aIndex < -1) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return nullptr;
}
nsCOMPtr<nsIDOMHTMLCollection> rows;
GetRows(getter_AddRefs(rows));
uint32_t rowCount;
rows->GetLength(&rowCount);
nsIHTMLCollection* rows = Rows();
uint32_t rowCount = rows->Length();
if (aIndex > (int32_t)rowCount) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return nullptr;
}
bool doInsert = (aIndex < int32_t(rowCount)) && (aIndex != -1);
@ -99,53 +159,45 @@ HTMLTableSectionElement::InsertRow(int32_t aIndex,
nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::tr,
getter_AddRefs(nodeInfo));
nsCOMPtr<nsIContent> rowContent = NS_NewHTMLTableRowElement(nodeInfo.forget());
nsRefPtr<nsGenericHTMLElement> rowContent =
NS_NewHTMLTableRowElement(nodeInfo.forget());
if (!rowContent) {
return NS_ERROR_OUT_OF_MEMORY;
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
nsCOMPtr<nsIDOMNode> rowNode(do_QueryInterface(rowContent));
NS_ASSERTION(rowNode, "Should implement nsIDOMNode!");
nsCOMPtr<nsIDOMNode> retChild;
nsresult rv;
if (doInsert) {
nsCOMPtr<nsIDOMNode> refRow;
rows->Item(aIndex, getter_AddRefs(refRow));
rv = InsertBefore(rowNode, refRow, getter_AddRefs(retChild));
NS_ENSURE_SUCCESS(rv, rv);
nsINode::InsertBefore(*rowContent, rows->Item(aIndex), aError);
} else {
rv = AppendChild(rowNode, getter_AddRefs(retChild));
NS_ENSURE_SUCCESS(rv, rv);
nsINode::AppendChild(*rowContent, aError);
}
if (retChild) {
CallQueryInterface(retChild, aValue);
}
return NS_OK;
return rowContent.forget();
}
NS_IMETHODIMP
HTMLTableSectionElement::DeleteRow(int32_t aValue)
HTMLTableSectionElement::InsertRow(int32_t aIndex,
nsIDOMHTMLElement** aValue)
{
ErrorResult rv;
nsRefPtr<nsGenericHTMLElement> row = InsertRow(aIndex, rv);
return rv.Failed() ? rv.ErrorCode() : CallQueryInterface(row, aValue);
}
void
HTMLTableSectionElement::DeleteRow(int32_t aValue, ErrorResult& aError)
{
if (aValue < -1) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return;
}
nsCOMPtr<nsIDOMHTMLCollection> rows;
GetRows(getter_AddRefs(rows));
nsIHTMLCollection* rows = Rows();
nsresult rv;
uint32_t refIndex;
if (aValue == -1) {
rv = rows->GetLength(&refIndex);
NS_ENSURE_SUCCESS(rv, rv);
refIndex = rows->Length();
if (refIndex == 0) {
return NS_OK;
return;
}
--refIndex;
@ -154,16 +206,21 @@ HTMLTableSectionElement::DeleteRow(int32_t aValue)
refIndex = (uint32_t)aValue;
}
nsCOMPtr<nsIDOMNode> row;
rv = rows->Item(refIndex, getter_AddRefs(row));
NS_ENSURE_SUCCESS(rv, rv);
nsINode* row = rows->Item(refIndex);
if (!row) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return;
}
nsCOMPtr<nsIDOMNode> retChild;
return RemoveChild(row, getter_AddRefs(retChild));
nsINode::RemoveChild(*row, aError);
}
NS_IMETHODIMP
HTMLTableSectionElement::DeleteRow(int32_t aValue)
{
ErrorResult rv;
DeleteRow(aValue, rv);
return rv.ErrorCode();
}
bool

View File

@ -6,7 +6,7 @@
#define mozilla_dom_HTMLTableSectionElement_h
#include "nsGenericHTMLElement.h"
#include "nsIDOMHTMLTableSectionElem.h"
#include "nsIDOMHTMLTableSectionElement.h"
namespace mozilla {
namespace dom {
@ -15,7 +15,11 @@ class HTMLTableSectionElement : public nsGenericHTMLElement,
public nsIDOMHTMLTableSectionElement
{
public:
HTMLTableSectionElement(already_AddRefed<nsINodeInfo> aNodeInfo);
HTMLTableSectionElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
SetIsDOMBinding();
}
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
@ -32,6 +36,44 @@ public:
// nsIDOMHTMLTableSectionElement
NS_DECL_NSIDOMHTMLTABLESECTIONELEMENT
nsIHTMLCollection* Rows();
already_AddRefed<nsGenericHTMLElement>
InsertRow(int32_t aIndex, ErrorResult& aError);
void DeleteRow(int32_t aValue, ErrorResult& aError);
void GetAlign(nsString& aAlign)
{
GetHTMLAttr(nsGkAtoms::align, aAlign);
}
void SetAlign(const nsAString& aAlign, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
}
void GetCh(nsString& aCh)
{
GetHTMLAttr(nsGkAtoms::_char, aCh);
}
void SetCh(const nsAString& aCh, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::_char, aCh, aError);
}
void GetChOff(nsString& aChOff)
{
GetHTMLAttr(nsGkAtoms::charoff, aChOff);
}
void SetChOff(const nsAString& aChOff, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::charoff, aChOff, aError);
}
void GetVAlign(nsString& aVAlign)
{
GetHTMLAttr(nsGkAtoms::valign, aVAlign);
}
void SetVAlign(const nsAString& aVAlign, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::valign, aVAlign, aError);
}
virtual bool ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
@ -48,6 +90,8 @@ public:
virtual nsIDOMNode* AsDOMNode() { return this; }
protected:
JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap);
nsRefPtr<nsContentList> mRows;
};

View File

@ -64,12 +64,9 @@ function reflectString(aParameters)
input: [ "accept", "alt", "formTarget", "max", "min", "name", "pattern", "placeholder", "step", "defaultValue" ],
link: [ "crossOrigin" ],
source: [ "media" ],
tbody: [ "align", "vAlign", "ch" ],
td: [ "align", "vAlign", "ch" ],
textarea: [ "name", "placeholder" ],
tfoot: [ "align", "vAlign", "ch" ],
th: [ "align", "vAlign", "ch" ],
thead: [ "align", "vAlign", "ch" ],
tr: [ "align", "vAlign", "ch" ],
};
if (!(element.localName in todoAttrs) || todoAttrs[element.localName].indexOf(idlAttr) == -1) {

View File

@ -256,7 +256,7 @@
#include "nsIDOMHTMLTableColElement.h"
#include "nsIDOMHTMLTableElement.h"
#include "nsIDOMHTMLTableRowElement.h"
#include "nsIDOMHTMLTableSectionElem.h"
#include "nsIDOMHTMLTableSectionElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsIDOMHTMLTitleElement.h"
#include "nsIDOMHTMLUListElement.h"

View File

@ -429,6 +429,13 @@ DOMInterfaces = {
]
},
'HTMLTableSectionElement': {
'hasInstanceInterface': 'nsIDOMHTMLTableSectionElement',
'resultNotAddRefed': [
'rows'
]
},
'HTMLUListElement': {
'headerFile' : 'mozilla/dom/HTMLSharedListElement.h'
},
@ -1117,8 +1124,6 @@ addExternalIface('File')
addExternalIface('HitRegionOptions', nativeType='nsISupports')
addExternalIface('HTMLHeadElement', nativeType='mozilla::dom::Element')
addExternalIface('HTMLCanvasElement', nativeType='mozilla::dom::HTMLCanvasElement')
addExternalIface('HTMLTableSectionElement',
headerFile="nsIDOMHTMLTableSectionElem.h")
addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
addExternalIface('LockedFile')

View File

@ -72,7 +72,7 @@ SDK_XPIDLSRCS = \
nsIDOMHTMLTableColElement.idl \
nsIDOMHTMLTableElement.idl \
nsIDOMHTMLTableRowElement.idl \
nsIDOMHTMLTableSectionElem.idl \
nsIDOMHTMLTableSectionElement.idl \
nsIDOMHTMLTextAreaElement.idl \
nsIDOMHTMLTitleElement.idl \
nsIDOMHTMLUListElement.idl \

View File

@ -11,8 +11,6 @@
* and create derivative works of this document.
*/
interface HTMLTableSectionElement;
interface HTMLTableElement : HTMLElement {
attribute HTMLTableCaptionElement? caption;
HTMLElement createCaption();

View File

@ -0,0 +1,33 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
interface HTMLTableSectionElement : HTMLElement {
readonly attribute HTMLCollection rows;
[Throws]
HTMLElement insertRow(optional long index = -1);
[Throws]
void deleteRow(long index);
/*
};
partial interface HTMLTableSectionElement {
*/
[SetterThrows]
attribute DOMString align;
[SetterThrows]
attribute DOMString ch;
[SetterThrows]
attribute DOMString chOff;
[SetterThrows]
attribute DOMString vAlign;
};

View File

@ -75,6 +75,7 @@ webidl_files = \
HTMLSpanElement.webidl \
HTMLTableCaptionElement.webidl \
HTMLTableElement.webidl \
HTMLTableSectionElement.webidl \
HTMLTitleElement.webidl \
HTMLUListElement.webidl \
ImageData.webidl \

View File

@ -195,9 +195,6 @@ members = [
'nsIDOMHTMLTableRowElement.cells',
'nsIDOMHTMLTableRowElement.deleteCell',
'nsIDOMHTMLTableRowElement.insertCell',
'nsIDOMHTMLTableSectionElement.rows',
'nsIDOMHTMLTableSectionElement.insertRow',
'nsIDOMHTMLTableSectionElement.deleteRow',
'nsIDOMHTMLTextAreaElement.rows',
'nsIDOMHTMLTextAreaElement.name',
'nsIDOMHTMLTextAreaElement.form',
@ -316,9 +313,6 @@ members = [
# a little help.
#
irregularFilenames = {
# abbreviations
'nsIDOMHTMLTableSectionElement': 'nsIDOMHTMLTableSectionElem',
# stowaways
'nsIDOMTextMetrics': 'nsIDOMCanvasRenderingContext2D',
'nsIDOMCanvasGradient': 'nsIDOMCanvasRenderingContext2D',