Bug 446663. Make sure that if the user is typing in a text input its text input listener will get the events (so that undo/redo work and oninput is fired).

This commit is contained in:
Mats Palmgren
2008-07-31 17:34:11 -07:00
parent 88b08d3248
commit e20f76575f
2 changed files with 18 additions and 10 deletions

View File

@@ -135,6 +135,15 @@ static const PRInt32 DEFAULT_UNDO_CAP = 1000;
static nsINativeKeyBindings *sNativeInputBindings = nsnull;
static nsINativeKeyBindings *sNativeTextAreaBindings = nsnull;
static PRBool
IsFocusedContent(nsPresContext* aPresContext, nsIContent* aContent)
{
nsCOMPtr<nsIContent> focusedContent;
aPresContext->EventStateManager()->
GetFocusedContent(getter_AddRefs(focusedContent));
return focusedContent == aContent;
}
static void
PlatformToDOMLineBreaks(nsString &aString)
{
@@ -1387,8 +1396,15 @@ nsTextControlFrame::CalcIntrinsicSize(nsIRenderingContext* aRenderingContext,
return NS_OK;
}
void nsTextControlFrame::PostCreateFrames() {
void
nsTextControlFrame::PostCreateFrames()
{
InitEditor();
// Notify the text listener we have focus and setup the caret etc (bug 446663).
if (IsFocusedContent(PresContext(), GetContent())) {
mTextListener->Focus(nsnull);
SetFocus(PR_TRUE, PR_FALSE);
}
}
nsIFrame*
@@ -1871,15 +1887,6 @@ nsTextControlFrame::IsLeaf() const
return PR_TRUE;
}
static PRBool
IsFocusedContent(nsPresContext* aPresContext, nsIContent* aContent)
{
nsCOMPtr<nsIContent> focusedContent;
aPresContext->EventStateManager()->
GetFocusedContent(getter_AddRefs(focusedContent));
return focusedContent == aContent;
}
//IMPLEMENTING NS_IFORMCONTROLFRAME
void nsTextControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
{