Fix for bug 135345, have input element check its own focus state before attempting to set focus to itself to avoid possible recursion inside onfocus handlers. r:jkeiser, sr:jst

This commit is contained in:
joki%netscape.com 2002-04-15 23:29:15 +00:00
Родитель b1c96aac9a
Коммит dc9ac75b02
1 изменённых файлов: 8 добавлений и 1 удалений

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

@ -1087,7 +1087,14 @@ nsHTMLInputElement::Select()
if (status == nsEventStatus_eIgnore) { if (status == nsEventStatus_eIgnore) {
nsCOMPtr<nsIEventStateManager> esm; nsCOMPtr<nsIEventStateManager> esm;
if (NS_OK == presContext->GetEventStateManager(getter_AddRefs(esm))) { if (NS_OK == presContext->GetEventStateManager(getter_AddRefs(esm))) {
esm->SetContentState(this, NS_EVENT_STATE_FOCUS); PRInt32 currentState;
//XXX Fix for bug 135345 - ESM currently does not check to see if we have
//focus before attempting to set focus again and may cause infinite recursion.
//For now check if we have focus and do not set focus again if already focused.
esm->GetContentState(this, currentState);
if (!(currentState & NS_EVENT_STATE_FOCUS)) {
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
}
} }
nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE);