forked from LadybirdBrowser/ladybird
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Fix "incorrect behavior on select()" LadybirdBrowser#1446
This patch resolves the problem outlined in issue LadybirdBrowser#1446, where the cursor_position node could be substituted with any other existing node by the mousedown event. Previously, if this new node was not equal to m_text_node, the function would return prematurely without updating the selection. With this fix, we ensure that the selection is properly updated in such cases, rather than simply exiting the function.
- Loading branch information
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
Tests/LibWeb/Text/input/DOM/range-bounding-client-rect-with-display-contents.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,44 @@ | ||
<!--refer to https://wpt.live/css/cssom-view/range-bounding-client-rect-with-display-contents.html --> | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Include display:contents elements recursively when calculating bounding rect for a ranges</title> | ||
<script src="../include.js"></script> | ||
<div id="container"> | ||
<div id="spacerBefore">spacer before</div> | ||
<div style="display:contents" id="parent"> | ||
<div style="height:30px; background:lightblue" id="first"> | ||
HEIGHT: 30px | ||
</div> | ||
<div style="display:contents" id="second"> | ||
<div style="display:contents"> | ||
<div style="height:30px; background:lightblue"> | ||
HEIGHT: 30px | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div id="spacerAfter">spacer after</div> | ||
</div> | ||
<script> | ||
test(function () { | ||
const spacerBefore = document.getElementById("spacerBefore"); | ||
const spacerAfter = document.getElementById("spacerAfter"); | ||
|
||
const expected = spacerAfter.getBoundingClientRect().top - spacerBefore.getBoundingClientRect().bottom; | ||
|
||
const rangeBetweenSpacers = document.createRange(); | ||
rangeBetweenSpacers.setStartAfter(spacerBefore); | ||
rangeBetweenSpacers.setEndBefore(spacerAfter); | ||
|
||
let rects = rangeBetweenSpacers.getClientRects(); | ||
console.log(rects); | ||
|
||
const actual = rangeBetweenSpacers.getBoundingClientRect().height; | ||
|
||
console.log(expected); | ||
console.log(actual); | ||
|
||
println(actual > 0); | ||
println(expected == actual); | ||
}) | ||
</script> |
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