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

Unified Diff: third_party/WebKit/Source/core/html/HTMLTableRowElement.cpp

Issue 2406423004: Change deleteCell behavior when there are no cells (Closed)
Patch Set: Fix comment for step 1 Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/LayoutTests/imported/wpt/html/semantics/tabular-data/the-tr-element/deleteCell-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLTableRowElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLTableRowElement.cpp b/third_party/WebKit/Source/core/html/HTMLTableRowElement.cpp
index 3a86b11717625760f3789adeb987a9e283a7ca37..1202573468891ae8b59ed578afd8816919d92ca1 100644
--- a/third_party/WebKit/Source/core/html/HTMLTableRowElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLTableRowElement.cpp
@@ -114,17 +114,25 @@ void HTMLTableRowElement::deleteCell(int index,
ExceptionState& exceptionState) {
HTMLCollection* children = cells();
int numCells = children ? children->length() : 0;
- if (index == -1)
- index = numCells - 1;
- if (index >= 0 && index < numCells) {
- Element* cell = children->item(index);
- HTMLElement::removeChild(cell, exceptionState);
- } else {
+ // 1. If index is less than −1 or greater than or equal to the number of
+ // elements in the cells collection, then throw "IndexSizeError".
+ if (index < -1 || index >= numCells) {
exceptionState.throwDOMException(
IndexSizeError, "The value provided (" + String::number(index) +
") is outside the range [0, " +
String::number(numCells) + ").");
+ return;
+ }
+ // 2. If index is −1, remove the last element in the cells collection
+ // from its parent, or do nothing if the cells collection is empty.
+ if (index == -1) {
+ if (numCells == 0)
+ return;
+ index = numCells - 1;
}
+ // 3. Remove the indexth element in the cells collection from its parent.
+ Element* cell = children->item(index);
+ HTMLElement::removeChild(cell, exceptionState);
}
HTMLCollection* HTMLTableRowElement::cells() {
« no previous file with comments | « third_party/WebKit/LayoutTests/imported/wpt/html/semantics/tabular-data/the-tr-element/deleteCell-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698