Commit 4e410bd7 authored by hyatt's avatar hyatt
Browse files

Make the delete/InsertRows/Cells methods as well as the rowIndex method

        able to work properly even when whitespace or comment nodes are present.

        Reviewed by aroben

        fast/table/rowindex-comment-nodes.html

        * html/HTMLTableRowElement.cpp:
        (WebCore::HTMLTableRowElement::rowIndex):
        (WebCore::HTMLTableRowElement::insertCell):
        (WebCore::HTMLTableRowElement::deleteCell):
        * html/HTMLTableSectionElement.cpp:
        (WebCore::HTMLTableSectionElement::insertRow):
        (WebCore::HTMLTableSectionElement::deleteRow):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21698 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c1f254d0
2007-05-23 David Hyatt <hyatt@apple.com>
Make the delete/InsertRows/Cells methods as well as the rowIndex method
able to work properly even when whitespace or comment nodes are present.
Reviewed by aroben
fast/table/rowindex-comment-nodes.html
* html/HTMLTableRowElement.cpp:
(WebCore::HTMLTableRowElement::rowIndex):
(WebCore::HTMLTableRowElement::insertCell):
(WebCore::HTMLTableRowElement::deleteCell):
* html/HTMLTableSectionElement.cpp:
(WebCore::HTMLTableSectionElement::insertRow):
(WebCore::HTMLTableSectionElement::deleteRow):
2007-05-23 David Hyatt <hyatt@apple.com>
 
<optgroup> should allow <script> and text nodes inside it, just like
......@@ -83,7 +83,8 @@ int HTMLTableRowElement::rowIndex() const
for (Node *row = head->firstChild(); row; row = row->nextSibling()) {
if (row == this)
return rIndex;
++rIndex;
if (row->hasTagName(trTag))
++rIndex;
}
}
......@@ -93,7 +94,8 @@ int HTMLTableRowElement::rowIndex() const
for (Node* row = section->firstChild(); row; row = row->nextSibling()) {
if (row == this)
return rIndex;
++rIndex;
if (row->hasTagName(trTag))
++rIndex;
}
}
}
......@@ -102,7 +104,8 @@ int HTMLTableRowElement::rowIndex() const
for (Node *row = foot->firstChild(); row; row = row->nextSibling()) {
if (row == this)
return rIndex;
++rIndex;
if (row->hasTagName(trTag))
++rIndex;
}
}
......@@ -124,10 +127,10 @@ int HTMLTableRowElement::sectionRowIndex() const
return rIndex;
}
HTMLElement *HTMLTableRowElement::insertCell( int index, ExceptionCode& ec)
HTMLElement *HTMLTableRowElement::insertCell(int index, ExceptionCode& ec)
{
HTMLTableCellElement *c = 0L;
RefPtr<NodeList> children = childNodes();
RefPtr<HTMLCollection> children = cells();
int numCells = children ? children->length() : 0;
if ( index < -1 || index > numCells )
ec = INDEX_SIZE_ERR; // per the DOM
......@@ -148,15 +151,15 @@ HTMLElement *HTMLTableRowElement::insertCell( int index, ExceptionCode& ec)
return c;
}
void HTMLTableRowElement::deleteCell( int index, ExceptionCode& ec)
void HTMLTableRowElement::deleteCell(int index, ExceptionCode& ec)
{
RefPtr<NodeList> children = childNodes();
RefPtr<HTMLCollection> children = cells();
int numCells = children ? children->length() : 0;
if (index == -1 )
if (index == -1)
index = numCells-1;
if (index >= 0 && index < numCells) {
RefPtr<Node> row = children->item(index);
HTMLElement::removeChild(row.get(), ec);
RefPtr<Node> cell = children->item(index);
HTMLElement::removeChild(cell.get(), ec);
} else
ec = INDEX_SIZE_ERR;
}
......
......@@ -77,7 +77,7 @@ CSSMutableStyleDeclaration* HTMLTableSectionElement::additionalAttributeStyleDec
PassRefPtr<HTMLElement> HTMLTableSectionElement::insertRow(int index, ExceptionCode& ec)
{
RefPtr<HTMLTableRowElement> r;
RefPtr<NodeList> children = childNodes();
RefPtr<HTMLCollection> children = rows();
int numRows = children ? (int)children->length() : 0;
if (index < -1 || index > numRows)
ec = INDEX_SIZE_ERR; // per the DOM
......@@ -99,7 +99,7 @@ PassRefPtr<HTMLElement> HTMLTableSectionElement::insertRow(int index, ExceptionC
void HTMLTableSectionElement::deleteRow( int index, ExceptionCode& ec)
{
RefPtr<NodeList> children = childNodes();
RefPtr<HTMLCollection> children = rows();
int numRows = children ? (int)children->length() : 0;
if (index == -1)
index = numRows - 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment