Add click event support for every element and initial keypress event support
git-svn-id: svn://10.0.0.236/trunk@15233 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user