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