Bug 644428 - Position the caret correctly for empty inline frames; r=roc

This commit is contained in:
Ehsan Akhgari 2011-03-28 20:17:16 -04:00
Родитель d6e1aafc64
Коммит 3813265288
6 изменённых файлов: 59 добавлений и 1 удалений

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

@ -138,6 +138,8 @@ _TEST_FILES = \
bug632215-ref.html \
bug633044-1.html \
bug633044-1-ref.html \
bug644428-1.html \
bug644428-1-ref.html \
test_bug514127.html \
test_bug518777.html \
test_bug548545.xhtml \

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

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
</head>
<body onload="setupCaret()">
<div contenteditable>a</div>
<script>
function setupCaret() {
var div = document.querySelector("div");
div.focus();
var sel = window.getSelection();
sel.collapse(div, 1);
}
</script>
</body>
</html>

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

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
</head>
<body onload="setupCaret()" spellcheck="false">
<div contenteditable>a<span>b</span>c </div>
<script>
function setupCaret() {
var div = document.querySelector("div");
div.focus();
var sel = window.getSelection();
sel.collapse(div, 3);
synthesizeKey("VK_BACK_SPACE", {});
synthesizeKey("VK_BACK_SPACE", {});
}
</script>
</body>
</html>

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

@ -121,7 +121,8 @@ var tests = [
[ 'bug613807-1.html' , 'bug613807-1-ref.html' ] ,
[ 'bug632215-1.html' , 'bug632215-ref.html' ] ,
[ 'bug632215-2.html' , 'bug632215-ref.html' ] ,
[ 'bug633044-1.html' , 'bug633044-1-ref.html' ]
[ 'bug633044-1.html' , 'bug633044-1-ref.html' ] ,
[ 'bug644428-1.html' , 'bug644428-1-ref.html' ]
];
var testIndex = 0;

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

@ -922,6 +922,22 @@ nsInlineFrame::GetBaseline() const
return ascent + GetUsedBorderAndPadding().top;
}
nscoord
nsInlineFrame::GetCaretBaseline() const
{
nscoord baseline;
if (mRect.height == 0) {
// Empty inline frames will be pushed down in the line, so we need to
// account for that here.
baseline = 0;
} else {
baseline = GetBaseline();
NS_ASSERTION(baseline <= mRect.height,
"We should never hit a case where our height is non-zero but smaller than the caret baseline...");
}
return baseline;
}
#ifdef ACCESSIBILITY
already_AddRefed<nsAccessible>
nsInlineFrame::CreateAccessible()

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

@ -119,6 +119,7 @@ public:
virtual void PullOverflowsFromPrevInFlow();
virtual nscoord GetBaseline() const;
virtual nscoord GetCaretBaseline() const;
/**
* Return true if the frame is leftmost frame or continuation.