approved by Dagley. fixes for CTRL_LEFT and CTRL_RIGHT navigation and wrapping

git-svn-id: svn://10.0.0.236/trunk@48797 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mjudge%netscape.com
1999-09-22 05:56:44 +00:00
parent 0eaf6f0e91
commit e27650740e
5 changed files with 44 additions and 27 deletions

View File

@@ -784,7 +784,7 @@ nsRangeList::HandleKeyEvent(nsGUIEvent *aGuiEvent)
weakNodeUsed = mDomSelections[SELECTION_NORMAL]->FetchAnchorNode();
}
result = mDomSelections[SELECTION_NORMAL]->Collapse(weakNodeUsed,offsetused);
return NS_OK;
} break;
case nsIDOMUIEvent::DOM_VK_RIGHT :
case nsIDOMUIEvent::DOM_VK_DOWN : {
@@ -797,12 +797,12 @@ nsRangeList::HandleKeyEvent(nsGUIEvent *aGuiEvent)
weakNodeUsed = mDomSelections[SELECTION_NORMAL]->FetchFocusNode();
}
result = mDomSelections[SELECTION_NORMAL]->Collapse(weakNodeUsed,offsetused);
return NS_OK;
} break;
}
if (keyEvent->keyCode == nsIDOMUIEvent::DOM_VK_UP || keyEvent->keyCode == nsIDOMUIEvent::DOM_VK_DOWN)
SetDesiredX(desiredX);
return NS_OK;
// if (keyEvent->keyCode == nsIDOMUIEvent::DOM_VK_UP || keyEvent->keyCode == nsIDOMUIEvent::DOM_VK_DOWN)
// SetDesiredX(desiredX);
}
offsetused = mDomSelections[SELECTION_NORMAL]->FetchFocusOffset();
@@ -816,7 +816,6 @@ nsRangeList::HandleKeyEvent(nsGUIEvent *aGuiEvent)
pos.SetData(mTracker, desiredX, amount, eDirPrevious, offsetused, PR_FALSE,PR_TRUE);
switch (keyEvent->keyCode){
case nsIDOMUIEvent::DOM_VK_RIGHT :
InvalidateDesiredX();
pos.mDirection = eDirNext;
mHint = HINTLEFT;//stick to this line
break;

View File

@@ -2172,8 +2172,11 @@ nsFrame::PeekOffset(nsPeekOffsetStruct *aPos)
if ((aPos->mDirection == eDirNext && lastFrame == this)
||(aPos->mDirection == eDirPrevious && firstFrame == this))
{
aPos->mPreferLeft = (PRBool)!(aPos->mPreferLeft);//drift to other side
aPos->mAmount = eSelectNoAmount;
if (aPos->mAmount != eSelectWord)
{
aPos->mPreferLeft = (PRBool)!(aPos->mPreferLeft);//drift to other side
aPos->mAmount = eSelectNoAmount;
}
}
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),LEAF,this);

View File

@@ -2089,6 +2089,7 @@ nsTextFrame::PeekOffset(nsPeekOffsetStruct *aPos)
case eSelectNoAmount:
{
aPos->mContentOffset = aPos->mStartOffset;
result = NS_OK;
}
break;
@@ -2181,19 +2182,24 @@ nsTextFrame::PeekOffset(nsPeekOffsetStruct *aPos)
if ((aPos->mEatingWS && !isWhitespace) || !aPos->mEatingWS){
aPos->mContentOffset = aPos->mStartOffset - contentLen;
//check for whitespace next.
if (aPos->mContentOffset > mContentOffset)
if (isWhitespace && aPos->mContentOffset <= mContentOffset)
{
keepSearching = PR_FALSE;//reached the beginning of a word
aPos->mEatingWS = !isWhitespace;//nowhite space, just eat chars.
while (isWhitespace && tx.GetPrevWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
aPos->mContentOffset -= contentLen;
aPos->mEatingWS = PR_FALSE;
aPos->mEatingWS = PR_FALSE;//if no real word then
}
keepSearching = aPos->mContentOffset <= mContentOffset;
if (!isWhitespace){
if (!keepSearching)
found = PR_TRUE;
else{
aPos->mEatingWS = !isWhitespace;//nowhite space, just eat chars.
while (isWhitespace && tx.GetPrevWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
aPos->mContentOffset -= contentLen;
aPos->mEatingWS = PR_TRUE;
}
keepSearching = aPos->mContentOffset <= mContentOffset;
if (!isWhitespace){
if (!keepSearching)
found = PR_TRUE;
else
aPos->mEatingWS = PR_TRUE;
}
}
}
else {

View File

@@ -2172,8 +2172,11 @@ nsFrame::PeekOffset(nsPeekOffsetStruct *aPos)
if ((aPos->mDirection == eDirNext && lastFrame == this)
||(aPos->mDirection == eDirPrevious && firstFrame == this))
{
aPos->mPreferLeft = (PRBool)!(aPos->mPreferLeft);//drift to other side
aPos->mAmount = eSelectNoAmount;
if (aPos->mAmount != eSelectWord)
{
aPos->mPreferLeft = (PRBool)!(aPos->mPreferLeft);//drift to other side
aPos->mAmount = eSelectNoAmount;
}
}
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),LEAF,this);

View File

@@ -2089,6 +2089,7 @@ nsTextFrame::PeekOffset(nsPeekOffsetStruct *aPos)
case eSelectNoAmount:
{
aPos->mContentOffset = aPos->mStartOffset;
result = NS_OK;
}
break;
@@ -2181,19 +2182,24 @@ nsTextFrame::PeekOffset(nsPeekOffsetStruct *aPos)
if ((aPos->mEatingWS && !isWhitespace) || !aPos->mEatingWS){
aPos->mContentOffset = aPos->mStartOffset - contentLen;
//check for whitespace next.
if (aPos->mContentOffset > mContentOffset)
if (isWhitespace && aPos->mContentOffset <= mContentOffset)
{
keepSearching = PR_FALSE;//reached the beginning of a word
aPos->mEatingWS = !isWhitespace;//nowhite space, just eat chars.
while (isWhitespace && tx.GetPrevWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
aPos->mContentOffset -= contentLen;
aPos->mEatingWS = PR_FALSE;
aPos->mEatingWS = PR_FALSE;//if no real word then
}
keepSearching = aPos->mContentOffset <= mContentOffset;
if (!isWhitespace){
if (!keepSearching)
found = PR_TRUE;
else{
aPos->mEatingWS = !isWhitespace;//nowhite space, just eat chars.
while (isWhitespace && tx.GetPrevWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
aPos->mContentOffset -= contentLen;
aPos->mEatingWS = PR_TRUE;
}
keepSearching = aPos->mContentOffset <= mContentOffset;
if (!isWhitespace){
if (!keepSearching)
found = PR_TRUE;
else
aPos->mEatingWS = PR_TRUE;
}
}
}
else {