mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Fixed bug 46085. We were not firing the select event. This is the second half of the checkin... had some problems with CVS. jst is watching this checkin. r=mjudge.
This commit is contained in:
parent
2c62335810
commit
8e2f31db68
@ -1439,29 +1439,35 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA
|
||||
InvalidateDesiredX();
|
||||
pos.mDirection = eDirNext;
|
||||
mHint = HINTLEFT;//stick to this line
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_LEFT : //no break
|
||||
InvalidateDesiredX();
|
||||
mHint = HINTRIGHT;//stick to opposite of movement
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_DOWN :
|
||||
pos.mAmount = eSelectLine;
|
||||
pos.mDirection = eDirNext;//no break here
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_UP :
|
||||
pos.mAmount = eSelectLine;
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_HOME :
|
||||
InvalidateDesiredX();
|
||||
pos.mAmount = eSelectBeginLine;
|
||||
InvalidateDesiredX();
|
||||
mHint = HINTRIGHT;//stick to opposite of movement
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_END :
|
||||
InvalidateDesiredX();
|
||||
pos.mAmount = eSelectEndLine;
|
||||
InvalidateDesiredX();
|
||||
mHint = HINTLEFT;//stick to this line
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
default :return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -2740,8 +2740,26 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
|
||||
|
||||
if (mViewManager) {
|
||||
// Get the viewport scroller
|
||||
nsIScrollableView* scrollingView;
|
||||
mViewManager->GetRootScrollableView(&scrollingView);
|
||||
nsIScrollableView* rootscrollingView;
|
||||
mViewManager->GetRootScrollableView(&rootscrollingView);
|
||||
|
||||
nsIFrame *viewParent;
|
||||
nsIScrollableView* scrollingView = nsnull;
|
||||
aFrame->GetParentWithView(mPresContext,&viewParent);
|
||||
if (viewParent) {
|
||||
nsIView *view;//XXX COM ptr?
|
||||
viewParent->GetView(mPresContext,&view);
|
||||
if (view) {
|
||||
nsIViewManager *vm = nsnull;
|
||||
view->GetViewManager(vm);
|
||||
if (vm){
|
||||
vm->GetRootScrollableView(&scrollingView);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!scrollingView) {
|
||||
scrollingView = rootscrollingView;
|
||||
}
|
||||
|
||||
if (scrollingView) {
|
||||
nsIView* scrolledView;
|
||||
|
@ -1439,29 +1439,35 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA
|
||||
InvalidateDesiredX();
|
||||
pos.mDirection = eDirNext;
|
||||
mHint = HINTLEFT;//stick to this line
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_LEFT : //no break
|
||||
InvalidateDesiredX();
|
||||
mHint = HINTRIGHT;//stick to opposite of movement
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_DOWN :
|
||||
pos.mAmount = eSelectLine;
|
||||
pos.mDirection = eDirNext;//no break here
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_UP :
|
||||
pos.mAmount = eSelectLine;
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_HOME :
|
||||
InvalidateDesiredX();
|
||||
pos.mAmount = eSelectBeginLine;
|
||||
InvalidateDesiredX();
|
||||
mHint = HINTRIGHT;//stick to opposite of movement
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_END :
|
||||
InvalidateDesiredX();
|
||||
pos.mAmount = eSelectEndLine;
|
||||
InvalidateDesiredX();
|
||||
mHint = HINTLEFT;//stick to this line
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
default :return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1439,29 +1439,35 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA
|
||||
InvalidateDesiredX();
|
||||
pos.mDirection = eDirNext;
|
||||
mHint = HINTLEFT;//stick to this line
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_LEFT : //no break
|
||||
InvalidateDesiredX();
|
||||
mHint = HINTRIGHT;//stick to opposite of movement
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_DOWN :
|
||||
pos.mAmount = eSelectLine;
|
||||
pos.mDirection = eDirNext;//no break here
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_UP :
|
||||
pos.mAmount = eSelectLine;
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_HOME :
|
||||
InvalidateDesiredX();
|
||||
pos.mAmount = eSelectBeginLine;
|
||||
InvalidateDesiredX();
|
||||
mHint = HINTRIGHT;//stick to opposite of movement
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_END :
|
||||
InvalidateDesiredX();
|
||||
pos.mAmount = eSelectEndLine;
|
||||
InvalidateDesiredX();
|
||||
mHint = HINTLEFT;//stick to this line
|
||||
PostReason(nsIDOMSelectionListener::KEYPRESS_REASON);
|
||||
break;
|
||||
default :return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -2740,8 +2740,26 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
|
||||
|
||||
if (mViewManager) {
|
||||
// Get the viewport scroller
|
||||
nsIScrollableView* scrollingView;
|
||||
mViewManager->GetRootScrollableView(&scrollingView);
|
||||
nsIScrollableView* rootscrollingView;
|
||||
mViewManager->GetRootScrollableView(&rootscrollingView);
|
||||
|
||||
nsIFrame *viewParent;
|
||||
nsIScrollableView* scrollingView = nsnull;
|
||||
aFrame->GetParentWithView(mPresContext,&viewParent);
|
||||
if (viewParent) {
|
||||
nsIView *view;//XXX COM ptr?
|
||||
viewParent->GetView(mPresContext,&view);
|
||||
if (view) {
|
||||
nsIViewManager *vm = nsnull;
|
||||
view->GetViewManager(vm);
|
||||
if (vm){
|
||||
vm->GetRootScrollableView(&scrollingView);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!scrollingView) {
|
||||
scrollingView = rootscrollingView;
|
||||
}
|
||||
|
||||
if (scrollingView) {
|
||||
nsIView* scrolledView;
|
||||
|
@ -203,7 +203,6 @@ protected:
|
||||
PRPackedBool mKnowSelectionCollapsed;
|
||||
|
||||
PRPackedBool mFirstDoOfFirstUndo;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -306,6 +305,42 @@ nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsIDOMSelectio
|
||||
if (!mFrame || !aDoc || !aSel || NS_FAILED(aSel->GetIsCollapsed(&collapsed)))
|
||||
return NS_OK;
|
||||
|
||||
// Fire the select event
|
||||
// The specs don't exactly say when we should fire the select event.
|
||||
// IE: Whenever you add/remove a character to/from the selection. Also
|
||||
// if you get to the end of the text field you will get new event for each
|
||||
// keypress or a continuous stream of events if you use the mouse. IE will
|
||||
// fire select event when the selection collapses to nothing if you are holding down
|
||||
// the shift or mouse button.
|
||||
// Mozilla: If we have non-empty selection we will fire a new event for each
|
||||
// keypress (or mouseup) if the selection changed. Mozilla will never
|
||||
// create an event if the selection collapses to nothing.
|
||||
if (!collapsed && ((aReason & MOUSEUP_REASON) || (aReason & KEYPRESS_REASON))) {
|
||||
nsCOMPtr<nsIContent> content;
|
||||
mFrame->GetFormContent(*getter_AddRefs(content));
|
||||
if (content) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsGUIEvent event;
|
||||
event.eventStructType = NS_GUI_EVENT;
|
||||
event.widget = nsnull;
|
||||
event.message = NS_FORM_SELECTED;
|
||||
event.flags = NS_EVENT_FLAG_INIT;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (NS_SUCCEEDED(content->GetDocument(*getter_AddRefs(doc)))) {
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIPresShell> presShell = dont_AddRef(doc->GetShellAt(0));
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
if (NS_SUCCEEDED(presShell->GetPresContext(getter_AddRefs(context)))&& context) {
|
||||
content->HandleDOMEvent(context, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if the collapsed state did not change, don't fire notifications
|
||||
if (mKnowSelectionCollapsed && collapsed == mSelectionWasCollapsed)
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user