diff --git a/adapter/ohos/entrance/ace_container.cpp b/adapter/ohos/entrance/ace_container.cpp index 16948c38e9e221e1e342b2a0c0ee7def23589323..ddd95d66298485fa23b3edbdb4c4df032d337eed 100644 --- a/adapter/ohos/entrance/ace_container.cpp +++ b/adapter/ohos/entrance/ace_container.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -86,6 +86,8 @@ namespace OHOS::Ace::Platform { namespace { constexpr uint32_t DIRECTION_KEY = 0b1000; +constexpr uint32_t POPUPSIZE_HEIGHT = 200; +constexpr uint32_t POPUPSIZE_WIDTH = 400; #ifdef _ARM64_ const std::string ASSET_LIBARCH_PATH = "/lib/arm64"; @@ -1124,24 +1126,61 @@ private: AceAutoFillType autoFillType_ = AceAutoFillType::ACE_UNSPECIFIED; }; -bool AceContainer::RequestAutoFill(const RefPtr& node, AceAutoFillType autoFillType) +bool AceContainer::UpdatePopupUIExtension(const RefPtr& node) +{ + CHECK_NULL_RETURN(node, false); + CHECK_NULL_RETURN(uiWindow_, false); + auto uiContent = uiWindow_->GetUIContent(); + auto uiContentImpl = reinterpret_cast(uiContent); + CHECK_NULL_RETURN(uiContentImpl, false); + auto viewDataWrap = ViewDataWrap::CreateViewDataWrap(); + uiContentImpl->DumpViewData(node, viewDataWrap); + auto viewDataWrapOhos = AceType::DynamicCast(viewDataWrap); + CHECK_NULL_RETURN(viewDataWrapOhos, false); + auto viewData = viewDataWrapOhos->GetViewData(); + AbilityRuntime::AutoFillManager::GetInstance().UpdateCustomPopupUIExtension(uiContent, viewData); + return true; +} + +bool AceContainer::RequestAutoFill(const RefPtr& node, AceAutoFillType autoFillType, bool& isPopup) { TAG_LOGI(AceLogTag::ACE_AUTO_FILL, "called, autoFillType: %{public}d", static_cast(autoFillType)); auto pipelineContext = AceType::DynamicCast(pipelineContext_); + CHECK_NULL_RETURN(node, false); CHECK_NULL_RETURN(pipelineContext, false); CHECK_NULL_RETURN(uiWindow_, false); auto uiContent = uiWindow_->GetUIContent(); + CHECK_NULL_RETURN(uiContent, false); auto uiContentImpl = reinterpret_cast(uiContent); CHECK_NULL_RETURN(uiContentImpl, false); auto viewDataWrap = ViewDataWrap::CreateViewDataWrap(); + CHECK_NULL_RETURN(viewDataWrap, false); uiContentImpl->DumpViewData(node, viewDataWrap); auto callback = std::make_shared(pipelineContext, node, autoFillType); auto viewDataWrapOhos = AceType::DynamicCast(viewDataWrap); CHECK_NULL_RETURN(viewDataWrapOhos, false); auto viewData = viewDataWrapOhos->GetViewData(); - if (AbilityRuntime::AutoFillManager::GetInstance().RequestAutoFill( - static_cast(autoFillType), uiContent, viewData, callback) != 0) { + AbilityRuntime::AutoFill::PopupSize popupSize; + popupSize.height = POPUPSIZE_HEIGHT; + popupSize.width = POPUPSIZE_WIDTH; + AbilityRuntime::AutoFill::AutoFillCustomConfig customConfig; + customConfig.targetSize = popupSize; + customConfig.isShowInSubWindow = false; + customConfig.nodeId = node->GetId(); + customConfig.isEnableArrow = false; + auto inputInspectorId = node->GetInspectorId().value_or(""); + if (!inputInspectorId.empty()) { + TAG_LOGI(AceLogTag::ACE_AUTO_FILL, "inputInspectorId is: %{public}s", inputInspectorId.c_str()); + customConfig.inspectorId = inputInspectorId; + } + AbilityRuntime::AutoFill::AutoFillRequest autoFillRequest; + autoFillRequest.config = customConfig; + autoFillRequest.autoFillType = static_cast(autoFillType); + autoFillRequest.autoFillCommand = AbilityRuntime::AutoFill::AutoFillCommand::FILL; + autoFillRequest.viewData = viewDataWrapOhos->GetViewData(); + if (AbilityRuntime::AutoFillManager::GetInstance(). + RequestAutoFill(uiContent, autoFillRequest, callback, isPopup) != 0) { return false; } return true; @@ -1176,7 +1215,11 @@ bool AceContainer::RequestAutoSave(const RefPtr& node) auto viewDataWrapOhos = AceType::DynamicCast(viewDataWrap); CHECK_NULL_RETURN(viewDataWrapOhos, false); auto viewData = viewDataWrapOhos->GetViewData(); - if (AbilityRuntime::AutoFillManager::GetInstance().RequestAutoSave(uiContent, viewData, callback) != 0) { + AbilityRuntime::AutoFill::AutoFillRequest autoFillRequest; + autoFillRequest.viewData = viewData; + autoFillRequest.autoFillCommand = AbilityRuntime::AutoFill::AutoFillCommand::SAVE; + autoFillRequest.autoFillType = ViewDataWrap::ViewDataToType(viewData); + if (AbilityRuntime::AutoFillManager::GetInstance().RequestAutoSave(uiContent, autoFillRequest, callback) != 0) { return false; } return true; diff --git a/adapter/ohos/entrance/ace_container.h b/adapter/ohos/entrance/ace_container.h index 15efcf30eb1a4edd3c73d69849c7b6839e3afc0b..485d88414eead4f071d2f4ce7870e2a82d955063 100644 --- a/adapter/ohos/entrance/ace_container.h +++ b/adapter/ohos/entrance/ace_container.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -88,6 +88,8 @@ public: ~AceContainer() override; + bool UpdatePopupUIExtension(const RefPtr& node) override; + void Initialize() override; void Destroy() override; @@ -523,7 +525,7 @@ public: bool GetCurPointerEventInfo(int32_t pointerId, int32_t& globalX, int32_t& globalY, int32_t& sourceType, StopDragCallback&& stopDragCallback) override; - bool RequestAutoFill(const RefPtr& node, AceAutoFillType autoFillType) override; + bool RequestAutoFill(const RefPtr& node, AceAutoFillType autoFillType, bool& isPopup) override; bool RequestAutoSave(const RefPtr& node) override; std::shared_ptr GetNavigationController(const std::string& navigationId) override; diff --git a/adapter/ohos/entrance/ui_content_impl.cpp b/adapter/ohos/entrance/ui_content_impl.cpp index 5220ba48262fb94d9892c9e459d45ab03d2736c4..bf4027ac40ef49621ac50693d31bef90d8ee2181 100644 --- a/adapter/ohos/entrance/ui_content_impl.cpp +++ b/adapter/ohos/entrance/ui_content_impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -73,6 +73,7 @@ #include "core/common/modal_ui_extension.h" #include "core/common/recorder/event_recorder.h" #include "core/common/resource/resource_manager.h" +#include "core/components/theme/shadow_theme.h" #include "core/components_ng/base/inspector.h" #include "core/components_ng/base/view_abstract.h" #include "core/image/image_file_cache.h" @@ -2477,7 +2478,7 @@ bool UIContentImpl::CheckNeedAutoSave() return needAutoSave; } -bool UIContentImpl::DumpViewData(AbilityBase::ViewData& viewData) +bool UIContentImpl::DumpViewData(AbilityBase::ViewData& viewData, AbilityBase::AutoFillType& type) { auto container = Platform::AceContainer::GetContainer(instanceId_); CHECK_NULL_RETURN(container, false); @@ -2495,7 +2496,7 @@ bool UIContentImpl::DumpViewData(AbilityBase::ViewData& viewData) viewData = viewDataWrapOhos->GetViewData(); }, TaskExecutor::TaskType::UI); - + type = ViewDataWrap::ViewDataToType(viewData); TAG_LOGI(AceLogTag::ACE_AUTO_FILL, "UIContentImpl DumpViewData, ret is %{public}d", ret); return ret; } @@ -2630,7 +2631,7 @@ RefPtr UIContentImpl::CreateCustomPopupParam(bool isShow, const Cust popupParam->SetIsShow(isShow); popupParam->SetUseCustomComponent(true); popupParam->SetShowInSubWindow(config.isShowInSubWindow); - + popupParam->SetShadow(GetPopupShadow()); if (config.isAutoCancel.has_value()) { popupParam->SetHasAction(!config.isAutoCancel.value()); } @@ -2675,6 +2676,19 @@ RefPtr UIContentImpl::CreateCustomPopupParam(bool isShow, const Cust return popupParam; } +Shadow UIContentImpl::GetPopupShadow() +{ + Shadow shadow; + auto colorMode = SystemProperties::GetColorMode(); + auto container = Container::Current(); + CHECK_NULL_RETURN(container, shadow); + auto pipelineContext = container->GetPipelineContext(); + CHECK_NULL_RETURN(pipelineContext, shadow); + auto shadowTheme = pipelineContext->GetTheme(); + CHECK_NULL_RETURN(shadowTheme, shadow); + return shadowTheme->GetShadow(ShadowStyle::OuterDefaultMD, colorMode); +} + void UIContentImpl::OnPopupStateChange( const std::string& event, const CustomPopupUIExtensionConfig& config, int32_t nodeId) { @@ -2707,18 +2721,29 @@ int32_t UIContentImpl::CreateCustomPopupUIExtension( int32_t nodeId = 0; taskExecutor->PostSyncTask( [want, &nodeId, callbacks = callbacks, config = config, this]() { - if (config.inspectorId.empty()) { - return; + int32_t nodeIdLabel = -1; + RefPtr targetNode = nullptr; + if (config.nodeId > -1) { + nodeIdLabel = config.nodeId; + targetNode = ElementRegister::GetInstance()->GetSpecificItemById(nodeIdLabel); + CHECK_NULL_VOID(targetNode); + } else if (!config.inspectorId.empty()) { + targetNode = NG::Inspector::GetFrameNodeByKey(config.inspectorId); + CHECK_NULL_VOID(targetNode); + nodeIdLabel = targetNode->GetId(); + } else { + CHECK_NULL_VOID(targetNode); } - auto targetNode = NG::Inspector::GetFrameNodeByKey(config.inspectorId); - CHECK_NULL_VOID(targetNode); - if (customPopupConfigMap_.find(targetNode->GetId()) != customPopupConfigMap_.end()) { - LOGW("Nodeid=%{public}d has unclosed popup, cannot create new", targetNode->GetId()); + if (customPopupConfigMap_.find(nodeIdLabel) != customPopupConfigMap_.end()) { + LOGW("Nodeid=%{public}d has unclosed popup, cannot create new", nodeIdLabel); return; } - auto popupParam = CreateCustomPopupParam(true, config); auto uiExtNode = ModalUIExtension::Create(want, callbacks); + auto focusHub = uiExtNode->GetFocusHub(); + if (focusHub) { + focusHub->SetFocusable(config.isFocusable); + } if (config.targetSize.has_value()) { auto layoutProperty = uiExtNode->GetLayoutProperty(); CHECK_NULL_VOID(layoutProperty); @@ -2729,7 +2754,7 @@ int32_t UIContentImpl::CreateCustomPopupUIExtension( layoutProperty->UpdateUserDefinedIdealSize(NG::CalcSize(width, height)); } uiExtNode->MarkModifyDone(); - nodeId = targetNode->GetId(); + nodeId = nodeIdLabel; popupParam->SetOnStateChange( [config, nodeId, this](const std::string& event) { this->OnPopupStateChange(event, config, nodeId); }); diff --git a/adapter/ohos/entrance/ui_content_impl.h b/adapter/ohos/entrance/ui_content_impl.h index 5b94047b2315b8908dd339e61632eae486ce7525..e15e000ed39e2317b027d4d73c6463ea41c572af 100644 --- a/adapter/ohos/entrance/ui_content_impl.h +++ b/adapter/ohos/entrance/ui_content_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -207,7 +207,8 @@ public: void SetParentToken(sptr token) override; sptr GetParentToken() override; - bool DumpViewData(AbilityBase::ViewData& viewData) override; + AbilityBase::AutoFillType ViewDataToType(const AbilityBase::ViewData& viewData); + bool DumpViewData(AbilityBase::ViewData& viewData, AbilityBase::AutoFillType& type) override; bool CheckNeedAutoSave() override; bool DumpViewData(const RefPtr& node, RefPtr viewDataWrap); @@ -238,6 +239,7 @@ public: std::string RecycleForm() override; void RecoverForm(const std::string& statusData) override; + Shadow GetPopupShadow(); int32_t CreateCustomPopupUIExtension(const AAFwk::Want& want, const ModalUIExtensionCallbacks& callbacks, const CustomPopupUIExtensionConfig& config) override; diff --git a/adapter/ohos/osal/view_data_wrap_ohos.cpp b/adapter/ohos/osal/view_data_wrap_ohos.cpp index b1212b1dae53755df65e11d36dc8862dd7595cfb..9f448eac5d581eaa7059dafdec60bbf869c74da3 100644 --- a/adapter/ohos/osal/view_data_wrap_ohos.cpp +++ b/adapter/ohos/osal/view_data_wrap_ohos.cpp @@ -33,6 +33,27 @@ RefPtr ViewDataWrap::CreateViewDataWrap() return AceType::MakeRefPtr(); } +AbilityBase::AutoFillType ViewDataWrap::ViewDataToType(const AbilityBase::ViewData& viewData) +{ + auto type = AbilityBase::AutoFillType::UNSPECIFIED; + for (auto it = viewData.nodes.begin(); it != viewData.nodes.end(); ++it) { + if (!it->value.empty()) { + if (type < it->autoFillType && it->autoFillType < AbilityBase::AutoFillType::FULL_STREET_ADDRESS) { + return it->autoFillType; + } + } + } + for (auto it = viewData.nodes.begin(); it != viewData.nodes.end(); ++it) { + if (!it->value.empty()) { + if (AbilityBase::AutoFillType::FULL_STREET_ADDRESS <= it->autoFillType && + it->autoFillType <= AbilityBase::AutoFillType::FORMAT_ADDRESS) { + return it->autoFillType; + } + } + } + return type; +} + RefPtr ViewDataWrap::CreateViewDataWrap(const AbilityBase::ViewData& viewData) { return AceType::MakeRefPtr(viewData); diff --git a/adapter/ohos/osal/view_data_wrap_ohos.h b/adapter/ohos/osal/view_data_wrap_ohos.h index 3ef2cebf40f34af583646e9de5faef5799d33606..abc2419aee618b6ed0aec0cc984b48e3128ab8b4 100644 --- a/adapter/ohos/osal/view_data_wrap_ohos.h +++ b/adapter/ohos/osal/view_data_wrap_ohos.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -113,8 +113,34 @@ public: { return pageNodeInfo_.enableAutoFill; } + + void SetIsFocus(bool isFocus) override + { + pageNodeInfo_.isFocus = isFocus; + } + + bool GetIsFocus() const override + { + return pageNodeInfo_.isFocus; + } + + void SetPageNodeRect(const NG::RectF& rect) override + { + pageNodeInfo_.rect.left = rect.GetX(); + pageNodeInfo_.rect.top = rect.GetY(); + pageNodeInfo_.rect.width = rect.Width(); + pageNodeInfo_.rect.height = rect.Height(); + pageNodeRect_ = rect; + } + + const NG::RectF& GetPageNodeRect() const override + { + return pageNodeRect_; + } + private: AbilityBase::PageNodeInfo pageNodeInfo_; + NG::RectF pageNodeRect_; }; class ViewDataWrapOhos : public ViewDataWrap { @@ -176,9 +202,25 @@ public: { return pageNodeInfoWraps_; } + + void SetPageRect(const NG::RectF& rect) override + { + viewData_.pageRect.left = rect.GetX(); + viewData_.pageRect.top = rect.GetY(); + viewData_.pageRect.width = rect.Width(); + viewData_.pageRect.height = rect.Height(); + pageRect_ = rect; + } + + const NG::RectF& GetPageRect() const override + { + return pageRect_; + } + private: std::vector> pageNodeInfoWraps_; AbilityBase::ViewData viewData_; + NG::RectF pageRect_; }; } // namespace OHOS::Ace #endif // FOUNDATION_ACE_ADAPTER_OHOS_OSAL_VIEW_DATA_WRAP_OHOS_H diff --git a/frameworks/base/view_data/ace_auto_fill_type.h b/frameworks/base/view_data/ace_auto_fill_type.h index 01061762e102d30b64eb5b456f13730bf8c46726..e41de7f448a2fa5bf602432fa4354a9612d78031 100644 --- a/frameworks/base/view_data/ace_auto_fill_type.h +++ b/frameworks/base/view_data/ace_auto_fill_type.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -23,7 +23,27 @@ enum class AceAutoFillType { ACE_UNSPECIFIED = 0, ACE_PASSWORD, ACE_USER_NAME, - ACE_NEW_PASSWORD + ACE_NEW_PASSWORD, + ACE_FULL_STREET_ADDRESS, + ACE_HOUSE_NUMBER, + ACE_DISTRICT_ADDRESS, + ACE_CITY_ADDRESS, + ACE_PROVINCE_ADDRESS, + ACE_COUNTRY_ADDRESS, + ACE_PERSON_FULL_NAME, + ACE_PERSON_LAST_NAME, + ACE_PERSON_FIRST_NAME, + ACE_PHONE_NUMBER, + ACE_PHONE_COUNTRY_CODE, + ACE_FULL_PHONE_NUMBER, + ACE_EMAIL_ADDRESS, + ACE_BANK_CARD_NUMBER, + ACE_ID_CARD_NUMBER, + ACE_PRECISE_TIME, + ACE_HOUR_AND_MINUTE, + ACE_DATE, + ACE_MONTH, + ACE_YEAR, }; } // namespace OHOS::Ace #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_ACE_AUTO_FILL_TYPE_H \ No newline at end of file diff --git a/frameworks/base/view_data/page_node_info_wrap.h b/frameworks/base/view_data/page_node_info_wrap.h index cfeb019ad8866135f75eec53d5e9c342ac0acc04..817ca4c95182a61d99ba4b8d1adb7e613e555538 100644 --- a/frameworks/base/view_data/page_node_info_wrap.h +++ b/frameworks/base/view_data/page_node_info_wrap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,10 +16,12 @@ #ifndef FOUNDATION_ACE_FRAMEWORKS_BASE_PAGE_NODE_INFO_WRAP_H #define FOUNDATION_ACE_FRAMEWORKS_BASE_PAGE_NODE_INFO_WRAP_H +#include "base/geometry/ng/rect_t.h" #include "base/memory/ace_type.h" #include "base/view_data/ace_auto_fill_type.h" namespace OHOS::AbilityBase { +struct Rect; struct PageNodeInfo; } // namespace OHOS::AbilityBase @@ -63,8 +65,17 @@ public: virtual void SetEnableAutoFill(bool enableAutoFill) {} virtual bool GetEnableAutoFill() const { - return 0; + return false; } + + virtual void SetIsFocus(bool isFocus) {} + virtual bool GetIsFocus() const + { + return false; + } + + virtual void SetPageNodeRect(const NG::RectF& rect) {} + virtual const NG::RectF& GetPageNodeRect() const = 0; }; } // namespace OHOS::Ace #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_PAGE_NODE_INFO_WRAP_H \ No newline at end of file diff --git a/frameworks/base/view_data/view_data_wrap.h b/frameworks/base/view_data/view_data_wrap.h index a1354a9229848201e6e2bbb9008f9f2fa1cf5867..3fd2a67bb7f39ee44b334cc4f02796690c546f24 100644 --- a/frameworks/base/view_data/view_data_wrap.h +++ b/frameworks/base/view_data/view_data_wrap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,6 +21,7 @@ namespace OHOS::AbilityBase { struct ViewData; +enum class AutoFillType; } // namespace OHOS::AbilityBase namespace OHOS::Ace { @@ -30,6 +31,7 @@ class ACE_EXPORT ViewDataWrap : public AceType { public: static RefPtr CreateViewDataWrap(); static RefPtr CreateViewDataWrap(const AbilityBase::ViewData& viewData); + static AbilityBase::AutoFillType ViewDataToType(const AbilityBase::ViewData& viewData); virtual void SetBundleName(const std::string& bundleName) {} virtual const std::string& GetBundleName() const = 0; @@ -45,6 +47,9 @@ public: virtual void AddPageNodeInfoWrap(RefPtr pageNodeInfoWrap) {} virtual const std::vector>& GetPageNodeInfoWraps() = 0; + + virtual void SetPageRect(const NG::RectF& rect) {} + virtual const NG::RectF& GetPageRect() const = 0; }; } // namespace OHOS::Ace #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_VIEW_DATA_WRAP_H diff --git a/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js b/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js index fe01f122fa43feb08cbb3571ad47f44a11a1e2dc..7ac53887d5eb26e8f96175a75cfd50a9c7d147ab 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js +++ b/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js @@ -1385,6 +1385,33 @@ var FunctionKey; FunctionKey[FunctionKey["F12"] = 12] = "F12"; })(FunctionKey || (FunctionKey = {})); +var ContentType; +(function (ContentType) { + ContentType[ContentType['USER_NAME'] = 0] = 'USER_NAME'; + ContentType[ContentType['PASSWORD'] = 1] = 'PASSWORD'; + ContentType[ContentType['NEW_PASSWORD'] = 2] = 'NEW_PASSWORD'; + ContentType[ContentType['FULL_STREET_ADDRESS'] = 3] = 'FULL_STREET_ADDRESS'; + ContentType[ContentType['HOUSE_NUMBER'] = 4] = 'HOUSE_NUMBER'; + ContentType[ContentType['DISTRICT_ADDRESS'] = 5] = 'DISTRICT_ADDRESS'; + ContentType[ContentType['CITY_ADDRESS'] = 6] = 'CITY_ADDRESS'; + ContentType[ContentType['PROVINCE_ADDRESS'] = 7] = 'PROVINCE_ADDRESS'; + ContentType[ContentType['COUNTRY_ADDRESS'] = 8] = 'COUNTRY_ADDRESS'; + ContentType[ContentType['PERSON_FULL_NAME'] = 9] = 'PERSON_FULL_NAME'; + ContentType[ContentType['PERSON_LAST_NAME'] = 10] = 'PERSON_LAST_NAME'; + ContentType[ContentType['PERSON_FIRST_NAME'] = 11] = 'PERSON_FIRST_NAME'; + ContentType[ContentType['PHONE_NUMBER'] = 12] = 'PHONE_NUMBER'; + ContentType[ContentType['PHONE_COUNTRY_CODE'] = 13] = 'PHONE_COUNTRY_CODE'; + ContentType[ContentType['FULL_PHONE_NUMBER'] = 14] = 'FULL_PHONE_NUMBER'; + ContentType[ContentType['EMAIL_ADDRESS'] = 15] = 'EMAIL_ADDRESS'; + ContentType[ContentType['BANK_CARD_NUMBER'] = 16] = 'BANK_CARD_NUMBER'; + ContentType[ContentType['ID_CARD_NUMBER'] = 17] = 'ID_CARD_NUMBER'; + ContentType[ContentType['PRECISE_TIME'] = 18] = 'PRECISE_TIME'; + ContentType[ContentType['HOUR_AND_MINUTE'] = 19] = 'HOUR_AND_MINUTE'; + ContentType[ContentType['DATE'] = 20] = 'DATE'; + ContentType[ContentType['MONTH'] = 21] = 'MONTH'; + ContentType[ContentType['YEAR'] = 22] = 'YEAR'; +})(ContentType || (ContentType = {})); + var GestureJudgeResult; (function (GestureJudgeResult) { GestureJudgeResult[GestureJudgeResult["CONTINUE"] = 0] = "CONTINUE"; diff --git a/frameworks/bridge/declarative_frontend/jsview/js_textfield.cpp b/frameworks/bridge/declarative_frontend/jsview/js_textfield.cpp index b0df89c10d0206cd0225db8b72b374ad41fc6c58..286ea32c007562c1bc049b592de74f4a426fd484 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_textfield.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_textfield.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -40,6 +40,7 @@ #include "core/components/common/layout/constants.h" #include "core/components/text_field/textfield_theme.h" #include "core/components_ng/base/view_abstract.h" +#include "core/components_ng/pattern/text_field/text_content_type.h" #include "core/components_ng/pattern/text_field/text_field_model.h" #include "core/components_ng/pattern/text_field/text_field_model_ng.h" #include "core/pipeline/pipeline_base.h" @@ -205,6 +206,22 @@ void JSTextField::SetType(const JSCallbackInfo& info) TextFieldModel::GetInstance()->SetType(textInputType); } +void JSTextField::SetContentType(const JSCallbackInfo& info) +{ + if (info.Length() < 1) { + return; + } + if (info[0]->IsUndefined()) { + TextFieldModel::GetInstance()->SetContentType(NG::TextContentType::UNSPECIFIED); + return; + } + if (!info[0]->IsNumber()) { + return; + } + NG::TextContentType textContentType = static_cast(info[0]->ToNumber()); + TextFieldModel::GetInstance()->SetContentType(textContentType); +} + void JSTextField::SetPlaceholderColor(const JSCallbackInfo& info) { if (info.Length() < 1) { diff --git a/frameworks/bridge/declarative_frontend/jsview/js_textfield.h b/frameworks/bridge/declarative_frontend/jsview/js_textfield.h index 96b596202b062562d4574772d529d8892b3241b5..2f5509bea2ad3e74fd2fa2545b8dd5024631f606 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_textfield.h +++ b/frameworks/bridge/declarative_frontend/jsview/js_textfield.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -33,6 +33,7 @@ public: static void CreateTextInput(const JSCallbackInfo& info); static void CreateTextArea(const JSCallbackInfo& info); static void SetType(const JSCallbackInfo& info); + static void SetContentType(const JSCallbackInfo& info); static void SetPlaceholderColor(const JSCallbackInfo& info); static void SetPlaceholderFont(const JSCallbackInfo& info); static void SetEnterKeyType(const JSCallbackInfo& info); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_textinput.cpp b/frameworks/bridge/declarative_frontend/jsview/js_textinput.cpp index d6337bc12badaa3c690f5d1df6712e115a6fb62e..9d9bf05c54bd1615777d5e9741b409cf1d3cf28b 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_textinput.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_textinput.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -32,6 +32,7 @@ #include "frameworks/core/common/ime/text_input_type.h" #include "frameworks/core/components/text_field/text_field_component.h" #include "frameworks/core/components/text_field/textfield_theme.h" +#include "frameworks/core/components_ng/pattern/text_field/text_content_type.h" namespace OHOS::Ace::Framework { @@ -41,6 +42,7 @@ void JSTextInput::JSBind(BindingTarget globalObj) MethodOptions opt = MethodOptions::NONE; JSClass::StaticMethod("create", &JSTextInput::Create, opt); JSClass::StaticMethod("type", &JSTextField::SetType); + JSClass::StaticMethod("contentType", &JSTextField::SetContentType); JSClass::StaticMethod("placeholderColor", &JSTextField::SetPlaceholderColor); JSClass::StaticMethod("placeholderFont", &JSTextField::SetPlaceholderFont); JSClass::StaticMethod("backgroundColor", &JSTextField::SetBackgroundColor); diff --git a/frameworks/bridge/declarative_frontend/jsview/models/text_field_model_impl.h b/frameworks/bridge/declarative_frontend/jsview/models/text_field_model_impl.h index c1682378a84e93800dc3b2419e28c7a080952e95..86257d8740731439c6813bcbdcebdc3c838dd15b 100644 --- a/frameworks/bridge/declarative_frontend/jsview/models/text_field_model_impl.h +++ b/frameworks/bridge/declarative_frontend/jsview/models/text_field_model_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -36,6 +36,7 @@ public: void RequestKeyboardOnFocus(bool needToRequest) override {}; void SetWidthAuto(bool isAuto) override {}; void SetType(TextInputType value) override; + void SetContentType(const NG::TextContentType& value) override {}; void SetPlaceholderColor(const Color& value) override; void SetPlaceholderFont(const Font& value) override; void SetEnterKeyType(TextInputAction value) override; diff --git a/frameworks/core/common/container.h b/frameworks/core/common/container.h index c2a65e35627560be1d9f7b3b55b9b85cb089d1a5..ddd49bdad36e346ad111f92d3d719c3dfee192b0 100755 --- a/frameworks/core/common/container.h +++ b/frameworks/core/common/container.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -79,6 +79,10 @@ public: } virtual void DestroyView() {} + virtual bool UpdatePopupUIExtension(const RefPtr& node) + { + return false; + } // Get the instance id of this container virtual int32_t GetInstanceId() const = 0; @@ -422,7 +426,7 @@ public: return false; } - virtual bool RequestAutoFill(const RefPtr& node, AceAutoFillType autoFillType) + virtual bool RequestAutoFill(const RefPtr& node, AceAutoFillType autoFillType, bool &isPopup) { return false; } diff --git a/frameworks/core/components_ng/pattern/text_field/text_content_type.cpp b/frameworks/core/components_ng/pattern/text_field/text_content_type.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4baa1c48cf3e74339795b7cb28036558077c98d7 --- /dev/null +++ b/frameworks/core/components_ng/pattern/text_field/text_content_type.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/components_ng/pattern/text_field/text_content_type.h" + +namespace OHOS::Ace::NG { +TextContentType CastToTextContentType(int32_t value) +{ + if (value < static_cast(TextContentType::BEGIN) || value > static_cast(TextContentType::END)) { + return TextContentType::BEGIN; + } + return static_cast(value); +} +} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/text_field/text_content_type.h b/frameworks/core/components_ng/pattern/text_field/text_content_type.h new file mode 100644 index 0000000000000000000000000000000000000000..8eeb039bffd74b53d7ed00015ec4dd91529434b3 --- /dev/null +++ b/frameworks/core/components_ng/pattern/text_field/text_content_type.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_FIELD_PATTERN_TEXT_CONTENT_TYPE_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_FIELD_PATTERN_TEXT_CONTENT_TYPE_H + +#include + +namespace OHOS::Ace::NG { +enum class TextContentType { + BEGIN = -1, + // Default type. + UNSPECIFIED = BEGIN, + USER_NAME = 0, + VISIBLE_PASSWORD = 1, + NEW_PASSWORD = 2, + FULL_STREET_ADDRESS = 3, + HOUSE_NUMBER = 4, + DISTRICT_ADDRESS = 5, + CITY_ADDRESS = 6, + PROVINCE_ADDRESS = 7, + COUNTRY_ADDRESS = 8, + PERSON_FULL_NAME = 9, + PERSON_LAST_NAME = 10, + PERSON_FIRST_NAME = 11, + PHONE_NUMBER = 12, + PHONE_COUNTRY_CODE = 13, + FULL_PHONE_NUMBER = 14, + EMAIL_ADDRESS = 15, + BANK_CARD_NUMBER = 16, + ID_CARD_NUMBER = 17, + PRECISE_TIME = 18, + HOUR_AND_MINUTE = 19, + DATE = 20, + MONTH = 21, + YEAR = 22, + END = YEAR, +}; +TextContentType CastToTextContentType(int32_t value); +}; // namespace OHOS::Ace::NG +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_FIELD_PATTERN_TEXT_CONTENT_TYPE_H \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_layout_property.h b/frameworks/core/components_ng/pattern/text_field/text_field_layout_property.h index 3cf80562c42836408bf545422786af514f6ffdbd..5b315acb609454c76247120856d1e70b0b66fea5 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_layout_property.h +++ b/frameworks/core/components_ng/pattern/text_field/text_field_layout_property.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,6 +21,7 @@ #include "core/components/text_field/textfield_theme.h" #include "core/components_ng/layout/layout_property.h" #include "core/components_ng/pattern/text/text_styles.h" +#include "core/components_ng/pattern/text_field/text_content_type.h" #include "core/components_ng/pattern/text_field/text_field_model.h" #include "core/components_ng/property/property.h" #include "core/image/image_source_info.h" @@ -155,6 +156,7 @@ public: ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(ErrorText, std::string, PROPERTY_UPDATE_MEASURE); ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(ShowErrorText, bool, PROPERTY_UPDATE_MEASURE); + ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TextContentType, TextContentType, PROPERTY_UPDATE_MEASURE); ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TextInputType, TextInputType, PROPERTY_UPDATE_MEASURE); ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(InputFilter, std::string, PROPERTY_UPDATE_MEASURE); ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(ShowPasswordIcon, bool, PROPERTY_UPDATE_MEASURE_SELF); @@ -164,6 +166,7 @@ public: ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(MaxViewLines, uint32_t, PROPERTY_UPDATE_MEASURE); ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(IsDisabled, bool, PROPERTY_UPDATE_MEASURE); + ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TextContentTypeChanged, bool, PROPERTY_UPDATE_MEASURE); ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(WidthAuto, bool, PROPERTY_UPDATE_MEASURE); ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TypeChanged, bool, PROPERTY_UPDATE_MEASURE); ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TextAlignChanged, bool, PROPERTY_UPDATE_MEASURE); diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_model.h b/frameworks/core/components_ng/pattern/text_field/text_field_model.h index 7aedbba563e764fc4d4de3c0ac88ffc8532d8966..a824da7dc9aaaaf90ec06f5bf6357505494f2f78 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_model.h +++ b/frameworks/core/components_ng/pattern/text_field/text_field_model.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -34,6 +34,7 @@ #include "core/components_ng/base/view_abstract_model_ng.h" #include "core/components_ng/pattern/text/text_menu_extension.h" #include "core/components_ng/property/measure_property.h" +#include "core/components_ng/pattern/text_field/text_content_type.h" #include "core/components_ng/pattern/text_field/text_field_event_hub.h" namespace OHOS::Ace { @@ -211,6 +212,7 @@ public: virtual void RequestKeyboardOnFocus(bool needToRequest) = 0; virtual void SetWidthAuto(bool isAuto) {} virtual void SetType(TextInputType value) = 0; + virtual void SetContentType(const NG::TextContentType& value) = 0; virtual void SetPlaceholderColor(const Color& value) = 0; virtual void SetPlaceholderFont(const Font& value) = 0; virtual void SetEnterKeyType(TextInputAction value) = 0; diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.cpp b/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.cpp index f0746a8951f41e77ae25b7cd41d54b28333f934c..76209b756819f8e526c22dfd44884813166d8d8f 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -252,6 +252,18 @@ void TextFieldModelNG::SetPlaceholderColor(const Color& value) ACE_UPDATE_LAYOUT_PROPERTY(TextFieldLayoutProperty, PlaceholderTextColor, value); } +void TextFieldModelNG::SetContentType(const TextContentType& value) +{ + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + CHECK_NULL_VOID(frameNode); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + if (layoutProperty->HasTextContentType() && layoutProperty->GetTextContentTypeValue() != value) { + layoutProperty->UpdateTextContentTypeChanged(true); + } + ACE_UPDATE_LAYOUT_PROPERTY(TextFieldLayoutProperty, TextContentType, value); +} + void TextFieldModelNG::SetPlaceholderFont(const Font& value) { if (value.fontSize.has_value()) { @@ -815,6 +827,17 @@ void TextFieldModelNG::SetType(FrameNode* frameNode, TextInputType value) ACE_UPDATE_NODE_LAYOUT_PROPERTY(TextFieldLayoutProperty, TextInputType, value, frameNode); } +void TextFieldModelNG::SetContentType(const FrameNode* frameNode, const TextContentType& value) +{ + CHECK_NULL_VOID(frameNode); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + if (layoutProperty->HasTextContentType() && layoutProperty->GetTextContentTypeValue() != value) { + layoutProperty->UpdateTextContentTypeChanged(true); + } + ACE_UPDATE_NODE_LAYOUT_PROPERTY(TextFieldLayoutProperty, TextContentType, value, frameNode); +} + void TextFieldModelNG::SetCopyOption(FrameNode* frameNode, CopyOptions copyOption) { ACE_UPDATE_NODE_LAYOUT_PROPERTY(TextFieldLayoutProperty, CopyOptions, copyOption, frameNode); diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.h b/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.h index edb2e14ea750be65f5d6a71ccf21044df9088402..4fd3beb013f0572daed653d1f01ddecd61c9a426 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.h +++ b/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,6 +16,7 @@ #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_FIELD_TEXT_FIELD_MODEL_NG_H #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_FIELD_TEXT_FIELD_MODEL_NG_H +#include "core/components_ng/pattern/text_field/text_content_type.h" #include "core/components_ng/pattern/text_field/text_field_model.h" namespace OHOS::Ace::NG { @@ -34,6 +35,7 @@ public: void RequestKeyboardOnFocus(bool needToRequest) override; void SetWidthAuto(bool isAuto) override; void SetType(TextInputType value) override; + void SetContentType(const TextContentType& value) override; void SetPlaceholderColor(const Color& value) override; void SetPlaceholderFont(const Font& value) override; void SetEnterKeyType(TextInputAction value) override; @@ -111,6 +113,7 @@ public: static void SetSelectedBackgroundColor(FrameNode* frameNode, const Color& value); static void SetMaxViewLines(FrameNode* frameNode, uint32_t value); static void SetType(FrameNode* frameNode, TextInputType value); + static void SetContentType(const FrameNode* frameNode, const TextContentType& value); static void SetCopyOption(FrameNode* frameNode, CopyOptions copyOption); static void SetShowPasswordIcon(FrameNode* frameNode, bool value); static void SetTextAlign(FrameNode* frameNode, TextAlign value); diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp index 4552b60bed90b42f62fd8c64e6e60711be7c2e03..0252b5366d8ed2720c26c3917b16f33214cf524c 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -57,6 +57,7 @@ #include "core/components_ng/pattern/text/text_pattern.h" #include "core/components_ng/pattern/text/text_styles.h" #include "core/components_ng/pattern/text_drag/text_drag_pattern.h" +#include "core/components_ng/pattern/text_field/text_content_type.h" #include "core/components_ng/pattern/text_field/text_field_controller.h" #include "core/components_ng/pattern/text_field/text_field_event_hub.h" #include "core/components_ng/pattern/text_field/text_field_layout_algorithm.h" @@ -142,6 +143,46 @@ const std::string SHOW_PASSWORD_SVG = "SYS_SHOW_PASSWORD_SVG"; const std::string HIDE_PASSWORD_SVG = "SYS_HIDE_PASSWORD_SVG"; constexpr int32_t DEFAULT_MODE = -1; +static std::unordered_map> contentTypeMap_ = { + {TextContentType::VISIBLE_PASSWORD, + std::make_pair(AceAutoFillType::ACE_PASSWORD, "TextContentType.VISIBLE_PASSWORD")}, + {TextContentType::USER_NAME, std::make_pair(AceAutoFillType::ACE_USER_NAME, "TextContentType.USER_NAME")}, + {TextContentType::NEW_PASSWORD, std::make_pair(AceAutoFillType::ACE_NEW_PASSWORD, "TextContentType.NEW_PASSWORD")}, + {TextContentType::FULL_STREET_ADDRESS, + std::make_pair(AceAutoFillType::ACE_FULL_STREET_ADDRESS, "TextContentType.FULL_STREET_ADDRESS")}, + {TextContentType::HOUSE_NUMBER, std::make_pair(AceAutoFillType::ACE_HOUSE_NUMBER, "TextContentType.HOUSE_NUMBER")}, + {TextContentType::DISTRICT_ADDRESS, + std::make_pair(AceAutoFillType::ACE_DISTRICT_ADDRESS, "TextContentType.DISTRICT_ADDRESS")}, + {TextContentType::CITY_ADDRESS, std::make_pair(AceAutoFillType::ACE_CITY_ADDRESS, "TextContentType.CITY_ADDRESS")}, + {TextContentType::PROVINCE_ADDRESS, + std::make_pair(AceAutoFillType::ACE_PROVINCE_ADDRESS, "TextContentType.PROVINCE_ADDRESS")}, + {TextContentType::COUNTRY_ADDRESS, + std::make_pair(AceAutoFillType::ACE_COUNTRY_ADDRESS, "TextContentType.COUNTRY_ADDRESS")}, + {TextContentType::PERSON_FULL_NAME, + std::make_pair(AceAutoFillType::ACE_PERSON_FULL_NAME, "TextContentType.PERSON_FULL_NAME")}, + {TextContentType::PERSON_LAST_NAME, + std::make_pair(AceAutoFillType::ACE_PERSON_LAST_NAME, "TextContentType.PERSON_LAST_NAME")}, + {TextContentType::PERSON_FIRST_NAME, + std::make_pair(AceAutoFillType::ACE_PERSON_FIRST_NAME, "TextContentType.PERSON_FIRST_NAME")}, + {TextContentType::PHONE_NUMBER, std::make_pair(AceAutoFillType::ACE_PHONE_NUMBER, "TextContentType.PHONE_NUMBER")}, + {TextContentType::PHONE_COUNTRY_CODE, + std::make_pair(AceAutoFillType::ACE_PHONE_COUNTRY_CODE, "TextContentType.PHONE_COUNTRY_CODE")}, + {TextContentType::FULL_PHONE_NUMBER, + std::make_pair(AceAutoFillType::ACE_FULL_PHONE_NUMBER, "TextContentType.FULL_PHONE_NUMBER")}, + {TextContentType::EMAIL_ADDRESS, + std::make_pair(AceAutoFillType::ACE_EMAIL_ADDRESS, "TextContentType.EMAIL_ADDRESS")}, + {TextContentType::BANK_CARD_NUMBER, + std::make_pair(AceAutoFillType::ACE_BANK_CARD_NUMBER, "TextContentType.BANK_CARD_NUMBER")}, + {TextContentType::ID_CARD_NUMBER, + std::make_pair(AceAutoFillType::ACE_ID_CARD_NUMBER, "TextContentType.ID_CARD_NUMBER")}, + {TextContentType::PRECISE_TIME, std::make_pair(AceAutoFillType::ACE_PRECISE_TIME, "TextContentType.PRECISE_TIME")}, + {TextContentType::HOUR_AND_MINUTE, + std::make_pair(AceAutoFillType::ACE_HOUR_AND_MINUTE, "TextContentType.HOUR_AND_MINUTE")}, + {TextContentType::DATE, std::make_pair(AceAutoFillType::ACE_DATE, "TextContentType.DATE")}, + {TextContentType::MONTH, std::make_pair(AceAutoFillType::ACE_MONTH, "TextContentType.MONTH")}, + {TextContentType::YEAR, std::make_pair(AceAutoFillType::ACE_YEAR, "TextContentType.YEAR")}, + {TextContentType::UNSPECIFIED, std::make_pair(AceAutoFillType::ACE_UNSPECIFIED, "TextContentType.UNSPECIFIED")}}; + void SwapIfLarger(int32_t& a, int32_t& b) { if (a > b) { @@ -1840,40 +1881,83 @@ void TextFieldPattern::HandleSingleClickEvent(GestureEvent& info) ProcessOverlay(true, true, false); } } - if (ProcessAutoFill()) { + DoProcessAutoFill(); + // emulate clicking bottom of the textField + UpdateTextFieldManager(Offset(parentGlobalOffset_.GetX(), parentGlobalOffset_.GetY()), frameRect_.Height()); + host->MarkDirtyNode(PROPERTY_UPDATE_RENDER); +} + +void TextFieldPattern::DoProcessAutoFill() +{ + bool isPopup = false; + auto isSuccess = ProcessAutoFill(isPopup); + if (!isPopup && isSuccess) { needToRequestKeyboardInner_ = false; } else if (RequestKeyboard(false, true, true)) { NotifyOnEditChanged(true); } - // emulate clicking bottom of the textField - UpdateTextFieldManager(Offset(parentGlobalOffset_.GetX(), parentGlobalOffset_.GetY()), frameRect_.Height()); - host->MarkDirtyNode(PROPERTY_UPDATE_RENDER); } -bool TextFieldPattern::CheckAutoFill() +bool TextFieldPattern::IsAutoFillPasswordType(const AceAutoFillType& autoFillType) +{ + return (autoFillType == AceAutoFillType::ACE_USER_NAME || autoFillType == AceAutoFillType::ACE_PASSWORD || + autoFillType == AceAutoFillType::ACE_NEW_PASSWORD); +} + +bool TextFieldPattern::CheckAutoFillType(const AceAutoFillType& aceAutoFillAllType) { auto host = GetHost(); CHECK_NULL_RETURN(host, false); - auto layoutProperty = GetLayoutProperty(); - CHECK_NULL_RETURN(layoutProperty, false); - bool isEnableAutoFill = layoutProperty->GetEnableAutoFillValue(true); - if (!isEnableAutoFill) { - return false; - } auto pageNode = host->GetPageNode(); CHECK_NULL_RETURN(pageNode, false); auto pagePattern = pageNode->GetPattern(); CHECK_NULL_RETURN(pagePattern, false); - auto autoFillType = layoutProperty->GetTextInputTypeValue(TextInputType::UNSPECIFIED); - if (autoFillType == TextInputType::USER_NAME || autoFillType == TextInputType::VISIBLE_PASSWORD) { + auto layoutProperty = GetLayoutProperty(); + CHECK_NULL_RETURN(layoutProperty, false); + if (aceAutoFillAllType == AceAutoFillType::ACE_UNSPECIFIED) { + TAG_LOGE(AceLogTag::ACE_AUTO_FILL, "CheckAutoFillType :aceAutoFillAllType is ACE_UNSPECIFIED."); + return false; + } else if (aceAutoFillAllType == AceAutoFillType::ACE_USER_NAME || + aceAutoFillAllType == AceAutoFillType::ACE_PASSWORD) { return !pagePattern->IsAutoFillPasswordTriggered(); - } else if (autoFillType == TextInputType::NEW_PASSWORD) { + } else if (aceAutoFillAllType == AceAutoFillType::ACE_NEW_PASSWORD) { return !pagePattern->IsAutoFillNewPasswordTriggered(); } - return false; + return true; +} + +AceAutoFillType TextFieldPattern::GetAutoFillType() +{ + auto layoutProperty = GetLayoutProperty(); + CHECK_NULL_RETURN(layoutProperty, AceAutoFillType::ACE_UNSPECIFIED); + auto aceContentType = + TextContentTypeToAceAutoFillType(layoutProperty->GetTextContentTypeValue(TextContentType::UNSPECIFIED)); + auto aceInputType = ConvertToAceAutoFillType(layoutProperty->GetTextInputTypeValue(TextInputType::UNSPECIFIED)); + if (aceContentType != AceAutoFillType::ACE_UNSPECIFIED) { + return aceContentType; + } + if (aceInputType != AceAutoFillType::ACE_UNSPECIFIED) { + if (IsAutoFillPasswordType(aceInputType)) { + return aceInputType; + } else { + return AceAutoFillType::ACE_UNSPECIFIED; + } + } + return AceAutoFillType::ACE_UNSPECIFIED; +} + +bool TextFieldPattern::CheckAutoFill() +{ + auto layoutProperty = GetLayoutProperty(); + CHECK_NULL_RETURN(layoutProperty, false); + bool isEnableAutoFill = layoutProperty->GetEnableAutoFillValue(true); + if (!isEnableAutoFill) { + return false; + } + return CheckAutoFillType(GetAutoFillType()); } -bool TextFieldPattern::ProcessAutoFill() +bool TextFieldPattern::ProcessAutoFill(bool& isPopup) { if (!CheckAutoFill()) { TAG_LOGI(AceLogTag::ACE_AUTO_FILL, "No nedd to auto fill."); @@ -1887,15 +1971,16 @@ bool TextFieldPattern::ProcessAutoFill() CHECK_NULL_RETURN(pagePattern, false); auto layoutProperty = GetLayoutProperty(); CHECK_NULL_RETURN(layoutProperty, false); - auto autoFillType = ConvertToAceAutoFillType(layoutProperty->GetTextInputTypeValue(TextInputType::UNSPECIFIED)); + auto autoFillType = GetAutoFillType(); auto container = Container::Current(); CHECK_NULL_RETURN(container, false); - if (autoFillType == AceAutoFillType::ACE_NEW_PASSWORD) { - pagePattern->SetAutoFillNewPasswordTriggered(true); - } else { + if (autoFillType == AceAutoFillType::ACE_USER_NAME || autoFillType == AceAutoFillType::ACE_PASSWORD) { pagePattern->SetAutoFillPasswordTriggered(true); + } else if (autoFillType == AceAutoFillType::ACE_NEW_PASSWORD) { + pagePattern->SetAutoFillNewPasswordTriggered(true); } - return container->RequestAutoFill(host, autoFillType); + SetFillRequestFinish(false); + return (container->RequestAutoFill(host, autoFillType, isPopup)); } void TextFieldPattern::HandleDoubleClickEvent(GestureEvent& info) @@ -2258,10 +2343,29 @@ void TextFieldPattern::CalculateDefaultCursor() selectController_->UpdateCaretHeight(PreferredLineHeight()); } +void TextFieldPattern::AutoFillValueChanged() +{ + if (IsFillRequestFinish()) { + return; + } + auto host = GetHost(); + CHECK_NULL_VOID(host); + auto layoutProperty = GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto autoContentType = layoutProperty->GetTextContentTypeValue(TextContentType::UNSPECIFIED); + auto container = Container::Current(); + CHECK_NULL_VOID(container); + if (autoContentType == TextContentType::PERSON_FULL_NAME || autoContentType == TextContentType::PERSON_LAST_NAME || + autoContentType == TextContentType::PERSON_FIRST_NAME) { + container->UpdatePopupUIExtension(host); + } +} + bool TextFieldPattern::FireOnTextChangeEvent() { auto host = GetHost(); CHECK_NULL_RETURN(host, false); + AutoFillValueChanged(); auto eventHub = host->GetEventHub(); CHECK_NULL_RETURN(eventHub, false); auto layoutProperty = host->GetLayoutProperty(); @@ -3132,6 +3236,41 @@ uint32_t TextFieldPattern::GetSCBSystemWindowId() } #endif +void TextFieldPattern::KeyboardContentTypeToInputType() +{ + if (keyboard_ != TextInputType::UNSPECIFIED) { + return; + } + auto autoFillType = GetAutoFillType(); + static std::unordered_map keyBoardMap = { + { AceAutoFillType::ACE_PASSWORD, TextInputType::VISIBLE_PASSWORD}, + { AceAutoFillType::ACE_USER_NAME, TextInputType::USER_NAME }, + { AceAutoFillType::ACE_NEW_PASSWORD, TextInputType::NEW_PASSWORD }, + { AceAutoFillType::ACE_FULL_STREET_ADDRESS, TextInputType::TEXT }, + { AceAutoFillType::ACE_HOUSE_NUMBER, TextInputType::TEXT }, + { AceAutoFillType::ACE_DISTRICT_ADDRESS, TextInputType::TEXT }, + { AceAutoFillType::ACE_CITY_ADDRESS, TextInputType::TEXT }, + { AceAutoFillType::ACE_PROVINCE_ADDRESS, TextInputType::TEXT }, + { AceAutoFillType::ACE_COUNTRY_ADDRESS, TextInputType::TEXT }, + { AceAutoFillType::ACE_PERSON_FULL_NAME, TextInputType::TEXT }, + { AceAutoFillType::ACE_PERSON_LAST_NAME, TextInputType::TEXT }, + { AceAutoFillType::ACE_PERSON_FIRST_NAME, TextInputType::TEXT }, + { AceAutoFillType::ACE_PHONE_NUMBER, TextInputType::PHONE }, + { AceAutoFillType::ACE_PHONE_COUNTRY_CODE, TextInputType::PHONE }, + { AceAutoFillType::ACE_FULL_PHONE_NUMBER, TextInputType::PHONE }, + { AceAutoFillType::ACE_EMAIL_ADDRESS, TextInputType::EMAIL_ADDRESS }, + { AceAutoFillType::ACE_BANK_CARD_NUMBER, TextInputType::NUMBER }, + { AceAutoFillType::ACE_ID_CARD_NUMBER, TextInputType::NUMBER }, + { AceAutoFillType::ACE_PRECISE_TIME, TextInputType::NUMBER }, + { AceAutoFillType::ACE_HOUR_AND_MINUTE, TextInputType::NUMBER }, + { AceAutoFillType::ACE_DATE, TextInputType::NUMBER }, + { AceAutoFillType::ACE_MONTH, TextInputType::NUMBER }, + { AceAutoFillType::ACE_YEAR, TextInputType::NUMBER } }; + if (keyBoardMap.find(autoFillType) != keyBoardMap.end()) { + keyboard_ = keyBoardMap[autoFillType]; + } +} + bool TextFieldPattern::RequestKeyboard(bool isFocusViewChanged, bool needStartTwinkling, bool needShowSoftKeyboard) { auto tmpHost = GetHost(); @@ -3143,6 +3282,7 @@ bool TextFieldPattern::RequestKeyboard(bool isFocusViewChanged, bool needStartTw if (customKeyboardBuilder_) { return RequestCustomKeyboard(); } + KeyboardContentTypeToInputType(); #if defined(ENABLE_STANDARD_INPUT) if (textChangeListener_ == nullptr) { textChangeListener_ = new OnTextChangedListenerImpl(WeakClaim(this)); @@ -3245,8 +3385,8 @@ std::optional TextFieldPattern::GetMiscTextConfig() co AceAutoFillType TextFieldPattern::ConvertToAceAutoFillType(TextInputType type) { - static std::unordered_map convertMap = { { TextInputType::VISIBLE_PASSWORD, - AceAutoFillType::ACE_PASSWORD }, + static std::unordered_map convertMap = { + { TextInputType::VISIBLE_PASSWORD, AceAutoFillType::ACE_PASSWORD }, { TextInputType::USER_NAME, AceAutoFillType::ACE_USER_NAME }, { TextInputType::NEW_PASSWORD, AceAutoFillType::ACE_NEW_PASSWORD } }; auto it = convertMap.find(type); @@ -3256,6 +3396,14 @@ AceAutoFillType TextFieldPattern::ConvertToAceAutoFillType(TextInputType type) return AceAutoFillType::ACE_UNSPECIFIED; } +AceAutoFillType TextFieldPattern::TextContentTypeToAceAutoFillType(const TextContentType& type) +{ + if (contentTypeMap_.find(type) != contentTypeMap_.end()) { + return contentTypeMap_[type].first; + } + return contentTypeMap_[TextContentType::UNSPECIFIED].first; +} + bool TextFieldPattern::CloseKeyboard(bool forceClose) { return CloseKeyboard(forceClose, forceClose); @@ -4786,6 +4934,17 @@ std::string TextFieldPattern::TextInputTypeToString() const } } +std::string TextFieldPattern::TextContentTypeToString() const +{ + auto layoutProperty = GetLayoutProperty(); + CHECK_NULL_RETURN(layoutProperty, ""); + auto contentType = layoutProperty->GetTextContentTypeValue(TextContentType::UNSPECIFIED); + if (contentTypeMap_.find(contentType) != contentTypeMap_.end()) { + return contentTypeMap_[contentType].second; + } + return contentTypeMap_[TextContentType::UNSPECIFIED].second; +} + std::string TextFieldPattern::TextInputActionToString() const { auto layoutProperty = GetLayoutProperty(); @@ -5664,6 +5823,7 @@ void TextFieldPattern::ToJsonValue(std::unique_ptr& json) const json->Put("textAlign", V2::ConvertWrapTextAlignToString(GetTextAlign()).c_str()); json->Put("caretColor", GetCaretColor().c_str()); json->Put("type", TextInputTypeToString().c_str()); + json->Put("contentType", TextContentTypeToString().c_str()); json->Put("placeholderColor", GetPlaceholderColor().c_str()); json->Put("placeholderFont", GetPlaceholderFont().c_str()); json->Put("enterKeyType", TextInputActionToString().c_str()); @@ -5963,7 +6123,7 @@ void TextFieldPattern::DumpViewDataPageNode(RefPtr viewDataWrap) CHECK_NULL_VOID(host); auto layoutProperty = host->GetLayoutProperty(); CHECK_NULL_VOID(layoutProperty); - auto autoFillType = ConvertToAceAutoFillType(layoutProperty->GetTextInputTypeValue(TextInputType::UNSPECIFIED)); + auto autoFillType = GetAutoFillType(); auto info = PageNodeInfoWrap::CreatePageNodeInfoWrap(); CHECK_NULL_VOID(info); info->SetId(host->GetId()); @@ -5974,24 +6134,42 @@ void TextFieldPattern::DumpViewDataPageNode(RefPtr viewDataWrap) info->SetPlaceholder(GetPlaceHolder()); info->SetPasswordRules(layoutProperty->GetPasswordRulesValue("")); info->SetEnableAutoFill(layoutProperty->GetEnableAutoFillValue(true)); + auto offsetToWindow = host->GetOffsetRelativeToWindow(); + auto geometryNode = host->GetGeometryNode(); + CHECK_NULL_VOID(geometryNode); + auto pageNodeRect = geometryNode->GetFrameRect(); + pageNodeRect.SetLeft(offsetToWindow.GetX()); + pageNodeRect.SetTop(offsetToWindow.GetY()); + info->SetPageNodeRect(pageNodeRect); + info->SetIsFocus(HasFocus()); viewDataWrap->AddPageNodeInfoWrap(info); + auto pipeline = PipelineContext::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + viewDataWrap->SetPageRect(pipeline->GetRootRect()); } void TextFieldPattern::NotifyFillRequestSuccess(RefPtr nodeWrap, AceAutoFillType autoFillType) { TAG_LOGI(AceLogTag::ACE_AUTO_FILL, "autoFillType:%{public}d", static_cast(autoFillType)); + SetFillRequestFinish(true); + auto host = GetHost(); + CHECK_NULL_VOID(host); CHECK_NULL_VOID(nodeWrap); + auto isFocus = nodeWrap->GetIsFocus(); + if (isFocus && !HasFocus()) { + auto focusHub = host->GetOrCreateFocusHub(); + focusHub->RequestFocusImmediately(); + DoProcessAutoFill(); + } if (!contentController_ || contentController_->GetTextValue() == nodeWrap->GetValue()) { return; } contentController_->SetTextValue(nodeWrap->GetValue()); - auto host = GetHost(); - CHECK_NULL_VOID(host); NotifyOnEditChanged(true); host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); auto layoutProperty = host->GetLayoutProperty(); CHECK_NULL_VOID(layoutProperty); - auto type = ConvertToAceAutoFillType(layoutProperty->GetTextInputTypeValue(TextInputType::UNSPECIFIED)); + auto type = GetAutoFillType(); if (!(type == AceAutoFillType::ACE_NEW_PASSWORD && type == autoFillType)) { TAG_LOGI(AceLogTag::ACE_AUTO_FILL, "Set last auto fill text value."); lastAutoFillPasswordTextValue_ = nodeWrap->GetValue(); @@ -6001,6 +6179,7 @@ void TextFieldPattern::NotifyFillRequestSuccess(RefPtr nodeWra void TextFieldPattern::NotifyFillRequestFailed(int32_t errCode) { TAG_LOGI(AceLogTag::ACE_AUTO_FILL, "errCode:%{public}d", errCode); + SetFillRequestFinish(true); if (errCode == AUTO_FILL_FAILED) { return; } @@ -6024,18 +6203,17 @@ bool TextFieldPattern::CheckAutoSave() if (!contentController_ || contentController_->GetTextValue().empty()) { return false; } - auto autoFillType = layoutProperty->GetTextInputTypeValue(TextInputType::UNSPECIFIED); - if (autoFillType == TextInputType::USER_NAME) { + auto autoFillType = GetAutoFillType(); + if (autoFillType == AceAutoFillType::ACE_USER_NAME) { if (!lastAutoFillPasswordTextValue_.empty() && contentController_->GetTextValue() != lastAutoFillPasswordTextValue_) { return true; } } - if ((autoFillType == TextInputType::VISIBLE_PASSWORD || autoFillType == TextInputType::NEW_PASSWORD)) { + if (AceAutoFillType::ACE_UNSPECIFIED < autoFillType && autoFillType <= AceAutoFillType::ACE_YEAR) if (contentController_->GetTextValue() != lastAutoFillPasswordTextValue_) { return true; } - } return false; } diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h index 9724b08b1bc6a193890eb20fab473e1f0a88f3ae..3617606a88546e2e2a69783760a745107b014fa3 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h +++ b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -51,6 +51,7 @@ #include "core/components_ng/pattern/text_drag/text_drag_base.h" #include "core/components_ng/pattern/text_field/content_controller.h" #include "core/components_ng/pattern/text_field/text_editing_value_ng.h" +#include "core/components_ng/pattern/text_field/text_content_type.h" #include "core/components_ng/pattern/text_field/text_field_accessibility_property.h" #include "core/components_ng/pattern/text_field/text_field_controller.h" #include "core/components_ng/pattern/text_field/text_field_event_hub.h" @@ -764,6 +765,7 @@ public: // xts std::string TextInputTypeToString() const; std::string TextInputActionToString() const; + std::string TextContentTypeToString() const; std::string GetPlaceholderFont() const; RefPtr GetTheme() const; std::string GetTextColor() const; @@ -939,6 +941,16 @@ public: return inlineState_.frameRect.Width(); } + void SetFillRequestFinish(bool success) + { + isFillRequestFinish_ = success; + } + + bool IsFillRequestFinish() + { + return isFillRequestFinish_; + } + bool IsNormalInlineState() const; bool IsUnspecifiedOrTextType() const; void TextIsEmptyRect(RectF& rect); @@ -1184,6 +1196,7 @@ private: void AfterSelection(); + void AutoFillValueChanged(); void FireEventHubOnChange(const std::string& text); // The return value represents whether the editor content has change. bool FireOnTextChangeEvent(); @@ -1277,7 +1290,7 @@ private: bool HasInputOperation(); AceAutoFillType ConvertToAceAutoFillType(TextInputType type); bool CheckAutoFill(); - bool ProcessAutoFill(); + bool ProcessAutoFill(bool& isPopup); void ScrollToSafeArea() const override; void RecordSubmitEvent() const; void UpdateCancelNode(); @@ -1288,6 +1301,12 @@ private: void UpdateBlurReason(); RectF GetSelectArea(); void UpdateOverlaySelectArea(); + AceAutoFillType TextContentTypeToAceAutoFillType(const TextContentType& type); + bool CheckAutoFillType(const AceAutoFillType& aceAutoFillAllType); + AceAutoFillType GetAutoFillType(); + bool IsAutoFillPasswordType(const AceAutoFillType& autoFillType); + void DoProcessAutoFill(); + void KeyboardContentTypeToInputType(); RectF frameRect_; RectF textRect_; @@ -1454,6 +1473,7 @@ private: bool hasMousePressed_ = false; bool isLongPressPage_ = false; Offset locationInfo_; + bool isFillRequestFinish_ = false; }; } // namespace OHOS::Ace::NG diff --git a/interfaces/inner_api/ace/popup_ui_extension_config.h b/interfaces/inner_api/ace/popup_ui_extension_config.h index 57fccf88fc6a94f4d6d7553126ed5dc89d808c16..2b22c8ab17bcfd41772c7524c2726e64b94208cb 100644 --- a/interfaces/inner_api/ace/popup_ui_extension_config.h +++ b/interfaces/inner_api/ace/popup_ui_extension_config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -12,13 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + #ifndef FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_POPUP_CONFIG_H #define FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_POPUP_CONFIG_H - + #include #include - + namespace OHOS::Ace { enum class PopupPlacement { LEFT, @@ -35,7 +35,7 @@ enum class PopupPlacement { RIGHT_BOTTOM, NONE, }; - + enum class PopupDimensionUnit { PX = 0, VP, @@ -45,26 +45,28 @@ enum class PopupDimensionUnit { AUTO, CALC, }; - + struct PopupOffset { PopupDimensionUnit unit = PopupDimensionUnit::PX; double deltaX = 0.0; double deltaY = 0.0; }; - + struct PopupSize { PopupDimensionUnit unit = PopupDimensionUnit::PX; double width = 0.0; double height = 0.0; }; - + struct PopupLength { PopupDimensionUnit unit = PopupDimensionUnit::PX; double length = 0.0; }; - + struct CustomPopupUIExtensionConfig { bool isShowInSubWindow = true; + bool isFocusable = true; + std::int32_t nodeId = -1; std::string inspectorId; std::optional isAutoCancel; std::optional isEnableArrow; diff --git a/interfaces/inner_api/ace/ui_content.h b/interfaces/inner_api/ace/ui_content.h index f608ebcdce033bfa58cc1475ed7dd42fab5c9970..98e09c9c3d58d425295635f9363a5c5fdfb0d9f5 100644 --- a/interfaces/inner_api/ace/ui_content.h +++ b/interfaces/inner_api/ace/ui_content.h @@ -74,6 +74,7 @@ class PixelMap; namespace AbilityBase { struct ViewData; +enum class AutoFillType; } // namespace AbilityBase class RefBase; @@ -244,7 +245,7 @@ public: */ virtual sptr GetParentToken(); - virtual bool DumpViewData(AbilityBase::ViewData& viewData) + virtual bool DumpViewData(AbilityBase::ViewData& viewData, AbilityBase::AutoFillType& type) { return false; }