Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Elements in a table are incorrectly selected in JavaScript.
https://bugs.webkit.org/show_bug.cgi?id=220607 Reviewed by Wenson Hsieh. Source/WebCore: After the fix for https://bugs.webkit.org/show_bug.cgi?id=130844 in https://trac.webkit.org/changeset/260207/webkit a regression was found for table cell selections through JavaScript. The previous fix was for an issue in the difference between how PositionIterator and Position calculated if it was canonical (::isCandidate) in the cases where the renderer was a BR. Instead of only converging isCandidate for BR, this function in PositionIterator was completely subsumed by just calling the implementation for Position. While there are many similarities, there are important differences, especially in the table code, therefore PositionIterator::isCandidate is being reinstated, but with the convergence in the BR case only. Also, moved the check added in http://webkit.org/b/211864 so it will cover cases that were missed due to this code being wrong while that fix was added. Test: editing/selection/editable-table-cell-selection.html * dom/PositionIterator.cpp: (WebCore::PositionIterator::isCandidate const): * editing/InsertParagraphSeparatorCommand.cpp: (WebCore::InsertParagraphSeparatorCommand::doApply): LayoutTests: * editing/execCommand/null_calc_primitive_value_for_css_property.html: Added ending tag that was missing and does not affect the issue the test was verifying. * editing/inserting/insert-list-in-table-cell-07-expected.txt: Restored expected text file to original output. * editing/selection/editable-table-cell-selection-expected.txt: Added. * editing/selection/editable-table-cell-selection.html: Added. Canonical link: https://commits.webkit.org/233161@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271635 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
8d2c409
commit a1fd940
Showing
8 changed files
with
209 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
</script> | ||
|
||
<body onload=cssPrimitiveValTest()> | ||
<ins id="x"> | ||
<ins id="x"></ins> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
LayoutTests/editing/selection/editable-table-cell-selection-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
A B C D | ||
1A 1B 1C 1D | ||
2A 2B 2C 2D | ||
3A 3B 3C 3D | ||
4A 4B 4C 4D | ||
5A 5B 5C 5D | ||
PASS: Correctly Selects row in thead | ||
PASS: Correctly Selects last cell in thead | ||
PASS: Correctly Selects row in tbody | ||
PASS: Correctly Selects last cell in tbody | ||
|
122 changes: 122 additions & 0 deletions
122
LayoutTests/editing/selection/editable-table-cell-selection.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<!DOCTYPE html> | ||
|
||
<html> | ||
<head> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.waitUntilDone(); | ||
} | ||
|
||
async function runTest() | ||
{ | ||
var output = ''; | ||
|
||
function select(element) { | ||
const range = document.createRange(); | ||
|
||
range.setStartBefore(element); | ||
range.setEndAfter(element); | ||
|
||
const selection = window.getSelection(); | ||
|
||
selection.removeAllRanges(); | ||
selection.addRange(range); | ||
} | ||
|
||
select(document.querySelector('thead tr')); | ||
if (document.getSelection().toString() == "A\tB\tC\tD\n") | ||
output += 'PASS: Correctly Selects row in thead'; | ||
else | ||
output += 'FAIL: Incorrect Selection: ' + document.getSelection().toString(); | ||
output += '<br>'; | ||
|
||
const lastHeadCell = [ ...document.querySelectorAll('thead th') ].pop(); | ||
select(lastHeadCell); | ||
if (document.getSelection().toString() == "D\n") | ||
output += 'PASS: Correctly Selects last cell in thead'; | ||
else | ||
output += 'FAIL: Incorrect Selection: ' + document.getSelection().toString(); | ||
output += '<br>'; | ||
|
||
select(document.querySelector('tbody tr')); | ||
if (document.getSelection().toString() == "1A\t1B\t1C\t1D\n") | ||
output += 'PASS: Correctly Selects row in tbody'; | ||
else | ||
output += 'FAIL: Incorrect Selection: ' + document.getSelection().toString(); | ||
output += '<br>'; | ||
|
||
const lastBodyCell = [ ...document.querySelectorAll('tbody td') ].pop(); | ||
select(lastBodyCell); | ||
if (document.getSelection().toString() == "5D\n") | ||
output += 'PASS: Correctly Selects last cell in tbody'; | ||
else | ||
output += 'FAIL: Incorrect Selection: ' + document.getSelection().toString(); | ||
output += '<br>'; | ||
|
||
document.getElementById('target').innerHTML = output; | ||
testRunner.notifyDone(); | ||
} | ||
|
||
window.addEventListener('load', runTest, false); | ||
</script> | ||
<style> | ||
#target { | ||
height: 50px; | ||
width: 300px; | ||
background-color: silver; | ||
font-family: monospace; | ||
font-size: 18px; | ||
} | ||
</style> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
<body> | ||
<div contenteditable> | ||
<table border="1"> | ||
<thead> | ||
<tr> | ||
<th scope="col">A</th> | ||
<th scope="col">B</th> | ||
<th scope="col">C</th> | ||
<th scope="col">D</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<th scope="row">1A</th> | ||
<td>1B</td> | ||
<td>1C</td> | ||
<td>1D</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">2A</th> | ||
<td>2B</td> | ||
<td>2C</td> | ||
<td>2D</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">3A</th> | ||
<td>3B</td> | ||
<td>3C</td> | ||
<td>3D</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">4A</th> | ||
<td>4B</td> | ||
<td>4C</td> | ||
<td>4D</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">5A</th> | ||
<td>5B</td> | ||
<td>5C</td> | ||
<td>5D</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
<div id="target"> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters