зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1672269 - NextWord shouldn't return empty. r=jfkthame
After landing bug 425915, we use NextWord instead of BreakInBetween. NextWord is possible to return empty string (offset equals to current position). So it shouldn't return empty string. Differential Revision: https://phabricator.services.mozilla.com/D94266
This commit is contained in:
Родитель
61a83c3467
Коммит
fdfea00747
|
@ -200,7 +200,7 @@ int32_t WordBreaker::NextWord(const char16_t* aText, uint32_t aLen,
|
|||
AutoTArray<uint8_t, 256> breakBefore;
|
||||
breakBefore.SetLength(aLen - aPos);
|
||||
NS_GetComplexLineBreaks(aText + aPos, aLen - aPos, breakBefore.Elements());
|
||||
uint32_t i = 0;
|
||||
uint32_t i = 1;
|
||||
while (i < cur - aPos && !breakBefore[i]) {
|
||||
i++;
|
||||
}
|
||||
|
@ -213,5 +213,6 @@ int32_t WordBreaker::NextWord(const char16_t* aText, uint32_t aLen,
|
|||
return NS_WORDBREAKER_NEED_MORE_TEXT;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(cur != aPos);
|
||||
return cur;
|
||||
}
|
||||
|
|
|
@ -252,6 +252,20 @@ void TestFindWordBreakFromPosition(uint32_t fragN, uint32_t offset,
|
|||
<< "FindWordBreakFromPosition(" << fragN << ", " << offset << ")";
|
||||
}
|
||||
|
||||
void TestNextWordBreakWithComplexLanguage() {
|
||||
RefPtr<mozilla::intl::WordBreaker> wbk = mozilla::intl::WordBreaker::Create();
|
||||
nsString fragText(u"\u0e40\u0e1b\u0e47\u0e19\u0e19\u0e31\u0e01");
|
||||
|
||||
int32_t offset = 0;
|
||||
while (offset != NS_WORDBREAKER_NEED_MORE_TEXT) {
|
||||
int32_t newOffset =
|
||||
wbk->NextWord(fragText.get(), fragText.Length(), offset);
|
||||
ASSERT_NE(offset, newOffset);
|
||||
offset = newOffset;
|
||||
}
|
||||
ASSERT_TRUE(true);
|
||||
}
|
||||
|
||||
TEST(LineBreak, WordBreakUsage)
|
||||
{
|
||||
TestPrintWordWithBreak();
|
||||
|
@ -265,4 +279,5 @@ TEST(LineBreak, WordBreakUsage)
|
|||
TestFindWordBreakFromPosition(3, 8, "ernationalization");
|
||||
TestFindWordBreakFromPosition(4, 6, " ");
|
||||
TestFindWordBreakFromPosition(4, 7, "work");
|
||||
TestNextWordBreakWithComplexLanguage();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче