Bug 1750316 - Replace WordBreaker with WordBreakIteratorUtf16 in nsFind::BreakInBetween(). r=jfkthame

Differential Revision: https://phabricator.services.mozilla.com/D136053
This commit is contained in:
Ting-Yu Lin 2022-01-15 22:09:48 +00:00
Родитель 65c866c33f
Коммит 52080993b1
1 изменённых файлов: 8 добавлений и 21 удалений

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

@ -22,6 +22,7 @@
#include "nsUnicodeProperties.h"
#include "nsCRT.h"
#include "nsRange.h"
#include "nsReadableUtils.h"
#include "nsContentUtils.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/TextEditor.h"
@ -31,8 +32,8 @@
#include "mozilla/dom/HTMLOptionElement.h"
#include "mozilla/dom/HTMLSelectElement.h"
#include "mozilla/dom/Text.h"
#include "mozilla/intl/Segmenter.h"
#include "mozilla/intl/UnicodeProperties.h"
#include "mozilla/intl/WordBreaker.h"
#include "mozilla/StaticPrefs_browser.h"
using namespace mozilla;
@ -520,27 +521,13 @@ char32_t nsFind::DecodeChar(const char16_t* t2b, int32_t* index) const {
}
bool nsFind::BreakInBetween(char32_t x, char32_t y) const {
char16_t text[4];
int32_t textLen;
if (IS_IN_BMP(x)) {
text[0] = (char16_t)x;
textLen = 1;
} else {
text[0] = H_SURROGATE(x);
text[1] = L_SURROGATE(x);
textLen = 2;
}
nsAutoStringN<4> text;
AppendUCS4ToUTF16(x, text);
const uint32_t x16Len = text.Length();
AppendUCS4ToUTF16(y, text);
const int32_t x16Len = textLen;
if (IS_IN_BMP(y)) {
text[textLen] = (char16_t)y;
textLen += 1;
} else {
text[textLen] = H_SURROGATE(y);
text[textLen + 1] = L_SURROGATE(y);
textLen += 2;
}
return intl::WordBreaker::Next(text, textLen, x16Len - 1) == x16Len;
intl::WordBreakIteratorUtf16 iter(text);
return *iter.Seek(x16Len - 1) == x16Len;
}
char32_t nsFind::PeekNextChar(State& aState, bool aAlreadyMatching) const {