For caret browsing, initialize the caret position to the top of the page (if there isn't already a selection). bug=144000 r+sr=bzbarsky

This commit is contained in:
uriber@gmail.com 2007-04-14 09:51:20 -07:00
parent b813fa7847
commit ac620263e8

View File

@ -1211,6 +1211,8 @@ protected:
ReflowCountMgr * mReflowCountMgr; ReflowCountMgr * mReflowCountMgr;
#endif #endif
nsresult CompleteMoveInner(PRBool aForward, PRBool aExtend, PRBool sScrollIntoView);
private: private:
PRBool InZombieDocument(nsIContent *aContent); PRBool InZombieDocument(nsIContent *aContent);
@ -3037,6 +3039,12 @@ PresShell::CompleteScroll(PRBool aForward)
NS_IMETHODIMP NS_IMETHODIMP
PresShell::CompleteMove(PRBool aForward, PRBool aExtend) PresShell::CompleteMove(PRBool aForward, PRBool aExtend)
{
return CompleteMoveInner(aForward, aExtend, PR_TRUE);
}
nsresult
PresShell::CompleteMoveInner(PRBool aForward, PRBool aExtend, PRBool aScrollIntoView)
{ {
nsIScrollableView *scrollableView; nsIScrollableView *scrollableView;
if (!mViewManager) if (!mViewManager)
@ -3071,7 +3079,14 @@ PresShell::CompleteMove(PRBool aForward, PRBool aExtend)
nsPeekOffsetStruct pos = frame->GetExtremeCaretPosition(!aForward); nsPeekOffsetStruct pos = frame->GetExtremeCaretPosition(!aForward);
mSelection->HandleClick(pos.mResultContent ,pos.mContentOffset ,pos.mContentOffset/*End*/ ,aExtend, PR_FALSE, aForward); mSelection->HandleClick(pos.mResultContent ,pos.mContentOffset ,pos.mContentOffset/*End*/ ,aExtend, PR_FALSE, aForward);
return ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL, nsISelectionController::SELECTION_FOCUS_REGION, PR_TRUE);
if (aScrollIntoView) {
result = ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL,
nsISelectionController::SELECTION_FOCUS_REGION, PR_TRUE);
if (NS_FAILED(result))
return result;
}
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -4401,6 +4416,18 @@ PresShell::UnsuppressAndInvalidate()
if (mViewManager) if (mViewManager)
mViewManager->SynthesizeMouseMove(PR_FALSE); mViewManager->SynthesizeMouseMove(PR_FALSE);
// If there is no selection, create a collapsed selection at the top of the document.
if (mSelection) {
nsISelection* domSelection = mSelection->
GetSelection(nsISelectionController::SELECTION_NORMAL);
if (domSelection) {
PRInt32 rangeCount;
domSelection->GetRangeCount(&rangeCount);
if (rangeCount == 0)
CompleteMoveInner(PR_FALSE, PR_FALSE, PR_FALSE);
}
}
} }
NS_IMETHODIMP NS_IMETHODIMP