diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 7efff0bdfa6..d69c77cade4 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -38,8 +38,6 @@ #include "nsIWebShell.h" #include "nsIFocusableContent.h" #include "nsIScrollableView.h" -#include "nsIDOMSelection.h" -#include "nsIFrameSelection.h" static NS_DEFINE_IID(kIEventStateManagerIID, NS_IEVENTSTATEMANAGER_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -161,22 +159,8 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext, case NS_MOUSE_LEFT_BUTTON_UP: case NS_MOUSE_MIDDLE_BUTTON_UP: case NS_MOUSE_RIGHT_BUTTON_UP: - { - ret = CheckForAndDispatchClick(aPresContext, (nsMouseEvent*)aEvent, aStatus); - SetContentState(nsnull, NS_EVENT_STATE_ACTIVE); - nsCOMPtr shell; - nsresult rv = aPresContext.GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell){ - nsCOMPtr selection; - rv = shell->GetSelection(getter_AddRefs(selection)); - if (NS_SUCCEEDED(rv) && selection){ - nsCOMPtr frameSel; - frameSel = do_QueryInterface(selection); - if (frameSel) - frameSel->SetMouseDownState(PR_FALSE); - } - } - } + ret = CheckForAndDispatchClick(aPresContext, (nsMouseEvent*)aEvent, aStatus); + SetContentState(nsnull, NS_EVENT_STATE_ACTIVE); break; case NS_KEY_DOWN: ret = DispatchKeyPressEvent(aPresContext, (nsKeyEvent*)aEvent, aStatus); diff --git a/layout/base/nsIFrameSelection.h b/layout/base/nsIFrameSelection.h index 465dd7cb0fa..988029d2a53 100644 --- a/layout/base/nsIFrameSelection.h +++ b/layout/base/nsIFrameSelection.h @@ -98,19 +98,6 @@ public: */ NS_IMETHOD LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength, PRInt32 *aStart, PRInt32 *aEnd, PRBool *aDrawSelected, PRUint32 aFlag/*not used*/) = 0; - - /** SetMouseDownState(PRBool); - * sets the mouse state to aState for resons of drag state. - * @param aState is the new state of mousedown - */ - NS_IMETHOD SetMouseDownState(PRBool aState)=0; - - /** GetMouseDownState(PRBool *); - * gets the mouse state to aState for resons of drag state. - * @param aState will hold the state of mousedown - */ - NS_IMETHOD GetMouseDownState(PRBool *aState)=0; - }; diff --git a/layout/base/public/nsIFrameSelection.h b/layout/base/public/nsIFrameSelection.h index 465dd7cb0fa..988029d2a53 100644 --- a/layout/base/public/nsIFrameSelection.h +++ b/layout/base/public/nsIFrameSelection.h @@ -98,19 +98,6 @@ public: */ NS_IMETHOD LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength, PRInt32 *aStart, PRInt32 *aEnd, PRBool *aDrawSelected, PRUint32 aFlag/*not used*/) = 0; - - /** SetMouseDownState(PRBool); - * sets the mouse state to aState for resons of drag state. - * @param aState is the new state of mousedown - */ - NS_IMETHOD SetMouseDownState(PRBool aState)=0; - - /** GetMouseDownState(PRBool *); - * gets the mouse state to aState for resons of drag state. - * @param aState will hold the state of mousedown - */ - NS_IMETHOD GetMouseDownState(PRBool *aState)=0; - }; diff --git a/layout/base/src/nsRangeList.cpp b/layout/base/src/nsRangeList.cpp index b536a3cb7ba..28ef6f1e115 100644 --- a/layout/base/src/nsRangeList.cpp +++ b/layout/base/src/nsRangeList.cpp @@ -92,9 +92,6 @@ public: NS_IMETHOD EnableFrameNotification(PRBool aEnable){mNotifyFrames = aEnable; return NS_OK;} NS_IMETHOD LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength, PRInt32 *aStart, PRInt32 *aEnd, PRBool *aDrawSelected , PRUint32 aFlag/*not used*/); - NS_IMETHOD SetMouseDownState(PRBool aState); - NS_IMETHOD GetMouseDownState(PRBool *aState); - /*END nsIFrameSelection interfacse*/ /*BEGIN nsIDOMSelection interface implementations*/ @@ -175,7 +172,6 @@ private: // for nsIScriptContextOwner void* mScriptObject; nsIFocusTracker *mTracker; - PRBool mMouseDownState; //for drag purposes }; class nsRangeListIterator : public nsIBidirectionalEnumerator @@ -241,7 +237,6 @@ nsRangeListIterator::nsRangeListIterator(nsRangeList *aList) return; } mRangeList = aList; - mDirection = PR_TRUE; NS_INIT_REFCNT(); } @@ -687,7 +682,6 @@ NS_IMETHODIMP nsRangeList::Init(nsIFocusTracker *aTracker) { mTracker = aTracker; - mMouseDownState = PR_FALSE; return NS_OK; } @@ -1002,27 +996,6 @@ nsRangeList::LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt -NS_METHOD -nsRangeList::SetMouseDownState(PRBool aState) -{ - mMouseDownState = aState; - return NS_OK; -} - - - -NS_METHOD -nsRangeList::GetMouseDownState(PRBool *aState) -{ - if (!aState) - return NS_ERROR_NULL_POINTER; - *aState = mMouseDownState; - return NS_OK; -} - - - -//////////END FRAMESELECTION NS_METHOD nsRangeList::AddSelectionListener(nsIDOMSelectionListener* inNewListener) { @@ -1492,7 +1465,11 @@ nsRangeList::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) } - return NS_OK; + // If we get here, the focus wasn't contained in any of the ranges. +#ifdef DEBUG + printf("nsRangeList::Extend: focus not contained in any ranges\n"); +#endif + return NS_ERROR_UNEXPECTED; } diff --git a/layout/events/src/nsEventStateManager.cpp b/layout/events/src/nsEventStateManager.cpp index 7efff0bdfa6..d69c77cade4 100644 --- a/layout/events/src/nsEventStateManager.cpp +++ b/layout/events/src/nsEventStateManager.cpp @@ -38,8 +38,6 @@ #include "nsIWebShell.h" #include "nsIFocusableContent.h" #include "nsIScrollableView.h" -#include "nsIDOMSelection.h" -#include "nsIFrameSelection.h" static NS_DEFINE_IID(kIEventStateManagerIID, NS_IEVENTSTATEMANAGER_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -161,22 +159,8 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext, case NS_MOUSE_LEFT_BUTTON_UP: case NS_MOUSE_MIDDLE_BUTTON_UP: case NS_MOUSE_RIGHT_BUTTON_UP: - { - ret = CheckForAndDispatchClick(aPresContext, (nsMouseEvent*)aEvent, aStatus); - SetContentState(nsnull, NS_EVENT_STATE_ACTIVE); - nsCOMPtr shell; - nsresult rv = aPresContext.GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell){ - nsCOMPtr selection; - rv = shell->GetSelection(getter_AddRefs(selection)); - if (NS_SUCCEEDED(rv) && selection){ - nsCOMPtr frameSel; - frameSel = do_QueryInterface(selection); - if (frameSel) - frameSel->SetMouseDownState(PR_FALSE); - } - } - } + ret = CheckForAndDispatchClick(aPresContext, (nsMouseEvent*)aEvent, aStatus); + SetContentState(nsnull, NS_EVENT_STATE_ACTIVE); break; case NS_KEY_DOWN: ret = DispatchKeyPressEvent(aPresContext, (nsKeyEvent*)aEvent, aStatus); diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 66e1544a6b5..595d1c43ac5 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -692,18 +692,30 @@ NS_IMETHODIMP nsComboboxControlFrame::HandleEvent(nsIPresContext& aPresContext, if (nsEventStatus_eConsumeNoDefault == aEventStatus) { return NS_OK; + } - aEventStatus = nsEventStatus_eConsumeNoDefault; + if(nsEventStatus_eConsumeNoDefault != aEventStatus) { + if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { + } else if (aEvent->message == NS_MOUSE_MOVE && mDoingSelection || + aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) { + // no-op + } else { + return NS_OK; + } - if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) { - mArrowStyle = mBtnOutStyleContext; - nsFormControlHelper::ForceDrawFrame(this); - } else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { - mArrowStyle = mBtnPressedStyleContext; - nsFormControlHelper::ForceDrawFrame(this); - MouseClicked(&aPresContext); + aEventStatus = nsEventStatus_eConsumeNoDefault; + + if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) { + mArrowStyle = mBtnOutStyleContext; + nsFormControlHelper::ForceDrawFrame(this); + } else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { + mArrowStyle = mBtnPressedStyleContext; + nsFormControlHelper::ForceDrawFrame(this); + MouseClicked(&aPresContext); + } } + return NS_OK; } diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 589b3614c38..c9586806280 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -72,6 +72,7 @@ PRInt32 fTrackerRemoveListMax = 0; nsIContent * fTrackerContentArrayAddList[1024]; PRInt32 fTrackerAddListMax = 0; +nsIDocument *gDoc = nsnull; // [HACK] Foward Declarations void ForceDrawFrame(nsFrame * aFrame); @@ -79,6 +80,8 @@ void ForceDrawFrame(nsFrame * aFrame); static void RefreshContentFrames(nsIPresContext& aPresContext, nsIContent * aStartContent, nsIContent * aEndContent); #endif +PRBool nsFrame::mDoingSelection = PR_FALSE; +PRBool nsFrame::mDidDrag = PR_FALSE; //---------------------------------------------------------------------- @@ -725,32 +728,36 @@ nsFrame::HandleEvent(nsIPresContext& aPresContext, return NS_OK; } -/*i have no idea why this is here keeping incase.. if (DisplaySelection(aPresContext) == PR_FALSE) { if (aEvent->message != NS_MOUSE_LEFT_BUTTON_DOWN) { return NS_OK; } } -*/ - if (aEvent->message == NS_MOUSE_MOVE) { - nsCOMPtr shell; - nsresult rv = aPresContext.GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv)){ - nsCOMPtr selection; - if (NS_SUCCEEDED(shell->GetSelection(getter_AddRefs(selection)))){ - nsCOMPtr frameselection; - frameselection = do_QueryInterface(selection); - if (frameselection) { - PRBool mouseDown = PR_FALSE; - if (NS_SUCCEEDED(frameselection->GetMouseDownState(&mouseDown)) && mouseDown){ - HandleDrag(aPresContext, aEvent, aEventStatus); - } - } - } + + if(nsEventStatus_eConsumeNoDefault != aEventStatus) { + if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { + } + else if (aEvent->message == NS_MOUSE_MOVE && mDoingSelection || + aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) { + // no-op + } + else { + return NS_OK; + } + if (SELECTION_DEBUG) printf("Message: %d-------------------------------------------------------------\n",aEvent->message); + + + if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) { + if (mDoingSelection) { + HandleRelease(aPresContext, aEvent, aEventStatus); + } + } else if (aEvent->message == NS_MOUSE_MOVE) { + mDidDrag = PR_TRUE; + HandleDrag(aPresContext, aEvent, aEventStatus); +//DEBUG MJUDGE DEBUG MESSAGE FOR DRAGGING FROM SELECTION + } else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { + HandlePress(aPresContext, aEvent, aEventStatus); } - } - else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { - HandlePress(aPresContext, aEvent, aEventStatus); } return NS_OK; @@ -768,6 +775,8 @@ nsFrame::HandlePress(nsIPresContext& aPresContext, return NS_OK; } + mDoingSelection = PR_TRUE; + mDidDrag = PR_FALSE; nsCOMPtr shell; nsresult rv = aPresContext.GetShell(getter_AddRefs(shell)); nsInputEvent *inputEvent = (nsInputEvent *)aEvent; @@ -778,18 +787,20 @@ nsFrame::HandlePress(nsIPresContext& aPresContext, PRInt32 startPos = 0; PRUint32 contentOffset = 0; if (NS_SUCCEEDED(GetPosition(aPresContext, acx, aEvent, this, contentOffset, startPos))){ - nsCOMPtr selection; - if (NS_SUCCEEDED(shell->GetSelection(getter_AddRefs(selection)))){ - nsCOMPtr frameselection; - frameselection = do_QueryInterface(selection); - if (frameselection) { + nsIDOMSelection *selection = nsnull; + if (NS_SUCCEEDED(shell->GetSelection(&selection))){ + nsIFrameSelection *frameselection = nsnull; + if (NS_SUCCEEDED(selection->QueryInterface(kIFrameSelection, (void **)&frameselection))) { nsCOMPtr content; rv = GetContent(getter_AddRefs(content)); if (NS_SUCCEEDED( rv )){ - frameselection->SetMouseDownState(PR_TRUE);//not important if it fails here + frameselection->EnableFrameNotification(PR_FALSE); frameselection->TakeFocus(content, startPos + contentOffset, inputEvent->isShift); + frameselection->EnableFrameNotification(PR_TRUE);//prevent cyclic call to reset selection. } + NS_RELEASE(frameselection); } + NS_RELEASE(selection); } //no release } @@ -807,6 +818,8 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext, return NS_OK; } + mDoingSelection = PR_TRUE; + mDidDrag = PR_FALSE; nsCOMPtr shell; nsresult rv = aPresContext.GetShell(getter_AddRefs(shell)); if (NS_SUCCEEDED(rv) && shell) { @@ -823,7 +836,9 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext, nsCOMPtr content; rv = GetContent(getter_AddRefs(content)); if (NS_SUCCEEDED( rv )){ + frameselection->EnableFrameNotification(PR_FALSE); frameselection->TakeFocus(content, startPos + contentOffset, PR_TRUE); //TRUE IS THE DIFFERENCE + frameselection->EnableFrameNotification(PR_TRUE);//prevent cyclic call to reset selection. } NS_RELEASE(frameselection); } @@ -840,6 +855,8 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsIPresContext& aPresContext, nsGUIEvent* aEvent, nsEventStatus& aEventStatus) { + mDoingSelection = PR_FALSE; + NS_IF_RELEASE(gDoc); return NS_OK; } diff --git a/layout/generic/nsFrame.h b/layout/generic/nsFrame.h index ad1cc37e0fc..ba6c6ccc557 100644 --- a/layout/generic/nsFrame.h +++ b/layout/generic/nsFrame.h @@ -350,6 +350,12 @@ protected: nsIFrame* mNextSibling; // singly linked list of frames nsFrameState mState; + /////////////////////////////////// + // Important Selection Variables + /////////////////////////////////// + static PRBool mDoingSelection; + static PRBool mDidDrag; + static PRInt32 mStartPos; // Selection data is valid only from the Mouse Press to the Mouse Release /////////////////////////////////// diff --git a/layout/html/base/src/nsFrame.cpp b/layout/html/base/src/nsFrame.cpp index 589b3614c38..c9586806280 100644 --- a/layout/html/base/src/nsFrame.cpp +++ b/layout/html/base/src/nsFrame.cpp @@ -72,6 +72,7 @@ PRInt32 fTrackerRemoveListMax = 0; nsIContent * fTrackerContentArrayAddList[1024]; PRInt32 fTrackerAddListMax = 0; +nsIDocument *gDoc = nsnull; // [HACK] Foward Declarations void ForceDrawFrame(nsFrame * aFrame); @@ -79,6 +80,8 @@ void ForceDrawFrame(nsFrame * aFrame); static void RefreshContentFrames(nsIPresContext& aPresContext, nsIContent * aStartContent, nsIContent * aEndContent); #endif +PRBool nsFrame::mDoingSelection = PR_FALSE; +PRBool nsFrame::mDidDrag = PR_FALSE; //---------------------------------------------------------------------- @@ -725,32 +728,36 @@ nsFrame::HandleEvent(nsIPresContext& aPresContext, return NS_OK; } -/*i have no idea why this is here keeping incase.. if (DisplaySelection(aPresContext) == PR_FALSE) { if (aEvent->message != NS_MOUSE_LEFT_BUTTON_DOWN) { return NS_OK; } } -*/ - if (aEvent->message == NS_MOUSE_MOVE) { - nsCOMPtr shell; - nsresult rv = aPresContext.GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv)){ - nsCOMPtr selection; - if (NS_SUCCEEDED(shell->GetSelection(getter_AddRefs(selection)))){ - nsCOMPtr frameselection; - frameselection = do_QueryInterface(selection); - if (frameselection) { - PRBool mouseDown = PR_FALSE; - if (NS_SUCCEEDED(frameselection->GetMouseDownState(&mouseDown)) && mouseDown){ - HandleDrag(aPresContext, aEvent, aEventStatus); - } - } - } + + if(nsEventStatus_eConsumeNoDefault != aEventStatus) { + if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { + } + else if (aEvent->message == NS_MOUSE_MOVE && mDoingSelection || + aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) { + // no-op + } + else { + return NS_OK; + } + if (SELECTION_DEBUG) printf("Message: %d-------------------------------------------------------------\n",aEvent->message); + + + if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) { + if (mDoingSelection) { + HandleRelease(aPresContext, aEvent, aEventStatus); + } + } else if (aEvent->message == NS_MOUSE_MOVE) { + mDidDrag = PR_TRUE; + HandleDrag(aPresContext, aEvent, aEventStatus); +//DEBUG MJUDGE DEBUG MESSAGE FOR DRAGGING FROM SELECTION + } else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { + HandlePress(aPresContext, aEvent, aEventStatus); } - } - else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { - HandlePress(aPresContext, aEvent, aEventStatus); } return NS_OK; @@ -768,6 +775,8 @@ nsFrame::HandlePress(nsIPresContext& aPresContext, return NS_OK; } + mDoingSelection = PR_TRUE; + mDidDrag = PR_FALSE; nsCOMPtr shell; nsresult rv = aPresContext.GetShell(getter_AddRefs(shell)); nsInputEvent *inputEvent = (nsInputEvent *)aEvent; @@ -778,18 +787,20 @@ nsFrame::HandlePress(nsIPresContext& aPresContext, PRInt32 startPos = 0; PRUint32 contentOffset = 0; if (NS_SUCCEEDED(GetPosition(aPresContext, acx, aEvent, this, contentOffset, startPos))){ - nsCOMPtr selection; - if (NS_SUCCEEDED(shell->GetSelection(getter_AddRefs(selection)))){ - nsCOMPtr frameselection; - frameselection = do_QueryInterface(selection); - if (frameselection) { + nsIDOMSelection *selection = nsnull; + if (NS_SUCCEEDED(shell->GetSelection(&selection))){ + nsIFrameSelection *frameselection = nsnull; + if (NS_SUCCEEDED(selection->QueryInterface(kIFrameSelection, (void **)&frameselection))) { nsCOMPtr content; rv = GetContent(getter_AddRefs(content)); if (NS_SUCCEEDED( rv )){ - frameselection->SetMouseDownState(PR_TRUE);//not important if it fails here + frameselection->EnableFrameNotification(PR_FALSE); frameselection->TakeFocus(content, startPos + contentOffset, inputEvent->isShift); + frameselection->EnableFrameNotification(PR_TRUE);//prevent cyclic call to reset selection. } + NS_RELEASE(frameselection); } + NS_RELEASE(selection); } //no release } @@ -807,6 +818,8 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext, return NS_OK; } + mDoingSelection = PR_TRUE; + mDidDrag = PR_FALSE; nsCOMPtr shell; nsresult rv = aPresContext.GetShell(getter_AddRefs(shell)); if (NS_SUCCEEDED(rv) && shell) { @@ -823,7 +836,9 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext, nsCOMPtr content; rv = GetContent(getter_AddRefs(content)); if (NS_SUCCEEDED( rv )){ + frameselection->EnableFrameNotification(PR_FALSE); frameselection->TakeFocus(content, startPos + contentOffset, PR_TRUE); //TRUE IS THE DIFFERENCE + frameselection->EnableFrameNotification(PR_TRUE);//prevent cyclic call to reset selection. } NS_RELEASE(frameselection); } @@ -840,6 +855,8 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsIPresContext& aPresContext, nsGUIEvent* aEvent, nsEventStatus& aEventStatus) { + mDoingSelection = PR_FALSE; + NS_IF_RELEASE(gDoc); return NS_OK; } diff --git a/layout/html/base/src/nsFrame.h b/layout/html/base/src/nsFrame.h index ad1cc37e0fc..ba6c6ccc557 100644 --- a/layout/html/base/src/nsFrame.h +++ b/layout/html/base/src/nsFrame.h @@ -350,6 +350,12 @@ protected: nsIFrame* mNextSibling; // singly linked list of frames nsFrameState mState; + /////////////////////////////////// + // Important Selection Variables + /////////////////////////////////// + static PRBool mDoingSelection; + static PRBool mDidDrag; + static PRInt32 mStartPos; // Selection data is valid only from the Mouse Press to the Mouse Release /////////////////////////////////// diff --git a/layout/html/forms/src/nsComboboxControlFrame.cpp b/layout/html/forms/src/nsComboboxControlFrame.cpp index 66e1544a6b5..595d1c43ac5 100644 --- a/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -692,18 +692,30 @@ NS_IMETHODIMP nsComboboxControlFrame::HandleEvent(nsIPresContext& aPresContext, if (nsEventStatus_eConsumeNoDefault == aEventStatus) { return NS_OK; + } - aEventStatus = nsEventStatus_eConsumeNoDefault; + if(nsEventStatus_eConsumeNoDefault != aEventStatus) { + if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { + } else if (aEvent->message == NS_MOUSE_MOVE && mDoingSelection || + aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) { + // no-op + } else { + return NS_OK; + } - if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) { - mArrowStyle = mBtnOutStyleContext; - nsFormControlHelper::ForceDrawFrame(this); - } else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { - mArrowStyle = mBtnPressedStyleContext; - nsFormControlHelper::ForceDrawFrame(this); - MouseClicked(&aPresContext); + aEventStatus = nsEventStatus_eConsumeNoDefault; + + if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) { + mArrowStyle = mBtnOutStyleContext; + nsFormControlHelper::ForceDrawFrame(this); + } else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { + mArrowStyle = mBtnPressedStyleContext; + nsFormControlHelper::ForceDrawFrame(this); + MouseClicked(&aPresContext); + } } + return NS_OK; }