Bug 573689 key events lost while page is loading r=smaug, sr=roc
This commit is contained in:
@@ -97,6 +97,7 @@ class gfxContext;
|
|||||||
class nsIDOMEvent;
|
class nsIDOMEvent;
|
||||||
class nsDisplayList;
|
class nsDisplayList;
|
||||||
class nsDisplayListBuilder;
|
class nsDisplayListBuilder;
|
||||||
|
class nsPIDOMWindow;
|
||||||
|
|
||||||
typedef short SelectionType;
|
typedef short SelectionType;
|
||||||
typedef PRUint64 nsFrameState;
|
typedef PRUint64 nsFrameState;
|
||||||
@@ -129,8 +130,8 @@ typedef struct CapturingContentInfo {
|
|||||||
} CapturingContentInfo;
|
} CapturingContentInfo;
|
||||||
|
|
||||||
#define NS_IPRESSHELL_IID \
|
#define NS_IPRESSHELL_IID \
|
||||||
{ 0x7ae0e29f, 0x4d2e, 0x4acd, \
|
{ 0x6b32e1ca, 0xb295, 0x406d, \
|
||||||
{ 0xb5, 0x74, 0xb6, 0x40, 0x8a, 0xca, 0xb8, 0x4d } }
|
{ 0xb2, 0x8b, 0x73, 0xda, 0xc3, 0x66, 0xc2, 0xa7 } }
|
||||||
|
|
||||||
// Constants for ScrollContentIntoView() function
|
// Constants for ScrollContentIntoView() function
|
||||||
#define NS_PRESSHELL_SCROLL_TOP 0
|
#define NS_PRESSHELL_SCROLL_TOP 0
|
||||||
@@ -1002,6 +1003,11 @@ public:
|
|||||||
PRUint64 GetPaintCount() { return mPaintCount; }
|
PRUint64 GetPaintCount() { return mPaintCount; }
|
||||||
void IncrementPaintCount() { ++mPaintCount; }
|
void IncrementPaintCount() { ++mPaintCount; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the root DOM window of this presShell.
|
||||||
|
*/
|
||||||
|
virtual already_AddRefed<nsPIDOMWindow> GetRootWindow() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh observer management.
|
* Refresh observer management.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -808,6 +808,8 @@ public:
|
|||||||
nsIntPoint& aPoint,
|
nsIntPoint& aPoint,
|
||||||
nsIntRect* aScreenRect);
|
nsIntRect* aScreenRect);
|
||||||
|
|
||||||
|
virtual already_AddRefed<nsPIDOMWindow> GetRootWindow();
|
||||||
|
|
||||||
//nsIViewObserver interface
|
//nsIViewObserver interface
|
||||||
|
|
||||||
NS_IMETHOD Paint(nsIView* aDisplayRoot,
|
NS_IMETHOD Paint(nsIView* aDisplayRoot,
|
||||||
@@ -1247,6 +1249,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
PRBool InZombieDocument(nsIContent *aContent);
|
PRBool InZombieDocument(nsIContent *aContent);
|
||||||
|
already_AddRefed<nsIPresShell> GetParentPresShell();
|
||||||
nsresult RetargetEventToParent(nsGUIEvent* aEvent,
|
nsresult RetargetEventToParent(nsGUIEvent* aEvent,
|
||||||
nsEventStatus* aEventStatus);
|
nsEventStatus* aEventStatus);
|
||||||
|
|
||||||
@@ -6013,8 +6016,51 @@ PRBool PresShell::InZombieDocument(nsIContent *aContent)
|
|||||||
return !doc || !doc->GetWindow();
|
return !doc || !doc->GetWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult PresShell::RetargetEventToParent(nsGUIEvent* aEvent,
|
already_AddRefed<nsPIDOMWindow>
|
||||||
nsEventStatus* aEventStatus)
|
PresShell::GetRootWindow()
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsPIDOMWindow> window =
|
||||||
|
do_QueryInterface(mDocument->GetWindow());
|
||||||
|
if (window) {
|
||||||
|
nsCOMPtr<nsPIDOMWindow> rootWindow = window->GetPrivateRoot();
|
||||||
|
NS_ASSERTION(rootWindow, "nsPIDOMWindow::GetPrivateRoot() returns NULL");
|
||||||
|
return rootWindow.forget();
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we don't have DOM window, we're zombie, we should find the root window
|
||||||
|
// with our parent shell.
|
||||||
|
nsCOMPtr<nsIPresShell> parent = GetParentPresShell();
|
||||||
|
NS_ENSURE_TRUE(parent, nsnull);
|
||||||
|
return parent->GetRootWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
already_AddRefed<nsIPresShell>
|
||||||
|
PresShell::GetParentPresShell()
|
||||||
|
{
|
||||||
|
NS_ENSURE_TRUE(mPresContext, nsnull);
|
||||||
|
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
|
||||||
|
if (!container) {
|
||||||
|
container = do_QueryReferent(mForwardingContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now, find the parent pres shell and send the event there
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(container);
|
||||||
|
// Might have gone away, or never been around to start with
|
||||||
|
NS_ENSURE_TRUE(treeItem, nsnull);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
|
||||||
|
treeItem->GetParent(getter_AddRefs(parentTreeItem));
|
||||||
|
nsCOMPtr<nsIDocShell> parentDocShell = do_QueryInterface(parentTreeItem);
|
||||||
|
NS_ENSURE_TRUE(parentDocShell && treeItem != parentTreeItem, nsnull);
|
||||||
|
|
||||||
|
nsIPresShell* parentPresShell = nsnull;
|
||||||
|
parentDocShell->GetPresShell(&parentPresShell);
|
||||||
|
return parentPresShell;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
PresShell::RetargetEventToParent(nsGUIEvent* aEvent,
|
||||||
|
nsEventStatus* aEventStatus)
|
||||||
{
|
{
|
||||||
// Send this events straight up to the parent pres shell.
|
// Send this events straight up to the parent pres shell.
|
||||||
// We do this for keystroke events in zombie documents or if either a frame
|
// We do this for keystroke events in zombie documents or if either a frame
|
||||||
@@ -6022,28 +6068,8 @@ nsresult PresShell::RetargetEventToParent(nsGUIEvent* aEvent,
|
|||||||
// That way at least the UI key bindings can work.
|
// That way at least the UI key bindings can work.
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
|
nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
|
||||||
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
|
nsCOMPtr<nsIPresShell> parentPresShell = GetParentPresShell();
|
||||||
if (!container)
|
NS_ENSURE_TRUE(parentPresShell, NS_ERROR_FAILURE);
|
||||||
container = do_QueryReferent(mForwardingContainer);
|
|
||||||
|
|
||||||
// Now, find the parent pres shell and send the event there
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> treeItem =
|
|
||||||
do_QueryInterface(container);
|
|
||||||
if (!treeItem) {
|
|
||||||
// Might have gone away, or never been around to start with
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
|
|
||||||
treeItem->GetParent(getter_AddRefs(parentTreeItem));
|
|
||||||
nsCOMPtr<nsIDocShell> parentDocShell =
|
|
||||||
do_QueryInterface(parentTreeItem);
|
|
||||||
if (!parentDocShell || treeItem == parentTreeItem) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> parentPresShell;
|
|
||||||
parentDocShell->GetPresShell(getter_AddRefs(parentPresShell));
|
|
||||||
nsCOMPtr<nsIViewObserver> parentViewObserver =
|
nsCOMPtr<nsIViewObserver> parentViewObserver =
|
||||||
do_QueryInterface(parentPresShell);
|
do_QueryInterface(parentPresShell);
|
||||||
if (!parentViewObserver) {
|
if (!parentViewObserver) {
|
||||||
@@ -6069,11 +6095,7 @@ PresShell::DisableNonTestMouseEvents(PRBool aDisable)
|
|||||||
already_AddRefed<nsPIDOMWindow>
|
already_AddRefed<nsPIDOMWindow>
|
||||||
PresShell::GetFocusedDOMWindowInOurWindow()
|
PresShell::GetFocusedDOMWindowInOurWindow()
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsPIDOMWindow> window =
|
nsCOMPtr<nsPIDOMWindow> rootWindow = GetRootWindow();
|
||||||
do_QueryInterface(mDocument->GetWindow());
|
|
||||||
NS_ENSURE_TRUE(window, nsnull);
|
|
||||||
|
|
||||||
nsCOMPtr<nsPIDOMWindow> rootWindow = window->GetPrivateRoot();
|
|
||||||
NS_ENSURE_TRUE(rootWindow, nsnull);
|
NS_ENSURE_TRUE(rootWindow, nsnull);
|
||||||
nsPIDOMWindow* focusedWindow;
|
nsPIDOMWindow* focusedWindow;
|
||||||
nsFocusManager::GetFocusedDescendant(rootWindow, PR_TRUE, &focusedWindow);
|
nsFocusManager::GetFocusedDescendant(rootWindow, PR_TRUE, &focusedWindow);
|
||||||
|
|||||||
Reference in New Issue
Block a user