Backing out. Doh! I have approval but I only wanted to check this into the trunk at first, for testing.
git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@177854 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -847,6 +847,14 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||
|
||||
if (focusController) {
|
||||
|
||||
// Make sure the focus controller is up-to-date, since restoring
|
||||
// focus memory may have caused focus to go elsewhere.
|
||||
|
||||
if (gLastFocusedDocument && gLastFocusedDocument == mDocument) {
|
||||
nsCOMPtr<nsIDOMElement> focusElement = do_QueryInterface(mCurrentFocus);
|
||||
focusController->SetFocusedElement(focusElement);
|
||||
}
|
||||
|
||||
PRBool isSuppressed;
|
||||
focusController->GetSuppressFocus(&isSuppressed);
|
||||
while (isSuppressed) {
|
||||
@@ -857,14 +865,6 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||
focusController->GetSuppressFocus(&isSuppressed);
|
||||
}
|
||||
focusController->SetSuppressFocusScroll(PR_FALSE);
|
||||
|
||||
// Make sure the focus controller is up-to-date, since restoring
|
||||
// focus memory may have caused focus to go elsewhere.
|
||||
|
||||
if (gLastFocusedDocument && gLastFocusedDocument == mDocument) {
|
||||
nsCOMPtr<nsIDOMElement> focusElement = do_QueryInterface(mCurrentFocus);
|
||||
focusController->SetFocusedElement(focusElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -3892,20 +3892,6 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState)
|
||||
// only raise window if the the focus controller is active
|
||||
SendFocusBlur(mPresContext, aContent, fcActive);
|
||||
|
||||
#ifdef DEBUG_aleventhal
|
||||
nsCOMPtr<nsPIDOMWindow> currentWindow =
|
||||
do_QueryInterface(GetDocumentOuterWindow(mDocument));
|
||||
if (currentWindow) {
|
||||
nsIFocusController *fc = currentWindow->GetRootFocusController();
|
||||
if (fc) {
|
||||
nsCOMPtr<nsIDOMElement> focusedElement;
|
||||
fc->GetFocusedElement(getter_AddRefs(focusedElement));
|
||||
if (!SameCOMIdentity(mCurrentFocus, focusedElement)) {
|
||||
printf("\n\nFocus out of whack!!!\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// If we now have focused content, ensure that the canvas focus ring
|
||||
// is removed.
|
||||
if (mDocument) {
|
||||
@@ -4113,6 +4099,23 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
|
||||
|
||||
EnsureDocument(presShell);
|
||||
|
||||
// Make sure we're not switching command dispatchers, if so,
|
||||
// surpress the blurred one
|
||||
if(gLastFocusedDocument && mDocument) {
|
||||
nsIFocusController *newFocusController = nsnull;
|
||||
nsIFocusController *oldFocusController = nsnull;
|
||||
nsCOMPtr<nsPIDOMWindow> newWindow =
|
||||
do_QueryInterface(GetDocumentOuterWindow(mDocument));
|
||||
nsCOMPtr<nsPIDOMWindow> oldWindow =
|
||||
do_QueryInterface(GetDocumentOuterWindow(gLastFocusedDocument));
|
||||
if(newWindow)
|
||||
newFocusController = newWindow->GetRootFocusController();
|
||||
if(oldWindow)
|
||||
oldFocusController = oldWindow->GetRootFocusController();
|
||||
if(oldFocusController && oldFocusController != newFocusController)
|
||||
oldFocusController->SetSuppressFocus(PR_TRUE, "SendFocusBlur Window Switch");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEventStateManager> esm;
|
||||
esm = oldPresContext->EventStateManager();
|
||||
esm->SetFocusedContent(gLastFocusedContent);
|
||||
@@ -4136,7 +4139,6 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
|
||||
if (previousFocus && previousFocus != focusAfterBlur) {
|
||||
// The content node's blur handler focused something else.
|
||||
// In this case, abort firing any more blur or focus events.
|
||||
EnsureFocusSynchronization();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
@@ -4153,6 +4155,23 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event(PR_TRUE, NS_BLUR_CONTENT);
|
||||
|
||||
// Make sure we're not switching command dispatchers, if so,
|
||||
// surpress the blurred one
|
||||
if (mDocument) {
|
||||
nsIFocusController *newFocusController = nsnull;
|
||||
nsIFocusController *oldFocusController = nsnull;
|
||||
nsCOMPtr<nsPIDOMWindow> newWindow =
|
||||
do_QueryInterface(GetDocumentOuterWindow(mDocument));
|
||||
nsCOMPtr<nsPIDOMWindow> oldWindow =
|
||||
do_QueryInterface(GetDocumentOuterWindow(gLastFocusedDocument));
|
||||
|
||||
if (newWindow)
|
||||
newFocusController = newWindow->GetRootFocusController();
|
||||
oldFocusController = oldWindow->GetRootFocusController();
|
||||
if (oldFocusController && oldFocusController != newFocusController)
|
||||
oldFocusController->SetSuppressFocus(PR_TRUE, "SendFocusBlur Window Switch #2");
|
||||
}
|
||||
|
||||
gLastFocusedPresContext->EventStateManager()->SetFocusedContent(nsnull);
|
||||
nsCOMPtr<nsIDocument> temp = gLastFocusedDocument;
|
||||
NS_RELEASE(gLastFocusedDocument);
|
||||
@@ -4164,10 +4183,7 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
|
||||
|
||||
if (previousFocus && mCurrentFocus != previousFocus) {
|
||||
// The document's blur handler focused something else.
|
||||
// Abort firing any additional blur or focus events, and make sure
|
||||
// nsFocusController:mFocusedElement is not nulled out, but agrees
|
||||
// with our current concept of focus.
|
||||
EnsureFocusSynchronization();
|
||||
// Abort firing any additional blur or focus events.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -4177,7 +4193,6 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
|
||||
if (previousFocus && mCurrentFocus != previousFocus) {
|
||||
// The window's blur handler focused something else.
|
||||
// Abort firing any additional blur or focus events.
|
||||
EnsureFocusSynchronization();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
@@ -4268,27 +4283,6 @@ nsEventStateManager::GetFocusedContent(nsIContent** aContent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsEventStateManager::EnsureFocusSynchronization()
|
||||
{
|
||||
// Sometimes the focus can get out of whack due to a blur handler
|
||||
// resetting focus. In addition, we fire onchange from the blur handler
|
||||
// for some controls, which is another place where focus can be changed.
|
||||
// XXX Ideally we will eventually store focus in one place instead of
|
||||
// the focus controller, esm, tabbrowser and some frames, so that it
|
||||
// cannot get out of sync.
|
||||
// See Bug 304751, calling FireOnChange() inside
|
||||
// nsComboboxControlFrame::SetFocus() is bad
|
||||
nsCOMPtr<nsPIDOMWindow> currentWindow =
|
||||
do_QueryInterface(GetDocumentOuterWindow(mDocument));
|
||||
if (currentWindow) {
|
||||
nsIFocusController *fc = currentWindow->GetRootFocusController();
|
||||
if (fc) {
|
||||
nsCOMPtr<nsIDOMElement> focusedElement = do_QueryInterface(mCurrentFocus);
|
||||
fc->SetFocusedElement(focusedElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventStateManager::SetFocusedContent(nsIContent* aContent)
|
||||
{
|
||||
|
||||
@@ -162,14 +162,6 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* In certain situations the focus controller's concept of focus gets out of
|
||||
* whack with mCurrentFocus. This is used in known cases to reset the focus
|
||||
* controller's focus. At some point we should probably move to a single
|
||||
* focus storage mechanism because tracking it in several places is error-prone.
|
||||
*/
|
||||
void EnsureFocusSynchronization();
|
||||
|
||||
void UpdateCursor(nsPresContext* aPresContext, nsEvent* aEvent, nsIFrame* aTargetFrame, nsEventStatus* aStatus);
|
||||
/**
|
||||
* Turn a GUI mouse event into a mouse event targeted at the specified
|
||||
|
||||
@@ -483,15 +483,11 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
|
||||
// on eventWindow. -bryner
|
||||
nsCOMPtr<nsIXULWindow> kungFuDeathGrip(eventWindow);
|
||||
|
||||
focusController->SetSuppressFocus(PR_TRUE, "Activation Suppression");
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> domWindow =
|
||||
do_QueryInterface(piWin);
|
||||
|
||||
if (domWindow == focusedWindow) {
|
||||
break; // Already focused
|
||||
}
|
||||
|
||||
focusController->SetSuppressFocus(PR_TRUE, "Activation Suppression");
|
||||
|
||||
NS_ASSERTION(domWindow,
|
||||
"windows must support nsIDOMWindowInternal");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user