Index: Source/core/html/HTMLTableSectionElement.cpp |
diff --git a/Source/core/html/HTMLTableSectionElement.cpp b/Source/core/html/HTMLTableSectionElement.cpp |
index 1820cabd68610e8b98c517202f4d83df74098afb..30af275fb286ad5abe094adbc35317c2e21e542d 100644 |
--- a/Source/core/html/HTMLTableSectionElement.cpp |
+++ b/Source/core/html/HTMLTableSectionElement.cpp |
@@ -55,27 +55,29 @@ const StylePropertySet* HTMLTableSectionElement::additionalPresentationAttribute |
return 0; |
} |
+PassRefPtr<HTMLElement> HTMLTableSectionElement::insertRow(ExceptionState& exceptionState) |
+{ |
+ // The default 'index' argument value is -1. |
+ return insertRow(-1, exceptionState); |
+} |
+ |
// these functions are rather slow, since we need to get the row at |
// the index... but they aren't used during usual HTML parsing anyway |
PassRefPtr<HTMLElement> HTMLTableSectionElement::insertRow(int index, ExceptionState& exceptionState) |
{ |
- RefPtr<HTMLTableRowElement> row; |
RefPtr<HTMLCollection> children = rows(); |
- int numRows = children ? (int)children->length() : 0; |
+ int numRows = children ? static_cast<int>(children->length()) : 0; |
if (index < -1 || index > numRows) { |
eseidel
2014/05/05 15:33:42
Lame that indicies don't work like python here. :)
|
exceptionState.throwDOMException(IndexSizeError, "The provided index (" + String::number(index) + " is outside the range [-1, " + String::number(numRows) + "]."); |
+ return nullptr; |
+ } |
+ |
+ RefPtr<HTMLTableRowElement> row = HTMLTableRowElement::create(document()); |
+ if (numRows == index || index == -1) { |
+ appendChild(row, exceptionState); |
} else { |
- row = HTMLTableRowElement::create(document()); |
- if (numRows == index || index == -1) |
- appendChild(row, exceptionState); |
- else { |
- Node* n; |
- if (index < 1) |
- n = firstChild(); |
- else |
- n = children->item(index); |
- insertBefore(row, n, exceptionState); |
- } |
+ Node* n = index ? children->item(index) : firstChild(); |
arv (Not doing code reviews)
2014/05/06 17:53:42
fistChild does not seem right here. It should be f
Inactive
2014/05/06 17:57:54
Oh, I thought this looked weird as well when I ref
Inactive
2014/05/06 18:55:45
Yes, I confirmed we behave differently thatn Firef
|
+ insertBefore(row, n, exceptionState); |
} |
return row.release(); |
} |