From 403f29b5fdd39be5ce71e32eb7426b6bac72d54d Mon Sep 17 00:00:00 2001 From: "bryner%netscape.com" Date: Mon, 24 Jun 2002 04:16:49 +0000 Subject: [PATCH] Fixing a crash resulting from my checkin for bug 138237. Instead of causing an initial reflow so that we can dispatch the focus event, just update the focus controller's state. r=alexsavulov, sr=blake. git-svn-id: svn://10.0.0.236/trunk@123915 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsPresShell.cpp | 24 ++++++++++++++------ mozilla/layout/html/base/src/nsPresShell.cpp | 24 ++++++++++++++------ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 4fa46d07f3f..80383271bb3 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -5969,14 +5969,24 @@ PresShell::HandleEvent(nsIView *aView, // We really don't want to just drop a focus event on the floor here, // because the widget-level focus change will have already happened - // by the time we get the event. Rather than dropping it, force an - // initial reflow if we haven't done one yet, so that we can process - // the event. + // by the time we get the event. Rather than dropping it, manually + // update the focus controller here. - if (aEvent->message == NS_GOTFOCUS && !mDidInitialReflow && mViewManager) { - nscoord width, height; - mViewManager->GetWindowDimensions(&width, &height); - InitialReflow(width, height); + if (aEvent->message == NS_GOTFOCUS && !mDidInitialReflow && mDocument) { + nsCOMPtr sgo; + mDocument->GetScriptGlobalObject(getter_AddRefs(sgo)); + if (sgo) { + nsCOMPtr pWindow = do_QueryInterface(sgo); + if (pWindow) { + nsCOMPtr controller; + pWindow->GetRootFocusController(getter_AddRefs(controller)); + if (controller) { + nsCOMPtr domWin = do_QueryInterface(sgo); + controller->SetFocusedWindow(domWin); + controller->SetFocusedElement(nsnull); + } + } + } } aView->GetClientData(clientData); diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 4fa46d07f3f..80383271bb3 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -5969,14 +5969,24 @@ PresShell::HandleEvent(nsIView *aView, // We really don't want to just drop a focus event on the floor here, // because the widget-level focus change will have already happened - // by the time we get the event. Rather than dropping it, force an - // initial reflow if we haven't done one yet, so that we can process - // the event. + // by the time we get the event. Rather than dropping it, manually + // update the focus controller here. - if (aEvent->message == NS_GOTFOCUS && !mDidInitialReflow && mViewManager) { - nscoord width, height; - mViewManager->GetWindowDimensions(&width, &height); - InitialReflow(width, height); + if (aEvent->message == NS_GOTFOCUS && !mDidInitialReflow && mDocument) { + nsCOMPtr sgo; + mDocument->GetScriptGlobalObject(getter_AddRefs(sgo)); + if (sgo) { + nsCOMPtr pWindow = do_QueryInterface(sgo); + if (pWindow) { + nsCOMPtr controller; + pWindow->GetRootFocusController(getter_AddRefs(controller)); + if (controller) { + nsCOMPtr domWin = do_QueryInterface(sgo); + controller->SetFocusedWindow(domWin); + controller->SetFocusedElement(nsnull); + } + } + } } aView->GetClientData(clientData);