Bug 794623 - Fewer virtual GetTargetForEventTargetChain calls, r=jst
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Fri, 28 Sep 2012 02:15:29 +0300
changeset 108463 895f66c4eadacee626cb0af56e009920fa64be23
parent 108462 bd2349429495a48b29b0eeefa4d1de21333b8cb4
child 108464 7fffa1ef35d926fb1961dc0c0b274aa79309ca95
push id15528
push useremorley@mozilla.com
push dateFri, 28 Sep 2012 15:01:34 +0000
treeherdermozilla-inbound@7d4e659d6fbf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs794623
milestone18.0a1
first release with
nightly linux32
895f66c4eada / 18.0a1 / 20120928030544 / files
nightly linux64
895f66c4eada / 18.0a1 / 20120928030544 / files
nightly mac
895f66c4eada / 18.0a1 / 20120928030544 / files
nightly win32
895f66c4eada / 18.0a1 / 20120928030544 / files
nightly win64
895f66c4eada / 18.0a1 / 20120928030544 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 794623 - Fewer virtual GetTargetForEventTargetChain calls, r=jst
content/base/src/nsDocument.cpp
content/events/src/nsEventDispatcher.cpp
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -6394,17 +6394,18 @@ nsDocument::PreHandleEvent(nsEventChainP
   aVisitor.mCanHandle = true;
    // FIXME! This is a hack to make middle mouse paste working also in Editor.
    // Bug 329119
   aVisitor.mForceContentDispatch = true;
 
   // Load events must not propagate to |window| object, see bug 335251.
   if (aVisitor.mEvent->message != NS_LOAD) {
     nsGlobalWindow* window = static_cast<nsGlobalWindow*>(GetWindow());
-    aVisitor.mParentTarget = static_cast<nsIDOMEventTarget*>(window);
+    aVisitor.mParentTarget =
+      window ? window->GetTargetForEventTargetChain() : nullptr;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::CreateEvent(const nsAString& aEventType, nsIDOMEvent** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -221,19 +221,19 @@ public:
   static uint32_t                   sCurrentEtciCount;
 };
 
 uint32_t nsEventTargetChainItem::sMaxEtciCount = 0;
 uint32_t nsEventTargetChainItem::sCurrentEtciCount = 0;
 
 nsEventTargetChainItem::nsEventTargetChainItem(nsIDOMEventTarget* aTarget,
                                                nsEventTargetChainItem* aChild)
-: mChild(aChild), mParent(nullptr), mFlags(0), mItemFlags(0)
+: mTarget(aTarget), mChild(aChild), mParent(nullptr), mFlags(0), mItemFlags(0)
 {
-  mTarget = aTarget->GetTargetForEventTargetChain();
+  MOZ_ASSERT(!aTarget || mTarget == aTarget->GetTargetForEventTargetChain());
   if (mChild) {
     mChild->mParent = this;
   }
 
   if (++sCurrentEtciCount > sMaxEtciCount) {
     sMaxEtciCount = sCurrentEtciCount;
   }
 }
@@ -528,17 +528,18 @@ nsEventDispatcher::Dispatch(nsISupports*
   // If we have a PresContext, make sure it doesn't die before
   // event dispatching is finished.
   nsRefPtr<nsPresContext> kungFuDeathGrip(aPresContext);
   ChainItemPool pool;
   NS_ENSURE_TRUE(pool.GetPool(), NS_ERROR_OUT_OF_MEMORY);
 
   // Create the event target chain item for the event target.
   nsEventTargetChainItem* targetEtci =
-    nsEventTargetChainItem::Create(pool.GetPool(), target);
+    nsEventTargetChainItem::Create(pool.GetPool(),
+                                   target->GetTargetForEventTargetChain());
   NS_ENSURE_TRUE(targetEtci, NS_ERROR_OUT_OF_MEMORY);
   if (!targetEtci->IsValid()) {
     nsEventTargetChainItem::Destroy(pool.GetPool(), targetEtci);
     return NS_ERROR_FAILURE;
   }
 
   // Make sure that nsIDOMEvent::target and nsIDOMEvent::originalTarget
   // point to the last item in the chain.