backout Bug 570510

This commit is contained in:
Olli Pettay 2010-06-10 14:25:08 +03:00
parent f8b4e9410c
commit 2da44e699b
2 changed files with 14 additions and 10 deletions

View File

@ -140,9 +140,9 @@ nsDOMEvent::nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent)
// Get the explicit original target (if it's anonymous make it null)
{
nsCOMPtr<nsIContent> content = GetTargetFromFrame();
mTmpRealOriginalTarget = do_QueryInterface(content);
mExplicitOriginalTarget = mTmpRealOriginalTarget;
mExplicitOriginalTarget = GetTargetFromFrame();
mTmpRealOriginalTarget = mExplicitOriginalTarget;
nsCOMPtr<nsIContent> content = do_QueryInterface(mExplicitOriginalTarget);
if (content && content->IsInAnonymousSubtree()) {
mExplicitOriginalTarget = nsnull;
}
@ -199,9 +199,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMEvent)
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mPresContext);
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTmpRealOriginalTarget)
// Always set mExplicitOriginalTarget to null, when
// mTmpRealOriginalTarget doesn't point to any object!
tmp->mExplicitOriginalTarget = nsnull;
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mExplicitOriginalTarget)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEvent)
@ -236,6 +234,7 @@ 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
@ -289,7 +288,7 @@ nsDOMEvent::GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget)
//
// Get the actual event target node (may have been retargeted for mouse events)
//
already_AddRefed<nsIContent>
already_AddRefed<nsIDOMEventTarget>
nsDOMEvent::GetTargetFromFrame()
{
if (!mPresContext) { return nsnull; }
@ -302,7 +301,12 @@ nsDOMEvent::GetTargetFromFrame()
// get the real content
nsCOMPtr<nsIContent> realEventContent;
targetFrame->GetContentForEvent(mPresContext, mEvent, getter_AddRefs(realEventContent));
return realEventContent.forget();
if (!realEventContent) { return nsnull; }
// Finally, we have the real content. QI it and return.
nsIDOMEventTarget* target = nsnull;
CallQueryInterface(realEventContent, &target);
return target;
}
NS_IMETHODIMP

View File

@ -206,13 +206,13 @@ protected:
// Internal helper functions
nsresult SetEventType(const nsAString& aEventTypeArg);
already_AddRefed<nsIContent> GetTargetFromFrame();
already_AddRefed<nsIDOMEventTarget> GetTargetFromFrame();
nsresult ReportWrongPropertyAccessWarning(const char* aPropertyName);
nsEvent* mEvent;
nsRefPtr<nsPresContext> mPresContext;
nsCOMPtr<nsIDOMEventTarget> mTmpRealOriginalTarget;
nsIDOMEventTarget* mExplicitOriginalTarget;
nsCOMPtr<nsIDOMEventTarget> mExplicitOriginalTarget;
nsString mCachedType;
PRPackedBool mEventIsInternal;
PRPackedBool mPrivateDataDuplicated;