Skip to content
Snippets Groups Projects
Commit 9adb53b9 authored by Masayuki Nakano's avatar Masayuki Nakano
Browse files

Bug 1773848 - Make the for-loop in the lambda in...

Bug 1773848 - Make the for-loop in the lambda in `HTMLEditor::InsertTableRowsWithTransaction` refer only `cellDataInLastRow` r=m_kato a=RyanVM

It's renamed from `CellData`, but `cellData` still exists in the wider scope.
https://searchfox.org/mozilla-central/rev/f6a2ef2f028b8f1eb82fa5dc5cb1e39a3baa8feb/editor/libeditor/HTMLTableEditor.cpp#923-924

Therefore, these lines are wrong:
https://searchfox.org/mozilla-central/rev/f6a2ef2f028b8f1eb82fa5dc5cb1e39a3baa8feb/editor/libeditor/HTMLTableEditor.cpp#1049,1053

because `cellData` was in the for-loop:
https://searchfox.org/mozilla-central/rev/bc4493c72442ad55aecf6b575edb0df4ed18b113/editor/libeditor/HTMLTableEditor.cpp#1008-1009,1020,1022,1026

Differential Revision: https://phabricator.services.mozilla.com/D152144
parent 62e277df
No related branches found
No related tags found
No related merge requests found
......@@ -1046,11 +1046,11 @@ nsresult HTMLEditor::InsertTableRowsWithTransaction(
MOZ_ASSERT(numberOfCellsInStartRow >=
cellDataInLastRow.mEffectiveColSpan);
numberOfCellsInStartRow -= cellDataInLastRow.mEffectiveColSpan;
} else if (colIndex < cellData.mCurrent.mColumn) {
} else if (colIndex < cellDataInLastRow.mCurrent.mColumn) {
offsetInTRElementToPutCaret++;
}
MOZ_ASSERT(colIndex < cellDataInLastRow.NextColumnIndex());
colIndex = cellData.NextColumnIndex();
colIndex = cellDataInLastRow.NextColumnIndex();
}
return TableRowData{nullptr, numberOfCellsInStartRow,
offsetInTRElementToPutCaret};
......
......@@ -373,6 +373,48 @@ SimpleTest.waitForFocus(() => {
"when selection is collapsed in a cell whose row follows a text node (testInsertAfterRowFollowedTextNode)"
);
})();
(function testInsertAfterLastRow() {
selection.removeAllRanges();
editor.innerHTML =
"<table>" +
"<tr><td>cell1-1</td><td>cell1-2</td></tr>" +
'<tr><td id="select">cell2-1</td><td>cell2-2</td></tr>' +
"</table>";
editor.focus();
beforeInputEvents = [];
inputEvents = [];
selection.collapse(document.getElementById("select").firstChild, 0);
getTableEditor().insertTableRow(1, true);
is(
editor.innerHTML,
"<table><tbody>" +
"<tr><td>cell1-1</td><td>cell1-2</td></tr>" +
'<tr><td id="select">cell2-1</td><td>cell2-2</td></tr>' +
'<tr><td valign="top"><br></td><td valign="top"><br></td></tr>' +
"</tbody></table>",
"testInsertAfterLastRow: nsITableEditor.insertTableRow(1, true) should insert a row after the last row"
);
is(
beforeInputEvents.length,
1,
'testInsertAfterLastRow: Only one "beforeinput" event should be fired'
);
checkInputEvent(
beforeInputEvents[0],
"when selection is collapsed in a cell whose row follows a text node (testInsertAfterLastRow)"
);
is(
inputEvents.length,
1,
'testInsertAfterLastRow: Only one "input" event should be fired'
);
checkInputEvent(
inputEvents[0],
"when selection is collapsed in a cell whose row follows a text node (testInsertAfterLastRow)"
);
})();
editor.removeEventListener("beforeinput", onBeforeInput);
editor.removeEventListener("input", onInput);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment