diff --git a/frameworks/base/memory/memory_monitor.cpp b/frameworks/base/memory/memory_monitor.cpp index b8415e59b647a29ab4e549c5cb8e02870ce14fea..909c642ccb7902680db9f6fd56681dcefddc818c 100644 --- a/frameworks/base/memory/memory_monitor.cpp +++ b/frameworks/base/memory/memory_monitor.cpp @@ -14,7 +14,6 @@ */ #include "base/memory/memory_monitor.h" - #include #include @@ -74,6 +73,7 @@ public: void Update(void* ptr, size_t size, const std::string& typeName) final { + LOGI("FL test :-> memory_monitor :: MemoryMonitorImpl :: Update"); std::lock_guard lock(mutex_); auto it = memoryMap_.find(ptr); if (it == memoryMap_.end()) { diff --git a/frameworks/base/memory/referenced.h b/frameworks/base/memory/referenced.h index 7ad2d7d9d7b7ac8897258fbae888359cd1b4c829..283ea6131743deec87af653f1beb52bbb2d954cb 100644 --- a/frameworks/base/memory/referenced.h +++ b/frameworks/base/memory/referenced.h @@ -21,6 +21,7 @@ #include "base/memory/memory_monitor.h" #include "base/memory/ref_counter.h" #include "base/utils/macros.h" +#include "base/log/log_wrapper.h" #define ACE_REMOVE(...) @@ -39,8 +40,10 @@ public: static RefPtr Claim(T* rawPtr) { if (MemoryMonitor::IsEnable()) { + LOGD("FL test :-> reference.h:: Claim:: IsEnable "); MemoryMonitor::GetInstance().Update(rawPtr, static_cast(rawPtr)); } + LOGD("FL test :-> reference.h:: Claim:: Not IsEnable -> return RefPtr(rawPtr)"); return RefPtr(rawPtr); } template @@ -54,6 +57,7 @@ public: template static RefPtr MakeRefPtr(Args&&... args) { + LOGD("FL test :-> reference.h:: MakeRefPtr: args "); return Claim(new T(std::forward(args)...)); } @@ -127,7 +131,7 @@ public: RefPtr() = default; ACE_REMOVE(explicit) RefPtr(std::nullptr_t) {} // Basic copy and move constructors. - ACE_REMOVE(explicit) RefPtr(const RefPtr& other) : RefPtr(other.rawPtr_) {} + ACE_REMOVE(explicit) RefPtr(const RefPtr& other) : RefPtr(other.rawPtr_) {} ACE_REMOVE(explicit) RefPtr(RefPtr&& other) : rawPtr_(other.rawPtr_) { other.rawPtr_ = nullptr; diff --git a/frameworks/bridge/declarative_frontend/jsview/js_interactable_view.cpp b/frameworks/bridge/declarative_frontend/jsview/js_interactable_view.cpp index 0a5fc2a3035df428553f57d4acd4bf7dd140f2c9..e9494f8251a80ba52b80f33a81ffb7b0a2e4a31b 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_interactable_view.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_interactable_view.cpp @@ -155,21 +155,36 @@ void JSInteractableView::SetFocusNode(bool isFocusNode) void JSInteractableView::JsOnAppear(const JSCallbackInfo& info) { - if (info[0]->IsFunction()) { + if (info[0]->IsUndefined()) { + LOGW("FL----js_interactable_view: JsOnAppear: the info is undefined => DisableOnAppear"); + ViewAbstractModel::GetInstance()->DisableOnAppear(); + return; + } + + if (info[0]->IsFunction()) { + LOGI("FL test :-> js_interactable_view:: JSInteractableView::JsOnAppear: info[0] is Function "); RefPtr jsOnAppearFunc = AceType::MakeRefPtr(JSRef(), JSRef::Cast(info[0])); + LOGI("FL test :-> js_interactable_view:: JSInteractableView::JsOnAppear:jsOnAppearFunc-TypeName = %{public}s ", jsOnAppearFunc->TypeName() ); auto onAppear = [execCtx = info.GetExecutionContext(), func = std::move(jsOnAppearFunc)]() { JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx); LOGI("About to call JsOnAppear method on js"); ACE_SCORING_EVENT("onAppear"); func->Execute(); }; + ViewAbstractModel::GetInstance()->SetOnAppear(std::move(onAppear)); } } void JSInteractableView::JsOnDisAppear(const JSCallbackInfo& info) { + if (info[0]->IsUndefined()) { + LOGW("FL----js_interactable_view: JsOnDisAppear: the info is undefined => DisableOnDisAppear"); + ViewAbstractModel::GetInstance()->DisableOnDisAppear(); + return; + } + if (info[0]->IsFunction()) { RefPtr jsOnDisAppearFunc = AceType::MakeRefPtr(JSRef(), JSRef::Cast(info[0])); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp index b0af2b1320c70fb5ebae5ed5fa119d137bbab436..a43b7b8736d6bfbcd8ddfb09be6cafd6587ac9a8 100755 --- a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp @@ -2246,9 +2246,11 @@ void ParseMenuParam(const JSCallbackInfo& info, const JSRef& menuOptio } auto onAppearValue = menuOptions->GetProperty("onAppear"); + LOGI("FL---- test :-> js_view_abstract: ParseMenuParam: onAppearValue "); if (onAppearValue->IsFunction()) { RefPtr jsOnAppearFunc = AceType::MakeRefPtr(JSRef(), JSRef::Cast(onAppearValue)); + auto onAppear = [execCtx = info.GetExecutionContext(), func = std::move(jsOnAppearFunc)]() { JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx); LOGI("About to call onAppear method on js"); @@ -4036,6 +4038,7 @@ void JSViewAbstract::JsOnAreaChange(const JSCallbackInfo& info) if (!CheckJSCallbackInfo("JsOnAreaChange", info, checkList)) { return; } + auto jsOnAreaChangeFunction = AceType::MakeRefPtr(JSRef::Cast(info[0])); auto onAreaChanged = [execCtx = info.GetExecutionContext(), func = std::move(jsOnAreaChangeFunction)]( @@ -4604,6 +4607,12 @@ void JSViewAbstract::JsOnKeyEvent(const JSCallbackInfo& args) void JSViewAbstract::JsOnFocus(const JSCallbackInfo& args) { + if (args[0]->IsUndefined()) { + LOGW("FL---- js_view_abstract: JsOnFocus: the info is undefined"); + ViewAbstractModel::GetInstance()->DisableOnFocus(); + return; + } + if (!args[0]->IsFunction()) { LOGE("OnFocus args need a function."); return; @@ -4620,6 +4629,12 @@ void JSViewAbstract::JsOnFocus(const JSCallbackInfo& args) void JSViewAbstract::JsOnBlur(const JSCallbackInfo& args) { + if (args[0]->IsUndefined()) { + LOGW("FL----js_view_abstract: JsOnBlur:the info is undefined"); + ViewAbstractModel::GetInstance()->DisableOnBlur(); + return; + } + if (!args[0]->IsFunction()) { LOGE("OnBlur args need a function."); return; @@ -5171,6 +5186,8 @@ void JSViewAbstract::JSBind(BindingTarget globalObj) JSClass::StaticMethod("id", &JSViewAbstract::JsId); JSClass::StaticMethod("restoreId", &JSViewAbstract::JsRestoreId); JSClass::StaticMethod("hoverEffect", &JSViewAbstract::JsHoverEffect); + + JSClass::StaticMethod("onMouse", &JSViewAbstract::JsOnMouse); JSClass::StaticMethod("onHover", &JSViewAbstract::JsOnHover); JSClass::StaticMethod("onClick", &JSViewAbstract::JsOnClick); @@ -5694,6 +5711,8 @@ void JSViewAbstract::JsOnHover(const JSCallbackInfo& info) void JSViewAbstract::JsOnClick(const JSCallbackInfo& info) { + LOGD("FL测试:: JSViewAbstract:JsOnClick ***FL"); + if (!info[0]->IsFunction()) { LOGW("the info is not click function"); return; @@ -5789,6 +5808,12 @@ void JSViewAbstract::JsOnVisibleAreaChange(const JSCallbackInfo& info) ratioVec.push_back(ratio); } + if (info[1]->IsUndefined()) { + LOGW("Fl: JsOnVisibleAreaChange: the info1 is undefined"); + ViewAbstractModel::GetInstance()->DisableOnVisibleAreaChange(ratioVec); + return; + } + RefPtr jsFunc = AceType::MakeRefPtr(JSRef(), JSRef::Cast(info[1])); auto onVisibleChange = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc)]( bool visible, double ratio) { @@ -5840,6 +5865,14 @@ void JSViewAbstract::JsKeyboardShortcut(const JSCallbackInfo& info) LOGE("JsKeyboardShortcut: The arg is wrong, it is supposed to have 2 or 3 arguments"); return; } + + // when param 3 is undefinde then Disable KeyboardShortcut + if (info.Length() -> 3 && args[2]->IsUndefined()) { + LOGW("FL: JsKeyboardShortcut: the info is undefined"); + ViewAbstractModel::GetInstance()->DisableKeyboardShortcut(); + return; + } + if ((!info[0]->IsString() && !info[0]->IsNumber()) || !info[1]->IsArray()) { LOGE("JsKeyboardShortcut: The param type is invalid."); ViewAbstractModel::GetInstance()->SetKeyboardShortcut("", std::vector(), nullptr); diff --git a/frameworks/bridge/declarative_frontend/jsview/models/view_abstract_model_impl.h b/frameworks/bridge/declarative_frontend/jsview/models/view_abstract_model_impl.h index c54a81d18d118bce14b9c64a3f4a51332ab7ccca..a3f3ca89286215212807a2a90cd766795bef960a 100644 --- a/frameworks/bridge/declarative_frontend/jsview/models/view_abstract_model_impl.h +++ b/frameworks/bridge/declarative_frontend/jsview/models/view_abstract_model_impl.h @@ -171,6 +171,18 @@ public: std::function&& onKeyboardShortcutAction) override {}; void SetObscured(const std::vector& reasons) override {}; + // Disable event. + void DisableOnClick() override {}; + void DisableOnTouch() override {}; + void DisableOnKeyEvent() override {}; + void DisableOnHover() override {}; + void DisableOnMouse() override {}; + void DisableOnAppear() override {}; + void DisableOnDisAppear() override {}; + void DisableOnAreaChange() override {}; + void DisableOnFocus() override {}; + void DisableOnBlur() override {}; + void BindPopup(const RefPtr& param, const RefPtr& customNode) override; void BindMenu(std::vector&& params, std::function&& buildFunc, const NG::MenuParam& menuParam) override; diff --git a/frameworks/core/components_ng/base/frame_node.h b/frameworks/core/components_ng/base/frame_node.h index d6fd64cd2a2e4053e5a938e24c367c05887e53e6..d7c30b4078092821414ae6b9910604520d22c17b 100644 --- a/frameworks/core/components_ng/base/frame_node.h +++ b/frameworks/core/components_ng/base/frame_node.h @@ -120,10 +120,23 @@ public: { visibleAreaUserCallbacks_[ratio] = callback; } + + + void ClearVisibleAreaUserCallback(double ratio) + { + LOGI("FL: frame_node:: ClearVisibleAreaUserCallback: visibleAreaInnerCallbacks_[ratio].callback = nullptr "); + if (visibleAreaInnerCallbacks_[ratio].callback) { + visibleAreaInnerCallbacks_[ratio].callback = nullptr; + } + + } + void AddVisibleAreaInnerCallback(double ratio, const VisibleCallbackInfo& callback) { visibleAreaInnerCallbacks_[ratio] = callback; } + + void TriggerVisibleAreaChangeCallback(bool forceDisappear = false); const RefPtr& GetGeometryNode() const diff --git a/frameworks/core/components_ng/base/view_abstract.cpp b/frameworks/core/components_ng/base/view_abstract.cpp index 8068a444f0161ef6602011e62047112d627a9458..8f9014b10d2481196cb4e19e8ed77318350c0ef4 100644 --- a/frameworks/core/components_ng/base/view_abstract.cpp +++ b/frameworks/core/components_ng/base/view_abstract.cpp @@ -36,6 +36,7 @@ #include "core/image/image_source_info.h" #include "core/pipeline_ng/pipeline_context.h" #include "core/pipeline_ng/ui_task_scheduler.h" +#include "core/components_ng/event/gesture_event_hub.h" namespace OHOS::Ace::NG { @@ -574,6 +575,13 @@ void ViewAbstract::SetOnFocus(OnFocusFunc&& onFocusCallback) focusHub->SetOnFocusCallback(std::move(onFocusCallback)); } +void ViewAbstract::DisableOnFocus() +{ + auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub(); + CHECK_NULL_VOID(focusHub); + focusHub->ClearUserOnFocus(); +} + void ViewAbstract::SetOnBlur(OnBlurFunc&& onBlurCallback) { auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub(); @@ -581,6 +589,13 @@ void ViewAbstract::SetOnBlur(OnBlurFunc&& onBlurCallback) focusHub->SetOnBlurCallback(std::move(onBlurCallback)); } +void ViewAbstract::DisableOnBlur() +{ + auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub(); + CHECK_NULL_VOID(focusHub); + focusHub->ClearUserOnBlur(); +} + void ViewAbstract::SetOnKeyEvent(OnKeyCallbackFunc&& onKeyCallback) { auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub(); @@ -623,6 +638,14 @@ void ViewAbstract::SetOnAppear(std::function&& onAppear) eventHub->SetOnAppear(std::move(onAppear)); } +void ViewAbstract::DisableOnAppear() +{ + auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub(); + CHECK_NULL_VOID(eventHub); + LOGI("FL----view_abstract.cpp: DisableOnAppear -> eventHub"); + eventHub->ClearUserOnAppear(); +} + void ViewAbstract::SetOnDisappear(std::function&& onDisappear) { auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub(); @@ -630,6 +653,14 @@ void ViewAbstract::SetOnDisappear(std::function&& onDisappear) eventHub->SetOnDisappear(std::move(onDisappear)); } + +void ViewAbstract::DisableOnDisAppear() +{ + auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub(); + CHECK_NULL_VOID(eventHub); + eventHub->ClearUserOnDisAppear(); +} + void ViewAbstract::SetOnAreaChanged( std::function&& onAreaChanged) @@ -655,6 +686,18 @@ void ViewAbstract::SetOnVisibleChange( } } +void ViewAbstract::DisableOnVisibleChange(const std::vector& ratioList) +{ + auto pipeline = PipelineContext::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + CHECK_NULL_VOID(frameNode); + // pipeline->ClearUserOnVisibleChange(frameNode); + for (const auto& ratio : ratioList) { + pipeline->ClearUserOnVisibleChange(frameNode, ratio); + } +} + void ViewAbstract::SetResponseRegion(const std::vector& responseRegion) { auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub(); @@ -1471,6 +1514,13 @@ void ViewAbstract::SetKeyboardShortcut( eventManager->AddKeyboardShortcutNode(WeakPtr(frameNode)); } +void ViewAbstract::DisableKeyboardShortcut() +{ + auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub(); + CHECK_NULL_VOID(eventHub); + eventHub->ClearUserKeyboardShortcut(); +} + void ViewAbstract::CreateAnimatablePropertyFloat(const std::string& propertyName, float value, const std::function& onCallbackEvent) { diff --git a/frameworks/core/components_ng/base/view_abstract.h b/frameworks/core/components_ng/base/view_abstract.h index 0d14a4930f212ac58c3ec1c111e3cf27afaee515..2dd05737bf45e6351d28681d4b4eecc2ed4a2d6c 100644 --- a/frameworks/core/components_ng/base/view_abstract.h +++ b/frameworks/core/components_ng/base/view_abstract.h @@ -252,6 +252,14 @@ public: static void Pop(); + // Disable event + static void DisableOnAppear(); + static void DisableOnDisAppear(); + static void DisableOnFocus(); + static void DisableOnBlur(); + static void DisableOnVisibleChange(const std::vector& ratioList); + static void DisableKeyboardShortcut(); + // foregroundColor static void SetForegroundColor(const Color& color); static void SetForegroundColorStrategy(const ForegroundColorStrategy& strategy); diff --git a/frameworks/core/components_ng/base/view_abstract_model.h b/frameworks/core/components_ng/base/view_abstract_model.h index 9881ef0be19471fc22077dfecbef654735516ffe..166b4afc55cf583ff646961011515217ac2027be 100644 --- a/frameworks/core/components_ng/base/view_abstract_model.h +++ b/frameworks/core/components_ng/base/view_abstract_model.h @@ -201,6 +201,20 @@ public: std::function&& onAreaChanged) = 0; + // Disable event when the param is undefined. + virtual void DisableOnClick() = 0; + virtual void DisableOnTouch() = 0; + virtual void DisableOnKeyEvent() = 0; + virtual void DisableOnHover() = 0; + virtual void DisableOnMouse() = 0; + virtual void DisableOnAppear() = 0; + virtual void DisableOnDisAppear() = 0; + virtual void DisableOnAreaChange() = 0; + virtual void DisableOnFocus() = 0; + virtual void DisableOnBlur() = 0; + virtual void DisableOnVisibleAreaChange(const std::vector ratioVec); + virtual void DisableKeyboardShortcut(); + // interact virtual void SetResponseRegion(const std::vector& responseRegion) = 0; virtual void SetEnabled(bool enabled) = 0; diff --git a/frameworks/core/components_ng/base/view_abstract_model_ng.cpp b/frameworks/core/components_ng/base/view_abstract_model_ng.cpp index 891f384db39cdc9a443c653160fc0197795fc985..1f8b5f8cb2902fab634265b4bac53dacc5fa0581 100644 --- a/frameworks/core/components_ng/base/view_abstract_model_ng.cpp +++ b/frameworks/core/components_ng/base/view_abstract_model_ng.cpp @@ -1,4 +1,4 @@ -/* +/*0 * Copyright (c) 2022-2023 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. diff --git a/frameworks/core/components_ng/base/view_abstract_model_ng.h b/frameworks/core/components_ng/base/view_abstract_model_ng.h index 5254abaeb6661895be65d1a756c4181519203bf0..cc6135675e1c8af60f955a630dde8ef7a41e1a9d 100644 --- a/frameworks/core/components_ng/base/view_abstract_model_ng.h +++ b/frameworks/core/components_ng/base/view_abstract_model_ng.h @@ -833,6 +833,45 @@ public: ViewAbstract::SetForegroundColorStrategy(strategy); } + // Disable event when the param is undefined. + void DisableOnClick() override{} + + void DisableOnTouch() override{} + + void DisableOnAppear() override + { + ViewAbstract::DisableOnAppear(); + } + + void DisableOnDisAppear() override + { + ViewAbstract::DisableOnDisAppear(); + }; + + void DisableOnFocus() override + { + ViewAbstract::DisableOnFocus(); + } + + void DisableOnBlur() override + { + ViewAbstract::DisableOnBlur(); + }; + + void DisableOnKeyEvent() override {}; + void DisableOnHover() override {}; + void DisableOnMouse() override {}; + void DisableOnAreaChange() override {}; + + void DisableOnVisibleAreaChange(const std::vector ratioVec) override + { + ViewAbstract::DisableOnVisibleAreaChange(ratioVec); + } + void DisableKeyboardShortcut() override + { + ViewAbstract::DisableKeyboardShortcut(); + } + private: void RegisterMenuAppearCallback( std::vector& params, std::function&& buildFunc, const MenuParam& menuParam); diff --git a/frameworks/core/components_ng/event/event_hub.h b/frameworks/core/components_ng/event/event_hub.h index 240d8206f10cd2ff8fd79c8f1effd7232f44eb8a..99f2a14b5cf168ca274eb22d9dc4e4cd35386bc6 100644 --- a/frameworks/core/components_ng/event/event_hub.h +++ b/frameworks/core/components_ng/event/event_hub.h @@ -16,6 +16,7 @@ #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_EVENT_EVENT_HUB_H #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_EVENT_EVENT_HUB_H +#include #include #include @@ -112,6 +113,15 @@ public: { onAppear_ = std::move(onAppear); } + + void ClearUserOnAppear() + { + if (onAppear_) { + LOGI("FL----event_hub: ClearUserOnAppear: Clear user OnAppear callback."); + onAppear_ = nullptr; + } + } + void FireOnAppear() { if (onAppear_) { @@ -135,6 +145,15 @@ public: { onDisappear_ = std::move(onDisappear); } + + void ClearUserOnDisAppear() + { + if (onDisappear_) { + LOGI("FL----event_hub: ClearUserOnDisAppear: Clear user OnDisAppear callback."); + onDisappear_ = nullptr; + } + } + void FireOnDisappear() { if (onDisappear_) { @@ -326,6 +345,14 @@ public: return keyboardShortcut_; } + void ClearUserKeyboardShortcut() + { + LOGI("FL----focus_hub: ClearUserKeyboardShortcut: Clear user KeyboardShortcut callback."); + if (! keyboardShortcut_.empty()) { + keyboardShortcut_.clear(); + } + } + protected: virtual void OnModifyDone() {} diff --git a/frameworks/core/components_ng/event/focus_hub.h b/frameworks/core/components_ng/event/focus_hub.h index 5f896d1ae2d0337c56d328af7a115c95572b4a53..7c80d58aac7747d7838500da432047cafcc13b36 100644 --- a/frameworks/core/components_ng/event/focus_hub.h +++ b/frameworks/core/components_ng/event/focus_hub.h @@ -248,6 +248,7 @@ public: { onFocusCallback_ = std::move(onFocusCallback); } + const OnFocusFunc& GetOnFocusCallback() { return onFocusCallback_; @@ -257,6 +258,7 @@ public: { onBlurCallback_ = std::move(onBlurCallback); } + const OnBlurFunc& GetOnBlurCallback() { return onBlurCallback_; @@ -542,6 +544,15 @@ public: } focusCallbackEvents_->SetOnFocusCallback(std::move(onFocusCallback)); } + + void ClearUserOnFocus() + { + LOGI("FL----focus_hub: ClearOnFocusCallback: Clear user OnFocus callback."); + if (focusCallbackEvents_) { + focusCallbackEvents_ = nullptr;; + } + } + OnFocusFunc GetOnFocusCallback() { return focusCallbackEvents_ ? focusCallbackEvents_->GetOnFocusCallback() : nullptr; @@ -554,6 +565,17 @@ public: } focusCallbackEvents_->SetOnBlurCallback(std::move(onBlurCallback)); } + + void ClearUserOnBlur() + { + // When the event param is undefined, it will clear the callback. + LOGI("FL----focus_hub: ClearOnBlurCallback: Clear user OnBlur callback."); + if (focusCallbackEvents_) { + // onBlurCallback_.Reset(); + focusCallbackEvents_ = nullptr; + } + } + OnBlurFunc GetOnBlurCallback() { return focusCallbackEvents_ ? focusCallbackEvents_->GetOnBlurCallback() : nullptr; diff --git a/frameworks/core/components_ng/event/gesture_event_hub.cpp b/frameworks/core/components_ng/event/gesture_event_hub.cpp index 68bf48a1203faa7416610022fbd11e1286931244..cec2a5e3824922b470762f434d2c43fb2842257b 100644 --- a/frameworks/core/components_ng/event/gesture_event_hub.cpp +++ b/frameworks/core/components_ng/event/gesture_event_hub.cpp @@ -22,6 +22,7 @@ #include "base/utils/time_util.h" #include "core/components_ng/base/frame_node.h" #include "core/components_ng/event/click_event.h" +#include "core/components_ng/event/focus_hub.h" #include "core/components_ng/event/event_hub.h" #include "core/components_ng/gestures/recognizers/click_recognizer.h" #include "core/components_ng/gestures/recognizers/exclusive_recognizer.h" @@ -564,6 +565,7 @@ void GestureEventHub::AddClickEvent(const RefPtr& clickEvent) SetFocusClickEvent(clickEventActuator_->GetClickEvent()); } + // replace last showMenu callback void GestureEventHub::BindMenu(GestureEventFunc&& showMenu) { @@ -784,4 +786,23 @@ bool GestureEventHub::IsAccessibilityLongClickable() } return ret; } + +// void GestureEventHub::ClearUserOnFocus() +// { +// LOGI("FL----gesture_event_hub.cpp : ClearUserOnFocus"); +// if (focusCallbackEvents_) { +// focusCallbackEvents_->ClearOnFocusCallback(); +// } +// } + +// void GestureEventHub::ClearUserOnBlur() +// { +// if (focusCallbackEvents_) { +// LOGI("FL----gesture_event_hub.cpp : ClearUserOnBlur"); +// focusCallbackEvents_->ClearOnBlurCallback(); +// } +// } + + } // namespace OHOS::Ace::NG + diff --git a/frameworks/core/components_ng/event/gesture_event_hub.h b/frameworks/core/components_ng/event/gesture_event_hub.h index 6b1f6cf05b1fbc78b49242217da7b9d2f11466cc..e05d3ae19252fbc46c05f0846b412da573ed0fbc 100644 --- a/frameworks/core/components_ng/event/gesture_event_hub.h +++ b/frameworks/core/components_ng/event/gesture_event_hub.h @@ -28,6 +28,7 @@ #include "core/components_ng/event/pan_event.h" #include "core/components_ng/event/scrollable_event.h" #include "core/components_ng/event/touch_event.h" +#include "core/components_ng/event/focus_hub.h" #include "core/components_ng/gestures/gesture_info.h" #include "core/components_ng/gestures/recognizers/exclusive_recognizer.h" #include "core/components_ng/gestures/recognizers/parallel_recognizer.h" @@ -195,9 +196,16 @@ public: bool ActClick(); void CheckClickActuator(); + void CheckOnFocusActuator(); // Set by user define, which will replace old one. void SetUserOnClick(GestureEventFunc&& clickEvent); + // When the event param is undefined, it will clear the callback. + void ClearUserOnAppear(); + void ClearUserOnDisAppear(); + void ClearUserOnFocus(); + void ClearUserOnBlur(); + void AddClickEvent(const RefPtr& clickEvent); void RemoveClickEvent(const RefPtr& clickEvent) @@ -406,6 +414,7 @@ private: RefPtr longPressEventActuator_; RefPtr panEventActuator_; RefPtr dragEventActuator_; + RefPtr focusCallbackEvents_; RefPtr innerExclusiveRecognizer_; RefPtr nodeExclusiveRecognizer_; RefPtr nodeParallelRecognizer_; diff --git a/frameworks/core/pipeline_ng/pipeline_context.cpp b/frameworks/core/pipeline_ng/pipeline_context.cpp index 034351ba205f41278ce3cc23402d4ae56cd51840..8f81593266a9c929fa432f8a18ebb10448ac2132 100644 --- a/frameworks/core/pipeline_ng/pipeline_context.cpp +++ b/frameworks/core/pipeline_ng/pipeline_context.cpp @@ -1324,6 +1324,13 @@ void PipelineContext::AddVisibleAreaChangeNode( } } +void PipelineContext::ClearUserOnVisibleChange(const RefPtr& node, double ratio) +{ + LOGI("FL: pipeline_context: ClearUserOnVisibleChange"); + CHECK_NULL_VOID(node); + node->ClearVisibleAreaUserCallback(ratio); +} + void PipelineContext::RemoveVisibleAreaChangeNode(int32_t nodeId) { onVisibleAreaChangeNodeIds_.erase(nodeId); diff --git a/frameworks/core/pipeline_ng/pipeline_context.h b/frameworks/core/pipeline_ng/pipeline_context.h index 56be341876bb011a600c2c6e51694f8025357138..4dd505c48c795c5c5f4e21f25cd2bd320da85e0d 100644 --- a/frameworks/core/pipeline_ng/pipeline_context.h +++ b/frameworks/core/pipeline_ng/pipeline_context.h @@ -132,6 +132,8 @@ public: const RefPtr& node, double ratio, const VisibleRatioCallback& callback, bool isUserCallback = true); void RemoveVisibleAreaChangeNode(int32_t nodeId); + void ClearUserOnVisibleChange(const RefPtr& node, double ratio); + void HandleVisibleAreaChangeEvent(); void Destroy() override; diff --git a/frameworks/core/pipeline_ng/test/mock/mock_pipeline_base.cpp b/frameworks/core/pipeline_ng/test/mock/mock_pipeline_base.cpp index 961549f6fd4caebfbe54013536a40cd311d43290..b455fce4a7880fc034d478f6b17cb51978f2e340 100644 --- a/frameworks/core/pipeline_ng/test/mock/mock_pipeline_base.cpp +++ b/frameworks/core/pipeline_ng/test/mock/mock_pipeline_base.cpp @@ -262,6 +262,8 @@ void PipelineContext::DumpPipelineInfo() const {} void PipelineContext::AddVisibleAreaChangeNode( const RefPtr& node, double ratio, const VisibleRatioCallback& callback, bool isUserCallback) {} + + void PipelineContext::RemoveVisibleAreaChangeNode(int32_t nodeId) {} bool PipelineContext::ChangeMouseStyle(int32_t nodeId, MouseFormat format)