зеркало из https://github.com/mozilla/gecko-dev.git
Bug 596333 - Part 2: Make ContainsDOMWordSeparator greedy; r=bz a=blocking-betaN+
This commit is contained in:
Родитель
b37718301c
Коммит
444c5cd862
|
@ -94,7 +94,7 @@ function runTest() {
|
||||||
gMisspeltWords = ["workd"];
|
gMisspeltWords = ["workd"];
|
||||||
edit.value = "";
|
edit.value = "";
|
||||||
append("workd");
|
append("workd");
|
||||||
paste(" x");
|
paste(" x");
|
||||||
SimpleTest.executeSoon(function() {
|
SimpleTest.executeSoon(function() {
|
||||||
is(isSpellingCheckOk(), true, "Misspelling is accounted for after pasting.");
|
is(isSpellingCheckOk(), true, "Misspelling is accounted for after pasting.");
|
||||||
|
|
||||||
|
|
|
@ -459,8 +459,10 @@ FindPrevNode(nsIDOMNode* aNode, nsIDOMNode* aRoot)
|
||||||
/**
|
/**
|
||||||
* Check if there's a DOM word separator before aBeforeOffset in this node.
|
* Check if there's a DOM word separator before aBeforeOffset in this node.
|
||||||
* Always returns PR_TRUE if it's a BR element.
|
* Always returns PR_TRUE if it's a BR element.
|
||||||
* aSeparatorOffset is set to the index of the last separator if any is found
|
* aSeparatorOffset is set to the index of the first character in the last
|
||||||
* (0 for BR elements).
|
* separator if any is found (0 for BR elements).
|
||||||
|
*
|
||||||
|
* This function does not modify aSeparatorOffset when it returns false.
|
||||||
*/
|
*/
|
||||||
static PRBool
|
static PRBool
|
||||||
ContainsDOMWordSeparator(nsIDOMNode* aNode, PRInt32 aBeforeOffset,
|
ContainsDOMWordSeparator(nsIDOMNode* aNode, PRInt32 aBeforeOffset,
|
||||||
|
@ -480,6 +482,14 @@ ContainsDOMWordSeparator(nsIDOMNode* aNode, PRInt32 aBeforeOffset,
|
||||||
NS_ASSERTION(textFragment, "Where is our text?");
|
NS_ASSERTION(textFragment, "Where is our text?");
|
||||||
for (PRInt32 i = NS_MIN(aBeforeOffset, PRInt32(textFragment->GetLength())) - 1; i >= 0; --i) {
|
for (PRInt32 i = NS_MIN(aBeforeOffset, PRInt32(textFragment->GetLength())) - 1; i >= 0; --i) {
|
||||||
if (IsDOMWordSeparator(textFragment->CharAt(i))) {
|
if (IsDOMWordSeparator(textFragment->CharAt(i))) {
|
||||||
|
// Be greedy, find as many separators as we can
|
||||||
|
for (PRInt32 j = i - 1; j >= 0; --j) {
|
||||||
|
if (IsDOMWordSeparator(textFragment->CharAt(j))) {
|
||||||
|
i = j;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
*aSeparatorOffset = i;
|
*aSeparatorOffset = i;
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче