1  /*
2   * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
3   * Licensed under the Apache License, Version 2.0 (the "License");
4   * you may not use this file except in compliance with the License.
5   * You may obtain a copy of the License at
6   *
7   *     http://www.apache.org/licenses/LICENSE-2.0
8   *
9   * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  
16  #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_FIELD_TEXT_FIELD_PATTERN_H
17  #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_FIELD_TEXT_FIELD_PATTERN_H
18  
19  #include <cstdint>
20  #include <optional>
21  #include <queue>
22  #include <string>
23  #include <utility>
24  #include <vector>
25  
26  #include "base/geometry/ng/offset_t.h"
27  #include "base/geometry/ng/rect_t.h"
28  #include "base/geometry/rect.h"
29  #include "base/memory/referenced.h"
30  #include "base/mousestyle/mouse_style.h"
31  #include "base/view_data/view_data_wrap.h"
32  #include "core/common/ai/ai_write_adapter.h"
33  #include "base/view_data/hint_to_type_wrap.h"
34  #include "core/common/autofill/auto_fill_trigger_state_holder.h"
35  #include "core/common/clipboard/clipboard.h"
36  #include "core/common/ime/text_edit_controller.h"
37  #include "core/common/ime/text_input_action.h"
38  #include "core/common/ime/text_input_client.h"
39  #include "core/common/ime/text_input_configuration.h"
40  #include "core/common/ime/text_input_connection.h"
41  #include "core/common/ime/text_input_formatter.h"
42  #include "core/common/ime/text_input_proxy.h"
43  #include "core/common/ime/text_input_type.h"
44  #include "core/common/ime/text_selection.h"
45  #include "core/components/text_field/textfield_theme.h"
46  #include "core/components_ng/base/frame_node.h"
47  #include "core/components_ng/image_provider/image_loading_context.h"
48  #include "core/components_ng/pattern/overlay/keyboard_base_pattern.h"
49  #include "core/components_ng/pattern/pattern.h"
50  #include "core/components_ng/pattern/scroll/inner/scroll_bar.h"
51  #include "core/components_ng/pattern/scroll_bar/proxy/scroll_bar_proxy.h"
52  #include "core/components_ng/pattern/scrollable/scrollable_pattern.h"
53  #include "core/components_ng/pattern/text/layout_info_interface.h"
54  #include "core/components_ng/pattern/text/multiple_click_recognizer.h"
55  #include "core/components_ng/pattern/text/text_base.h"
56  #include "core/components_ng/pattern/text/text_menu_extension.h"
57  #include "core/components_ng/pattern/text_area/text_area_layout_algorithm.h"
58  #include "core/components_ng/pattern/text_drag/text_drag_base.h"
59  #include "core/components_ng/pattern/text_field/content_controller.h"
60  #include "core/components_ng/pattern/text_field/text_editing_value_ng.h"
61  #include "core/components_ng/pattern/text_field/text_content_type.h"
62  #include "core/components_ng/pattern/text_field/text_field_accessibility_property.h"
63  #include "core/components_ng/pattern/text_field/text_field_controller.h"
64  #include "core/components_ng/pattern/text_field/text_field_event_hub.h"
65  #include "core/components_ng/pattern/text_field/text_field_layout_property.h"
66  #include "core/components_ng/pattern/text_field/text_field_manager.h"
67  #include "core/components_ng/pattern/text_field/text_field_paint_method.h"
68  #include "core/components_ng/pattern/text_field/text_field_paint_property.h"
69  #include "core/components_ng/pattern/text_field/text_field_select_overlay.h"
70  #include "core/components_ng/pattern/text_field/text_input_response_area.h"
71  #include "core/components_ng/pattern/text_field/text_select_controller.h"
72  #include "core/components_ng/pattern/text_field/text_selector.h"
73  #include "core/components_ng/pattern/text_input/text_input_layout_algorithm.h"
74  #include "core/components_ng/property/property.h"
75  #include "core/components_ng/pattern/select_overlay/magnifier_controller.h"
76  #include "core/components_ng/pattern/select_overlay/magnifier.h"
77  
78  #ifndef ACE_UNITTEST
79  #ifdef ENABLE_STANDARD_INPUT
80  #include "commonlibrary/c_utils/base/include/refbase.h"
81  
82  namespace OHOS::MiscServices {
83  class InspectorFilter;
84  class OnTextChangedListener;
85  
86  struct TextConfig;
87  } // namespace OHOS::MiscServices
88  #endif
89  #endif
90  
91  namespace OHOS::Ace::NG {
92  
93  enum class FocuseIndex { TEXT = 0, CANCEL, UNIT };
94  
95  enum class SelectionMode { SELECT, SELECT_ALL, NONE };
96  
97  enum class DragStatus { DRAGGING, ON_DROP, NONE };
98  
99  enum class CaretStatus { SHOW, HIDE, NONE };
100  
101  enum class InputOperation {
102      INSERT,
103      DELETE_BACKWARD,
104      DELETE_FORWARD,
105      CURSOR_UP,
106      CURSOR_DOWN,
107      CURSOR_LEFT,
108      CURSOR_RIGHT,
109      SET_PREVIEW_TEXT,
110      SET_PREVIEW_FINISH,
111  };
112  
113  enum {
114      ACTION_SELECT_ALL, // Smallest code unit.
115      ACTION_UNDO,
116      ACTION_REDO,
117      ACTION_CUT,
118      ACTION_COPY,
119      ACTION_PASTE,
120      ACTION_SHARE,
121      ACTION_PASTE_AS_PLAIN_TEXT,
122      ACTION_REPLACE,
123      ACTION_ASSIST,
124      ACTION_AUTOFILL,
125  };
126  
127  struct PasswordModeStyle {
128      Color bgColor;
129      Color textColor;
130      BorderWidthProperty borderwidth;
131      BorderColorProperty borderColor;
132      BorderRadiusProperty radius;
133      PaddingProperty padding;
134      MarginProperty margin;
135  };
136  
137  struct PreState {
138      Color textColor;
139      Color bgColor;
140      BorderRadiusProperty radius;
141      BorderWidthProperty borderWidth;
142      BorderColorProperty borderColor;
143      PaddingProperty padding;
144      MarginProperty margin;
145      RectF frameRect;
146      bool setHeight = false;
147      bool saveState = false;
148      bool hasBorderColor = false;
149  };
150  
151  enum class RequestKeyboardReason {
152      UNKNOWN = 0,
153      ON_KEY_EVENT,
154      SINGLE_CLICK,
155      DOUBLE_CLICK,
156      LONG_PRESS,
157      RESET_KEYBOARD,
158      MOUSE_RELEASE,
159      SET_SELECTION,
160      SEARCH_REQUEST,
161      AUTO_FILL_REQUEST_FAIL,
162      SHOW_KEYBOARD_ON_FOCUS,
163      STYLUS_DETECTOR,
164      CUSTOM_KEYBOARD
165  };
166  
167  enum class RequestFocusReason {
168      UNKNOWN = 0,
169      DRAG_END,
170      DRAG_MOVE,
171      CLICK,
172      LONG_PRESS,
173      AUTO_FILL,
174      CLEAN_NODE,
175      MOUSE,
176  };
177  
178  struct PreviewTextInfo {
179      std::string text;
180      PreviewRange range;
181  };
182  
183  struct SourceAndValueInfo {
184      std::string insertValue;
185      bool isIME = false;
186  };
187  
188  struct TouchAndMoveCaretState {
189      bool isTouchCaret = false;
190      bool isMoveCaret = false;
191      Offset touchDownOffset;
192      Dimension minDinstance = 5.0_vp;
193      int32_t touchFingerId = -1;
194  };
195  
196  class TextFieldPattern : public ScrollablePattern,
197                           public TextDragBase,
198                           public ValueChangeObserver,
199                           public TextInputClient,
200                           public TextBase,
201                           public Magnifier,
202                           public TextGestureSelector,
203                           public LayoutInfoInterface {
204      DECLARE_ACE_TYPE(TextFieldPattern, ScrollablePattern, TextDragBase, ValueChangeObserver, TextInputClient, TextBase,
205          Magnifier, TextGestureSelector);
206  
207  public:
208      TextFieldPattern();
209      ~TextFieldPattern() override;
210  
GetInstanceId()211      int32_t GetInstanceId() const override
212      {
213          return GetHostInstanceId();
214      }
215  
216      // TextField needs softkeyboard, override function.
NeedSoftKeyboard()217      bool NeedSoftKeyboard() const override
218      {
219          return true;
220      }
221  
222      RefPtr<NodePaintMethod> CreateNodePaintMethod() override;
223  
CreateLayoutProperty()224      RefPtr<LayoutProperty> CreateLayoutProperty() override
225      {
226          return MakeRefPtr<TextFieldLayoutProperty>();
227      }
228  
CreateEventHub()229      RefPtr<EventHub> CreateEventHub() override
230      {
231          return MakeRefPtr<TextFieldEventHub>();
232      }
233  
CreatePaintProperty()234      RefPtr<PaintProperty> CreatePaintProperty() override
235      {
236          return MakeRefPtr<TextFieldPaintProperty>();
237      }
238  
CreateAccessibilityProperty()239      RefPtr<AccessibilityProperty> CreateAccessibilityProperty() override
240      {
241          return MakeRefPtr<TextFieldAccessibilityProperty>();
242      }
243  
CreateLayoutAlgorithm()244      RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override
245      {
246          if (IsTextArea()) {
247              return MakeRefPtr<TextAreaLayoutAlgorithm>();
248          }
249          return MakeRefPtr<TextInputLayoutAlgorithm>();
250      }
251  
SetBlurOnSubmit(bool blurOnSubmit)252      void SetBlurOnSubmit(bool blurOnSubmit)
253      {
254          textInputBlurOnSubmit_ = blurOnSubmit;
255          textAreaBlurOnSubmit_ = blurOnSubmit;
256      }
GetBlurOnSubmit()257      bool GetBlurOnSubmit()
258      {
259          return IsTextArea() ? textAreaBlurOnSubmit_ : textInputBlurOnSubmit_;
260      }
261  
NeedToRequestKeyboardOnFocus()262      bool NeedToRequestKeyboardOnFocus() const override
263      {
264          return needToRequestKeyboardOnFocus_;
265      }
266  
267      bool CheckBlurReason();
268  
269      void OnModifyDone() override;
270      void ProcessUnderlineColorOnModifierDone();
271      void UpdateSelectionOffset();
272      void CalcCaretMetricsByPosition(
273          int32_t extent, CaretMetricsF& caretCaretMetric, TextAffinity textAffinity = TextAffinity::DOWNSTREAM);
274      int32_t ConvertTouchOffsetToCaretPosition(const Offset& localOffset);
275      int32_t ConvertTouchOffsetToCaretPositionNG(const Offset& localOffset);
276  
277      // Obtain the systemWindowsId when switching between windows
278      uint32_t GetSCBSystemWindowId();
279  
280      void InsertValue(const std::string& insertValue, bool isIME = false) override;
281      void InsertValueOperation(const SourceAndValueInfo& info);
282      void CalcCounterAfterFilterInsertValue(int32_t curLength, const std::string insertValue, int32_t maxLength);
283      void UpdateObscure(const std::string& insertValue, bool hasInsertValue);
284      float MeasureCounterNodeHeight();
285      double CalcCounterBoundHeight();
286      void UpdateCounterMargin();
287      void CleanCounterNode();
288      void CleanErrorNode();
289      float CalcDecoratorWidth(const RefPtr<FrameNode>& decoratorNode);
290      float CalcDecoratorHeight(const RefPtr<FrameNode>& decoratorNode);
291      void UltralimitShake();
292      void UpdateAreaBorderStyle(BorderWidthProperty& currentBorderWidth, BorderWidthProperty& overCountBorderWidth,
293          BorderColorProperty& overCountBorderColor, BorderColorProperty& currentBorderColor);
294      void DeleteBackward(int32_t length) override;
295      void DeleteBackwardOperation(int32_t length);
296      void DeleteForward(int32_t length) override;
297      void DeleteForwardOperation(int32_t length);
298      void HandleOnDelete(bool backward) override;
299      void UpdateRecordCaretIndex(int32_t index);
300      void CreateHandles() override;
301      void GetEmojiSubStringRange(int32_t& start, int32_t& end);
302  
303      int32_t SetPreviewText(const std::string& previewValue, const PreviewRange range) override;
304      void FinishTextPreview() override;
305      void SetPreviewTextOperation(PreviewTextInfo info);
306      void FinishTextPreviewOperation();
307  
GetCounterNode()308      WeakPtr<LayoutWrapper> GetCounterNode()
309      {
310          return counterTextNode_;
311      }
312  
GetErrorNode()313      WeakPtr<FrameNode> GetErrorNode() const
314      {
315          return errorTextNode_;
316      }
317  
GetShowCounterStyleValue()318      bool GetShowCounterStyleValue() const
319      {
320          return showCountBorderStyle_;
321      }
322  
SetCounterState(bool counterChange)323      void SetCounterState(bool counterChange)
324      {
325          counterChange_ = counterChange;
326      }
327  
328      float GetTextOrPlaceHolderFontSize();
329  
SetTextFieldController(const RefPtr<TextFieldController> & controller)330      void SetTextFieldController(const RefPtr<TextFieldController>& controller)
331      {
332          textFieldController_ = controller;
333      }
334  
GetTextFieldController()335      const RefPtr<TextFieldController>& GetTextFieldController()
336      {
337          return textFieldController_;
338      }
339  
SetJSTextEditableController(const RefPtr<Referenced> & jsController)340      void SetJSTextEditableController(const RefPtr<Referenced>& jsController)
341      {
342          jsTextEditableController_ = jsController;
343      }
344  
GetJSTextEditableController()345      RefPtr<Referenced> GetJSTextEditableController()
346      {
347          return jsTextEditableController_.Upgrade();
348      }
349  
SetTextEditController(const RefPtr<TextEditController> & textEditController)350      void SetTextEditController(const RefPtr<TextEditController>& textEditController)
351      {
352          textEditingController_ = textEditController;
353      }
354  
GetTextValue()355      std::string GetTextValue() const
356      {
357          return contentController_->GetTextValue();
358      }
359  
360  #if defined(IOS_PLATFORM)
GetInputEditingValue()361      const TextEditingValue& GetInputEditingValue() const override
362      {
363          static TextEditingValue value;
364          value.text = contentController_->GetTextValue();
365          value.hint = GetPlaceHolder();
366          value.selection.Update(selectController_->GetStartIndex(), selectController_->GetEndIndex());
367          return value;
368      };
369      Offset GetGlobalOffset() const;
370      double GetEditingBoxY() const override;
371      double GetEditingBoxTopY() const override;
372      bool GetEditingBoxModel() const override;
373  #endif
374  
ShouldDelayChildPressedState()375      bool ShouldDelayChildPressedState() const override
376      {
377          return false;
378      }
379  
UpdateEditingValue(const std::string & value,int32_t caretPosition)380      void UpdateEditingValue(const std::string& value, int32_t caretPosition)
381      {
382          contentController_->SetTextValue(value);
383          selectController_->UpdateCaretIndex(caretPosition);
384      }
385      void UpdateCaretPositionByTouch(const Offset& offset);
386  
387      bool IsReachedBoundary(float offset);
388      virtual int32_t GetRequestKeyboardId();
389  
390      virtual TextInputAction GetDefaultTextInputAction() const;
391      bool RequestKeyboardCrossPlatForm(bool isFocusViewChanged);
392      bool RequestKeyboard(bool isFocusViewChanged, bool needStartTwinkling, bool needShowSoftKeyboard);
393      bool CloseKeyboard(bool forceClose) override;
394      bool CloseKeyboard(bool forceClose, bool isStopTwinkling);
395  
GetFocusPattern()396      FocusPattern GetFocusPattern() const override
397      {
398          FocusPattern focusPattern = { FocusType::NODE, true, FocusStyleType::FORCE_NONE };
399          focusPattern.SetIsFocusActiveWhenFocused(true);
400          return focusPattern;
401      }
402      void PerformAction(TextInputAction action, bool forceCloseKeyboard = false) override;
403      void UpdateEditingValue(const std::shared_ptr<TextEditingValue>& value, bool needFireChangeEvent = true) override;
404      void UpdateInputFilterErrorText(const std::string& errorText) override;
405  
406      void OnValueChanged(bool needFireChangeEvent = true, bool needFireSelectChangeEvent = true) override;
407  
408      void OnHandleAreaChanged() override;
409      void OnVisibleChange(bool isVisible) override;
410      void ClearEditingValue();
411      void HandleCounterBorder();
GetWideText()412      std::wstring GetWideText()
413      {
414          return contentController_->GetWideText();
415      }
416  
GetCaretIndex()417      int32_t GetCaretIndex() const override
418      {
419          return selectController_->GetCaretIndex();
420      }
421  
GetFirstHandleOffset()422      OffsetF GetFirstHandleOffset() const override
423      {
424          return selectController_->GetFirstHandleOffset();
425      }
426  
GetSecondHandleOffset()427      OffsetF GetSecondHandleOffset() const override
428      {
429          return selectController_->GetSecondHandleOffset();
430      }
431  
ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(TextInputAction,TextInputAction)432      ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(TextInputAction, TextInputAction)
433  
434      const RefPtr<Paragraph>& GetParagraph() const
435      {
436          return paragraph_;
437      }
438  
GetCursorVisible()439      bool GetCursorVisible() const
440      {
441          return cursorVisible_;
442      }
443  
444  #if defined(OHOS_STANDARD_SYSTEM) && !defined(PREVIEW)
GetImeAttached()445      bool GetImeAttached() const
446      {
447          return imeAttached_;
448      }
449  #endif
450  
GetLastTouchOffset()451      const OffsetF& GetLastTouchOffset()
452      {
453          return lastTouchOffset_;
454      }
455  
GetCaretOffset()456      OffsetF GetCaretOffset() const override
457      {
458          return movingCaretOffset_;
459      }
460  
SetMovingCaretOffset(const OffsetF & offset)461      void SetMovingCaretOffset(const OffsetF& offset)
462      {
463          movingCaretOffset_ = offset;
464      }
465  
GetCaretUpdateType()466      CaretUpdateType GetCaretUpdateType() const
467      {
468          return caretUpdateType_;
469      }
470  
SetCaretUpdateType(CaretUpdateType type)471      void SetCaretUpdateType(CaretUpdateType type)
472      {
473          caretUpdateType_ = type;
474      }
475  
476      float GetPaddingTop() const;
477  
478      float GetPaddingBottom() const;
479  
480      float GetPaddingLeft() const;
481  
482      float GetPaddingRight() const;
483  
484      float GetHorizontalPaddingAndBorderSum() const;
485      float GetVerticalPaddingAndBorderSum() const;
486      BorderWidthProperty GetBorderWidthProperty() const;
487  
GetPercentReferenceWidth()488      double GetPercentReferenceWidth() const
489      {
490          auto host = GetHost();
491          if (host && host->GetGeometryNode() && host->GetGeometryNode()->GetParentLayoutConstraint().has_value()) {
492              return host->GetGeometryNode()->GetParentLayoutConstraint()->percentReference.Width();
493          }
494          return 0.0f;
495      }
496  
497      float GetBorderLeft(BorderWidthProperty border) const;
498      float GetBorderTop(BorderWidthProperty border) const;
499      float GetBorderBottom(BorderWidthProperty border) const;
500      float GetBorderRight(BorderWidthProperty border) const;
501  
GetTextRect()502      const RectF& GetTextRect() override
503      {
504          return textRect_;
505      }
506  
SetTextRect(const RectF & textRect)507      void SetTextRect(const RectF& textRect)
508      {
509          textRect_ = textRect;
510      }
511  
GetFrameRect()512      const RectF& GetFrameRect() const
513      {
514          return frameRect_;
515      }
516  
GetCountHeight()517      float GetCountHeight() const
518      {
519          return countHeight_;
520      }
521  
GetTextSelectController()522      const RefPtr<TextSelectController>& GetTextSelectController()
523      {
524          return selectController_;
525      }
526  
GetTextContentController()527      const RefPtr<ContentController>& GetTextContentController()
528      {
529          return contentController_;
530      }
531  
SetInSelectMode(SelectionMode selectionMode)532      void SetInSelectMode(SelectionMode selectionMode)
533      {
534          selectionMode_ = selectionMode;
535      }
536  
GetSelectMode()537      SelectionMode GetSelectMode() const
538      {
539          return selectionMode_;
540      }
541  
IsSelected()542      bool IsSelected() const override
543      {
544          return selectController_->IsSelected();
545      }
546  
IsUsingMouse()547      bool IsUsingMouse() const
548      {
549          return selectOverlay_->IsUsingMouse();
550      }
551      int32_t GetWordLength(int32_t originCaretPosition, int32_t directionalMove);
552      int32_t GetLineBeginPosition(int32_t originCaretPosition, bool needToCheckLineChanged = true);
553      int32_t GetLineEndPosition(int32_t originCaretPosition, bool needToCheckLineChanged = true);
IsOperation()554      bool IsOperation() const
555      {
556          return !contentController_->IsEmpty();
557      }
558  
559      void CursorMove(CaretMoveIntent direction) override;
560      bool CursorMoveLeft();
561      bool CursorMoveLeftOperation();
562      bool CursorMoveLeftWord();
563      bool CursorMoveLineBegin();
564      bool CursorMoveToParagraphBegin();
565      bool CursorMoveHome();
566      bool CursorMoveRight();
567      bool CursorMoveRightOperation();
568      bool CursorMoveRightWord();
569      bool CursorMoveLineEnd();
570      bool CursorMoveToParagraphEnd();
571      bool CursorMoveEnd();
572      bool CursorMoveUp();
573      bool CursorMoveDown();
574      bool CursorMoveUpOperation();
575      bool CursorMoveDownOperation();
576      void SetCaretPosition(int32_t position);
577      void HandleSetSelection(int32_t start, int32_t end, bool showHandle = true) override;
578      void HandleExtendAction(int32_t action) override;
579      void HandleSelect(CaretMoveIntent direction) override;
580      OffsetF GetDragUpperLeftCoordinates() override;
581  
GetTextBoxes()582      std::vector<RectF> GetTextBoxes() override
583      {
584          return selectController_->GetSelectedRects();
585      }
586      void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override;
587      void ToJsonValueForOption(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const;
588      void ToJsonValueSelectOverlay(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const;
589      void FromJson(const std::unique_ptr<JsonValue>& json) override;
590      void InitEditingValueText(std::string content);
591      bool InitValueText(std::string content);
592  
593      void CloseSelectOverlay() override;
594      void CloseSelectOverlay(bool animation);
SetInputMethodStatus(bool keyboardShown)595      void SetInputMethodStatus(bool keyboardShown) override
596      {
597  #if defined(OHOS_STANDARD_SYSTEM) && !defined(PREVIEW)
598          imeShown_ = keyboardShown;
599  #endif
600      }
NotifyKeyboardClosedByUser()601      void NotifyKeyboardClosedByUser() override
602      {
603          TAG_LOGI(AceLogTag::ACE_TEXT_FIELD, "NotifyKeyboardClosedByUser");
604          isKeyboardClosedByUser_ = true;
605          FocusHub::LostFocusToViewRoot();
606          isKeyboardClosedByUser_ = false;
607      }
608  
NotifyKeyboardClosed()609      void NotifyKeyboardClosed() override
610      {
611          TAG_LOGI(AceLogTag::ACE_TEXT_FIELD, "NotifyKeyboardClosed");
612          if (HasFocus() && !(customKeyboard_ || customKeyboardBuilder_)) {
613              FocusHub::LostFocusToViewRoot();
614          }
615      }
616  
617      std::u16string GetLeftTextOfCursor(int32_t number) override;
618      std::u16string GetRightTextOfCursor(int32_t number) override;
619      int32_t GetTextIndexAtCursor() override;
620  
HasConnection()621      bool HasConnection() const
622      {
623  #if defined(OHOS_STANDARD_SYSTEM) && !defined(PREVIEW)
624          return imeShown_;
625  #else
626          return connection_;
627  #endif
628      }
629      float PreferredLineHeight(bool isAlgorithmMeasure = false);
630  
631      void SearchRequestKeyboard();
632  
633      bool RequestKeyboardNotByFocusSwitch(RequestKeyboardReason reason = RequestKeyboardReason::UNKNOWN);
634  
635      bool TextFieldRequestFocus(RequestFocusReason reason = RequestFocusReason::UNKNOWN);
636  
637      static std::string RequestFocusReasonToString(RequestFocusReason reason);
638  
639      static std::string RequestKeyboardReasonToString(RequestKeyboardReason reason);
640  
GetTextObscured()641      bool GetTextObscured() const
642      {
643          return textObscured_;
644      }
645  
646      static std::u16string CreateObscuredText(int32_t len);
647      static std::u16string CreateDisplayText(
648          const std::string& content, int32_t nakedCharPosition, bool needObscureText, bool showPasswordDirectly);
649      bool IsTextArea() const override;
650  
GetTouchListener()651      const RefPtr<TouchEventImpl>& GetTouchListener()
652      {
653          return touchListener_;
654      }
655  
NeedShowPasswordIcon()656      bool NeedShowPasswordIcon()
657      {
658          auto layoutProperty = GetLayoutProperty<TextFieldLayoutProperty>();
659          CHECK_NULL_RETURN(layoutProperty, false);
660          return IsInPasswordMode() && layoutProperty->GetShowPasswordIconValue(true);
661      }
662  
SetEnableTouchAndHoverEffect(bool enable)663      void SetEnableTouchAndHoverEffect(bool enable)
664      {
665          enableTouchAndHoverEffect_ = enable;
666      }
667  
GetCaretRect()668      RectF GetCaretRect() const override
669      {
670          return selectController_->GetCaretRect();
671      }
672  
673      void HandleSurfaceChanged(int32_t newWidth, int32_t newHeight, int32_t prevWidth, int32_t prevHeight);
674      void HandleSurfacePositionChanged(int32_t posX, int32_t posY);
675  
676      void InitSurfaceChangedCallback();
677      void InitSurfacePositionChangedCallback();
678  
HasSurfaceChangedCallback()679      bool HasSurfaceChangedCallback()
680      {
681          return surfaceChangedCallbackId_.has_value();
682      }
UpdateSurfaceChangedCallbackId(int32_t id)683      void UpdateSurfaceChangedCallbackId(int32_t id)
684      {
685          surfaceChangedCallbackId_ = id;
686      }
687  
HasSurfacePositionChangedCallback()688      bool HasSurfacePositionChangedCallback()
689      {
690          return surfacePositionChangedCallbackId_.has_value();
691      }
UpdateSurfacePositionChangedCallbackId(int32_t id)692      void UpdateSurfacePositionChangedCallbackId(int32_t id)
693      {
694          surfacePositionChangedCallbackId_ = id;
695      }
696  
697      void ProcessInnerPadding();
698      void ProcessNumberOfLines();
699      void OnCursorMoveDone(
700          TextAffinity textAffinity = TextAffinity::UPSTREAM, std::optional<Offset> offset = std::nullopt);
701      bool IsDisabled();
702      bool AllowCopy();
703  
GetIsMousePressed()704      bool GetIsMousePressed() const
705      {
706          return isMousePressed_;
707      }
708  
GetMouseStatus()709      MouseStatus GetMouseStatus() const
710      {
711          return mouseStatus_;
712      }
713  
714      void UpdateEditingValueToRecord();
715      void UpdateScrollBarOffset() override;
716  
UpdateCurrentOffset(float offset,int32_t source)717      bool UpdateCurrentOffset(float offset, int32_t source) override
718      {
719          OnScrollCallback(offset, source);
720          return true;
721      }
722  
723      void PlayScrollBarAppearAnimation();
724  
725      void ScheduleDisappearDelayTask();
726  
IsAtTop()727      bool IsAtTop() const override
728      {
729          return contentRect_.GetY() == textRect_.GetY();
730      }
731  
IsAtBottom()732      bool IsAtBottom() const override
733      {
734          return contentRect_.GetY() + contentRect_.Height() == textRect_.GetY() + textRect_.Height();
735      }
736  
IsScrollable()737      bool IsScrollable() const override
738      {
739          return scrollable_;
740      }
741  
IsAtomicNode()742      bool IsAtomicNode() const override
743      {
744          return true;
745      }
746  
GetCurrentOffset()747      float GetCurrentOffset() const
748      {
749          return currentOffset_;
750      }
751  
GetContentModifier()752      RefPtr<TextFieldContentModifier> GetContentModifier()
753      {
754          return textFieldContentModifier_;
755      }
756  
757      double GetScrollBarWidth();
758  
GetLineHeight()759      float GetLineHeight() const override
760      {
761          return selectController_->GetCaretRect().Height();
762      }
763  
GetParentGlobalOffset()764      OffsetF GetParentGlobalOffset() const override
765      {
766          return parentGlobalOffset_;
767      }
768  
769      RectF GetTextContentRect(bool isActualText = false) const override
770      {
771          return contentRect_;
772      }
773  
GetKeyboardOverLay()774      const RefPtr<OverlayManager>& GetKeyboardOverLay()
775      {
776          return keyboardOverlay_;
777      }
778  
GetIsCustomKeyboardAttached()779      bool GetIsCustomKeyboardAttached()
780      {
781          return isCustomKeyboardAttached_;
782      }
783  
GetDragParagraph()784      const RefPtr<Paragraph>& GetDragParagraph() const override
785      {
786          return paragraph_;
787      }
788  
MoveDragNode()789      const RefPtr<FrameNode>& MoveDragNode() override
790      {
791          return dragNode_;
792      }
793  
GetDragContents()794      const std::vector<std::string>& GetDragContents() const
795      {
796          return dragContents_;
797      }
798  
AddDragFrameNodeToManager(const RefPtr<FrameNode> & frameNode)799      void AddDragFrameNodeToManager(const RefPtr<FrameNode>& frameNode)
800      {
801          auto context = PipelineContext::GetCurrentContext();
802          CHECK_NULL_VOID(context);
803          auto dragDropManager = context->GetDragDropManager();
804          CHECK_NULL_VOID(dragDropManager);
805          dragDropManager->AddDragFrameNode(frameNode->GetId(), AceType::WeakClaim(AceType::RawPtr(frameNode)));
806      }
807  
RemoveDragFrameNodeFromManager(const RefPtr<FrameNode> & frameNode)808      void RemoveDragFrameNodeFromManager(const RefPtr<FrameNode>& frameNode)
809      {
810          auto context = PipelineContext::GetCurrentContext();
811          CHECK_NULL_VOID(context);
812          auto dragDropManager = context->GetDragDropManager();
813          CHECK_NULL_VOID(dragDropManager);
814          dragDropManager->RemoveDragFrameNode(frameNode->GetId());
815      }
816  
IsDragging()817      bool IsDragging() const
818      {
819          return dragStatus_ == DragStatus::DRAGGING;
820      }
821  
BetweenSelectedPosition(const Offset & globalOffset)822      bool BetweenSelectedPosition(const Offset& globalOffset) override
823      {
824          if (!IsSelected()) {
825              return false;
826          }
827          auto localOffset = ConvertGlobalToLocalOffset(globalOffset);
828          auto offsetX = IsTextArea() ? contentRect_.GetX() : textRect_.GetX();
829          auto offsetY = IsTextArea() ? textRect_.GetY() : contentRect_.GetY();
830          Offset offset = localOffset - Offset(offsetX, offsetY);
831          for (const auto& rect : selectController_->GetSelectedRects()) {
832              bool isInRange = rect.IsInRegion({ offset.GetX(), offset.GetY() });
833              if (isInRange) {
834                  return true;
835              }
836          }
837          return false;
838      }
839  
840      bool RequestCustomKeyboard();
841      bool CloseCustomKeyboard();
842  
843      // xts
844      std::string TextInputTypeToString() const;
845      std::string TextInputActionToString() const;
846      std::string TextContentTypeToString() const;
847      std::string GetPlaceholderFont() const;
848      RefPtr<TextFieldTheme> GetTheme() const;
849      void InitTheme();
850      std::string GetTextColor() const;
851      std::string GetCaretColor() const;
852      std::string GetPlaceholderColor() const;
853      std::string GetFontSize() const;
854      std::string GetMinFontSize() const;
855      std::string GetMaxFontSize() const;
856      std::string GetTextIndent() const;
857      Ace::FontStyle GetItalicFontStyle() const;
858      FontWeight GetFontWeight() const;
859      std::string GetFontFamily() const;
860      TextAlign GetTextAlign() const;
861      std::string GetPlaceHolder() const;
862      uint32_t GetMaxLength() const;
863      uint32_t GetMaxLines() const;
864      std::string GetInputFilter() const;
865      std::string GetCopyOptionString() const;
866      std::string GetInputStyleString() const;
867      std::string GetErrorTextString() const;
868      std::string GetBarStateString() const;
869      bool GetErrorTextState() const;
870      std::string GetShowPasswordIconString() const;
871      int32_t GetNakedCharPosition() const;
872      void SetSelectionFlag(int32_t selectionStart, int32_t selectionEnd,
873          const std::optional<SelectionOptions>& options = std::nullopt, bool isForward = false);
874      void SetSelection(int32_t start, int32_t end,
875          const std::optional<SelectionOptions>& options = std::nullopt, bool isForward = false) override;
876      void HandleBlurEvent();
877      void HandleFocusEvent();
878      void ProcessFocusStyle();
879      bool OnBackPressed() override;
880      void CheckScrollable();
881      void HandleClickEvent(GestureEvent& info);
882      bool CheckMousePressedOverScrollBar(GestureEvent& info);
883      int32_t CheckClickLocation(GestureEvent& info);
884      void HandleDoubleClickEvent(GestureEvent& info);
885      void HandleTripleClickEvent(GestureEvent& info);
886      void HandleSingleClickEvent(GestureEvent& info, bool firstGetFocus = false);
887      bool HandleBetweenSelectedPosition(const GestureEvent& info);
888  
889      void HandleSelectionUp();
890      void HandleSelectionDown();
891      void HandleSelectionLeft();
892      void HandleSelectionLeftWord();
893      void HandleSelectionLineBegin();
894      void HandleSelectionHome();
895      void HandleSelectionRight();
896      void HandleSelectionRightWord();
897      void HandleSelectionLineEnd();
898      void HandleSelectionEnd();
899      bool HandleOnEscape() override;
900      bool HandleOnTab(bool backward) override;
HandleOnEnter()901      void HandleOnEnter() override
902      {
903          PerformAction(GetTextInputActionValue(GetDefaultTextInputAction()), false);
904      }
905      void HandleOnUndoAction() override;
906      void HandleOnRedoAction() override;
907      bool CanUndo();
908      bool CanRedo();
909      void HandleOnSelectAll(bool isKeyEvent, bool inlineStyle = false, bool showMenu = false);
HandleOnSelectAll()910      void HandleOnSelectAll() override
911      {
912          HandleOnSelectAll(true);
913      }
914      void HandleOnCopy(bool isUsingExternalKeyboard = false) override;
915      void HandleOnPaste() override;
916      void HandleOnCut() override;
917      void HandleOnCameraInput();
918      void HandleOnAIWrite();
919      void GetAIWriteInfo(AIWriteInfo& info);
920      bool IsShowAIWrite();
921      void HandleAIWriteResult(int32_t start, int32_t end, std::vector<uint8_t>& buffer);
922      void UpdateShowCountBorderStyle();
923      void StripNextLine(std::wstring& data);
924      bool IsShowHandle();
925      std::string GetCancelButton();
926      std::string GetCancelImageText();
927      std::string GetPasswordIconPromptInformation(bool show);
928      bool OnKeyEvent(const KeyEvent& event);
929      size_t GetLineCount() const override;
GetKeyboard()930      TextInputType GetKeyboard()
931      {
932          return keyboard_;
933      }
GetAction()934      TextInputAction GetAction()
935      {
936          return action_;
937      }
938  
SetNeedToRequestKeyboardOnFocus(bool needToRequest)939      void SetNeedToRequestKeyboardOnFocus(bool needToRequest)
940      {
941          needToRequestKeyboardOnFocus_ = needToRequest;
942      }
SetUnitNode(const RefPtr<NG::UINode> & unitNode)943      void SetUnitNode(const RefPtr<NG::UINode>& unitNode)
944      {
945          unitNode_ = unitNode;
946      }
947      void AddCounterNode();
948      void ClearCounterNode();
949      void SetShowError();
950  
GetUnderlineWidth()951      float GetUnderlineWidth() const
952      {
953          return static_cast<float>(underlineWidth_.Value());
954      }
955  
GetUnderlineColor()956      const Color& GetUnderlineColor() const
957      {
958          return underlineColor_;
959      }
960  
961      float GetMarginBottom() const;
962  
SetUnderlineColor(Color underlineColor)963      void SetUnderlineColor(Color underlineColor)
964      {
965          underlineColor_ = underlineColor;
966      }
967  
SetNormalUnderlineColor(const Color & normalColor)968      void SetNormalUnderlineColor(const Color& normalColor)
969      {
970          userUnderlineColor_.normal = normalColor;
971      }
972  
SetUserUnderlineColor(UserUnderlineColor userUnderlineColor)973      void SetUserUnderlineColor(UserUnderlineColor userUnderlineColor)
974      {
975          userUnderlineColor_ = userUnderlineColor;
976      }
977  
GetUserUnderlineColor()978      UserUnderlineColor GetUserUnderlineColor()
979      {
980          return userUnderlineColor_;
981      }
982  
SetUnderlineWidth(Dimension underlineWidth)983      void SetUnderlineWidth(Dimension underlineWidth)
984      {
985          underlineWidth_ = underlineWidth;
986      }
987  
IsSelectAll()988      bool IsSelectAll()
989      {
990          return abs(selectController_->GetStartIndex() - selectController_->GetEndIndex()) >=
991                 static_cast<int32_t>(contentController_->GetWideText().length());
992      }
993  
994      void StopEditing();
995  
MarkContentChange()996      void MarkContentChange()
997      {
998          contChange_ = true;
999      }
1000  
ResetContChange()1001      void ResetContChange()
1002      {
1003          contChange_ = false;
1004      }
1005  
GetContChange()1006      bool GetContChange() const
1007      {
1008          return contChange_;
1009      }
1010      std::string GetShowResultImageSrc() const;
1011      std::string GetHideResultImageSrc() const;
1012      std::string GetNormalUnderlineColorStr() const;
1013      std::string GetTypingUnderlineColorStr() const;
1014      std::string GetDisableUnderlineColorStr() const;
1015      std::string GetErrorUnderlineColorStr() const;
1016      void OnAttachToFrameNode() override;
1017  
GetTextInputFlag()1018      bool GetTextInputFlag() const
1019      {
1020          return isTextInput_;
1021      }
1022  
SetSingleLineHeight(float height)1023      void SetSingleLineHeight(float height)
1024      {
1025          inlineSingleLineHeight_ = height;
1026      }
1027  
GetSingleLineHeight()1028      float GetSingleLineHeight() const
1029      {
1030          return inlineSingleLineHeight_;
1031      }
1032  
GetInlinePadding()1033      float GetInlinePadding() const
1034      {
1035          return inlinePadding_;
1036      }
1037  
GetScrollBarVisible()1038      bool GetScrollBarVisible() const
1039      {
1040          return scrollBarVisible_;
1041      }
1042  
SetFillRequestFinish(bool success)1043      void SetFillRequestFinish(bool success)
1044      {
1045          isFillRequestFinish_ = success;
1046      }
1047  
IsFillRequestFinish()1048      bool IsFillRequestFinish()
1049      {
1050          return isFillRequestFinish_;
1051      }
1052  
SetTextInputFlag(bool isTextInput)1053      void SetTextInputFlag(bool isTextInput)
1054      {
1055          isTextInput_ = isTextInput;
1056      }
1057  
1058      bool IsNormalInlineState() const;
1059      bool IsUnspecifiedOrTextType() const;
1060      void TextIsEmptyRect(RectF& rect);
1061      void TextAreaInputRectUpdate(RectF& rect);
1062      void UpdateRectByTextAlign(RectF& rect);
1063  
1064      void EditingValueFilterChange();
1065  
SetCustomKeyboard(const std::function<void ()> && keyboardBuilder)1066      void SetCustomKeyboard(const std::function<void()>&& keyboardBuilder)
1067      {
1068          if (customKeyboardBuilder_ && isCustomKeyboardAttached_ && !keyboardBuilder) {
1069              // close customKeyboard and request system keyboard
1070              CloseCustomKeyboard();
1071              customKeyboardBuilder_ = keyboardBuilder; // refresh current keyboard
1072              RequestKeyboardNotByFocusSwitch(RequestKeyboardReason::CUSTOM_KEYBOARD);
1073              StartTwinkling();
1074              return;
1075          }
1076          if (!customKeyboardBuilder_ && keyboardBuilder) {
1077              // close system keyboard and request custom keyboard
1078  #if defined(OHOS_STANDARD_SYSTEM) && !defined(PREVIEW)
1079              if (imeShown_) {
1080                  CloseKeyboard(true);
1081                  customKeyboardBuilder_ = keyboardBuilder; // refresh current keyboard
1082                  RequestKeyboardNotByFocusSwitch(RequestKeyboardReason::CUSTOM_KEYBOARD);
1083                  StartTwinkling();
1084                  return;
1085              }
1086  #endif
1087          }
1088          customKeyboardBuilder_ = keyboardBuilder;
1089      }
1090  
SetCustomKeyboardWithNode(const RefPtr<UINode> & keyboardBuilder)1091      void SetCustomKeyboardWithNode(const RefPtr<UINode>& keyboardBuilder)
1092      {
1093          if (customKeyboard_ && isCustomKeyboardAttached_ && !keyboardBuilder) {
1094              // close customKeyboard and request system keyboard
1095              CloseCustomKeyboard();
1096              customKeyboard_ = keyboardBuilder; // refresh current keyboard
1097              RequestKeyboardNotByFocusSwitch(RequestKeyboardReason::CUSTOM_KEYBOARD);
1098              StartTwinkling();
1099              return;
1100          }
1101          if (!customKeyboard_ && keyboardBuilder) {
1102              // close system keyboard and request custom keyboard
1103  #if defined(OHOS_STANDARD_SYSTEM) && !defined(PREVIEW)
1104              if (imeShown_) {
1105                  CloseKeyboard(true);
1106                  customKeyboard_ = keyboardBuilder; // refresh current keyboard
1107                  RequestKeyboardNotByFocusSwitch(RequestKeyboardReason::CUSTOM_KEYBOARD);
1108                  StartTwinkling();
1109                  return;
1110              }
1111  #endif
1112          }
1113          customKeyboard_ = keyboardBuilder;
1114      }
1115  
HasCustomKeyboard()1116      bool HasCustomKeyboard()
1117      {
1118          return customKeyboardBuilder_ != nullptr || customKeyboard_ != nullptr;
1119      }
1120  
1121      void DumpInfo() override;
1122      void DumpAdvanceInfo() override;
1123      void DumpPlaceHolderInfo();
1124      void DumpTextEngineInfo();
1125      void DumpScaleInfo();
1126      std::string GetDumpTextValue() const;
1127      void DumpViewDataPageNode(RefPtr<ViewDataWrap> viewDataWrap, bool needsRecordData = false) override;
1128      void NotifyFillRequestSuccess(RefPtr<ViewDataWrap> viewDataWrap,
1129          RefPtr<PageNodeInfoWrap> nodeWrap, AceAutoFillType autoFillType) override;
1130      void NotifyFillRequestFailed(int32_t errCode, const std::string& fillContent = "", bool isPopup = false) override;
1131      bool CheckAutoSave() override;
1132      void OnColorConfigurationUpdate() override;
1133      bool NeedPaintSelect();
1134      void SetCustomKeyboardOption(bool supportAvoidance);
1135  
SetIsCustomFont(bool isCustomFont)1136      void SetIsCustomFont(bool isCustomFont)
1137      {
1138          isCustomFont_ = isCustomFont;
1139      }
1140  
GetIsCustomFont()1141      bool GetIsCustomFont() const
1142      {
1143          return isCustomFont_;
1144      }
1145  
SetIsCounterIdealHeight(bool isIdealHeight)1146      void SetIsCounterIdealHeight(bool isIdealHeight)
1147      {
1148          isCounterIdealheight_ = isIdealHeight;
1149      }
1150  
GetIsCounterIdealHeight()1151      bool GetIsCounterIdealHeight() const
1152      {
1153          return isCounterIdealheight_;
1154      }
1155  
1156      virtual RefPtr<FocusHub> GetFocusHub() const;
1157      void UpdateCaretInfoToController(bool forceUpdate = false);
1158      void OnObscuredChanged(bool isObscured);
GetResponseArea()1159      const RefPtr<TextInputResponseArea>& GetResponseArea()
1160      {
1161          return responseArea_;
1162      }
1163  
GetCleanNodeResponseArea()1164      const RefPtr<TextInputResponseArea>& GetCleanNodeResponseArea()
1165      {
1166          return cleanNodeResponseArea_;
1167      }
1168  
1169      bool IsShowUnit() const;
1170      bool IsShowPasswordIcon() const;
1171      std::optional<bool> IsShowPasswordText() const;
1172      bool IsInPasswordMode() const;
1173      bool IsShowCancelButtonMode() const;
1174      void CheckPasswordAreaState();
1175  
GetShowSelect()1176      bool GetShowSelect() const
1177      {
1178          return showSelect_;
1179      }
1180  
1181      bool HasFocus() const;
1182      void StopTwinkling();
1183  
IsModifyDone()1184      bool IsModifyDone()
1185      {
1186          return isModifyDone_;
1187      }
SetModifyDoneStatus(bool value)1188      void SetModifyDoneStatus(bool value)
1189      {
1190          isModifyDone_ = value;
1191      }
1192  
GetLastClickTime()1193      const TimeStamp& GetLastClickTime()
1194      {
1195          return lastClickTimeStamp_;
1196      }
1197  
ShowSelect()1198      void ShowSelect()
1199      {
1200          showSelect_ = true;
1201      }
1202  
1203      void FocusForwardStopTwinkling();
1204      bool UpdateFocusForward();
1205  
1206      bool UpdateFocusBackward();
1207  
1208      bool HandleSpaceEvent();
1209  
1210      void SavePreUnderLineState();
1211      virtual void ApplyNormalTheme();
1212      void ApplyUnderlineTheme();
1213      void ApplyInlineTheme();
1214  
GetContentWideTextLength()1215      int32_t GetContentWideTextLength() override
1216      {
1217          return static_cast<int32_t>(contentController_->GetWideText().length());
1218      }
1219  
HandleOnShowMenu()1220      void HandleOnShowMenu() override
1221      {
1222          selectOverlay_->HandleOnShowMenu();
1223      }
1224      void StartTwinkling();
1225  
1226      void CheckTextAlignByDirection(TextAlign& textAlign, TextDirection direction);
1227  
1228      OffsetF GetTextPaintOffset() const override;
1229  
1230      OffsetF GetPaintRectGlobalOffset() const;
1231  
NeedRequestKeyboard()1232      void NeedRequestKeyboard()
1233      {
1234          needToRequestKeyboardInner_ = true;
1235      }
1236  
1237      void GetCaretMetrics(CaretMetricsF& caretCaretMetric) override;
1238      void CleanNodeResponseKeyEvent();
1239      bool IsUnderlineMode() const;
1240      bool IsInlineMode() const;
1241      bool IsShowError();
1242      bool IsShowCount();
1243      void ResetContextAttr();
1244      void RestoreDefaultMouseState();
1245  
1246      void RegisterWindowSizeCallback();
1247      void OnWindowSizeChanged(int32_t width, int32_t height, WindowSizeChangeReason type) override;
1248  
IsTransparent()1249      bool IsTransparent()
1250      {
1251          return isTransparent_;
1252      }
1253  
GetClipboard()1254      RefPtr<Clipboard> GetClipboard() override
1255      {
1256          return clipboard_;
1257      }
1258  
1259      const Dimension& GetAvoidSoftKeyboardOffset() const override;
1260  
GetPaintContentRect()1261      RectF GetPaintContentRect() override
1262      {
1263          auto transformContentRect = contentRect_;
1264          selectOverlay_->GetLocalRectWithTransform(transformContentRect);
1265          return transformContentRect;
1266      }
1267  
GetCustomKeyboard()1268      RefPtr<UINode> GetCustomKeyboard()
1269      {
1270          return customKeyboard_;
1271      }
1272  
GetCustomKeyboardOption()1273      bool GetCustomKeyboardOption()
1274      {
1275          return keyboardAvoidance_;
1276      }
1277  
1278      void SetShowKeyBoardOnFocus(bool value);
GetShowKeyBoardOnFocus()1279      bool GetShowKeyBoardOnFocus()
1280      {
1281          return showKeyBoardOnFocus_;
1282      }
1283  
1284      bool ProcessAutoFill(bool& isPopup, bool isFromKeyBoard = false, bool isNewPassWord = false);
SetAutoFillUserName(const std::string & userName)1285      void SetAutoFillUserName(const std::string& userName)
1286      {
1287          autoFillUserName_ = userName;
1288      }
1289  
GetAutoFillUserName()1290      std::string GetAutoFillUserName()
1291      {
1292          return autoFillUserName_;
1293      }
1294  
GetAutoFillNewPassword()1295      std::string GetAutoFillNewPassword()
1296      {
1297          return autoFillNewPassword_;
1298      }
1299  
SetAutoFillNewPassword(const std::string & newPassword)1300      void SetAutoFillNewPassword(const std::string& newPassword)
1301      {
1302          autoFillNewPassword_ = newPassword;
1303      }
SetAutoFillOtherAccount(bool otherAccount)1304      void SetAutoFillOtherAccount(bool otherAccount)
1305      {
1306          autoFillOtherAccount_ = otherAccount;
1307      }
1308  
1309      std::vector<RectF> GetPreviewTextRects() const;
1310  
GetIsPreviewText()1311      bool GetIsPreviewText() const
1312      {
1313          return hasPreviewText_;
1314      }
1315  
GetPreviewDecorationColor()1316      const Color& GetPreviewDecorationColor() const
1317      {
1318          auto theme = GetTheme();
1319          CHECK_NULL_RETURN(theme, Color::TRANSPARENT);
1320          return theme->GetPreviewUnderlineColor();
1321      }
1322  
1323      bool NeedDrawPreviewText();
1324  
GetPreviewUnderlineWidth()1325      float GetPreviewUnderlineWidth() const
1326      {
1327          return static_cast<float>(previewUnderlineWidth_.ConvertToPx());
1328      }
1329  
1330      void ReceivePreviewTextStyle(const std::string& style) override;
1331  
1332      PreviewTextStyle GetPreviewTextStyle() const;
1333  
1334      void OnSelectionMenuOptionsUpdate(
1335          const NG::OnCreateMenuCallback&& onCreateMenuCallback, const NG::OnMenuItemClickCallback&& onMenuItemClick);
1336  
OnCreateMenuCallbackUpdate(const NG::OnCreateMenuCallback && onCreateMenuCallback)1337      void OnCreateMenuCallbackUpdate(const NG::OnCreateMenuCallback&& onCreateMenuCallback)
1338      {
1339          selectOverlay_->OnCreateMenuCallbackUpdate(std::move(onCreateMenuCallback));
1340      }
1341  
OnMenuItemClickCallbackUpdate(const NG::OnMenuItemClickCallback && onMenuItemClick)1342      void OnMenuItemClickCallbackUpdate(const NG::OnMenuItemClickCallback&& onMenuItemClick)
1343      {
1344          selectOverlay_->OnMenuItemClickCallbackUpdate(std::move(onMenuItemClick));
1345      }
1346  
SetSupportPreviewText(bool isSupported)1347      void SetSupportPreviewText(bool isSupported)
1348      {
1349          hasSupportedPreviewText_ = isSupported;
1350      }
1351  
GetSupportPreviewText()1352      bool GetSupportPreviewText() const
1353      {
1354          return hasSupportedPreviewText_;
1355      }
1356  
GetPreviewTextStart()1357      int32_t GetPreviewTextStart() const
1358      {
1359          return hasPreviewText_ ? previewTextStart_ : selectController_->GetCaretIndex();
1360      }
1361  
GetPreviewTextEnd()1362      int32_t GetPreviewTextEnd() const
1363      {
1364          return hasPreviewText_ ? previewTextEnd_ : selectController_->GetCaretIndex();
1365      }
1366  
GetPreviewTextValue()1367      std::string GetPreviewTextValue() const
1368      {
1369          return contentController_->GetSelectedValue(GetPreviewTextStart(), GetPreviewTextEnd());
1370      }
1371  
GetBodyTextValue()1372      std::string GetBodyTextValue() const
1373      {
1374          return hasPreviewText_ ? bodyTextInPreivewing_ : GetTextValue();
1375      }
1376  
IsPressSelectedBox()1377      bool IsPressSelectedBox()
1378      {
1379          return isPressSelectedBox_;
1380      }
1381  
1382      int32_t CheckPreviewTextValidate(const std::string& previewValue, const PreviewRange range) override;
1383  
1384      void ScrollPage(bool reverse, bool smooth = false,
1385          AccessibilityScrollType scrollType = AccessibilityScrollType::SCROLL_FULL) override;
InitScrollBarClickEvent()1386      void InitScrollBarClickEvent() override {}
1387  
OnFrameNodeChanged(FrameNodeChangeInfoFlag flag)1388      void OnFrameNodeChanged(FrameNodeChangeInfoFlag flag) override
1389      {
1390          selectOverlay_->OnAncestorNodeChanged(flag);
1391      }
1392  
GetSelectIndex(int32_t & start,int32_t & end)1393      void GetSelectIndex(int32_t& start, int32_t& end) const override
1394      {
1395          start = selectController_->GetStartIndex();
1396          end = selectController_->GetEndIndex();
1397      }
1398  
SetTextChangedAtCreation(bool changed)1399      void SetTextChangedAtCreation(bool changed)
1400      {
1401          isTextChangedAtCreation_ = changed;
1402      }
1403  
1404      bool IsResponseRegionExpandingNeededForStylus(const TouchEvent& touchEvent) const override;
1405  
1406      RectF ExpandDefaultResponseRegion(RectF& rect) override;
1407  
UpdateParentGlobalOffset()1408      void UpdateParentGlobalOffset()
1409      {
1410          parentGlobalOffset_ = GetPaintRectGlobalOffset();
1411      }
1412  
1413      PositionWithAffinity GetGlyphPositionAtCoordinate(int32_t x, int32_t y) override;
1414  
1415      bool InsertOrDeleteSpace(int32_t index) override;
1416  
1417      void DeleteRange(int32_t start, int32_t end) override;
1418  
1419      bool SetCaretOffset(int32_t caretPostion) override;
1420  
GetMultipleClickRecognizer()1421      const RefPtr<MultipleClickRecognizer>& GetMultipleClickRecognizer() const
1422      {
1423          return multipleClickRecognizer_;
1424      }
1425  
SetAdaptFontSize(const std::optional<Dimension> & adaptFontSize)1426      void SetAdaptFontSize(const std::optional<Dimension>& adaptFontSize)
1427      {
1428          adaptFontSize_ = adaptFontSize;
1429      }
1430  
1431      void ShowCaretAndStopTwinkling();
1432  
1433      void TriggerAvoidOnCaretChange();
1434  
1435      void TriggerAvoidWhenCaretGoesDown();
1436  
1437      bool IsTextEditableForStylus() const override;
1438      bool IsHandleDragging();
IsLTRLayout()1439      bool IsLTRLayout()
1440      {
1441          auto host = GetHost();
1442          CHECK_NULL_RETURN(host, true);
1443          return host->GetLayoutProperty()->GetNonAutoLayoutDirection() == TextDirection::LTR;
1444      }
1445  
GetLastCaretPos()1446      float GetLastCaretPos()
1447      {
1448          return lastCaretPos_;
1449      }
1450  
SetLastCaretPos(float lastCaretPos)1451      void SetLastCaretPos(float lastCaretPos)
1452      {
1453          lastCaretPos_ = lastCaretPos;
1454      }
1455  
SetEnableHapticFeedback(bool isEnabled)1456      void SetEnableHapticFeedback(bool isEnabled)
1457      {
1458          isEnableHapticFeedback_ = isEnabled;
1459      }
1460  
1461      void StartVibratorByIndexChange(int32_t currentIndex, int32_t preIndex);
1462      virtual void ProcessSelection();
1463      void AfterLayoutProcessCleanResponse(
1464          const RefPtr<CleanNodeResponseArea>& cleanNodeResponseArea);
1465  
1466      virtual float FontSizeConvertToPx(const Dimension& fontSize);
1467  
SetMaxFontSizeScale(float scale)1468      void SetMaxFontSizeScale(float scale)
1469      {
1470          maxFontSizeScale_ = scale;
1471      }
1472  
GetMaxFontSizeScale()1473      std::optional<float> GetMaxFontSizeScale()
1474      {
1475          return maxFontSizeScale_;
1476      }
1477  
1478  protected:
1479      virtual void InitDragEvent();
1480      void OnAttachToMainTree() override;
1481  
1482      void OnDetachFromMainTree() override;
1483  
IsReverse()1484      bool IsReverse() const override
1485      {
1486          return false;
1487      }
1488  
SelectOverlayIsOn()1489      bool SelectOverlayIsOn()
1490      {
1491          return selectOverlay_->SelectOverlayIsOn();
1492      }
1493  
SetIsSingleHandle(bool isSingleHandle)1494      void SetIsSingleHandle(bool isSingleHandle)
1495      {
1496          selectOverlay_->SetIsSingleHandle(isSingleHandle);
1497      }
1498  
1499      int32_t GetTouchIndex(const OffsetF& offset) override;
1500      void OnTextGestureSelectionUpdate(int32_t start, int32_t end, const TouchEventInfo& info) override;
1501      void OnTextGenstureSelectionEnd() override;
1502      void DoTextSelectionTouchCancel() override;
1503      void UpdateSelection(int32_t both);
1504      void UpdateSelection(int32_t start, int32_t end);
1505      virtual bool IsNeedProcessAutoFill();
1506  
1507      RefPtr<ContentController> contentController_;
1508      RefPtr<TextSelectController> selectController_;
1509      bool needToRefreshSelectOverlay_ = false;
1510      bool isTextChangedAtCreation_ = false;
1511  
1512  private:
1513      Offset ConvertTouchOffsetToTextOffset(const Offset& touchOffset);
1514      void GetTextSelectRectsInRangeAndWillChange();
1515      bool BeforeIMEInsertValue(const std::string& insertValue, int32_t offset);
1516      void AfterIMEInsertValue(const std::string& insertValue);
1517      bool BeforeIMEDeleteValue(const std::string& deleteValue, TextDeleteDirection direction, int32_t offset);
1518      void AfterIMEDeleteValue(const std::string& deleteValue, TextDeleteDirection direction);
1519      void OnAfterModifyDone() override;
1520      void HandleTouchEvent(const TouchEventInfo& info);
1521      void HandleTouchDown(const Offset& offset);
1522      void HandleTouchUp();
1523      void HandleTouchMove(const TouchLocationInfo& info);
1524      void UpdateCaretByTouchMove(const TouchLocationInfo& info);
1525      void InitDisableColor();
1526      void InitFocusEvent();
1527      void InitTouchEvent();
1528      void InitLongPressEvent();
1529      void InitClickEvent();
1530      void InitDragDropEvent();
1531      bool ProcessFocusIndexAction();
1532      std::function<DragDropInfo(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)> OnDragStart();
1533      std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)> OnDragDrop();
1534      void ShowSelectAfterDragEvent();
1535      void ClearDragDropEvent();
1536      std::function<void(Offset)> GetThumbnailCallback();
1537      bool HasStateStyle(UIState state) const;
1538  
1539      void OnTextInputScroll(float offset);
1540      void OnTextAreaScroll(float offset);
1541      bool OnScrollCallback(float offset, int32_t source) override;
1542      void OnScrollEndCallback() override;
1543      bool CheckSelectAreaVisible();
1544      void InitMouseEvent();
1545      void HandleHoverEffect(MouseInfo& info, bool isHover);
1546      void OnHover(bool isHover);
1547      void ChangeMouseState(
1548          const Offset location, const RefPtr<PipelineContext>& pipeline, int32_t frameId, bool isByPass = false);
1549      void HandleMouseEvent(MouseInfo& info);
1550      void FocusAndUpdateCaretByMouse(MouseInfo& info);
1551      void HandleRightMouseEvent(MouseInfo& info);
1552      void HandleRightMousePressEvent(MouseInfo& info);
1553      void HandleRightMouseReleaseEvent(MouseInfo& info);
1554      void HandleLeftMouseEvent(MouseInfo& info);
1555      void HandleLeftMousePressEvent(MouseInfo& info);
1556      void HandleLeftMouseMoveEvent(MouseInfo& info);
1557      void HandleLeftMouseReleaseEvent(MouseInfo& info);
1558      void StartVibratorByLongPress();
1559      void HandleLongPress(GestureEvent& info);
1560      bool CanChangeSelectState();
1561      void UpdateCaretPositionWithClamp(const int32_t& pos);
1562      void CursorMoveOnClick(const Offset& offset);
1563  
1564      void DelayProcessOverlay(const OverlayRequest& request = OverlayRequest());
1565      void ProcessOverlayAfterLayout(const OffsetF& prevOffset);
1566      void ProcessOverlay(const OverlayRequest& request = OverlayRequest());
1567  
1568      // when moving one handle causes shift of textRect, update x position of the other handle
1569      void SetHandlerOnMoveDone();
1570      void OnDetachFromFrameNode(FrameNode* node) override;
1571      void OnAttachContext(PipelineContext* context) override;
1572      void OnDetachContext(PipelineContext* context) override;
1573      void UpdateSelectionByMouseDoubleClick();
1574  
1575      void AfterSelection();
1576  
1577      void AutoFillValueChanged();
1578      void FireEventHubOnChange(const std::string& text);
1579      // The return value represents whether the editor content has change.
1580      bool FireOnTextChangeEvent();
1581      void AddTextFireOnChange();
1582  
1583      void FilterInitializeText();
1584  
1585      void UpdateCaretPositionByLastTouchOffset();
1586      bool UpdateCaretPosition();
1587      void UpdateCaretRect(bool isEditorValueChanged);
1588      void AdjustTextInReasonableArea();
1589      bool CharLineChanged(int32_t caretPosition);
1590  
1591      void ScheduleCursorTwinkling();
1592      void OnCursorTwinkling();
1593      void CheckIfNeedToResetKeyboard();
1594  
1595      float PreferredTextHeight(bool isPlaceholder, bool isAlgorithmMeasure = false);
1596  
1597      void SetCaretOffsetForEmptyTextOrPositionZero();
1598      void UpdateTextFieldManager(const Offset& offset, float height);
1599      void OnTextInputActionUpdate(TextInputAction value);
1600  
1601      void Delete(int32_t start, int32_t end);
1602      void CheckAndUpdateRecordBeforeOperation();
1603      void BeforeCreateLayoutWrapper() override;
1604      bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
1605      bool CursorInContentRegion();
1606      bool OffsetInContentRegion(const Offset& offset);
1607      void SetDisabledStyle();
1608  
1609      void CalculateDefaultCursor();
1610      void RequestKeyboardByFocusSwitch();
1611      bool IsModalCovered();
1612      void SetNeedToRequestKeyboardOnFocus();
1613      void SetAccessibilityAction() override;
1614      void SetAccessibilityActionGetAndSetCaretPosition();
1615      void SetAccessibilityActionOverlayAndSelection();
1616      void SetAccessibilityMoveTextAction();
1617      void SetAccessibilityScrollAction();
1618      void SetAccessibilityErrotText();
1619      void SetAccessibilityClearAction();
1620      void SetAccessibilityPasswordIconAction();
1621      void SetAccessibilityUnitAction();
1622  
1623      void UpdateCopyAllStatus();
1624      void RestorePreInlineStates();
1625      void ProcessRectPadding();
1626      void CalcInlineScrollRect(Rect& inlineScrollRect);
1627  
1628      bool ResetObscureTickCountDown();
1629      bool IsAccessibilityClick();
1630      bool IsOnUnitByPosition(const Offset& globalOffset);
1631      bool IsOnPasswordByPosition(const Offset& globalOffset);
1632      bool IsOnCleanNodeByPosition(const Offset& globalOffset);
1633      bool IsTouchAtLeftOffset(float currentOffsetX);
1634      void FilterExistText();
1635      void CreateErrorParagraph(const std::string& content);
1636      void UpdateErrorTextMargin();
1637      void UpdateSelectController();
1638      void CloseHandleAndSelect() override;
1639      void UpdateHandlesOffsetOnScroll(float offset);
1640  
1641      bool RepeatClickCaret(const Offset& offset, int32_t lastCaretIndex);
1642      bool RepeatClickCaret(const Offset& offset, const RectF& lastCaretRect);
1643      void PaintTextRect();
1644      void GetIconPaintRect(const RefPtr<TextInputResponseArea>& responseArea, RoundRect& paintRect);
1645      void GetInnerFocusPaintRect(RoundRect& paintRect);
1646      void PaintResponseAreaRect();
1647      void PaintCancelRect();
1648      void PaintUnitRect();
1649      void PaintPasswordRect();
CancelNodeIsShow()1650      bool CancelNodeIsShow()
1651      {
1652          auto cleanNodeArea = AceType::DynamicCast<CleanNodeResponseArea>(cleanNodeResponseArea_);
1653          CHECK_NULL_RETURN(cleanNodeArea, false);
1654          return cleanNodeArea->IsShow();
1655      }
1656  
1657      void InitPanEvent();
1658  
1659      void PasswordResponseKeyEvent();
1660      void UnitResponseKeyEvent();
1661      void ProcBorderAndUnderlineInBlurEvent();
1662      void ProcNormalInlineStateInBlurEvent();
1663      bool IsMouseOverScrollBar(const GestureEvent& info);
1664  #if defined(ENABLE_STANDARD_INPUT)
1665      std::optional<MiscServices::TextConfig> GetMiscTextConfig() const;
1666      void GetInlinePositionYAndHeight(double& positionY, double& height) const;
1667  #endif
1668      void NotifyOnEditChanged(bool isChanged);
1669      void ProcessResponseArea();
1670      bool HasInputOperation();
1671      AceAutoFillType ConvertToAceAutoFillType(TextInputType type);
1672      bool CheckAutoFill(bool isFromKeyBoard = false);
1673      void ScrollToSafeArea() const override;
1674      void RecordSubmitEvent() const;
1675      void UpdateCancelNode();
1676      void RequestKeyboardAfterLongPress();
1677      void UpdateBlurReason();
1678      void InitDragDropCallBack();
1679      void InitDragDropEventWithOutDragStart();
1680      void UpdatePasswordModeState();
1681      AceAutoFillType TextContentTypeToAceAutoFillType(const TextContentType& type);
1682      bool CheckAutoFillType(const AceAutoFillType& aceAutoFillAllType, bool isFromKeyBoard = false);
1683      bool GetAutoFillTriggeredStateByType(const AceAutoFillType& autoFillType);
1684      void SetAutoFillTriggeredStateByType(const AceAutoFillType& autoFillType);
1685      AceAutoFillType GetAutoFillType(bool isNeedToHitType = true);
1686      bool IsAutoFillPasswordType(const AceAutoFillType& autoFillType);
1687      void DoProcessAutoFill();
1688      void KeyboardContentTypeToInputType();
1689      void ProcessScroll();
1690      void ProcessCounter();
1691      void HandleParentGlobalOffsetChange();
1692      HintToTypeWrap GetHintType();
1693      HintToTypeWrap GetAutoFillTypeAndMetaData(bool isNeedToHitType = true);
1694      PaddingProperty GetPaddingByUserValue();
1695      void SetThemeAttr();
1696      void SetThemeBorderAttr();
1697      void ProcessInlinePaddingAndMargin();
1698      Offset ConvertGlobalToLocalOffset(const Offset& globalOffset);
1699      void HandleCountStyle();
1700      void HandleDeleteOnCounterScene();
1701      bool ParseFillContentJsonValue(const std::unique_ptr<JsonValue>& jsonObject,
1702          std::unordered_map<std::string, std::variant<std::string, bool, int32_t>>& map);
1703      void HandleContentSizeChange(const RectF& textRect);
1704  
UpdatePreviewIndex(int32_t start,int32_t end)1705      void UpdatePreviewIndex(int32_t start, int32_t end)
1706      {
1707          previewTextStart_ = start;
1708          previewTextEnd_ = end;
1709      }
1710  
1711      void CalculatePreviewingTextMovingLimit(const Offset& touchOffset, double& limitL, double& limitR);
1712      void UpdateParam(GestureEvent& info, bool shouldProcessOverlayAfterLayout);
1713      void OnCaretMoveDone(const TouchEventInfo& info);
1714      void HandleCrossPlatformInBlurEvent();
1715      void ModifyInnerStateInBlurEvent();
1716  
1717      void TwinklingByFocus();
1718  
1719      bool FinishTextPreviewByPreview(const std::string& insertValue);
1720  
1721      bool GetTouchInnerPreviewText(const Offset& offset) const;
1722      bool IsShowMenu(const std::optional<SelectionOptions>& options, bool defaultValue);
1723      bool IsContentRectNonPositive();
1724  
1725      void ReportEvent();
1726      void ResetPreviewTextState();
1727      TextFieldInfo GenerateTextFieldInfo();
1728      void AddTextFieldInfo();
1729      void RemoveTextFieldInfo();
1730      void UpdateTextFieldInfo();
1731      bool IsAutoFillUserName(const AceAutoFillType& autoFillType);
1732      bool HasAutoFillPasswordNode();
1733      bool IsTriggerAutoFillPassword();
1734      std::optional<TouchLocationInfo> GetAcceptedTouchLocationInfo(const TouchEventInfo& info);
1735  
1736      RectF frameRect_;
1737      RectF textRect_;
1738      RefPtr<Paragraph> paragraph_;
1739      WeakPtr<FrameNode> errorTextNode_;
1740      RefPtr<Paragraph> dragParagraph_;
1741      InlineMeasureItem inlineMeasureItem_;
1742      TextStyle nextLineUtilTextStyle_;
1743  
1744      RefPtr<ClickEvent> clickListener_;
1745      RefPtr<TouchEventImpl> touchListener_;
1746      RefPtr<ScrollableEvent> scrollableEvent_;
1747      RefPtr<InputEvent> mouseEvent_;
1748      RefPtr<InputEvent> hoverEvent_;
1749      RefPtr<LongPressEvent> longPressEvent_;
1750      CursorPositionType cursorPositionType_ = CursorPositionType::NORMAL;
1751  
1752      // What the keyboard should appears.
1753      TextInputType keyboard_ = TextInputType::UNSPECIFIED;
1754      // Action when "enter" pressed.
1755      TextInputAction action_ = TextInputAction::UNSPECIFIED;
1756      TextDirection textDirection_ = TextDirection::LTR;
1757  
1758      OffsetF parentGlobalOffset_;
1759      OffsetF lastTouchOffset_;
1760      std::optional<PaddingPropertyF> utilPadding_;
1761  
1762      bool setBorderFlag_ = true;
1763      BorderWidthProperty lastDiffBorderWidth_;
1764      BorderColorProperty lastDiffBorderColor_;
1765  
1766      HandleMoveStatus handleMoveStatus_;
1767      bool cursorVisible_ = false;
1768      bool focusEventInitialized_ = false;
1769      bool isMousePressed_ = false;
1770      bool textObscured_ = true;
1771      bool enableTouchAndHoverEffect_ = true;
1772      bool isOnHover_ = false;
1773      bool needToRequestKeyboardInner_ = false;
1774      bool needToRequestKeyboardOnFocus_ = false;
1775      bool isTransparent_ = false;
1776      bool contChange_ = false;
1777      bool counterChange_ = false;
1778      WeakPtr<LayoutWrapper> counterTextNode_;
1779      std::optional<int32_t> surfaceChangedCallbackId_;
1780      std::optional<int32_t> surfacePositionChangedCallbackId_;
1781  
1782      SelectionMode selectionMode_ = SelectionMode::NONE;
1783      CaretUpdateType caretUpdateType_ = CaretUpdateType::NONE;
1784      bool scrollable_ = true;
1785      bool blockPress_ = false;
1786      bool isPressSelectedBox_ = false;
1787      float previewWidth_ = 0.0f;
1788      float lastTextRectY_ = 0.0f;
1789      std::optional<DisplayMode> barState_;
1790  
1791      uint32_t twinklingInterval_ = 0;
1792      int32_t obscureTickCountDown_ = 0;
1793      int32_t nakedCharPosition_ = -1;
1794      bool obscuredChange_ = false;
1795      float currentOffset_ = 0.0f;
1796      float countHeight_ = 0.0f;
1797      Dimension underlineWidth_ = 1.0_px;
1798      Color underlineColor_;
1799      UserUnderlineColor userUnderlineColor_ = UserUnderlineColor();
1800      bool scrollBarVisible_ = false;
1801      bool isCounterIdealheight_ = false;
1802      float maxFrameOffsetY_ = 0.0f;
1803      float maxFrameHeight_ = 0.0f;
1804  
1805      CancelableCallback<void()> cursorTwinklingTask_;
1806  
1807      std::list<std::unique_ptr<TextInputFormatter>> textInputFormatters_;
1808  
1809      RefPtr<TextFieldController> textFieldController_;
1810      WeakPtr<Referenced> jsTextEditableController_;
1811      RefPtr<TextEditController> textEditingController_;
1812      TextEditingValueNG textEditingValue_;
1813      // controls redraw of overlay modifier, update when need to redraw
1814      bool changeSelectedRects_ = false;
1815      RefPtr<TextFieldOverlayModifier> textFieldOverlayModifier_;
1816      RefPtr<TextFieldContentModifier> textFieldContentModifier_;
1817      RefPtr<TextFieldForegroundModifier> textFieldForegroundModifier_;
1818      WeakPtr<TextFieldTheme> textFieldTheme_;
1819      ACE_DISALLOW_COPY_AND_MOVE(TextFieldPattern);
1820  
1821      int32_t dragTextStart_ = 0;
1822      int32_t dragTextEnd_ = 0;
1823      std::string dragValue_;
1824      RefPtr<FrameNode> dragNode_;
1825      DragStatus dragStatus_ = DragStatus::NONE;          // The status of the dragged initiator
1826      DragStatus dragRecipientStatus_ = DragStatus::NONE;
1827      RefPtr<Clipboard> clipboard_;
1828      std::vector<TextEditingValueNG> operationRecords_;
1829      std::vector<TextEditingValueNG> redoOperationRecords_;
1830      BorderRadiusProperty borderRadius_;
1831      PasswordModeStyle passwordModeStyle_;
1832      SelectMenuInfo selectMenuInfo_;
1833  
1834      RefPtr<PanEvent> boxSelectPanEvent_;
1835  
1836      // inline
1837      bool isTextInput_ = false;
1838      bool inlineSelectAllFlag_ = false;
1839      bool inlineFocusState_ = false;
1840      float inlineSingleLineHeight_ = 0.0f;
1841      float inlinePadding_ = 0.0f;
1842  
1843      bool isOritationListenerRegisted_ = false;
1844  
1845  #if defined(ENABLE_STANDARD_INPUT)
1846      sptr<OHOS::MiscServices::OnTextChangedListener> textChangeListener_;
1847  #else
1848      RefPtr<TextInputConnection> connection_;
1849  #endif
1850  #if defined(OHOS_STANDARD_SYSTEM) && !defined(PREVIEW)
1851      bool imeAttached_ = false;
1852      bool imeShown_ = false;
1853  #endif
1854      BlurReason blurReason_ = BlurReason::FOCUS_SWITCH;
1855      bool isFocusedBeforeClick_ = false;
1856      bool isCustomKeyboardAttached_ = false;
1857      std::function<void()> customKeyboardBuilder_;
1858      RefPtr<UINode> customKeyboard_;
1859      RefPtr<OverlayManager> keyboardOverlay_;
1860      bool isCustomFont_ = false;
1861      TimeStamp lastClickTimeStamp_;
1862      float paragraphWidth_ = 0.0f;
1863  
1864      std::queue<int32_t> deleteBackwardOperations_;
1865      std::queue<int32_t> deleteForwardOperations_;
1866      std::queue<SourceAndValueInfo> insertValueOperations_;
1867      std::queue<InputOperation> inputOperations_;
1868      bool leftMouseCanMove_ = false;
1869      bool isLongPress_ = false;
1870      bool isEdit_ = false;
1871      CaretStatus caretStatus_ = CaretStatus::NONE;
1872      RefPtr<NG::UINode> unitNode_;
1873      RefPtr<TextInputResponseArea> responseArea_;
1874      std::string lastAutoFillTextValue_;
1875      RefPtr<TextInputResponseArea> cleanNodeResponseArea_;
1876      bool isSupportCameraInput_ = false;
1877      std::function<void()> processOverlayDelayTask_;
1878      FocuseIndex focusIndex_ = FocuseIndex::TEXT;
1879      TouchAndMoveCaretState moveCaretState_;
1880      bool needSelectAll_ = false;
1881      bool isModifyDone_ = false;
1882      bool initTextRect_ = false;
1883      bool colorModeChange_ = false;
1884      bool isKeyboardClosedByUser_ = false;
1885      bool lockRecord_ = false;
1886      bool isFillRequestFinish_ = true;
1887      bool showCountBorderStyle_ = false;
1888      RefPtr<TextFieldSelectOverlay> selectOverlay_;
1889      bool keyboardAvoidance_ = false;
1890      OffsetF movingCaretOffset_;
1891      bool textInputBlurOnSubmit_ = true;
1892      bool textAreaBlurOnSubmit_ = false;
1893      std::string autoFillUserName_;
1894      std::string autoFillNewPassword_;
1895      bool autoFillOtherAccount_ = false;
1896      uint32_t autoFillSessionId_ = 0;
1897      std::unordered_map<std::string, std::variant<std::string, bool, int32_t>> fillContentMap_;
1898  
1899      bool isDetachFromMainTree_ = false;
1900      Dimension previewUnderlineWidth_ = 2.0_vp;
1901      bool hasSupportedPreviewText_ = true;
1902      bool hasPreviewText_ = false;
1903      std::queue<PreviewTextInfo> previewTextOperation_;
1904      int32_t previewTextStart_ = -1;
1905      int32_t previewTextEnd_ = -1;
1906      std::string bodyTextInPreivewing_;
1907      PreviewRange lastCursorRange_ = {};
1908      std::string lastTextValue_ = "";
1909      float lastCursorTop_ = 0.0f;
1910      bool showKeyBoardOnFocus_ = true;
1911      bool isTextSelectionMenuShow_ = true;
1912      bool isMoveCaretAnywhere_ = false;
1913      bool isTouchPreviewText_ = false;
1914      bool isCaretTwinkling_ = false;
1915      bool isEnableHapticFeedback_ = true;
1916      RefPtr<MultipleClickRecognizer> multipleClickRecognizer_ = MakeRefPtr<MultipleClickRecognizer>();
1917      RefPtr<AIWriteAdapter> aiWriteAdapter_ = MakeRefPtr<AIWriteAdapter>();
1918      std::optional<Dimension> adaptFontSize_;
1919      uint32_t longPressFingerNum_ = 0;
1920      WeakPtr<FrameNode> firstAutoFillContainerNode_;
1921      std::optional<float> maxFontSizeScale_;
1922      float lastCaretPos_ = 0.0f;
1923      bool hasMousePressed_ = false;
1924  };
1925  } // namespace OHOS::Ace::NG
1926  
1927  #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_FIELD_TEXT_FIELD_PATTERN_H
1928