Bug 695623 - xul:browser is subject of focus event when tabbing from chrome to content process, r=davidb, olli.pettay

This commit is contained in:
Alexander Surkov 2011-10-26 15:42:20 +09:00
Родитель 0c46b073ba
Коммит 5c182f0204
3 изменённых файлов: 23 добавлений и 21 удалений

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

@ -41,6 +41,7 @@
#include "nsAccUtils.h"
#include "nsRootAccessible.h"
#include "nsEventStateManager.h"
#include "nsFocusManager.h"
namespace dom = mozilla::dom;
@ -352,18 +353,22 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
}
}
nsIContent*
FocusManager::FocusedDOMElm() const
nsINode*
FocusManager::FocusedDOMNode() const
{
nsFocusManager* DOMFocusManager = nsFocusManager::GetFocusManager();
return DOMFocusManager->GetFocusedContent();
}
nsIContent* focusedElm = DOMFocusManager->GetFocusedContent();
nsIDocument*
FocusManager::FocusedDOMDocument() const
{
nsFocusManager* DOMFocusManager = nsFocusManager::GetFocusManager();
// No focus on remote target elements like xul:browser having DOM focus and
// residing in chrome process because it means an element in content process
// keeps the focus.
if (focusedElm) {
if (nsEventStateManager::IsRemoteTarget(focusedElm))
return nsnull;
return focusedElm;
}
// Otherwise the focus can be on DOM document.
nsCOMPtr<nsIDOMWindow> focusedWnd;
DOMFocusManager->GetFocusedWindow(getter_AddRefs(focusedWnd));
if (focusedWnd) {
@ -374,3 +379,10 @@ FocusManager::FocusedDOMDocument() const
}
return nsnull;
}
nsIDocument*
FocusManager::FocusedDOMDocument() const
{
nsINode* focusedNode = FocusedDOMNode();
return focusedNode ? focusedNode->OwnerDoc() : nsnull;
}

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

@ -146,18 +146,7 @@ private:
/**
* Return DOM node having DOM focus.
*/
inline nsINode* FocusedDOMNode() const
{
nsINode* focusedNode = FocusedDOMElm();
if (focusedNode)
return focusedNode;
return FocusedDOMDocument();
}
/**
* Return DOM element having DOM focus.
*/
nsIContent* FocusedDOMElm() const;
nsINode* FocusedDOMNode() const;
/**
* Return DOM document having DOM focus.

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

@ -228,6 +228,8 @@ public:
// Sets the full-screen event state on aElement to aIsFullScreen.
static void SetFullScreenState(mozilla::dom::Element* aElement, bool aIsFullScreen);
static bool IsRemoteTarget(nsIContent* aTarget);
protected:
friend class MouseEnterLeaveDispatcher;
@ -465,7 +467,6 @@ protected:
bool IsTargetCrossProcess(nsGUIEvent *aEvent);
void DispatchCrossProcessEvent(nsEvent* aEvent, nsIFrameLoader* remote);
bool IsRemoteTarget(nsIContent* target);
bool HandleCrossProcessEvent(nsEvent *aEvent,
nsIFrame* aTargetFrame,
nsEventStatus *aStatus);