#include "content/browser/renderer_host/text_input_manager.h"
#include <algorithm>
#include "base/numerics/clamped_math.h"
#include "base/observer_list.h"
#include "base/strings/string_number_conversions.h"
#include "build/build_config.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/range/range.h"
namespace content {
namespace {
bool ShouldUpdateTextInputState(const ui::mojom::TextInputState& old_state,
const ui::mojom::TextInputState& new_state) { … }
}
TextInputManager::TextInputManager() : … { … }
TextInputManager::~TextInputManager() { … }
RenderWidgetHostImpl* TextInputManager::GetActiveWidget() const { … }
const ui::mojom::TextInputState* TextInputManager::GetTextInputState() const { … }
gfx::Range TextInputManager::GetAutocorrectRange() const { … }
std::optional<ui::GrammarFragment> TextInputManager::GetGrammarFragment(
gfx::Range range) const { … }
const TextInputManager::SelectionRegion* TextInputManager::GetSelectionRegion(
RenderWidgetHostViewBase* view) const { … }
const TextInputManager::CompositionRangeInfo*
TextInputManager::GetCompositionRangeInfo() const { … }
const TextInputManager::TextSelection* TextInputManager::GetTextSelection(
RenderWidgetHostViewBase* view) const { … }
const std::optional<gfx::Rect> TextInputManager::GetTextControlBounds() const { … }
const std::optional<gfx::Rect> TextInputManager::GetTextSelectionBounds()
const { … }
void TextInputManager::UpdateTextInputState(
RenderWidgetHostViewBase* view,
const ui::mojom::TextInputState& text_input_state) { … }
void TextInputManager::ImeCancelComposition(RenderWidgetHostViewBase* view) { … }
void TextInputManager::SelectionBoundsChanged(
RenderWidgetHostViewBase* view,
const gfx::Rect& anchor_rect,
base::i18n::TextDirection anchor_dir,
const gfx::Rect& focus_rect,
base::i18n::TextDirection focus_dir,
const gfx::Rect& bounding_box,
bool is_anchor_first) { … }
void TextInputManager::NotifySelectionBoundsChanged(
RenderWidgetHostViewBase* view) { … }
void TextInputManager::ImeCompositionRangeChanged(
RenderWidgetHostViewBase* view,
const gfx::Range& range,
const std::optional<std::vector<gfx::Rect>>& character_bounds,
const std::optional<std::vector<gfx::Rect>>& line_bounds) { … }
void TextInputManager::SelectionChanged(RenderWidgetHostViewBase* view,
const std::u16string& text,
size_t offset,
const gfx::Range& range) { … }
void TextInputManager::Register(RenderWidgetHostViewBase* view) { … }
void TextInputManager::Unregister(RenderWidgetHostViewBase* view) { … }
bool TextInputManager::IsRegistered(RenderWidgetHostViewBase* view) const { … }
void TextInputManager::AddObserver(Observer* observer) { … }
void TextInputManager::RemoveObserver(Observer* observer) { … }
bool TextInputManager::HasObserver(Observer* observer) const { … }
size_t TextInputManager::GetRegisteredViewsCountForTesting() { … }
ui::TextInputType TextInputManager::GetTextInputTypeForViewForTesting(
RenderWidgetHostViewBase* view) { … }
const gfx::Range* TextInputManager::GetCompositionRangeForTesting() const { … }
void TextInputManager::NotifyObserversAboutInputStateUpdate(
RenderWidgetHostViewBase* updated_view,
bool did_update_state) { … }
TextInputManager::SelectionRegion::SelectionRegion() = default;
TextInputManager::SelectionRegion::SelectionRegion(
const SelectionRegion& other) = default;
TextInputManager::SelectionRegion& TextInputManager::SelectionRegion::operator=(
const SelectionRegion& other) = default;
TextInputManager::CompositionRangeInfo::CompositionRangeInfo() = default;
TextInputManager::CompositionRangeInfo::CompositionRangeInfo(
const CompositionRangeInfo& other) = default;
TextInputManager::CompositionRangeInfo::~CompositionRangeInfo() = default;
TextInputManager::TextSelection::TextSelection()
: … { … }
TextInputManager::TextSelection::TextSelection(const TextSelection& other) =
default;
TextInputManager::TextSelection::~TextSelection() = default;
void TextInputManager::TextSelection::SetSelection(const std::u16string& text,
size_t offset,
const gfx::Range& range) { … }
}