diff --git a/mozilla/accessible/src/base/nsBaseWidgetAccessible.cpp b/mozilla/accessible/src/base/nsBaseWidgetAccessible.cpp index 71d2e6b8813..d3406d85c20 100644 --- a/mozilla/accessible/src/base/nsBaseWidgetAccessible.cpp +++ b/mozilla/accessible/src/base/nsBaseWidgetAccessible.cpp @@ -247,15 +247,7 @@ NS_IMETHODIMP nsLinkableAccessible::DoAction(PRUint8 index) if (IsALink()) { nsCOMPtr presContext(GetPresContext()); if (presContext) { - nsMouseEvent linkClickEvent; - linkClickEvent.eventStructType = NS_EVENT; - linkClickEvent.message = NS_MOUSE_LEFT_CLICK; - linkClickEvent.isShift = PR_FALSE; - linkClickEvent.isControl = PR_FALSE; - linkClickEvent.isAlt = PR_FALSE; - linkClickEvent.isMeta = PR_FALSE; - linkClickEvent.clickCount = 0; - linkClickEvent.widget = nsnull; + nsMouseEvent linkClickEvent(NS_MOUSE_LEFT_CLICK); nsEventStatus eventStatus = nsEventStatus_eIgnore; mLinkContent->HandleDOMEvent(presContext, diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index fd4c2a89aac..efd27a34d29 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -906,10 +906,8 @@ DocumentViewerImpl::LoadComplete(nsresult aStatus) // Now, fire either an OnLoad or OnError event to the document... if(NS_SUCCEEDED(aStatus)) { nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; + nsEvent event(NS_PAGE_LOAD); - event.eventStructType = NS_EVENT; - event.message = NS_PAGE_LOAD; rv = global->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); #ifdef MOZ_TIMELINE @@ -985,10 +983,8 @@ DocumentViewerImpl::Unload() // Now, fire an Unload event to the document... nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; + nsEvent event(NS_PAGE_UNLOAD); - event.eventStructType = NS_EVENT; - event.message = NS_PAGE_UNLOAD; return global->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index 2fc51c78a64..cf79ac64bde 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -1141,13 +1141,10 @@ nsGenericDOMDataNode::SetText(const PRUnichar* aBuffer, if (mDocument && nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED)) { nsCOMPtr node(do_QueryInterface(this)); - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_CHARACTERDATAMODIFIED; - mutation.mTarget = node; + nsMutationEvent mutation(NS_MUTATION_CHARACTERDATAMODIFIED, node); // XXX Handle the setting of prevValue! - nsAutoString newVal(aBuffer); + nsDependentString newVal(aBuffer); if (!newVal.IsEmpty()) mutation.mNewAttrValue = do_GetAtom(newVal); nsEventStatus status = nsEventStatus_eIgnore; @@ -1180,15 +1177,11 @@ nsGenericDOMDataNode::SetText(const char* aBuffer, PRInt32 aLength, if (mDocument && nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED)) { nsCOMPtr node(do_QueryInterface(this)); - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_CHARACTERDATAMODIFIED; - mutation.mTarget = node; + nsMutationEvent mutation(NS_MUTATION_CHARACTERDATAMODIFIED, node); // XXX Handle the setting of prevValue! - nsAutoString newVal; newVal.AssignWithConversion(aBuffer); - if (!newVal.IsEmpty()) - mutation.mNewAttrValue = do_GetAtom(newVal); + if (*aBuffer) + mutation.mNewAttrValue = do_GetAtom(aBuffer); nsEventStatus status = nsEventStatus_eIgnore; HandleDOMEvent(nsnull, &mutation, nsnull, NS_EVENT_FLAG_INIT, &status); @@ -1214,15 +1207,11 @@ nsGenericDOMDataNode::SetText(const nsAString& aStr, if (mDocument && nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED)) { nsCOMPtr node(do_QueryInterface(this)); - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_CHARACTERDATAMODIFIED; - mutation.mTarget = node; + nsMutationEvent mutation(NS_MUTATION_CHARACTERDATAMODIFIED, node); // XXX Handle the setting of prevValue! - nsAutoString newVal(aStr); - if (!newVal.IsEmpty()) - mutation.mNewAttrValue = do_GetAtom(newVal); + if (!aStr.IsEmpty()) + mutation.mNewAttrValue = do_GetAtom(aStr); nsEventStatus status = nsEventStatus_eIgnore; HandleDOMEvent(nsnull, &mutation, nsnull, NS_EVENT_FLAG_INIT, &status); diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index f78e1c2d621..4b622cac53b 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -2424,10 +2424,7 @@ nsGenericElement::InsertChildAt(nsIContent* aKid, } if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEINSERTED)) { - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_NODEINSERTED; - mutation.mTarget = do_QueryInterface(aKid); + nsMutationEvent mutation(NS_MUTATION_NODEINSERTED, aKid); mutation.mRelatedNode = do_QueryInterface(this); nsEventStatus status = nsEventStatus_eIgnore; @@ -2460,10 +2457,7 @@ nsGenericElement::ReplaceChildAt(nsIContent* aKid, mDocument->ContentReplaced(this, oldKid, aKid, aIndex); } if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED)) { - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_SUBTREEMODIFIED; - mutation.mTarget = do_QueryInterface(this); + nsMutationEvent mutation(NS_MUTATION_SUBTREEMODIFIED, this); mutation.mRelatedNode = do_QueryInterface(oldKid); nsEventStatus status = nsEventStatus_eIgnore; @@ -2502,10 +2496,7 @@ nsGenericElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, } if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEINSERTED)) { - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_NODEINSERTED; - mutation.mTarget = do_QueryInterface(aKid); + nsMutationEvent mutation(NS_MUTATION_NODEINSERTED, aKid); mutation.mRelatedNode = do_QueryInterface(this); nsEventStatus status = nsEventStatus_eIgnore; @@ -2523,11 +2514,7 @@ nsGenericElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify); if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEREMOVED)) { - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_NODEREMOVED; - mutation.mTarget = do_QueryInterface(oldKid); - + nsMutationEvent mutation(NS_MUTATION_NODEREMOVED, oldKid); mutation.mRelatedNode = do_QueryInterface(this); nsEventStatus status = nsEventStatus_eIgnore; @@ -3485,10 +3472,7 @@ nsGenericContainerElement::SetAttr(nsINodeInfo* aNodeInfo, if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) { nsCOMPtr node(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this))); - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_ATTRMODIFIED; - mutation.mTarget = node; + nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node); nsAutoString attrName; name->ToString(attrName); @@ -3638,10 +3622,7 @@ nsGenericContainerElement::UnsetAttr(PRInt32 aNameSpaceID, if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) { nsCOMPtr node(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this))); - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_ATTRMODIFIED; - mutation.mTarget = node; + nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node); nsAutoString attrName; aName->ToString(attrName); diff --git a/mozilla/content/base/src/nsImageLoadingContent.cpp b/mozilla/content/base/src/nsImageLoadingContent.cpp index f9ef176106c..85b86cb268b 100644 --- a/mozilla/content/base/src/nsImageLoadingContent.cpp +++ b/mozilla/content/base/src/nsImageLoadingContent.cpp @@ -625,15 +625,15 @@ HandleImagePLEvent(PLEvent* aEvent) { ImageEvent* evt = NS_STATIC_CAST(ImageEvent*, aEvent); nsEventStatus estatus = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; + PRUint32 eventMsg; if (evt->mMessage == NS_LITERAL_STRING("load")) { - event.message = NS_IMAGE_LOAD; + eventMsg = NS_IMAGE_LOAD; } else { - event.message = NS_IMAGE_ERROR; + eventMsg = NS_IMAGE_ERROR; } + nsEvent event(eventMsg); evt->mContent->HandleDOMEvent(evt->mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &estatus); diff --git a/mozilla/content/base/src/nsSelection.cpp b/mozilla/content/base/src/nsSelection.cpp index 49750ab488a..82a1617c257 100644 --- a/mozilla/content/base/src/nsSelection.cpp +++ b/mozilla/content/base/src/nsSelection.cpp @@ -1372,7 +1372,7 @@ nsSelection::HandleTextEvent(nsGUIEvent *aGUIEvent) printf("nsSelection: HandleTextEvent\n"); #endif nsresult result(NS_OK); - if (NS_TEXT_EVENT == aGUIEvent->message) { + if (NS_TEXT_TEXT == aGUIEvent->message) { PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); result = mDomSelections[index]->ScrollIntoView(); } diff --git a/mozilla/content/events/public/nsMutationEvent.h b/mozilla/content/events/public/nsMutationEvent.h index 7ca085036f7..c8579bebd90 100644 --- a/mozilla/content/events/public/nsMutationEvent.h +++ b/mozilla/content/events/public/nsMutationEvent.h @@ -1,10 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2003 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + #include "nsGUIEvent.h" #include "nsIDOMNode.h" #include "nsIAtom.h" #include "nsIDOMEventTarget.h" +#include "nsIContent.h" + +#define NS_MUTATION_EVENT 20 struct nsMutationEvent : public nsEvent -{ +{ + nsMutationEvent(PRUint32 msg = 0, PRUint8 structType = NS_MUTATION_EVENT) + : nsEvent(msg, structType), + mAttrChange(0) + { + } + + nsMutationEvent(PRUint32 msg, + nsIDOMEventTarget *target, + PRUint8 structType = NS_MUTATION_EVENT) + : nsEvent(msg, structType), + mTarget(target), + mAttrChange(0) + { + } + + nsMutationEvent(PRUint32 msg, + nsIContent *target, + PRUint8 structType = NS_MUTATION_EVENT) + : nsEvent(msg, structType), + mTarget(do_QueryInterface(target)), + mAttrChange(0) + { + } + nsCOMPtr mRelatedNode; nsCOMPtr mTarget; @@ -15,8 +79,6 @@ struct nsMutationEvent : public nsEvent unsigned short mAttrChange; }; -#define NS_MUTATION_EVENT 20 - #define NS_MUTATION_START 1800 #define NS_MUTATION_SUBTREEMODIFIED (NS_MUTATION_START) #define NS_MUTATION_NODEINSERTED (NS_MUTATION_START+1) diff --git a/mozilla/content/events/src/nsDOMEvent.cpp b/mozilla/content/events/src/nsDOMEvent.cpp index 9476489a93a..0a3edf13579 100644 --- a/mozilla/content/events/src/nsDOMEvent.cpp +++ b/mozilla/content/events/src/nsDOMEvent.cpp @@ -160,41 +160,7 @@ nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, } 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; - } + AllocateEvent(aEventType); } // Get the explicit original target (if it's anonymous make it null) @@ -278,7 +244,7 @@ nsDOMEvent::~nsDOMEvent() NS_IF_RELEASE(event->mRequestingWindowURI); NS_IF_RELEASE(event->mPopupWindowURI); } - PR_DELETE(mEvent); + delete mEvent; } delete mText; @@ -610,7 +576,7 @@ nsDOMEvent::GetDetail(PRInt32* aDetail) NS_METHOD nsDOMEvent::GetText(nsString& aText) { - if (mEvent->message == NS_TEXT_EVENT) { + if (mEvent->message == NS_TEXT_TEXT) { aText = *mText; return NS_OK; } @@ -621,7 +587,7 @@ NS_METHOD nsDOMEvent::GetText(nsString& aText) NS_METHOD nsDOMEvent::GetInputRange(nsIPrivateTextRangeList** aInputRange) { NS_ENSURE_ARG_POINTER(aInputRange); - if (mEvent->message == NS_TEXT_EVENT) { + if (mEvent->message == NS_TEXT_TEXT) { *aInputRange = mTextRange; return NS_OK; } @@ -632,7 +598,7 @@ NS_METHOD nsDOMEvent::GetInputRange(nsIPrivateTextRangeList** aInputRange) NS_METHOD nsDOMEvent::GetEventReply(nsTextEventReply** aReply) { NS_ENSURE_ARG_POINTER(aReply); - if (mEvent->message==NS_TEXT_EVENT) { + if (mEvent->message==NS_TEXT_TEXT) { *aReply = &(((nsTextEvent*)mEvent)->theReply); return NS_OK; } @@ -667,7 +633,7 @@ NS_METHOD nsDOMEvent::GetScreenX(PRInt32* aScreenX) if (!mEvent || (mEvent->eventStructType != NS_MOUSE_EVENT && mEvent->eventStructType != NS_POPUP_EVENT && - mEvent->eventStructType != NS_DRAGDROP_EVENT)) { + !NS_IS_DRAG_EVENT(mEvent))) { *aScreenX = 0; return NS_OK; } @@ -692,7 +658,7 @@ NS_METHOD nsDOMEvent::GetScreenY(PRInt32* aScreenY) if (!mEvent || (mEvent->eventStructType != NS_MOUSE_EVENT && mEvent->eventStructType != NS_POPUP_EVENT && - mEvent->eventStructType != NS_DRAGDROP_EVENT)) { + !NS_IS_DRAG_EVENT(mEvent))) { *aScreenY = 0; return NS_OK; } @@ -717,7 +683,7 @@ NS_METHOD nsDOMEvent::GetClientX(PRInt32* aClientX) if (!mEvent || (mEvent->eventStructType != NS_MOUSE_EVENT && mEvent->eventStructType != NS_POPUP_EVENT && - mEvent->eventStructType != NS_DRAGDROP_EVENT) || + !NS_IS_DRAG_EVENT(mEvent)) || !mPresContext) { *aClientX = 0; return NS_OK; @@ -771,8 +737,8 @@ NS_METHOD nsDOMEvent::GetClientY(PRInt32* aClientY) if (!mEvent || (mEvent->eventStructType != NS_MOUSE_EVENT && mEvent->eventStructType != NS_POPUP_EVENT && - mEvent->eventStructType != NS_DRAGDROP_EVENT) || - !mPresContext) { + !NS_IS_DRAG_EVENT(mEvent)) || + !mPresContext) { *aClientY = 0; return NS_OK; } @@ -1225,90 +1191,67 @@ nsDOMEvent::SetEventType(const nsAString& aEventTypeArg) { nsCOMPtr atom= do_GetAtom(NS_LITERAL_STRING("on") + aEventTypeArg); - if (atom == nsLayoutAtoms::onmousedown && mEvent->eventStructType == NS_MOUSE_EVENT) { - mEvent->message = NS_MOUSE_LEFT_BUTTON_DOWN; + if (mEvent->eventStructType == NS_MOUSE_EVENT) { + if (atom == nsLayoutAtoms::onmousedown) + mEvent->message = NS_MOUSE_LEFT_BUTTON_DOWN; + else if (atom == nsLayoutAtoms::onmouseup) + mEvent->message = NS_MOUSE_LEFT_BUTTON_UP; + else if (atom == nsLayoutAtoms::onclick) + mEvent->message = NS_MOUSE_LEFT_CLICK; + else if (atom == nsLayoutAtoms::ondblclick) + mEvent->message = NS_MOUSE_LEFT_DOUBLECLICK; + else if (atom == nsLayoutAtoms::onmouseover) + mEvent->message = NS_MOUSE_ENTER_SYNTH; + else if (atom == nsLayoutAtoms::onmouseout) + mEvent->message = NS_MOUSE_EXIT_SYNTH; + else if (atom == nsLayoutAtoms::onmousemove) + mEvent->message = NS_MOUSE_MOVE; + else if (atom == nsLayoutAtoms::oncontextmenu) + mEvent->message = NS_CONTEXTMENU; + } else if (mEvent->eventStructType == NS_KEY_EVENT) { + if (atom == nsLayoutAtoms::onkeydown) + mEvent->message = NS_KEY_DOWN; + else if (atom == nsLayoutAtoms::onkeyup) + mEvent->message = NS_KEY_UP; + else if (atom == nsLayoutAtoms::onkeypress) + mEvent->message = NS_KEY_PRESS; + } else if (mEvent->eventStructType == NS_EVENT) { + if (atom == nsLayoutAtoms::onfocus) + mEvent->message = NS_FOCUS_CONTENT; + else if (atom == nsLayoutAtoms::onblur) + mEvent->message = NS_BLUR_CONTENT; + else if (atom == nsLayoutAtoms::onsubmit) + mEvent->message = NS_FORM_SUBMIT; + else if (atom == nsLayoutAtoms::onreset) + mEvent->message = NS_FORM_RESET; + else if (atom == nsLayoutAtoms::onchange) + mEvent->message = NS_FORM_CHANGE; + else if (atom == nsLayoutAtoms::onselect) + mEvent->message = NS_FORM_SELECTED; + else if (atom == nsLayoutAtoms::onload) + mEvent->message = NS_PAGE_LOAD; + else if (atom == nsLayoutAtoms::onunload) + mEvent->message = NS_PAGE_UNLOAD; + else if (atom == nsLayoutAtoms::onabort) + mEvent->message = NS_IMAGE_ABORT; + else if (atom == nsLayoutAtoms::onerror) + mEvent->message = NS_IMAGE_ERROR; + } else if (mEvent->eventStructType == NS_MUTATION_EVENT) { + if (atom == nsLayoutAtoms::onDOMAttrModified) + mEvent->message = NS_MUTATION_ATTRMODIFIED; + else if (atom == nsLayoutAtoms::onDOMCharacterDataModified) + mEvent->message = NS_MUTATION_CHARACTERDATAMODIFIED; + else if (atom == nsLayoutAtoms::onDOMNodeInserted) + mEvent->message = NS_MUTATION_NODEINSERTED; + else if (atom == nsLayoutAtoms::onDOMNodeRemoved) + mEvent->message = NS_MUTATION_NODEREMOVED; + else if (atom == nsLayoutAtoms::onDOMNodeInsertedIntoDocument) + mEvent->message = NS_MUTATION_NODEINSERTEDINTODOCUMENT; + else if (atom == nsLayoutAtoms::onDOMNodeRemovedFromDocument) + mEvent->message = NS_MUTATION_NODEREMOVEDFROMDOCUMENT; + else if (atom == nsLayoutAtoms::onDOMSubtreeModified) + mEvent->message = NS_MUTATION_SUBTREEMODIFIED; } - else if (atom == nsLayoutAtoms::onmouseup && mEvent->eventStructType == NS_MOUSE_EVENT) { - mEvent->message = NS_MOUSE_LEFT_BUTTON_UP; - } - else if (atom == nsLayoutAtoms::onclick && mEvent->eventStructType == NS_MOUSE_EVENT) { - mEvent->message = NS_MOUSE_LEFT_CLICK; - } - else if (atom == nsLayoutAtoms::ondblclick && mEvent->eventStructType == NS_MOUSE_EVENT) { - mEvent->message = NS_MOUSE_LEFT_DOUBLECLICK; - } - else if (atom == nsLayoutAtoms::onmouseover && mEvent->eventStructType == NS_MOUSE_EVENT) { - mEvent->message = NS_MOUSE_ENTER_SYNTH; - } - else if (atom == nsLayoutAtoms::onmouseout && mEvent->eventStructType == NS_MOUSE_EVENT) { - mEvent->message = NS_MOUSE_EXIT_SYNTH; - } - else if (atom == nsLayoutAtoms::onmousemove && mEvent->eventStructType == NS_MOUSE_EVENT) { - mEvent->message = NS_MOUSE_MOVE; - } - else if (atom == nsLayoutAtoms::oncontextmenu && mEvent->eventStructType == NS_MOUSE_EVENT) { - mEvent->message = NS_CONTEXTMENU; - } - else if (atom == nsLayoutAtoms::onkeydown && mEvent->eventStructType == NS_KEY_EVENT) { - mEvent->message = NS_KEY_DOWN; - } - else if (atom == nsLayoutAtoms::onkeyup && mEvent->eventStructType == NS_KEY_EVENT) { - mEvent->message = NS_KEY_UP; - } - else if (atom == nsLayoutAtoms::onkeypress && mEvent->eventStructType == NS_KEY_EVENT) { - mEvent->message = NS_KEY_PRESS; - } - else if (atom == nsLayoutAtoms::onfocus && mEvent->eventStructType == NS_EVENT) { - mEvent->message = NS_FOCUS_CONTENT; - } - else if (atom == nsLayoutAtoms::onblur && mEvent->eventStructType == NS_EVENT) { - mEvent->message = NS_BLUR_CONTENT; - } - else if (atom == nsLayoutAtoms::onsubmit && mEvent->eventStructType == NS_EVENT) { - mEvent->message = NS_FORM_SUBMIT; - } - else if (atom == nsLayoutAtoms::onreset && mEvent->eventStructType == NS_EVENT) { - mEvent->message = NS_FORM_RESET; - } - else if (atom == nsLayoutAtoms::onchange && mEvent->eventStructType == NS_EVENT) { - mEvent->message = NS_FORM_CHANGE; - } - else if (atom == nsLayoutAtoms::onselect && mEvent->eventStructType == NS_EVENT) { - mEvent->message = NS_FORM_SELECTED; - } - else if (atom == nsLayoutAtoms::onload && mEvent->eventStructType == NS_EVENT) { - mEvent->message = NS_PAGE_LOAD; - } - else if (atom == nsLayoutAtoms::onunload && mEvent->eventStructType == NS_EVENT) { - mEvent->message = NS_PAGE_UNLOAD; - } - else if (atom == nsLayoutAtoms::onabort && mEvent->eventStructType == NS_EVENT) { - mEvent->message = NS_IMAGE_ABORT; - } - else if (atom == nsLayoutAtoms::onerror && mEvent->eventStructType == NS_EVENT) { - mEvent->message = NS_IMAGE_ERROR; - } - else if (atom == nsLayoutAtoms::onDOMAttrModified && mEvent->eventStructType == NS_MUTATION_EVENT) { - mEvent->message = NS_MUTATION_ATTRMODIFIED; - } - else if (atom == nsLayoutAtoms::onDOMCharacterDataModified && mEvent->eventStructType == NS_MUTATION_EVENT) { - mEvent->message = NS_MUTATION_CHARACTERDATAMODIFIED; - } - else if (atom == nsLayoutAtoms::onDOMNodeInserted && mEvent->eventStructType == NS_MUTATION_EVENT) { - mEvent->message = NS_MUTATION_NODEINSERTED; - } - else if (atom == nsLayoutAtoms::onDOMNodeRemoved && mEvent->eventStructType == NS_MUTATION_EVENT) { - mEvent->message = NS_MUTATION_NODEREMOVED; - } - else if (atom == nsLayoutAtoms::onDOMNodeInsertedIntoDocument && mEvent->eventStructType == NS_MUTATION_EVENT) { - mEvent->message = NS_MUTATION_NODEINSERTEDINTODOCUMENT; - } - else if (atom == nsLayoutAtoms::onDOMNodeRemovedFromDocument && mEvent->eventStructType == NS_MUTATION_EVENT) { - mEvent->message = NS_MUTATION_NODEREMOVEDFROMDOCUMENT; - } - else if (atom == nsLayoutAtoms::onDOMSubtreeModified && mEvent->eventStructType == NS_MUTATION_EVENT) { - mEvent->message = NS_MUTATION_SUBTREEMODIFIED; - } else { mEvent->message = NS_USER_DEFINED_EVENT; mEvent->userType = new nsStringKey(aEventTypeArg); @@ -1583,7 +1526,7 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType) return mEventNames[eDOMEvents_resize]; case NS_SCROLL_EVENT: return mEventNames[eDOMEvents_scroll]; - case NS_TEXT_EVENT: + case NS_TEXT_TEXT: return mEventNames[eDOMEvents_text]; case NS_XUL_POPUP_SHOWING: return mEventNames[eDOMEvents_popupShowing]; @@ -1652,6 +1595,34 @@ NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult, return CallQueryInterface(it, aInstancePtrResult); } +void +nsDOMEvent::AllocateEvent(const nsAString& aEventType) +{ + //Allocate internal event + nsAutoString eventType(aEventType); + if (eventType.EqualsIgnoreCase("MouseEvents")) { + mEvent = new nsMouseEvent(); + } + else if (eventType.EqualsIgnoreCase("MouseScrollEvents")) { + mEvent = new nsMouseScrollEvent(); + } + else if (eventType.EqualsIgnoreCase("KeyEvents")) { + mEvent = new nsKeyEvent(); + } + else if (eventType.EqualsIgnoreCase("MutationEvents")) { + mEvent = new nsMutationEvent(); + } + else if (eventType.EqualsIgnoreCase("PopupEvents")) { + mEvent = new nsGUIEvent(); + } + else if (eventType.EqualsIgnoreCase("PopupBlockedEvents")) { + mEvent = new nsPopupBlockedEvent(); + } + else { + mEvent = new nsEvent(); + } +} + nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext* aPresContext, nsEvent *aEvent) diff --git a/mozilla/content/events/src/nsDOMEvent.h b/mozilla/content/events/src/nsDOMEvent.h index 7f934d97197..c4fe1a13875 100644 --- a/mozilla/content/events/src/nsDOMEvent.h +++ b/mozilla/content/events/src/nsDOMEvent.h @@ -234,6 +234,7 @@ protected: nsresult SetEventType(const nsAString& aEventTypeArg); const char* GetEventName(PRUint32 aEventType); already_AddRefed GetTargetFromFrame(); + void AllocateEvent(const nsAString& aEventType); nsEvent* mEvent; nsCOMPtr mPresContext; diff --git a/mozilla/content/events/src/nsEventListenerManager.cpp b/mozilla/content/events/src/nsEventListenerManager.cpp index 1db3a5fe1f0..eb57257e2cd 100644 --- a/mozilla/content/events/src/nsEventListenerManager.cpp +++ b/mozilla/content/events/src/nsEventListenerManager.cpp @@ -202,7 +202,7 @@ static const EventDispatchData sCompositionEvents[] = { }; static const EventDispatchData sTextEvents[] = { - {NS_TEXT_EVENT,HANDLER(&nsIDOMTextListener::HandleText),NS_EVENT_BITS_TEXT_TEXT}, + {NS_TEXT_TEXT,HANDLER(&nsIDOMTextListener::HandleText),NS_EVENT_BITS_TEXT_TEXT}, }; static const EventDispatchData sKeyEvents[] = { diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 6cd856d9d39..2d5e1480dd3 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -459,9 +459,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, // Fire the blur event on the previously focused document. nsEventStatus blurstatus = nsEventStatus_eIgnore; - nsEvent blurevent; - blurevent.eventStructType = NS_EVENT; - blurevent.message = NS_BLUR_CONTENT; + nsEvent blurevent(NS_BLUR_CONTENT); gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &blurevent, @@ -514,9 +512,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, // then the content node, then the window. nsEventStatus status = nsEventStatus_eIgnore; - nsEvent focusevent; - focusevent.eventStructType = NS_EVENT; - focusevent.message = NS_FOCUS_CONTENT; + nsEvent focusevent(NS_FOCUS_CONTENT); nsCOMPtr globalObject = mDocument->GetScriptGlobalObject(); if (globalObject) { @@ -614,9 +610,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, // and window. nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_BLUR_CONTENT; + nsEvent event(NS_BLUR_CONTENT); if (gLastFocusedDocument && gLastFocusedPresContext) { if (gLastFocusedContent) { @@ -775,10 +769,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, if (gLastFocusedDocument && gLastFocusedDocument == mDocument) { nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_BLUR_CONTENT; - event.flags = 0; + nsEvent event(NS_BLUR_CONTENT); if (gLastFocusedContent) { nsIPresShell *shell = gLastFocusedDocument->GetShellAt(0); @@ -949,15 +940,7 @@ nsEventStateManager::HandleAccessKey(nsIPresContext* aPresContext, if (activate) { // B) Click on it if the users prefs indicate to do so. nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_MOUSE_LEFT_CLICK); content->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } @@ -1170,17 +1153,10 @@ nsEventStateManager::FireContextClick() #endif nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_CONTEXTMENU; - event.widget = mEventDownWidget; + nsMouseEvent event(NS_CONTEXTMENU, mEventDownWidget); event.clickCount = 1; event.point = mEventPoint; event.refPoint = mEventRefPoint; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; // Dispatch to the DOM. We have to fake out the ESM and tell it that the // current target frame is actually where the mouseDown occurred, otherwise it @@ -1424,11 +1400,7 @@ nsEventStateManager::GenerateDragGesture(nsIPresContext* aPresContext, // get the widget from the target frame nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_DRAGDROP_EVENT; - event.message = NS_DRAGDROP_GESTURE; - event.widget = mGestureDownFrame->GetWindow(); - event.clickCount = 0; + nsMouseEvent event(NS_DRAGDROP_GESTURE, mGestureDownFrame->GetWindow()); event.point = mGestureDownPoint; event.refPoint = mGestureDownRefPoint; // ideally, we should get the modifiers from the original event too, @@ -1586,20 +1558,7 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext, // Create a mouseout event that we fire to the content before // scrolling, to allow tooltips to disappear, etc. - nsMouseEvent mouseOutEvent; - mouseOutEvent.eventStructType = NS_MOUSE_EVENT; - mouseOutEvent.message = NS_MOUSE_EXIT; - mouseOutEvent.widget = aMSEvent->widget; - mouseOutEvent.clickCount = 0; - mouseOutEvent.point = nsPoint(0,0); - mouseOutEvent.refPoint = nsPoint(0,0); - mouseOutEvent.isShift = PR_FALSE; - mouseOutEvent.isControl = PR_FALSE; - mouseOutEvent.isAlt = PR_FALSE; - mouseOutEvent.isMeta = PR_FALSE; - - // initialize nativeMsg field otherwise plugin code will crash when trying to access it - mouseOutEvent.nativeMsg = nsnull; + nsMouseEvent mouseOutEvent(NS_MOUSE_EXIT, aMSEvent->widget); nsIPresShell *presShell = aPresContext->PresShell(); @@ -2454,11 +2413,7 @@ nsEventStateManager::DispatchMouseEvent(nsIPresContext* aPresContext, nsIContent* aRelatedContent) { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = aMessage; - event.widget = aEvent->widget; - event.clickCount = 0; + nsMouseEvent event(aMessage, aEvent->widget); event.point = aEvent->point; event.refPoint = aEvent->refPoint; event.isShift = ((nsMouseEvent*)aEvent)->isShift; @@ -2513,11 +2468,7 @@ nsEventStateManager::MaybeDispatchMouseEventToIframe( nsIPresShell *parentShell = parentDoc->GetShellAt(0); if (parentShell) { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = aMessage; - event.widget = aEvent->widget; - event.clickCount = 0; + nsMouseEvent event(aMessage, aEvent->widget); event.point = aEvent->point; event.refPoint = aEvent->refPoint; event.isShift = ((nsMouseEvent*)aEvent)->isShift; @@ -2670,11 +2621,7 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext* aPresContext, if ( mLastDragOverFrame ) { //fire drag exit nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_DRAGDROP_EVENT; - event.message = NS_DRAGDROP_EXIT_SYNTH; - event.widget = aEvent->widget; - event.clickCount = 0; + nsMouseEvent event(NS_DRAGDROP_EXIT_SYNTH, aEvent->widget); event.point = aEvent->point; event.refPoint = aEvent->refPoint; event.isShift = ((nsMouseEvent*)aEvent)->isShift; @@ -2707,11 +2654,7 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext* aPresContext, //fire drag enter nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_DRAGDROP_EVENT; - event.message = NS_DRAGDROP_ENTER; - event.widget = aEvent->widget; - event.clickCount = 0; + nsMouseEvent event(NS_DRAGDROP_ENTER, aEvent->widget); event.point = aEvent->point; event.refPoint = aEvent->refPoint; event.isShift = ((nsMouseEvent*)aEvent)->isShift; @@ -2752,11 +2695,7 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext* aPresContext, // fire mouseout nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_DRAGDROP_EVENT; - event.message = NS_DRAGDROP_EXIT_SYNTH; - event.widget = aEvent->widget; - event.clickCount = 0; + nsMouseEvent event(NS_DRAGDROP_EXIT_SYNTH, aEvent->widget); event.point = aEvent->point; event.refPoint = aEvent->refPoint; event.isShift = ((nsMouseEvent*)aEvent)->isShift; @@ -2859,7 +2798,7 @@ nsEventStateManager::CheckForAndDispatchClick(nsIPresContext* aPresContext, nsEventStatus* aStatus) { nsresult ret = NS_OK; - nsMouseEvent event; + PRUint32 eventMsg = 0; PRInt32 flags = NS_EVENT_FLAG_INIT; //If mouse is still over same element, clickcount will be > 1. @@ -2868,21 +2807,19 @@ nsEventStateManager::CheckForAndDispatchClick(nsIPresContext* aPresContext, //fire click switch (aEvent->message) { case NS_MOUSE_LEFT_BUTTON_UP: - event.message = NS_MOUSE_LEFT_CLICK; + eventMsg = NS_MOUSE_LEFT_CLICK; break; case NS_MOUSE_MIDDLE_BUTTON_UP: - event.message = NS_MOUSE_MIDDLE_CLICK; + eventMsg = NS_MOUSE_MIDDLE_CLICK; flags |= mLeftClickOnly ? NS_EVENT_FLAG_NO_CONTENT_DISPATCH : NS_EVENT_FLAG_NONE; break; case NS_MOUSE_RIGHT_BUTTON_UP: - event.message = NS_MOUSE_RIGHT_CLICK; + eventMsg = NS_MOUSE_RIGHT_CLICK; flags |= mLeftClickOnly ? NS_EVENT_FLAG_NO_CONTENT_DISPATCH : NS_EVENT_FLAG_NONE; break; } - event.eventStructType = NS_MOUSE_EVENT; - event.widget = aEvent->widget; - event.nativeMsg = nsnull; + nsMouseEvent event(eventMsg, aEvent->widget); event.point = aEvent->point; event.refPoint = aEvent->refPoint; event.clickCount = aEvent->clickCount; @@ -2898,23 +2835,21 @@ nsEventStateManager::CheckForAndDispatchClick(nsIPresContext* aPresContext, ret = presShell->HandleEventWithTarget(&event, mCurrentTarget, mouseContent, flags, aStatus); if (NS_SUCCEEDED(ret) && aEvent->clickCount == 2) { - nsMouseEvent event2; + eventMsg = 0; //fire double click switch (aEvent->message) { case NS_MOUSE_LEFT_BUTTON_UP: - event2.message = NS_MOUSE_LEFT_DOUBLECLICK; + eventMsg = NS_MOUSE_LEFT_DOUBLECLICK; break; case NS_MOUSE_MIDDLE_BUTTON_UP: - event2.message = NS_MOUSE_MIDDLE_DOUBLECLICK; + eventMsg = NS_MOUSE_MIDDLE_DOUBLECLICK; break; case NS_MOUSE_RIGHT_BUTTON_UP: - event2.message = NS_MOUSE_RIGHT_DOUBLECLICK; + eventMsg = NS_MOUSE_RIGHT_DOUBLECLICK; break; } - event2.eventStructType = NS_MOUSE_EVENT; - event2.widget = aEvent->widget; - event2.nativeMsg = nsnull; + nsMouseEvent event2(eventMsg, aEvent->widget); event2.point = aEvent->point; event2.refPoint = aEvent->refPoint; event2.clickCount = aEvent->clickCount; @@ -4110,9 +4045,7 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, //fire blur nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_BLUR_CONTENT; + nsEvent event(NS_BLUR_CONTENT); EnsureDocument(presShell); @@ -4168,9 +4101,7 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, if (gLastFocusedDocument && (gLastFocusedDocument != mDocument) && globalObject) { nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_BLUR_CONTENT; + nsEvent event(NS_BLUR_CONTENT); // Make sure we're not switching command dispatchers, if so, surpress the blurred one if (mDocument) { @@ -4256,9 +4187,7 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, //fire focus nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_FOCUS_CONTENT; + nsEvent event(NS_FOCUS_CONTENT); if (nsnull != mPresContext) { nsCxPusher pusher(aContent); @@ -4279,9 +4208,7 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, //fire focus on document even if the content isn't focusable (ie. text) //see bugzilla bug 93521 nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_FOCUS_CONTENT; + nsEvent event(NS_FOCUS_CONTENT); if (nsnull != mPresContext && mDocument) { nsCxPusher pusher(mDocument); mDocument->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 8c2246de85a..869c9a7adcc 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -1466,15 +1466,12 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIPresContext* aPresContext, if (aEvent->eventStructType == NS_KEY_EVENT) { nsKeyEvent* keyEvent = NS_STATIC_CAST(nsKeyEvent*, aEvent); if (keyEvent->keyCode == NS_VK_RETURN) { - nsMouseEvent event; nsEventStatus status = nsEventStatus_eIgnore; nsCOMPtr mouseContent; //fire click - event.message = NS_MOUSE_LEFT_CLICK; - event.eventStructType = NS_MOUSE_EVENT; nsGUIEvent* guiEvent = NS_STATIC_CAST(nsGUIEvent*, aEvent); - event.widget = guiEvent->widget; + nsMouseEvent event(NS_MOUSE_LEFT_CLICK, guiEvent->widget); event.point = aEvent->point; event.refPoint = aEvent->refPoint; event.clickCount = 1; @@ -1733,10 +1730,7 @@ nsGenericHTMLElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, if (nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) { nsCOMPtr node = do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)); - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_ATTRMODIFIED; - mutation.mTarget = node; + nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node); nsAutoString attrName; aAttribute->ToString(attrName); @@ -1823,10 +1817,7 @@ nsGenericHTMLElement::SetAttr(nsINodeInfo* aNodeInfo, const nsAString& aValue, nsCOMPtr node = do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)); - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_ATTRMODIFIED; - mutation.mTarget = node; + nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node); nsAutoString attrLocalName, attrNamespace; localName->ToString(attrLocalName); @@ -1977,10 +1968,7 @@ nsGenericHTMLElement::SetHTMLAttribute(nsIAtom* aAttribute, if (haveListeners) { nsCOMPtr node(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this))); - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_ATTRMODIFIED; - mutation.mTarget = node; + nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node); nsAutoString attrName; aAttribute->ToString(attrName); @@ -2050,10 +2038,7 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, if (nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) { nsCOMPtr node(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this))); - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_ATTRMODIFIED; - mutation.mTarget = node; + nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node); nsAutoString attrName; aAttribute->ToString(attrName); diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp index 97b0686bdb0..ef9305fdb86 100644 --- a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp @@ -310,15 +310,7 @@ nsHTMLButtonElement::Click() shell->GetPresContext(getter_AddRefs(context)); if (context) { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_MOUSE_LEFT_CLICK); HandleDOMEvent(context, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } @@ -507,15 +499,7 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext, if ((keyEvent->keyCode == NS_VK_RETURN && NS_KEY_PRESS == aEvent->message) || keyEvent->keyCode == NS_VK_SPACE && NS_KEY_UP == aEvent->message) { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_MOUSE_LEFT_CLICK); rv = HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } @@ -526,10 +510,8 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext, { if (mForm) { if (mType == NS_FORM_BUTTON_SUBMIT || mType == NS_FORM_BUTTON_RESET) { - nsFormEvent event; - event.eventStructType = NS_FORM_EVENT; - event.message = (mType == NS_FORM_BUTTON_RESET) - ? NS_FORM_RESET : NS_FORM_SUBMIT; + nsFormEvent event((mType == NS_FORM_BUTTON_RESET) + ? NS_FORM_RESET : NS_FORM_SUBMIT); event.originator = this; nsEventStatus status = nsEventStatus_eIgnore; diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp index 5038e988887..75d0d068666 100644 --- a/mozilla/content/html/content/src/nsHTMLFormElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp @@ -603,10 +603,7 @@ nsHTMLFormElement::Reset() // the frame does not exist. This does not have an effect right now, but // If PresShell::HandleEventWithTarget() ever starts to work for elements // without frames, that should be called instead. - nsFormEvent event; - event.eventStructType = NS_FORM_EVENT; - event.message = NS_FORM_RESET; - event.originator = nsnull; + nsFormEvent event(NS_FORM_RESET); nsEventStatus status = nsEventStatus_eIgnore; HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index 2e3afe0a163..076a8e92d91 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -1070,19 +1070,13 @@ nsHTMLInputElement::MaybeSubmitForm(nsIPresContext* aPresContext) if (submitControl) { // Fire the button's onclick handler and let the button handle // submitting the form. - nsGUIEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - event.widget = nsnull; + nsGUIEvent event(NS_MOUSE_LEFT_CLICK); nsEventStatus status = nsEventStatus_eIgnore; shell->HandleDOMEventWithTarget(submitControl, &event, &status); } else if (numTextControlsFound == 1) { // If there's only one text control, just submit the form nsCOMPtr form = do_QueryInterface(mForm); - nsFormEvent event; - event.eventStructType = NS_FORM_EVENT; - event.message = NS_FORM_SUBMIT; - event.originator = nsnull; + nsFormEvent event(NS_FORM_SUBMIT); nsEventStatus status = nsEventStatus_eIgnore; shell->HandleDOMEventWithTarget(form, &event, &status); } @@ -1147,9 +1141,7 @@ nsHTMLInputElement::FireOnChange() nsCOMPtr presContext; GetPresContext(this, getter_AddRefs(presContext)); nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_FORM_CHANGE; + nsEvent event(NS_FORM_CHANGE); HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } @@ -1284,9 +1276,7 @@ nsHTMLInputElement::Select() //If already handling select event, don't dispatch a second. if (!GET_BOOLBIT(mBitField, BF_HANDLING_SELECT_EVENT)) { - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_FORM_SELECTED; + nsEvent event(NS_FORM_SELECTED); SET_BOOLBIT(mBitField, BF_HANDLING_SELECT_EVENT, PR_TRUE); rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, @@ -1372,15 +1362,7 @@ nsHTMLInputElement::Click() if (context) { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_MOUSE_LEFT_CLICK); SET_BOOLBIT(mBitField, BF_HANDLING_CLICK, PR_TRUE); @@ -1609,15 +1591,7 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext, case NS_FORM_INPUT_IMAGE: // Bug 34418 { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_MOUSE_LEFT_CLICK); rv = HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } // case @@ -1705,9 +1679,8 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext, case NS_FORM_INPUT_IMAGE: { if (mForm) { - nsFormEvent event; - event.eventStructType = NS_FORM_EVENT; - event.message = (mType == NS_FORM_INPUT_RESET) ? NS_FORM_RESET : NS_FORM_SUBMIT; + nsFormEvent event((mType == NS_FORM_INPUT_RESET) ? + NS_FORM_RESET : NS_FORM_SUBMIT); event.originator = this; nsEventStatus status = nsEventStatus_eIgnore; diff --git a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp index 436baf667d3..22e090aa68d 100644 --- a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp @@ -570,10 +570,7 @@ nsHTMLScriptElement::ScriptAvailable(nsresult aResult, GetPresContext(this, getter_AddRefs(presContext)); nsEventStatus status = nsEventStatus_eIgnore; - nsScriptErrorEvent event; - event.eventStructType = NS_EVENT; - - event.message = NS_SCRIPT_ERROR; + nsScriptErrorEvent event(NS_SCRIPT_ERROR); event.lineNr = aLineNo; @@ -606,10 +603,7 @@ nsHTMLScriptElement::ScriptEvaluated(nsresult aResult, GetPresContext(this, getter_AddRefs(presContext)); nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - - event.message = NS_SUCCEEDED(aResult) ? NS_SCRIPT_LOAD : NS_SCRIPT_ERROR; + nsEvent event(NS_SUCCEEDED(aResult) ? NS_SCRIPT_LOAD : NS_SCRIPT_ERROR); rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp index ea9821b6ff7..ec871bcdafe 100644 --- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -357,11 +357,7 @@ nsHTMLTextAreaElement::Select() GetPresContext(this, getter_AddRefs(presContext)); nsEventStatus status = nsEventStatus_eIgnore; - nsGUIEvent event; - event.eventStructType = NS_GUI_EVENT; - event.message = NS_FORM_SELECTED; - event.flags = NS_EVENT_FLAG_NONE; - event.widget = nsnull; + nsGUIEvent event(NS_FORM_SELECTED); rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); // If the DOM event was not canceled (e.g. by a JS event handler diff --git a/mozilla/content/svg/content/src/nsSVGAttributes.cpp b/mozilla/content/svg/content/src/nsSVGAttributes.cpp index e9940fce8e7..66a83f70dcd 100644 --- a/mozilla/content/svg/content/src/nsSVGAttributes.cpp +++ b/mozilla/content/svg/content/src/nsSVGAttributes.cpp @@ -645,10 +645,7 @@ nsSVGAttributes::SetAttr(nsINodeInfo* aNodeInfo, if (nsGenericElement::HasMutationListeners(mContent, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) { nsCOMPtr node(do_QueryInterface(mContent)); - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_ATTRMODIFIED; - mutation.mTarget = node; + nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node); CallQueryInterface(attr, NS_STATIC_CAST(nsIDOMNode**, @@ -717,10 +714,7 @@ nsSVGAttributes::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, if (mContent && nsGenericElement::HasMutationListeners(mContent, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) { nsCOMPtr node(do_QueryInterface(mContent)); - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_ATTRMODIFIED; - mutation.mTarget = node; + nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node); CallQueryInterface(attr, NS_STATIC_CAST(nsIDOMNode**, diff --git a/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp b/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp index 6d78bb176f6..bb4fdd92fe8 100644 --- a/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp @@ -474,15 +474,7 @@ nsresult nsXBLPrototypeHandler::BindingAttached(nsIDOMEventReceiver* aReceiver) { nsresult ret; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_COMMAND; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_COMMAND); nsCOMPtr listenerManager; if (NS_FAILED(ret = aReceiver->GetListenerManager(getter_AddRefs(listenerManager)))) { @@ -514,15 +506,7 @@ nsresult nsXBLPrototypeHandler::BindingDetached(nsIDOMEventReceiver* aReceiver) { nsresult ret; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_COMMAND; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_COMMAND); nsCOMPtr listenerManager; if (NS_FAILED(ret = aReceiver->GetListenerManager(getter_AddRefs(listenerManager)))) { diff --git a/mozilla/content/xml/content/src/nsXMLElement.cpp b/mozilla/content/xml/content/src/nsXMLElement.cpp index b4edb8c668d..7de3966d4de 100644 --- a/mozilla/content/xml/content/src/nsXMLElement.cpp +++ b/mozilla/content/xml/content/src/nsXMLElement.cpp @@ -430,14 +430,11 @@ nsXMLElement::HandleDOMEvent(nsIPresContext* aPresContext, if (aEvent->eventStructType == NS_KEY_EVENT) { nsKeyEvent* keyEvent = NS_STATIC_CAST(nsKeyEvent*, aEvent); if (keyEvent->keyCode == NS_VK_RETURN) { - nsMouseEvent event; nsEventStatus status = nsEventStatus_eIgnore; //fire click - event.message = NS_MOUSE_LEFT_CLICK; - event.eventStructType = NS_MOUSE_EVENT; nsGUIEvent* guiEvent = NS_STATIC_CAST(nsGUIEvent*, aEvent); - event.widget = guiEvent->widget; + nsMouseEvent event(NS_MOUSE_LEFT_CLICK, guiEvent->widget); event.point = aEvent->point; event.refPoint = aEvent->refPoint; event.clickCount = 1; diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index 2e863ea7163..0ddf38cea62 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -683,9 +683,7 @@ nsXMLDocument::EndLoad() // Generate a document load event for the case when an XML document was loaded // as pure data without any presentation attached to it. nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_PAGE_LOAD; + nsEvent event(NS_PAGE_LOAD); nsCOMPtr sgo; nsCOMPtr container = diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 5b58076e222..913015d9d60 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -1862,11 +1862,7 @@ nsXULElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify, if (mDocument && HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEINSERTED)) { - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_NODEINSERTED; - mutation.mTarget = do_QueryInterface(aKid); - + nsMutationEvent mutation(NS_MUTATION_NODEINSERTED, aKid); mutation.mRelatedNode = do_QueryInterface(NS_STATIC_CAST(nsIStyledContent*, this)); @@ -1917,10 +1913,7 @@ nsXULElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify, } if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED)) { - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_SUBTREEMODIFIED; - mutation.mTarget = do_QueryInterface(NS_STATIC_CAST(nsIStyledContent*, this)); + nsMutationEvent mutation(NS_MUTATION_SUBTREEMODIFIED, this); mutation.mRelatedNode = do_QueryInterface(oldKid); nsEventStatus status = nsEventStatus_eIgnore; @@ -1967,11 +1960,7 @@ nsXULElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEINSERTED)) { - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_NODEINSERTED; - mutation.mTarget = do_QueryInterface(aKid); - + nsMutationEvent mutation(NS_MUTATION_NODEINSERTED, aKid); mutation.mRelatedNode = do_QueryInterface(NS_STATIC_CAST(nsIStyledContent*, this)); @@ -1998,11 +1987,7 @@ nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify); if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEREMOVED)) { - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_NODEREMOVED; - mutation.mTarget = do_QueryInterface(oldKid); - + nsMutationEvent mutation(NS_MUTATION_NODEREMOVED, oldKid); mutation.mRelatedNode = do_QueryInterface(NS_STATIC_CAST(nsIStyledContent*, this)); @@ -2314,10 +2299,7 @@ nsXULElement::FinishSetAttr(PRInt32 aAttrNS, nsIAtom* aAttrName, binding->AttributeChanged(aAttrName, aAttrNS, PR_FALSE, aNotify); if (HasMutationListeners(NS_STATIC_CAST(nsIStyledContent*, this), NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) { - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_ATTRMODIFIED; - mutation.mTarget = do_QueryInterface(NS_STATIC_CAST(nsIStyledContent*, this)); + nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, this); nsAutoString attrName2; aAttrName->ToString(attrName2); @@ -2543,11 +2525,7 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify) // Fire mutation listeners if (HasMutationListeners(NS_STATIC_CAST(nsIStyledContent*, this), NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) { - nsMutationEvent mutation; - mutation.eventStructType = NS_MUTATION_EVENT; - mutation.message = NS_MUTATION_ATTRMODIFIED; - mutation.mTarget = - do_QueryInterface(NS_STATIC_CAST(nsIStyledContent*, this)); + nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, this); nsAutoString attrName2; aName->ToString(attrName2); @@ -4126,20 +4104,9 @@ nsXULElement::Click() nsIPresShell *shell = doc->GetShellAt(i); shell->GetPresContext(getter_AddRefs(context)); - nsMouseEvent eventDown; - eventDown.eventStructType = NS_MOUSE_EVENT; - eventDown.message = NS_MOUSE_LEFT_BUTTON_DOWN; - eventDown.isShift = PR_FALSE; - eventDown.isControl = PR_FALSE; - eventDown.isAlt = PR_FALSE; - eventDown.isMeta = PR_FALSE; - eventDown.clickCount = 0; - eventDown.widget = nsnull; - - // use copy constructor for bit-wise copy - nsMouseEvent eventUp(eventDown), eventClick(eventDown); - eventUp.message = NS_MOUSE_LEFT_BUTTON_UP; - eventClick.message = NS_XUL_CLICK; + nsMouseEvent eventDown(NS_MOUSE_LEFT_BUTTON_DOWN), + eventUp(NS_MOUSE_LEFT_BUTTON_UP), + eventClick(NS_XUL_CLICK); // send mouse down nsEventStatus status = nsEventStatus_eIgnore; @@ -4175,9 +4142,7 @@ nsXULElement::DoCommand() shell->GetPresContext(getter_AddRefs(context)); nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_COMMAND; + nsMouseEvent event(NS_XUL_COMMAND); HandleDOMEvent(context, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } diff --git a/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp b/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp index 49966d4d49d..ef1b12357b4 100644 --- a/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp +++ b/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp @@ -375,9 +375,7 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName) // Handle the DOM event nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_COMMAND_UPDATE; + nsEvent event(NS_XUL_COMMAND_UPDATE); content->HandleDOMEvent(context, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } } diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 990563a3bca..3857f920bf9 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -1059,9 +1059,7 @@ nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster, // This is the right element. Execute the // |onbroadcast| event handler - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_BROADCAST; + nsEvent event(NS_XUL_BROADCAST); PRInt32 j = mPresShells.Count(); while (--j >= 0) { diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index c8127f5bd49..dface115f87 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -889,10 +889,7 @@ GlobalWindowImpl::HandleDOMEvent(nsIPresContext* aPresContext, // onload event for the frame element. nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - - event.eventStructType = NS_EVENT; - event.message = NS_PAGE_LOAD; + nsEvent event(NS_PAGE_LOAD); // Most of the time we could get a pres context to pass in here, // but not always (i.e. if this window is not shown there won't @@ -4275,15 +4272,9 @@ GlobalWindowImpl::Activate() NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE); nsEventStatus status; - nsGUIEvent guiEvent; - guiEvent.eventStructType = NS_GUI_EVENT; - guiEvent.point.x = 0; - guiEvent.point.y = 0; + nsGUIEvent guiEvent(NS_ACTIVATE, widget); guiEvent.time = PR_IntervalNow(); - guiEvent.nativeMsg = nsnull; - guiEvent.message = NS_ACTIVATE; - guiEvent.widget = widget; vm->DispatchEvent(&guiEvent, &status); @@ -4309,15 +4300,9 @@ GlobalWindowImpl::Deactivate() NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE); nsEventStatus status; - nsGUIEvent guiEvent; - guiEvent.eventStructType = NS_GUI_EVENT; - guiEvent.point.x = 0; - guiEvent.point.y = 0; + nsGUIEvent guiEvent(NS_DEACTIVATE, widget); guiEvent.time = PR_IntervalNow(); - guiEvent.nativeMsg = nsnull; - guiEvent.message = NS_DEACTIVATE; - guiEvent.widget = widget; vm->DispatchEvent(&guiEvent, &status); diff --git a/mozilla/dom/src/base/nsJSEnvironment.cpp b/mozilla/dom/src/base/nsJSEnvironment.cpp index cd6e4a6d45a..df056a99a70 100644 --- a/mozilla/dom/src/base/nsJSEnvironment.cpp +++ b/mozilla/dom/src/base/nsJSEnvironment.cpp @@ -182,9 +182,7 @@ NS_ScriptErrorReporter(JSContext *cx, docShell->GetPresContext(getter_AddRefs(presContext)); if (presContext && errorDepth < 2) { - nsScriptErrorEvent errorevent; - errorevent.eventStructType = NS_EVENT; - errorevent.message = NS_SCRIPT_ERROR; + nsScriptErrorEvent errorevent(NS_SCRIPT_ERROR); errorevent.fileName = fileName.get(); errorevent.errorMsg = msg.get(); diff --git a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp index 374f7f0690a..11d9c7cf344 100644 --- a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp @@ -1082,9 +1082,7 @@ nsXMLHttpRequest::RequestCompleted() return NS_ERROR_FAILURE; } - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_PAGE_LOAD; + nsEvent event(NS_PAGE_LOAD); rv = manager->CreateEvent(nsnull, &event, NS_LITERAL_STRING("HTMLEvents"), getter_AddRefs(domevent)); diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index fd4c2a89aac..efd27a34d29 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -906,10 +906,8 @@ DocumentViewerImpl::LoadComplete(nsresult aStatus) // Now, fire either an OnLoad or OnError event to the document... if(NS_SUCCEEDED(aStatus)) { nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; + nsEvent event(NS_PAGE_LOAD); - event.eventStructType = NS_EVENT; - event.message = NS_PAGE_LOAD; rv = global->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); #ifdef MOZ_TIMELINE @@ -985,10 +983,8 @@ DocumentViewerImpl::Unload() // Now, fire an Unload event to the document... nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; + nsEvent event(NS_PAGE_UNLOAD); - event.eventStructType = NS_EVENT; - event.message = NS_PAGE_UNLOAD; return global->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 920502b8a4f..763e6e5fdac 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -3020,11 +3020,8 @@ PresShell::FireResizeEvent() return; //Send resize event from here. - nsEvent event; + nsEvent event(NS_RESIZE_EVENT); nsEventStatus status = nsEventStatus_eIgnore; - event.eventStructType = NS_EVENT; - event.message = NS_RESIZE_EVENT; - event.time = 0; nsCOMPtr globalObj = mDocument->GetScriptGlobalObject(); if (globalObj) { diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index 63f9aeacd86..cf05ebd7c8a 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -576,15 +576,7 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup) // fire a popup dom event nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = aShowPopup ? NS_XUL_POPUP_SHOWING : NS_XUL_POPUP_HIDING; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(aShowPopup ? NS_XUL_POPUP_SHOWING : NS_XUL_POPUP_HIDING); nsIPresShell *shell = mPresContext->GetPresShell(); if (shell) diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index 62fe0911a9d..b676c927670 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -2483,9 +2483,7 @@ nsListControlFrame::FireOnChange() // Dispatch the NS_FORM_CHANGE event nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_FORM_CHANGE; + nsEvent event(NS_FORM_CHANGE); nsIPresShell *presShell = mPresContext->GetPresShell(); if (presShell) { diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index e1e8d2bc195..f2f530b23c7 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -269,9 +269,7 @@ nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection* if (presShell) { nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_FORM_SELECTED; + nsEvent event(NS_FORM_SELECTED); presShell->HandleEventWithTarget(&event,mFrame,content,NS_EVENT_FLAG_INIT,&status); } @@ -2809,11 +2807,7 @@ nsTextControlFrame::FireOnInput() // Dispatch the "input" event nsEventStatus status = nsEventStatus_eIgnore; - nsGUIEvent event; - event.eventStructType = NS_GUI_EVENT; - event.widget = nsnull; - event.message = NS_FORM_INPUT; - event.flags = NS_EVENT_FLAG_INIT; + nsGUIEvent event(NS_FORM_INPUT); // Have the content handle the event, propagating it according to normal // DOM rules. @@ -2862,15 +2856,7 @@ nsTextControlFrame::FireOnChange() if (NS_SUCCEEDED(GetFormContent(*getter_AddRefs(content)))) { nsEventStatus status = nsEventStatus_eIgnore; - nsInputEvent event; - event.eventStructType = NS_INPUT_EVENT; - event.widget = nsnull; - event.message = NS_FORM_CHANGE; - event.flags = NS_EVENT_FLAG_INIT; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; + nsInputEvent event(NS_FORM_CHANGE); // Have the content handle the event. nsWeakPtr &shell = mTextSelImpl->GetPresShell(); diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index c8b7f698c89..7363b724e27 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -1041,10 +1041,7 @@ nsGfxScrollFrameInner::CurPosAttributeChanged(nsIPresContext* aPresContext, // Fire the onScroll event now that we have scrolled nsIPresShell *presShell = mOuter->mPresContext->GetPresShell(); if (presShell) { - nsScrollbarEvent event; - event.eventStructType = NS_SCROLLBAR_EVENT; - event.message = NS_SCROLL_EVENT; - event.flags = 0; + nsScrollbarEvent event(NS_SCROLL_EVENT); nsEventStatus status = nsEventStatus_eIgnore; // note if hcontent is non-null then hframe must be non-null. // likewise for vcontent and vframe. Thus targetFrame will always diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 66b8a21eac0..71bfe6f1055 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -3234,9 +3234,7 @@ nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent) nsEvent * theEvent; privateEvent->GetInternalNSEvent(&theEvent); if (theEvent) { - nsGUIEvent focusEvent; - memset(&focusEvent, 0, sizeof(focusEvent)); - focusEvent.message = theEvent->message; // we only care about the message in ProcessEvent + nsGUIEvent focusEvent(theEvent->message); // we only care about the message in ProcessEvent nsEventStatus rv = ProcessEvent(focusEvent); if (nsEventStatus_eConsumeNoDefault == rv) { aFocusEvent->PreventDefault(); diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index 49750ab488a..82a1617c257 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -1372,7 +1372,7 @@ nsSelection::HandleTextEvent(nsGUIEvent *aGUIEvent) printf("nsSelection: HandleTextEvent\n"); #endif nsresult result(NS_OK); - if (NS_TEXT_EVENT == aGUIEvent->message) { + if (NS_TEXT_TEXT == aGUIEvent->message) { PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); result = mDomSelections[index]->ScrollIntoView(); } diff --git a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp index c8b7f698c89..7363b724e27 100644 --- a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp @@ -1041,10 +1041,7 @@ nsGfxScrollFrameInner::CurPosAttributeChanged(nsIPresContext* aPresContext, // Fire the onScroll event now that we have scrolled nsIPresShell *presShell = mOuter->mPresContext->GetPresShell(); if (presShell) { - nsScrollbarEvent event; - event.eventStructType = NS_SCROLLBAR_EVENT; - event.message = NS_SCROLL_EVENT; - event.flags = 0; + nsScrollbarEvent event(NS_SCROLL_EVENT); nsEventStatus status = nsEventStatus_eIgnore; // note if hcontent is non-null then hframe must be non-null. // likewise for vcontent and vframe. Thus targetFrame will always diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 66b8a21eac0..71bfe6f1055 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -3234,9 +3234,7 @@ nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent) nsEvent * theEvent; privateEvent->GetInternalNSEvent(&theEvent); if (theEvent) { - nsGUIEvent focusEvent; - memset(&focusEvent, 0, sizeof(focusEvent)); - focusEvent.message = theEvent->message; // we only care about the message in ProcessEvent + nsGUIEvent focusEvent(theEvent->message); // we only care about the message in ProcessEvent nsEventStatus rv = ProcessEvent(focusEvent); if (nsEventStatus_eConsumeNoDefault == rv) { aFocusEvent->PreventDefault(); diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 920502b8a4f..763e6e5fdac 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -3020,11 +3020,8 @@ PresShell::FireResizeEvent() return; //Send resize event from here. - nsEvent event; + nsEvent event(NS_RESIZE_EVENT); nsEventStatus status = nsEventStatus_eIgnore; - event.eventStructType = NS_EVENT; - event.message = NS_RESIZE_EVENT; - event.time = 0; nsCOMPtr globalObj = mDocument->GetScriptGlobalObject(); if (globalObj) { diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index 63f9aeacd86..cf05ebd7c8a 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -576,15 +576,7 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup) // fire a popup dom event nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = aShowPopup ? NS_XUL_POPUP_SHOWING : NS_XUL_POPUP_HIDING; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(aShowPopup ? NS_XUL_POPUP_SHOWING : NS_XUL_POPUP_HIDING); nsIPresShell *shell = mPresContext->GetPresShell(); if (shell) diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index 62fe0911a9d..b676c927670 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -2483,9 +2483,7 @@ nsListControlFrame::FireOnChange() // Dispatch the NS_FORM_CHANGE event nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_FORM_CHANGE; + nsEvent event(NS_FORM_CHANGE); nsIPresShell *presShell = mPresContext->GetPresShell(); if (presShell) { diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp index e1e8d2bc195..f2f530b23c7 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp @@ -269,9 +269,7 @@ nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection* if (presShell) { nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_FORM_SELECTED; + nsEvent event(NS_FORM_SELECTED); presShell->HandleEventWithTarget(&event,mFrame,content,NS_EVENT_FLAG_INIT,&status); } @@ -2809,11 +2807,7 @@ nsTextControlFrame::FireOnInput() // Dispatch the "input" event nsEventStatus status = nsEventStatus_eIgnore; - nsGUIEvent event; - event.eventStructType = NS_GUI_EVENT; - event.widget = nsnull; - event.message = NS_FORM_INPUT; - event.flags = NS_EVENT_FLAG_INIT; + nsGUIEvent event(NS_FORM_INPUT); // Have the content handle the event, propagating it according to normal // DOM rules. @@ -2862,15 +2856,7 @@ nsTextControlFrame::FireOnChange() if (NS_SUCCEEDED(GetFormContent(*getter_AddRefs(content)))) { nsEventStatus status = nsEventStatus_eIgnore; - nsInputEvent event; - event.eventStructType = NS_INPUT_EVENT; - event.widget = nsnull; - event.message = NS_FORM_CHANGE; - event.flags = NS_EVENT_FLAG_INIT; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; + nsInputEvent event(NS_FORM_CHANGE); // Have the content handle the event. nsWeakPtr &shell = mTextSelImpl->GetPresShell(); diff --git a/mozilla/layout/xul/base/src/nsButtonBoxFrame.cpp b/mozilla/layout/xul/base/src/nsButtonBoxFrame.cpp index 08b4a484548..0a0b893aad7 100644 --- a/mozilla/layout/xul/base/src/nsButtonBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsButtonBoxFrame.cpp @@ -162,22 +162,13 @@ nsButtonBoxFrame::MouseClicked (nsIPresContext* aPresContext, nsGUIEvent* aEvent // Execute the oncommand event handler. nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_COMMAND; + nsMouseEvent event(NS_XUL_COMMAND); if(aEvent) { event.isShift = ((nsInputEvent*)(aEvent))->isShift; event.isControl = ((nsInputEvent*)(aEvent))->isControl; event.isAlt = ((nsInputEvent*)(aEvent))->isAlt; event.isMeta = ((nsInputEvent*)(aEvent))->isMeta; - } else { - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; } - event.clickCount = 0; - event.widget = nsnull; // Have the content handle the event, propagating it according to normal DOM rules. nsIPresShell *shell = aPresContext->GetPresShell(); diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp index aa7c286a4b6..4ae6e9a0ed4 100644 --- a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp @@ -130,9 +130,7 @@ HandleImagePLEvent(nsIContent *aContent, PRUint32 aMessage, PRUint32 aFlags) } nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = aMessage; + nsEvent event(aMessage); aContent->HandleDOMEvent(pres_context, &event, nsnull, aFlags, &status); } diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.cpp b/mozilla/layout/xul/base/src/nsMenuFrame.cpp index 70a13ba5aec..28b1ddad0ae 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuFrame.cpp @@ -1619,9 +1619,7 @@ nsMenuFrame::Execute(nsGUIEvent *aEvent) nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_COMMAND; + nsMouseEvent event(NS_XUL_COMMAND); if (aEvent && (aEvent->eventStructType == NS_MOUSE_EVENT || aEvent->eventStructType == NS_KEY_EVENT || aEvent->eventStructType == NS_ACCESSIBLE_EVENT)) { @@ -1630,14 +1628,8 @@ nsMenuFrame::Execute(nsGUIEvent *aEvent) event.isControl = NS_STATIC_CAST(nsInputEvent *, aEvent)->isControl; event.isAlt = NS_STATIC_CAST(nsInputEvent *, aEvent)->isAlt; event.isMeta = NS_STATIC_CAST(nsInputEvent *, aEvent)->isMeta; - } else { - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; } - event.clickCount = 0; - event.widget = nsnull; + // The order of the nsIViewManager and nsIPresShell COM pointers is // important below. We want the pres shell to get released before the // associated view manager on exit from this function. @@ -1672,15 +1664,7 @@ PRBool nsMenuFrame::OnCreate() { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_POPUP_SHOWING; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_SHOWING); nsCOMPtr child; GetMenuChildrenElement(getter_AddRefs(child)); @@ -1769,15 +1753,7 @@ PRBool nsMenuFrame::OnCreated() { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_POPUP_SHOWN; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_SHOWN); nsCOMPtr child; GetMenuChildrenElement(getter_AddRefs(child)); @@ -1803,15 +1779,7 @@ PRBool nsMenuFrame::OnDestroy() { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_POPUP_HIDING; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_HIDING); nsCOMPtr child; GetMenuChildrenElement(getter_AddRefs(child)); @@ -1837,15 +1805,7 @@ PRBool nsMenuFrame::OnDestroyed() { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_POPUP_HIDDEN; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_HIDDEN); nsCOMPtr child; GetMenuChildrenElement(getter_AddRefs(child)); diff --git a/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp b/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp index d05882db169..e7cddf241d5 100644 --- a/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp +++ b/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp @@ -573,15 +573,7 @@ PRBool nsPopupSetFrame::OnCreate(PRInt32 aX, PRInt32 aY, nsIContent* aPopupContent) { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_POPUP_EVENT; - event.message = NS_XUL_POPUP_SHOWING; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_SHOWING); event.point.x = aX; event.point.y = aY; @@ -658,15 +650,7 @@ PRBool nsPopupSetFrame::OnCreated(PRInt32 aX, PRInt32 aY, nsIContent* aPopupContent) { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_POPUP_EVENT; - event.message = NS_XUL_POPUP_SHOWN; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_SHOWN); event.point.x = aX; event.point.y = aY; @@ -688,15 +672,7 @@ PRBool nsPopupSetFrame::OnDestroy(nsIContent* aPopupContent) { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_POPUP_EVENT; - event.message = NS_XUL_POPUP_HIDING; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_HIDING); if (aPopupContent) { nsIPresShell *shell = mPresContext->GetPresShell(); @@ -715,15 +691,7 @@ PRBool nsPopupSetFrame::OnDestroyed(nsIContent* aPopupContent) { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_POPUP_EVENT; - event.message = NS_XUL_POPUP_HIDDEN; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_HIDDEN); if (aPopupContent) { nsIPresShell *shell = mPresContext->GetPresShell(); diff --git a/mozilla/layout/xul/base/src/nsResizerFrame.cpp b/mozilla/layout/xul/base/src/nsResizerFrame.cpp index 77db136bdb3..2b1a7b65c4e 100644 --- a/mozilla/layout/xul/base/src/nsResizerFrame.cpp +++ b/mozilla/layout/xul/base/src/nsResizerFrame.cpp @@ -361,14 +361,6 @@ nsResizerFrame::MouseClicked (nsIPresContext* aPresContext) { // Execute the oncommand event handler. nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_COMMAND; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_COMMAND); mContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } diff --git a/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp b/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp index 45d8ad34acc..860d1318429 100644 --- a/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp @@ -504,13 +504,10 @@ nsScrollBoxFrame::PostScrollPortEvent(nsIPresShell* aShell, PRBool aOverflow, ns if (!mContent) return; - nsScrollPortEvent* event = new nsScrollPortEvent(); - event->eventStructType = NS_SCROLLPORT_EVENT; - event->widget = nsnull; + nsScrollPortEvent* event = new nsScrollPortEvent(aOverflow ? + NS_SCROLLPORT_OVERFLOW : + NS_SCROLLPORT_UNDERFLOW); event->orient = aType; - event->nativeMsg = nsnull; - event->message = aOverflow ? NS_SCROLLPORT_OVERFLOW : NS_SCROLLPORT_UNDERFLOW; - aShell->PostDOMEvent(mContent, event); } diff --git a/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp b/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp index 06eb36405f8..455e0eb2587 100644 --- a/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp @@ -235,14 +235,6 @@ nsTitleBarFrame::MouseClicked (nsIPresContext* aPresContext) { // Execute the oncommand event handler. nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_COMMAND; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_COMMAND); mContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 2c5d6a7c6c2..b76bae42701 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -1050,12 +1050,9 @@ nsresult nsTreeBodyFrame::CheckVerticalOverflow() } if (verticalOverflowChanged) { - nsScrollPortEvent event; - event.eventStructType = NS_SCROLLPORT_EVENT; - event.widget = nsnull; + nsScrollPortEvent event(mVerticalOverflow ? NS_SCROLLPORT_OVERFLOW + : NS_SCROLLPORT_UNDERFLOW); event.orient = nsScrollPortEvent::vertical; - event.nativeMsg = nsnull; - event.message = mVerticalOverflow ? NS_SCROLLPORT_OVERFLOW : NS_SCROLLPORT_UNDERFLOW; nsEventStatus status = nsEventStatus_eIgnore; mContent->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeSelection.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeSelection.cpp index 75c68cbdb69..f1549c79054 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeSelection.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeSelection.cpp @@ -782,9 +782,7 @@ nsTreeSelection::FireOnSelectHandler() shell->GetPresContext(getter_AddRefs(aPresContext)); nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_FORM_SELECTED; + nsEvent event(NS_FORM_SELECTED); content->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); diff --git a/mozilla/view/src/nsViewManager.cpp b/mozilla/view/src/nsViewManager.cpp index d98952daac9..30195fd318c 100644 --- a/mozilla/view/src/nsViewManager.cpp +++ b/mozilla/view/src/nsViewManager.cpp @@ -2045,7 +2045,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS // // if the event is an nsTextEvent, we need to map the reply back into platform coordinates // - if (aEvent->message==NS_TEXT_EVENT) { + if (aEvent->message==NS_TEXT_TEXT) { ((nsTextEvent*)aEvent)->theReply.mCursorPosition.x=NSTwipsToIntPixels(((nsTextEvent*)aEvent)->theReply.mCursorPosition.x, t2p); ((nsTextEvent*)aEvent)->theReply.mCursorPosition.y=NSTwipsToIntPixels(((nsTextEvent*)aEvent)->theReply.mCursorPosition.y, t2p); ((nsTextEvent*)aEvent)->theReply.mCursorPosition.width=NSTwipsToIntPixels(((nsTextEvent*)aEvent)->theReply.mCursorPosition.width, t2p); diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index 02a28c642c9..fb6555520ff 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -689,36 +689,6 @@ HandleLocationEvent(nsGUIEvent *aEvent) } break; - case NS_DRAGDROP_EVENT: { - /*printf("Drag & Drop Event\n"); - nsDragDropEvent * ev = (nsDragDropEvent *)aEvent; - nsAutoString fileURL; - BuildFileURL(ev->mURL, fileURL); - nsAutoString fileName(ev->mURL); - char * str = ToNewCString(fileName); - - PRInt32 len = strlen(str); - PRInt32 sum = len + sizeof(FILE_PROTOCOL); - char* lpszFileURL = new char[sum]; - - // Translate '\' to '/' - for (PRInt32 i = 0; i < len; i++) { - if (str[i] == '\\') { - str[i] = '/'; - } - } - - // Build the file URL - PR_snprintf(lpszFileURL, sum, "%s%s", FILE_PROTOCOL, str); - - // Ask the Web widget to load the file URL - nsString urlStr(lpszFileURL); - const PRUnichar * uniStr = fileURL.get(); - bw->GoTo(uniStr); - //delete [] lpszFileURL; - //delete [] str;*/ - } break; - default: break; } diff --git a/mozilla/widget/public/nsGUIEvent.h b/mozilla/widget/public/nsGUIEvent.h index 8cf783b3cf6..18da28980fe 100644 --- a/mozilla/widget/public/nsGUIEvent.h +++ b/mozilla/widget/public/nsGUIEvent.h @@ -75,14 +75,12 @@ class nsIURI; #define NS_KEY_EVENT 9 #define NS_MOUSE_EVENT 10 #define NS_MENU_EVENT 11 -#define NS_DRAGDROP_EVENT 12 +#define NS_SCRIPT_ERROR_EVENT 12 #define NS_TEXT_EVENT 13 -#define NS_COMPOSITION_START 14 -#define NS_COMPOSITION_END 15 +#define NS_COMPOSITION_EVENT 14 +#define NS_RECONVERSION_EVENT 15 #define NS_MOUSE_SCROLL_EVENT 16 -#define NS_COMPOSITION_QUERY 17 #define NS_SCROLLPORT_EVENT 18 -#define NS_RECONVERSION_QUERY 19 #define NS_ACCESSIBLE_EVENT 20 #define NS_FORM_EVENT 21 #define NS_FOCUS_EVENT 22 @@ -139,15 +137,15 @@ enum nsWindowZ { */ struct nsEvent { - nsEvent() - : eventStructType(NS_EVENT), - message(NS_EVENT_TYPE_NULL), + nsEvent(PRUint32 msg = 0, PRUint8 structType = NS_EVENT) + : eventStructType(structType), + message(msg), point(0, 0), refPoint(0, 0), time(0), - flags(NS_EVENT_FLAG_NONE), - internalAppFlags(NS_APP_EVENT_FLAG_NONE), - userType(nsnull) + flags(0), + internalAppFlags(0), + userType(0) { } @@ -173,10 +171,19 @@ struct nsEvent { * General graphic user interface event */ -struct nsGUIEvent : public nsEvent { - /// Originator of the event +struct nsGUIEvent : public nsEvent +{ + nsGUIEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_GUI_EVENT) + : nsEvent(msg, structType), + widget(w), nativeMsg(nsnull) + { + } + + /// Originator of the event nsIWidget* widget; - /// Internal platform specific message. + /// Internal platform specific message. void* nativeMsg; }; @@ -184,7 +191,15 @@ struct nsGUIEvent : public nsEvent { * Script error event */ -struct nsScriptErrorEvent : public nsEvent { +struct nsScriptErrorEvent : public nsEvent +{ + nsScriptErrorEvent(PRUint32 msg = 0, + PRUint8 structType = NS_SCRIPT_ERROR_EVENT) + : nsEvent(msg, structType), + lineNr(0), errorMsg(nsnull), fileName(nsnull) + { + } + PRInt32 lineNr; const PRUnichar* errorMsg; const PRUnichar* fileName; @@ -194,29 +209,55 @@ struct nsScriptErrorEvent : public nsEvent { * Window resize event */ -struct nsSizeEvent : public nsGUIEvent { - /// x,y width, height in pixels (client area) - nsRect *windowSize; - /// width of entire window (in pixels) - PRInt32 mWinWidth; - /// height of entire window (in pixels) - PRInt32 mWinHeight; +struct nsSizeEvent : public nsGUIEvent +{ + nsSizeEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_SIZE_EVENT) + : nsGUIEvent(msg, w, structType), + windowSize(nsnull), mWinWidth(0), mWinHeight(0) + { + } + + /// x,y width, height in pixels (client area) + nsRect *windowSize; + /// width of entire window (in pixels) + PRInt32 mWinWidth; + /// height of entire window (in pixels) + PRInt32 mWinHeight; }; /** * Window size mode event */ -struct nsSizeModeEvent : public nsGUIEvent { +struct nsSizeModeEvent : public nsGUIEvent +{ + nsSizeModeEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_SIZEMODE_EVENT) + : nsGUIEvent(msg, w, structType), + mSizeMode(nsSizeMode_Normal) + { + } - nsSizeMode mSizeMode; + nsSizeMode mSizeMode; }; /** * Window z-level event */ -struct nsZLevelEvent : public nsGUIEvent { +struct nsZLevelEvent : public nsGUIEvent +{ + nsZLevelEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_ZLEVEL_EVENT) + : nsGUIEvent(msg, w, structType), + mPlacement(nsWindowZTop), mReqBelow(nsnull), mActualBelow(nsnull), + mImmediate(PR_FALSE), mAdjusted(PR_FALSE) + { + } nsWindowZ mPlacement; nsIWidget *mReqBelow, // widget we request being below, if any @@ -229,133 +270,240 @@ struct nsZLevelEvent : public nsGUIEvent { * Window repaint event */ -struct nsPaintEvent : public nsGUIEvent { - /// Context to paint in. - nsIRenderingContext *renderingContext; - /// area to paint (should be used instead of rect) - nsIRegion *region; - /// x,y, width, height in pixels of area to paint - nsRect *rect; +struct nsPaintEvent : public nsGUIEvent +{ + nsPaintEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_PAINT_EVENT) + : nsGUIEvent(msg, w, structType), + renderingContext(nsnull), region(nsnull), rect(nsnull) + { + } + + /// Context to paint in. + nsIRenderingContext *renderingContext; + /// area to paint (should be used instead of rect) + nsIRegion *region; + /// x,y, width, height in pixels of area to paint + nsRect *rect; }; /** * Scrollbar event */ -struct nsScrollbarEvent : public nsGUIEvent { - /// ranges between scrollbar 0 and (maxRange - thumbSize). See nsIScrollbar - PRUint32 position; +struct nsScrollbarEvent : public nsGUIEvent +{ + nsScrollbarEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_SCROLLBAR_EVENT) + : nsGUIEvent(msg, w, structType), + position(0) + { + } + + /// ranges between scrollbar 0 and (maxRange - thumbSize). See nsIScrollbar + PRUint32 position; }; -struct nsScrollPortEvent : public nsGUIEvent { +struct nsScrollPortEvent : public nsGUIEvent +{ enum orientType { vertical = 0, horizontal = 1, both = 2 }; + nsScrollPortEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_SCROLLPORT_EVENT) + : nsGUIEvent(msg, w, structType), + orient(vertical) + { + } + orientType orient; }; -struct nsInputEvent : public nsGUIEvent { - /// PR_TRUE indicates the shift key is down - PRBool isShift; - /// PR_TRUE indicates the control key is down - PRBool isControl; - /// PR_TRUE indicates the alt key is down - PRBool isAlt; - /// PR_TRUE indicates the meta key is down - /// (or, on Mac, the Command key) - PRBool isMeta; +struct nsInputEvent : public nsGUIEvent +{ + nsInputEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_INPUT_EVENT) + : nsGUIEvent(msg, w, structType), + isShift(PR_FALSE), isControl(PR_FALSE), isAlt(PR_FALSE), isMeta(PR_FALSE) + { + } + + /// PR_TRUE indicates the shift key is down + PRBool isShift; + /// PR_TRUE indicates the control key is down + PRBool isControl; + /// PR_TRUE indicates the alt key is down + PRBool isAlt; + /// PR_TRUE indicates the meta key is down (or, on Mac, the Command key) + PRBool isMeta; }; /** * Mouse event */ -struct nsMouseEvent : public nsInputEvent { - /// The number of mouse clicks - PRUint32 clickCount; - /// Special return code for MOUSE_ACTIVATE to signal - /// if the target accepts activation (1), or denies it (0) - PRBool acceptActivation; +struct nsMouseEvent : public nsInputEvent +{ + nsMouseEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_MOUSE_EVENT) + : nsInputEvent(msg, w, structType), + clickCount(0), acceptActivation(PR_FALSE) + { + } + + /// The number of mouse clicks + PRUint32 clickCount; + /// Special return code for MOUSE_ACTIVATE to signal + /// if the target accepts activation (1), or denies it (0) + PRBool acceptActivation; }; /** * Accessible event */ -struct nsAccessibleEvent : public nsInputEvent { - nsIAccessible* accessible; +struct nsAccessibleEvent : public nsInputEvent +{ + nsAccessibleEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_ACCESSIBLE_EVENT) + : nsInputEvent(msg, w, structType), + accessible(nsnull) + { + } + + nsIAccessible* accessible; }; /** * Keyboard event */ -struct nsKeyEvent : public nsInputEvent { - /// see NS_VK codes - PRUint32 keyCode; - /// OS translated Unicode char - PRUint32 charCode; - // indicates whether the event signifies a printable character - PRBool isChar; +struct nsKeyEvent : public nsInputEvent +{ + nsKeyEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_KEY_EVENT) + : nsInputEvent(msg, w, structType), + keyCode(0), charCode(0), isChar(0) + { + } + + /// see NS_VK codes + PRUint32 keyCode; + /// OS translated Unicode char + PRUint32 charCode; + // indicates whether the event signifies a printable character + PRBool isChar; }; /** * IME Related Events */ struct nsTextRange { - PRUint32 mStartOffset; - PRUint32 mEndOffset; - PRUint32 mRangeType; + nsTextRange() + : mStartOffset(0), mEndOffset(0), mRangeType(0) + { + } + + PRUint32 mStartOffset; + PRUint32 mEndOffset; + PRUint32 mRangeType; }; typedef struct nsTextRange nsTextRange; typedef nsTextRange* nsTextRangeArray; struct nsTextEventReply { - nsRect mCursorPosition; - PRBool mCursorIsCollapsed; + nsTextEventReply() + : mCursorIsCollapsed(PR_FALSE) + { + } + + nsRect mCursorPosition; + PRBool mCursorIsCollapsed; }; typedef struct nsTextEventReply nsTextEventReply; -struct nsTextEvent : public nsInputEvent { - PRUnichar* theText; - nsTextEventReply theReply; - PRUint32 rangeCount; - nsTextRangeArray rangeArray; - PRBool isChar; +struct nsTextEvent : public nsInputEvent +{ + nsTextEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_TEXT_EVENT) + : nsInputEvent(msg, w, structType), + theText(nsnull), rangeCount(0), isChar(PR_FALSE) + { + } + + PRUnichar* theText; + nsTextEventReply theReply; + PRUint32 rangeCount; + nsTextRangeArray rangeArray; + PRBool isChar; }; -struct nsCompositionEvent : public nsInputEvent { - PRUint32 compositionMessage; - nsTextEventReply theReply; +struct nsCompositionEvent : public nsInputEvent +{ + nsCompositionEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_COMPOSITION_EVENT) + : nsInputEvent(msg, w, structType) + { + } + + nsTextEventReply theReply; }; -struct nsMouseScrollEvent : public nsInputEvent { - +struct nsMouseScrollEvent : public nsInputEvent +{ enum nsMouseScrollFlags { kIsFullPage = 1 << 0, kIsVertical = 1 << 1, kIsHorizontal = 1 << 2 }; + nsMouseScrollEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_MOUSE_SCROLL_EVENT) + : nsInputEvent(msg, w, structType), + scrollFlags(0), delta(0) + { + } + PRInt32 scrollFlags; PRInt32 delta; }; struct nsReconversionEventReply { + nsReconversionEventReply() + : mReconversionString(nsnull) + { + } + PRUnichar *mReconversionString; }; -struct nsReconversionEvent : public nsInputEvent { +struct nsReconversionEvent : public nsInputEvent +{ + nsReconversionEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_RECONVERSION_EVENT) + : nsInputEvent(msg, w, structType) + { + } + nsReconversionEventReply theReply; }; - - /** * MenuItem event * @@ -363,9 +511,18 @@ struct nsReconversionEvent : public nsInputEvent { * for the event */ -struct nsMenuEvent : public nsGUIEvent { +struct nsMenuEvent : public nsGUIEvent +{ + nsMenuEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_MENU_EVENT) + : nsGUIEvent(msg, w, structType), + mMenuItem(nsnull), mCommand(0) + { + } + nsIMenuItem * mMenuItem; - PRUint32 mCommand; + PRUint32 mCommand; }; /** @@ -375,14 +532,30 @@ struct nsMenuEvent : public nsGUIEvent { * originator is a weak pointer (does not hold a strong reference). */ -struct nsFormEvent : public nsEvent { +struct nsFormEvent : public nsEvent +{ + nsFormEvent(PRUint32 msg = 0, PRUint8 structType = NS_FORM_EVENT) + : nsEvent(msg, structType), + originator(nsnull) + { + } + nsIContent *originator; }; /** * Focus event */ -struct nsFocusEvent : public nsGUIEvent { +struct nsFocusEvent : public nsGUIEvent +{ + nsFocusEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_FOCUS_EVENT) + : nsGUIEvent(msg, w, structType), + isMozWindowTakingFocus(PR_FALSE) + { + } + PRBool isMozWindowTakingFocus; }; @@ -392,14 +565,31 @@ struct nsFocusEvent : public nsGUIEvent { * Custom commands from the operating system. eg. WM_APPCOMMAND on Windows */ -struct nsAppCommandEvent : public nsInputEvent { - PRUint32 appCommand; +struct nsAppCommandEvent : public nsInputEvent +{ + nsAppCommandEvent(PRUint32 msg = 0, + nsIWidget *w = nsnull, + PRUint8 structType = NS_APPCOMMAND_EVENT) + : nsInputEvent(msg, w, structType), + appCommand(0) + { + } + + PRUint32 appCommand; }; /** * blocked popup window event */ -struct nsPopupBlockedEvent : public nsEvent { +struct nsPopupBlockedEvent : public nsEvent +{ + nsPopupBlockedEvent(PRUint32 msg = 0, + PRUint8 structType = NS_POPUPBLOCKED_EVENT) + : nsEvent(msg, structType), + mRequestingWindowURI(nsnull), mPopupWindowURI(nsnull) + { + } + nsIURI* mRequestingWindowURI; // owning reference nsIURI* mPopupWindowURI; // owning reference }; @@ -408,11 +598,11 @@ struct nsPopupBlockedEvent : public nsEvent { * Event status for D&D Event */ enum nsDragDropEventStatus { - /// The event is a enter + /// The event is a enter nsDragDropEventStatus_eDragEntered, - /// The event is exit + /// The event is exit nsDragDropEventStatus_eDragExited, - /// The event is drop + /// The event is drop nsDragDropEventStatus_eDrop }; @@ -592,6 +782,20 @@ enum nsDragDropEventStatus { #define NS_APPCOMMAND_FAVORITES (NS_APPCOMMAND_START + 6) #define NS_APPCOMMAND_HOME (NS_APPCOMMAND_START + 7) +// composition events +#define NS_COMPOSITION_EVENT_START 2200 +#define NS_COMPOSITION_START (NS_COMPOSITION_EVENT_START) +#define NS_COMPOSITION_END (NS_COMPOSITION_EVENT_START + 1) +#define NS_COMPOSITION_QUERY (NS_COMPOSITION_EVENT_START + 2) + +// reconversion events +#define NS_RECONVERSION_START 2300 +#define NS_RECONVERSION_QUERY (NS_RECONVERSION_START) + +// text events +#define NS_TEXT_START 2400 +#define NS_TEXT_TEXT (NS_TEXT_START) + #define NS_IS_MOUSE_EVENT(evnt) \ (((evnt)->message == NS_MOUSE_LEFT_BUTTON_DOWN) || \ ((evnt)->message == NS_MOUSE_LEFT_BUTTON_UP) || \ @@ -628,7 +832,7 @@ enum nsDragDropEventStatus { ((evnt)->message == NS_KEY_UP)) #define NS_IS_IME_EVENT(evnt) \ - (((evnt)->message == NS_TEXT_EVENT) || \ + (((evnt)->message == NS_TEXT_TEXT) || \ ((evnt)->message == NS_COMPOSITION_START) || \ ((evnt)->message == NS_COMPOSITION_END) || \ ((evnt)->message == NS_RECONVERSION_QUERY) || \ @@ -779,4 +983,3 @@ enum nsDragDropEventStatus { #define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05 #endif // nsGUIEvent_h__ - diff --git a/mozilla/widget/src/beos/nsWindow.cpp b/mozilla/widget/src/beos/nsWindow.cpp index e9f5d434440..cbe638b9cbc 100644 --- a/mozilla/widget/src/beos/nsWindow.cpp +++ b/mozilla/widget/src/beos/nsWindow.cpp @@ -245,9 +245,8 @@ PRBool nsWindow::ConvertStatus(nsEventStatus aStatus) // Initialize an event to dispatch // //------------------------------------------------------------------------- -void nsWindow::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint) +void nsWindow::InitEvent(nsGUIEvent& event, nsPoint* aPoint) { - event.widget = this; NS_ADDREF(event.widget); if (nsnull == aPoint) // use the point from the event @@ -262,7 +261,6 @@ void nsWindow::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint event.point.y = aPoint->y; } event.time = PR_IntervalNow(); - event.message = aEventType; } //------------------------------------------------------------------------- @@ -305,9 +303,8 @@ PRBool nsWindow::DispatchWindowEvent(nsGUIEvent* event) PRBool nsWindow::DispatchStandardEvent(PRUint32 aMsg) { - nsGUIEvent event; - event.eventStructType = NS_GUI_EVENT; - InitEvent(event, aMsg); + nsGUIEvent event(aMsg, this) + InitEvent(event); PRBool result = DispatchWindowEvent(&event); NS_RELEASE(event.widget); @@ -1773,16 +1770,12 @@ bool nsWindow::CallMethod(MethodInfo *info) { NS_ASSERTION(info->nArgs == 1, "Wrong number of arguments to CallMethod"); - nsMouseScrollEvent scrollEvent; + nsMouseScrollEvent scrollEvent(NS_MOUSE_SCROLL, this); scrollEvent.scrollFlags = nsMouseScrollEvent::kIsVertical; scrollEvent.delta = (info->args)[0]; - scrollEvent.eventStructType = NS_MOUSE_SCROLL_EVENT; - scrollEvent.message = NS_MOUSE_SCROLL; - scrollEvent.nativeMsg = nsnull; - scrollEvent.widget = this; scrollEvent.time = PR_IntervalNow(); // XXX implement these items? @@ -2240,13 +2233,13 @@ PRBool nsWindow::OnKeyUp(PRUint32 aEventType, const char *bytes, PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, PRUint32 aCharCode, PRUint32 aKeyCode) { - nsKeyEvent event; + nsKeyEvent event(aEventType, this); nsPoint point; point.x = 0; point.y = 0; - InitEvent(event, aEventType, &point); // this add ref's event.widget + InitEvent(event, &point); // this add ref's event.widget event.charCode = aCharCode; event.keyCode = aKeyCode; @@ -2267,7 +2260,6 @@ PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, PRUint32 aCharCode, event.isControl = mIsControlDown; event.isMeta = mIsMetaDown; event.isAlt = mIsAltDown; - event.eventStructType = NS_KEY_EVENT; PRBool result = DispatchWindowEvent(&event); NS_RELEASE(event.widget); @@ -2317,11 +2309,10 @@ void nsWindow::OnDestroy() //------------------------------------------------------------------------- PRBool nsWindow::OnMove(PRInt32 aX, PRInt32 aY) { - nsGUIEvent event; - InitEvent(event, NS_MOVE); + nsGUIEvent event(NS_MOVE, this); + InitEvent(event); event.point.x = aX; event.point.y = aY; - event.eventStructType = NS_GUI_EVENT; PRBool result = DispatchWindowEvent(&event); NS_RELEASE(event.widget); @@ -2346,12 +2337,11 @@ PRBool nsWindow::OnPaint(nsRect &r) invalid.Include(BRect(r.x, r.y, r.x + r.width - 1, r.y + r.height - 1)); mView->ConstrainClippingRegion(&invalid); - nsPaintEvent event; + nsPaintEvent event(NS_PAINT, this); - InitEvent(event, NS_PAINT); + InitEvent(event); event.region = nsnull; event.rect = &r; - event.eventStructType = NS_PAINT_EVENT; static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID); static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID); @@ -2386,10 +2376,9 @@ PRBool nsWindow::OnResize(nsRect &aWindowRect) // call the event callback if (mEventCallback) { - nsSizeEvent event; - InitEvent(event, NS_SIZE); + nsSizeEvent event(NS_SIZE, this); + InitEvent(event); event.windowSize = &aWindowRect; - event.eventStructType = NS_SIZE_EVENT; if(mView && mView->LockLooper()) { BRect r = mView->Bounds(); @@ -2420,14 +2409,13 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, nsPoint aPoint, PRUint3 PRBool result = PR_FALSE; if(nsnull != mEventCallback || nsnull != mMouseListener) { - nsMouseEvent event; - InitEvent (event, aEventType, &aPoint); + nsMouseEvent event(aEventType, this); + InitEvent (event, &aPoint); event.isShift = mod & B_SHIFT_KEY; event.isControl = mod & B_CONTROL_KEY; event.isAlt = mod & B_COMMAND_KEY; event.isMeta = mod & B_OPTION_KEY; event.clickCount = clicks; - event.eventStructType = NS_MOUSE_EVENT; // call the event callback if(nsnull != mEventCallback) diff --git a/mozilla/widget/src/beos/nsWindow.h b/mozilla/widget/src/beos/nsWindow.h index d7c0c2f9c7c..8fd0cf2806b 100644 --- a/mozilla/widget/src/beos/nsWindow.h +++ b/mozilla/widget/src/beos/nsWindow.h @@ -181,7 +181,6 @@ public: virtual PRBool AutoErase(); void InitEvent(nsGUIEvent& event, - PRUint32 aEventType, nsPoint* aPoint = nsnull); protected: diff --git a/mozilla/widget/src/cocoa/nsChildView.mm b/mozilla/widget/src/cocoa/nsChildView.mm index 036581e15b9..a21bca03cf3 100644 --- a/mozilla/widget/src/cocoa/nsChildView.mm +++ b/mozilla/widget/src/cocoa/nsChildView.mm @@ -500,13 +500,9 @@ static pascal OSStatus OnContentClick(EventHandlerCallRef handler, EventRef even GlobalToLocal(&localWhere); nsChildView* childView = (nsChildView*) userData; - nsMouseEvent geckoEvent; - geckoEvent.eventStructType = NS_MOUSE_EVENT; - geckoEvent.message = NS_MOUSE_LEFT_BUTTON_DOWN; + nsMouseEvent geckoEvent(NS_MOUSE_LEFT_BUTTON_DOWN, childView); geckoEvent.nativeMsg = &macEvent; - geckoEvent.widget = childView; geckoEvent.time = PR_IntervalNow(); - geckoEvent.flags = 0; geckoEvent.clickCount = 1; geckoEvent.refPoint.x = geckoEvent.point.x = localWhere.h; @@ -1555,15 +1551,9 @@ nsChildView::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext) StPortSetter port(curPort); // initialize the paint event - nsPaintEvent paintEvent; - paintEvent.eventStructType = NS_PAINT_EVENT; // nsEvent - paintEvent.nativeMsg = nsnull; - paintEvent.message = NS_PAINT; - paintEvent.widget = this; // nsGUIEvent - paintEvent.nativeMsg = NULL; + nsPaintEvent paintEvent(NS_PAINT, this); paintEvent.renderingContext = aContext; // nsPaintEvent paintEvent.rect = &aRect; - paintEvent.region = nsnull; // offscreen drawing is pointless. if (paintEvent.rect->x < 0) @@ -1861,20 +1851,11 @@ PRBool nsChildView::DispatchMouseEvent(nsMouseEvent &aEvent) PRBool nsChildView::ReportDestroyEvent() { // nsEvent - nsGUIEvent moveEvent; - moveEvent.eventStructType = NS_GUI_EVENT; - moveEvent.nativeMsg = nsnull; - moveEvent.message = NS_DESTROY; - moveEvent.point.x = 0; - moveEvent.point.y = 0; - moveEvent.time = PR_IntervalNow(); - - // nsGUIEvent - moveEvent.widget = this; - moveEvent.nativeMsg = nsnull; + nsGUIEvent event(NS_DESTROY, this); + event.time = PR_IntervalNow(); // dispatch event - return (DispatchWindowEvent(moveEvent)); + return (DispatchWindowEvent(event)); } //------------------------------------------------------------------------- @@ -1884,18 +1865,11 @@ PRBool nsChildView::ReportDestroyEvent() PRBool nsChildView::ReportMoveEvent() { // nsEvent - nsGUIEvent moveEvent; - moveEvent.eventStructType = NS_GUI_EVENT; - moveEvent.nativeMsg = nsnull; - moveEvent.message = NS_MOVE; + nsGUIEvent moveEvent(NS_MOVE, this); moveEvent.point.x = mBounds.x; moveEvent.point.y = mBounds.y; moveEvent.time = PR_IntervalNow(); - // nsGUIEvent - moveEvent.widget = this; - moveEvent.nativeMsg = nsnull; - // dispatch event return (DispatchWindowEvent(moveEvent)); } @@ -1907,18 +1881,9 @@ PRBool nsChildView::ReportMoveEvent() PRBool nsChildView::ReportSizeEvent() { // nsEvent - nsSizeEvent sizeEvent; - sizeEvent.eventStructType = NS_SIZE_EVENT; - sizeEvent.nativeMsg = nsnull; - sizeEvent.message = NS_SIZE; - sizeEvent.point.x = 0; - sizeEvent.point.y = 0; + nsSizeEvent sizeEvent(NS_SIZE, this); sizeEvent.time = PR_IntervalNow(); - // nsGUIEvent - sizeEvent.widget = this; - sizeEvent.nativeMsg = nsnull; - // nsSizeEvent sizeEvent.windowSize = &mBounds; sizeEvent.mWinWidth = mBounds.width; @@ -2183,7 +2148,6 @@ nsChildView::DragEvent(PRUint32 aMessage, PRInt16 aMouseGlobalX, PRInt16 aMouseG } nsMouseEvent geckoEvent; - geckoEvent.eventStructType = NS_DRAGDROP_EVENT; // we're given the point in global coordinates. We need to convert it to // window coordinates for convert:message:toGeckoEvent @@ -2245,10 +2209,7 @@ nsChildView::Idle() { // Fire the context menu event into Gecko. nsMouseEvent geckoEvent; - geckoEvent.eventStructType = NS_MOUSE_EVENT; - geckoEvent.nativeMsg = nsnull; [self convert:theEvent message:NS_CONTEXTMENU toGeckoEvent:&geckoEvent]; - geckoEvent.clickCount = 0; // send event into Gecko by going directly to the // the widget. @@ -2531,8 +2492,6 @@ nsChildView::Idle() } nsMouseEvent geckoEvent; - geckoEvent.eventStructType = NS_MOUSE_EVENT; - geckoEvent.nativeMsg = nsnull; [self convert:theEvent message:NS_MOUSE_LEFT_BUTTON_DOWN toGeckoEvent:&geckoEvent]; geckoEvent.clickCount = [theEvent clickCount]; @@ -2563,8 +2522,6 @@ nsChildView::Idle() return; } nsMouseEvent geckoEvent; - geckoEvent.eventStructType = NS_MOUSE_EVENT; - geckoEvent.nativeMsg = nsnull; [self convert:theEvent message:NS_MOUSE_LEFT_BUTTON_UP toGeckoEvent:&geckoEvent]; NSPoint mouseLoc = [theEvent locationInWindow]; @@ -2600,8 +2557,6 @@ nsChildView::Idle() return; } nsMouseEvent geckoEvent; - geckoEvent.eventStructType = NS_MOUSE_EVENT; - geckoEvent.nativeMsg = nsnull; [self convert:theEvent message:NS_MOUSE_MOVE toGeckoEvent:&geckoEvent]; NSPoint mouseLoc = [theEvent locationInWindow]; @@ -2629,8 +2584,6 @@ nsChildView::Idle() return; } nsMouseEvent geckoEvent; - geckoEvent.eventStructType = NS_MOUSE_EVENT; - geckoEvent.nativeMsg = nsnull; [self convert:theEvent message:NS_MOUSE_MOVE toGeckoEvent:&geckoEvent]; EventRecord macEvent; @@ -2672,8 +2625,6 @@ nsChildView::Idle() // The right mouse went down. Fire off a right mouse down and // then send the context menu event. nsMouseEvent geckoEvent; - geckoEvent.eventStructType = NS_MOUSE_EVENT; - geckoEvent.nativeMsg = nsnull; [self convert: theEvent message: NS_MOUSE_RIGHT_BUTTON_DOWN toGeckoEvent:&geckoEvent]; @@ -2695,8 +2646,6 @@ nsChildView::Idle() - (void)rightMouseUp:(NSEvent *)theEvent { nsMouseEvent geckoEvent; - geckoEvent.eventStructType = NS_MOUSE_EVENT; - geckoEvent.nativeMsg = nsnull; [self convert: theEvent message: NS_MOUSE_RIGHT_BUTTON_UP toGeckoEvent:&geckoEvent]; @@ -2718,8 +2667,6 @@ nsChildView::Idle() - (void)otherMouseDown:(NSEvent *)theEvent { nsMouseEvent geckoEvent; - geckoEvent.eventStructType = NS_MOUSE_EVENT; - geckoEvent.nativeMsg = nsnull; [self convert:theEvent message:NS_MOUSE_MIDDLE_BUTTON_DOWN toGeckoEvent:&geckoEvent]; geckoEvent.clickCount = [theEvent clickCount]; @@ -2733,8 +2680,6 @@ nsChildView::Idle() - (void)otherMouseUp:(NSEvent *)theEvent { nsMouseEvent geckoEvent; - geckoEvent.eventStructType = NS_MOUSE_EVENT; - geckoEvent.nativeMsg = nsnull; [self convert:theEvent message:NS_MOUSE_MIDDLE_BUTTON_UP toGeckoEvent:&geckoEvent]; // send event into Gecko by going directly to the @@ -2752,9 +2697,6 @@ const PRInt32 kNumLines = 4; // default kNumLines of 4 for now (until I learn how we can get settings from // the OS). --dwh nsMouseScrollEvent geckoEvent; - geckoEvent.eventStructType = NS_MOUSE_SCROLL_EVENT; - geckoEvent.nativeMsg = nsnull; - geckoEvent.scrollFlags = 0; [self convert:theEvent message:NS_MOUSE_SCROLL toGeckoEvent:&geckoEvent]; PRInt32 incomingDeltaX = (PRInt32)[theEvent deltaX]; @@ -2800,7 +2742,6 @@ const PRInt32 kNumLines = 4; { outGeckoEvent->message = inMsg; outGeckoEvent->widget = [self widget]; - outGeckoEvent->nativeMsg = nsnull; outGeckoEvent->time = PR_IntervalNow(); if (outGeckoEvent->eventStructType != NS_KEY_EVENT) { @@ -2905,17 +2846,8 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac #endif // static void init_composition_event( *aEvent, int aType) - nsCompositionEvent event; - event.eventStructType = aEventType; - event.message = aEventType; - event.compositionMessage = aEventType; // this field shouldn't be defined in nsGUIEvent.h since no one seems to need it - event.point.x = 0; - event.point.y = 0; - event.nativeMsg = nsnull; - event.widget = mGeckoChild; + nsCompositionEvent event(aEventType, mGeckoChild); event.time = PR_IntervalNow(); - event.theReply.mCursorPosition.x = 0; - event.theReply.mCursorPosition.y = 0; mGeckoChild->DispatchWindowEvent(event); return event.theReply.mCursorPosition; } @@ -2931,17 +2863,9 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac NSLog(@" markRange = %d, %d; selRange = %d, %d\n", markRange.location, markRange.length, selRange.location, selRange.length); #endif - nsTextEvent textEvent; - textEvent.eventStructType = NS_TEXT_EVENT; - textEvent.message = NS_TEXT_EVENT; - textEvent.point.x = 0; - textEvent.point.y = 0; - textEvent.nativeMsg = nsnull; + nsTextEvent textEvent(NS_TEXT_TEXT, mGeckoChild); textEvent.time = PR_IntervalNow(); - textEvent.widget = mGeckoChild; textEvent.theText = aBuffer; - textEvent.rangeCount = 0; - textEvent.rangeArray = nsnull; if (!doCommit) fillTextRangeInTextEvent(&textEvent, aString, markRange); @@ -2973,17 +2897,10 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac if (len == 1 && !mInComposition) { // dispatch keypress event with char instead of textEvent - nsKeyEvent geckoEvent; - geckoEvent.eventStructType = NS_KEY_EVENT; - geckoEvent.message = NS_KEY_PRESS; - geckoEvent.widget = mGeckoChild; - geckoEvent.point.x = geckoEvent.point.y = 0; + nsKeyEvent geckoEvent(NS_KEY_PRESS, mGeckoChild); geckoEvent.time = PR_IntervalNow(); - geckoEvent.keyCode = 0; geckoEvent.charCode = bufPtr[0]; // gecko expects OS-translated unicode geckoEvent.isChar = PR_TRUE; - geckoEvent.isShift = geckoEvent.isControl = geckoEvent.isAlt = geckoEvent.isMeta = PR_FALSE; - geckoEvent.nativeMsg = nsnull; // plugins need a native autokey event here, but only if this is a repeat event EventRecord macEvent; @@ -3111,15 +3028,8 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac NSLog(@" selectedRange = %d, %d\n", mSelectedRange.location, mSelectedRange.length); #endif - nsReconversionEvent reconversionEvent; - reconversionEvent.eventStructType = NS_RECONVERSION_QUERY; - reconversionEvent.message = NS_RECONVERSION_QUERY; - reconversionEvent.point.x = 0; - reconversionEvent.point.y = 0; - reconversionEvent.nativeMsg = nsnull; + nsReconversionEvent reconversionEvent(NS_RECONVERSION_QUERY, mGeckoChild); reconversionEvent.time = PR_IntervalNow(); - reconversionEvent.widget = mGeckoChild; - reconversionEvent.theReply.mReconversionString = nsnull; nsresult rv = mGeckoChild->DispatchWindowEvent(reconversionEvent); if (NS_SUCCEEDED(rv)) @@ -3353,15 +3263,7 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac // This method is called when we are about to be focused. - (BOOL)becomeFirstResponder { - nsFocusEvent event; - event.eventStructType = NS_FOCUS_EVENT; - event.nativeMsg = nsnull; - event.message = NS_GOTFOCUS; - event.widget = mGeckoChild; - - //focus and blur event should go to their base widget loc - event.point.x = 0; - event.point.y = 0; + nsFocusEvent event(NS_GOTFOCUS, mGeckoChild); mGeckoChild->DispatchWindowEvent(event); return [super becomeFirstResponder]; @@ -3370,15 +3272,7 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac // This method is called when are are about to lose focus. - (BOOL)resignFirstResponder { - nsFocusEvent event; - event.eventStructType = NS_FOCUS_EVENT; - event.nativeMsg = nsnull; - event.message = NS_LOSTFOCUS; - event.widget = mGeckoChild; - - //focus and blur event should go to their base widget loc - event.point.x = 0; - event.point.y = 0; + nsFocusEvent event(NS_LOSTFOCUS, mGeckoChild); mGeckoChild->DispatchWindowEvent(event); @@ -3646,7 +3540,6 @@ static PRBool IsSpecialRaptorKey(UInt32 macKeyCode) isChar:(PRBool*)aIsChar toGeckoEvent:(nsKeyEvent*)outGeckoEvent { - outGeckoEvent->eventStructType = NS_KEY_EVENT; [self convert:aKeyEvent message:aMessage toGeckoEvent:outGeckoEvent]; // Initialize the out boolean for whether or not we are using diff --git a/mozilla/widget/src/cocoa/nsCocoaWindow.mm b/mozilla/widget/src/cocoa/nsCocoaWindow.mm index 53630e78219..0079d7097f8 100644 --- a/mozilla/widget/src/cocoa/nsCocoaWindow.mm +++ b/mozilla/widget/src/cocoa/nsCocoaWindow.mm @@ -1498,20 +1498,13 @@ PRBool nsCocoaWindow::DragEvent ( unsigned int aMessage, Point aMouseGlobal, UIn //------------------------------------------------------------------------- void nsCocoaWindow::ComeToFront() { #if 0 - nsZLevelEvent event; + nsZLevelEvent event(NS_SETZLEVEL, this); event.point.x = mBounds.x; event.point.y = mBounds.y; event.time = PR_IntervalNow(); - event.widget = this; - event.nativeMsg = nsnull; - event.eventStructType = NS_ZLEVEL_EVENT; - event.message = NS_SETZLEVEL; - event.mPlacement = nsWindowZTop; - event.mReqBelow = 0; event.mImmediate = PR_TRUE; - event.mAdjusted = PR_FALSE; DispatchWindowEvent(event); #endif @@ -1571,10 +1564,8 @@ nsCocoaWindow::DispatchEvent ( void* anEvent, void* aView, PRBool *_retval ) ChildView* view = NS_REINTERPRET_CAST(ChildView*, aView); - nsMouseEvent geckoEvent; - geckoEvent.eventStructType = NS_MOUSE_EVENT; + nsMouseEvent geckoEvent(0, view ? [view widget] : this) - geckoEvent.widget = this; geckoEvent.nativeMsg = anEvent; geckoEvent.time = PR_IntervalNow(); NSPoint mouseLoc = [event locationInWindow]; @@ -1582,8 +1573,6 @@ nsCocoaWindow::DispatchEvent ( void* anEvent, void* aView, PRBool *_retval ) geckoEvent.refPoint.y = NS_STATIC_CAST(nscoord, mouseLoc.y); //printf("-- global mouse click at (%ld,%ld)\n", geckoEvent.refPoint.x, geckoEvent.refPoint.y ); if ( view ) { - geckoEvent.widget = [view widget]; - // convert point to view coordinate system NSPoint localPoint = [view convertPoint:mouseLoc fromView:nil]; geckoEvent.point.x = NS_STATIC_CAST(nscoord, localPoint.x); @@ -1671,17 +1660,9 @@ void nsCocoaWindow::ReportSizeEvent() { // nsEvent - nsSizeEvent sizeEvent; - sizeEvent.eventStructType = NS_SIZE_EVENT; - sizeEvent.message = NS_SIZE; - sizeEvent.point.x = 0; - sizeEvent.point.y = 0; + nsSizeEvent sizeEvent(NS_SIZE, this); sizeEvent.time = PR_IntervalNow(); - // nsGUIEvent - sizeEvent.widget = this; - sizeEvent.nativeMsg = nsnull; - // nsSizeEvent sizeEvent.windowSize = &mBounds; sizeEvent.mWinWidth = mBounds.width; diff --git a/mozilla/widget/src/cocoa/nsMenuBarX.cpp b/mozilla/widget/src/cocoa/nsMenuBarX.cpp index 406968cc9b2..205000c4c01 100644 --- a/mozilla/widget/src/cocoa/nsMenuBarX.cpp +++ b/mozilla/widget/src/cocoa/nsMenuBarX.cpp @@ -402,9 +402,7 @@ nsMenuBarX :: ExecuteCommand ( nsIContent* inDispatchTo ) nsCOMPtr presContext; MenuHelpersX::WebShellToPresContext(webShell, getter_AddRefs(presContext)); - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_XUL_COMMAND; + nsMouseEvent event(NS_XUL_COMMAND); inDispatchTo->HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } diff --git a/mozilla/widget/src/cocoa/nsMenuItemX.cpp b/mozilla/widget/src/cocoa/nsMenuItemX.cpp index e2ce42425ad..a206dec966e 100644 --- a/mozilla/widget/src/cocoa/nsMenuItemX.cpp +++ b/mozilla/widget/src/cocoa/nsMenuItemX.cpp @@ -261,9 +261,7 @@ NS_METHOD nsMenuItemX::DoCommand() MenuHelpersX::WebShellToPresContext(webShell, getter_AddRefs(presContext)); nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_XUL_COMMAND; + nsMouseEvent event(NS_XUL_COMMAND); // See if we have a command element. If so, we execute on the command instead // of on our content element. diff --git a/mozilla/widget/src/cocoa/nsMenuX.cpp b/mozilla/widget/src/cocoa/nsMenuX.cpp index f52a485227b..106f0c2f979 100644 --- a/mozilla/widget/src/cocoa/nsMenuX.cpp +++ b/mozilla/widget/src/cocoa/nsMenuX.cpp @@ -747,12 +747,7 @@ static pascal OSStatus MyMenuEventHandler(EventHandlerCallRef myHandler, EventRe if (listener) { MenuRef menuRef; ::GetEventParameter(event, kEventParamDirectObject, typeMenuRef, NULL, sizeof(menuRef), NULL, &menuRef); - nsMenuEvent menuEvent; - menuEvent.message = NS_MENU_SELECTED; - menuEvent.eventStructType = NS_MENU_EVENT; - menuEvent.point.x = 0; - menuEvent.point.y = 0; - menuEvent.widget = nsnull; + nsMenuEvent menuEvent(NS_MENU_SELECTED); menuEvent.time = PR_IntervalNow(); menuEvent.mCommand = (PRUint32) menuRef; if (kind == kEventMenuOpening) { @@ -978,15 +973,7 @@ PRBool nsMenuX::OnCreate() { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_POPUP_SHOWING; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_SHOWING); nsCOMPtr popupContent; GetMenuPopupContent(getter_AddRefs(popupContent)); @@ -1069,15 +1056,7 @@ PRBool nsMenuX::OnCreated() { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_POPUP_SHOWN; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_SHOWN); nsCOMPtr popupContent; GetMenuPopupContent(getter_AddRefs(popupContent)); @@ -1113,15 +1092,7 @@ nsMenuX::OnDestroy() return PR_TRUE; nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_POPUP_HIDING; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_HIDING); nsCOMPtr webShell = do_QueryReferent(mWebShellWeakRef); if (!webShell) { @@ -1151,15 +1122,7 @@ PRBool nsMenuX::OnDestroyed() { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_POPUP_HIDDEN; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_HIDDEN); nsCOMPtr webShell = do_QueryReferent(mWebShellWeakRef); if (!webShell) { diff --git a/mozilla/widget/src/gtk/nsGtkEventHandler.cpp b/mozilla/widget/src/gtk/nsGtkEventHandler.cpp index 60cd7b167f9..ab2c8998d4d 100644 --- a/mozilla/widget/src/gtk/nsGtkEventHandler.cpp +++ b/mozilla/widget/src/gtk/nsGtkEventHandler.cpp @@ -77,15 +77,8 @@ static PRBool suppressNextKeyDown = PR_FALSE; //============================================================== void InitAllocationEvent(GtkAllocation *aAlloc, - gpointer p, - nsSizeEvent &anEvent, - PRUint32 aEventType) + nsSizeEvent &anEvent) { - anEvent.message = aEventType; - anEvent.widget = (nsWidget *) p; - - anEvent.eventStructType = NS_SIZE_EVENT; - if (aAlloc != nsnull) { // HACK // nsRect *foo = new nsRect(aAlloc->x, aAlloc->y, aAlloc->width, aAlloc->height); @@ -94,8 +87,6 @@ void InitAllocationEvent(GtkAllocation *aAlloc, // anEvent.point.x = aAlloc->x; // anEvent.point.y = aAlloc->y; // HACK - anEvent.point.x = 0; - anEvent.point.y = 0; anEvent.mWinWidth = aAlloc->width; anEvent.mWinHeight = aAlloc->height; } @@ -375,38 +366,24 @@ PRUint32 nsConvertCharCodeToUnicode(GdkEventKey* aGEK) //============================================================== void InitKeyEvent(GdkEventKey *aGEK, - gpointer p, - nsKeyEvent &anEvent, - PRUint32 aEventType) + nsKeyEvent &anEvent) { - anEvent.message = aEventType; - anEvent.widget = (nsWidget *) p; - - anEvent.eventStructType = NS_KEY_EVENT; - if (aGEK != nsnull) { anEvent.keyCode = nsPlatformToDOMKeyCode(aGEK); - anEvent.charCode = 0; anEvent.time = aGEK->time; anEvent.isShift = (aGEK->state & GDK_SHIFT_MASK) ? PR_TRUE : PR_FALSE; anEvent.isControl = (aGEK->state & GDK_CONTROL_MASK) ? PR_TRUE : PR_FALSE; anEvent.isAlt = (aGEK->state & GDK_MOD1_MASK) ? PR_TRUE : PR_FALSE; anEvent.isMeta = (aGEK->state & GDK_MOD4_MASK) ? PR_TRUE : PR_FALSE; - anEvent.point.x = 0; - anEvent.point.y = 0; } } void InitKeyPressEvent(GdkEventKey *aGEK, - gpointer p, nsKeyEvent &anEvent) { // // init the basic event fields // - anEvent.eventStructType = NS_KEY_EVENT; - anEvent.message = NS_KEY_PRESS; - anEvent.widget = (nsWidget*)p; if (aGEK!=nsnull) { anEvent.isShift = (aGEK->state & GDK_SHIFT_MASK) ? PR_TRUE : PR_FALSE; @@ -416,8 +393,6 @@ void InitKeyPressEvent(GdkEventKey *aGEK, anEvent.charCode = nsConvertCharCodeToUnicode(aGEK); if (anEvent.charCode) { - anEvent.keyCode = 0; - // if the control, meta, or alt key is down, then we should leave // the isShift flag alone (probably not a printable character) // if none of the other modifier keys are pressed then we need to @@ -460,8 +435,6 @@ void InitKeyPressEvent(GdkEventKey *aGEK, #endif anEvent.time = aGEK->time; - anEvent.point.x = 0; - anEvent.point.y = 0; } } @@ -473,9 +446,9 @@ void InitKeyPressEvent(GdkEventKey *aGEK, void handle_size_allocate(GtkWidget *w, GtkAllocation *alloc, gpointer p) { nsWindow *widget = (nsWindow *)p; - nsSizeEvent event; + nsSizeEvent event(NS_SIZE, widget); - InitAllocationEvent(alloc, p, event, NS_SIZE); + InitAllocationEvent(alloc, event); NS_ADDREF(widget); widget->OnResize(&event); NS_RELEASE(widget); @@ -506,8 +479,8 @@ gint handle_key_press_event_for_text(GtkObject *w, GdkEventKey* event, return PR_TRUE; NS_ADDREF(win); - nsKeyEvent keyDownEvent; - InitKeyEvent(event, p, keyDownEvent, NS_KEY_DOWN); + nsKeyEvent keyDownEvent(NS_KEY_DOWN, p); + InitKeyEvent(event, keyDownEvent); win->OnKey(keyDownEvent); // @@ -515,8 +488,8 @@ gint handle_key_press_event_for_text(GtkObject *w, GdkEventKey* event, // character code. Note we have to check for modifier keys, since // gtk returns a character value for them // - nsKeyEvent keyPressEvent; - InitKeyPressEvent(event,p, keyPressEvent); + nsKeyEvent keyPressEvent(NS_KEY_PRESS, p); + InitKeyPressEvent(event, keyPressEvent); win->OnKey(keyPressEvent); NS_RELEASE(win); @@ -532,8 +505,8 @@ gint handle_key_press_event_for_text(GtkObject *w, GdkEventKey* event, gint handle_key_release_event_for_text(GtkObject *w, GdkEventKey* event, gpointer p) { - nsKeyEvent kevent; nsTextWidget* win = (nsTextWidget*)p; + nsKeyEvent kevent(NS_KEY_UP, win); // Don't pass shift, control and alt as key release events if (event->keyval == GDK_Shift_L @@ -545,7 +518,7 @@ gint handle_key_release_event_for_text(GtkObject *w, GdkEventKey* event, ) return PR_TRUE; - InitKeyEvent(event, p, kevent, NS_KEY_UP); + InitKeyEvent(event, kevent); NS_ADDREF(win); win->OnKey(kevent); NS_RELEASE(win); @@ -588,8 +561,8 @@ gint handle_key_press_event(GtkObject *w, GdkEventKey* event, gpointer p) // but lie about where it came from and say it is from the // window that currently has focus inside our app... // - nsKeyEvent keyDownEvent; - InitKeyEvent(event, win, keyDownEvent, NS_KEY_DOWN); + nsKeyEvent keyDownEvent(NS_KEY_DOWN, win); + InitKeyEvent(event, keyDownEvent); // if we need to suppress this NS_KEY_DOWN event, reset the flag if (suppressNextKeyDown == PR_TRUE) suppressNextKeyDown = PR_FALSE; @@ -604,8 +577,8 @@ gint handle_key_press_event(GtkObject *w, GdkEventKey* event, gpointer p) // // Call nsConvertCharCodeToUnicode() here to get kevent.charCode - nsKeyEvent keyPressEvent; - InitKeyPressEvent(event, win, keyPressEvent); + nsKeyEvent keyPressEvent(NS_KEY_PRESS, win); + InitKeyPressEvent(event, keyPressEvent); if (event->length) { if (keyPressEvent.charCode || keyPressEvent.keyCode) { @@ -677,8 +650,8 @@ gint handle_key_release_event(GtkObject *w, GdkEventKey* event, gpointer p) if (nsWidget::sFocusWindow) win = nsWidget::sFocusWindow; - nsKeyEvent kevent; - InitKeyEvent(event, win, kevent, NS_KEY_UP); + nsKeyEvent kevent(NS_KEY_UP, win); + InitKeyEvent(event, kevent); NS_ADDREF(win); win->OnKey(kevent); diff --git a/mozilla/widget/src/gtk/nsWidget.cpp b/mozilla/widget/src/gtk/nsWidget.cpp index 42d97ebb193..cf8b82d8934 100644 --- a/mozilla/widget/src/gtk/nsWidget.cpp +++ b/mozilla/widget/src/gtk/nsWidget.cpp @@ -121,7 +121,6 @@ ConvertKeyEventToContextMenuEvent(const nsKeyEvent* inKeyEvent, nsMouseEvent* outCMEvent) { *(nsInputEvent *)outCMEvent = *(nsInputEvent *)inKeyEvent; - outCMEvent->eventStructType = NS_MOUSE_EVENT; outCMEvent->message = NS_CONTEXTMENU_KEY; outCMEvent->isShift = outCMEvent->isControl = PR_FALSE; outCMEvent->isAlt = outCMEvent->isMeta = PR_FALSE; @@ -638,10 +637,9 @@ PRBool nsWidget::OnResize(nsSizeEvent *event) PRBool nsWidget::OnResize(nsRect &aRect) { - nsSizeEvent event; + nsSizeEvent event(NS_SIZE, this); - InitEvent(event, NS_SIZE); - event.eventStructType = NS_SIZE_EVENT; + InitEvent(event); nsRect *foo = new nsRect(0, 0, aRect.width, aRect.height); event.windowSize = foo; @@ -679,11 +677,10 @@ PRBool nsWidget::OnMove(PRInt32 aX, PRInt32 aY) ResetInternalVisibility(); - nsGUIEvent event; - InitEvent(event, NS_MOVE); + nsGUIEvent event(NS_MOVE, this); + InitEvent(event); event.point.x = aX; event.point.y = aY; - event.eventStructType = NS_GUI_EVENT; PRBool result = DispatchWindowEvent(&event); return result; } @@ -1334,10 +1331,8 @@ void nsWidget::ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY) } -void nsWidget::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint) +void nsWidget::InitEvent(nsGUIEvent& event, nsPoint* aPoint) { - event.widget = this; - // This copies, and we need to call gdk_event_free. GdkEvent *ge = gtk_get_current_event(); @@ -1348,9 +1343,6 @@ void nsWidget::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint // ::ScreenToClient(mWnd, &cpos); event.point.x = PRInt32(ge->configure.x); event.point.y = PRInt32(ge->configure.y); - } else { - event.point.x = 0; - event.point.y = 0; } } else { // use the point override if provided @@ -1359,7 +1351,6 @@ void nsWidget::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint } event.time = gdk_event_get_time(ge); - event.message = aEventType; // mLastPoint.x = event.point.x; // mLastPoint.y = event.point.y; @@ -1399,9 +1390,8 @@ PRBool nsWidget::DispatchWindowEvent(nsGUIEvent* event) PRBool nsWidget::DispatchStandardEvent(PRUint32 aMsg) { - nsGUIEvent event; - event.eventStructType = NS_GUI_EVENT; - InitEvent(event, aMsg); + nsGUIEvent event(aMsg, this); + InitEvent(event); PRBool result = DispatchWindowEvent(&event); return result; } @@ -1671,10 +1661,7 @@ nsWidget::OnMotionNotifySignal(GdkEventMotion * aGdkMotionEvent) if (mIsDestroying) return; - nsMouseEvent event; - - event.message = NS_MOUSE_MOVE; - event.eventStructType = NS_MOUSE_EVENT; + nsMouseEvent event(NS_MOUSE_MOVE); // If there is a button motion target, use that instead of the // current widget @@ -1766,11 +1753,7 @@ nsWidget::OnEnterNotifySignal(GdkEventCrossing * aGdkCrossingEvent) return; } - nsMouseEvent event; - - event.message = NS_MOUSE_ENTER; - event.widget = this; - event.eventStructType = NS_MOUSE_EVENT; + nsMouseEvent event(NS_MOUSE_ENTER, this); if (aGdkCrossingEvent != NULL) { @@ -1801,11 +1784,7 @@ nsWidget::OnLeaveNotifySignal(GdkEventCrossing * aGdkCrossingEvent) return; } - nsMouseEvent event; - - event.message = NS_MOUSE_EXIT; - event.widget = this; - event.eventStructType = NS_MOUSE_EVENT; + nsMouseEvent event(NS_MOUSE_EXIT, this); if (aGdkCrossingEvent != NULL) { @@ -1826,8 +1805,7 @@ nsWidget::OnLeaveNotifySignal(GdkEventCrossing * aGdkCrossingEvent) /* virtual */ void nsWidget::OnButtonPressSignal(GdkEventButton * aGdkButtonEvent) { - nsMouseEvent event; - nsMouseScrollEvent scrollEvent; + nsMouseScrollEvent scrollEvent(NS_MOUSE_SCROLL, this); PRUint32 eventType = 0; // If you double click in GDK, it will actually generate a single @@ -1877,10 +1855,6 @@ nsWidget::OnButtonPressSignal(GdkEventButton * aGdkButtonEvent) else scrollEvent.delta = 3; - scrollEvent.message = NS_MOUSE_SCROLL; - scrollEvent.widget = this; - scrollEvent.eventStructType = NS_MOUSE_SCROLL_EVENT; - scrollEvent.point.x = nscoord(aGdkButtonEvent->x); scrollEvent.point.y = nscoord(aGdkButtonEvent->y); @@ -1906,7 +1880,8 @@ nsWidget::OnButtonPressSignal(GdkEventButton * aGdkButtonEvent) break; } - InitMouseEvent(aGdkButtonEvent, event, eventType); + nsMouseEvent event(eventType, this); + InitMouseEvent(aGdkButtonEvent, event); // Set the button motion target and remeber the widget and root coords sButtonMotionTarget = this; @@ -1931,8 +1906,8 @@ nsWidget::OnButtonPressSignal(GdkEventButton * aGdkButtonEvent) // if we're a right-button-down on linux, we're trying to // popup a context menu. send that event to gecko also. if (eventType == NS_MOUSE_RIGHT_BUTTON_DOWN) { - nsMouseEvent contextMenuEvent; - InitMouseEvent(aGdkButtonEvent, contextMenuEvent, NS_CONTEXTMENU); + nsMouseEvent contextMenuEvent(NS_CONTEXTMENU, this); + InitMouseEvent(aGdkButtonEvent, contextMenuEvent); DispatchMouseEvent(contextMenuEvent); } @@ -1943,7 +1918,6 @@ nsWidget::OnButtonPressSignal(GdkEventButton * aGdkButtonEvent) /* virtual */ void nsWidget::OnButtonReleaseSignal(GdkEventButton * aGdkButtonEvent) { - nsMouseEvent event; PRUint32 eventType = 0; switch (aGdkButtonEvent->button) @@ -1971,8 +1945,8 @@ nsWidget::OnButtonReleaseSignal(GdkEventButton * aGdkButtonEvent) break; } - - InitMouseEvent(aGdkButtonEvent, event, eventType); + nsMouseEvent event(eventType, sButtonMotionTarget); + InitMouseEvent(aGdkButtonEvent, event); if (sButtonMotionTarget) { gint diffX = 0; @@ -1981,8 +1955,6 @@ nsWidget::OnButtonReleaseSignal(GdkEventButton * aGdkButtonEvent) diffX = (gint) aGdkButtonEvent->x_root - sButtonMotionRootX; diffY = (gint) aGdkButtonEvent->y_root - sButtonMotionRootY; - event.widget = sButtonMotionTarget; - // see comments in nsWidget::OnMotionNotifySignal event.point.x = nscoord(sButtonMotionWidgetX + diffX); event.point.y = nscoord(sButtonMotionWidgetY + diffY); @@ -2010,18 +1982,10 @@ nsWidget::OnFocusInSignal(GdkEventFocus * aGdkFocusEvent) GTK_WIDGET_SET_FLAGS(mWidget, GTK_HAS_FOCUS); - nsGUIEvent event; - - event.message = NS_GOTFOCUS; - event.widget = this; - - event.eventStructType = NS_GUI_EVENT; + nsFocusEvent event(NS_GOTFOCUS, this); // event.time = aGdkFocusEvent->time;; // event.time = PR_Now(); - event.time = 0; - event.point.x = 0; - event.point.y = 0; AddRef(); @@ -2038,18 +2002,10 @@ nsWidget::OnFocusOutSignal(GdkEventFocus * aGdkFocusEvent) GTK_WIDGET_UNSET_FLAGS(mWidget, GTK_HAS_FOCUS); - nsGUIEvent event; - - event.message = NS_LOSTFOCUS; - event.widget = this; - - event.eventStructType = NS_GUI_EVENT; + nsFocusEvent event(NS_LOSTFOCUS, this); // event.time = aGdkFocusEvent->time;; // event.time = PR_Now(); - event.time = 0; - event.point.x = 0; - event.point.y = 0; AddRef(); @@ -2090,14 +2046,8 @@ nsWidget::InstallSignal(GtkWidget * aWidget, ////////////////////////////////////////////////////////////////// void nsWidget::InitMouseEvent(GdkEventButton * aGdkButtonEvent, - nsMouseEvent &anEvent, - PRUint32 aEventType) + nsMouseEvent &anEvent) { - anEvent.message = aEventType; - anEvent.widget = this; - - anEvent.eventStructType = NS_MOUSE_EVENT; - if (aGdkButtonEvent != NULL) { anEvent.point.x = nscoord(aGdkButtonEvent->x); anEvent.point.y = nscoord(aGdkButtonEvent->y); diff --git a/mozilla/widget/src/gtk/nsWidget.h b/mozilla/widget/src/gtk/nsWidget.h index 3eec27fd194..27610bd7859 100644 --- a/mozilla/widget/src/gtk/nsWidget.h +++ b/mozilla/widget/src/gtk/nsWidget.h @@ -171,7 +171,7 @@ public: // nsIKBStateControl NS_IMETHOD ResetInputState(); - void InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint = nsnull); + void InitEvent(nsGUIEvent& event, nsPoint* aPoint = nsnull); // Utility functions @@ -367,8 +367,7 @@ protected: GtkSignalFunc aSignalFunction); void InitMouseEvent(GdkEventButton * aGdkButtonEvent, - nsMouseEvent & anEvent, - PRUint32 aEventType); + nsMouseEvent & anEvent); #ifdef DEBUG nsCAutoString debug_GetName(GtkObject * aGtkWidget); diff --git a/mozilla/widget/src/gtk/nsWindow.cpp b/mozilla/widget/src/gtk/nsWindow.cpp index 5347921a6c0..cbed3ffa88f 100644 --- a/mozilla/widget/src/gtk/nsWindow.cpp +++ b/mozilla/widget/src/gtk/nsWindow.cpp @@ -803,19 +803,13 @@ nsWindow::DoPaint (nsIRegion *aClipRegion) if (!mEventCallback) return; - nsPaintEvent event; + nsPaintEvent event(NS_PAINT, this); - event.message = NS_PAINT; - event.widget = (nsWidget *)this; - event.eventStructType = NS_PAINT_EVENT; - event.point.x = 0; - event.point.y = 0; event.time = GDK_CURRENT_TIME; // No time in EXPOSE events nsRect boundsRect; aClipRegion->GetBoundingBox(&boundsRect.x, &boundsRect.y, &boundsRect.width, &boundsRect.height); event.rect = &boundsRect; - event.region = nsnull; // aClipRegion; // Don't paint anything if our window isn't visible. if (!mSuperWin) @@ -1399,15 +1393,7 @@ void nsWindow::DispatchSetFocusEvent(void) printf("nsWindow::DispatchSetFocusEvent %p\n", NS_STATIC_CAST(void *, this)); #endif /* DEBUG_FOCUS */ - nsGUIEvent event; - event.message = NS_GOTFOCUS; - event.widget = this; - - event.eventStructType = NS_GUI_EVENT; - - event.time = 0; - event.point.x = 0; - event.point.y = 0; + nsGUIEvent event(NS_GOTFOCUS, this); NS_ADDREF_THIS(); DispatchFocus(event); @@ -1427,15 +1413,7 @@ void nsWindow::DispatchLostFocusEvent(void) printf("nsWindow::DispatchLostFocusEvent %p\n", NS_STATIC_CAST(void *, this)); #endif /* DEBUG_FOCUS */ - nsGUIEvent event; - event.message = NS_LOSTFOCUS; - event.widget = this; - - event.eventStructType = NS_GUI_EVENT; - - event.time = 0; - event.point.x = 0; - event.point.y = 0; + nsGUIEvent event(NS_LOSTFOCUS, this); NS_ADDREF_THIS(); @@ -1456,15 +1434,7 @@ void nsWindow::DispatchActivateEvent(void) gJustGotDeactivate = PR_FALSE; - nsGUIEvent event; - event.message = NS_ACTIVATE; - event.widget = this; - - event.eventStructType = NS_GUI_EVENT; - - event.time = 0; - event.point.x = 0; - event.point.y = 0; + nsGUIEvent event(NS_ACTIVATE, this); NS_ADDREF_THIS(); DispatchFocus(event); @@ -1485,15 +1455,7 @@ void nsWindow::DispatchDeactivateEvent(void) IMEBeingActivate(PR_TRUE); #endif // USE_XIM - nsGUIEvent event; - event.message = NS_DEACTIVATE; - event.widget = this; - - event.eventStructType = NS_GUI_EVENT; - - event.time = 0; - event.point.x = 0; - event.point.y = 0; + nsGUIEvent event(NS_DEACTIVATE, this); NS_ADDREF_THIS(); DispatchFocus(event); @@ -1686,20 +1648,13 @@ nsWindow::OnFocusInSignal(GdkEventFocus * aGdkFocusEvent) GTK_WIDGET_SET_FLAGS(mMozArea, GTK_HAS_FOCUS); - nsGUIEvent event; + nsFocusEvent event(NS_GOTFOCUS, this); #ifdef DEBUG printf("send NS_GOTFOCUS from nsWindow::OnFocusInSignal\n"); #endif - event.message = NS_GOTFOCUS; - event.widget = this; - - event.eventStructType = NS_GUI_EVENT; // event.time = aGdkFocusEvent->time;; // event.time = PR_Now(); - event.time = 0; - event.point.x = 0; - event.point.y = 0; AddRef(); @@ -1714,18 +1669,10 @@ nsWindow::OnFocusOutSignal(GdkEventFocus * aGdkFocusEvent) GTK_WIDGET_UNSET_FLAGS(mMozArea, GTK_HAS_FOCUS); - nsGUIEvent event; + nsFocusEvent event(NS_LOSTFOCUS, this); - event.message = NS_LOSTFOCUS; - event.widget = this; - - event.eventStructType = NS_GUI_EVENT; - // event.time = aGdkFocusEvent->time;; // event.time = PR_Now(); - event.time = 0; - event.point.x = 0; - event.point.y = 0; AddRef(); @@ -1817,17 +1764,9 @@ gint handle_delete_event(GtkWidget *w, GdkEventAny *e, nsWindow *win) NS_ADDREF(win); // dispatch an "onclose" event. to delete immediately, call win->Destroy() - nsGUIEvent event; + nsGUIEvent event(NS_XUL_CLOSE, win); nsEventStatus status; - event.message = NS_XUL_CLOSE; - event.widget = win; - event.eventStructType = NS_GUI_EVENT; - - event.time = 0; - event.point.x = 0; - event.point.y = 0; - win->DispatchEvent(&event, status); NS_RELEASE(win); @@ -2843,17 +2782,11 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) } if (mIsToplevel || mListenForResizes) { //g_print("sending resize event\n"); - nsSizeEvent sevent; - sevent.message = NS_SIZE; - sevent.widget = this; - sevent.eventStructType = NS_SIZE_EVENT; + nsSizeEvent sevent(NS_SIZE, this); sevent.windowSize = new nsRect (0, 0, sizeWidth, sizeHeight); - sevent.point.x = 0; - sevent.point.y = 0; sevent.mWinWidth = sizeWidth; sevent.mWinHeight = sizeHeight; - // XXX fix this - sevent.time = 0; + // XXX fix sevent.time AddRef(); OnResize(&sevent); Release(); @@ -3033,18 +2966,14 @@ nsWindow::HandleXlibConfigureNotifyEvent(XEvent *event) #endif if (mIsToplevel) { - nsSizeEvent sevent; - sevent.message = NS_SIZE; - sevent.widget = this; - sevent.eventStructType = NS_SIZE_EVENT; + nsSizeEvent sevent(NS_SIZE, this); sevent.windowSize = new nsRect (event->xconfigure.x, event->xconfigure.y, event->xconfigure.width, event->xconfigure.height); sevent.point.x = event->xconfigure.x; sevent.point.y = event->xconfigure.y; sevent.mWinWidth = event->xconfigure.width; sevent.mWinHeight = event->xconfigure.height; - // XXX fix this - sevent.time = 0; + // XXX fix sevent.time AddRef(); OnResize(&sevent); Release(); @@ -3186,8 +3115,6 @@ GtkWindow *nsWindow::GetTopLevelWindow(void) void nsWindow::InitDragEvent (nsMouseEvent &aEvent) { - // set everything to zero - memset(&aEvent, 0, sizeof(nsMouseEvent)); // set the keyboard modifiers gint x, y; GdkModifierType state = (GdkModifierType)0; @@ -3312,18 +3239,13 @@ gint nsWindow::OnDragMotionSignal (GtkWidget * aWidget, // notify the drag service that we are starting a drag motion. dragSessionGTK->TargetStartDragMotion(); - nsMouseEvent event; + nsMouseEvent event(NS_DRAGDROP_OVER, innerMostWidget); InitDragEvent(event); // now that we have initialized the event update our drag status UpdateDragStatus(event, aDragContext, dragService); - event.message = NS_DRAGDROP_OVER; - event.eventStructType = NS_DRAGDROP_EVENT; - - event.widget = innerMostWidget; - event.point.x = retx; event.point.y = rety; @@ -3458,16 +3380,13 @@ nsWindow::OnDragDropSignal (GtkWidget *aWidget, innerMostWidget->AddRef(); - nsMouseEvent event; + nsMouseEvent event(NS_DRAGDROP_OVER, innerMostWidget); InitDragEvent(event); // now that we have initialized the event update our drag status UpdateDragStatus(event, aDragContext, dragService); - event.message = NS_DRAGDROP_OVER; - event.eventStructType = NS_DRAGDROP_EVENT; - event.widget = innerMostWidget; event.point.x = retx; event.point.y = rety; @@ -3476,8 +3395,6 @@ nsWindow::OnDragDropSignal (GtkWidget *aWidget, InitDragEvent(event); event.message = NS_DRAGDROP_DROP; - event.eventStructType = NS_DRAGDROP_EVENT; - event.widget = innerMostWidget; event.point.x = retx; event.point.y = rety; @@ -3552,15 +3469,7 @@ nsWindow::OnDragLeave(void) g_print("nsWindow::OnDragLeave\n"); #endif /* DEBUG_DND_EVENTS */ - nsMouseEvent event; - - event.message = NS_DRAGDROP_EXIT; - event.eventStructType = NS_DRAGDROP_EVENT; - - event.widget = this; - - event.point.x = 0; - event.point.y = 0; + nsMouseEvent event(NS_DRAGDROP_EXIT, this); AddRef(); @@ -3576,12 +3485,7 @@ nsWindow::OnDragEnter(nscoord aX, nscoord aY) g_print("nsWindow::OnDragEnter\n"); #endif /* DEBUG_DND_EVENTS */ - nsMouseEvent event; - - event.message = NS_DRAGDROP_ENTER; - event.eventStructType = NS_DRAGDROP_EVENT; - - event.widget = this; + nsMouseEvent event(NS_DRAGDROP_ENTER, this); event.point.x = aX; event.point.y = aY; @@ -3798,54 +3702,47 @@ void nsWindow::ICSpotCallback(nsITimer * aTimer, void * aClosure) nsresult nsWindow::UpdateICSpot(nsIMEGtkIC *aXIC) { - // set spot location - nsCompositionEvent compEvent; - compEvent.widget = NS_STATIC_CAST(nsWidget *, this); - compEvent.point.x = 0; - compEvent.point.y = 0; - compEvent.time = 0; - compEvent.message = NS_COMPOSITION_QUERY; - compEvent.eventStructType = NS_COMPOSITION_QUERY; - compEvent.compositionMessage = NS_COMPOSITION_QUERY; - static gint oldx =0; - static gint oldy =0; - static gint oldw =0; - static gint oldh =0; - compEvent.theReply.mCursorPosition.x=-1; - compEvent.theReply.mCursorPosition.y=-1; - this->OnComposition(compEvent); - // set SpotLocation - if((compEvent.theReply.mCursorPosition.x < 0) && - (compEvent.theReply.mCursorPosition.y < 0)) - return NS_ERROR_FAILURE; + // set spot location + nsCompositionEvent compEvent(NS_COMPOSITION_QUERY, this); + static gint oldx =0; + static gint oldy =0; + static gint oldw =0; + static gint oldh =0; + compEvent.theReply.mCursorPosition.x=-1; + compEvent.theReply.mCursorPosition.y=-1; + this->OnComposition(compEvent); + // set SpotLocation + if((compEvent.theReply.mCursorPosition.x < 0) && + (compEvent.theReply.mCursorPosition.y < 0)) + return NS_ERROR_FAILURE; - // In over-the-spot style, pre-edit can not be drawn properly when - // IMESetFocusWindow() is called at height=1 and width=1 - // After resizing, we need to call SetPreeditArea() again - if((oldw != mBounds.width) || (oldh != mBounds.height)) { - GdkWindow *gdkWindow = (GdkWindow*)this->GetNativeData(NS_NATIVE_WINDOW); - if (gdkWindow) { - aXIC->SetPreeditArea(0, 0, - (int)((GdkWindowPrivate*)gdkWindow)->width, - (int)((GdkWindowPrivate*)gdkWindow)->height); - } - oldw = mBounds.width; - oldh = mBounds.height; - } + // In over-the-spot style, pre-edit can not be drawn properly when + // IMESetFocusWindow() is called at height=1 and width=1 + // After resizing, we need to call SetPreeditArea() again + if((oldw != mBounds.width) || (oldh != mBounds.height)) { + GdkWindow *gdkWindow = (GdkWindow*)this->GetNativeData(NS_NATIVE_WINDOW); + if (gdkWindow) { + aXIC->SetPreeditArea(0, 0, + (int)((GdkWindowPrivate*)gdkWindow)->width, + (int)((GdkWindowPrivate*)gdkWindow)->height); + } + oldw = mBounds.width; + oldh = mBounds.height; + } - if((compEvent.theReply.mCursorPosition.x != oldx)|| - (compEvent.theReply.mCursorPosition.y != oldy)) - { - nsPoint spot; - spot.x = compEvent.theReply.mCursorPosition.x; - spot.y = compEvent.theReply.mCursorPosition.y + - compEvent.theReply.mCursorPosition.height; - SetXICBaseFontSize(aXIC, compEvent.theReply.mCursorPosition.height - 1); - SetXICSpotLocation(aXIC, spot); - oldx = compEvent.theReply.mCursorPosition.x; - oldy = compEvent.theReply.mCursorPosition.y; - } - return NS_OK; + if((compEvent.theReply.mCursorPosition.x != oldx)|| + (compEvent.theReply.mCursorPosition.y != oldy)) + { + nsPoint spot; + spot.x = compEvent.theReply.mCursorPosition.x; + spot.y = compEvent.theReply.mCursorPosition.y + + compEvent.theReply.mCursorPosition.height; + SetXICBaseFontSize(aXIC, compEvent.theReply.mCursorPosition.height - 1); + SetXICSpotLocation(aXIC, spot); + oldx = compEvent.theReply.mCursorPosition.x; + oldy = compEvent.theReply.mCursorPosition.y; + } + return NS_OK; } void @@ -4070,12 +3967,8 @@ nsWindow::IMEComposeStart(guint aTime) return; } #endif // USE_XIM - nsCompositionEvent compEvent; - compEvent.widget = NS_STATIC_CAST(nsWidget *, this); - compEvent.point.x = compEvent.point.y = 0; + nsCompositionEvent compEvent(NS_COMPOSITION_START, this); compEvent.time = aTime; - compEvent.message = compEvent.eventStructType - = compEvent.compositionMessage = NS_COMPOSITION_START; OnComposition(compEvent); @@ -4147,7 +4040,7 @@ void nsWindow::IMEComposeText(GdkEventKey *aEvent, const PRUnichar *aText, const PRInt32 aLen, const char *aFeedback) { - nsTextEvent textEvent; + nsTextEvent textEvent(NS_TEXT_TEXT, this); if (aEvent) { textEvent.isShift = (aEvent->state & GDK_SHIFT_MASK) ? PR_TRUE : PR_FALSE; textEvent.isControl = (aEvent->state & GDK_CONTROL_MASK) ? PR_TRUE : PR_FALSE; @@ -4155,23 +4048,10 @@ nsWindow::IMEComposeText(GdkEventKey *aEvent, // XXX textEvent.isMeta = PR_FALSE; //(aEvent->state & GDK_MOD2_MASK) ? PR_TRUE : PR_FALSE; textEvent.time = aEvent->time; - } else { - textEvent.time = 0; - textEvent.isShift = textEvent.isControl = - textEvent.isAlt = textEvent.isMeta = PR_FALSE; } - textEvent.message = textEvent.eventStructType = NS_TEXT_EVENT; - textEvent.widget = NS_STATIC_CAST(nsWidget *, this); - textEvent.point.x = textEvent.point.y = 0; - if (aLen == 0) { - textEvent.theText = nsnull; - textEvent.rangeCount = 0; - textEvent.rangeArray = nsnull; - } else { + if (aLen != 0) { textEvent.theText = (PRUnichar*)aText; - textEvent.rangeCount = 0; - textEvent.rangeArray = nsnull; #ifdef USE_XIM if (aFeedback) { nsIMEPreedit::IMSetTextRange(aLen, @@ -4198,12 +4078,8 @@ nsWindow::IMEComposeEnd(guint aTime) } #endif // USE_XIM - nsCompositionEvent compEvent; - compEvent.widget = NS_STATIC_CAST(nsWidget*, this); - compEvent.point.x = compEvent.point.y = 0; + nsCompositionEvent compEvent(NS_COMPOSITION_END, this); compEvent.time = aTime; - compEvent.message = compEvent.eventStructType - = compEvent.compositionMessage = NS_COMPOSITION_END; OnComposition(compEvent); #ifdef USE_XIM diff --git a/mozilla/widget/src/gtk2/nsCommonWidget.cpp b/mozilla/widget/src/gtk2/nsCommonWidget.cpp index 33f9483ff87..888d04c8b33 100644 --- a/mozilla/widget/src/gtk2/nsCommonWidget.cpp +++ b/mozilla/widget/src/gtk2/nsCommonWidget.cpp @@ -76,51 +76,9 @@ nsCommonWidget::CommonCreate(nsIWidget *aParent, PRBool aListenForResizes) } void -nsCommonWidget::InitPaintEvent(nsPaintEvent &aEvent) -{ - memset(&aEvent, 0, sizeof(nsPaintEvent)); - aEvent.eventStructType = NS_PAINT_EVENT; - aEvent.message = NS_PAINT; - aEvent.widget = NS_STATIC_CAST(nsIWidget *, this); - aEvent.region = nsnull; -} - -void -nsCommonWidget::InitSizeEvent(nsSizeEvent &aEvent) -{ - memset(&aEvent, 0, sizeof(nsSizeEvent)); - aEvent.eventStructType = NS_SIZE_EVENT; - aEvent.message = NS_SIZE; - aEvent.widget = NS_STATIC_CAST(nsIWidget *, this); -} - -void -nsCommonWidget::InitGUIEvent(nsGUIEvent &aEvent, PRUint32 aMsg) -{ - memset(&aEvent, 0, sizeof(nsGUIEvent)); - aEvent.eventStructType = NS_GUI_EVENT; - aEvent.message = aMsg; - aEvent.widget = NS_STATIC_CAST(nsIWidget *, this); -} - -void -nsCommonWidget::InitMouseEvent(nsMouseEvent &aEvent, PRUint32 aMsg) -{ - memset(&aEvent, 0, sizeof(nsMouseEvent)); - aEvent.eventStructType = NS_MOUSE_EVENT; - aEvent.message = aMsg; - aEvent.widget = NS_STATIC_CAST(nsIWidget *, this); -} - -void -nsCommonWidget::InitButtonEvent(nsMouseEvent &aEvent, PRUint32 aMsg, +nsCommonWidget::InitButtonEvent(nsMouseEvent &aEvent, GdkEventButton *aGdkEvent) { - memset(&aEvent, 0, sizeof(nsMouseEvent)); - aEvent.eventStructType = NS_MOUSE_EVENT; - aEvent.message = aMsg; - aEvent.widget = NS_STATIC_CAST(nsIWidget *, this); - aEvent.point.x = nscoord(aGdkEvent->x); aEvent.point.y = nscoord(aGdkEvent->y); @@ -148,13 +106,8 @@ nsCommonWidget::InitButtonEvent(nsMouseEvent &aEvent, PRUint32 aMsg, void nsCommonWidget::InitMouseScrollEvent(nsMouseScrollEvent &aEvent, - GdkEventScroll *aGdkEvent, PRUint32 aMsg) + GdkEventScroll *aGdkEvent) { - memset(&aEvent, 0, sizeof(nsMouseScrollEvent)); - aEvent.eventStructType = NS_MOUSE_SCROLL_EVENT; - aEvent.message = aMsg; - aEvent.widget = NS_STATIC_CAST(nsIWidget *, this); - switch (aGdkEvent->direction) { case GDK_SCROLL_UP: aEvent.scrollFlags = nsMouseScrollEvent::kIsVertical; @@ -186,15 +139,9 @@ nsCommonWidget::InitMouseScrollEvent(nsMouseScrollEvent &aEvent, } void -nsCommonWidget::InitKeyEvent(nsKeyEvent &aEvent, GdkEventKey *aGdkEvent, - PRUint32 aMsg) +nsCommonWidget::InitKeyEvent(nsKeyEvent &aEvent, GdkEventKey *aGdkEvent) { - memset(&aEvent, 0, sizeof(nsKeyEvent)); - aEvent.eventStructType = NS_KEY_EVENT; - aEvent.message = aMsg; - aEvent.widget = NS_STATIC_CAST(nsIWidget *, this); aEvent.keyCode = GdkKeyCodeToDOMKeyCode(aGdkEvent->keyval); - aEvent.charCode = 0; aEvent.isShift = (aGdkEvent->state & GDK_SHIFT_MASK) ? PR_TRUE : PR_FALSE; aEvent.isControl = (aGdkEvent->state & GDK_CONTROL_MASK) @@ -206,34 +153,10 @@ nsCommonWidget::InitKeyEvent(nsKeyEvent &aEvent, GdkEventKey *aGdkEvent, aEvent.time = aGdkEvent->time; } -#ifdef ACCESSIBILITY - -void -nsCommonWidget::InitAccessibleEvent(nsAccessibleEvent &aEvent) -{ - memset(&aEvent, 0, sizeof(nsAccessibleEvent)); - aEvent.message = NS_GETACCESSIBLE; - aEvent.eventStructType = NS_ACCESSIBLE_EVENT; - aEvent.accessible = nsnull; - aEvent.widget = NS_STATIC_CAST(nsIWidget *, this); -} - -#endif - -void -nsCommonWidget::InitSizeModeEvent(nsSizeModeEvent &aEvent) -{ - memset(&aEvent, 0, sizeof(nsSizeModeEvent)); - aEvent.eventStructType = NS_SIZEMODE_EVENT; - aEvent.message = NS_SIZEMODE; - aEvent.widget = NS_STATIC_CAST(nsIWidget *, this); -} - void nsCommonWidget::DispatchGotFocusEvent(void) { - nsGUIEvent event; - InitGUIEvent(event, NS_GOTFOCUS); + nsGUIEvent event(NS_GOTFOCUS, this); nsEventStatus status; DispatchEvent(&event, status); } @@ -241,8 +164,7 @@ nsCommonWidget::DispatchGotFocusEvent(void) void nsCommonWidget::DispatchLostFocusEvent(void) { - nsGUIEvent event; - InitGUIEvent(event, NS_LOSTFOCUS); + nsGUIEvent event(NS_LOSTFOCUS, this); nsEventStatus status; DispatchEvent(&event, status); } @@ -250,8 +172,7 @@ nsCommonWidget::DispatchLostFocusEvent(void) void nsCommonWidget::DispatchActivateEvent(void) { - nsGUIEvent event; - InitGUIEvent(event, NS_ACTIVATE); + nsGUIEvent event(NS_ACTIVATE, this); nsEventStatus status; DispatchEvent(&event, status); } @@ -259,8 +180,7 @@ nsCommonWidget::DispatchActivateEvent(void) void nsCommonWidget::DispatchDeactivateEvent(void) { - nsGUIEvent event; - InitGUIEvent(event, NS_DEACTIVATE); + nsGUIEvent event(NS_DEACTIVATE, this); nsEventStatus status; DispatchEvent(&event, status); } @@ -268,8 +188,7 @@ nsCommonWidget::DispatchDeactivateEvent(void) void nsCommonWidget::DispatchResizeEvent(nsRect &aRect, nsEventStatus &aStatus) { - nsSizeEvent event; - InitSizeEvent(event); + nsSizeEvent event(NS_SIZE, this); event.windowSize = &aRect; event.point.x = aRect.x; @@ -516,9 +435,7 @@ nsCommonWidget::OnDestroy(void) nsCOMPtr kungFuDeathGrip = this; - nsGUIEvent event; - InitGUIEvent(event, NS_DESTROY); - + nsGUIEvent event(NS_DESTROY, this); nsEventStatus status; DispatchEvent(&event, status); } diff --git a/mozilla/widget/src/gtk2/nsCommonWidget.h b/mozilla/widget/src/gtk2/nsCommonWidget.h index d63b28a2818..4de9cd95467 100644 --- a/mozilla/widget/src/gtk2/nsCommonWidget.h +++ b/mozilla/widget/src/gtk2/nsCommonWidget.h @@ -68,20 +68,11 @@ public: void CommonCreate(nsIWidget *aParent, PRBool aListenForResizes); // event handling code - void InitPaintEvent(nsPaintEvent &aEvent); - void InitSizeEvent(nsSizeEvent &aEvent); - void InitGUIEvent(nsGUIEvent &aEvent, PRUint32 aMsg); - void InitMouseEvent(nsMouseEvent &aEvent, PRUint32 aMsg); - void InitButtonEvent(nsMouseEvent &aEvent, PRUint32 aMsg, + void InitButtonEvent(nsMouseEvent &aEvent, GdkEventButton *aGdkEvent); void InitMouseScrollEvent(nsMouseScrollEvent &aEvent, - GdkEventScroll *aGdkEvent, PRUint32 aMsg); - void InitKeyEvent(nsKeyEvent &aEvent, GdkEventKey *aGdkEvent, PRUint32 aMsg); - void InitSizeModeEvent(nsSizeModeEvent &aEvent); - -#ifdef ACCESSIBILITY - void InitAccessibleEvent(nsAccessibleEvent &aEvent); -#endif + GdkEventScroll *aGdkEvent); + void InitKeyEvent(nsKeyEvent &aEvent, GdkEventKey *aGdkEvent); void DispatchGotFocusEvent(void); void DispatchLostFocusEvent(void); diff --git a/mozilla/widget/src/gtk2/nsWindow.cpp b/mozilla/widget/src/gtk2/nsWindow.cpp index d0c8b7d33a1..8b27e51c872 100644 --- a/mozilla/widget/src/gtk2/nsWindow.cpp +++ b/mozilla/widget/src/gtk2/nsWindow.cpp @@ -1178,9 +1178,7 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent) // XXX figure out the region/rect stuff! nsRect rect(aEvent->area.x, aEvent->area.y, aEvent->area.width, aEvent->area.height); - nsPaintEvent event; - - InitPaintEvent(event); + nsPaintEvent event(NS_PAINT, this); event.point.x = aEvent->area.x; event.point.y = aEvent->area.y; @@ -1210,8 +1208,7 @@ nsWindow::OnConfigureEvent(GtkWidget *aWidget, GdkEventConfigure *aEvent) mBounds.y == aEvent->y) return FALSE; - nsGUIEvent event; - InitGUIEvent(event, NS_MOVE); + nsGUIEvent event(NS_MOVE, this); event.point.x = aEvent->x; event.point.y = aEvent->y; @@ -1249,9 +1246,7 @@ nsWindow::OnSizeAllocate(GtkWidget *aWidget, GtkAllocation *aAllocation) void nsWindow::OnDeleteEvent(GtkWidget *aWidget, GdkEventAny *aEvent) { - nsGUIEvent event; - - InitGUIEvent(event, NS_XUL_CLOSE); + nsGUIEvent event(NS_XUL_CLOSE, this); event.point.x = 0; event.point.y = 0; @@ -1263,8 +1258,7 @@ nsWindow::OnDeleteEvent(GtkWidget *aWidget, GdkEventAny *aEvent) void nsWindow::OnEnterNotifyEvent(GtkWidget *aWidget, GdkEventCrossing *aEvent) { - nsMouseEvent event; - InitMouseEvent(event, NS_MOUSE_ENTER); + nsMouseEvent event(NS_MOUSE_ENTER, this); event.point.x = nscoord(aEvent->x); event.point.y = nscoord(aEvent->y); @@ -1278,8 +1272,7 @@ nsWindow::OnEnterNotifyEvent(GtkWidget *aWidget, GdkEventCrossing *aEvent) void nsWindow::OnLeaveNotifyEvent(GtkWidget *aWidget, GdkEventCrossing *aEvent) { - nsMouseEvent event; - InitMouseEvent(event, NS_MOUSE_EXIT); + nsMouseEvent event(NS_MOUSE_EXIT, this); event.point.x = nscoord(aEvent->x); event.point.y = nscoord(aEvent->y); @@ -1311,8 +1304,7 @@ nsWindow::OnMotionNotifyEvent(GtkWidget *aWidget, GdkEventMotion *aEvent) gPluginFocusWindow->LoseNonXEmbedPluginFocus(); } - nsMouseEvent event; - InitMouseEvent(event, NS_MOUSE_MOVE); + nsMouseEvent event(NS_MOUSE_MOVE, this); if (synthEvent) { event.point.x = nscoord(xevent.xmotion.x); @@ -1344,7 +1336,6 @@ nsWindow::OnMotionNotifyEvent(GtkWidget *aWidget, GdkEventMotion *aEvent) void nsWindow::OnButtonPressEvent(GtkWidget *aWidget, GdkEventButton *aEvent) { - nsMouseEvent event; PRUint32 eventType; nsEventStatus status; @@ -1389,14 +1380,15 @@ nsWindow::OnButtonPressEvent(GtkWidget *aWidget, GdkEventButton *aEvent) break; } - InitButtonEvent(event, eventType, aEvent); + nsMouseEvent event(eventType, this); + InitButtonEvent(event, aEvent); DispatchEvent(&event, status); // right menu click on linux should also pop up a context menu if (eventType == NS_MOUSE_RIGHT_BUTTON_DOWN) { - nsMouseEvent contextMenuEvent; - InitButtonEvent(contextMenuEvent, NS_CONTEXTMENU, aEvent); + nsMouseEvent contextMenuEvent(NS_CONTEXTMENU, this); + InitButtonEvent(contextMenuEvent, aEvent); DispatchEvent(&contextMenuEvent, status); } } @@ -1404,7 +1396,6 @@ nsWindow::OnButtonPressEvent(GtkWidget *aWidget, GdkEventButton *aEvent) void nsWindow::OnButtonReleaseEvent(GtkWidget *aWidget, GdkEventButton *aEvent) { - nsMouseEvent event; PRUint32 eventType; switch (aEvent->button) { @@ -1425,7 +1416,8 @@ nsWindow::OnButtonReleaseEvent(GtkWidget *aWidget, GdkEventButton *aEvent) break; } - InitButtonEvent(event, eventType, aEvent); + nsMouseEvent event(eventType, this); + InitButtonEvent(event, aEvent); nsEventStatus status; DispatchEvent(&event, status); @@ -1531,7 +1523,6 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent) LOGIM(("sending as regular key press event\n")); #endif - nsKeyEvent event; nsEventStatus status; // work around for annoying things. @@ -1560,11 +1551,13 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent) mInKeyRepeat = PR_TRUE; // send the key down event - InitKeyEvent(event, aEvent, NS_KEY_DOWN); - DispatchEvent(&event, status); + nsKeyEvent downEvent(NS_KEY_DOWN, this); + InitKeyEvent(downEvent, aEvent); + DispatchEvent(&downEvent, status); } - InitKeyEvent(event, aEvent, NS_KEY_PRESS); + nsKeyEvent event(NS_KEY_PRESS, this); + InitKeyEvent(event, aEvent); event.charCode = nsConvertCharCodeToUnicode(aEvent); if (event.charCode) { event.keyCode = 0; @@ -1620,7 +1613,6 @@ nsWindow::OnKeyReleaseEvent(GtkWidget *aWidget, GdkEventKey *aEvent) return TRUE; #endif - nsKeyEvent event; nsEventStatus status; // unset the repeat flag @@ -1637,7 +1629,8 @@ nsWindow::OnKeyReleaseEvent(GtkWidget *aWidget, GdkEventKey *aEvent) return TRUE; } - InitKeyEvent(event, aEvent, NS_KEY_UP); + nsKeyEvent event(NS_KEY_UP, this); + InitKeyEvent(event, aEvent); DispatchEvent(&event, status); @@ -1653,8 +1646,8 @@ nsWindow::OnKeyReleaseEvent(GtkWidget *aWidget, GdkEventKey *aEvent) void nsWindow::OnScrollEvent(GtkWidget *aWidget, GdkEventScroll *aEvent) { - nsMouseScrollEvent event; - InitMouseScrollEvent(event, aEvent, NS_MOUSE_SCROLL); + nsMouseScrollEvent event(NS_MOUSE_SCROLL, this); + InitMouseScrollEvent(event, aEvent); // check to see if we should rollup if (check_for_rollup(aEvent->window, aEvent->x_root, aEvent->y_root, @@ -1689,8 +1682,7 @@ nsWindow::OnWindowStateEvent(GtkWidget *aWidget, GdkEventWindowState *aEvent) LOG(("nsWindow::OnWindowStateEvent [%p] changed %d new_window_state %d\n", (void *)this, aEvent->changed_mask, aEvent->new_window_state)); - nsSizeModeEvent event; - InitSizeModeEvent(event); + nsSizeModeEvent event(NS_SIZEMODE, this); // We don't care about anything but changes in the maximized/icon // states @@ -1780,18 +1772,13 @@ nsWindow::OnDragMotionEvent(GtkWidget *aWidget, // notify the drag service that we are starting a drag motion. dragSessionGTK->TargetStartDragMotion(); - nsMouseEvent event; + nsMouseEvent event(NS_DRAGDROP_OVER, innerMostWidget); InitDragEvent(event); // now that we have initialized the event update our drag status UpdateDragStatus(event, aDragContext, dragService); - event.message = NS_DRAGDROP_OVER; - event.eventStructType = NS_DRAGDROP_EVENT; - - event.widget = innerMostWidget; - event.point.x = retx; event.point.y = rety; @@ -1900,27 +1887,20 @@ nsWindow::OnDragDropEvent(GtkWidget *aWidget, innerMostWidget->AddRef(); - nsMouseEvent event; + nsMouseEvent event(NS_DRAGDROP_OVER, innerMostWidget); InitDragEvent(event); // now that we have initialized the event update our drag status UpdateDragStatus(event, aDragContext, dragService); - event.message = NS_DRAGDROP_OVER; - event.eventStructType = NS_DRAGDROP_EVENT; - event.widget = innerMostWidget; event.point.x = retx; event.point.y = rety; nsEventStatus status; innerMostWidget->DispatchEvent(&event, status); - InitDragEvent(event); - event.message = NS_DRAGDROP_DROP; - event.eventStructType = NS_DRAGDROP_EVENT; - event.widget = innerMostWidget; event.point.x = retx; event.point.y = rety; @@ -1975,15 +1955,7 @@ nsWindow::OnDragLeave(void) { LOG(("nsWindow::OnDragLeave(%p)\n", this)); - nsMouseEvent event; - - event.message = NS_DRAGDROP_EXIT; - event.eventStructType = NS_DRAGDROP_EVENT; - - event.widget = this; - - event.point.x = 0; - event.point.y = 0; + nsMouseEvent event(NS_DRAGDROP_EXIT, this); AddRef(); @@ -1998,12 +1970,7 @@ nsWindow::OnDragEnter(nscoord aX, nscoord aY) { LOG(("nsWindow::OnDragEnter(%p)\n", this)); - nsMouseEvent event; - - event.message = NS_DRAGDROP_ENTER; - event.eventStructType = NS_DRAGDROP_EVENT; - - event.widget = this; + nsMouseEvent event(NS_DRAGDROP_ENTER, this); event.point.x = aX; event.point.y = aY; @@ -3488,8 +3455,6 @@ property_notify_event_cb (GtkWidget *widget, GdkEventProperty *event) void nsWindow::InitDragEvent(nsMouseEvent &aEvent) { - // set everything to zero - memset(&aEvent, 0, sizeof(nsMouseEvent)); // set the keyboard modifiers gint x, y; GdkModifierType state = (GdkModifierType)0; @@ -3757,7 +3722,6 @@ key_event_to_context_menu_event(const nsKeyEvent* aKeyEvent, nsMouseEvent* aCMEvent) { memcpy(aCMEvent, aKeyEvent, sizeof(nsInputEvent)); - aCMEvent->eventStructType = NS_MOUSE_EVENT; aCMEvent->message = NS_CONTEXTMENU_KEY; aCMEvent->isShift = aCMEvent->isControl = PR_FALSE; aCMEvent->isAlt = aCMEvent->isMeta = PR_FALSE; @@ -3816,11 +3780,10 @@ PRBool nsWindow::DispatchAccessibleEvent(nsIAccessible** aAccessible) { PRBool result = PR_FALSE; - nsAccessibleEvent event; + nsAccessibleEvent event(NS_GETACCESSIBLE, this); *aAccessible = nsnull; - InitAccessibleEvent(event); nsEventStatus status; DispatchEvent(&event, status); result = (nsEventStatus_eConsumeNoDefault == status) ? PR_TRUE : PR_FALSE; @@ -3900,13 +3863,7 @@ nsWindow::IMEComposeStart(void) mComposingText = PR_TRUE; - nsCompositionEvent compEvent; - - compEvent.widget = NS_STATIC_CAST(nsIWidget *, this); - compEvent.point.x = compEvent.point.y = 0; - compEvent.time = 0; // Potential problem ? - compEvent.message = compEvent.eventStructType - = compEvent.compositionMessage = NS_COMPOSITION_START; + nsCompositionEvent compEvent(NS_COMPOSITION_START, this); nsEventStatus status; DispatchEvent(&compEvent, status); @@ -3923,24 +3880,10 @@ nsWindow::IMEComposeText (const PRUnichar *aText, IMEComposeStart(); LOGIM(("IMEComposeText\n")); - nsTextEvent textEvent; + nsTextEvent textEvent(NS_TEXT_TEXT, this); - textEvent.time = 0; - textEvent.isShift = textEvent.isControl = - textEvent.isAlt = textEvent.isMeta = PR_FALSE; - - textEvent.message = textEvent.eventStructType = NS_TEXT_EVENT; - textEvent.widget = NS_STATIC_CAST(nsIWidget *, this); - textEvent.point.x = textEvent.point.y = 0; - - if (aLen == 0) { - textEvent.theText = nsnull; - textEvent.rangeCount = 0; - textEvent.rangeArray = nsnull; - } else { + if (aLen != 0) { textEvent.theText = (PRUnichar*)aText; - textEvent.rangeCount = 0; - textEvent.rangeArray = nsnull; if (aPreeditString && aFeedback && (aLen > 0)) { IM_set_text_range(aLen, aPreeditString, aFeedback, @@ -3969,12 +3912,7 @@ nsWindow::IMEComposeEnd(void) mComposingText = PR_FALSE; - nsCompositionEvent compEvent; - compEvent.widget = NS_STATIC_CAST(nsIWidget *, this); - compEvent.point.x = compEvent.point.y = 0; - compEvent.time = 0; - compEvent.message = compEvent.eventStructType - = compEvent.compositionMessage = NS_COMPOSITION_END; + nsCompositionEvent compEvent(NS_COMPOSITION_END, this); nsEventStatus status; DispatchEvent(&compEvent, status); diff --git a/mozilla/widget/src/mac/nsDynamicMDEF.cpp b/mozilla/widget/src/mac/nsDynamicMDEF.cpp index 9a24b4a5cae..c19cab2aa98 100644 --- a/mozilla/widget/src/mac/nsDynamicMDEF.cpp +++ b/mozilla/widget/src/mac/nsDynamicMDEF.cpp @@ -246,14 +246,8 @@ pascal void nsDynamicMDEFMain( if(listener) { //printf("MenuPop \n"); - nsMenuEvent mevent; - mevent.message = NS_MENU_SELECTED; - mevent.eventStructType = NS_MENU_EVENT; - mevent.point.x = 0; - mevent.point.y = 0; - mevent.widget = nsnull; + nsMenuEvent mevent(NS_MENU_SELECTED); mevent.time = PR_IntervalNow(); - mevent.mCommand = (PRUint32) nsnull; // UNDO listener->MenuDeselected(mevent); @@ -392,12 +386,7 @@ void nsBuildMenu(MenuHandle theMenu, PRBool isChild) return; } - nsMenuEvent mevent; - mevent.message = NS_MENU_SELECTED; - mevent.eventStructType = NS_MENU_EVENT; - mevent.point.x = 0; - mevent.point.y = 0; - mevent.widget = nsnull; + nsMenuEvent mevent(NS_MENU_SELECTED); mevent.time = PR_IntervalNow(); mevent.mCommand = (PRUint32) theMenu; @@ -538,14 +527,8 @@ void nsPreviousMenuStackUnwind(nsIMenu * aMenuJustBuilt, MenuHandle aMenuHandleJ if( menuHandle != aMenuHandleJustBuilt ) { nsCOMPtr listener(do_QueryInterface(menu)); if(listener) { - nsMenuEvent mevent; - mevent.message = NS_MENU_SELECTED; - mevent.eventStructType = NS_MENU_EVENT; - mevent.point.x = 0; - mevent.point.y = 0; - mevent.widget = nsnull; + nsMenuEvent mevent(NS_MENU_SELECTED); mevent.time = PR_IntervalNow(); - mevent.mCommand = (PRUint32) nsnull; // UNDO listener->MenuDeselected(mevent); diff --git a/mozilla/widget/src/mac/nsMacControl.cpp b/mozilla/widget/src/mac/nsMacControl.cpp index 11da9d008cd..cc4e6286221 100644 --- a/mozilla/widget/src/mac/nsMacControl.cpp +++ b/mozilla/widget/src/mac/nsMacControl.cpp @@ -261,14 +261,8 @@ void nsMacControl::ControlChanged(PRInt32 aNewValue) mValue = aNewValue; mLastValue = mValue; // safely assume that the control has been repainted already - nsGUIEvent guiEvent; - nsPoint point(0,0); - guiEvent.eventStructType = NS_GUI_EVENT; - guiEvent.message = NS_CONTROL_CHANGE; - guiEvent.point = point; + nsGUIEvent guiEvent(NS_CONTROL_CHANGE, this); guiEvent.time = PR_IntervalNow(); - guiEvent.widget = this; - guiEvent.nativeMsg = nsnull; Inherited::DispatchWindowEvent(guiEvent); } } diff --git a/mozilla/widget/src/mac/nsMacEventHandler.cpp b/mozilla/widget/src/mac/nsMacEventHandler.cpp index 598e5e1ba92..40bb4f7810d 100644 --- a/mozilla/widget/src/mac/nsMacEventHandler.cpp +++ b/mozilla/widget/src/mac/nsMacEventHandler.cpp @@ -150,7 +150,7 @@ HandleScrollEvent ( EventMouseWheelAxis inAxis, PRBool inByLine, PRInt32 inDelta if (!inWidget) return nsEventStatus_eIgnore; - nsMouseScrollEvent scrollEvent; + nsMouseScrollEvent scrollEvent(NS_MOUSE_SCROLL, inWidget); scrollEvent.scrollFlags = (inAxis == kEventMouseWheelAxisX) ? nsMouseScrollEvent::kIsHorizontal : nsMouseScrollEvent::kIsVertical; @@ -166,18 +166,10 @@ HandleScrollEvent ( EventMouseWheelAxis inAxis, PRBool inByLine, PRInt32 inDelta inWidget->ConvertToDeviceCoordinates(widgetOrigin.x, widgetOrigin.y); mouseLocRelativeToWidget.MoveBy(-widgetOrigin.x, -widgetOrigin.y); - scrollEvent.eventStructType = NS_MOUSE_SCROLL_EVENT; - scrollEvent.isShift = PR_FALSE; - scrollEvent.isControl = PR_FALSE; - scrollEvent.isMeta = PR_FALSE; - scrollEvent.isAlt = PR_FALSE; - scrollEvent.message = NS_MOUSE_SCROLL; scrollEvent.delta = inDelta; scrollEvent.point.x = mouseLocRelativeToWidget.x; scrollEvent.point.y = mouseLocRelativeToWidget.y; scrollEvent.time = PR_IntervalNow(); - scrollEvent.widget = inWidget; - scrollEvent.nativeMsg = nsnull; // dispatch scroll event nsEventStatus rv; @@ -235,14 +227,8 @@ void nsMacEventDispatchHandler::DispatchGuiEvent(nsWindow *aWidget, PRUint32 aEv if (!aWidget) return; - nsGUIEvent guiEvent; - guiEvent.eventStructType = NS_GUI_EVENT; - guiEvent.point.x = 0; - guiEvent.point.y = 0; + nsGUIEvent guiEvent(aEventType, aWidget); guiEvent.time = PR_IntervalNow(); - guiEvent.nativeMsg = nsnull; - guiEvent.message = aEventType; - guiEvent.widget = aWidget; aWidget->DispatchWindowEvent(guiEvent); } @@ -255,14 +241,8 @@ void nsMacEventDispatchHandler::DispatchSizeModeEvent(nsWindow *aWidget, nsSizeM if (!aWidget) return; - nsSizeModeEvent event; - event.eventStructType = NS_SIZEMODE_EVENT; - event.point.x = 0; - event.point.y = 0; + nsSizeModeEvent event(NS_SIZEMODE, aWidget); event.time = PR_IntervalNow(); - event.nativeMsg = nsnull; - event.message = NS_SIZEMODE; - event.widget = aWidget; event.mSizeMode = aMode; aWidget->DispatchWindowEvent(event); } @@ -593,19 +573,16 @@ PRBool nsMacEventHandler::HandleMenuCommand( focusedWidget = mTopLevelWidget; // nsEvent - nsMenuEvent menuEvent; - menuEvent.eventStructType = NS_MENU_EVENT; - menuEvent.message = NS_MENU_SELECTED; + nsMenuEvent menuEvent(NS_MENU_SELECTED, focusedWidget); menuEvent.point.x = aOSEvent.where.h; menuEvent.point.y = aOSEvent.where.v; menuEvent.time = PR_IntervalNow(); // nsGUIEvent - menuEvent.widget = focusedWidget; menuEvent.nativeMsg = (void*)&aOSEvent; // nsMenuEvent - menuEvent.mMenuItem = nsnull; //ÄTODO: initialize mMenuItem + // TODO: initialize mMenuItem menuEvent.mCommand = aMenuResult; // dispatch the menu event @@ -659,8 +636,6 @@ PRBool nsMacEventHandler::HandleMenuCommand( // PRBool nsMacEventHandler::DragEvent ( unsigned int aMessage, Point aMouseGlobal, UInt16 aKeyModifiers ) { - nsMouseEvent geckoEvent; - // convert the mouse to local coordinates. We have to do all the funny port origin // stuff just in case it has been changed. Point hitPointLocal = aMouseGlobal; @@ -693,16 +668,12 @@ PRBool nsMacEventHandler::DragEvent ( unsigned int aMessage, Point aMouseGlobal, // update the tracking of which widget the mouse is now over. gEventDispatchHandler.SetWidgetPointed(widgetHit); + nsMouseEvent geckoEvent(aMessage, widgetHit); + // nsEvent - geckoEvent.eventStructType = NS_DRAGDROP_EVENT; - geckoEvent.message = aMessage; geckoEvent.point = widgetHitPoint; geckoEvent.time = PR_IntervalNow(); - // nsGUIEvent - geckoEvent.widget = widgetHit; - geckoEvent.nativeMsg = nsnull; - // nsInputEvent geckoEvent.isShift = ((aKeyModifiers & shiftKey) != 0); geckoEvent.isControl = ((aKeyModifiers & controlKey) != 0); @@ -927,16 +898,12 @@ static PRUint32 ConvertMacToRaptorKeyCode(UInt32 eventMessage, UInt32 eventModif //------------------------------------------------------------------------- void nsMacEventHandler::InitializeKeyEvent(nsKeyEvent& aKeyEvent, - EventRecord& aOSEvent, nsWindow* aFocusedWidget, PRUint32 aMessage, + EventRecord& aOSEvent, nsWindow* aFocusedWidget, PRBool* aIsChar, PRBool aConvertChar) { // // initalize the basic message parts // - aKeyEvent.eventStructType = NS_KEY_EVENT; - aKeyEvent.message = aMessage; - aKeyEvent.point.x = 0; - aKeyEvent.point.y = 0; aKeyEvent.time = PR_IntervalNow(); // @@ -1178,16 +1145,16 @@ PRBool nsMacEventHandler::HandleKeyEvent(EventRecord& aOSEvent) { case keyUp: { - nsKeyEvent keyUpEvent; - InitializeKeyEvent(keyUpEvent, aOSEvent, focusedWidget, NS_KEY_UP); + nsKeyEvent keyUpEvent(NS_KEY_UP); + InitializeKeyEvent(keyUpEvent, aOSEvent, focusedWidget); result = focusedWidget->DispatchWindowEvent(keyUpEvent); break; } case keyDown: { - nsKeyEvent keyDownEvent, keyPressEvent; - InitializeKeyEvent(keyDownEvent, aOSEvent, focusedWidget, NS_KEY_DOWN); + nsKeyEvent keyDownEvent(NS_KEY_DOWN), keyPressEvent(NS_KEY_PRESS); + InitializeKeyEvent(keyDownEvent, aOSEvent, focusedWidget); result = focusedWidget->DispatchWindowEvent(keyDownEvent); // get the focused widget again in case something happened to it on the previous event @@ -1199,7 +1166,7 @@ PRBool nsMacEventHandler::HandleKeyEvent(EventRecord& aOSEvent) if (checkFocusedWidget != focusedWidget) return result; - InitializeKeyEvent(keyPressEvent, aOSEvent, focusedWidget, NS_KEY_PRESS); + InitializeKeyEvent(keyPressEvent, aOSEvent, focusedWidget); // before we dispatch this key, check if it's the contextmenu key. // If so, send a context menu event instead. @@ -1218,8 +1185,8 @@ PRBool nsMacEventHandler::HandleKeyEvent(EventRecord& aOSEvent) case autoKey: { - nsKeyEvent keyPressEvent; - InitializeKeyEvent(keyPressEvent, aOSEvent, focusedWidget, NS_KEY_PRESS); + nsKeyEvent keyPressEvent(NS_KEY_PRESS); + InitializeKeyEvent(keyPressEvent, aOSEvent, focusedWidget); result = focusedWidget->DispatchWindowEvent(keyPressEvent); break; } @@ -1242,7 +1209,6 @@ ConvertKeyEventToContextMenuEvent(const nsKeyEvent* inKeyEvent, nsMouseEvent* ou { *(nsInputEvent*)outCMEvent = *(nsInputEvent*)inKeyEvent; - outCMEvent->eventStructType = NS_MOUSE_EVENT; outCMEvent->message = NS_CONTEXTMENU_KEY; outCMEvent->isShift = outCMEvent->isControl = outCMEvent->isAlt = outCMEvent->isMeta = PR_FALSE; @@ -1285,8 +1251,8 @@ PRBool nsMacEventHandler::HandleUKeyEvent(PRUnichar* text, long charCount, Event // simulate key down event if this isn't an autoKey event if (aOSEvent.what == keyDown) { - nsKeyEvent keyDownEvent; - InitializeKeyEvent(keyDownEvent, aOSEvent, focusedWidget, NS_KEY_DOWN, &isCharacter, PR_FALSE); + nsKeyEvent keyDownEvent(NS_KEY_DOWN); + InitializeKeyEvent(keyDownEvent, aOSEvent, focusedWidget, &isCharacter, PR_FALSE); result = focusedWidget->DispatchWindowEvent(keyDownEvent); NS_ASSERTION(NS_SUCCEEDED(result), "cannot DispatchWindowEvent keydown"); @@ -1299,8 +1265,8 @@ PRBool nsMacEventHandler::HandleUKeyEvent(PRUnichar* text, long charCount, Event } // simulate key press events - nsKeyEvent keyPressEvent; - InitializeKeyEvent(keyPressEvent, aOSEvent, focusedWidget, NS_KEY_PRESS, &isCharacter, PR_FALSE); + nsKeyEvent keyPressEvent(NS_KEY_PRESS); + InitializeKeyEvent(keyPressEvent, aOSEvent, focusedWidget, &isCharacter, PR_FALSE); if (isCharacter) { @@ -1901,7 +1867,6 @@ void nsMacEventHandler::ConvertOSEventToMouseEvent( widgetHit = mTopLevelWidget; // nsEvent - aMouseEvent.eventStructType = NS_MOUSE_EVENT; aMouseEvent.message = aMessage; aMouseEvent.point = widgetHitPoint; aMouseEvent.time = PR_IntervalNow(); @@ -2511,15 +2476,8 @@ nsresult nsMacEventHandler::HandleUnicodeGetSelectedText(nsAString& outString) if (!focusedWidget) focusedWidget = mTopLevelWidget; - nsReconversionEvent reconversionEvent; - reconversionEvent.eventStructType = NS_RECONVERSION_QUERY; - reconversionEvent.message = NS_RECONVERSION_QUERY; - reconversionEvent.point.x = 0; - reconversionEvent.point.y = 0; - reconversionEvent.nativeMsg = nsnull; + nsReconversionEvent reconversionEvent(NS_RECONVERSION_QUERY, focusedWidget); reconversionEvent.time = PR_IntervalNow(); - reconversionEvent.widget = focusedWidget; - reconversionEvent.theReply.mReconversionString = NULL; nsresult res = focusedWidget->DispatchWindowEvent(reconversionEvent); @@ -2558,20 +2516,9 @@ nsresult nsMacEventHandler::HandleStartComposition(void) // // create the nsCompositionEvent // - nsCompositionEvent compositionEvent; - - compositionEvent.eventStructType = NS_COMPOSITION_START; - compositionEvent.message = NS_COMPOSITION_START; - compositionEvent.point.x = 0; - compositionEvent.point.y = 0; + nsCompositionEvent compositionEvent(NS_COMPOSITION_START, focusedWidget); compositionEvent.time = PR_IntervalNow(); - // - // nsGUIEvent parts - // - compositionEvent.widget = focusedWidget; - compositionEvent.nativeMsg = (void*)nsnull; // no native message for this - nsresult res = focusedWidget->DispatchWindowEvent(compositionEvent); if(NS_SUCCEEDED(res)) { mIMEPos.x = compositionEvent.theReply.mCursorPosition.x; @@ -2606,19 +2553,9 @@ nsresult nsMacEventHandler::HandleEndComposition(void) // // create the nsCompositionEvent // - nsCompositionEvent compositionEvent; - - compositionEvent.eventStructType = NS_COMPOSITION_END; - compositionEvent.message = NS_COMPOSITION_END; - compositionEvent.point.x = 0; - compositionEvent.point.y = 0; + nsCompositionEvent compositionEvent(NS_COMPOSITION_END, focusedWidget); compositionEvent.time = PR_IntervalNow(); - // - // nsGUIEvent parts - // - compositionEvent.widget = focusedWidget; - compositionEvent.nativeMsg = (void*)nsnull; // no native message for this return(focusedWidget->DispatchWindowEvent(compositionEvent)); } @@ -2677,25 +2614,14 @@ nsresult nsMacEventHandler::HandleTextEvent(PRUint32 textRangeCount, nsTextRange focusedWidget = mTopLevelWidget; // - // create the nsCompositionEvent + // create the nsTextEvent // - nsTextEvent textEvent; - - textEvent.eventStructType = NS_TEXT_EVENT; - textEvent.message = NS_TEXT_EVENT; - textEvent.point.x = 0; - textEvent.point.y = 0; + nsTextEvent textEvent(NS_TEXT_TEXT, focusedWidget); textEvent.time = PR_IntervalNow(); textEvent.theText = (PRUnichar*)mIMECompositionStr->get(); textEvent.rangeCount = textRangeCount; textEvent.rangeArray = textRangeArray; - // - // nsGUIEvent parts - // - textEvent.widget = focusedWidget; - textEvent.nativeMsg = (void*)nsnull; // no native message for this - nsresult res = NS_OK; if (NS_SUCCEEDED(res = focusedWidget->DispatchWindowEvent(textEvent))) { mIMEPos.x = textEvent.theReply.mCursorPosition.x; diff --git a/mozilla/widget/src/mac/nsMacEventHandler.h b/mozilla/widget/src/mac/nsMacEventHandler.h index cccb40242d9..28dc6785e8c 100644 --- a/mozilla/widget/src/mac/nsMacEventHandler.h +++ b/mozilla/widget/src/mac/nsMacEventHandler.h @@ -185,7 +185,7 @@ public: protected: #if 1 virtual void InitializeKeyEvent(nsKeyEvent& aKeyEvent, EventRecord& aOSEvent, - nsWindow* aFocusedWidget, PRUint32 aMessage, + nsWindow* aFocusedWidget, PRBool* aIsChar=nsnull, PRBool aConvertChar=PR_TRUE); virtual PRBool IsSpecialRaptorKey(UInt32 macKeyCode); virtual PRUint32 ConvertKeyEventToUnicode(EventRecord& aOSEvent); diff --git a/mozilla/widget/src/mac/nsMacWindow.cpp b/mozilla/widget/src/mac/nsMacWindow.cpp index d07596d815f..14be2482c3f 100644 --- a/mozilla/widget/src/mac/nsMacWindow.cpp +++ b/mozilla/widget/src/mac/nsMacWindow.cpp @@ -1799,20 +1799,13 @@ nsMacWindow::Idle() NS_IMETHODIMP nsMacWindow::ComeToFront() { - nsZLevelEvent event; + nsZLevelEvent event(NS_SETZLEVEL, this); event.point.x = mBounds.x; event.point.y = mBounds.y; event.time = PR_IntervalNow(); - event.widget = this; - event.nativeMsg = nsnull; - event.eventStructType = NS_ZLEVEL_EVENT; - event.message = NS_SETZLEVEL; - event.mPlacement = nsWindowZTop; - event.mReqBelow = 0; event.mImmediate = PR_TRUE; - event.mAdjusted = PR_FALSE; DispatchWindowEvent(event); diff --git a/mozilla/widget/src/mac/nsMenuBarX.cpp b/mozilla/widget/src/mac/nsMenuBarX.cpp index 33b2e557dc2..ead4f6946c1 100644 --- a/mozilla/widget/src/mac/nsMenuBarX.cpp +++ b/mozilla/widget/src/mac/nsMenuBarX.cpp @@ -995,15 +995,10 @@ MenuHelpersX::DispatchCommandTo(nsIWeakReference* aWebShellWeakRef, MenuHelpersX::WebShellToPresContext(webShell, getter_AddRefs(presContext)); nsEventStatus status = nsEventStatus_eConsumeNoDefault; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_XUL_COMMAND; + nsMouseEvent event(NS_XUL_COMMAND); // FIXME: Should probably figure out how to init this with the actual // pressed keys, but this is a big old edge case anyway. -dwh - event.isShift = event.isControl = event.isAlt = event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; // See if we have a command element. If so, we execute on the // command instead of on our content element. diff --git a/mozilla/widget/src/mac/nsMenuX.cpp b/mozilla/widget/src/mac/nsMenuX.cpp index a87a72e353a..c92b98a2945 100644 --- a/mozilla/widget/src/mac/nsMenuX.cpp +++ b/mozilla/widget/src/mac/nsMenuX.cpp @@ -753,12 +753,7 @@ static pascal OSStatus MyMenuEventHandler(EventHandlerCallRef myHandler, EventRe if (listener) { MenuRef menuRef; ::GetEventParameter(event, kEventParamDirectObject, typeMenuRef, NULL, sizeof(menuRef), NULL, &menuRef); - nsMenuEvent menuEvent; - menuEvent.message = NS_MENU_SELECTED; - menuEvent.eventStructType = NS_MENU_EVENT; - menuEvent.point.x = 0; - menuEvent.point.y = 0; - menuEvent.widget = nsnull; + nsMenuEvent menuEvent(NS_MENU_SELECTED); menuEvent.time = PR_IntervalNow(); menuEvent.mCommand = (PRUint32) menuRef; if (kind == kEventMenuOpening) { @@ -984,15 +979,7 @@ PRBool nsMenuX::OnCreate() { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_POPUP_SHOWING; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_SHOWING); nsCOMPtr popupContent; GetMenuPopupContent(getter_AddRefs(popupContent)); @@ -1074,15 +1061,7 @@ PRBool nsMenuX::OnCreated() { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_POPUP_SHOWN; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_SHOWN); nsCOMPtr popupContent; GetMenuPopupContent(getter_AddRefs(popupContent)); @@ -1118,15 +1097,7 @@ nsMenuX::OnDestroy() return PR_TRUE; nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_POPUP_HIDING; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_HIDING); nsCOMPtr webShell = do_QueryReferent(mWebShellWeakRef); if (!webShell) { @@ -1156,15 +1127,7 @@ PRBool nsMenuX::OnDestroyed() { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_POPUP_HIDDEN; - event.isShift = PR_FALSE; - event.isControl = PR_FALSE; - event.isAlt = PR_FALSE; - event.isMeta = PR_FALSE; - event.clickCount = 0; - event.widget = nsnull; + nsMouseEvent event(NS_XUL_POPUP_HIDDEN); nsCOMPtr webShell = do_QueryReferent(mWebShellWeakRef); if (!webShell) { diff --git a/mozilla/widget/src/mac/nsWindow.cpp b/mozilla/widget/src/mac/nsWindow.cpp index 334bdc31c9c..848e462c063 100644 --- a/mozilla/widget/src/mac/nsWindow.cpp +++ b/mozilla/widget/src/mac/nsWindow.cpp @@ -1718,14 +1718,9 @@ void nsWindow::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext) return; // initialize the paint event - nsPaintEvent paintEvent; - paintEvent.eventStructType = NS_PAINT_EVENT; // nsEvent - paintEvent.message = NS_PAINT; - paintEvent.widget = this; // nsGUIEvent - paintEvent.nativeMsg = NULL; + nsPaintEvent paintEvent(NS_PAINT, this); paintEvent.renderingContext = aContext; // nsPaintEvent paintEvent.rect = &aRect; - paintEvent.region = nsnull; // draw the widget StartDraw(aContext); @@ -2118,17 +2113,10 @@ PRBool nsWindow::DispatchMouseEvent(nsMouseEvent &aEvent) PRBool nsWindow::ReportDestroyEvent() { // nsEvent - nsGUIEvent moveEvent; - moveEvent.eventStructType = NS_GUI_EVENT; + nsGUIEvent moveEvent(NS_DESTROY, this); moveEvent.message = NS_DESTROY; - moveEvent.point.x = 0; - moveEvent.point.y = 0; moveEvent.time = PR_IntervalNow(); - // nsGUIEvent - moveEvent.widget = this; - moveEvent.nativeMsg = nsnull; - // dispatch event return (DispatchWindowEvent(moveEvent)); } @@ -2140,17 +2128,11 @@ PRBool nsWindow::ReportDestroyEvent() PRBool nsWindow::ReportMoveEvent() { // nsEvent - nsGUIEvent moveEvent; - moveEvent.eventStructType = NS_GUI_EVENT; - moveEvent.message = NS_MOVE; + nsGUIEvent moveEvent(NS_MOVE, this); moveEvent.point.x = mBounds.x; moveEvent.point.y = mBounds.y; moveEvent.time = PR_IntervalNow(); - // nsGUIEvent - moveEvent.widget = this; - moveEvent.nativeMsg = nsnull; - // dispatch event return (DispatchWindowEvent(moveEvent)); } @@ -2162,17 +2144,9 @@ PRBool nsWindow::ReportMoveEvent() PRBool nsWindow::ReportSizeEvent() { // nsEvent - nsSizeEvent sizeEvent; - sizeEvent.eventStructType = NS_SIZE_EVENT; - sizeEvent.message = NS_SIZE; - sizeEvent.point.x = 0; - sizeEvent.point.y = 0; + nsSizeEvent sizeEvent(NS_SIZE, this); sizeEvent.time = PR_IntervalNow(); - // nsGUIEvent - sizeEvent.widget = this; - sizeEvent.nativeMsg = nsnull; - // nsSizeEvent sizeEvent.windowSize = &mBounds; sizeEvent.mWinWidth = mBounds.width; diff --git a/mozilla/widget/src/os2/nsFrameWindow.cpp b/mozilla/widget/src/os2/nsFrameWindow.cpp index f213db12e02..1b2e5ac247e 100644 --- a/mozilla/widget/src/os2/nsFrameWindow.cpp +++ b/mozilla/widget/src/os2/nsFrameWindow.cpp @@ -362,15 +362,14 @@ MRESULT nsFrameWindow::FrameMessage( ULONG msg, MPARAM mp1, MPARAM mp2) } if ( pSwp->fl & (SWP_MAXIMIZE | SWP_MINIMIZE | SWP_RESTORE)) { - nsSizeModeEvent event; - event.eventStructType = NS_SIZEMODE_EVENT; + nsSizeModeEvent event(NS_SIZEMODE, this); if ( pSwp->fl & SWP_MAXIMIZE) event.mSizeMode = nsSizeMode_Maximized; else if ( pSwp->fl & SWP_MINIMIZE) event.mSizeMode = nsSizeMode_Minimized; else event.mSizeMode = nsSizeMode_Normal; - InitEvent(event, NS_SIZEMODE); + InitEvent(event); DispatchWindowEvent(&event); NS_RELEASE(event.widget); } diff --git a/mozilla/widget/src/os2/nsWindow.cpp b/mozilla/widget/src/os2/nsWindow.cpp index 9ad46e6488c..5cc2197042a 100644 --- a/mozilla/widget/src/os2/nsWindow.cpp +++ b/mozilla/widget/src/os2/nsWindow.cpp @@ -152,8 +152,6 @@ static int currentWindowIdentifier = 0; // Drag and Drop flags and global data // see the D&D section toward the end of this file for additional info -#define DispatchDragDropEvent(msg) DispatchStandardEvent(msg,NS_DRAGDROP_EVENT) - // actions that might cause problems during d&d #define ACTION_PAINT 1 #define ACTION_DRAW 2 @@ -402,11 +400,9 @@ PRBool nsWindow::ConvertStatus(nsEventStatus aStatus) // Initialize an event to dispatch // //------------------------------------------------------------------------- -void nsWindow::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint) +void nsWindow::InitEvent(nsGUIEvent& event, nsPoint* aPoint) { - event.widget = this; NS_ADDREF(event.widget); - event.nativeMsg = 0; if (nsnull == aPoint) { // use the point from the event // for most events, get the message position; for drag events, @@ -442,7 +438,6 @@ void nsWindow::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint } event.time = WinQueryMsgTime( 0/*hab*/); - event.message = aEventType; /* OS2TODO mLastPoint.x = event.point.x; @@ -502,11 +497,10 @@ PRBool nsWindow::DispatchWindowEvent(nsGUIEvent*event, nsEventStatus &aStatus) { // //------------------------------------------------------------------------- -PRBool nsWindow::DispatchStandardEvent(PRUint32 aMsg, PRUint8 aEST) +PRBool nsWindow::DispatchStandardEvent(PRUint32 aMsg) { - nsGUIEvent event; - event.eventStructType = aEST; - InitEvent(event, aMsg); + nsGUIEvent event(aMsg, this); + InitEvent(event); PRBool result = DispatchWindowEvent(&event); NS_RELEASE(event.widget); @@ -2151,7 +2145,7 @@ BOOL nsWindow::CallMethod(MethodInfo *info) // PRBool nsWindow::OnKey( MPARAM mp1, MPARAM mp2) { - nsKeyEvent event, pressEvent; + nsKeyEvent pressEvent; USHORT fsFlags = SHORT1FROMMP(mp1); USHORT usVKey = SHORT2FROMMP(mp2); USHORT usChar = SHORT1FROMMP(mp2); @@ -2197,13 +2191,13 @@ PRBool nsWindow::OnKey( MPARAM mp1, MPARAM mp2) // have the unicode charcode in. nsPoint point(0,0); - InitEvent( event, (fsFlags & KC_KEYUP) ? NS_KEY_UP : NS_KEY_DOWN, &point); + nsKeyEvent event((fsFlags & KC_KEYUP) ? NS_KEY_UP : NS_KEY_DOWN, this); + InitEvent( event, &point); event.keyCode = WMChar2KeyCode( mp1, mp2); event.isShift = (fsFlags & KC_SHIFT) ? PR_TRUE : PR_FALSE; event.isControl = (fsFlags & KC_CTRL) ? PR_TRUE : PR_FALSE; event.isAlt = (fsFlags & KC_ALT) ? PR_TRUE : PR_FALSE; event.isMeta = PR_FALSE; - event.eventStructType = NS_KEY_EVENT; event.charCode = 0; // OS2 does not set the shift, ctl, or alt on keyup if( fsFlags & (KC_VIRTUALKEY|KC_KEYUP|KC_LONEKEY)) @@ -2307,11 +2301,10 @@ PRBool nsWindow::OnKey( MPARAM mp1, MPARAM mp2) void nsWindow::ConstrainZLevel(HWND *aAfter) { - nsZLevelEvent event; + nsZLevelEvent event(NS_SETZLEVEL, this); nsWindow *aboveWindow = 0; - event.eventStructType = NS_ZLEVEL_EVENT; - InitEvent(event, NS_SETZLEVEL); + InitEvent(event); if (*aAfter == HWND_BOTTOM) event.mPlacement = nsWindowZBottom; @@ -2356,10 +2349,9 @@ PRBool nsWindow::ProcessMessage( ULONG msg, MPARAM mp1, MPARAM mp2, MRESULT &rc) //#if 0 case WM_COMMAND: // fire off menu selections { - nsMenuEvent event; + nsMenuEvent event(NS_MENU_SELECTED, this); event.mCommand = SHORT1FROMMP(mp1); - event.eventStructType = NS_MENU_EVENT; - InitEvent(event, NS_MENU_SELECTED); + InitEvent(event); result = DispatchWindowEvent(&event); NS_RELEASE(event.widget); } @@ -2382,10 +2374,9 @@ PRBool nsWindow::ProcessMessage( ULONG msg, MPARAM mp1, MPARAM mp2, MRESULT &rc) #if 0 // Tooltips appear to be gone case WMU_SHOW_TOOLTIP: { - nsTooltipEvent event; - InitEvent( event, NS_SHOW_TOOLTIP); + nsTooltipEvent event(NS_SHOW_TOOLTIP, this); + InitEvent( event ); event.tipIndex = LONGFROMMP(mp1); - event.eventStructType = NS_TOOLTIP_EVENT; result = DispatchWindowEvent(&event); NS_RELEASE(event.widget); break; @@ -2456,14 +2447,11 @@ PRBool nsWindow::ProcessMessage( ULONG msg, MPARAM mp1, MPARAM mp2, MRESULT &rc) case WM_QUERYCONVERTPOS: { PRECTL pCursorRect = (PRECTL)mp1; - nsCompositionEvent event; + nsCompositionEvent event(NS_COMPOSITION_QUERY, this); nsPoint point; point.x = 0; point.y = 0; - InitEvent(event,NS_COMPOSITION_QUERY,&point); - event.widget = NS_STATIC_CAST(nsIWidget *, this); - event.eventStructType = NS_COMPOSITION_QUERY; - event.compositionMessage = NS_COMPOSITION_QUERY; + InitEvent(event,&point); DispatchWindowEvent(&event); if ((event.theReply.mCursorPosition.x) || (event.theReply.mCursorPosition.y)) @@ -2546,9 +2534,9 @@ PRBool nsWindow::ProcessMessage( ULONG msg, MPARAM mp1, MPARAM mp2, MRESULT &rc) (WinQuerySysValue(HWND_DESKTOP, SV_CYMOTIONSTART) / 2)) isCopy = TRUE; - nsKeyEvent event; + nsKeyEvent event(NS_KEY_PRESS, this); nsPoint point(0,0); - InitEvent( event, NS_KEY_PRESS, &point); + InitEvent( event, &point); event.keyCode = NS_VK_INSERT; if (isCopy) { @@ -2838,11 +2826,10 @@ void nsWindow::OnDestroy() PRBool nsWindow::OnMove(PRInt32 aX, PRInt32 aY) { // Params here are in XP-space for the desktop - nsGUIEvent event; - InitEvent( event, NS_MOVE); + nsGUIEvent event(NS_MOVE, this); + InitEvent( event); event.point.x = aX; event.point.y = aY; - event.eventStructType = NS_GUI_EVENT; PRBool result = DispatchWindowEvent( &event); NS_RELEASE(event.widget); @@ -2877,8 +2864,8 @@ PRBool nsWindow::OnPaint() // call the event callback if (mEventCallback) { - nsPaintEvent event; - InitEvent(event, NS_PAINT); + nsPaintEvent event(NS_PAINT, this); + InitEvent(event); // build XP rect from in-ex window rect nsRect rect; @@ -2888,7 +2875,6 @@ PRBool nsWindow::OnPaint() rect.height = rcl.yTop - rcl.yBottom; event.rect = ▭ event.region = nsnull; - event.eventStructType = NS_PAINT_EVENT; #ifdef NS_DEBUG debug_DumpPaintEvent(stdout, @@ -2955,11 +2941,10 @@ PRBool nsWindow::DispatchResizeEvent( PRInt32 aX, PRInt32 aY) { PRBool result; // call the event callback - nsSizeEvent event; + nsSizeEvent event(NS_SIZE, this); nsRect rect( 0, 0, aX, aY); - InitEvent( event, NS_SIZE); - event.eventStructType = NS_SIZE_EVENT; + InitEvent( event); event.windowSize = ▭ // this is the *client* rectangle event.mWinWidth = mBounds.width; event.mWinHeight = mBounds.height; @@ -2982,7 +2967,7 @@ PRBool nsWindow::DispatchMouseEvent( PRUint32 aEventType, MPARAM mp1, MPARAM mp2 return result; } - nsMouseEvent event; + nsMouseEvent event(aEventType, this); // Mouse leave & enter messages don't seem to have position built in. if( aEventType && aEventType != NS_MOUSE_ENTER && aEventType != NS_MOUSE_EXIT) @@ -2997,7 +2982,7 @@ PRBool nsWindow::DispatchMouseEvent( PRUint32 aEventType, MPARAM mp1, MPARAM mp2 } PM2NS(ptl); nsPoint pt( ptl.x, ptl.y); - InitEvent( event, aEventType, &pt); + InitEvent( event, &pt); USHORT usFlags = SHORT2FROMMP( mp2); event.isShift = (usFlags & KC_SHIFT) ? PR_TRUE : PR_FALSE; @@ -3006,14 +2991,13 @@ PRBool nsWindow::DispatchMouseEvent( PRUint32 aEventType, MPARAM mp1, MPARAM mp2 } else { - InitEvent( event, aEventType, nsnull); + InitEvent( event, nsnull); event.isShift = WinIsKeyDown( VK_SHIFT); event.isControl = WinIsKeyDown( VK_CTRL); event.isAlt = WinIsKeyDown( VK_ALT) || WinIsKeyDown( VK_ALTGRAF); } event.isMeta = PR_FALSE; - event.eventStructType = NS_MOUSE_EVENT; //Dblclicks are used to set the click count, then changed to mousedowns if (aEventType == NS_MOUSE_LEFT_DOUBLECLICK || @@ -3208,9 +3192,8 @@ PRBool nsWindow::DispatchFocus(PRUint32 aEventType, PRBool isMozWindowTakingFocu { // call the event callback if (mEventCallback) { - nsFocusEvent event; - event.eventStructType = NS_FOCUS_EVENT; - InitEvent(event, aEventType); + nsFocusEvent event(aEventType, this); + InitEvent(event); //focus and blur event should go to their base widget loc, not current mouse pos event.point.x = 0; @@ -3258,9 +3241,8 @@ PRBool nsWindow::OnScroll( ULONG msgid, MPARAM mp1, MPARAM mp2) PRBool nsWindow::OnVScroll( MPARAM mp1, MPARAM mp2) { if (nsnull != mEventCallback) { - nsMouseScrollEvent scrollEvent; - scrollEvent.eventStructType = NS_MOUSE_SCROLL_EVENT; - InitEvent(scrollEvent, NS_MOUSE_SCROLL); + nsMouseScrollEvent scrollEvent(NS_MOUSE_SCROLL, this); + InitEvent(scrollEvent); scrollEvent.isShift = WinIsKeyDown( VK_SHIFT); scrollEvent.isControl = WinIsKeyDown( VK_CTRL); scrollEvent.isAlt = WinIsKeyDown( VK_ALT) || WinIsKeyDown( VK_ALTGRAF); @@ -3294,9 +3276,8 @@ PRBool nsWindow::OnVScroll( MPARAM mp1, MPARAM mp2) PRBool nsWindow::OnHScroll( MPARAM mp1, MPARAM mp2) { if (nsnull != mEventCallback) { - nsMouseScrollEvent scrollEvent; - scrollEvent.eventStructType = NS_MOUSE_SCROLL_EVENT; - InitEvent(scrollEvent, NS_MOUSE_SCROLL); + nsMouseScrollEvent scrollEvent(NS_MOUSE_SCROLL, this); + InitEvent(scrollEvent); scrollEvent.isShift = WinIsKeyDown( VK_SHIFT); scrollEvent.isControl = WinIsKeyDown( VK_CTRL); scrollEvent.isAlt = WinIsKeyDown( VK_ALT) || WinIsKeyDown( VK_ALTGRAF); @@ -3601,10 +3582,10 @@ PRBool nsWindow::OnDragDropMsg(ULONG msg, MPARAM mp1, MPARAM mp2, MRESULT &mr) mDragStatus = gDragStatus = (dragFlags & DND_DragStatus); if (dragFlags & DND_DispatchEnterEvent) - DispatchDragDropEvent(NS_DRAGDROP_ENTER); + DispatchStandardEvent(NS_DRAGDROP_ENTER); if (dragFlags & DND_DispatchEvent) - DispatchDragDropEvent(eventType); + DispatchStandardEvent(eventType); if (dragFlags & DND_GetDragoverResult) dragSession->GetDragoverResult(mr); diff --git a/mozilla/widget/src/os2/nsWindow.h b/mozilla/widget/src/os2/nsWindow.h index b0795297b57..1379e56fad2 100644 --- a/mozilla/widget/src/os2/nsWindow.h +++ b/mozilla/widget/src/os2/nsWindow.h @@ -288,10 +288,10 @@ protected: virtual void SubclassWindow(BOOL bState); PRBool ConvertStatus( nsEventStatus aStatus); - void InitEvent( nsGUIEvent &event, PRUint32 aEventType, nsPoint *pt = 0); + void InitEvent( nsGUIEvent &event, nsPoint *pt = 0); virtual PRBool DispatchWindowEvent(nsGUIEvent* event); virtual PRBool DispatchWindowEvent(nsGUIEvent*event, nsEventStatus &aStatus); - PRBool DispatchStandardEvent( PRUint32 aMsg, PRUint8 aStructType = NS_GUI_EVENT); + PRBool DispatchStandardEvent( PRUint32 aMsg); virtual PRBool DispatchMouseEvent( PRUint32 aEventType, MPARAM mp1, MPARAM mp2); virtual PRBool DispatchResizeEvent( PRInt32 aClientX, PRInt32 aClientY); void GetNonClientBounds(nsRect &aRect); diff --git a/mozilla/widget/src/photon/nsWidget.cpp b/mozilla/widget/src/photon/nsWidget.cpp index 07321ca3463..4ec53cd1130 100644 --- a/mozilla/widget/src/photon/nsWidget.cpp +++ b/mozilla/widget/src/photon/nsWidget.cpp @@ -359,7 +359,6 @@ PRBool nsWidget::OnResize( nsRect &aRect ) { nsSizeEvent event; InitEvent(event, NS_SIZE); - event.eventStructType = NS_SIZE_EVENT; nsRect *foo = new nsRect(0, 0, aRect.width, aRect.height); event.windowSize = foo; @@ -386,7 +385,6 @@ PRBool nsWidget::OnMove( PRInt32 aX, PRInt32 aY ) { InitEvent(event, NS_MOVE); event.point.x = aX; event.point.y = aY; - event.eventStructType = NS_GUI_EVENT; return DispatchWindowEvent(&event); } @@ -676,7 +674,6 @@ void nsWidget::InitMouseEvent(PhPointerEvent_t *aPhButtonEvent, { anEvent.message = aEventType; anEvent.widget = aWidget; - anEvent.eventStructType = NS_MOUSE_EVENT; if (aPhButtonEvent != nsnull) { anEvent.time = PR_IntervalNow(); @@ -748,7 +745,6 @@ PRBool nsWidget::DispatchMouseEvent( PhPoint_t &aPos, PRUint32 aEvent ) { nsMouseEvent event; InitEvent( event, aEvent ); - event.eventStructType = NS_MOUSE_EVENT; event.point.x = aPos.x; event.point.y = aPos.y; event.isShift = PR_FALSE; @@ -892,7 +888,6 @@ inline void nsWidget::InitKeyEvent(PhKeyEvent_t *aPhKeyEvent, anEvent.message = aEventType; anEvent.widget = aWidget; - anEvent.eventStructType = NS_KEY_EVENT; anEvent.nativeMsg = (void *)aPhKeyEvent; anEvent.time = PR_IntervalNow(); anEvent.point.x = 0; @@ -1183,7 +1178,6 @@ int nsWidget::GotFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t sJustGotActivated = PR_TRUE; nsMouseEvent event; - event.eventStructType = NS_GUI_EVENT; pWidget->InitEvent(event, NS_MOUSE_ACTIVATE); event.acceptActivation = PR_TRUE; diff --git a/mozilla/widget/src/photon/nsWidget.h b/mozilla/widget/src/photon/nsWidget.h index 01a39811328..e2772b295e8 100644 --- a/mozilla/widget/src/photon/nsWidget.h +++ b/mozilla/widget/src/photon/nsWidget.h @@ -252,7 +252,6 @@ public: inline PRBool DispatchStandardEvent(PRUint32 aMsg) { nsGUIEvent event; - event.eventStructType = NS_GUI_EVENT; InitEvent(event, aMsg); return DispatchWindowEvent(&event); } diff --git a/mozilla/widget/src/photon/nsWindow.cpp b/mozilla/widget/src/photon/nsWindow.cpp index 5df1a86d835..cd8580bffd4 100644 --- a/mozilla/widget/src/photon/nsWindow.cpp +++ b/mozilla/widget/src/photon/nsWindow.cpp @@ -596,7 +596,6 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) nsSizeEvent sevent; sevent.message = NS_SIZE; sevent.widget = this; - sevent.eventStructType = NS_SIZE_EVENT; sevent.windowSize = new nsRect (0, 0, aWidth, aHeight); @@ -633,7 +632,6 @@ int nsWindow::WindowWMHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t event.message = NS_XUL_CLOSE; event.widget = win; - event.eventStructType = NS_GUI_EVENT; event.time = 0; event.point.x = 0; @@ -687,7 +685,6 @@ void nsWindow::RawDrawFunc( PtWidget_t * pWidget, PhTile_t * damage ) new_damage = intersect; pWin->InitEvent(pev, NS_PAINT); - pev.eventStructType = NS_PAINT_EVENT; pev.region = nsnull; pev.renderingContext = nsnull; pev.renderingContext = pWin->GetRenderingContext(); @@ -702,7 +699,6 @@ void nsWindow::RawDrawFunc( PtWidget_t * pWidget, PhTile_t * damage ) /* Re-Setup Paint Event */ pWin->InitEvent(pev, NS_PAINT); - pev.eventStructType = NS_PAINT_EVENT; pev.point.x = nsDmg.x; pev.point.y = nsDmg.y; pev.rect = &nsDmg; diff --git a/mozilla/widget/src/windows/nsNativeDragTarget.cpp b/mozilla/widget/src/windows/nsNativeDragTarget.cpp index f79f99ebbc9..a9c91aa2c04 100644 --- a/mozilla/widget/src/windows/nsNativeDragTarget.cpp +++ b/mozilla/widget/src/windows/nsNativeDragTarget.cpp @@ -181,11 +181,10 @@ void nsNativeDragTarget::DispatchDragDropEvent(PRUint32 aEventType, POINTL aPT) { nsEventStatus status; - nsMouseEvent event; - event.eventStructType = NS_DRAGDROP_EVENT; + nsMouseEvent event(aEventType, mWindow); nsWindow * win = NS_STATIC_CAST(nsWindow *, mWindow); - win->InitEvent(event, aEventType); + win->InitEvent(event); POINT cpos; cpos.x = aPT.x; diff --git a/mozilla/widget/src/windows/nsWindow.cpp b/mozilla/widget/src/windows/nsWindow.cpp index aab73a9d396..2cada42e3b1 100644 --- a/mozilla/widget/src/windows/nsWindow.cpp +++ b/mozilla/widget/src/windows/nsWindow.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: NPL 1.1/GPL 2.0/LGPL 2.1 * @@ -960,9 +960,8 @@ PRBool nsWindow::ConvertStatus(nsEventStatus aStatus) // Initialize an event to dispatch // //------------------------------------------------------------------------- -void nsWindow::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint) +void nsWindow::InitEvent(nsGUIEvent& event, nsPoint* aPoint) { - event.widget = this; NS_ADDREF(event.widget); if (nsnull == aPoint) { // use the point from the event @@ -988,7 +987,6 @@ void nsWindow::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint } event.time = ::GetMessageTime(); - event.message = aEventType; mLastPoint.x = event.point.x; mLastPoint.y = event.point.y; @@ -1084,9 +1082,8 @@ PRBool nsWindow::DispatchWindowEvent(nsGUIEvent*event, nsEventStatus &aStatus) { PRBool nsWindow::DispatchStandardEvent(PRUint32 aMsg) { - nsGUIEvent event; - event.eventStructType = NS_GUI_EVENT; - InitEvent(event, aMsg); + nsGUIEvent event(aMsg, this); + InitEvent(event); PRBool result = DispatchWindowEvent(&event); NS_RELEASE(event.widget); @@ -1100,9 +1097,9 @@ PRBool nsWindow::DispatchStandardEvent(PRUint32 aMsg) //------------------------------------------------------------------------- PRBool nsWindow::DispatchAppCommandEvent(PRUint32 aEventCommand) { - nsAppCommandEvent event; + nsAppCommandEvent event(NS_APPCOMMAND_START, this); - InitEvent(event, NS_APPCOMMAND_START); + InitEvent(event); event.appCommand = NS_APPCOMMAND_START + aEventCommand; DispatchWindowEvent(&event); @@ -2872,13 +2869,10 @@ UINT nsWindow::MapFromNativeToDOM(UINT aNativeKeyCode) //------------------------------------------------------------------------- PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, UINT aVirtualCharCode, LPARAM aKeyData) { - nsKeyEvent event; - nsPoint point; + nsKeyEvent event(aEventType, this); + nsPoint point(0, 0); - point.x = 0; - point.y = 0; - - InitEvent(event, aEventType, &point); // this add ref's event.widget + InitEvent(event, &point); // this add ref's event.widget event.charCode = aCharCode; event.keyCode = aVirtualCharCode; @@ -2907,7 +2901,6 @@ PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, UINT aVir event.isControl = mIsControlDown; event.isMeta = PR_FALSE; event.isAlt = mIsAltDown; - event.eventStructType = NS_KEY_EVENT; nsPluginEvent pluginEvent; @@ -3120,11 +3113,10 @@ BOOL nsWindow::OnChar( UINT mbcsCharCode, UINT virtualKeyCode, bool isMultiByte void nsWindow::ConstrainZLevel(HWND *aAfter) { - nsZLevelEvent event; + nsZLevelEvent event(NS_SETZLEVEL, this); nsWindow *aboveWindow = 0; - event.eventStructType = NS_ZLEVEL_EVENT; - InitEvent(event, NS_SETZLEVEL); + InitEvent(event); if (*aAfter == HWND_BOTTOM) event.mPlacement = nsWindowZBottom; @@ -3663,17 +3655,15 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT case WM_COMMAND: { WORD wNotifyCode = HIWORD(wParam); // notification code if ((CBN_SELENDOK == wNotifyCode) || (CBN_SELENDCANCEL == wNotifyCode)) { // Combo box change - nsGUIEvent event; - event.eventStructType = NS_GUI_EVENT; + nsGUIEvent event(NS_CONTROL_CHANGE, this); nsPoint point(0,0); - InitEvent(event, NS_CONTROL_CHANGE, &point); // this add ref's event.widget + InitEvent(event, &point); // this add ref's event.widget result = DispatchWindowEvent(&event); NS_RELEASE(event.widget); } else if (wNotifyCode == 0) { // Menu selection - nsMenuEvent event; + nsMenuEvent event(NS_MENU_SELECTED, this); event.mCommand = LOWORD(wParam); - event.eventStructType = NS_MENU_EVENT; - InitEvent(event, NS_MENU_SELECTED); + InitEvent(event); result = DispatchWindowEvent(&event); NS_RELEASE(event.widget); } @@ -4103,9 +4093,8 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT gJustGotDeactivate = PR_TRUE; } else { gJustGotActivate = PR_TRUE; - nsMouseEvent event; - event.eventStructType = NS_GUI_EVENT; - InitEvent(event, NS_MOUSE_ACTIVATE); + nsMouseEvent event(NS_MOUSE_ACTIVATE, this); + InitEvent(event); event.acceptActivation = PR_TRUE; @@ -4246,15 +4235,14 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT pl.length = sizeof(pl); ::GetWindowPlacement(mWnd, &pl); - nsSizeModeEvent event; - event.eventStructType = NS_SIZEMODE_EVENT; + nsSizeModeEvent event(NS_SIZEMODE, this); if (pl.showCmd == SW_SHOWMAXIMIZED) event.mSizeMode = nsSizeMode_Maximized; else if (pl.showCmd == SW_SHOWMINIMIZED) event.mSizeMode = nsSizeMode_Minimized; else event.mSizeMode = nsSizeMode_Normal; - InitEvent(event, NS_SIZEMODE); + InitEvent(event); result = DispatchWindowEvent(&event); @@ -4371,8 +4359,8 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT #endif nsAutoString fileStr(szFileName); nsEventStatus status; - nsDragDropEvent event; - InitEvent(event, NS_DRAGDROP_EVENT); + nsDragDropEvent event(NS_DRAGDROP_EVENT, this); + InitEvent(event); event.mType = nsDragDropEventStatus_eDrop; event.mIsFileURL = PR_FALSE; event.mURL = (PRUnichar *)fileStr.get(); @@ -4567,7 +4555,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT #endif } - nsMouseScrollEvent scrollEvent; + nsMouseScrollEvent scrollEvent(NS_MOUSE_SCROLL, this); scrollEvent.scrollFlags = nsMouseScrollEvent::kIsVertical; if (ulScrollLines == WHEEL_PAGESCROLL) { scrollEvent.scrollFlags |= nsMouseScrollEvent::kIsFullPage; @@ -4582,12 +4570,11 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT scrollEvent.delta = -((int) wParam / iDeltaPerLine); } - scrollEvent.eventStructType = NS_MOUSE_SCROLL_EVENT; scrollEvent.isShift = IS_VK_DOWN(NS_VK_SHIFT); scrollEvent.isControl = IS_VK_DOWN(NS_VK_CONTROL); scrollEvent.isMeta = PR_FALSE; scrollEvent.isAlt = IS_VK_DOWN(NS_VK_ALT); - InitEvent(scrollEvent, NS_MOUSE_SCROLL); + InitEvent(scrollEvent); if (nsnull != mEventCallback) { result = DispatchWindowEvent(&scrollEvent); } @@ -4908,11 +4895,10 @@ PRBool nsWindow::OnMove(PRInt32 aX, PRInt32 aY) mBounds.x = aX; mBounds.y = aY; - nsGUIEvent event; - InitEvent(event, NS_MOVE); + nsGUIEvent event(NS_MOVE, this); + InitEvent(event); event.point.x = aX; event.point.y = aY; - event.eventStructType = NS_GUI_EVENT; PRBool result = DispatchWindowEvent(&event); NS_RELEASE(event.widget); @@ -4958,15 +4944,14 @@ PRBool nsWindow::OnPaint(HDC aDC) if (mEventCallback) { - nsPaintEvent event; + nsPaintEvent event(NS_PAINT, this); - InitEvent(event, NS_PAINT); + InitEvent(event); nsRect rect(paintRect.left, paintRect.top, paintRect.right - paintRect.left, paintRect.bottom - paintRect.top); - event.eventStructType = NS_PAINT_EVENT; event.region = nsnull; event.rect = ▭ // Should probably pass in a real region here, using GetRandomRgn @@ -5047,10 +5032,9 @@ PRBool nsWindow::OnResize(nsRect &aWindowRect) { // call the event callback if (mEventCallback) { - nsSizeEvent event; - InitEvent(event, NS_SIZE); + nsSizeEvent event(NS_SIZE, this); + InitEvent(event); event.windowSize = &aWindowRect; - event.eventStructType = NS_SIZE_EVENT; RECT r; if (::GetWindowRect(mWnd, &r)) { event.mWinWidth = PRInt32(r.right - r.left); @@ -5080,19 +5064,18 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam, nsPoint* return result; } - nsMouseEvent event; + nsMouseEvent event(aEventType, this); if (aEventType == NS_CONTEXTMENU_KEY) { nsPoint zero(0, 0); - InitEvent(event, aEventType, &zero); + InitEvent(event, &zero); } else { - InitEvent(event, aEventType, aPoint); + InitEvent(event, aPoint); } event.isShift = IS_VK_DOWN(NS_VK_SHIFT); event.isControl = IS_VK_DOWN(NS_VK_CONTROL); event.isMeta = PR_FALSE; event.isAlt = IS_VK_DOWN(NS_VK_ALT); - event.eventStructType = NS_MOUSE_EVENT; //Dblclicks are used to set the click count, then changed to mousedowns LONG curMsgTime = ::GetMessageTime(); @@ -5341,14 +5324,13 @@ PRBool nsWindow::DispatchAccessibleEvent(PRUint32 aEventType, nsIAccessible** aA *aAcc = nsnull; - nsAccessibleEvent event; - InitEvent(event, aEventType, aPoint); + nsAccessibleEvent event(aEventType, this); + InitEvent(event, aPoint); event.isShift = IS_VK_DOWN(NS_VK_SHIFT); event.isControl = IS_VK_DOWN(NS_VK_CONTROL); event.isMeta = PR_FALSE; event.isAlt = IS_VK_DOWN(NS_VK_ALT); - event.eventStructType = NS_ACCESSIBLE_EVENT; event.accessible = nsnull; result = DispatchWindowEvent(&event); @@ -5372,9 +5354,8 @@ PRBool nsWindow::DispatchFocus(PRUint32 aEventType, PRBool isMozWindowTakingFocu { // call the event callback if (mEventCallback) { - nsFocusEvent event; - event.eventStructType = NS_FOCUS_EVENT; - InitEvent(event, aEventType); + nsFocusEvent event(aEventType, this); + InitEvent(event); //focus and blur event should go to their base widget loc, not current mouse pos event.point.x = 0; @@ -5627,14 +5608,12 @@ nsWindow::HandleTextEvent(HIMC hIMEContext,PRBool aCheckAttr) if((nsnull == mIMECompString) || (nsnull == mIMECompUnicode)) return; - nsTextEvent event; - nsPoint point; + nsTextEvent event(NS_TEXT_TEXT, this); + nsPoint point(0, 0); size_t unicharSize; CANDIDATEFORM candForm; - point.x = 0; - point.y = 0; - InitEvent(event, NS_TEXT_EVENT, &point); + InitEvent(event, &point); // // convert the composition string text into unicode before it is sent to xp-land @@ -5673,7 +5652,6 @@ nsWindow::HandleTextEvent(HIMC hIMEContext,PRBool aCheckAttr) event.isControl = mIsControlDown; event.isMeta = PR_FALSE; event.isAlt = mIsAltDown; - event.eventStructType = NS_TEXT_EVENT; (void)DispatchWindowEvent(&event); NS_RELEASE(event.widget); @@ -5741,16 +5719,11 @@ BOOL nsWindow::HandleStartComposition(HIMC hIMEContext) { NS_ASSERTION( !mIMEIsComposing, "conflict state"); - nsCompositionEvent event; - nsPoint point; + nsCompositionEvent event(NS_COMPOSITION_START, this); + nsPoint point(0, 0); CANDIDATEFORM candForm; - point.x = 0; - point.y = 0; - - InitEvent(event,NS_COMPOSITION_START,&point); - event.eventStructType = NS_COMPOSITION_START; - event.compositionMessage = NS_COMPOSITION_START; + InitEvent(event,&point); (void)DispatchWindowEvent(&event); // @@ -5808,11 +5781,8 @@ void nsWindow::HandleEndComposition(void) { NS_ASSERTION(mIMEIsComposing, "conflict state"); - nsCompositionEvent event; - nsPoint point; - - point.x = 0; - point.y = 0; + nsCompositionEvent event(NS_COMPOSITION_END, this); + nsPoint point(0, 0); if (gPinYinIMECaretCreated) { @@ -5820,9 +5790,7 @@ nsWindow::HandleEndComposition(void) gPinYinIMECaretCreated = PR_FALSE; } - InitEvent(event,NS_COMPOSITION_END,&point); - event.eventStructType = NS_COMPOSITION_END; - event.compositionMessage = NS_COMPOSITION_END; + InitEvent(event,&point); (void)DispatchWindowEvent(&event); NS_RELEASE(event.widget); PR_FREEIF(mIMECompCharPos); @@ -6420,12 +6388,10 @@ PRBool nsWindow::OnIMEReconvert(LPARAM aData, LRESULT *oResult, PRBool aUseUnico } // Get reconversion string - nsReconversionEvent event; - nsPoint point; + nsReconversionEvent event(NS_RECONVERSION_QUERY, this); + nsPoint point(0, 0); - point.x = 0; - point.y = 0; - InitEvent(event, NS_RECONVERSION_QUERY, &point); + InitEvent(event, &point); event.theReply.mReconversionString = NULL; DispatchWindowEvent(&event); diff --git a/mozilla/widget/src/windows/nsWindow.h b/mozilla/widget/src/windows/nsWindow.h index 3f7bd347d7e..336e4d341f6 100644 --- a/mozilla/widget/src/windows/nsWindow.h +++ b/mozilla/widget/src/windows/nsWindow.h @@ -401,7 +401,7 @@ public: PRInt32 GetNewCmdMenuId() { mMenuCmdId++; return mMenuCmdId;} - void InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint = nsnull); + void InitEvent(nsGUIEvent& event, nsPoint* aPoint = nsnull); void SuppressBlurEvents(PRBool aSuppress); PRBool BlurEventsSuppressed(); diff --git a/mozilla/widget/src/xlib/nsAppShell.cpp b/mozilla/widget/src/xlib/nsAppShell.cpp index 083080d696e..f9d415fc76d 100644 --- a/mozilla/widget/src/xlib/nsAppShell.cpp +++ b/mozilla/widget/src/xlib/nsAppShell.cpp @@ -601,15 +601,13 @@ nsAppShell::DispatchXEvent(XEvent *event) void nsAppShell::HandleMotionNotifyEvent(XEvent *event, nsWidget *aWidget) { - nsMouseEvent mevent; - XEvent aEvent; - if (mDragging) { HandleDragMotionEvent(event, aWidget); } - mevent.widget = aWidget; - mevent.time = 0; + nsMouseEvent mevent(NS_MOUSE_MOVE, aWidget); + XEvent aEvent; + mevent.point.x = event->xmotion.x; mevent.point.y = event->xmotion.y; @@ -628,8 +626,6 @@ nsAppShell::HandleMotionNotifyEvent(XEvent *event, nsWidget *aWidget) mevent.point.x = aEvent.xmotion.x; mevent.point.y = aEvent.xmotion.y; } - mevent.message = NS_MOUSE_MOVE; - mevent.eventStructType = NS_MOUSE_EVENT; NS_ADDREF(aWidget); aWidget->DispatchMouseEvent(mevent); NS_RELEASE(aWidget); @@ -638,14 +634,9 @@ nsAppShell::HandleMotionNotifyEvent(XEvent *event, nsWidget *aWidget) void nsAppShell::HandleButtonEvent(XEvent *event, nsWidget *aWidget) { - nsMouseEvent mevent; - mevent.isShift = mShiftDown; - mevent.isControl = mCtrlDown; - mevent.isAlt = mAltDown; - mevent.isMeta = mMetaDown; PRUint32 eventType = 0; PRBool currentlyDragging = mDragging; - nsMouseScrollEvent scrollEvent; + nsMouseScrollEvent scrollEvent(NS_MOUSE_SCROLL, aWidget); PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("Button event for window 0x%lx button %d type %s\n", event->xany.window, @@ -670,9 +661,6 @@ nsAppShell::HandleButtonEvent(XEvent *event, nsWidget *aWidget) case 5: scrollEvent.delta = (event->xbutton.button == 4) ? -3 : 3; scrollEvent.scrollFlags = nsMouseScrollEvent::kIsVertical; - scrollEvent.message = NS_MOUSE_SCROLL; - scrollEvent.widget = aWidget; - scrollEvent.eventStructType = NS_MOUSE_SCROLL_EVENT; scrollEvent.point.x = event->xbutton.x; scrollEvent.point.y = event->xbutton.y; @@ -707,7 +695,11 @@ nsAppShell::HandleButtonEvent(XEvent *event, nsWidget *aWidget) break; } - mevent.widget = aWidget; + nsMouseEvent mevent(eventType, aWidget); + mevent.isShift = mShiftDown; + mevent.isControl = mCtrlDown; + mevent.isAlt = mAltDown; + mevent.isMeta = mMetaDown; mevent.point.x = event->xbutton.x; mevent.point.y = event->xbutton.y; mevent.time = PR_Now(); @@ -736,8 +728,6 @@ nsAppShell::HandleButtonEvent(XEvent *event, nsWidget *aWidget) if (currentlyDragging && !mDragging) HandleDragDropEvent(event, aWidget); - mevent.message = eventType; - mevent.eventStructType = NS_MOUSE_EVENT; mevent.clickCount = mClicks; NS_IF_ADDREF(aWidget); aWidget->DispatchMouseEvent(mevent); @@ -798,18 +788,14 @@ nsAppShell::HandleConfigureNotifyEvent(XEvent *event, nsWidget *aWidget) } } - nsSizeEvent sevent; - sevent.message = NS_SIZE; - sevent.widget = aWidget; - sevent.eventStructType = NS_SIZE_EVENT; + nsSizeEvent sevent(NS_SIZE, aWidget); sevent.windowSize = new nsRect (event->xconfigure.x, event->xconfigure.y, event->xconfigure.width, event->xconfigure.height); sevent.point.x = event->xconfigure.x; sevent.point.y = event->xconfigure.y; sevent.mWinWidth = event->xconfigure.width; sevent.mWinHeight = event->xconfigure.height; - // XXX fix this - sevent.time = 0; + // XXX fix sevent.time NS_ADDREF(aWidget); aWidget->OnResize(sevent); NS_RELEASE(aWidget); @@ -902,7 +888,7 @@ nsAppShell::HandleKeyPressEvent(XEvent *event, nsWidget *aWidget) return; } - nsKeyEvent keyEvent; + nsKeyEvent keyEvent(NS_KEY_DOWN, focusWidget); XComposeStatus compose; @@ -910,18 +896,12 @@ nsAppShell::HandleKeyPressEvent(XEvent *event, nsWidget *aWidget) string_buf[len] = '\0'; keyEvent.keyCode = nsKeyCode::ConvertKeySymToVirtualKey(keysym); - keyEvent.charCode = 0; keyEvent.time = event->xkey.time; keyEvent.isShift = (event->xkey.state & ShiftMask) ? PR_TRUE : PR_FALSE; keyEvent.isControl = (event->xkey.state & ControlMask) ? 1 : 0; keyEvent.isAlt = (event->xkey.state & Mod1Mask) ? 1 : 0; // I think 'meta' is the same as 'alt' in X11. Is this OK for other systems? keyEvent.isMeta = (event->xkey.state & Mod1Mask) ? 1 : 0; - keyEvent.point.x = 0; - keyEvent.point.y = 0; - keyEvent.message = NS_KEY_DOWN; - keyEvent.widget = focusWidget; - keyEvent.eventStructType = NS_KEY_EVENT; // printf("keysym = %x, keycode = %x, vk = %x\n", // keysym, @@ -930,20 +910,16 @@ nsAppShell::HandleKeyPressEvent(XEvent *event, nsWidget *aWidget) focusWidget->DispatchKeyEvent(keyEvent); - keyEvent.keyCode = nsKeyCode::ConvertKeySymToVirtualKey(keysym); - keyEvent.charCode = nsConvertCharCodeToUnicode(&event->xkey); - keyEvent.time = event->xkey.time; - keyEvent.isShift = (event->xkey.state & ShiftMask) ? PR_TRUE : PR_FALSE; - keyEvent.isControl = (event->xkey.state & ControlMask) ? 1 : 0; - keyEvent.isAlt = (event->xkey.state & Mod1Mask) ? 1 : 0; - keyEvent.isMeta = (event->xkey.state & Mod1Mask) ? 1 : 0; - keyEvent.point.x = 0; - keyEvent.point.y = 0; - keyEvent.message = NS_KEY_PRESS; - keyEvent.widget = focusWidget; - keyEvent.eventStructType = NS_KEY_EVENT; + nsKeyEvent pressEvent(NS_KEY_PRESS, focusWidget); + pressEvent.keyCode = nsKeyCode::ConvertKeySymToVirtualKey(keysym); + pressEvent.charCode = nsConvertCharCodeToUnicode(&event->xkey); + pressEvent.time = event->xkey.time; + pressEvent.isShift = (event->xkey.state & ShiftMask) ? PR_TRUE : PR_FALSE; + pressEvent.isControl = (event->xkey.state & ControlMask) ? 1 : 0; + pressEvent.isAlt = (event->xkey.state & Mod1Mask) ? 1 : 0; + pressEvent.isMeta = (event->xkey.state & Mod1Mask) ? 1 : 0; - focusWidget->DispatchKeyEvent(keyEvent); + focusWidget->DispatchKeyEvent(pressEvent); } @@ -983,10 +959,9 @@ nsAppShell::HandleKeyReleaseEvent(XEvent *event, nsWidget *aWidget) return; } - nsKeyEvent keyEvent; + nsKeyEvent keyEvent(NS_KEY_UP, aWidget); keyEvent.keyCode = nsKeyCode::ConvertKeySymToVirtualKey(keysym); - keyEvent.charCode = 0; keyEvent.time = event->xkey.time; keyEvent.isShift = event->xkey.state & ShiftMask; keyEvent.isControl = (event->xkey.state & ControlMask) ? 1 : 0; @@ -994,9 +969,6 @@ nsAppShell::HandleKeyReleaseEvent(XEvent *event, nsWidget *aWidget) keyEvent.isMeta = (event->xkey.state & Mod1Mask) ? 1 : 0; keyEvent.point.x = event->xkey.x; keyEvent.point.y = event->xkey.y; - keyEvent.message = NS_KEY_UP; - keyEvent.widget = aWidget; - keyEvent.eventStructType = NS_KEY_EVENT; NS_ADDREF(aWidget); @@ -1010,16 +982,7 @@ nsAppShell::HandleFocusInEvent(XEvent *event, nsWidget *aWidget) { PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("FocusIn event for window 0x%lx\n", event->xfocus.window)); - nsGUIEvent focusEvent; - - focusEvent.message = NS_GOTFOCUS; - focusEvent.widget = aWidget; - - focusEvent.eventStructType = NS_GUI_EVENT; - - focusEvent.time = 0; - focusEvent.point.x = 0; - focusEvent.point.y = 0; + nsFocusEvent focusEvent(NS_GOTFOCUS, aWidget); NS_ADDREF(aWidget); aWidget->DispatchWindowEvent(focusEvent); @@ -1031,17 +994,8 @@ nsAppShell::HandleFocusOutEvent(XEvent *event, nsWidget *aWidget) { PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("FocusOut event for window 0x%lx\n", event->xfocus.window)); - nsGUIEvent focusEvent; - - focusEvent.message = NS_LOSTFOCUS; - focusEvent.widget = aWidget; - - focusEvent.eventStructType = NS_GUI_EVENT; - - focusEvent.time = 0; - focusEvent.point.x = 0; - focusEvent.point.y = 0; - + nsFocusEvent focusEvent(NS_LOSTFOCUS, aWidget); + NS_ADDREF(aWidget); aWidget->DispatchWindowEvent(focusEvent); NS_RELEASE(aWidget); @@ -1069,7 +1023,6 @@ nsAppShell::HandleEnterEvent(XEvent *event, nsWidget *aWidget) { PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("Enter event for window 0x%lx\n", event->xcrossing.window)); - nsMouseEvent enterEvent; if(is_wm_ungrab_enter(&event->xcrossing)) return; @@ -1078,15 +1031,12 @@ nsAppShell::HandleEnterEvent(XEvent *event, nsWidget *aWidget) HandleDragEnterEvent(event, aWidget); } - enterEvent.widget = aWidget; - + nsMouseEvent enterEvent(NS_MOUSE_ENTER, aWidget); + enterEvent.time = event->xcrossing.time; enterEvent.point.x = nscoord(event->xcrossing.x); enterEvent.point.y = nscoord(event->xcrossing.y); - enterEvent.message = NS_MOUSE_ENTER; - enterEvent.eventStructType = NS_MOUSE_EVENT; - // make sure this is in focus. This will do until I rewrite all the // focus routines. KenF aWidget->SetFocus(); @@ -1102,8 +1052,6 @@ nsAppShell::HandleLeaveEvent(XEvent *event, nsWidget *aWidget) PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("Leave event for window 0x%lx\n", event->xcrossing.window)); - nsMouseEvent leaveEvent; - if(is_wm_grab_leave(&event->xcrossing)) return; @@ -1111,15 +1059,12 @@ nsAppShell::HandleLeaveEvent(XEvent *event, nsWidget *aWidget) HandleDragLeaveEvent(event, aWidget); } - leaveEvent.widget = aWidget; - + nsMouseEvent leaveEvent(NS_MOUSE_EXIT, aWidget); + leaveEvent.time = event->xcrossing.time; leaveEvent.point.x = nscoord(event->xcrossing.x); leaveEvent.point.y = nscoord(event->xcrossing.y); - leaveEvent.message = NS_MOUSE_EXIT; - leaveEvent.eventStructType = NS_MOUSE_EVENT; - NS_ADDREF(aWidget); aWidget->DispatchWindowEvent(leaveEvent); NS_RELEASE(aWidget); @@ -1178,16 +1123,14 @@ void nsAppShell::HandleClientMessageEvent(XEvent *event, nsWidget *aWidget) void nsAppShell::HandleSelectionRequestEvent(XEvent *event, nsWidget *aWidget) { - nsGUIEvent ev; + nsGUIEvent ev(0, aWidget); - ev.widget = (nsIWidget *)aWidget; ev.nativeMsg = (void *)event; aWidget->DispatchWindowEvent(ev); } void nsAppShell::HandleDragMotionEvent(XEvent *event, nsWidget *aWidget) { - nsMouseEvent mevent; PRBool currentlyDragging = PR_FALSE; nsresult rv; @@ -1202,13 +1145,11 @@ void nsAppShell::HandleDragMotionEvent(XEvent *event, nsWidget *aWidget) { if (currentlyDragging) { dragServiceXlib->UpdatePosition(event->xmotion.x, event->xmotion.y); - mevent.widget = aWidget; + + nsMouseEvent mevent(NS_DRAGDROP_OVER, aWidget); mevent.point.x = event->xmotion.x; mevent.point.y = event->xmotion.y; - mevent.message = NS_DRAGDROP_OVER; - mevent.eventStructType = NS_DRAGDROP_EVENT; - NS_ADDREF(aWidget); aWidget->DispatchMouseEvent(mevent); NS_RELEASE(aWidget); @@ -1216,7 +1157,6 @@ void nsAppShell::HandleDragMotionEvent(XEvent *event, nsWidget *aWidget) { } void nsAppShell::HandleDragEnterEvent(XEvent *event, nsWidget *aWidget) { - nsMouseEvent enterEvent; PRBool currentlyDragging = PR_FALSE; nsresult rv; @@ -1230,14 +1170,11 @@ void nsAppShell::HandleDragEnterEvent(XEvent *event, nsWidget *aWidget) { } if (currentlyDragging) { - enterEvent.widget = aWidget; + nsMouseEvent enterEvent(NS_DRAGDROP_ENTER, aWidget); enterEvent.point.x = event->xcrossing.x; enterEvent.point.y = event->xcrossing.y; - enterEvent.message = NS_DRAGDROP_ENTER; - enterEvent.eventStructType = NS_DRAGDROP_EVENT; - NS_ADDREF(aWidget); aWidget->DispatchWindowEvent(enterEvent); NS_RELEASE(aWidget); @@ -1245,7 +1182,6 @@ void nsAppShell::HandleDragEnterEvent(XEvent *event, nsWidget *aWidget) { } void nsAppShell::HandleDragLeaveEvent(XEvent *event, nsWidget *aWidget) { - nsMouseEvent leaveEvent; PRBool currentlyDragging = PR_FALSE; nsresult rv; @@ -1261,14 +1197,11 @@ void nsAppShell::HandleDragLeaveEvent(XEvent *event, nsWidget *aWidget) { } if (currentlyDragging) { - leaveEvent.widget = aWidget; + nsMouseEvent leaveEvent(NS_DRAGDROP_EXIT, aWidget); leaveEvent.point.x = event->xcrossing.x; leaveEvent.point.y = event->xcrossing.y; - leaveEvent.message = NS_DRAGDROP_EXIT; - leaveEvent.eventStructType = NS_DRAGDROP_EVENT; - NS_ADDREF(aWidget); aWidget->DispatchWindowEvent(leaveEvent); NS_RELEASE(aWidget); @@ -1276,7 +1209,6 @@ void nsAppShell::HandleDragLeaveEvent(XEvent *event, nsWidget *aWidget) { } void nsAppShell::HandleDragDropEvent(XEvent *event, nsWidget *aWidget) { - nsMouseEvent mevent; PRBool currentlyDragging = PR_FALSE; nsresult rv; @@ -1292,13 +1224,10 @@ void nsAppShell::HandleDragDropEvent(XEvent *event, nsWidget *aWidget) { } if (currentlyDragging) { - mevent.widget = aWidget; + nsMouseEvent mevent(NS_DRAGDROP_DROP, aWidget); mevent.point.x = event->xbutton.x; mevent.point.y = event->xbutton.y; - mevent.message = NS_DRAGDROP_DROP; - mevent.eventStructType = NS_DRAGDROP_EVENT; - NS_IF_ADDREF(aWidget); aWidget->DispatchMouseEvent(mevent); NS_IF_RELEASE(aWidget); @@ -1309,8 +1238,7 @@ void nsAppShell::HandleDragDropEvent(XEvent *event, nsWidget *aWidget) { void nsAppShell::ForwardEvent(XEvent *event, nsWidget *aWidget) { - nsGUIEvent ev; - ev.widget = (nsIWidget *)aWidget; + nsGUIEvent ev(0, aWidget); ev.nativeMsg = (void *)event; aWidget->DispatchWindowEvent(ev); diff --git a/mozilla/widget/src/xlib/nsWidget.cpp b/mozilla/widget/src/xlib/nsWidget.cpp index c2a53b7db25..f3a06f08c74 100644 --- a/mozilla/widget/src/xlib/nsWidget.cpp +++ b/mozilla/widget/src/xlib/nsWidget.cpp @@ -1064,14 +1064,7 @@ PRBool nsWidget::OnDeleteWindow(void) PRBool nsWidget::DispatchDestroyEvent(void) { PRBool result = PR_FALSE; if (nsnull != mEventCallback) { - nsGUIEvent event; - event.nativeMsg = nsnull; - event.eventStructType = NS_GUI_EVENT; - event.message = NS_DESTROY; - event.widget = this; - event.time = 0; - event.point.x = 0; - event.point.y = 0; + nsGUIEvent event(NS_DESTROY, this); AddRef(); result = DispatchWindowEvent(event); Release(); diff --git a/mozilla/widget/src/xlib/nsWindow.cpp b/mozilla/widget/src/xlib/nsWindow.cpp index c905df1800f..13eae43a636 100644 --- a/mozilla/widget/src/xlib/nsWindow.cpp +++ b/mozilla/widget/src/xlib/nsWindow.cpp @@ -381,7 +381,7 @@ NS_IMETHODIMP nsWindow::InvalidateRegion(const nsIRegion* aRegion, PRBool aIsSyn NS_IMETHODIMP nsWindow::SetFocus(PRBool aRaise) { nsEventStatus status; - nsGUIEvent event; + nsFocusEvent event(NS_GOTFOCUS, this); // nsGUIEvent eventActivate; if (mBaseWindow) @@ -392,26 +392,14 @@ NS_IMETHODIMP nsWindow::SetFocus(PRBool aRaise) mBlockFocusEvents = PR_TRUE; - event.message = NS_GOTFOCUS; - event.widget = this; - event.eventStructType = NS_GUI_EVENT; - event.time = 0; - event.point.x = 0; - event.point.y = 0; - AddRef(); DispatchEvent(&event, status); Release(); - event.message = NS_ACTIVATE; - event.widget = this; - event.eventStructType = NS_GUI_EVENT; - event.time = 0; - event.point.x = 0; - event.point.y = 0; + nsGUIEvent actEvent(NS_ACTIVATE, this); AddRef(); - DispatchWindowEvent(event); + DispatchWindowEvent(actEvent); Release(); mBlockFocusEvents = PR_FALSE; @@ -460,17 +448,11 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, } nsWidget::Resize(aWidth, aHeight, aRepaint); - nsSizeEvent sevent; + nsSizeEvent sevent(NS_SIZE, this); nsRect sevent_windowSize(0, 0, aWidth, aHeight); - sevent.message = NS_SIZE; - sevent.widget = this; - sevent.eventStructType = NS_SIZE_EVENT; sevent.windowSize = &sevent_windowSize; - sevent.point.x = 0; - sevent.point.y = 0; sevent.mWinWidth = aWidth; sevent.mWinHeight = aHeight; - sevent.time = 0; AddRef(); OnResize(sevent); Release(); @@ -499,17 +481,11 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aX, nsWidget::Resize(aX, aY, aWidth, aHeight, aRepaint); - nsSizeEvent sevent; + nsSizeEvent sevent(NS_SIZE, this); nsRect sevent_windowSize(0, 0, aWidth, aHeight); - sevent.message = NS_SIZE; - sevent.widget = this; - sevent.eventStructType = NS_SIZE_EVENT; sevent.windowSize = &sevent_windowSize; - sevent.point.x = 0; - sevent.point.y = 0; sevent.mWinWidth = aWidth; sevent.mWinHeight = aHeight; - sevent.time = 0; AddRef(); OnResize(sevent); Release(); @@ -572,16 +548,12 @@ nsWindow::DoPaint (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, nsIRegion *aClipRegion) { if (mEventCallback) { - nsPaintEvent event; + nsPaintEvent event(NS_PAINT, this); nsRect rect(aX, aY, aWidth, aHeight); - event.message = NS_PAINT; - event.widget = this; - event.eventStructType = NS_PAINT_EVENT; event.point.x = aX; event.point.y = aY; event.time = PR_Now(); /* No time in EXPOSE events */ event.rect = ▭ - event.region = nsnull; event.renderingContext = GetRenderingContext(); if (event.renderingContext) { diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index eaa24dc5339..2d94401152e 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -1502,9 +1502,7 @@ PRBool nsWebShellWindow::ExecuteCloseHandler() docViewer = do_QueryInterface(contentViewer); if (docViewer && NS_SUCCEEDED(docViewer->GetPresContext(getter_AddRefs(presContext)))) { nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_XUL_CLOSE; + nsMouseEvent event(NS_XUL_CLOSE); rv = globalObject->HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); if (NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault) return PR_TRUE;