已合并
autofill text menu #76677
duanshaofei创建于 2025年11月21日
autofill text menu #76677
已合并
共 23 个文件变更+246-13
Mframeworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/generated/component/web.ets+7-0
| @@ -904,6 +904,10 @@ export class WebContextMenuResult implements MaterializedBase { | |||
| 904 | this.pasteAndMatchStyle_serialize() | 904 | this.pasteAndMatchStyle_serialize() |
| 905 | return | 905 | return |
| 906 | } | 906 | } |
| 907 | + public requestPasswordAutoFill(): void { | ||
| 908 | + this.requestPasswordAutoFill_serialize() | ||
| 909 | + return | ||
| 910 | + } | ||
| 907 | closeContextMenu_serialize(): void { | 911 | closeContextMenu_serialize(): void { |
| 908 | ArkUIGeneratedNativeModule._WebContextMenuResult_closeContextMenu(this.peer!.ptr) | 912 | ArkUIGeneratedNativeModule._WebContextMenuResult_closeContextMenu(this.peer!.ptr) |
| 909 | } | 913 | } |
| @@ -931,6 +935,9 @@ export class WebContextMenuResult implements MaterializedBase { | |||
| 931 | pasteAndMatchStyle_serialize(): void { | 935 | pasteAndMatchStyle_serialize(): void { |
| 932 | ArkUIGeneratedNativeModule._WebContextMenuResult_pasteAndMatchStyle(this.peer!.ptr) | 936 | ArkUIGeneratedNativeModule._WebContextMenuResult_pasteAndMatchStyle(this.peer!.ptr) |
| 933 | } | 937 | } |
| 938 | + requestPasswordAutoFill_serialize(): void { | ||
| 939 | + ArkUIGeneratedNativeModule._WebContextMenuResult_requestPasswordAutoFill(this.peer!.ptr) | ||
| 940 | + } | ||
| 934 | } | 941 | } |
| 935 | export class WebKeyboardControllerInternal { | 942 | export class WebKeyboardControllerInternal { |
| 936 | public static fromPtr(ptr: KPointer): WebKeyboardController { | 943 | public static fromPtr(ptr: KPointer): WebKeyboardController { |
| @@ -6271,6 +6271,8 @@ export class ArkUIGeneratedNativeModule { | |||
| 6271 | @ani.unsafe.Direct | 6271 | @ani.unsafe.Direct |
| 6272 | native static _WebContextMenuResult_pasteAndMatchStyle(ptr: KPointer): void | 6272 | native static _WebContextMenuResult_pasteAndMatchStyle(ptr: KPointer): void |
| 6273 | @ani.unsafe.Direct | 6273 | @ani.unsafe.Direct |
| 6274 | + native static _WebContextMenuResult_requestPasswordAutoFill(ptr: KPointer): void | ||
| 6275 | + @ani.unsafe.Direct | ||
| 6274 | native static _WebKeyboardController_construct(): KPointer | 6276 | native static _WebKeyboardController_construct(): KPointer |
| 6275 | @ani.unsafe.Direct | 6277 | @ani.unsafe.Direct |
| 6276 | native static _WebKeyboardController_getFinalizer(): KPointer | 6278 | native static _WebKeyboardController_getFinalizer(): KPointer |
| @@ -29603,6 +29603,7 @@ typedef struct GENERATED_ArkUIWebContextMenuResultAccessor { | |||
| 29603 | void (*redo)(Ark_WebContextMenuResult peer); | 29603 | void (*redo)(Ark_WebContextMenuResult peer); |
| 29604 | void (*undo)(Ark_WebContextMenuResult peer); | 29604 | void (*undo)(Ark_WebContextMenuResult peer); |
| 29605 | void (*pasteAndMatchStyle)(Ark_WebContextMenuResult peer); | 29605 | void (*pasteAndMatchStyle)(Ark_WebContextMenuResult peer); |
| 29606 | + void (*requestPasswordAutoFill)(Ark_WebContextMenuResult peer); | ||
| 29606 | } GENERATED_ArkUIWebContextMenuResultAccessor; | 29607 | } GENERATED_ArkUIWebContextMenuResultAccessor; |
| 29607 | 29608 | ||
| 29608 | typedef struct GENERATED_ArkUIWebKeyboardControllerAccessor { | 29609 | typedef struct GENERATED_ArkUIWebKeyboardControllerAccessor { |
| @@ -39183,6 +39183,11 @@ void impl_WebContextMenuResult_pasteAndMatchStyle(Ark_NativePointer thisPtr) { | |||
| 39183 | GetAccessors()->getWebContextMenuResultAccessor()->pasteAndMatchStyle(self); | 39183 | GetAccessors()->getWebContextMenuResultAccessor()->pasteAndMatchStyle(self); |
| 39184 | } | 39184 | } |
| 39185 | KOALA_INTEROP_DIRECT_V1(WebContextMenuResult_pasteAndMatchStyle, Ark_NativePointer) | 39185 | KOALA_INTEROP_DIRECT_V1(WebContextMenuResult_pasteAndMatchStyle, Ark_NativePointer) |
| 39186 | +void impl_WebContextMenuResult_requestPasswordAutoFill(Ark_NativePointer thisPtr) { | ||
| 39187 | + Ark_WebContextMenuResult self = reinterpret_cast<Ark_WebContextMenuResult>(thisPtr); | ||
| 39188 | + GetAccessors()->getWebContextMenuResultAccessor()->requestPasswordAutoFill(self); | ||
| 39189 | +} | ||
| 39190 | +KOALA_INTEROP_DIRECT_V1(WebContextMenuResult_requestPasswordAutoFill, Ark_NativePointer) | ||
| 39186 | Ark_NativePointer impl_WebKeyboardController_construct() { | 39191 | Ark_NativePointer impl_WebKeyboardController_construct() { |
| 39187 | return GetAccessors()->getWebKeyboardControllerAccessor()->construct(); | 39192 | return GetAccessors()->getWebKeyboardControllerAccessor()->construct(); |
| 39188 | } | 39193 | } |
| @@ -46228,6 +46228,16 @@ namespace OHOS::Ace::NG::GeneratedModifier { | |||
| 46228 | out.append(") \n"); | 46228 | out.append(") \n"); |
| 46229 | appendGroupedLog(1, out); | 46229 | appendGroupedLog(1, out); |
| 46230 | } | 46230 | } |
| 46231 | + void RequestPasswordAutoFillImpl(Ark_WebContextMenuResult peer) | ||
| 46232 | + { | ||
| 46233 | + if (!needGroupedLog(1)) | ||
| 46234 | + { | ||
| 46235 | + return; | ||
| 46236 | + } | ||
| 46237 | + string out("requestPasswordAutoFill("); | ||
| 46238 | + out.append(") \n"); | ||
| 46239 | + appendGroupedLog(1, out); | ||
| 46240 | + } | ||
| 46231 | } // WebContextMenuResultAccessor | 46241 | } // WebContextMenuResultAccessor |
| 46232 | namespace WebKeyboardControllerAccessor { | 46242 | namespace WebKeyboardControllerAccessor { |
| 46233 | void DestroyPeerImpl(Ark_WebKeyboardController peer) | 46243 | void DestroyPeerImpl(Ark_WebKeyboardController peer) |
| @@ -50571,6 +50581,7 @@ namespace OHOS::Ace::NG::GeneratedModifier { | |||
| 50571 | WebContextMenuResultAccessor::RedoImpl, | 50581 | WebContextMenuResultAccessor::RedoImpl, |
| 50572 | WebContextMenuResultAccessor::UndoImpl, | 50582 | WebContextMenuResultAccessor::UndoImpl, |
| 50573 | WebContextMenuResultAccessor::PasteAndMatchStyleImpl, | 50583 | WebContextMenuResultAccessor::PasteAndMatchStyleImpl, |
| 50584 | + WebContextMenuResultAccessor::RequestPasswordAutoFillImpl, | ||
| 50574 | }; | 50585 | }; |
| 50575 | return &WebContextMenuResultAccessorImpl; | 50586 | return &WebContextMenuResultAccessorImpl; |
| 50576 | } | 50587 | } |
| @@ -19074,6 +19074,9 @@ namespace OHOS::Ace::NG::GeneratedModifier { | |||
| 19074 | void PasteAndMatchStyleImpl(Ark_WebContextMenuResult peer) | 19074 | void PasteAndMatchStyleImpl(Ark_WebContextMenuResult peer) |
| 19075 | { | 19075 | { |
| 19076 | } | 19076 | } |
| 19077 | + void RequestPasswordAutoFillImpl(Ark_WebContextMenuResult peer) | ||
| 19078 | + { | ||
| 19079 | + } | ||
| 19077 | } // WebContextMenuResultAccessor | 19080 | } // WebContextMenuResultAccessor |
| 19078 | namespace WebKeyboardControllerAccessor { | 19081 | namespace WebKeyboardControllerAccessor { |
| 19079 | void DestroyPeerImpl(Ark_WebKeyboardController peer) | 19082 | void DestroyPeerImpl(Ark_WebKeyboardController peer) |
| @@ -2075,6 +2075,8 @@ public: | |||
| 2075 | JSClass<JSContextMenuResult>::CustomMethod("undo", &JSContextMenuResult::Undo); | 2075 | JSClass<JSContextMenuResult>::CustomMethod("undo", &JSContextMenuResult::Undo); |
| 2076 | JSClass<JSContextMenuResult>::CustomMethod("redo", &JSContextMenuResult::Redo); | 2076 | JSClass<JSContextMenuResult>::CustomMethod("redo", &JSContextMenuResult::Redo); |
| 2077 | JSClass<JSContextMenuResult>::CustomMethod("pasteAndMatchStyle", &JSContextMenuResult::PasteAndMatchStyle); | 2077 | JSClass<JSContextMenuResult>::CustomMethod("pasteAndMatchStyle", &JSContextMenuResult::PasteAndMatchStyle); |
| 2078 | + JSClass<JSContextMenuResult>::CustomMethod("requestPasswordAutoFill", | ||
| 2079 | + &JSContextMenuResult::RequestPasswordAutoFill); | ||
| 2078 | JSClass<JSContextMenuResult>::Bind( | 2080 | JSClass<JSContextMenuResult>::Bind( |
| 2079 | globalObj, &JSContextMenuResult::Constructor, &JSContextMenuResult::Destructor); | 2081 | globalObj, &JSContextMenuResult::Constructor, &JSContextMenuResult::Destructor); |
| 2080 | } | 2082 | } |
| @@ -2151,6 +2153,13 @@ public: | |||
| 2151 | } | 2153 | } |
| 2152 | } | 2154 | } |
| 2153 | 2155 | ||
| 2156 | + void RequestPasswordAutoFill(const JSCallbackInfo& args) | ||
| 2157 | + { | ||
| 2158 | + if (result_) { | ||
| 2159 | + result_->RequestPasswordAutoFill(); | ||
| 2160 | + } | ||
| 2161 | + } | ||
| 2162 | + | ||
| 2154 | private: | 2163 | private: |
| 2155 | static void Constructor(const JSCallbackInfo& args) | 2164 | static void Constructor(const JSCallbackInfo& args) |
| 2156 | { | 2165 | { |
| @@ -719,7 +719,7 @@ bool WebClientImpl::RunContextMenu( | |||
| 719 | ContainerScope scope(delegate->GetInstanceId()); | 719 | ContainerScope scope(delegate->GetInstanceId()); |
| 720 | bool jsResult = false; | 720 | bool jsResult = false; |
| 721 | auto param = std::make_shared<ContextMenuEvent>(AceType::MakeRefPtr<ContextMenuParamOhos>(params), | 721 | auto param = std::make_shared<ContextMenuEvent>(AceType::MakeRefPtr<ContextMenuParamOhos>(params), |
| 722 | - AceType::MakeRefPtr<ContextMenuResultOhos>(callback)); | 722 | + AceType::MakeRefPtr<ContextMenuResultOhos>(callback, webDelegate_)); |
| 723 | auto task = delegate->GetTaskExecutor(); | 723 | auto task = delegate->GetTaskExecutor(); |
| 724 | if (task == nullptr) { | 724 | if (task == nullptr) { |
| 725 | return false; | 725 | return false; |
| @@ -831,6 +831,17 @@ void ContextMenuResultOhos::PasteAndMatchStyle() const | |||
| 831 | } | 831 | } |
| 832 | } | 832 | } |
| 833 | 833 | ||
| 834 | +void ContextMenuResultOhos::RequestPasswordAutoFill() const | ||
| 835 | +{ | ||
| 836 | + if (callback_) { | ||
| 837 | + callback_->Continue(CI_REQUEST_AUTOFILL, EF_NONE); | ||
| 838 | + } | ||
| 839 | + auto delegate = delegate_.Upgrade(); | ||
| 840 | + if (delegate) { | ||
| 841 | + delegate->OnRequestAutofill(static_cast<int32_t>(NG::WebMenuType::TYPE_CONTEXTMENU)); | ||
| 842 | + } | ||
| 843 | +} | ||
| 844 | + | ||
| 834 | void WebWindowNewHandlerOhos::SetWebController(int32_t id) | 845 | void WebWindowNewHandlerOhos::SetWebController(int32_t id) |
| 835 | { | 846 | { |
| 836 | if (handler_) { | 847 | if (handler_) { |
| @@ -9592,6 +9603,13 @@ void WebDelegate::OnFirstScreenPaint( | |||
| 9592 | TaskExecutor::TaskType::JS, "ArkUIWebOnFirstScreenPaint"); | 9603 | TaskExecutor::TaskType::JS, "ArkUIWebOnFirstScreenPaint"); |
| 9593 | } | 9604 | } |
| 9594 | 9605 | ||
| 9606 | +void WebDelegate::OnRequestAutofill(int32_t menuType) | ||
| 9607 | +{ | ||
| 9608 | + auto webPattern = webPattern_.Upgrade(); | ||
| 9609 | + CHECK_NULL_VOID(webPattern); | ||
| 9610 | + webPattern->RequestPasswordAutoFill(static_cast<NG::WebMenuType>(menuType)); | ||
| 9611 | +} | ||
| 9612 | + | ||
| 9595 | void WebDelegate::UpdateBlankScreenDetectionConfig(bool enable, const std::vector<double>& detectionTiming, | 9613 | void WebDelegate::UpdateBlankScreenDetectionConfig(bool enable, const std::vector<double>& detectionTiming, |
| 9596 | const std::vector<int32_t>& detectionMethods, int32_t contentfulNodesCountThreshold) | 9614 | const std::vector<int32_t>& detectionMethods, int32_t contentfulNodesCountThreshold) |
| 9597 | { | 9615 | { |
| @@ -317,8 +317,9 @@ class ContextMenuResultOhos : public ContextMenuResult { | |||
| 317 | DECLARE_ACE_TYPE(ContextMenuResultOhos, ContextMenuResult); | 317 | DECLARE_ACE_TYPE(ContextMenuResultOhos, ContextMenuResult); |
| 318 | 318 | ||
| 319 | public: | 319 | public: |
| 320 | - explicit ContextMenuResultOhos(std::shared_ptr<OHOS::NWeb::NWebContextMenuCallback> callback) | 320 | + explicit ContextMenuResultOhos(std::shared_ptr<OHOS::NWeb::NWebContextMenuCallback> callback, |
| 321 | - : callback_(callback) {} | 321 | + const WeakPtr<WebDelegate>& delegate) |
| 322 | + : callback_(callback), delegate_(delegate) {} | ||
| 322 | 323 | ||
| 323 | void Cancel() const override; | 324 | void Cancel() const override; |
| 324 | void CopyImage() const override; | 325 | void CopyImage() const override; |
| @@ -329,9 +330,11 @@ public: | |||
| 329 | void Undo() const override; | 330 | void Undo() const override; |
| 330 | void Redo() const override; | 331 | void Redo() const override; |
| 331 | void PasteAndMatchStyle() const override; | 332 | void PasteAndMatchStyle() const override; |
| 333 | + void RequestPasswordAutoFill() const override; | ||
| 332 | 334 | ||
| 333 | private: | 335 | private: |
| 334 | std::shared_ptr<OHOS::NWeb::NWebContextMenuCallback> callback_; | 336 | std::shared_ptr<OHOS::NWeb::NWebContextMenuCallback> callback_; |
| 337 | + WeakPtr<WebDelegate> delegate_; | ||
| 335 | }; | 338 | }; |
| 336 | 339 | ||
| 337 | class WebGeolocationOhos : public WebGeolocation { | 340 | class WebGeolocationOhos : public WebGeolocation { |
| @@ -1507,6 +1510,7 @@ public: | |||
| 1507 | void OnPdfScrollAtBottom(const std::string& url); | 1510 | void OnPdfScrollAtBottom(const std::string& url); |
| 1508 | void OnPdfLoadEvent(int32_t result, const std::string& url); | 1511 | void OnPdfLoadEvent(int32_t result, const std::string& url); |
| 1509 | void SetImeShow(bool visible); | 1512 | void SetImeShow(bool visible); |
| 1513 | + void OnRequestAutofill(int32_t menuType); | ||
| 1510 | 1514 | ||
| 1511 | bool HasOnNativeEmbedGestureEventV2() | 1515 | bool HasOnNativeEmbedGestureEventV2() |
| 1512 | { | 1516 | { |
| @@ -1757,6 +1757,7 @@ public: | |||
| 1757 | virtual void Undo() const = 0; | 1757 | virtual void Undo() const = 0; |
| 1758 | virtual void Redo() const = 0; | 1758 | virtual void Redo() const = 0; |
| 1759 | virtual void PasteAndMatchStyle() const = 0; | 1759 | virtual void PasteAndMatchStyle() const = 0; |
| 1760 | + virtual void RequestPasswordAutoFill() const = 0; | ||
| 1760 | }; | 1761 | }; |
| 1761 | 1762 | ||
| 1762 | class ACE_EXPORT ContextMenuEvent : public BaseEventInfo { | 1763 | class ACE_EXPORT ContextMenuEvent : public BaseEventInfo { |
| @@ -1216,6 +1216,7 @@ void WebPattern::OnContextMenuShow(const std::shared_ptr<BaseEventInfo>& info, b | |||
| 1216 | CHECK_NULL_VOID(contextMenuParam_); | 1216 | CHECK_NULL_VOID(contextMenuParam_); |
| 1217 | contextMenuResult_ = eventInfo->GetContextMenuResult(); | 1217 | contextMenuResult_ = eventInfo->GetContextMenuResult(); |
| 1218 | CHECK_NULL_VOID(contextMenuResult_); | 1218 | CHECK_NULL_VOID(contextMenuResult_); |
| 1219 | + isEditableOnContextMenu_ = contextMenuParam_->IsEditable(); | ||
| 1219 | bool isImage = false; | 1220 | bool isImage = false; |
| 1220 | bool isHyperLink = false; | 1221 | bool isHyperLink = false; |
| 1221 | bool isText = false; | 1222 | bool isText = false; |
| @@ -5444,7 +5445,11 @@ void WebPattern::NotifyFillRequestSuccess(RefPtr<ViewDataWrap> viewDataWrap, | |||
| 5444 | if (nodeInfoWrap->GetIsFocus()) { | 5445 | if (nodeInfoWrap->GetIsFocus()) { |
| 5445 | focusType = type; | 5446 | focusType = type; |
| 5446 | } | 5447 | } |
| 5448 | + if (triggerType == AceAutoFillTriggerType::MANUAL_REQUEST && type == AceAutoFillType::ACE_UNSPECIFIED) { | ||
| 5449 | + jsonNode->Put(OHOS::NWeb::NWEB_VIEW_DATA_KEY_VALUE.c_str(), nodeInfoWrap->GetValue().c_str()); | ||
| 5450 | + } | ||
| 5447 | } | 5451 | } |
| 5452 | + | ||
| 5448 | auto pageUrl = viewDataWrap->GetPageUrl(); | 5453 | auto pageUrl = viewDataWrap->GetPageUrl(); |
| 5449 | jsonNode->Put(AUTO_FILL_VIEW_DATA_PAGE_URL.c_str(), pageUrl.c_str()); | 5454 | jsonNode->Put(AUTO_FILL_VIEW_DATA_PAGE_URL.c_str(), pageUrl.c_str()); |
| 5450 | auto otherAccount = viewDataWrap->GetOtherAccount(); | 5455 | auto otherAccount = viewDataWrap->GetOtherAccount(); |
| @@ -5452,6 +5457,14 @@ void WebPattern::NotifyFillRequestSuccess(RefPtr<ViewDataWrap> viewDataWrap, | |||
| 5452 | delegate_->NotifyAutoFillViewData(jsonNode->ToString(), ConvertAceAutoFillTriggerType(triggerType)); | 5457 | delegate_->NotifyAutoFillViewData(jsonNode->ToString(), ConvertAceAutoFillTriggerType(triggerType)); |
| 5453 | 5458 | ||
| 5454 | // shift focus after autofill | 5459 | // shift focus after autofill |
| 5460 | + ShiftFocusAfterAutoFill(focusType); | ||
| 5461 | + if (triggerType == AceAutoFillTriggerType::MANUAL_REQUEST) { | ||
| 5462 | + autoFillMenuType_ = WebMenuType::TYPE_UNKNOWN_MENU; | ||
| 5463 | + } | ||
| 5464 | +} | ||
| 5465 | + | ||
| 5466 | +void WebPattern::ShiftFocusAfterAutoFill(AceAutoFillType focusType) | ||
| 5467 | +{ | ||
| 5455 | if (focusType != AceAutoFillType::ACE_UNSPECIFIED && !isPasswordFill_) { | 5468 | if (focusType != AceAutoFillType::ACE_UNSPECIFIED && !isPasswordFill_) { |
| 5456 | for (const auto& nodeInfo : pageNodeInfo_) { | 5469 | for (const auto& nodeInfo : pageNodeInfo_) { |
| 5457 | if (nodeInfo && nodeInfo->GetAutoFillType() == focusType) { | 5470 | if (nodeInfo && nodeInfo->GetAutoFillType() == focusType) { |
| @@ -5671,8 +5684,9 @@ bool WebPattern::HandleAutoFillEvent() | |||
| 5671 | 5684 | ||
| 5672 | auto eventType = viewDataCommon_->GetEventType(); | 5685 | auto eventType = viewDataCommon_->GetEventType(); |
| 5673 | if (eventType == OHOS::NWeb::NWebAutofillEvent::FILL) { | 5686 | if (eventType == OHOS::NWeb::NWebAutofillEvent::FILL) { |
| 5687 | + AceAutoFillTriggerType triggerType = AceAutoFillTriggerType::AUTO_REQUEST; | ||
| 5674 | if (isPasswordFill_ && !system::GetBoolParameter(AUTO_FILL_START_POPUP_WINDOW, false)) { | 5688 | if (isPasswordFill_ && !system::GetBoolParameter(AUTO_FILL_START_POPUP_WINDOW, false)) { |
| 5675 | - return RequestAutoFill(GetFocusedType()); | 5689 | + return RequestAutoFill(GetFocusedType(), triggerType); |
| 5676 | } | 5690 | } |
| 5677 | auto host = GetHost(); | 5691 | auto host = GetHost(); |
| 5678 | CHECK_NULL_RETURN(host, false); | 5692 | CHECK_NULL_RETURN(host, false); |
| @@ -5684,7 +5698,8 @@ bool WebPattern::HandleAutoFillEvent() | |||
| 5684 | [weak = WeakClaim(this), nodeInfos = pageNodeInfo_] () { | 5698 | [weak = WeakClaim(this), nodeInfos = pageNodeInfo_] () { |
| 5685 | auto pattern = weak.Upgrade(); | 5699 | auto pattern = weak.Upgrade(); |
| 5686 | CHECK_NULL_RETURN(pattern, false); | 5700 | CHECK_NULL_RETURN(pattern, false); |
| 5687 | - return pattern->RequestAutoFill(pattern->GetFocusedType(), nodeInfos); | 5701 | + AceAutoFillTriggerType triggerType = AceAutoFillTriggerType::AUTO_REQUEST; |
| 5702 | + return pattern->RequestAutoFill(pattern->GetFocusedType(), nodeInfos, triggerType); | ||
| 5688 | }, | 5703 | }, |
| 5689 | TaskExecutor::TaskType::UI, AUTOFILL_DELAY_TIME, "ArkUIWebHandleAutoFillEvent"); | 5704 | TaskExecutor::TaskType::UI, AUTOFILL_DELAY_TIME, "ArkUIWebHandleAutoFillEvent"); |
| 5690 | return fillRet; | 5705 | return fillRet; |
| @@ -5719,12 +5734,13 @@ bool WebPattern::HandleAutoFillEvent(const std::shared_ptr<OHOS::NWeb::NWebHapVa | |||
| 5719 | return HandleAutoFillEvent(); | 5734 | return HandleAutoFillEvent(); |
| 5720 | } | 5735 | } |
| 5721 | 5736 | ||
| 5722 | -bool WebPattern::RequestAutoFill(AceAutoFillType autoFillType) | 5737 | +bool WebPattern::RequestAutoFill(AceAutoFillType autoFillType, AceAutoFillTriggerType triggerType) |
| 5723 | { | 5738 | { |
| 5724 | - return RequestAutoFill(autoFillType, pageNodeInfo_); | 5739 | + return RequestAutoFill(autoFillType, pageNodeInfo_, triggerType); |
| 5725 | } | 5740 | } |
| 5726 | 5741 | ||
| 5727 | -bool WebPattern::RequestAutoFill(AceAutoFillType autoFillType, const std::vector<RefPtr<PageNodeInfoWrap>>& nodeInfos) | 5742 | +bool WebPattern::RequestAutoFill(AceAutoFillType autoFillType, const std::vector<RefPtr<PageNodeInfoWrap>>& nodeInfos, |
| 5743 | + AceAutoFillTriggerType triggerType) | ||
| 5728 | { | 5744 | { |
| 5729 | TAG_LOGI(AceLogTag::ACE_WEB, "RequestAutoFill"); | 5745 | TAG_LOGI(AceLogTag::ACE_WEB, "RequestAutoFill"); |
| 5730 | auto host = GetHost(); | 5746 | auto host = GetHost(); |
| @@ -5752,10 +5768,26 @@ bool WebPattern::RequestAutoFill(AceAutoFillType autoFillType, const std::vector | |||
| 5752 | CHECK_NULL_RETURN(container, false); | 5768 | CHECK_NULL_RETURN(container, false); |
| 5753 | isAutoFillClosing_ = false; | 5769 | isAutoFillClosing_ = false; |
| 5754 | bool isPopup = false; | 5770 | bool isPopup = false; |
| 5755 | - return container->RequestAutoFill(host, autoFillType, false, isPopup, autoFillSessionId_, false) == | 5771 | + return container->RequestAutoFill(host, autoFillType, false, isPopup, autoFillSessionId_, |
| 5772 | + false, nullptr, nullptr, triggerType) == | ||
两个nullptr 作用明确一下,是否为默认值 ![]() ![]() | |||
| 5756 | AceAutoFillError::ACE_AUTO_FILL_SUCCESS; | 5773 | AceAutoFillError::ACE_AUTO_FILL_SUCCESS; |
| 5757 | } | 5774 | } |
| 5758 | 5775 | ||
| 5776 | +void WebPattern::RequestPasswordAutoFill(WebMenuType menuType) | ||
| 5777 | +{ | ||
| 5778 | + TAG_LOGI(AceLogTag::ACE_WEB, "WebPattern::RequestPasswordAutoFill"); | ||
| 5779 | + if (menuType == WebMenuType::TYPE_CONTEXTMENU) { | ||
| 5780 | + if (!isEditableOnContextMenu_) { | ||
isEditableOnContextMenu_ 是否需要在这次请求后,恢复初值 ![]() ![]() | |||
| 5781 | + TAG_LOGE(AceLogTag::ACE_WEB, "web do not send autofill request."); | ||
| 5782 | + return; | ||
| 5783 | + } | ||
| 5784 | + } | ||
| 5785 | + autoFillMenuType_ = menuType; | ||
| 5786 | + FakePageNodeInfo(); | ||
| 5787 | + RequestAutoFill(GetFocusedType(), AceAutoFillTriggerType::MANUAL_REQUEST); | ||
| 5788 | + isEditableOnContextMenu_ = false; | ||
| 5789 | +} | ||
| 5790 | + | ||
| 5759 | void WebPattern::FakePageNodeInfo() | 5791 | void WebPattern::FakePageNodeInfo() |
| 5760 | { | 5792 | { |
| 5761 | auto host = GetHost(); | 5793 | auto host = GetHost(); |
| @@ -117,6 +117,12 @@ enum class WebInfoType : int32_t { | |||
| 117 | TYPE_UNKNOWN | 117 | TYPE_UNKNOWN |
| 118 | }; | 118 | }; |
| 119 | 119 | ||
| 120 | +enum class WebMenuType : int32_t { | ||
| 121 | + TYPE_CONTEXTMENU, | ||
| 122 | + TYPE_QUICKMENU, | ||
| 123 | + TYPE_UNKNOWN_MENU | ||
| 124 | +}; | ||
| 125 | + | ||
| 120 | struct PipInfo { | 126 | struct PipInfo { |
| 121 | int32_t nodeId; | 127 | int32_t nodeId; |
| 122 | uint32_t mainWindowId; | 128 | uint32_t mainWindowId; |
| @@ -695,10 +701,13 @@ public: | |||
| 695 | bool HandleAutoFillEvent(); | 701 | bool HandleAutoFillEvent(); |
| 696 | bool HandleAutoFillEvent(const std::shared_ptr<OHOS::NWeb::NWebMessage>& viewDataJson); | 702 | bool HandleAutoFillEvent(const std::shared_ptr<OHOS::NWeb::NWebMessage>& viewDataJson); |
| 697 | bool HandleAutoFillEvent(const std::shared_ptr<OHOS::NWeb::NWebHapValue>& viewDataJson); | 703 | bool HandleAutoFillEvent(const std::shared_ptr<OHOS::NWeb::NWebHapValue>& viewDataJson); |
| 698 | - bool RequestAutoFill(AceAutoFillType autoFillType); | 704 | + bool RequestAutoFill(AceAutoFillType autoFillType, |
| 699 | - bool RequestAutoFill(AceAutoFillType autoFillType, const std::vector<RefPtr<PageNodeInfoWrap>>& nodeInfos); | 705 | + AceAutoFillTriggerType triggerType = AceAutoFillTriggerType::AUTO_REQUEST); |
| 706 | + bool RequestAutoFill(AceAutoFillType autoFillType, const std::vector<RefPtr<PageNodeInfoWrap>>& nodeInfos, | ||
| 707 | + AceAutoFillTriggerType triggerType = AceAutoFillTriggerType::AUTO_REQUEST); | ||
| 700 | bool RequestAutoFill(bool& isPopup, bool isNewPassWord, const AceAutoFillTriggerType& triggerType); | 708 | bool RequestAutoFill(bool& isPopup, bool isNewPassWord, const AceAutoFillTriggerType& triggerType); |
| 701 | bool RequestAutoSave(); | 709 | bool RequestAutoSave(); |
| 710 | + void RequestPasswordAutoFill(WebMenuType menuType); | ||
| 702 | bool UpdateAutoFillPopup(); | 711 | bool UpdateAutoFillPopup(); |
| 703 | bool CloseAutoFillPopup(); | 712 | bool CloseAutoFillPopup(); |
| 704 | void OnCompleteSwapWithNewSize(); | 713 | void OnCompleteSwapWithNewSize(); |
| @@ -1340,6 +1349,8 @@ private: | |||
| 1340 | bool MenuAvoidKeyboard(bool hideOrClose, double height = 0.0f); | 1349 | bool MenuAvoidKeyboard(bool hideOrClose, double height = 0.0f); |
| 1341 | int32_t GetVisibleViewportAvoidHeight(); | 1350 | int32_t GetVisibleViewportAvoidHeight(); |
| 1342 | 1351 | ||
| 1352 | + void ShiftFocusAfterAutoFill(AceAutoFillType focusType); | ||
| 1353 | + | ||
| 1343 | void HandleAIWriteResult(int32_t start, int32_t end, std::vector<uint8_t>& buffer); | 1354 | void HandleAIWriteResult(int32_t start, int32_t end, std::vector<uint8_t>& buffer); |
| 1344 | void FormatIndex(int32_t& startIndex, int32_t& endIndex); | 1355 | void FormatIndex(int32_t& startIndex, int32_t& endIndex); |
| 1345 | std::u16string GetSelectedValue(int32_t startIndex, int32_t endIndex); | 1356 | std::u16string GetSelectedValue(int32_t startIndex, int32_t endIndex); |
| @@ -1521,6 +1532,8 @@ private: | |||
| 1521 | uint32_t windowId_ = 0; | 1532 | uint32_t windowId_ = 0; |
| 1522 | int64_t focusedAccessibilityId_ = -1; | 1533 | int64_t focusedAccessibilityId_ = -1; |
| 1523 | std::vector<RefPtr<PageNodeInfoWrap>> pageNodeInfo_; | 1534 | std::vector<RefPtr<PageNodeInfoWrap>> pageNodeInfo_; |
| 1535 | + bool isEditableOnContextMenu_ = false; | ||
| 1536 | + WebMenuType autoFillMenuType_ = WebMenuType::TYPE_UNKNOWN_MENU; | ||
| 1524 | bool isRenderModeInit_ = false; | 1537 | bool isRenderModeInit_ = false; |
| 1525 | bool isAutoFillClosing_ = true; | 1538 | bool isAutoFillClosing_ = true; |
| 1526 | std::shared_ptr<ViewDataCommon> viewDataCommon_; | 1539 | std::shared_ptr<ViewDataCommon> viewDataCommon_; |
| @@ -350,6 +350,16 @@ void WebSelectOverlay::HideMagnifier() | |||
| 350 | pattern->HideMagnifier(); | 350 | pattern->HideMagnifier(); |
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | +bool WebSelectOverlay::IsShowMenuOfAutoFill(uint32_t flags, SelectOverlayInfo& selectInfo) | ||
| 354 | +{ | ||
| 355 | + if (!(flags & OHOS::NWeb::NWebQuickMenuParams::QM_EF_CAN_AUTOFILL) || | ||
| 356 | + !(selectInfo.isSingleHandle || selectInfo.menuInfo.showCut)) { | ||
!(selectInfo.isSingleHandle || selectInfo.menuInfo.showCut) 作用是判断是否在编译态 ![]() ![]() | |||
| 357 | + return false; | ||
| 358 | + } else { | ||
| 359 | + return true; | ||
| 360 | + } | ||
| 361 | +} | ||
| 362 | + | ||
| 353 | void WebSelectOverlay::SetMenuOptions(SelectOverlayInfo& selectInfo, | 363 | void WebSelectOverlay::SetMenuOptions(SelectOverlayInfo& selectInfo, |
| 354 | std::shared_ptr<OHOS::NWeb::NWebQuickMenuParams> params, | 364 | std::shared_ptr<OHOS::NWeb::NWebQuickMenuParams> params, |
| 355 | std::shared_ptr<OHOS::NWeb::NWebQuickMenuCallback> callback) | 365 | std::shared_ptr<OHOS::NWeb::NWebQuickMenuCallback> callback) |
| @@ -382,7 +392,8 @@ void WebSelectOverlay::SetMenuOptions(SelectOverlayInfo& selectInfo, | |||
| 382 | } else { | 392 | } else { |
| 383 | selectInfo.menuInfo.showCopyAll = true; | 393 | selectInfo.menuInfo.showCopyAll = true; |
| 384 | } | 394 | } |
| 385 | - bool detectFlag = !isSelectAll_; | 395 | + selectInfo.menuInfo.showAutoFill = IsShowMenuOfAutoFill(flags, selectInfo); |
| 396 | + | ||
| 386 | auto value = GetSelectedText(); | 397 | auto value = GetSelectedText(); |
| 387 | auto queryWord = std::regex_replace(value, std::regex("^\\s+|\\s+$"), ""); | 398 | auto queryWord = std::regex_replace(value, std::regex("^\\s+|\\s+$"), ""); |
| 388 | selectInfo.menuInfo.showSearch = false; | 399 | selectInfo.menuInfo.showSearch = false; |
| @@ -401,7 +412,7 @@ void WebSelectOverlay::SetMenuOptions(SelectOverlayInfo& selectInfo, | |||
| 401 | selectInfo.menuInfo.showShare = canCopyOut && !queryWord.empty(); | 412 | selectInfo.menuInfo.showShare = canCopyOut && !queryWord.empty(); |
| 402 | canShowAIMenu_ = canCopyOut && !(flags & OHOS::NWeb::NWebQuickMenuParams::QM_EF_CAN_CUT) && !queryWord.empty(); | 413 | canShowAIMenu_ = canCopyOut && !(flags & OHOS::NWeb::NWebQuickMenuParams::QM_EF_CAN_CUT) && !queryWord.empty(); |
| 403 | selectInfo.menuInfo.isAskCeliaEnabled = canShowAIMenu_; | 414 | selectInfo.menuInfo.isAskCeliaEnabled = canShowAIMenu_; |
| 404 | - DetectSelectedText(detectFlag ? value : std::string()); | 415 | + DetectSelectedText((!isSelectAll_) ? value : std::string()); |
| 405 | } | 416 | } |
| 406 | 417 | ||
| 407 | void WebSelectOverlay::HideHandleAndQuickMenuIfNecessary(bool hide, bool isScroll) | 418 | void WebSelectOverlay::HideHandleAndQuickMenuIfNecessary(bool hide, bool isScroll) |
| @@ -960,6 +971,13 @@ void WebSelectOverlay::OnMenuItemAction(OptionMenuActionId id, OptionMenuType ty | |||
| 960 | case OptionMenuActionId::ASK_CELIA: | 971 | case OptionMenuActionId::ASK_CELIA: |
| 961 | HandleOnAskCelia(); | 972 | HandleOnAskCelia(); |
| 962 | break; | 973 | break; |
| 974 | + case OptionMenuActionId::PASSWORD_VAULT: | ||
| 975 | + pattern->RequestPasswordAutoFill(WebMenuType::TYPE_QUICKMENU); | ||
| 976 | + pattern->CloseSelectOverlay(); | ||
| 977 | + break; | ||
| 978 | + case OptionMenuActionId::AUTO_FILL: | ||
HandleOnAutoFill(type); 需要加上这个处理一级菜单点击出现二级菜单 ![]() ![]() | |||
| 979 | + HandleOnAutoFill(type); | ||
| 980 | + break; | ||
| 963 | default: | 981 | default: |
| 964 | break; | 982 | break; |
| 965 | } | 983 | } |
| @@ -211,6 +211,7 @@ private: | |||
| 211 | bool IsMouseInHandleRect( | 211 | bool IsMouseInHandleRect( |
| 212 | const MouseInfo& mouseInfo, std::shared_ptr<OHOS::NWeb::NWebTouchHandleState>& selectionHandle, float& offsetY); | 212 | const MouseInfo& mouseInfo, std::shared_ptr<OHOS::NWeb::NWebTouchHandleState>& selectionHandle, float& offsetY); |
| 213 | void OnOverlayMouseEvent(const MouseInfo& info); | 213 | void OnOverlayMouseEvent(const MouseInfo& info); |
| 214 | + bool IsShowMenuOfAutoFill(uint32_t flags, SelectOverlayInfo& selectInfo); | ||
| 214 | bool isShowHandle_ = false; | 215 | bool isShowHandle_ = false; |
| 215 | bool needResetHandleReverse_ = false; | 216 | bool needResetHandleReverse_ = false; |
| 216 | bool isSelectAll_ = false; | 217 | bool isSelectAll_ = false; |
| @@ -29608,6 +29608,7 @@ typedef struct GENERATED_ArkUIWebContextMenuResultAccessor { | |||
| 29608 | void (*redo)(Ark_WebContextMenuResult peer); | 29608 | void (*redo)(Ark_WebContextMenuResult peer); |
| 29609 | void (*undo)(Ark_WebContextMenuResult peer); | 29609 | void (*undo)(Ark_WebContextMenuResult peer); |
| 29610 | void (*pasteAndMatchStyle)(Ark_WebContextMenuResult peer); | 29610 | void (*pasteAndMatchStyle)(Ark_WebContextMenuResult peer); |
| 29611 | + void (*requestPasswordAutoFill)(Ark_WebContextMenuResult peer); | ||
| 29611 | } GENERATED_ArkUIWebContextMenuResultAccessor; | 29612 | } GENERATED_ArkUIWebContextMenuResultAccessor; |
| 29612 | 29613 | ||
| 29613 | typedef struct GENERATED_ArkUIWebKeyboardControllerAccessor { | 29614 | typedef struct GENERATED_ArkUIWebKeyboardControllerAccessor { |
| @@ -390,6 +390,7 @@ void ContextMenuResultOhos::CopyImage() const {} | |||
| 390 | void ContextMenuResultOhos::Copy() const {} | 390 | void ContextMenuResultOhos::Copy() const {} |
| 391 | void ContextMenuResultOhos::Paste() const {} | 391 | void ContextMenuResultOhos::Paste() const {} |
| 392 | void ContextMenuResultOhos::Cut() const {} | 392 | void ContextMenuResultOhos::Cut() const {} |
| 393 | +void ContextMenuResultOhos::RequestPasswordAutoFill() const {} | ||
| 393 | void ContextMenuResultOhos::SelectAll() const {} | 394 | void ContextMenuResultOhos::SelectAll() const {} |
| 394 | void WebWindowNewHandlerOhos::SetWebController(int32_t id) {} | 395 | void WebWindowNewHandlerOhos::SetWebController(int32_t id) {} |
| 395 | bool WebWindowNewHandlerOhos::IsFrist() const | 396 | bool WebWindowNewHandlerOhos::IsFrist() const |
| @@ -1477,6 +1478,7 @@ void WebDelegate::OnDetectedBlankScreen( | |||
| 1477 | const std::string& url, int32_t blankScreenReason, int32_t detectedContentfulNodesCount) {} | 1478 | const std::string& url, int32_t blankScreenReason, int32_t detectedContentfulNodesCount) {} |
| 1478 | void WebDelegate::UpdateBlankScreenDetectionConfig(bool enable, const std::vector<double>& detectionTiming, | 1479 | void WebDelegate::UpdateBlankScreenDetectionConfig(bool enable, const std::vector<double>& detectionTiming, |
| 1479 | const std::vector<int32_t>& detectionMethods, int32_t contentfulNodesCountThreshold) {} | 1480 | const std::vector<int32_t>& detectionMethods, int32_t contentfulNodesCountThreshold) {} |
| 1481 | +void WebDelegate::OnRequestAutofill(int32_t menuType) {} | ||
| 1480 | void WebDelegate::OnSwitchFreeMultiWindow(bool enable) {} | 1482 | void WebDelegate::OnSwitchFreeMultiWindow(bool enable) {} |
| 1481 | void WebDelegate::RegisterFreeMultiWindowListener() {} | 1483 | void WebDelegate::RegisterFreeMultiWindowListener() {} |
| 1482 | void WebDelegate::UnregisterFreeMultiWindowListener() {} | 1484 | void WebDelegate::UnregisterFreeMultiWindowListener() {} |
| @@ -103,6 +103,7 @@ public: | |||
| 103 | MOCK_METHOD(void, Undo, (), (const, override)); | 103 | MOCK_METHOD(void, Undo, (), (const, override)); |
| 104 | MOCK_METHOD(void, Redo, (), (const, override)); | 104 | MOCK_METHOD(void, Redo, (), (const, override)); |
| 105 | MOCK_METHOD(void, PasteAndMatchStyle, (), (const, override)); | 105 | MOCK_METHOD(void, PasteAndMatchStyle, (), (const, override)); |
| 106 | + MOCK_METHOD(void, RequestPasswordAutoFill, (), (const, override)); | ||
| 106 | }; | 107 | }; |
| 107 | 108 | ||
| 108 | class WebContextSelectOverlayTest : public testing::Test { | 109 | class WebContextSelectOverlayTest : public testing::Test { |
| @@ -79,6 +79,7 @@ public: | |||
| 79 | MOCK_METHOD(void, Undo, (), (const, override)); | 79 | MOCK_METHOD(void, Undo, (), (const, override)); |
| 80 | MOCK_METHOD(void, Redo, (), (const, override)); | 80 | MOCK_METHOD(void, Redo, (), (const, override)); |
| 81 | MOCK_METHOD(void, PasteAndMatchStyle, (), (const, override)); | 81 | MOCK_METHOD(void, PasteAndMatchStyle, (), (const, override)); |
| 82 | + MOCK_METHOD(void, RequestPasswordAutoFill, (), (const, override)); | ||
| 82 | }; | 83 | }; |
| 83 | } // namespace | 84 | } // namespace |
| 84 | 85 | ||
| @@ -380,6 +380,34 @@ public: | |||
| 380 | MOCK_METHOD(const NG::RectF&, GetPageNodeRect, (), (const, override)); | 380 | MOCK_METHOD(const NG::RectF&, GetPageNodeRect, (), (const, override)); |
| 381 | }; | 381 | }; |
| 382 | 382 | ||
| 383 | +/** | ||
| 384 | + * @tc.name: ShiftFocusAfterAutoFill001 | ||
| 385 | + * @tc.desc: ShiftFocusAfterAutoFill. | ||
| 386 | + * @tc.type: FUNC | ||
| 387 | + */ | ||
| 388 | +HWTEST_F(WebPatternPartTwoTest, ShiftFocusAfterAutoFill001, TestSize.Level1) | ||
| 389 | +{ | ||
| 390 | + | ||
| 391 | + auto* stack = ViewStackProcessor::GetInstance(); | ||
| 392 | + ASSERT_NE(stack, nullptr); | ||
| 393 | + auto nodeId = stack->ClaimNodeId(); | ||
| 394 | + auto frameNode = | ||
| 395 | + FrameNode::GetOrCreateFrameNode(V2::WEB_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr<WebPattern>(); }); | ||
| 396 | + ASSERT_NE(frameNode, nullptr); | ||
| 397 | + stack->Push(frameNode); | ||
| 398 | + auto webPattern = frameNode->GetPattern<WebPattern>(); | ||
| 399 | + ASSERT_NE(webPattern, nullptr); | ||
| 400 | + webPattern->OnModifyDone(); | ||
| 401 | + auto viewDataWrap = RefPtr<ViewDataWrapMock>(); | ||
| 402 | + viewDataWrap = nullptr; | ||
| 403 | + RefPtr<PageNodeInfoWrapMock> nodeWrap = AceType::MakeRefPtr<PageNodeInfoWrapMock>(); | ||
| 404 | + AceAutoFillType autoFillType = AceAutoFillType::ACE_DETAIL_INFO_WITHOUT_STREET; | ||
| 405 | + webPattern->NotifyFillRequestSuccess(viewDataWrap, nodeWrap, autoFillType); | ||
| 406 | + webPattern->isPasswordFill_ = false; | ||
| 407 | + webPattern->ShiftFocusAfterAutoFill(autoFillType); | ||
| 408 | + | ||
| 409 | +} | ||
| 410 | + | ||
| 383 | /** | 411 | /** |
| 384 | * @tc.name: NotifyFillRequestSuccess001 | 412 | * @tc.name: NotifyFillRequestSuccess001 |
| 385 | * @tc.desc: NotifyFillRequestSuccess. | 413 | * @tc.desc: NotifyFillRequestSuccess. |
| @@ -916,6 +944,33 @@ HWTEST_F(WebPatternPartTwoTest, RequestAutoFill001, TestSize.Level1) | |||
| 916 | 944 | ||
| 917 | } | 945 | } |
| 918 | 946 | ||
| 947 | +/** | ||
| 948 | + * @tc.name: RequestPasswordAutoFill001 | ||
| 949 | + * @tc.desc: RequestPasswordAutoFill. | ||
| 950 | + * @tc.type: FUNC | ||
| 951 | + */ | ||
| 952 | +HWTEST_F(WebPatternPartTwoTest, RequestPasswordAutoFill001, TestSize.Level1) | ||
| 953 | +{ | ||
| 954 | + | ||
| 955 | + auto* stack = ViewStackProcessor::GetInstance(); | ||
| 956 | + EXPECT_NE(stack, nullptr); | ||
| 957 | + auto nodeId = stack->ClaimNodeId(); | ||
| 958 | + auto frameNode = | ||
| 959 | + FrameNode::GetOrCreateFrameNode(V2::WEB_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr<WebPattern>(); }); | ||
| 960 | + EXPECT_NE(frameNode, nullptr); | ||
| 961 | + stack->Push(frameNode); | ||
| 962 | + auto webPattern = frameNode->GetPattern<WebPattern>(); | ||
| 963 | + EXPECT_NE(webPattern, nullptr); | ||
| 964 | + WebMenuType menuType = WebMenuType::TYPE_CONTEXTMENU; | ||
| 965 | + webPattern->isEditableOnContextMenu_ = false; | ||
| 966 | + webPattern->RequestPasswordAutoFill(menuType); | ||
| 967 | + EXPECT_EQ(webPattern->isEditableOnContextMenu_, false); | ||
| 968 | + menuType = WebMenuType::TYPE_QUICKMENU; | ||
| 969 | + webPattern->RequestPasswordAutoFill(menuType); | ||
| 970 | + EXPECT_EQ(webPattern->isEditableOnContextMenu_, false); | ||
| 971 | + | ||
| 972 | +} | ||
| 973 | + | ||
| 919 | /** | 974 | /** |
| 920 | * @tc.name: RequestAutoSave001 | 975 | * @tc.name: RequestAutoSave001 |
| 921 | * @tc.desc: RequestAutoSave. | 976 | * @tc.desc: RequestAutoSave. |
| @@ -73,6 +73,7 @@ public: | |||
| 73 | MOCK_METHOD(void, Undo, (), (const, override)); | 73 | MOCK_METHOD(void, Undo, (), (const, override)); |
| 74 | MOCK_METHOD(void, Redo, (), (const, override)); | 74 | MOCK_METHOD(void, Redo, (), (const, override)); |
| 75 | MOCK_METHOD(void, PasteAndMatchStyle, (), (const, override)); | 75 | MOCK_METHOD(void, PasteAndMatchStyle, (), (const, override)); |
| 76 | + MOCK_METHOD(void, RequestPasswordAutoFill, (), (const, override)); | ||
| 76 | }; | 77 | }; |
| 77 | class WebPatternTestNgSupplement : public testing::Test { | 78 | class WebPatternTestNgSupplement : public testing::Test { |
| 78 | public: | 79 | public: |
| @@ -3155,6 +3155,43 @@ HWTEST_F(WebSelectOverlayTest, ComputeTouchHandleRectTest, TestSize.Level1) | |||
| 3155 | 3155 | ||
| 3156 | } | 3156 | } |
| 3157 | 3157 | ||
| 3158 | +/** | ||
| 3159 | + * @tc.name: IsShowMenuOfAutoFill_001 | ||
| 3160 | + * @tc.desc: IsShowMenuOfAutoFill. | ||
| 3161 | + * @tc.type: FUNC | ||
| 3162 | + */ | ||
| 3163 | +HWTEST_F(WebSelectOverlayTest, IsShowMenuOfAutoFill_001, TestSize.Level1) | ||
TDD 运行成功截图附一下 ![]() ![]() duanshaofei 2025年12月9日 评论: 2025年12月9日 评论: | |||
| 3164 | +{ | ||
| 3165 | + | ||
| 3166 | + auto* stack = ViewStackProcessor::GetInstance(); | ||
| 3167 | + ASSERT_NE(stack, nullptr); | ||
| 3168 | + auto nodeId = stack->ClaimNodeId(); | ||
| 3169 | + auto frameNode = | ||
| 3170 | + FrameNode::GetOrCreateFrameNode(V2::WEB_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr<WebPattern>(); }); | ||
| 3171 | + ASSERT_NE(frameNode, nullptr); | ||
| 3172 | + stack->Push(frameNode); | ||
| 3173 | + auto webPattern = frameNode->GetPattern<WebPattern>(); | ||
| 3174 | + ASSERT_NE(webPattern, nullptr); | ||
| 3175 | + webPattern->OnModifyDone(); | ||
| 3176 | + ASSERT_NE(webPattern->delegate_, nullptr); | ||
| 3177 | + OHOS::Ace::SetReturnStatus(""); | ||
| 3178 | + WebSelectOverlay overlay(webPattern); | ||
| 3179 | + std::shared_ptr<OHOS::NWeb::NWebQuickMenuParams> params = | ||
| 3180 | + std::make_shared<OHOS::NWeb::NWebQuickMenuParamsSelectImpl>(); | ||
| 3181 | + std::shared_ptr<OHOS::NWeb::NWebQuickMenuCallback> callback = | ||
| 3182 | + std::make_shared<OHOS::NWeb::NWebQuickMenuCallbackMock>(); | ||
| 3183 | + SelectOverlayInfo selectInfo; | ||
| 3184 | + overlay.SetMenuOptions(selectInfo, params, callback); | ||
| 3185 | + uint32_t flags = 0; | ||
| 3186 | + bool isShow = overlay.IsShowMenuOfAutoFill(flags, selectInfo); | ||
| 3187 | + EXPECT_EQ(isShow, false); | ||
| 3188 | + flags = 87; | ||
| 3189 | + selectInfo.isSingleHandle = true; | ||
| 3190 | + isShow = overlay.IsShowMenuOfAutoFill(flags, selectInfo); | ||
| 3191 | + EXPECT_EQ(isShow, true); | ||
| 3192 | + | ||
| 3193 | +} | ||
| 3194 | + | ||
| 3158 | /** | 3195 | /** |
| 3159 | * @tc.name: SetMenuOptions_001 | 3196 | * @tc.name: SetMenuOptions_001 |
| 3160 | * @tc.desc: SetMenuOptions. | 3197 | * @tc.desc: SetMenuOptions. |
| @@ -3488,6 +3525,10 @@ HWTEST_F(WebSelectOverlayTest, OnMenuItemAction_002, TestSize.Level1) | |||
| 3488 | SelectOverlayInfo selectInfo; | 3525 | SelectOverlayInfo selectInfo; |
| 3489 | overlay.SetMenuOptions(selectInfo, params, callback); | 3526 | overlay.SetMenuOptions(selectInfo, params, callback); |
| 3490 | overlay.OnMenuItemAction(OptionMenuActionId::CUT, OptionMenuType::TOUCH_MENU); | 3527 | overlay.OnMenuItemAction(OptionMenuActionId::CUT, OptionMenuType::TOUCH_MENU); |
| 3528 | + overlay.OnMenuItemAction(OptionMenuActionId::AUTO_FILL, OptionMenuType::TOUCH_MENU); | ||
| 3529 | + EXPECT_EQ(selectInfo.menuInfo.showAutoFill, false); | ||
| 3530 | + overlay.OnMenuItemAction(OptionMenuActionId::PASSWORD_VAULT, OptionMenuType::TOUCH_MENU); | ||
| 3531 | + EXPECT_EQ(selectInfo.menuInfo.showAutoFill, false); | ||
| 3491 | 3532 | ||
| 3492 | } | 3533 | } |
| 3493 | 3534 | ||


代码风格确认一下