#include "third_party/blink/renderer/core/editing/ime/edit_context.h"
#include "base/containers/contains.h"
#include "base/ranges/algorithm.h"
#include "base/trace_event/trace_event.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_range.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_edit_context_init.h"
#include "third_party/blink/renderer/core/css/css_color.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/editing/ime/character_bounds_update_event.h"
#include "third_party/blink/renderer/core/editing/ime/input_method_controller.h"
#include "third_party/blink/renderer/core/editing/ime/text_format.h"
#include "third_party/blink/renderer/core/editing/ime/text_format_update_event.h"
#include "third_party/blink/renderer/core/editing/ime/text_update_event.h"
#include "third_party/blink/renderer/core/editing/state_machines/backward_grapheme_boundary_state_machine.h"
#include "third_party/blink/renderer/core/editing/state_machines/forward_grapheme_boundary_state_machine.h"
#include "third_party/blink/renderer/core/event_target_names.h"
#include "third_party/blink/renderer/core/events/composition_event.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/text/text_boundaries.h"
#include "third_party/blink/renderer/platform/wtf/decimal.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "ui/base/ime/ime_text_span.h"
#include "ui/gfx/geometry/rect_conversions.h"
namespace blink {
EditContext::EditContext(ScriptState* script_state, const EditContextInit* dict)
: … { … }
EditContext* EditContext::Create(ScriptState* script_state,
const EditContextInit* dict) { … }
EditContext::~EditContext() = default;
const AtomicString& EditContext::InterfaceName() const { … }
ExecutionContext* EditContext::GetExecutionContext() const { … }
LocalDOMWindow* EditContext::DomWindow() const { … }
bool EditContext::HasPendingActivity() const { … }
InputMethodController& EditContext::GetInputMethodController() const { … }
bool EditContext::IsEditContextActive() const { … }
ui::mojom::VirtualKeyboardVisibilityRequest
EditContext::GetLastVirtualKeyboardVisibilityRequest() const { … }
void EditContext::SetVirtualKeyboardVisibilityRequest(
ui::mojom::VirtualKeyboardVisibilityRequest vk_visibility_request) { … }
void EditContext::DispatchCompositionEndEvent(const String& text) { … }
bool EditContext::DispatchCompositionStartEvent(const String& text) { … }
void EditContext::DispatchCharacterBoundsUpdateEvent(uint32_t range_start,
uint32_t range_end) { … }
void EditContext::DispatchTextUpdateEvent(const String& text,
uint32_t update_range_start,
uint32_t update_range_end,
uint32_t new_selection_start,
uint32_t new_selection_end) { … }
void EditContext::DispatchTextFormatEvent(
const WebVector<ui::ImeTextSpan>& ime_text_spans) { … }
void EditContext::Focus() { … }
void EditContext::Blur() { … }
void EditContext::updateSelection(uint32_t start,
uint32_t end,
ExceptionState& exception_state) { … }
void EditContext::updateCharacterBounds(
unsigned long range_start,
HeapVector<Member<DOMRect>>& character_bounds) { … }
void EditContext::updateControlBounds(DOMRect* control_bounds) { … }
void EditContext::updateSelectionBounds(DOMRect* selection_bounds) { … }
void EditContext::updateText(uint32_t start,
uint32_t end,
const String& new_text,
ExceptionState& exception_state) { … }
String EditContext::text() const { … }
uint32_t EditContext::selectionStart() const { … }
uint32_t EditContext::selectionEnd() const { … }
uint32_t EditContext::characterBoundsRangeStart() const { … }
const HeapVector<Member<HTMLElement>>& EditContext::attachedElements() { … }
const HeapVector<Member<DOMRect>> EditContext::characterBounds() { … }
void EditContext::GetLayoutBounds(gfx::Rect* control_bounds,
gfx::Rect* selection_bounds) { … }
bool EditContext::SetComposition(
const WebString& text,
const WebVector<ui::ImeTextSpan>& ime_text_spans,
const WebRange& replacement_range,
int selection_start,
int selection_end) { … }
void EditContext::ClearCompositionState() { … }
uint32_t EditContext::OrderedSelectionStart() const { … }
uint32_t EditContext::OrderedSelectionEnd() const { … }
bool EditContext::SetCompositionFromExistingText(
int composition_start,
int composition_end,
const WebVector<ui::ImeTextSpan>& ime_text_spans) { … }
void EditContext::CancelComposition() { … }
bool EditContext::InsertText(const WebString& text) { … }
void EditContext::DeleteCurrentSelection() { … }
template <typename StateMachine>
int FindNextBoundaryOffset(const String& str, int current);
void EditContext::DeleteBackward() { … }
void EditContext::DeleteForward() { … }
void EditContext::DeleteWordBackward() { … }
void EditContext::DeleteWordForward() { … }
bool EditContext::CommitText(const WebString& text,
const WebVector<ui::ImeTextSpan>& ime_text_spans,
const WebRange& replacement_range,
int relative_caret_position) { … }
bool EditContext::FinishComposingText(
ConfirmCompositionBehavior selection_behavior) { … }
void EditContext::ExtendSelectionAndDelete(int before, int after) { … }
void EditContext::DeleteSurroundingText(int before, int after) { … }
void EditContext::SetSelection(int start,
int end,
bool dispatch_text_update_event) { … }
void EditContext::AttachElement(HTMLElement* element_to_attach) { … }
void EditContext::DetachElement(HTMLElement* element_to_detach) { … }
WebTextInputInfo EditContext::TextInputInfo() { … }
WebRange EditContext::CompositionRange() const { … }
bool EditContext::GetCompositionCharacterBounds(WebVector<gfx::Rect>& bounds) { … }
bool EditContext::FirstRectForCharacterRange(uint32_t location,
uint32_t length,
gfx::Rect& rect_in_viewport) { … }
bool EditContext::HasValidCompositionBounds() const { … }
WebRange EditContext::GetSelectionOffsets() const { … }
void EditContext::Trace(Visitor* visitor) const { … }
}