nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, const nsAString& aEventType) {  mPresContext = aPresContext; mEventIsTrusted = PR_FALSE;  if (aEvent) { mEvent = aEvent; mEventIsTrusted = PR_TRUE; } else { mEventIsInternal = PR_TRUE;   nsAutoString eventType(aEventType); if (eventType.EqualsIgnoreCase("MouseEvents")) { mEvent = PR_NEWZAP(nsMouseEvent); mEvent->eventStructType = NS_MOUSE_EVENT; } else if (eventType.EqualsIgnoreCase("MouseScrollEvents")) { mEvent = PR_NEWZAP(nsMouseScrollEvent); mEvent->eventStructType = NS_MOUSE_SCROLL_EVENT; } else if (eventType.EqualsIgnoreCase("KeyEvents")) { mEvent = PR_NEWZAP(nsKeyEvent); mEvent->eventStructType = NS_KEY_EVENT; } else if (eventType.EqualsIgnoreCase("HTMLEvents")) { mEvent = PR_NEWZAP(nsEvent); mEvent->eventStructType = NS_EVENT; } else if (eventType.EqualsIgnoreCase("MutationEvents")) { mEvent = PR_NEWZAP(nsMutationEvent); mEvent->eventStructType = NS_MUTATION_EVENT; } else if (eventType.EqualsIgnoreCase("PopupEvents")) { mEvent = PR_NEWZAP(nsGUIEvent); mEvent->eventStructType = NS_POPUP_EVENT; } else if (eventType.EqualsIgnoreCase("PopupBlockedEvents")) { mEvent = PR_NEWZAP(nsPopupBlockedEvent); mEvent->eventStructType = NS_POPUPBLOCKED_EVENT; } else { mEvent = PR_NEWZAP(nsEvent); mEvent->eventStructType = NS_EVENT; } }   { mExplicitOriginalTarget = GetTargetFromFrame(); mTmpRealOriginalTarget = mExplicitOriginalTarget; nsCOMPtr<nsIContent> content = do_QueryInterface(mExplicitOriginalTarget); if (content) { if (content->IsNativeAnonymous()) { mExplicitOriginalTarget = nsnull; } if (content->GetBindingParent()) { mExplicitOriginalTarget = nsnull; } } } mText = nsnull; mButton = -1; if (aEvent) { mScreenPoint.x = aEvent->refPoint.x; mScreenPoint.y = aEvent->refPoint.y; mClientPoint.x = aEvent->point.x; mClientPoint.y = aEvent->point.y; } else mScreenPoint.x = mScreenPoint.y = mClientPoint.x = mClientPoint.y = 0;  if (aEvent && aEvent->eventStructType == NS_TEXT_EVENT) {     nsTextEvent *te = (nsTextEvent*)aEvent;  mText = new nsString(te->theText);       nsIPrivateTextRange** tempTextRangeList = new nsIPrivateTextRange*[te->rangeCount];  if (tempTextRangeList) { PRUint16 i;  for(i = 0; i < te->rangeCount; i++) { nsPrivateTextRange* tempPrivateTextRange = new nsPrivateTextRange(te->rangeArray[i].mStartOffset, te->rangeArray[i].mEndOffset, te->rangeArray[i].mRangeType);  if (tempPrivateTextRange) { NS_ADDREF(tempPrivateTextRange);  tempTextRangeList[i] = (nsIPrivateTextRange*)tempPrivateTextRange; } } }        mTextRange = new nsPrivateTextRangeList(te->rangeCount ,tempTextRangeList); } }
nsDOMEvent() {};
nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent,                       const nsAString& aEventType) {  mPresContext = aPresContext;  mEventIsTrusted = PR_FALSE;  if (aEvent) {    mEvent = aEvent;    mEventIsTrusted = PR_TRUE;  }  else {    mEventIsInternal = PR_TRUE;    //Allocate internal event    nsAutoString eventType(aEventType);    if (eventType.EqualsIgnoreCase("MouseEvents")) {      mEvent = PR_NEWZAP(nsMouseEvent);      mEvent->eventStructType = NS_MOUSE_EVENT;    }    else if (eventType.EqualsIgnoreCase("MouseScrollEvents")) {      mEvent = PR_NEWZAP(nsMouseScrollEvent);      mEvent->eventStructType = NS_MOUSE_SCROLL_EVENT;    }    else if (eventType.EqualsIgnoreCase("KeyEvents")) {      mEvent = PR_NEWZAP(nsKeyEvent);      mEvent->eventStructType = NS_KEY_EVENT;    }    else if (eventType.EqualsIgnoreCase("HTMLEvents")) {      mEvent = PR_NEWZAP(nsEvent);      mEvent->eventStructType = NS_EVENT;    }    else if (eventType.EqualsIgnoreCase("MutationEvents")) {      mEvent = PR_NEWZAP(nsMutationEvent);      mEvent->eventStructType = NS_MUTATION_EVENT;    }    else if (eventType.EqualsIgnoreCase("PopupEvents")) {      mEvent = PR_NEWZAP(nsGUIEvent);      mEvent->eventStructType = NS_POPUP_EVENT;    }    else if (eventType.EqualsIgnoreCase("PopupBlockedEvents")) {      mEvent = PR_NEWZAP(nsPopupBlockedEvent);      mEvent->eventStructType = NS_POPUPBLOCKED_EVENT;    }    else {      mEvent = PR_NEWZAP(nsEvent);      mEvent->eventStructType = NS_EVENT;    }  }  // 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()) {        mExplicitOriginalTarget = nsnull;      }      if (content->GetBindingParent()) {        mExplicitOriginalTarget = nsnull;      }    }  }  mText = nsnull;  mButton = -1;  if (aEvent) {    mScreenPoint.x = aEvent->refPoint.x;    mScreenPoint.y = aEvent->refPoint.y;    mClientPoint.x = aEvent->point.x;    mClientPoint.y = aEvent->point.y;  } else    mScreenPoint.x = mScreenPoint.y = mClientPoint.x = mClientPoint.y = 0;  if (aEvent && aEvent->eventStructType == NS_TEXT_EVENT) {	  //	  // extract the IME composition string	  //    nsTextEvent *te = (nsTextEvent*)aEvent;	  mText = new nsString(te->theText);	  //	  // build the range list -- ranges need to be DOM-ified since the	  // IME transaction will hold a ref, the widget representation	  // isn't persistent	  //	  nsIPrivateTextRange** tempTextRangeList =      new nsIPrivateTextRange*[te->rangeCount];	  if (tempTextRangeList) {      PRUint16 i;      for(i = 0; i < te->rangeCount; i++) {        nsPrivateTextRange* tempPrivateTextRange = new          nsPrivateTextRange(te->rangeArray[i].mStartOffset,                             te->rangeArray[i].mEndOffset,                             te->rangeArray[i].mRangeType);        if (tempPrivateTextRange) {          NS_ADDREF(tempPrivateTextRange);          tempTextRangeList[i] = (nsIPrivateTextRange*)tempPrivateTextRange;        }      }	  }	  // We need to create mTextRange even rangeCount is 0. 	  // If rangeCount is 0, mac carbon will return 0 for new and	  // tempTextRangeList will be null. but we should still create	  // mTextRange, otherwise, we will crash it later when some code	  // call GetInputRange and AddRef to the result    mTextRange = new nsPrivateTextRangeList(te->rangeCount ,tempTextRangeList);  }}