#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/text/text_break_iterator.h"
#include <unicode/rbbi.h>
#include <unicode/ubrk.h>
#include <algorithm>
#include <limits>
#include <memory>
#include <utility>
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/notreached.h"
#include "third_party/blink/renderer/platform/text/icu_error.h"
#include "third_party/blink/renderer/platform/text/text_break_iterator_internal_icu.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string_hash.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/thread_specific.h"
namespace blink {
namespace {
class LineBreakIteratorPool final { … };
enum TextContext { … };
constexpr int kTextBufferCapacity = …;
struct UTextWithBuffer { … };
inline int64_t TextPinIndex(int64_t& index, int64_t limit) { … }
inline int64_t TextNativeLength(UText* text) { … }
void TextFixPointer(const UText* source,
UText* destination,
const void*& pointer) { … }
UText* TextClone(UText* destination,
const UText* source,
UBool deep,
UErrorCode* status) { … }
int32_t TextExtract(UText*,
int64_t,
int64_t,
UChar*,
int32_t,
UErrorCode* error_code) { … }
void TextClose(UText* text) { … }
inline TextContext TextGetContext(const UText* text,
int64_t native_index,
UBool forward) { … }
inline TextContext TextLatin1GetCurrentContext(const UText* text) { … }
void TextLatin1MoveInPrimaryContext(UText* text,
int64_t native_index,
int64_t native_length,
UBool forward) { … }
void TextLatin1SwitchToPrimaryContext(UText* text,
int64_t native_index,
int64_t native_length,
UBool forward) { … }
void TextLatin1MoveInPriorContext(UText* text,
int64_t native_index,
int64_t native_length,
UBool forward) { … }
void TextLatin1SwitchToPriorContext(UText* text,
int64_t native_index,
int64_t native_length,
UBool forward) { … }
inline bool TextInChunkOrOutOfRange(UText* text,
int64_t native_index,
int64_t native_length,
UBool forward,
UBool& is_accessible) { … }
UBool TextLatin1Access(UText* text, int64_t native_index, UBool forward) { … }
constexpr struct UTextFuncs kTextLatin1Funcs = …;
void TextInit(UText* text,
const UTextFuncs* funcs,
const void* string,
unsigned length,
const UChar* prior_context,
int prior_context_length) { … }
UText* TextOpenLatin1(UTextWithBuffer* ut_with_buffer,
base::span<const LChar> string,
const UChar* prior_context,
int prior_context_length,
UErrorCode* status) { … }
inline TextContext TextUTF16GetCurrentContext(const UText* text) { … }
void TextUTF16MoveInPrimaryContext(UText* text,
int64_t native_index,
int64_t native_length,
UBool forward) { … }
void TextUTF16SwitchToPrimaryContext(UText* text,
int64_t native_index,
int64_t native_length,
UBool forward) { … }
void TextUTF16MoveInPriorContext(UText* text,
int64_t native_index,
int64_t native_length,
UBool forward) { … }
void TextUTF16SwitchToPriorContext(UText* text,
int64_t native_index,
int64_t native_length,
UBool forward) { … }
UBool TextUTF16Access(UText* text, int64_t native_index, UBool forward) { … }
constexpr struct UTextFuncs kTextUTF16Funcs = …;
UText* TextOpenUTF16(UText* text,
base::span<const UChar> string,
const UChar* prior_context,
int prior_context_length,
UErrorCode* status) { … }
constexpr UText g_empty_text = …;
TextBreakIterator* WordBreakIterator(base::span<const LChar> string) { … }
void SetText16(TextBreakIterator* iter, base::span<const UChar> string) { … }
TextBreakIterator* GetNonSharedCharacterBreakIterator() { … }
}
TextBreakIterator* WordBreakIterator(base::span<const UChar> string) { … }
TextBreakIterator* WordBreakIterator(const String& string,
int start,
int length) { … }
PooledBreakIterator AcquireLineBreakIterator(
base::span<const LChar> string,
const AtomicString& locale,
const UChar* prior_context = nullptr,
unsigned prior_context_length = 0) { … }
PooledBreakIterator AcquireLineBreakIterator(
base::span<const UChar> string,
const AtomicString& locale,
const UChar* prior_context = nullptr,
unsigned prior_context_length = 0) { … }
PooledBreakIterator AcquireLineBreakIterator(StringView string,
const AtomicString& locale) { … }
void ReturnBreakIteratorToPool::operator()(void* ptr) const { … }
NonSharedCharacterBreakIterator::NonSharedCharacterBreakIterator(
const StringView& string)
: … { … }
NonSharedCharacterBreakIterator::NonSharedCharacterBreakIterator(
const UChar* buffer,
unsigned length)
: … { … }
void NonSharedCharacterBreakIterator::CreateIteratorForBuffer(
const UChar* buffer,
unsigned length) { … }
NonSharedCharacterBreakIterator::~NonSharedCharacterBreakIterator() { … }
int NonSharedCharacterBreakIterator::Next() { … }
int NonSharedCharacterBreakIterator::Current() { … }
bool NonSharedCharacterBreakIterator::IsBreak(int offset) const { … }
int NonSharedCharacterBreakIterator::Preceding(int offset) const { … }
int NonSharedCharacterBreakIterator::Following(int offset) const { … }
TextBreakIterator* SentenceBreakIterator(base::span<const UChar> string) { … }
bool IsWordTextBreak(TextBreakIterator* iterator) { … }
TextBreakIterator* CursorMovementIterator(base::span<const UChar> string) { … }
}