The code that checked to see whether it should explicitly set focus on the gfx's containing widget

now uget the new focused content's frame instead of using the mCurrentTarget. The mCurrentTarget
is correct for a mouse down but incorrect for a "tab". This is because the mCurrentTarget points at
the currently focused content for a tab event, instead of the new content.
r=joki, bug 11162
This commit is contained in:
rods%netscape.com 1999-10-19 21:57:43 +00:00
Родитель caab8220a0
Коммит a915909a72
2 изменённых файлов: 28 добавлений и 10 удалений

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

@ -1529,12 +1529,21 @@ nsEventStateManager::SendFocusBlur(nsIContent *aContent)
mCurrentTabIndex = val;
}
// Check to see if the mCurrentTarget has a view with a widget
nsIFrame * currentFocusFrame = nsnull;
nsCOMPtr<nsIPresShell> shell;
if (mPresContext) {
nsresult rv = mPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell){
shell->GetPrimaryFrameFor(aContent, &currentFocusFrame);
}
}
// Check to see if the newly focused content's frame has a view with a widget
// i.e TextField or TextArea, if so, don't set the focus on their window
PRBool shouldSetFocusOnWindow = PR_TRUE;
if (nsnull != mCurrentTarget) {
if (nsnull != currentFocusFrame) {
nsIView * view = nsnull;
mCurrentTarget->GetView(&view);
currentFocusFrame->GetView(&view);
if (view != nsnull) {
nsIWidget *window = nsnull;
view->GetWidget(window);
@ -1552,9 +1561,9 @@ nsEventStateManager::SendFocusBlur(nsIContent *aContent)
// so some windows may get multiple focus events
// For example, if you clicked in the window (generates focus event)
// then click on a gfx control (generates another focus event)
if (shouldSetFocusOnWindow && nsnull != mCurrentTarget) {
if (shouldSetFocusOnWindow && nsnull != currentFocusFrame) {
nsIFrame * parentFrame;
mCurrentTarget->GetParentWithView(&parentFrame);
currentFocusFrame->GetParentWithView(&parentFrame);
if (nsnull != parentFrame) {
nsIView * pView;
parentFrame->GetView(&pView);

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

@ -1529,12 +1529,21 @@ nsEventStateManager::SendFocusBlur(nsIContent *aContent)
mCurrentTabIndex = val;
}
// Check to see if the mCurrentTarget has a view with a widget
nsIFrame * currentFocusFrame = nsnull;
nsCOMPtr<nsIPresShell> shell;
if (mPresContext) {
nsresult rv = mPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell){
shell->GetPrimaryFrameFor(aContent, &currentFocusFrame);
}
}
// Check to see if the newly focused content's frame has a view with a widget
// i.e TextField or TextArea, if so, don't set the focus on their window
PRBool shouldSetFocusOnWindow = PR_TRUE;
if (nsnull != mCurrentTarget) {
if (nsnull != currentFocusFrame) {
nsIView * view = nsnull;
mCurrentTarget->GetView(&view);
currentFocusFrame->GetView(&view);
if (view != nsnull) {
nsIWidget *window = nsnull;
view->GetWidget(window);
@ -1552,9 +1561,9 @@ nsEventStateManager::SendFocusBlur(nsIContent *aContent)
// so some windows may get multiple focus events
// For example, if you clicked in the window (generates focus event)
// then click on a gfx control (generates another focus event)
if (shouldSetFocusOnWindow && nsnull != mCurrentTarget) {
if (shouldSetFocusOnWindow && nsnull != currentFocusFrame) {
nsIFrame * parentFrame;
mCurrentTarget->GetParentWithView(&parentFrame);
currentFocusFrame->GetParentWithView(&parentFrame);
if (nsnull != parentFrame) {
nsIView * pView;
parentFrame->GetView(&pView);