Fix drag and drop to/from textarea and input (bug 194802), r=bryner@netscape.com, sr=jst@netscape.com, a=sspitzer@netscape.com

This commit is contained in:
jkeiser%netscape.com 2003-05-21 00:42:32 +00:00
parent 209f09c081
commit d484da106e
4 changed files with 21 additions and 1 deletions

View File

@ -200,6 +200,7 @@ nsDOMEvent::nsDOMEvent(nsIPresContext* 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);
if (content) {
if (content->IsNativeAnonymous()) {
@ -411,6 +412,18 @@ nsDOMEvent::GetExplicitOriginalTarget(nsIDOMEventTarget** aRealEventTarget)
return GetTarget(aRealEventTarget);
}
NS_IMETHODIMP
nsDOMEvent::GetTmpRealOriginalTarget(nsIDOMEventTarget** aRealEventTarget)
{
if (mTmpRealOriginalTarget) {
*aRealEventTarget = mTmpRealOriginalTarget;
NS_ADDREF(*aRealEventTarget);
return NS_OK;
}
return GetOriginalTarget(aRealEventTarget);
}
NS_IMETHODIMP
nsDOMEvent::GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget)
{

View File

@ -241,6 +241,7 @@ protected:
nsCOMPtr<nsIDOMEventTarget> mCurrentTarget;
nsCOMPtr<nsIDOMEventTarget> mOriginalTarget;
nsCOMPtr<nsIDOMEventTarget> mExplicitOriginalTarget;
nsCOMPtr<nsIDOMEventTarget> mTmpRealOriginalTarget;
nsString* mText;
nsCOMPtr<nsIPrivateTextRangeList> mTextRange;
PRPackedBool mEventIsInternal;

View File

@ -92,6 +92,12 @@ interface nsIDOMNSEvent : nsISupports
* contain anonymous content.
*/
readonly attribute nsIDOMEventTarget explicitOriginalTarget;
/* XXX This is TEMPORARY.
* The original target, without any retargeting (like textnode retargeting).
* This really needs to be in .originalTarget, but this is a less risky way of
* fixing it.
*/
[noscript] readonly attribute nsIDOMEventTarget tmpRealOriginalTarget;
void preventBubble();
void preventCapture();

View File

@ -350,7 +350,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDr
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDragEvent));
if (nsevent) {
res = nsevent->GetExplicitOriginalTarget(getter_AddRefs(eventTarget));
res = nsevent->GetTmpRealOriginalTarget(getter_AddRefs(eventTarget));
if (NS_FAILED(res)) return res;
}