gecko-dev/layout/base/tests/bug989012-2-ref.html
Ehsan Akhgari 4d42b88e0b Bug 989012 - Part 1: Stop after passing over a non-selectable frame if one is found during the frame traversal; r=roc
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.
2015-01-27 23:11:26 -05:00

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>