Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(885)

Unified Diff: Source/core/html/HTMLTableSectionElement.cpp

Issue 263193002: HTMLTableSectionElement.insertRow()'s argument default value should be -1 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
}

Powered by Google App Engine
This is Rietveld 408576698