#include "ui/views/controls/textfield/textfield_model.h"
#include <algorithm>
#include <utility>
#include "base/check_op.h"
#include "base/no_destructor.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/current_thread.h"
#include "build/chromeos_buildflags.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "ui/gfx/range/range.h"
#include "ui/gfx/utf16_indexing.h"
#include "ui/views/style/platform_style.h"
namespace {
void order_ranges(std::vector<gfx::Range>* ranges) { … }
size_t adjust_position_for_removals(size_t position,
std::vector<gfx::Range> ranges) { … }
}
namespace views {
namespace internal {
class Edit { … };
class InsertEdit : public Edit { … };
class ReplaceEdit : public Edit { … };
class DeleteEdit : public Edit { … };
}
namespace {
gfx::Range GetFirstEmphasizedRange(const ui::CompositionText& composition) { … }
std::u16string* GetKillBuffer() { … }
void SetKillBuffer(const std::u16string& buffer) { … }
void SelectRangeInCompositionText(gfx::RenderText* render_text,
size_t cursor,
const gfx::Range& range) { … }
}
TextfieldModel::Delegate::~Delegate() = default;
TextfieldModel::TextfieldModel(Delegate* delegate)
: … { … }
TextfieldModel::~TextfieldModel() { … }
bool TextfieldModel::SetText(const std::u16string& new_text,
size_t cursor_position) { … }
void TextfieldModel::Append(const std::u16string& new_text) { … }
bool TextfieldModel::Delete(bool add_to_kill_buffer) { … }
bool TextfieldModel::Backspace(bool add_to_kill_buffer) { … }
size_t TextfieldModel::GetCursorPosition() const { … }
void TextfieldModel::MoveCursor(gfx::BreakType break_type,
gfx::VisualCursorDirection direction,
gfx::SelectionBehavior selection_behavior) { … }
bool TextfieldModel::MoveCursorTo(const gfx::SelectionModel& cursor) { … }
bool TextfieldModel::MoveCursorTo(size_t pos) { … }
bool TextfieldModel::MoveCursorTo(const gfx::Point& point, bool select) { … }
std::u16string TextfieldModel::GetSelectedText() const { … }
void TextfieldModel::SelectRange(const gfx::Range& range, bool primary) { … }
void TextfieldModel::SelectSelectionModel(const gfx::SelectionModel& sel) { … }
void TextfieldModel::SelectAll(bool reversed) { … }
void TextfieldModel::SelectWord() { … }
void TextfieldModel::ClearSelection() { … }
bool TextfieldModel::CanUndo() { … }
bool TextfieldModel::CanRedo() { … }
bool TextfieldModel::Undo() { … }
bool TextfieldModel::Redo() { … }
bool TextfieldModel::Cut() { … }
bool TextfieldModel::Copy() { … }
bool TextfieldModel::Paste() { … }
bool TextfieldModel::Transpose() { … }
bool TextfieldModel::Yank() { … }
bool TextfieldModel::HasSelection(bool primary_only) const { … }
void TextfieldModel::DeleteSelection() { … }
void TextfieldModel::DeletePrimarySelectionAndInsertTextAt(
const std::u16string& new_text,
size_t position) { … }
std::u16string TextfieldModel::GetTextFromRange(const gfx::Range& range) const { … }
void TextfieldModel::GetTextRange(gfx::Range* range) const { … }
void TextfieldModel::SetCompositionText(
const ui::CompositionText& composition) { … }
void TextfieldModel::SetCompositionFromExistingText(const gfx::Range& range) { … }
size_t TextfieldModel::ConfirmCompositionText() { … }
void TextfieldModel::CancelCompositionText() { … }
void TextfieldModel::ClearComposition() { … }
void TextfieldModel::GetCompositionTextRange(gfx::Range* range) const { … }
bool TextfieldModel::HasCompositionText() const { … }
void TextfieldModel::ClearEditHistory() { … }
void TextfieldModel::InsertTextInternal(const std::u16string& new_text,
bool mergeable) { … }
void TextfieldModel::ReplaceTextInternal(const std::u16string& new_text,
bool mergeable) { … }
void TextfieldModel::ClearRedoHistory() { … }
void TextfieldModel::ExecuteAndRecordDelete(std::vector<gfx::Range> ranges,
bool mergeable) { … }
void TextfieldModel::ExecuteAndRecordReplaceSelection(
internal::MergeType merge_type,
const std::u16string& new_text) { … }
void TextfieldModel::ExecuteAndRecordReplace(
internal::MergeType merge_type,
std::vector<gfx::Range> replacement_ranges,
size_t new_cursor_pos,
const std::u16string& new_text,
size_t new_text_start) { … }
void TextfieldModel::ExecuteAndRecordInsert(const std::u16string& new_text,
bool mergeable) { … }
void TextfieldModel::AddOrMergeEditHistory(
std::unique_ptr<internal::Edit> edit) { … }
void TextfieldModel::ModifyText(
const std::vector<gfx::Range>& deletions,
const std::vector<std::u16string>& insertion_texts,
const std::vector<size_t>& insertion_positions,
const gfx::Range& primary_selection,
const std::vector<gfx::Range>& secondary_selections) { … }
void TextfieldModel::SetRenderTextText(const std::u16string& text) { … }
void TextfieldModel::ClearKillBuffer() { … }
}