From f57a128396f924ad42fe7084a6eaafec562eda7d Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Thu, 10 Jun 2010 13:05:31 +0300 Subject: [PATCH] Bug 568975 - m-c message manager slowed down event handling a bit, r=jst --HG-- extra : rebase_source : 33a1b10f31760b69a565645f43062f872b136b98 --- dom/base/nsGlobalWindow.cpp | 22 ++++++++++++++-------- dom/base/nsPIDOMWindow.h | 4 ++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 3339aa80b007..e98491a77dbd 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -943,6 +943,7 @@ nsGlobalWindow::CleanUp(PRBool aIgnoreModalDialog) mContext = nsnull; // Forces Release } mChromeEventHandler = nsnull; // Forces Release + mParentTarget = nsnull; nsGlobalWindow *inner = GetCurrentInnerWindowInternal(); @@ -1197,6 +1198,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsGlobalWindow) // Traverse stuff from nsPIDOMWindow NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mChromeEventHandler) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mParentTarget) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDocument) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFrameElement) @@ -1230,6 +1232,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow) // Unlink stuff from nsPIDOMWindow NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChromeEventHandler) + NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mParentTarget) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDocument) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFrameElement) @@ -2399,16 +2402,19 @@ nsGlobalWindow::PreHandleEvent(nsEventChainPreVisitor& aVisitor) } } - nsPIDOMEventTarget* chromeTarget = mChromeEventHandler; - nsCOMPtr flo = do_QueryInterface(mChromeEventHandler); - if (flo) { - nsRefPtr fl = flo->GetFrameLoader(); - if (fl) { - nsPIDOMEventTarget* t = fl->GetTabChildGlobalAsEventTarget(); - chromeTarget = t ? t : chromeTarget; + if (!mParentTarget) { + nsCOMPtr flo = do_QueryInterface(mChromeEventHandler); + if (flo) { + nsRefPtr fl = flo->GetFrameLoader(); + if (fl) { + mParentTarget = fl->GetTabChildGlobalAsEventTarget(); + } + } + if (!mParentTarget) { + mParentTarget = mChromeEventHandler; } } - aVisitor.mParentTarget = chromeTarget; + aVisitor.mParentTarget = mParentTarget; return NS_OK; } diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index 1da70c4ad7bb..5b20edca6717 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -524,6 +524,8 @@ protected: void SetChromeEventHandlerInternal(nsPIDOMEventTarget* aChromeEventHandler) { mChromeEventHandler = aChromeEventHandler; + // mParentTarget will be set when the next event is dispatched. + mParentTarget = nsnull; } // These two variables are special in that they're set to the same @@ -532,6 +534,8 @@ protected: nsCOMPtr mChromeEventHandler; // strong nsCOMPtr mDocument; // strong + nsCOMPtr mParentTarget; // strong + // These members are only used on outer windows. nsCOMPtr mFrameElement; nsIDocShell *mDocShell; // Weak Reference