зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1750316 - Replace WordBreaker with WordBreakIteratorUtf16 in nsFind::BreakInBetween(). r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D136053
This commit is contained in:
Родитель
65c866c33f
Коммит
52080993b1
|
@ -22,6 +22,7 @@
|
||||||
#include "nsUnicodeProperties.h"
|
#include "nsUnicodeProperties.h"
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsRange.h"
|
#include "nsRange.h"
|
||||||
|
#include "nsReadableUtils.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "mozilla/DebugOnly.h"
|
#include "mozilla/DebugOnly.h"
|
||||||
#include "mozilla/TextEditor.h"
|
#include "mozilla/TextEditor.h"
|
||||||
|
@ -31,8 +32,8 @@
|
||||||
#include "mozilla/dom/HTMLOptionElement.h"
|
#include "mozilla/dom/HTMLOptionElement.h"
|
||||||
#include "mozilla/dom/HTMLSelectElement.h"
|
#include "mozilla/dom/HTMLSelectElement.h"
|
||||||
#include "mozilla/dom/Text.h"
|
#include "mozilla/dom/Text.h"
|
||||||
|
#include "mozilla/intl/Segmenter.h"
|
||||||
#include "mozilla/intl/UnicodeProperties.h"
|
#include "mozilla/intl/UnicodeProperties.h"
|
||||||
#include "mozilla/intl/WordBreaker.h"
|
|
||||||
#include "mozilla/StaticPrefs_browser.h"
|
#include "mozilla/StaticPrefs_browser.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
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 {
|
bool nsFind::BreakInBetween(char32_t x, char32_t y) const {
|
||||||
char16_t text[4];
|
nsAutoStringN<4> text;
|
||||||
int32_t textLen;
|
AppendUCS4ToUTF16(x, text);
|
||||||
if (IS_IN_BMP(x)) {
|
const uint32_t x16Len = text.Length();
|
||||||
text[0] = (char16_t)x;
|
AppendUCS4ToUTF16(y, text);
|
||||||
textLen = 1;
|
|
||||||
} else {
|
|
||||||
text[0] = H_SURROGATE(x);
|
|
||||||
text[1] = L_SURROGATE(x);
|
|
||||||
textLen = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int32_t x16Len = textLen;
|
intl::WordBreakIteratorUtf16 iter(text);
|
||||||
if (IS_IN_BMP(y)) {
|
return *iter.Seek(x16Len - 1) == x16Len;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char32_t nsFind::PeekNextChar(State& aState, bool aAlreadyMatching) const {
|
char32_t nsFind::PeekNextChar(State& aState, bool aAlreadyMatching) const {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче