mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
0cbca8d56b
The caret movement code already handles unselectable text frames if we happen to land in the middle of one in nsTextFrame::PeekOffsetCharacter/Word. However, when performing frame traversal to find the next frame to jump to, we don't remember if we skipped over an unselectable frame, which causes us to jump one offset too much when the caret is on the boundary of selectable and unselectable content. The test cases demonstrate the scenario. Note that an <img alt=foo> is implemented by adding a generated content to the inline frame representing it, so as far as the caret movement code is concerned, both test cases are treated similarly. Note that we need to do this only when moving the selection, and not when extending it. We are adding an aExtend argument to nsPeekOffsetStruct's constructor in order to be able to special case that.
27 lines
730 B
HTML
27 lines
730 B
HTML
<html class="reftest-wait">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
<style>
|
|
span:before {
|
|
content: "IMAGE";
|
|
}
|
|
</style>
|
|
</head>
|
|
<body onload="start()">
|
|
<div onfocus="done()" contenteditable>foo<span></span>bar</div>
|
|
<script>
|
|
var div = document.querySelector("div");
|
|
function start() {
|
|
div.focus();
|
|
}
|
|
function done() {
|
|
var sel = getSelection();
|
|
// Set the caret right before "bar"
|
|
sel.collapse(div.lastChild, 0);
|
|
document.documentElement.removeAttribute("class");
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|