chromium/third_party/blink/renderer/platform/text/text_break_iterator_icu.cc

/*
 * Copyright (C) 2006 Lars Knoll <[email protected]>
 * Copyright (C) 2007, 2011, 2012 Apple Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 */

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#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) {}

// Relocate pointer from source into destination as required.
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() {}

}  // namespace

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) {}

}  // namespace blink