Bug 642823 - Make the behavior of nsISelection::Modify consistent for word selection across platforms by not eating spaces on any platform; r=roc

This commit is contained in:
Ehsan Akhgari 2011-03-20 15:49:06 -04:00
Родитель 944f090fc9
Коммит 93de29b2e6
3 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -5498,6 +5498,17 @@ nsIFrame::PeekOffset(nsPeekOffsetStruct* aPos)
break;
}
case eSelectWordNoSpace:
// eSelectWordNoSpace means that we should not be eating any whitespace when
// moving to the adjacent word. This means that we should set aPos->
// mWordMovementType to eEndWord if we're moving forwards, and to eStartWord
// if we're moving backwards.
if (aPos->mDirection == eDirPrevious) {
aPos->mWordMovementType = eStartWord;
} else {
aPos->mWordMovementType = eEndWord;
}
// Intentionally fall through the eSelectWord case.
case eSelectWord:
{
// wordSelectEatSpace means "are we looking for a boundary between whitespace

Просмотреть файл

@ -306,7 +306,10 @@ enum nsSelectionAmount {
eSelectBeginLine = 4,
eSelectEndLine = 5,
eSelectNoAmount = 6, // just bounce back current offset.
eSelectParagraph = 7 // select a "paragraph"
eSelectParagraph = 7, // select a "paragraph"
eSelectWordNoSpace = 8 // select a "word" without selecting the following
// space, no matter what the default platform
// behavior is
};
enum nsDirection {

Просмотреть файл

@ -5861,7 +5861,7 @@ nsTypedSelection::Modify(const nsAString& aAlter, const nsAString& aDirection,
(PRUint32) nsIDOMKeyEvent::DOM_VK_LEFT;
}
else if (aGranularity.LowerCaseEqualsLiteral("word")) {
amount = eSelectWord;
amount = eSelectWordNoSpace;
keycode = forward ? (PRUint32) nsIDOMKeyEvent::DOM_VK_RIGHT :
(PRUint32) nsIDOMKeyEvent::DOM_VK_LEFT;
}