mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 570510 - Reduce Addref/release/QI during event creation, r=jst
--HG-- extra : rebase_source : 9857313cb6d51044ba4869d87e1ad57ec7c2cba3
This commit is contained in:
parent
653fb105c5
commit
37fd1014e5
@ -140,9 +140,9 @@ nsDOMEvent::nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent)
|
||||
|
||||
// Get the explicit original target (if it's anonymous make it null)
|
||||
{
|
||||
mExplicitOriginalTarget = GetTargetFromFrame();
|
||||
mTmpRealOriginalTarget = mExplicitOriginalTarget;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mExplicitOriginalTarget);
|
||||
nsCOMPtr<nsIContent> content = GetTargetFromFrame();
|
||||
mTmpRealOriginalTarget = do_QueryInterface(content);
|
||||
mExplicitOriginalTarget = mTmpRealOriginalTarget;
|
||||
if (content && content->IsInAnonymousSubtree()) {
|
||||
mExplicitOriginalTarget = nsnull;
|
||||
}
|
||||
@ -199,7 +199,9 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMEvent)
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mPresContext);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTmpRealOriginalTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mExplicitOriginalTarget)
|
||||
// Always set mExplicitOriginalTarget to null, when
|
||||
// mTmpRealOriginalTarget doesn't point to any object!
|
||||
tmp->mExplicitOriginalTarget = nsnull;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEvent)
|
||||
@ -234,7 +236,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEvent)
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mPresContext.get(), nsPresContext)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTmpRealOriginalTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mExplicitOriginalTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
// nsIDOMEventInterface
|
||||
@ -288,7 +289,7 @@ nsDOMEvent::GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget)
|
||||
//
|
||||
// Get the actual event target node (may have been retargeted for mouse events)
|
||||
//
|
||||
already_AddRefed<nsIDOMEventTarget>
|
||||
already_AddRefed<nsIContent>
|
||||
nsDOMEvent::GetTargetFromFrame()
|
||||
{
|
||||
if (!mPresContext) { return nsnull; }
|
||||
@ -301,12 +302,7 @@ nsDOMEvent::GetTargetFromFrame()
|
||||
// get the real content
|
||||
nsCOMPtr<nsIContent> realEventContent;
|
||||
targetFrame->GetContentForEvent(mPresContext, mEvent, getter_AddRefs(realEventContent));
|
||||
if (!realEventContent) { return nsnull; }
|
||||
|
||||
// Finally, we have the real content. QI it and return.
|
||||
nsIDOMEventTarget* target = nsnull;
|
||||
CallQueryInterface(realEventContent, &target);
|
||||
return target;
|
||||
return realEventContent.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -206,13 +206,13 @@ protected:
|
||||
|
||||
// Internal helper functions
|
||||
nsresult SetEventType(const nsAString& aEventTypeArg);
|
||||
already_AddRefed<nsIDOMEventTarget> GetTargetFromFrame();
|
||||
already_AddRefed<nsIContent> GetTargetFromFrame();
|
||||
nsresult ReportWrongPropertyAccessWarning(const char* aPropertyName);
|
||||
|
||||
nsEvent* mEvent;
|
||||
nsRefPtr<nsPresContext> mPresContext;
|
||||
nsCOMPtr<nsIDOMEventTarget> mTmpRealOriginalTarget;
|
||||
nsCOMPtr<nsIDOMEventTarget> mExplicitOriginalTarget;
|
||||
nsIDOMEventTarget* mExplicitOriginalTarget;
|
||||
nsString mCachedType;
|
||||
PRPackedBool mEventIsInternal;
|
||||
PRPackedBool mPrivateDataDuplicated;
|
||||
|
Loading…
Reference in New Issue
Block a user