• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 #include "core/components_ng/pattern/text_field/text_field_manager.h"
17 
18 #include "base/geometry/dimension.h"
19 #include "base/memory/ace_type.h"
20 #include "base/utils/utils.h"
21 #include "core/common/ime/text_input_type.h"
22 #include "core/components_ng/event/focus_hub.h"
23 #include "core/components_ng/pattern/navigation/navigation_pattern.h"
24 #include "core/components_ng/pattern/scrollable/scrollable_pattern.h"
25 #include "core/components_ng/pattern/text/text_base.h"
26 #include "core/components_ng/pattern/text_field/text_field_pattern.h"
27 
28 namespace OHOS::Ace::NG {
29 namespace {
30 constexpr Dimension RESERVE_BOTTOM_HEIGHT = 24.0_vp;
31 } // namespace
32 
ClearOnFocusTextField()33 void TextFieldManagerNG::ClearOnFocusTextField()
34 {
35     onFocusTextField_ = nullptr;
36 }
37 
ClearOnFocusTextField(int32_t id)38 void TextFieldManagerNG::ClearOnFocusTextField(int32_t id)
39 {
40     if (onFocusTextFieldId == id) {
41         onFocusTextField_ = nullptr;
42         focusFieldIsInline = false;
43         optionalPosition_ = std::nullopt;
44         usingCustomKeyboardAvoid_ = false;
45         isScrollableChild_ = false;
46     }
47 }
48 
OnBackPressed()49 bool TextFieldManagerNG::OnBackPressed()
50 {
51     auto pattern = onFocusTextField_.Upgrade();
52     CHECK_NULL_RETURN(pattern, false);
53     auto textBasePattern = AceType::DynamicCast<TextBase>(pattern);
54     CHECK_NULL_RETURN(textBasePattern, false);
55     return textBasePattern->OnBackPressed();
56 }
57 
SetClickPosition(const Offset & position)58 void TextFieldManagerNG::SetClickPosition(const Offset& position)
59 {
60     auto pipeline = PipelineContext::GetCurrentContextSafely();
61     CHECK_NULL_VOID(pipeline);
62     auto rootHeight = pipeline->GetRootHeight();
63     if (GreatOrEqual(position.GetY(), rootHeight)) {
64         auto pattern = onFocusTextField_.Upgrade();
65         CHECK_NULL_VOID(pattern);
66         auto host = pattern->GetHost();
67         CHECK_NULL_VOID(host);
68         auto parent = host->GetAncestorNodeOfFrame(true);
69         while (parent) {
70             if (parent->GetTag() == "Panel" || parent->GetTag() == "SheetPage") {
71                 return;
72             }
73             parent = parent->GetAncestorNodeOfFrame(true);
74         }
75     }
76     if (LessOrEqual(position.GetY(), 0.0f)) {
77         return;
78     }
79     auto rootWidth = pipeline->GetRootWidth();
80     if (GreatOrEqual(position.GetX(), rootWidth) || LessNotEqual(position.GetX(), 0.0f)) {
81         return;
82     }
83     position_ = position;
84     optionalPosition_ = position;
85 }
86 
FindScrollableOfFocusedTextField(const RefPtr<FrameNode> & textField)87 RefPtr<FrameNode> TextFieldManagerNG::FindScrollableOfFocusedTextField(const RefPtr<FrameNode>& textField)
88 {
89     CHECK_NULL_RETURN(textField, {});
90     auto parent = textField->GetAncestorNodeOfFrame(true);
91     while (parent) {
92         auto pattern = parent->GetPattern<ScrollablePattern>();
93         if (pattern) {
94             return parent;
95         }
96         parent = parent->GetAncestorNodeOfFrame(true);
97     }
98     return {};
99 }
100 
GetFocusedNodeCaretRect()101 RectF TextFieldManagerNG::GetFocusedNodeCaretRect()
102 {
103     auto node = onFocusTextField_.Upgrade();
104     CHECK_NULL_RETURN(node, RectF());
105     auto frameNode = node->GetHost();
106     CHECK_NULL_RETURN(frameNode, RectF());
107     auto textBase = DynamicCast<TextBase>(node);
108     CHECK_NULL_RETURN(textBase, RectF());
109     auto caretRect = textBase->GetCaretRect() + frameNode->GetTransformRectRelativeToWindow();
110     return caretRect;
111 }
112 
TriggerCustomKeyboardAvoid()113 void TextFieldManagerNG::TriggerCustomKeyboardAvoid()
114 {
115     CHECK_NULL_VOID(UsingCustomKeyboardAvoid());
116     auto pattern = onFocusTextField_.Upgrade();
117     CHECK_NULL_VOID(pattern);
118     auto curPattern = DynamicCast<TextFieldPattern>(pattern);
119     CHECK_NULL_VOID(curPattern);
120     if (!curPattern->GetIsCustomKeyboardAttached()) {
121         return;
122     }
123     auto caretHeight = curPattern->GetCaretRect().Height();
124     auto safeHeight = caretHeight + curPattern->GetCaretRect().GetY();
125     if (curPattern->GetCaretRect().GetY() > caretHeight) {
126         safeHeight = caretHeight;
127     }
128     auto keyboardOverLay = curPattern->GetKeyboardOverLay();
129     CHECK_NULL_VOID(keyboardOverLay);
130     auto host = curPattern->GetHost();
131     CHECK_NULL_VOID(host);
132     auto nodeId = host->GetId();
133     keyboardOverLay->AvoidCustomKeyboard(nodeId, safeHeight);
134 }
135 
TriggerAvoidOnCaretChange()136 void TextFieldManagerNG::TriggerAvoidOnCaretChange()
137 {
138     auto pattern = onFocusTextField_.Upgrade();
139     CHECK_NULL_VOID(pattern);
140     auto host = pattern->GetHost();
141     CHECK_NULL_VOID(host);
142     auto pipeline = host->GetContext();
143     CHECK_NULL_VOID(pipeline);
144     auto safeAreaManager = pipeline->GetSafeAreaManager();
145     CHECK_NULL_VOID(safeAreaManager);
146     if (!pipeline->UsingCaretAvoidMode() || NearEqual(safeAreaManager->GetKeyboardInset().Length(), 0)) {
147         return;
148     }
149     if (UsingCustomKeyboardAvoid()) {
150         ScrollTextFieldToSafeArea();
151         TriggerCustomKeyboardAvoid();
152     } else {
153         ScrollTextFieldToSafeArea();
154         auto keyboardInset = safeAreaManager->GetKeyboardInset();
155         lastKeyboardOffset_ = safeAreaManager->GetKeyboardOffsetDirectly();
156         Rect keyboardRect;
157         keyboardRect.SetRect(0, 0, 0, keyboardInset.Length());
158         pipeline->OnVirtualKeyboardAreaChange(keyboardRect,
159             GetFocusedNodeCaretRect().Top(), GetHeight());
160     }
161     auto currentKeyboardOffset = safeAreaManager->GetKeyboardOffsetDirectly();
162     if (currentKeyboardOffset != lastKeyboardOffset_) {
163         AvoidKeyboardInSheet(host);
164     }
165 }
166 
GetOnFocusTextFieldInfo(const WeakPtr<Pattern> & onFocusTextField)167 void TextFieldManagerNG::GetOnFocusTextFieldInfo(const WeakPtr<Pattern>& onFocusTextField)
168 {
169     auto node = onFocusTextField.Upgrade();
170     CHECK_NULL_VOID(node);
171     auto frameNode = node->GetHost();
172     CHECK_NULL_VOID(frameNode);
173     auto scrollableNode = FindScrollableOfFocusedTextField(frameNode);
174     CHECK_NULL_VOID(scrollableNode);
175     auto scrollPattern = scrollableNode->GetPattern<ScrollablePattern>();
176     CHECK_NULL_VOID(scrollPattern);
177     isScrollableChild_ = scrollPattern->IsScrollToSafeAreaHelper();
178     TAG_LOGI(ACE_KEYBOARD, "isScrollableChild_: %{public}d", isScrollableChild_);
179 }
180 
ScrollToSafeAreaHelper(const SafeAreaInsets::Inset & bottomInset,bool isShowKeyboard)181 bool TextFieldManagerNG::ScrollToSafeAreaHelper(
182     const SafeAreaInsets::Inset& bottomInset, bool isShowKeyboard)
183 {
184     auto node = onFocusTextField_.Upgrade();
185     CHECK_NULL_RETURN(node, false);
186     auto frameNode = node->GetHost();
187     CHECK_NULL_RETURN(frameNode, false);
188     auto textBase = DynamicCast<TextBase>(node);
189     CHECK_NULL_RETURN(textBase, false);
190     textBase->OnVirtualKeyboardAreaChanged();
191 
192     auto scrollableNode = FindScrollableOfFocusedTextField(frameNode);
193     CHECK_NULL_RETURN(scrollableNode, false);
194     auto scrollPattern = scrollableNode->GetPattern<ScrollablePattern>();
195     CHECK_NULL_RETURN(scrollPattern && scrollPattern->IsScrollToSafeAreaHelper(), false);
196     CHECK_NULL_RETURN(scrollPattern->GetAxis() != Axis::HORIZONTAL, false);
197 
198     auto scrollableRect = scrollableNode->GetTransformRectRelativeToWindow();
199     if (isShowKeyboard) {
200         CHECK_NULL_RETURN(scrollableRect.Top() < bottomInset.start, false);
201     }
202 
203     auto pipeline = frameNode->GetContext();
204     CHECK_NULL_RETURN(pipeline, false);
205     auto safeAreaManager = pipeline->GetSafeAreaManager();
206     CHECK_NULL_RETURN(safeAreaManager, false);
207     if (pipeline->UsingCaretAvoidMode()) {
208         scrollableRect.SetTop(scrollableRect.Top() - safeAreaManager->GetKeyboardOffset());
209     }
210 
211     auto caretRect = textBase->GetCaretRect() + frameNode->GetPositionToWindowWithTransform();
212     auto diffTop = caretRect.Top() - scrollableRect.Top();
213     // caret height larger scroll's content region
214     if (isShowKeyboard && diffTop <= 0 && LessNotEqual(bottomInset.start,
215         (caretRect.Bottom() + RESERVE_BOTTOM_HEIGHT.ConvertToPx()))) {
216         return false;
217     }
218 
219     // caret above scroll's content region
220     if (diffTop < 0) {
221         TAG_LOGI(ACE_KEYBOARD, "scrollRect:%{public}s caretRect:%{public}s totalOffset()=%{public}f diffTop=%{public}f",
222             scrollableRect.ToString().c_str(), caretRect.ToString().c_str(), scrollPattern->GetTotalOffset(), diffTop);
223         scrollPattern->ScrollTo(scrollPattern->GetTotalOffset() + diffTop);
224         return true;
225     }
226 
227     // caret inner scroll's content region
228     if (isShowKeyboard && LessNotEqual((caretRect.Bottom() + RESERVE_BOTTOM_HEIGHT.ConvertToPx()), bottomInset.start)) {
229         return false;
230     }
231 
232     // caret below safeArea
233     float diffBot = 0.0f;
234 
235     auto scrollBottom = isShowKeyboard && GreatOrEqual(scrollableRect.Bottom(), bottomInset.start) ?
236         bottomInset.start : scrollableRect.Bottom();
237     diffBot = scrollBottom - caretRect.Bottom() - RESERVE_BOTTOM_HEIGHT.ConvertToPx();
238     CHECK_NULL_RETURN(diffBot < 0, false);
239     TAG_LOGI(ACE_KEYBOARD, "scrollRect:%{public}s caretRect:%{public}s totalOffset()=%{public}f diffBot=%{public}f",
240         scrollableRect.ToString().c_str(), caretRect.ToString().c_str(), scrollPattern->GetTotalOffset(), diffBot);
241     scrollPattern->ScrollTo(scrollPattern->GetTotalOffset() - diffBot);
242     return true;
243 }
244 
ScrollTextFieldToSafeArea()245 bool TextFieldManagerNG::ScrollTextFieldToSafeArea()
246 {
247     auto pipeline = PipelineContext::GetCurrentContext();
248     CHECK_NULL_RETURN(pipeline, false);
249     auto keyboardInset = pipeline->GetSafeAreaManager()->GetKeyboardInset();
250     bool isShowKeyboard = keyboardInset.IsValid();
251     if (isShowKeyboard) {
252         auto bottomInset = pipeline->GetSafeArea().bottom_.Combine(keyboardInset);
253         CHECK_NULL_RETURN(bottomInset.IsValid(), false);
254         return ScrollToSafeAreaHelper(bottomInset, isShowKeyboard);
255     } else if (pipeline->GetSafeAreaManager()->KeyboardSafeAreaEnabled()) {
256         // hide keyboard only scroll when keyboard avoid mode is resize
257         return ScrollToSafeAreaHelper({0, 0}, isShowKeyboard);
258     }
259     return false;
260 }
261 
SetHeight(float height)262 void TextFieldManagerNG::SetHeight(float height)
263 {
264     height_ = height + RESERVE_BOTTOM_HEIGHT.ConvertToPx();
265 }
266 
UpdateScrollableParentViewPort(const RefPtr<FrameNode> & node)267 void TextFieldManagerNG::UpdateScrollableParentViewPort(const RefPtr<FrameNode>& node)
268 {
269     CHECK_NULL_VOID(node);
270     auto scrollableNode = FindScrollableOfFocusedTextField(node);
271     CHECK_NULL_VOID(scrollableNode);
272     auto scrollPattern = scrollableNode->GetPattern<ScrollablePattern>();
273     CHECK_NULL_VOID(scrollPattern);
274     if (scrollPattern->GetAxis() == Axis::HORIZONTAL) {
275         return;
276     }
277     auto scrollableRect = scrollableNode->GetTransformRectRelativeToWindow();
278     scrollableNode->SetViewPort(scrollableRect);
279 }
280 
AvoidKeyBoardInNavigation()281 void TextFieldManagerNG::AvoidKeyBoardInNavigation()
282 {
283     auto node = onFocusTextField_.Upgrade();
284     auto pipeline = PipelineContext::GetCurrentContext();
285     CHECK_NULL_VOID(pipeline);
286     auto manager = pipeline->GetSafeAreaManager();
287     auto avoidKeyboardOffset =  manager ? manager->GetKeyboardOffset() : 0.0f;
288     if (!node) {
289         auto navNode = weakNavNode_.Upgrade();
290         CHECK_NULL_VOID(navNode);
291         SetNavContentAvoidKeyboardOffset(navNode, avoidKeyboardOffset);
292         return;
293     }
294     auto frameNode = node->GetHost();
295     CHECK_NULL_VOID(frameNode);
296     auto preNavNode = weakNavNode_.Upgrade();
297     if (preNavNode) {
298         SetNavContentAvoidKeyboardOffset(preNavNode, 0.0f);
299     }
300     auto navNode = FindNavNode(frameNode);
301     CHECK_NULL_VOID(navNode);
302     weakNavNode_ = navNode;
303     SetNavContentAvoidKeyboardOffset(navNode, avoidKeyboardOffset);
304 }
305 
AvoidKeyboardInSheet(const RefPtr<FrameNode> & textField)306 void TextFieldManagerNG::AvoidKeyboardInSheet(const RefPtr<FrameNode>& textField)
307 {
308     CHECK_NULL_VOID(textField);
309     auto parent = textField->GetAncestorNodeOfFrame(true);
310     bool findSheet = false;
311     while (parent) {
312         if (parent->GetHostTag() == V2::SHEET_PAGE_TAG) {
313             findSheet = true;
314             break;
315         }
316         parent = parent->GetAncestorNodeOfFrame(true);
317     }
318     CHECK_NULL_VOID(parent);
319     auto sheetNodePattern = parent->GetPattern<SheetPresentationPattern>();
320     CHECK_NULL_VOID(sheetNodePattern);
321     TAG_LOGI(ACE_KEYBOARD, "Force AvoidKeyboard in sheet");
322     sheetNodePattern->AvoidSafeArea(true);
323 }
324 
FindNavNode(const RefPtr<FrameNode> & textField)325 RefPtr<FrameNode> TextFieldManagerNG::FindNavNode(const RefPtr<FrameNode>& textField)
326 {
327     CHECK_NULL_RETURN(textField, nullptr);
328     auto parent = textField->GetAncestorNodeOfFrame(true);
329     RefPtr<FrameNode> ret = nullptr;
330     while (parent) {
331         // when the sheet showed in navdestination, sheet replaced navdestination to do avoid keyboard.
332         if (parent->GetHostTag() == V2::SHEET_WRAPPER_TAG) {
333             auto sheetNode = parent->GetChildAtIndex(0);
334             CHECK_NULL_RETURN(sheetNode, nullptr);
335             return AceType::DynamicCast<FrameNode>(sheetNode);
336         }
337         if (parent->GetHostTag() == V2::DIALOG_ETS_TAG) {
338             return AceType::DynamicCast<FrameNode>(parent);
339         }
340         if (parent->GetHostTag() == V2::NAVDESTINATION_VIEW_ETS_TAG ||
341             parent->GetHostTag() == V2::NAVBAR_ETS_TAG) {
342                 ret = parent;
343                 break;
344             }
345         parent = parent->GetAncestorNodeOfFrame(true);
346     }
347     CHECK_NULL_RETURN(ret, nullptr);
348 
349     // return navdestination or navBar if the closest ancestor navigation can expandKeyboard
350     // if can't, recursively find the ancestor navigation can expandKeyboard.
351     auto navigationNode = ret->GetAncestorNodeOfFrame(true);
352     while (navigationNode) {
353         if (navigationNode->GetHostTag() == V2::NAVIGATION_VIEW_ETS_TAG) {
354             break;
355         }
356         navigationNode = navigationNode->GetAncestorNodeOfFrame(true);
357     }
358     CHECK_NULL_RETURN(navigationNode, nullptr);
359     auto layoutProperty = navigationNode->GetLayoutProperty<NavigationLayoutProperty>();
360     CHECK_NULL_RETURN(layoutProperty, nullptr);
361     auto& opts = layoutProperty->GetSafeAreaExpandOpts();
362 
363     // if the extended keyboard area is set for the navigation, top navdestination or navbar need to avoid keyboard,
364     // otherwise don't aovid, following parent navigation.
365     bool isExpandKeyboard = opts && (opts->type & SAFE_AREA_TYPE_KEYBOARD) && (opts->edges & SAFE_AREA_EDGE_BOTTOM);
366     if (isExpandKeyboard) {
367         return ret;
368     }
369     auto mayAvoidNavContentNode = FindNavNode(navigationNode);
370     if (mayAvoidNavContentNode) {
371         return mayAvoidNavContentNode;
372     }
373     SetNavContentAvoidKeyboardOffset(ret, 0.0f);
374     return nullptr;
375 }
376 
SetNavContentAvoidKeyboardOffset(RefPtr<FrameNode> navNode,float avoidKeyboardOffset)377 void TextFieldManagerNG::SetNavContentAvoidKeyboardOffset(RefPtr<FrameNode> navNode, float avoidKeyboardOffset)
378 {
379     auto navDestinationNode = AceType::DynamicCast<NavDestinationGroupNode>(navNode);
380     if (navDestinationNode) {
381         TAG_LOGI(ACE_KEYBOARD, "navNode id:%{public}d, avoidKeyboardOffset:%{public}f", navNode->GetId(),
382             avoidKeyboardOffset);
383         auto pattern = navDestinationNode->GetPattern<NavDestinationPattern>();
384         if (pattern) {
385             avoidKeyboardOffset = pattern->NeedIgnoreKeyboard() ? 0.0f : avoidKeyboardOffset;
386             pattern->SetAvoidKeyboardOffset(avoidKeyboardOffset);
387         }
388     }
389     auto navBarNode = AceType::DynamicCast<NavBarNode>(navNode);
390     if (navBarNode) {
391         auto pattern = navBarNode->GetPattern<NavBarPattern>();
392         if (pattern) {
393             pattern->SetAvoidKeyboardOffset(avoidKeyboardOffset);
394         }
395     }
396     navNode->MarkDirtyNode(PROPERTY_UPDATE_LAYOUT);
397 }
398 
AddTextFieldInfo(const TextFieldInfo & textFieldInfo)399 void TextFieldManagerNG::AddTextFieldInfo(const TextFieldInfo& textFieldInfo)
400 {
401     if (textFieldInfo.nodeId == -1 || textFieldInfo.autoFillContainerNodeId == -1) {
402         return;
403     }
404 
405     auto containerNodeIter = textFieldInfoMap_.find(textFieldInfo.autoFillContainerNodeId);
406     if (containerNodeIter != textFieldInfoMap_.end()) {
407         auto& innerTextFieldMap = containerNodeIter->second;
408         innerTextFieldMap[textFieldInfo.nodeId] = textFieldInfo;
409     } else {
410         std::unordered_map<int32_t, TextFieldInfo> innerTextFieldInfoMap;
411         innerTextFieldInfoMap[textFieldInfo.nodeId] = textFieldInfo;
412         textFieldInfoMap_[textFieldInfo.autoFillContainerNodeId] = innerTextFieldInfoMap;
413     }
414 }
415 
RemoveTextFieldInfo(const int32_t & autoFillContainerNodeId,const int32_t & nodeId)416 void TextFieldManagerNG::RemoveTextFieldInfo(const int32_t& autoFillContainerNodeId, const int32_t& nodeId)
417 {
418     auto containerNodeIter = textFieldInfoMap_.find(autoFillContainerNodeId);
419     if (containerNodeIter != textFieldInfoMap_.end()) {
420         auto& innerTextFieldInfoMap = containerNodeIter->second;
421         auto textFieldNodeIter = innerTextFieldInfoMap.find(nodeId);
422         if (textFieldNodeIter != innerTextFieldInfoMap.end()) {
423             innerTextFieldInfoMap.erase(textFieldNodeIter);
424         }
425     }
426 }
427 
UpdateTextFieldInfo(const TextFieldInfo & textFieldInfo)428 void TextFieldManagerNG::UpdateTextFieldInfo(const TextFieldInfo& textFieldInfo)
429 {
430     if (textFieldInfo.nodeId == -1 || textFieldInfo.autoFillContainerNodeId == -1) {
431         return;
432     }
433     auto containerNodeIter = textFieldInfoMap_.find(textFieldInfo.autoFillContainerNodeId);
434     if (containerNodeIter != textFieldInfoMap_.end()) {
435         auto& innerTextFieldInfoMap = containerNodeIter->second;
436         auto textFieldNodeIter = innerTextFieldInfoMap.find(textFieldInfo.nodeId);
437         if (textFieldNodeIter != innerTextFieldInfoMap.end()) {
438             innerTextFieldInfoMap.erase(textFieldNodeIter);
439         }
440         innerTextFieldInfoMap[textFieldInfo.nodeId] = textFieldInfo;
441     } else {
442         AddTextFieldInfo(textFieldInfo);
443     }
444 }
445 
HasAutoFillPasswordNodeInContainer(const int32_t & autoFillContainerNodeId,const int32_t & nodeId)446 bool TextFieldManagerNG::HasAutoFillPasswordNodeInContainer(
447     const int32_t& autoFillContainerNodeId, const int32_t& nodeId)
448 {
449     auto containerNodeIter = textFieldInfoMap_.find(autoFillContainerNodeId);
450     if (containerNodeIter == textFieldInfoMap_.end()) {
451         return false;
452     }
453 
454     auto& innerTextFieldInfoMap = containerNodeIter->second;
455     auto textFieldNodeIter = innerTextFieldInfoMap.find(nodeId);
456     if (textFieldNodeIter == innerTextFieldInfoMap.end()) {
457         return false;
458     }
459 
460     for (const auto& textField : innerTextFieldInfoMap) {
461         auto textFieldId = textField.first;
462         auto textFieldInfo = textField.second;
463         if (textFieldId == nodeId) {
464             continue;
465         }
466 
467         auto isPasswordType = IsAutoFillPasswordType(textFieldInfo);
468         if (isPasswordType && textFieldInfo.enableAutoFill) {
469             return true;
470         }
471     }
472 
473     return false;
474 }
475 
IsAutoFillPasswordType(const TextFieldInfo & textFieldInfo)476 bool TextFieldManagerNG::IsAutoFillPasswordType(const TextFieldInfo& textFieldInfo)
477 {
478     return textFieldInfo.inputType == TextInputType::VISIBLE_PASSWORD ||
479            textFieldInfo.inputType == TextInputType::NEW_PASSWORD ||
480            textFieldInfo.inputType == TextInputType::NUMBER_PASSWORD ||
481            textFieldInfo.contentType == TextContentType::VISIBLE_PASSWORD ||
482            textFieldInfo.contentType == TextContentType::NEW_PASSWORD;
483 }
484 
~TextFieldManagerNG()485 TextFieldManagerNG::~TextFieldManagerNG()
486 {
487     textFieldInfoMap_.clear();
488 }
489 } // namespace OHOS::Ace::NG
490