layout/reftests/table-dom/tableDom.js

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

michael@0 1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 var count = 1;
michael@0 7 function genName(prefix) {
michael@0 8 return "X" + count++ + "\n";
michael@0 9 }
michael@0 10
michael@0 11 function appendCell(aRow, aRowSpan, aColSpan) {
michael@0 12 var cell = document.createElement("TD", null);
michael@0 13 cell.rowSpan = aRowSpan;
michael@0 14 cell.colSpan = aColSpan;
michael@0 15 var text = document.createTextNode(genName());
michael@0 16 cell.appendChild(text);
michael@0 17 aRow.appendChild(cell);
michael@0 18 }
michael@0 19
michael@0 20 function appendCellAt(aRowIndex, aRowSpan, aColSpan) {
michael@0 21 var row = document.getElementsByTagName("TR")[aRowIndex];
michael@0 22 appendCell(row, aRowSpan, aColSpan);
michael@0 23 }
michael@0 24
michael@0 25 function insertCell(aRow, aColIndex, aRowSpan, aColSpan) {
michael@0 26 var cells = aRow.cells;
michael@0 27 var refCell = cells.item(aColIndex);
michael@0 28 var newCell = document.createElement("TD", null);
michael@0 29 newCell.rowSpan = aRowSpan;
michael@0 30 newCell.colSpan = aColSpan;
michael@0 31 var text = document.createTextNode(genName());
michael@0 32 newCell.appendChild(text);
michael@0 33 aRow.insertBefore(newCell, refCell);
michael@0 34 //dump("SCRIPT: inserted CELL as first cell in first row\n");
michael@0 35 }
michael@0 36
michael@0 37 function insertCellAt(aRowIndex, aColIndex, aRowSpan, aColSpan) {
michael@0 38 var row = document.getElementsByTagName("TR")[aRowIndex];
michael@0 39 insertCell(row, aColIndex, aRowSpan, aColSpan);
michael@0 40 }
michael@0 41
michael@0 42 function deleteCell(aRow, aColIndex) {
michael@0 43 aRow.deleteCell(aColIndex);
michael@0 44 }
michael@0 45
michael@0 46 function deleteCellAt(aRowIndex, aColIndex) {
michael@0 47 var row = document.getElementsByTagName("TR")[aRowIndex];
michael@0 48 deleteCell(row, aColIndex);
michael@0 49 }
michael@0 50
michael@0 51 //function appendRow(aRowGroup) {
michael@0 52 // var row = document.createElement("TR", null);
michael@0 53 // cell = document.createElement("TD", null);
michael@0 54 // row.appendChild(cell);
michael@0 55 // aRowGroup.appendChild(row);
michael@0 56 //}
michael@0 57
michael@0 58 function appendRow(aRowGroup) {
michael@0 59 var row = document.createElement("TR", null);
michael@0 60 cell = document.createElement("TD", null);
michael@0 61 aRowGroup.appendChild(row);
michael@0 62 //row.appendChild(cell);
michael@0 63 //appendCell(row, 1, 1);
michael@0 64 }
michael@0 65
michael@0 66 function appendRowAt(aRowGroupIndex) {
michael@0 67 var rowGroup = document.getElementsByTagName("TBODY")[aRowGroupIndex];
michael@0 68 appendRow(rowGroup);
michael@0 69 }
michael@0 70
michael@0 71 function insertRow(aRowGroup, aRowIndex) {
michael@0 72 var rows = aRowGroup.rows;
michael@0 73 var refRow = rows.item(aRowIndex);
michael@0 74 var row = document.createElement("TR", null);
michael@0 75 aRowGroup.insertBefore(row, refRow);
michael@0 76 //appendCell(row, 1, 1);
michael@0 77 }
michael@0 78
michael@0 79 function insertRowAt(aRowGroupIndex, aRowIndex) {
michael@0 80 var rowGroup = document.getElementsByTagName("TBODY")[aRowGroupIndex];
michael@0 81 insertRow(rowGroup, aRowIndex);
michael@0 82 }
michael@0 83
michael@0 84 function deleteRow(aRowGroup, aRowIndex) {
michael@0 85 aRowGroup.deleteRow(aRowIndex);
michael@0 86 }
michael@0 87
michael@0 88 function deleteRowAt(aRowGroupIndex, aRowIndex) {
michael@0 89 var row = document.getElementsByTagName("TBODY")[aRowGroupIndex];
michael@0 90 deleteRow(row, aRowIndex);
michael@0 91 }
michael@0 92
michael@0 93 function insertTbody(aTable, aTbodyIndex) {
michael@0 94 var tbodies = aTable.tBodies;
michael@0 95 var refTbody = tbodies.item(aTbodyIndex);
michael@0 96 var tbody = document.createElement("TBODY", null);
michael@0 97 aTable.insertBefore(tbody, refTbody);
michael@0 98 }
michael@0 99
michael@0 100 function insertTbodyAt(aTableIndex, aTbodyIndex) {
michael@0 101 var table = document.getElementsByTagName("TABLE")[aTableIndex];
michael@0 102 insertTbodyAt(table, aTbodyIndex);
michael@0 103 }
michael@0 104
michael@0 105 function deleteTbody(aTable, aTbodyIndex) {
michael@0 106 var tbodies = aTable.tBodies;
michael@0 107 var tbody = tbodies.item(aTbodyIndex);
michael@0 108 aTable.removeChild(tbody);
michael@0 109 }
michael@0 110
michael@0 111 function deleteTbodyAt(aTableIndex, aTbodyIndex) {
michael@0 112 var table = document.getElementsByTagName("TABLE")[aTableIndex];
michael@0 113 deleteTbody(table, aTbodyIndex);
michael@0 114 }
michael@0 115
michael@0 116 function buildTable(aNumRows, aNumCols) {
michael@0 117 var table = document.getElementsByTagName("TABLE")[0];
michael@0 118 for (rowX = 0; rowX < aNumRows; rowX++) {
michael@0 119 var row = document.createElement("TR", null);
michael@0 120 for (colX = 0; colX < aNumCols; colX++) {
michael@0 121 var cell = document.createElement("TD", null);
michael@0 122 var text = document.createTextNode(genName());
michael@0 123 cell.appendChild(text);
michael@0 124 row.appendChild(cell);
michael@0 125 }
michael@0 126 table.appendChild(row);
michael@0 127 }
michael@0 128 }
michael@0 129

mercurial