diff --git a/mozilla/content/events/public/nsIEventStateManager.h b/mozilla/content/events/public/nsIEventStateManager.h index 6d75caa2ad6..db0f489296e 100644 --- a/mozilla/content/events/public/nsIEventStateManager.h +++ b/mozilla/content/events/public/nsIEventStateManager.h @@ -40,7 +40,12 @@ class nsIEventStateManager : public nsISupports { public: - NS_IMETHOD HandleEvent(nsIPresContext& aPresContext, + NS_IMETHOD PreHandleEvent(nsIPresContext& aPresContext, + nsGUIEvent *aEvent, + nsIFrame* aTargetFrame, + nsEventStatus& aStatus) = 0; + + NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext, nsGUIEvent *aEvent, nsIFrame* aTargetFrame, nsEventStatus& aStatus) = 0; diff --git a/mozilla/content/events/src/nsDOMEvent.cpp b/mozilla/content/events/src/nsDOMEvent.cpp index 08138706682..2a8ca0b50c8 100644 --- a/mozilla/content/events/src/nsDOMEvent.cpp +++ b/mozilla/content/events/src/nsDOMEvent.cpp @@ -385,6 +385,8 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType) return mEventNames[eDOMEvents_keyup]; case NS_KEY_DOWN: return mEventNames[eDOMEvents_keydown]; + case NS_KEY_PRESS: + return mEventNames[eDOMEvents_keypress]; case NS_GOTFOCUS: return mEventNames[eDOMEvents_focus]; case NS_LOSTFOCUS: diff --git a/mozilla/content/events/src/nsEventListenerManager.cpp b/mozilla/content/events/src/nsEventListenerManager.cpp index 890d765c8d2..dd312221e15 100644 --- a/mozilla/content/events/src/nsEventListenerManager.cpp +++ b/mozilla/content/events/src/nsEventListenerManager.cpp @@ -319,7 +319,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, else { ret = mEventListener->ProcessEvent(*aDOMEvent); } - aEventStatus = (NS_OK == ret) ? nsEventStatus_eIgnore : nsEventStatus_eConsumeNoDefault; + aEventStatus = (NS_OK == ret) ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } } @@ -350,7 +350,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, else { ret = mEventListener->ProcessEvent(*aDOMEvent); } - aEventStatus = (NS_OK == ret) ? nsEventStatus_eIgnore : nsEventStatus_eConsumeNoDefault; + aEventStatus = (NS_OK == ret) ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } } @@ -358,6 +358,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, case NS_KEY_UP: case NS_KEY_DOWN: + case NS_KEY_PRESS: if (nsnull != mKeyListeners) { if (nsnull == *aDOMEvent) { ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent); @@ -377,6 +378,9 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, case NS_KEY_DOWN: ret = mKeyListener->KeyDown(*aDOMEvent); break; + case NS_KEY_PRESS: + ret = mKeyListener->KeyPress(*aDOMEvent); + break; default: break; } @@ -385,7 +389,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, else { ret = mEventListener->ProcessEvent(*aDOMEvent); } - aEventStatus = (NS_OK == ret) ? nsEventStatus_eIgnore : nsEventStatus_eConsumeNoDefault; + aEventStatus = (NS_OK == ret) ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } } @@ -420,7 +424,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, else { ret = mEventListener->ProcessEvent(*aDOMEvent); } - aEventStatus = (NS_OK == ret) ? nsEventStatus_eIgnore : nsEventStatus_eConsumeNoDefault; + aEventStatus = (NS_OK == ret) ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } } @@ -459,7 +463,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, else { ret = mEventListener->ProcessEvent(*aDOMEvent); } - aEventStatus = (NS_OK == ret) ? nsEventStatus_eIgnore : nsEventStatus_eConsumeNoDefault; + aEventStatus = (NS_OK == ret) ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } } @@ -494,7 +498,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, else { ret = mEventListener->ProcessEvent(*aDOMEvent); } - aEventStatus = (NS_OK == ret) ? nsEventStatus_eIgnore : nsEventStatus_eConsumeNoDefault; + aEventStatus = (NS_OK == ret) ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } } @@ -521,7 +525,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, ret = eventListener->ProcessEvent(*aDOMEvent); } aEventStatus = (NS_OK == ret) - ? nsEventStatus_eIgnore + ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 1329d070609..5aa86ef5d2d 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -43,6 +43,10 @@ static NS_DEFINE_IID(kIDOMHTMLTextAreaElementIID, NS_IDOMHTMLTEXTAREAELEMENT_IID nsEventStateManager::nsEventStateManager() { mLastMouseOverFrame = nsnull; mCurrentTarget = nsnull; + mLastLeftMouseDownFrame = nsnull; + mLastMiddleMouseDownFrame = nsnull; + mLastRightMouseDownFrame = nsnull; + mActiveLink = nsnull; mCurrentFocus = nsnull; mDocument = nsnull; @@ -61,7 +65,7 @@ NS_IMPL_RELEASE(nsEventStateManager) NS_IMPL_QUERY_INTERFACE(nsEventStateManager, kIEventStateManagerIID); NS_IMETHODIMP -nsEventStateManager::HandleEvent(nsIPresContext& aPresContext, +nsEventStateManager::PreHandleEvent(nsIPresContext& aPresContext, nsGUIEvent *aEvent, nsIFrame* aTargetFrame, nsEventStatus& aStatus) @@ -83,14 +87,6 @@ nsEventStateManager::HandleEvent(nsIPresContext& aPresContext, case NS_MOUSE_EXIT: //GenerateMouseEnterExit(aPresContext, aEvent, aTargetFrame); break; - case NS_KEY_DOWN: - switch(((nsKeyEvent*)aEvent)->keyCode) { - case NS_VK_TAB: - ShiftFocus(); - aStatus = nsEventStatus_eConsumeNoDefault; - break; - } - break; case NS_GOTFOCUS: NS_IF_RELEASE(mCurrentFocus); aTargetFrame->GetContent(mCurrentFocus); @@ -99,6 +95,44 @@ nsEventStateManager::HandleEvent(nsIPresContext& aPresContext, return NS_OK; } +NS_IMETHODIMP +nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext, + nsGUIEvent *aEvent, + nsIFrame* aTargetFrame, + nsEventStatus& aStatus) +{ + mCurrentTarget = aTargetFrame; + nsresult ret = NS_OK; + + nsFrameState state; + mCurrentTarget->GetFrameState(state); + state |= NS_FRAME_EXTERNAL_REFERENCE; + mCurrentTarget->SetFrameState(state); + + switch (aEvent->message) { + case NS_MOUSE_LEFT_BUTTON_DOWN: + case NS_MOUSE_MIDDLE_BUTTON_DOWN: + case NS_MOUSE_RIGHT_BUTTON_DOWN: + case NS_MOUSE_LEFT_BUTTON_UP: + case NS_MOUSE_MIDDLE_BUTTON_UP: + case NS_MOUSE_RIGHT_BUTTON_UP: + ret = CheckForAndDispatchClick(aPresContext, (nsMouseEvent*)aEvent, aStatus); + break; + case NS_KEY_DOWN: + ret = DispatchKeyPressEvent(aPresContext, (nsKeyEvent*)aEvent, aStatus); + if (nsEventStatus_eConsumeNoDefault != aStatus) { + switch(((nsKeyEvent*)aEvent)->keyCode) { + case NS_VK_TAB: + ShiftFocus(); + aStatus = nsEventStatus_eConsumeNoDefault; + break; + } + } + break; + } + return ret; +} + NS_IMETHODIMP nsEventStateManager::SetPresContext(nsIPresContext* aPresContext) { @@ -112,9 +146,18 @@ nsEventStateManager::ClearFrameRefs(nsIFrame* aFrame) if (aFrame == mLastMouseOverFrame) { mLastMouseOverFrame = nsnull; } - else if (aFrame == mCurrentTarget) { + if (aFrame == mCurrentTarget) { mCurrentTarget = nsnull; } + if (aFrame == mLastLeftMouseDownFrame) { + mLastLeftMouseDownFrame = nsnull; + } + if (aFrame == mLastMiddleMouseDownFrame) { + mLastMiddleMouseDownFrame = nsnull; + } + if (aFrame == mLastRightMouseDownFrame) { + mLastRightMouseDownFrame = nsnull; + } return NS_OK; } @@ -184,6 +227,7 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE nsMouseEvent event; event.eventStructType = NS_MOUSE_EVENT; event.message = NS_MOUSE_EXIT; + event.widget = nsnull; //The frame has change but the content may not have. Check before dispatching to content mLastMouseOverFrame->GetContent(lastContent); @@ -204,6 +248,7 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE nsMouseEvent event; event.eventStructType = NS_MOUSE_EVENT; event.message = NS_MOUSE_ENTER; + event.widget = nsnull; //The frame has change but the content may not have. Check before dispatching to content if (lastContent != targetContent) { @@ -238,6 +283,7 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE nsMouseEvent event; event.eventStructType = NS_MOUSE_EVENT; event.message = NS_MOUSE_EXIT; + event.widget = nsnull; nsIContent *lastContent; mLastMouseOverFrame->GetContent(lastContent); @@ -256,6 +302,96 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE } +NS_IMETHODIMP +nsEventStateManager::CheckForAndDispatchClick(nsIPresContext& aPresContext, + nsMouseEvent *aEvent, + nsEventStatus& aStatus) +{ + nsresult ret; + nsMouseEvent event; + PRBool fireClick = PR_FALSE; + + switch (aEvent->message) { + case NS_MOUSE_LEFT_BUTTON_DOWN: + mLastLeftMouseDownFrame = mCurrentTarget; + break; + case NS_MOUSE_LEFT_BUTTON_UP: + if (mLastLeftMouseDownFrame == mCurrentTarget) { + fireClick = PR_TRUE; + event.message = NS_MOUSE_LEFT_CLICK; + } + break; + case NS_MOUSE_MIDDLE_BUTTON_DOWN: + mLastMiddleMouseDownFrame = mCurrentTarget; + break; + case NS_MOUSE_MIDDLE_BUTTON_UP: + if (mLastMiddleMouseDownFrame == mCurrentTarget) { + fireClick = PR_TRUE; + event.message = NS_MOUSE_MIDDLE_CLICK; + } + break; + case NS_MOUSE_RIGHT_BUTTON_DOWN: + mLastRightMouseDownFrame = mCurrentTarget; + break; + case NS_MOUSE_RIGHT_BUTTON_UP: + if (mLastRightMouseDownFrame == mCurrentTarget) { + fireClick = PR_TRUE; + event.message = NS_MOUSE_RIGHT_CLICK; + } + break; + } + + if (fireClick) { + //fire click + event.eventStructType = NS_MOUSE_EVENT; + event.widget = nsnull; + + nsIContent *content; + mCurrentTarget->GetContent(content); + + if (nsnull != content) { + ret = content->HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, aStatus); + NS_RELEASE(content); + } + + //Now dispatch to the frame + if (nsnull != mCurrentTarget) { + mCurrentTarget->HandleEvent(aPresContext, &event, aStatus); + } + } + return ret; +} + +NS_IMETHODIMP +nsEventStateManager::DispatchKeyPressEvent(nsIPresContext& aPresContext, + nsKeyEvent *aEvent, + nsEventStatus& aStatus) +{ + nsresult ret; + + //fire keypress + nsKeyEvent event; + event.eventStructType = NS_KEY_EVENT; + event.message = NS_KEY_PRESS; + event.widget = nsnull; + event.keyCode = aEvent->keyCode; + + nsIContent *content; + mCurrentTarget->GetContent(content); + + if (nsnull != content) { + ret = content->HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, aStatus); + NS_RELEASE(content); + } + + //Now dispatch to the frame + if (nsnull != mCurrentTarget) { + mCurrentTarget->HandleEvent(aPresContext, &event, aStatus); + } + + return ret; +} + void nsEventStateManager::ShiftFocus() { diff --git a/mozilla/content/events/src/nsEventStateManager.h b/mozilla/content/events/src/nsEventStateManager.h index f64961ac4be..2a2dca64bfd 100644 --- a/mozilla/content/events/src/nsEventStateManager.h +++ b/mozilla/content/events/src/nsEventStateManager.h @@ -35,7 +35,12 @@ public: NS_DECL_ISUPPORTS - NS_IMETHOD HandleEvent(nsIPresContext& aPresContext, + NS_IMETHOD PreHandleEvent(nsIPresContext& aPresContext, + nsGUIEvent *aEvent, + nsIFrame* aTargetFrame, + nsEventStatus& aStatus); + + NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext, nsGUIEvent *aEvent, nsIFrame* aTargetFrame, nsEventStatus& aStatus); @@ -52,11 +57,18 @@ public: protected: void UpdateCursor(nsIPresContext& aPresContext, nsPoint& aPoint, nsIFrame* aTargetFrame); void GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIEvent* aEvent, nsIFrame* aTargetFrame); + NS_IMETHOD DispatchKeyPressEvent(nsIPresContext& aPresContext, nsKeyEvent *aEvent, nsEventStatus& aStatus); + NS_IMETHOD CheckForAndDispatchClick(nsIPresContext& aPresContext, nsMouseEvent *aEvent, nsEventStatus& aStatus); void ShiftFocus(); nsIContent* GetNextTabbableContent(nsIContent* aParent, nsIContent* aChild, nsIContent* aTop); + //Any frames here must be checked for validity in ClearFrameRefs nsIFrame* mCurrentTarget; nsIFrame* mLastMouseOverFrame; + nsIFrame* mLastLeftMouseDownFrame; + nsIFrame* mLastMiddleMouseDownFrame; + nsIFrame* mLastRightMouseDownFrame; + nsIContent* mActiveLink; nsIContent* mCurrentFocus; diff --git a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp index 11982494d95..1792a166577 100644 --- a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp @@ -269,13 +269,7 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext, } if (activeLink == this) { - nsEventStatus status; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, status); - - if (nsEventStatus_eConsumeNoDefault != status) { + if (nsEventStatus_eConsumeNoDefault != aEventStatus) { nsAutoString base, target; GetAttribute(nsString(NS_HTML_BASE_HREF), base); GetAttribute(nsString("target"), target); diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp index 3c9c3e63915..cf44d6bcade 100644 --- a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp @@ -332,13 +332,7 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext, } if (activeLink == this) { - nsEventStatus status; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, status); - - if (nsEventStatus_eConsumeNoDefault != status) { + if (nsEventStatus_eConsumeNoDefault != aEventStatus) { nsAutoString base, href, target; GetAttribute(nsString(NS_HTML_BASE_HREF), base); GetAttribute(nsString("href"), href); diff --git a/mozilla/content/xml/content/src/nsXMLElement.cpp b/mozilla/content/xml/content/src/nsXMLElement.cpp index 949548076f9..5bf67af0f35 100644 --- a/mozilla/content/xml/content/src/nsXMLElement.cpp +++ b/mozilla/content/xml/content/src/nsXMLElement.cpp @@ -213,26 +213,20 @@ nsXMLElement::HandleDOMEvent(nsIPresContext& aPresContext, } if (activeLink == this) { - nsEventStatus status; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, status); - - if (nsEventStatus_eConsumeNoDefault != status) { + if (nsEventStatus_eConsumeNoDefault != aEventStatus) { nsAutoString show, href, base, target; - nsLinkVerb verb = eLinkVerb_Replace; - base.Truncate(); - target.Truncate(); + nsLinkVerb verb = eLinkVerb_Replace; + base.Truncate(); + target.Truncate(); GetAttribute(nsString("href"), href); GetAttribute(nsString("show"), show); - // XXX Should probably do this using atoms - if (show.Equals("new")) { - verb = eLinkVerb_New; - } - else if (show.Equals("embed")) { - verb = eLinkVerb_Embed; - } + // XXX Should probably do this using atoms + if (show.Equals("new")) { + verb = eLinkVerb_New; + } + else if (show.Equals("embed")) { + verb = eLinkVerb_Embed; + } mInner.TriggerLink(aPresContext, verb, base, href, target, PR_TRUE); aEventStatus = nsEventStatus_eConsumeNoDefault; } diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 1ec0178c092..d1334262293 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -1041,8 +1041,8 @@ NS_IMETHODIMP PresShell :: HandleEvent(nsIView *aView, //Once we have the targetFrame, handle the event in this order nsIEventStateManager *manager; if (NS_OK == mPresContext->GetEventStateManager(&manager)) { - //1. Give event to event manager for state changes and generation of synthetic events. - rv = manager->HandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus); + //1. Give event to event manager for pre event state changes and generation of synthetic events. + rv = manager->PreHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus); //2. Give event to the DOM for third party and JS use. if (nsnull != mCurrentEventFrame && NS_OK == rv) { @@ -1052,13 +1052,18 @@ NS_IMETHODIMP PresShell :: HandleEvent(nsIView *aView, DOM_EVENT_INIT, aEventStatus); NS_RELEASE(targetContent); } - } - //3. Give event to the Frames for browser default processing. - // XXX The event isn't translated into the local coordinate space - // of the frame... - if (nsnull != mCurrentEventFrame && NS_OK == rv) { - rv = mCurrentEventFrame->HandleEvent(*mPresContext, aEvent, aEventStatus); + //3. Give event to the Frames for browser default processing. + // XXX The event isn't translated into the local coordinate space + // of the frame... + if (nsnull != mCurrentEventFrame && NS_OK == rv) { + rv = mCurrentEventFrame->HandleEvent(*mPresContext, aEvent, aEventStatus); + + //4. Give event to event manager for post event state changes and generation of synthetic events. + if (nsnull != mCurrentEventFrame && NS_OK == rv) { + rv = manager->PostHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus); + } + } } NS_RELEASE(manager); } diff --git a/mozilla/layout/events/public/nsIEventStateManager.h b/mozilla/layout/events/public/nsIEventStateManager.h index 6d75caa2ad6..db0f489296e 100644 --- a/mozilla/layout/events/public/nsIEventStateManager.h +++ b/mozilla/layout/events/public/nsIEventStateManager.h @@ -40,7 +40,12 @@ class nsIEventStateManager : public nsISupports { public: - NS_IMETHOD HandleEvent(nsIPresContext& aPresContext, + NS_IMETHOD PreHandleEvent(nsIPresContext& aPresContext, + nsGUIEvent *aEvent, + nsIFrame* aTargetFrame, + nsEventStatus& aStatus) = 0; + + NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext, nsGUIEvent *aEvent, nsIFrame* aTargetFrame, nsEventStatus& aStatus) = 0; diff --git a/mozilla/layout/events/src/nsDOMEvent.cpp b/mozilla/layout/events/src/nsDOMEvent.cpp index 08138706682..2a8ca0b50c8 100644 --- a/mozilla/layout/events/src/nsDOMEvent.cpp +++ b/mozilla/layout/events/src/nsDOMEvent.cpp @@ -385,6 +385,8 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType) return mEventNames[eDOMEvents_keyup]; case NS_KEY_DOWN: return mEventNames[eDOMEvents_keydown]; + case NS_KEY_PRESS: + return mEventNames[eDOMEvents_keypress]; case NS_GOTFOCUS: return mEventNames[eDOMEvents_focus]; case NS_LOSTFOCUS: diff --git a/mozilla/layout/events/src/nsEventListenerManager.cpp b/mozilla/layout/events/src/nsEventListenerManager.cpp index 890d765c8d2..dd312221e15 100644 --- a/mozilla/layout/events/src/nsEventListenerManager.cpp +++ b/mozilla/layout/events/src/nsEventListenerManager.cpp @@ -319,7 +319,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, else { ret = mEventListener->ProcessEvent(*aDOMEvent); } - aEventStatus = (NS_OK == ret) ? nsEventStatus_eIgnore : nsEventStatus_eConsumeNoDefault; + aEventStatus = (NS_OK == ret) ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } } @@ -350,7 +350,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, else { ret = mEventListener->ProcessEvent(*aDOMEvent); } - aEventStatus = (NS_OK == ret) ? nsEventStatus_eIgnore : nsEventStatus_eConsumeNoDefault; + aEventStatus = (NS_OK == ret) ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } } @@ -358,6 +358,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, case NS_KEY_UP: case NS_KEY_DOWN: + case NS_KEY_PRESS: if (nsnull != mKeyListeners) { if (nsnull == *aDOMEvent) { ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent); @@ -377,6 +378,9 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, case NS_KEY_DOWN: ret = mKeyListener->KeyDown(*aDOMEvent); break; + case NS_KEY_PRESS: + ret = mKeyListener->KeyPress(*aDOMEvent); + break; default: break; } @@ -385,7 +389,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, else { ret = mEventListener->ProcessEvent(*aDOMEvent); } - aEventStatus = (NS_OK == ret) ? nsEventStatus_eIgnore : nsEventStatus_eConsumeNoDefault; + aEventStatus = (NS_OK == ret) ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } } @@ -420,7 +424,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, else { ret = mEventListener->ProcessEvent(*aDOMEvent); } - aEventStatus = (NS_OK == ret) ? nsEventStatus_eIgnore : nsEventStatus_eConsumeNoDefault; + aEventStatus = (NS_OK == ret) ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } } @@ -459,7 +463,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, else { ret = mEventListener->ProcessEvent(*aDOMEvent); } - aEventStatus = (NS_OK == ret) ? nsEventStatus_eIgnore : nsEventStatus_eConsumeNoDefault; + aEventStatus = (NS_OK == ret) ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } } @@ -494,7 +498,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, else { ret = mEventListener->ProcessEvent(*aDOMEvent); } - aEventStatus = (NS_OK == ret) ? nsEventStatus_eIgnore : nsEventStatus_eConsumeNoDefault; + aEventStatus = (NS_OK == ret) ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } } @@ -521,7 +525,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, ret = eventListener->ProcessEvent(*aDOMEvent); } aEventStatus = (NS_OK == ret) - ? nsEventStatus_eIgnore + ? aEventStatus : nsEventStatus_eConsumeNoDefault; } } diff --git a/mozilla/layout/events/src/nsEventStateManager.cpp b/mozilla/layout/events/src/nsEventStateManager.cpp index 1329d070609..5aa86ef5d2d 100644 --- a/mozilla/layout/events/src/nsEventStateManager.cpp +++ b/mozilla/layout/events/src/nsEventStateManager.cpp @@ -43,6 +43,10 @@ static NS_DEFINE_IID(kIDOMHTMLTextAreaElementIID, NS_IDOMHTMLTEXTAREAELEMENT_IID nsEventStateManager::nsEventStateManager() { mLastMouseOverFrame = nsnull; mCurrentTarget = nsnull; + mLastLeftMouseDownFrame = nsnull; + mLastMiddleMouseDownFrame = nsnull; + mLastRightMouseDownFrame = nsnull; + mActiveLink = nsnull; mCurrentFocus = nsnull; mDocument = nsnull; @@ -61,7 +65,7 @@ NS_IMPL_RELEASE(nsEventStateManager) NS_IMPL_QUERY_INTERFACE(nsEventStateManager, kIEventStateManagerIID); NS_IMETHODIMP -nsEventStateManager::HandleEvent(nsIPresContext& aPresContext, +nsEventStateManager::PreHandleEvent(nsIPresContext& aPresContext, nsGUIEvent *aEvent, nsIFrame* aTargetFrame, nsEventStatus& aStatus) @@ -83,14 +87,6 @@ nsEventStateManager::HandleEvent(nsIPresContext& aPresContext, case NS_MOUSE_EXIT: //GenerateMouseEnterExit(aPresContext, aEvent, aTargetFrame); break; - case NS_KEY_DOWN: - switch(((nsKeyEvent*)aEvent)->keyCode) { - case NS_VK_TAB: - ShiftFocus(); - aStatus = nsEventStatus_eConsumeNoDefault; - break; - } - break; case NS_GOTFOCUS: NS_IF_RELEASE(mCurrentFocus); aTargetFrame->GetContent(mCurrentFocus); @@ -99,6 +95,44 @@ nsEventStateManager::HandleEvent(nsIPresContext& aPresContext, return NS_OK; } +NS_IMETHODIMP +nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext, + nsGUIEvent *aEvent, + nsIFrame* aTargetFrame, + nsEventStatus& aStatus) +{ + mCurrentTarget = aTargetFrame; + nsresult ret = NS_OK; + + nsFrameState state; + mCurrentTarget->GetFrameState(state); + state |= NS_FRAME_EXTERNAL_REFERENCE; + mCurrentTarget->SetFrameState(state); + + switch (aEvent->message) { + case NS_MOUSE_LEFT_BUTTON_DOWN: + case NS_MOUSE_MIDDLE_BUTTON_DOWN: + case NS_MOUSE_RIGHT_BUTTON_DOWN: + case NS_MOUSE_LEFT_BUTTON_UP: + case NS_MOUSE_MIDDLE_BUTTON_UP: + case NS_MOUSE_RIGHT_BUTTON_UP: + ret = CheckForAndDispatchClick(aPresContext, (nsMouseEvent*)aEvent, aStatus); + break; + case NS_KEY_DOWN: + ret = DispatchKeyPressEvent(aPresContext, (nsKeyEvent*)aEvent, aStatus); + if (nsEventStatus_eConsumeNoDefault != aStatus) { + switch(((nsKeyEvent*)aEvent)->keyCode) { + case NS_VK_TAB: + ShiftFocus(); + aStatus = nsEventStatus_eConsumeNoDefault; + break; + } + } + break; + } + return ret; +} + NS_IMETHODIMP nsEventStateManager::SetPresContext(nsIPresContext* aPresContext) { @@ -112,9 +146,18 @@ nsEventStateManager::ClearFrameRefs(nsIFrame* aFrame) if (aFrame == mLastMouseOverFrame) { mLastMouseOverFrame = nsnull; } - else if (aFrame == mCurrentTarget) { + if (aFrame == mCurrentTarget) { mCurrentTarget = nsnull; } + if (aFrame == mLastLeftMouseDownFrame) { + mLastLeftMouseDownFrame = nsnull; + } + if (aFrame == mLastMiddleMouseDownFrame) { + mLastMiddleMouseDownFrame = nsnull; + } + if (aFrame == mLastRightMouseDownFrame) { + mLastRightMouseDownFrame = nsnull; + } return NS_OK; } @@ -184,6 +227,7 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE nsMouseEvent event; event.eventStructType = NS_MOUSE_EVENT; event.message = NS_MOUSE_EXIT; + event.widget = nsnull; //The frame has change but the content may not have. Check before dispatching to content mLastMouseOverFrame->GetContent(lastContent); @@ -204,6 +248,7 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE nsMouseEvent event; event.eventStructType = NS_MOUSE_EVENT; event.message = NS_MOUSE_ENTER; + event.widget = nsnull; //The frame has change but the content may not have. Check before dispatching to content if (lastContent != targetContent) { @@ -238,6 +283,7 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE nsMouseEvent event; event.eventStructType = NS_MOUSE_EVENT; event.message = NS_MOUSE_EXIT; + event.widget = nsnull; nsIContent *lastContent; mLastMouseOverFrame->GetContent(lastContent); @@ -256,6 +302,96 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE } +NS_IMETHODIMP +nsEventStateManager::CheckForAndDispatchClick(nsIPresContext& aPresContext, + nsMouseEvent *aEvent, + nsEventStatus& aStatus) +{ + nsresult ret; + nsMouseEvent event; + PRBool fireClick = PR_FALSE; + + switch (aEvent->message) { + case NS_MOUSE_LEFT_BUTTON_DOWN: + mLastLeftMouseDownFrame = mCurrentTarget; + break; + case NS_MOUSE_LEFT_BUTTON_UP: + if (mLastLeftMouseDownFrame == mCurrentTarget) { + fireClick = PR_TRUE; + event.message = NS_MOUSE_LEFT_CLICK; + } + break; + case NS_MOUSE_MIDDLE_BUTTON_DOWN: + mLastMiddleMouseDownFrame = mCurrentTarget; + break; + case NS_MOUSE_MIDDLE_BUTTON_UP: + if (mLastMiddleMouseDownFrame == mCurrentTarget) { + fireClick = PR_TRUE; + event.message = NS_MOUSE_MIDDLE_CLICK; + } + break; + case NS_MOUSE_RIGHT_BUTTON_DOWN: + mLastRightMouseDownFrame = mCurrentTarget; + break; + case NS_MOUSE_RIGHT_BUTTON_UP: + if (mLastRightMouseDownFrame == mCurrentTarget) { + fireClick = PR_TRUE; + event.message = NS_MOUSE_RIGHT_CLICK; + } + break; + } + + if (fireClick) { + //fire click + event.eventStructType = NS_MOUSE_EVENT; + event.widget = nsnull; + + nsIContent *content; + mCurrentTarget->GetContent(content); + + if (nsnull != content) { + ret = content->HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, aStatus); + NS_RELEASE(content); + } + + //Now dispatch to the frame + if (nsnull != mCurrentTarget) { + mCurrentTarget->HandleEvent(aPresContext, &event, aStatus); + } + } + return ret; +} + +NS_IMETHODIMP +nsEventStateManager::DispatchKeyPressEvent(nsIPresContext& aPresContext, + nsKeyEvent *aEvent, + nsEventStatus& aStatus) +{ + nsresult ret; + + //fire keypress + nsKeyEvent event; + event.eventStructType = NS_KEY_EVENT; + event.message = NS_KEY_PRESS; + event.widget = nsnull; + event.keyCode = aEvent->keyCode; + + nsIContent *content; + mCurrentTarget->GetContent(content); + + if (nsnull != content) { + ret = content->HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, aStatus); + NS_RELEASE(content); + } + + //Now dispatch to the frame + if (nsnull != mCurrentTarget) { + mCurrentTarget->HandleEvent(aPresContext, &event, aStatus); + } + + return ret; +} + void nsEventStateManager::ShiftFocus() { diff --git a/mozilla/layout/events/src/nsEventStateManager.h b/mozilla/layout/events/src/nsEventStateManager.h index f64961ac4be..2a2dca64bfd 100644 --- a/mozilla/layout/events/src/nsEventStateManager.h +++ b/mozilla/layout/events/src/nsEventStateManager.h @@ -35,7 +35,12 @@ public: NS_DECL_ISUPPORTS - NS_IMETHOD HandleEvent(nsIPresContext& aPresContext, + NS_IMETHOD PreHandleEvent(nsIPresContext& aPresContext, + nsGUIEvent *aEvent, + nsIFrame* aTargetFrame, + nsEventStatus& aStatus); + + NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext, nsGUIEvent *aEvent, nsIFrame* aTargetFrame, nsEventStatus& aStatus); @@ -52,11 +57,18 @@ public: protected: void UpdateCursor(nsIPresContext& aPresContext, nsPoint& aPoint, nsIFrame* aTargetFrame); void GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIEvent* aEvent, nsIFrame* aTargetFrame); + NS_IMETHOD DispatchKeyPressEvent(nsIPresContext& aPresContext, nsKeyEvent *aEvent, nsEventStatus& aStatus); + NS_IMETHOD CheckForAndDispatchClick(nsIPresContext& aPresContext, nsMouseEvent *aEvent, nsEventStatus& aStatus); void ShiftFocus(); nsIContent* GetNextTabbableContent(nsIContent* aParent, nsIContent* aChild, nsIContent* aTop); + //Any frames here must be checked for validity in ClearFrameRefs nsIFrame* mCurrentTarget; nsIFrame* mLastMouseOverFrame; + nsIFrame* mLastLeftMouseDownFrame; + nsIFrame* mLastMiddleMouseDownFrame; + nsIFrame* mLastRightMouseDownFrame; + nsIContent* mActiveLink; nsIContent* mCurrentFocus; diff --git a/mozilla/layout/forms/nsFormControlFrame.cpp b/mozilla/layout/forms/nsFormControlFrame.cpp index 6f5aae9042c..75cdb58d20c 100644 --- a/mozilla/layout/forms/nsFormControlFrame.cpp +++ b/mozilla/layout/forms/nsFormControlFrame.cpp @@ -643,21 +643,7 @@ NS_METHOD nsFormControlFrame::HandleEvent(nsIPresContext& aPresContext, break; case NS_MOUSE_LEFT_BUTTON_UP: if (eMouseDown == mLastMouseState) { - //widget->SetFocus(); - float t2p = aPresContext.GetTwipsToPixels(); - SetClickPoint(NSTwipsToIntPixels(aEvent->point.x, t2p), - NSTwipsToIntPixels(aEvent->point.y, t2p)); - - nsEventStatus mStatus = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - mContent->HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, mStatus); - - if (nsEventStatus_eConsumeNoDefault != mStatus) { - MouseClicked(&aPresContext); - //return PR_FALSE; - } + MouseClicked(&aPresContext); } mLastMouseState = eMouseEnter; break; diff --git a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp index dcb088d8ca5..65a0b3d84b8 100644 --- a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp @@ -469,14 +469,8 @@ nsHTMLButtonControlFrame::HandleEvent(nsIPresContext& aPresContext, break; case NS_MOUSE_LEFT_BUTTON_UP: if (eMouseDown == mLastMouseState) { - ShiftContents(aPresContext, PR_FALSE); - nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - mContent->HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, status); - - if (nsEventStatus_eConsumeNoDefault != status) { + if (nsEventStatus_eConsumeNoDefault != aEventStatus) { + ShiftContents(aPresContext, PR_FALSE); MouseClicked(&aPresContext); } mLastMouseState = eMouseUp; diff --git a/mozilla/layout/forms/nsImageControlFrame.cpp b/mozilla/layout/forms/nsImageControlFrame.cpp index b54fd83cdab..3ece6cd04e7 100644 --- a/mozilla/layout/forms/nsImageControlFrame.cpp +++ b/mozilla/layout/forms/nsImageControlFrame.cpp @@ -224,17 +224,7 @@ nsImageControlFrame::HandleEvent(nsIPresContext& aPresContext, case NS_MOUSE_LEFT_BUTTON_UP: { if (eMouseDown == mLastMouseState) { - nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - mContent->HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, status); - - float t2p = aPresContext.GetTwipsToPixels(); - mLastClickPoint.x = NSTwipsToIntPixels(aEvent->point.x - mTranslatedRect.x, t2p); - mLastClickPoint.y = NSTwipsToIntPixels(aEvent->point.y - mTranslatedRect.y, t2p); - - if (nsEventStatus_eConsumeNoDefault != status) { + if (nsEventStatus_eConsumeNoDefault != aEventStatus) { MouseClicked(&aPresContext); } } diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index d4ca09070b0..f09760b9d21 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -921,8 +921,8 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext, } mCurrentFrame = this; - NS_RELEASE(currentContent); - NS_RELEASE(newContent); + NS_IF_RELEASE(currentContent); + NS_IF_RELEASE(newContent); } else if ((nsnull != mStartSelectionPoint) && (nsnull != mEndSelectionPoint)) { if (SELECTION_DEBUG) printf("HandleDrag::Same Frame.\n"); @@ -964,7 +964,7 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext, // " "+mStartSelectionPoint->IsAnchor()+ // " End: "+mEndSelectionPoint->GetOffset() + // " "+mEndSelectionPoint->IsAnchor()); - NS_RELEASE(newContent); + NS_IF_RELEASE(newContent); } NS_IF_RELEASE(selStartContent); NS_IF_RELEASE(selEndContent); diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index d4ca09070b0..f09760b9d21 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -921,8 +921,8 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext, } mCurrentFrame = this; - NS_RELEASE(currentContent); - NS_RELEASE(newContent); + NS_IF_RELEASE(currentContent); + NS_IF_RELEASE(newContent); } else if ((nsnull != mStartSelectionPoint) && (nsnull != mEndSelectionPoint)) { if (SELECTION_DEBUG) printf("HandleDrag::Same Frame.\n"); @@ -964,7 +964,7 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext, // " "+mStartSelectionPoint->IsAnchor()+ // " End: "+mEndSelectionPoint->GetOffset() + // " "+mEndSelectionPoint->IsAnchor()); - NS_RELEASE(newContent); + NS_IF_RELEASE(newContent); } NS_IF_RELEASE(selStartContent); NS_IF_RELEASE(selEndContent); diff --git a/mozilla/layout/html/base/src/nsHTMLTagContent.cpp b/mozilla/layout/html/base/src/nsHTMLTagContent.cpp index c9a117e1b7d..e89415117e6 100644 --- a/mozilla/layout/html/base/src/nsHTMLTagContent.cpp +++ b/mozilla/layout/html/base/src/nsHTMLTagContent.cpp @@ -1286,13 +1286,7 @@ nsresult nsHTMLTagContent::HandleDOMEvent(nsIPresContext& aPresContext, } if (mActiveLink == this) { - nsEventStatus mStatus; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, mStatus); - - if (nsEventStatus_eConsumeNoDefault != mStatus) { + if (nsEventStatus_eConsumeNoDefault != aEventStatus) { nsAutoString base, href, target; GetAttribute(nsString(NS_HTML_BASE_HREF), base); GetAttribute(nsString("href"), href); diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 1ec0178c092..d1334262293 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -1041,8 +1041,8 @@ NS_IMETHODIMP PresShell :: HandleEvent(nsIView *aView, //Once we have the targetFrame, handle the event in this order nsIEventStateManager *manager; if (NS_OK == mPresContext->GetEventStateManager(&manager)) { - //1. Give event to event manager for state changes and generation of synthetic events. - rv = manager->HandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus); + //1. Give event to event manager for pre event state changes and generation of synthetic events. + rv = manager->PreHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus); //2. Give event to the DOM for third party and JS use. if (nsnull != mCurrentEventFrame && NS_OK == rv) { @@ -1052,13 +1052,18 @@ NS_IMETHODIMP PresShell :: HandleEvent(nsIView *aView, DOM_EVENT_INIT, aEventStatus); NS_RELEASE(targetContent); } - } - //3. Give event to the Frames for browser default processing. - // XXX The event isn't translated into the local coordinate space - // of the frame... - if (nsnull != mCurrentEventFrame && NS_OK == rv) { - rv = mCurrentEventFrame->HandleEvent(*mPresContext, aEvent, aEventStatus); + //3. Give event to the Frames for browser default processing. + // XXX The event isn't translated into the local coordinate space + // of the frame... + if (nsnull != mCurrentEventFrame && NS_OK == rv) { + rv = mCurrentEventFrame->HandleEvent(*mPresContext, aEvent, aEventStatus); + + //4. Give event to event manager for post event state changes and generation of synthetic events. + if (nsnull != mCurrentEventFrame && NS_OK == rv) { + rv = manager->PostHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus); + } + } } NS_RELEASE(manager); } diff --git a/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp index 11982494d95..1792a166577 100644 --- a/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp @@ -269,13 +269,7 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext, } if (activeLink == this) { - nsEventStatus status; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, status); - - if (nsEventStatus_eConsumeNoDefault != status) { + if (nsEventStatus_eConsumeNoDefault != aEventStatus) { nsAutoString base, target; GetAttribute(nsString(NS_HTML_BASE_HREF), base); GetAttribute(nsString("target"), target); diff --git a/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp b/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp index 3c9c3e63915..cf44d6bcade 100644 --- a/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp @@ -332,13 +332,7 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext, } if (activeLink == this) { - nsEventStatus status; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, status); - - if (nsEventStatus_eConsumeNoDefault != status) { + if (nsEventStatus_eConsumeNoDefault != aEventStatus) { nsAutoString base, href, target; GetAttribute(nsString(NS_HTML_BASE_HREF), base); GetAttribute(nsString("href"), href); diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp index 6f5aae9042c..75cdb58d20c 100644 --- a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp @@ -643,21 +643,7 @@ NS_METHOD nsFormControlFrame::HandleEvent(nsIPresContext& aPresContext, break; case NS_MOUSE_LEFT_BUTTON_UP: if (eMouseDown == mLastMouseState) { - //widget->SetFocus(); - float t2p = aPresContext.GetTwipsToPixels(); - SetClickPoint(NSTwipsToIntPixels(aEvent->point.x, t2p), - NSTwipsToIntPixels(aEvent->point.y, t2p)); - - nsEventStatus mStatus = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - mContent->HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, mStatus); - - if (nsEventStatus_eConsumeNoDefault != mStatus) { - MouseClicked(&aPresContext); - //return PR_FALSE; - } + MouseClicked(&aPresContext); } mLastMouseState = eMouseEnter; break; diff --git a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp index dcb088d8ca5..65a0b3d84b8 100644 --- a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp @@ -469,14 +469,8 @@ nsHTMLButtonControlFrame::HandleEvent(nsIPresContext& aPresContext, break; case NS_MOUSE_LEFT_BUTTON_UP: if (eMouseDown == mLastMouseState) { - ShiftContents(aPresContext, PR_FALSE); - nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - mContent->HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, status); - - if (nsEventStatus_eConsumeNoDefault != status) { + if (nsEventStatus_eConsumeNoDefault != aEventStatus) { + ShiftContents(aPresContext, PR_FALSE); MouseClicked(&aPresContext); } mLastMouseState = eMouseUp; diff --git a/mozilla/layout/html/forms/src/nsImageControlFrame.cpp b/mozilla/layout/html/forms/src/nsImageControlFrame.cpp index b54fd83cdab..3ece6cd04e7 100644 --- a/mozilla/layout/html/forms/src/nsImageControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsImageControlFrame.cpp @@ -224,17 +224,7 @@ nsImageControlFrame::HandleEvent(nsIPresContext& aPresContext, case NS_MOUSE_LEFT_BUTTON_UP: { if (eMouseDown == mLastMouseState) { - nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - mContent->HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, status); - - float t2p = aPresContext.GetTwipsToPixels(); - mLastClickPoint.x = NSTwipsToIntPixels(aEvent->point.x - mTranslatedRect.x, t2p); - mLastClickPoint.y = NSTwipsToIntPixels(aEvent->point.y - mTranslatedRect.y, t2p); - - if (nsEventStatus_eConsumeNoDefault != status) { + if (nsEventStatus_eConsumeNoDefault != aEventStatus) { MouseClicked(&aPresContext); } } diff --git a/mozilla/layout/html/forms/src/nsInputFrame.cpp b/mozilla/layout/html/forms/src/nsInputFrame.cpp index c7ccbc602d6..1e860ae507b 100644 --- a/mozilla/layout/html/forms/src/nsInputFrame.cpp +++ b/mozilla/layout/html/forms/src/nsInputFrame.cpp @@ -414,17 +414,7 @@ NS_METHOD nsInputFrame::HandleEvent(nsIPresContext& aPresContext, break; case NS_MOUSE_LEFT_BUTTON_UP: if (eMouseDown == mLastMouseState) { - float t2p = aPresContext.GetTwipsToPixels(); - ((nsInput*)mContent)->SetClickPoint(NSTwipsToIntPixels(aEvent->point.x, t2p), - NSTwipsToIntPixels(aEvent->point.y, t2p)); - - nsEventStatus mStatus = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - mContent->HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, mStatus); - - if (nsEventStatus_eConsumeNoDefault != mStatus) { + if (nsEventStatus_eConsumeNoDefault != aEventStatus) { MouseClicked(&aPresContext); } } diff --git a/mozilla/layout/html/forms/src/nsLabelFrame.cpp b/mozilla/layout/html/forms/src/nsLabelFrame.cpp index 7e7a6905753..3d19e4de81f 100644 --- a/mozilla/layout/html/forms/src/nsLabelFrame.cpp +++ b/mozilla/layout/html/forms/src/nsLabelFrame.cpp @@ -177,13 +177,7 @@ nsLabelFrame::HandleEvent(nsIPresContext& aPresContext, break; case NS_MOUSE_LEFT_BUTTON_UP: if (eMouseDown == mLastMouseState) { - nsEventStatus status = nsEventStatus_eIgnore; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - mContent->HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, status); - - if (nsEventStatus_eConsumeNoDefault != status) { + if (nsEventStatus_eConsumeNoDefault != aEventStatus) { mControlFrame->MouseClicked(&aPresContext); } } diff --git a/mozilla/layout/xml/content/src/nsXMLElement.cpp b/mozilla/layout/xml/content/src/nsXMLElement.cpp index 949548076f9..5bf67af0f35 100644 --- a/mozilla/layout/xml/content/src/nsXMLElement.cpp +++ b/mozilla/layout/xml/content/src/nsXMLElement.cpp @@ -213,26 +213,20 @@ nsXMLElement::HandleDOMEvent(nsIPresContext& aPresContext, } if (activeLink == this) { - nsEventStatus status; - nsMouseEvent event; - event.eventStructType = NS_MOUSE_EVENT; - event.message = NS_MOUSE_LEFT_CLICK; - HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, status); - - if (nsEventStatus_eConsumeNoDefault != status) { + if (nsEventStatus_eConsumeNoDefault != aEventStatus) { nsAutoString show, href, base, target; - nsLinkVerb verb = eLinkVerb_Replace; - base.Truncate(); - target.Truncate(); + nsLinkVerb verb = eLinkVerb_Replace; + base.Truncate(); + target.Truncate(); GetAttribute(nsString("href"), href); GetAttribute(nsString("show"), show); - // XXX Should probably do this using atoms - if (show.Equals("new")) { - verb = eLinkVerb_New; - } - else if (show.Equals("embed")) { - verb = eLinkVerb_Embed; - } + // XXX Should probably do this using atoms + if (show.Equals("new")) { + verb = eLinkVerb_New; + } + else if (show.Equals("embed")) { + verb = eLinkVerb_Embed; + } mInner.TriggerLink(aPresContext, verb, base, href, target, PR_TRUE); aEventStatus = nsEventStatus_eConsumeNoDefault; }