Bug 396652, gecko scrolls on activate event (mouse click) with gtk embeds, r+sr+a=roc, p=iainnicol-mozbugs2007@yahoo.co.uk+me

This commit is contained in:
Olli.Pettay%helsinki.fi 2007-09-22 15:57:03 +00:00
Родитель 734a028d81
Коммит 327addc38a
3 изменённых файлов: 40 добавлений и 26 удалений

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

@ -1091,13 +1091,14 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
win->GetRootFocusController();
nsCOMPtr<nsIDOMElement> focusedElement;
nsCOMPtr<nsIDOMWindowInternal> focusedWindow;
nsFocusScrollSuppressor scrollSuppressor;
if (focusController) {
// Obtain focus info from the focus controller.
focusController->GetFocusedWindow(getter_AddRefs(focusedWindow));
focusController->GetFocusedElement(getter_AddRefs(focusedElement));
focusController->SetSuppressFocusScroll(PR_TRUE);
scrollSuppressor.Init(focusController);
focusController->SetActive(PR_TRUE);
}
@ -1151,7 +1152,6 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
focusController->GetSuppressFocus(&isSuppressed);
}
focusController->SetSuppressFocusScroll(PR_FALSE);
}
}
break;
@ -3197,13 +3197,9 @@ nsEventStateManager::ChangeFocusWith(nsIContent* aFocusContent,
// If this is called from mouse event, we lock to scroll.
// Because the part of element is always in view. See bug 105894.
PRBool suppressFocusScroll =
focusController && (aFocusedWith == eEventFocusedByMouse);
if (suppressFocusScroll) {
PRBool currentState = PR_FALSE;
focusController->GetSuppressFocusScroll(&currentState);
NS_ASSERTION(!currentState, "locked scroll already!");
focusController->SetSuppressFocusScroll(PR_TRUE);
nsFocusScrollSuppressor scrollSuppressor;
if (aFocusedWith == eEventFocusedByMouse) {
scrollSuppressor.Init(focusController);
}
aFocusContent->SetFocus(mPresContext);
@ -3225,11 +3221,6 @@ nsEventStateManager::ChangeFocusWith(nsIContent* aFocusContent,
}
}
}
// Unlock scroll
if (suppressFocusScroll)
focusController->SetSuppressFocusScroll(PR_FALSE);
return NS_OK;
}

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

@ -294,23 +294,13 @@ nsXULPopupListener::FireFocusOnTargetContent(nsIDOMNode* aTargetNode)
if (focusableContent) {
// Lock to scroll by SetFocus. See bug 309075.
nsCOMPtr<nsIFocusController> focusController = nsnull;
PRBool isAlreadySuppressed = PR_FALSE;
nsFocusScrollSuppressor scrollSuppressor;
nsPIDOMWindow *ourWindow = doc->GetWindow();
if (ourWindow) {
focusController = ourWindow->GetRootFocusController();
if (focusController) {
focusController->GetSuppressFocusScroll(&isAlreadySuppressed);
if (!isAlreadySuppressed)
focusController->SetSuppressFocusScroll(PR_TRUE);
}
scrollSuppressor.Init(ourWindow->GetRootFocusController());
}
focusableContent->SetFocus(context);
// Unlock scroll if it's needed.
if (focusController && !isAlreadySuppressed)
focusController->SetSuppressFocusScroll(PR_FALSE);
} else if (!suppressBlur)
esm->SetContentState(nsnull, NS_EVENT_STATE_FOCUS);

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

@ -130,4 +130,37 @@ private:
const char *mReason;
};
class nsFocusScrollSuppressor
{
public:
nsFocusScrollSuppressor(nsIFocusController* aController = nsnull)
: mWasSuppressed(PR_FALSE)
{
Init(aController);
}
~nsFocusScrollSuppressor()
{
Init(nsnull);
}
void Init(nsIFocusController* aController)
{
if (mController) {
mController->SetSuppressFocusScroll(mWasSuppressed);
}
mController = aController;
if (mController) {
mController->GetSuppressFocusScroll(&mWasSuppressed);
if (!mWasSuppressed) {
mController->SetSuppressFocusScroll(PR_TRUE);
}
}
}
private:
nsCOMPtr<nsIFocusController> mController;
PRBool mWasSuppressed;
};
#endif // nsIFocusController_h__