mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
4d42b88e0b
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>
|