Update the caret after creating a new frame, if the node has focus. b=536421 r=ehsan a=blocking2.0:final

This commit is contained in:
Mats Palmgren 2010-10-11 00:07:01 +02:00
parent d0a2a35c8c
commit d000a22403
6 changed files with 122 additions and 1 deletions

View File

@ -311,7 +311,7 @@ nsEditor::PostCreate()
NotifyDocumentListeners(eDocumentCreated);
NotifyDocumentListeners(eDocumentStateChanged);
// update nsTextStateManager if we have focus
// update nsTextStateManager and caret if we have focus
if (HasFocus()) {
nsFocusManager* fm = nsFocusManager::GetFocusManager();
NS_ASSERTION(fm, "no focus manager?");
@ -324,6 +324,11 @@ nsEditor::PostCreate()
nsIMEStateManager::OnTextStateBlur(pc, nsnull);
nsIMEStateManager::OnTextStateFocus(pc, focusedContent);
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(focusedContent);
if (target) {
InitializeSelection(target);
}
}
}
return NS_OK;

View File

@ -0,0 +1,28 @@
<!DOCTYPE HTML>
<html class="reftest-wait">
<head>
<title>bug 536421</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
input { border:1px solid blue; }
</style>
</head>
<body onload="doTest()">
<input value="test" id="textbox" onfocus="triggerBug();" type="text">
<script type="text/javascript">
function finishTest()
{
document.documentElement.removeAttribute("class");
}
function triggerBug()
{
finishTest();
}
function doTest()
{
var t = document.getElementById("textbox");
t.focus();
}
</script>
</body>
</html>

View File

@ -0,0 +1,32 @@
<!DOCTYPE HTML>
<html class="reftest-wait">
<head>
<title>bug 536421</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
input { border:1px solid blue; }
</style>
</head>
<body onload="doTest()">
<input value="test" id="textbox" onfocus="triggerBug();" type="text">
<script type="text/javascript">
function finishTest()
{
document.documentElement.removeAttribute("class");
}
function triggerBug()
{
var t = document.getElementById("textbox");
t.style.display = "none";
document.body.offsetWidth;
t.style.display = "";
finishTest();
}
function doTest()
{
var t = document.getElementById("textbox");
t.focus();
}
</script>
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html class="reftest-wait">
<head>
<title>bug 536421</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body onload="doTest()">
<input value="test" id="textbox" onfocus="triggerBug();" type="text">
<script type="text/javascript">
function finishTest()
{
document.documentElement.removeAttribute("class");
}
function triggerBug()
{
finishTest();
}
function doTest()
{
var t = document.getElementById("textbox");
t.focus();
}
</script>
</body>
</html>

View File

@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html class="reftest-wait">
<head>
<title>bug 536421</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body onload="doTest()">
<input value="test" id="textbox" onfocus="triggerBug();" type="text">
<script type="text/javascript">
function finishTest()
{
document.documentElement.removeAttribute("class");
}
function triggerBug()
{
var t = document.getElementById("textbox");
t.style.display = "none";
document.body.offsetWidth;
t.style.display = "";
finishTest();
}
function doTest()
{
var t = document.getElementById("textbox");
t.focus();
}
</script>
</body>
</html>

View File

@ -19,3 +19,5 @@ include xul/reftest.list
== caret_on_positioned.html caret_on_positioned-ref.html
== spellcheck-1.html spellcheck-ref.html
!= caret_on_textarea_lastline.html caret_on_textarea_lastline-ref.html
== input-text-onfocus-reframe.html input-text-onfocus-reframe-ref.html
== input-text-notheme-onfocus-reframe.html input-text-notheme-onfocus-reframe-ref.html