Bug 989012 - Part 2: Don't get stuck when seeing an image without a src or alt attribute; r=roc

We do not want to traverse inside native anonymous elements, but we
should still be able to skip over generated content, to avoid getting
stuck on such images.
This commit is contained in:
Ehsan Akhgari 2015-01-15 11:59:13 -05:00
Родитель 4d42b88e0b
Коммит cdf636c674
5 изменённых файлов: 66 добавлений и 2 удалений

Просмотреть файл

@ -0,0 +1,28 @@
<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>
img {
border: solid 1px red;
mid-width: 1em;
display: inline-block;
}
</style>
</head>
<body onload="start()">
<div onfocus="done()" contenteditable>foo<img>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>

Просмотреть файл

@ -0,0 +1,31 @@
<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>
img {
border: solid 1px red;
mid-width: 1em;
display: inline-block;
}
</style>
</head>
<body onload="start()">
<div onfocus="done()" contenteditable>foo<img>bar</div>
<script>
var div = document.querySelector("div");
function start() {
div.focus();
}
function done() {
var sel = getSelection();
sel.collapse(div, 0);
// Press Right four times to set the caret right before "bar"
for (var i = 0; i < 4; ++i) {
synthesizeKey("VK_RIGHT", {});
}
document.documentElement.removeAttribute("class");
}
</script>
</body>
</html>

Просмотреть файл

@ -57,6 +57,8 @@ support-files =
bug989012-1-ref.html
bug989012-2.html
bug989012-2-ref.html
bug989012-3.html
bug989012-3-ref.html
bug1061468.html
bug1061468-ref.html
bug1109968-1-ref.html

Просмотреть файл

@ -109,6 +109,7 @@ var tests = [
[ 'bug613807-1.html' , 'bug613807-1-ref.html' ] ,
[ 'bug989012-1.html' , 'bug989012-1-ref.html' ] ,
[ 'bug989012-2.html' , 'bug989012-2-ref.html' ] ,
[ 'bug989012-3.html' , 'bug989012-3-ref.html' ] ,
[ 'bug1082486-1.html', 'bug1082486-1-ref.html'] ,
[ 'bug1082486-2.html', 'bug1082486-2-ref.html'] ,
// The following test cases are all involving with one sending

Просмотреть файл

@ -7046,10 +7046,12 @@ nsIFrame::GetFrameFromDirection(nsDirection aDirection, bool aVisual,
traversedFrame = frameTraversal->CurrentItem();
// Skip anonymous elements
// Skip anonymous elements, but watch out for generated content
if (!traversedFrame ||
traversedFrame->GetContent()->IsRootOfNativeAnonymousSubtree())
(!traversedFrame->IsGeneratedContentFrame() &&
traversedFrame->GetContent()->IsRootOfNativeAnonymousSubtree())) {
return NS_ERROR_FAILURE;
}
traversedFrame->IsSelectable(&selectable, nullptr);
if (!selectable) {