Changeset 207640 in webkit


Ignore:
Timestamp:
Oct 20, 2016 2:00:54 PM (8 years ago)
Author:
Chris Dumez
Message:

Make table.deleteRow(-1) a no-op when there are no rows
https://bugs.webkit.org/show_bug.cgi?id=163746

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Import test coverage from:

  • web-platform-tests/html/semantics/tabular-data/the-table-element/remove-row-expected.txt:
  • web-platform-tests/html/semantics/tabular-data/the-table-element/remove-row.html:
  • web-platform-tests/html/semantics/tabular-data/the-tbody-element/deleteRow-expected.txt:
  • web-platform-tests/html/semantics/tabular-data/the-tbody-element/deleteRow.html:
  • web-platform-tests/html/semantics/tabular-data/the-tr-element/deleteCell-expected.txt:
  • web-platform-tests/html/semantics/tabular-data/the-tr-element/deleteCell.html:

Source/WebCore:

Make table.deleteRow(-1) a no-op when there are no rows, instead of throwing:

This is more consistent with the behavior of tbody.deleteRow(-1) and
tr.deleteCell(-1). This is also consistent with Gecko. Blink is doing the
same change via:

No new tests, updated existing tests.

  • html/HTMLTableElement.cpp:

(WebCore::HTMLTableElement::deleteRow):

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r207573 r207640  
     12016-10-20  Chris Dumez  <cdumez@apple.com>
     2
     3        Make table.deleteRow(-1) a no-op when there are no rows
     4        https://bugs.webkit.org/show_bug.cgi?id=163746
     5
     6        Reviewed by Alex Christensen.
     7
     8        Import test coverage from:
     9        - https://github.com/w3c/web-platform-tests/pull/4001
     10
     11        * web-platform-tests/html/semantics/tabular-data/the-table-element/remove-row-expected.txt:
     12        * web-platform-tests/html/semantics/tabular-data/the-table-element/remove-row.html:
     13        * web-platform-tests/html/semantics/tabular-data/the-tbody-element/deleteRow-expected.txt:
     14        * web-platform-tests/html/semantics/tabular-data/the-tbody-element/deleteRow.html:
     15        * web-platform-tests/html/semantics/tabular-data/the-tr-element/deleteCell-expected.txt:
     16        * web-platform-tests/html/semantics/tabular-data/the-tr-element/deleteCell.html:
     17
    1182016-10-19  Dean Jackson  <dino@apple.com>
    219
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/the-table-element/remove-row-expected.txt

    r204079 r207640  
    1 First column    Second column
    21
    32PASS deleteRow function invalid argument
     
    54PASS check normal deleteRow
    65PASS check normal deleteRow bis
     6PASS deleteRow(-1) with no rows
     7PASS deleteRow(0) with no rows
    78
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/the-table-element/remove-row.html

    r204079 r207640  
    4343}, "check normal deleteRow");
    4444test(function() {
    45   while (el.rows.length > 1) {
     45  assert_equals(el.rows.length, 3);
     46  do {
     47    var old_length = el.rows.length;
    4648    el.deleteRow(-1);
    47   }
    48   assert_equals(1, el.rows.length);
     49    assert_equals(el.rows.length, old_length - 1);
     50  } while (el.rows.length);
    4951}, "check normal deleteRow bis");
     52
     53test(function() {
     54  assert_equals(el.rows.length, 0);
     55  el.deleteRow(-1);
     56}, 'deleteRow(-1) with no rows');
     57
     58test(function() {
     59  assert_equals(el.rows.length, 0);
     60  assert_throws("IndexSizeError", function() {
     61    el.deleteRow(0);
     62  });
     63}, 'deleteRow(0) with no rows');
    5064</script>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/the-tbody-element/deleteRow-expected.txt

    r202952 r207640  
    55PASS HTMLTableSectionElement deleteRow(-2)
    66PASS HTMLTableSectionElement deleteRow(-1) with no rows
     7PASS HTMLTableSectionElement deleteRow(0) with no rows
    78
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/the-tbody-element/deleteRow.html

    r194580 r207640  
    5252}, "HTMLTableSectionElement deleteRow(-1) with no rows");
    5353
     54test(function () {
     55  assert_equals(tbody.rows.length, 0);
     56  assert_throws("IndexSizeError", function () {
     57    tbody.deleteRow(0);
     58  });
     59}, "HTMLTableSectionElement deleteRow(0) with no rows");
     60
    5461</script>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/the-tr-element/deleteCell-expected.txt

    r202952 r207640  
    55PASS HTMLTableRowElement deleteCell(cells.length)
    66PASS HTMLTableRowElement deleteCell(-1) with no cells
     7PASS HTMLTableRowElement deleteCell(0) with no cells
    78
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/the-tr-element/deleteCell.html

    r194580 r207640  
    5252}, "HTMLTableRowElement deleteCell(-1) with no cells");
    5353
     54test(function () {
     55  assert_equals(tr.cells.length, 0);
     56  assert_throws("IndexSizeError", function () {
     57    tr.deleteCell(0);
     58  });
     59}, "HTMLTableRowElement deleteCell(0) with no cells");
     60
    5461</script>
  • trunk/Source/WebCore/ChangeLog

    r207638 r207640  
     12016-10-20  Chris Dumez  <cdumez@apple.com>
     2
     3        Make table.deleteRow(-1) a no-op when there are no rows
     4        https://bugs.webkit.org/show_bug.cgi?id=163746
     5
     6        Reviewed by Alex Christensen.
     7
     8        Make table.deleteRow(-1) a no-op when there are no rows, instead of throwing:
     9        - https://github.com/whatwg/html/pull/1924
     10
     11        This is more consistent with the behavior of tbody.deleteRow(-1) and
     12        tr.deleteCell(-1). This is also consistent with Gecko. Blink is doing the
     13        same change via:
     14        - https://codereview.chromium.org/2427963004/
     15
     16        No new tests, updated existing tests.
     17
     18        * html/HTMLTableElement.cpp:
     19        (WebCore::HTMLTableElement::deleteRow):
     20
    1212016-10-20  Dave Hyatt  <hyatt@apple.com>
    222
  • trunk/Source/WebCore/html/HTMLTableElement.cpp

    r207458 r207640  
    251251{
    252252    HTMLTableRowElement* row = nullptr;
    253     if (index == -1)
     253    if (index == -1) {
    254254        row = HTMLTableRowsCollection::lastRow(*this);
    255     else {
     255        if (!row)
     256            return;
     257    } else {
    256258        for (int i = 0; i <= index; ++i) {
    257259            row = HTMLTableRowsCollection::rowAfter(*this, row);
     
    259261                break;
    260262        }
    261     }
    262     if (!row) {
    263         ec = INDEX_SIZE_ERR;
    264         return;
     263        if (!row) {
     264            ec = INDEX_SIZE_ERR;
     265            return;
     266        }
    265267    }
    266268    row->remove(ec);
Note: See TracChangeset for help on using the changeset viewer.