mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 01:03:08 +00:00
!47621 UIExtension Event Callback 逻辑优化
Merge pull request !47621 from cuijiawei/master
This commit is contained in:
commit
780deb3d81
@ -2104,6 +2104,21 @@ void AceContainer::AttachView(std::shared_ptr<Window> window, const RefPtr<AceVi
|
||||
TaskExecutor::TaskType::PLATFORM, "ArkUIStatusBarColorChanged");
|
||||
};
|
||||
pipelineContext_->SetStatusBarEventHandler(setStatusBarEventHandler);
|
||||
|
||||
auto uiExtensionEventCallback = [weak = WeakClaim(this)] (uint32_t eventId) {
|
||||
auto container = weak.Upgrade();
|
||||
CHECK_NULL_VOID(container);
|
||||
container->FireUIExtensionEventCallback(eventId);
|
||||
};
|
||||
pipelineContext_->SetUIExtensionEventCallback(uiExtensionEventCallback);
|
||||
|
||||
auto accessibilityEventCallback = [weak = WeakClaim(this)] (uint32_t eventId, int64_t parameter) {
|
||||
auto container = weak.Upgrade();
|
||||
CHECK_NULL_VOID(container);
|
||||
container->FireAccessibilityEventCallback(eventId, parameter);
|
||||
};
|
||||
pipelineContext_->SetAccessibilityEventCallback(accessibilityEventCallback);
|
||||
|
||||
if (GetSettings().usePlatformAsUIThread) {
|
||||
FrameReport::GetInstance().Init();
|
||||
} else {
|
||||
@ -2911,6 +2926,15 @@ bool AceContainer::IsUIExtensionWindow()
|
||||
return uiWindow_->GetType() == Rosen::WindowType::WINDOW_TYPE_UI_EXTENSION;
|
||||
}
|
||||
|
||||
void AceContainer::FireUIExtensionEventCallback(uint32_t eventId)
|
||||
{
|
||||
if (!IsUIExtensionWindow()) {
|
||||
return;
|
||||
}
|
||||
ACE_SCOPED_TRACE("FireUIExtensionEventCallback event[%u]", eventId);
|
||||
uiWindow_->NotifyExtensionEventAsync(eventId);
|
||||
}
|
||||
|
||||
bool AceContainer::IsSceneBoardEnabled()
|
||||
{
|
||||
return Rosen::SceneBoardJudgement::IsSceneBoardEnabled();
|
||||
@ -3220,6 +3244,24 @@ void AceContainer::HandleAccessibilityHoverEvent(float pointX, float pointY, int
|
||||
TaskExecutor::TaskType::UI, "ArkUIHandleAccessibilityHoverEvent");
|
||||
}
|
||||
|
||||
void AceContainer::FireAccessibilityEventCallback(uint32_t eventId, int64_t parameter)
|
||||
{
|
||||
CHECK_NULL_VOID(taskExecutor_);
|
||||
taskExecutor_->PostTask(
|
||||
[weak = WeakClaim(this), eventId, parameter] {
|
||||
auto container = weak.Upgrade();
|
||||
CHECK_NULL_VOID(container);
|
||||
ContainerScope scope(container->GetInstanceId());
|
||||
auto pipelineContext = container->GetPipelineContext();
|
||||
auto ngPipeline = AceType::DynamicCast<NG::PipelineContext>(pipelineContext);
|
||||
CHECK_NULL_VOID(ngPipeline);
|
||||
auto accessibilityManager = ngPipeline->GetAccessibilityManager();
|
||||
CHECK_NULL_VOID(accessibilityManager);
|
||||
accessibilityManager->FireAccessibilityEventCallback(eventId, parameter);
|
||||
},
|
||||
TaskExecutor::TaskType::UI, "ArkUIHandleAccessibilityEventCallback");
|
||||
}
|
||||
|
||||
std::vector<Ace::RectF> AceContainer::GetOverlayNodePositions()
|
||||
{
|
||||
auto pipeline = AceType::DynamicCast<NG::PipelineContext>(pipelineContext_);
|
||||
|
@ -710,6 +710,8 @@ public:
|
||||
auto rect = uiWindow_->GetHostWindowRect(instanceId);
|
||||
return Rect(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
}
|
||||
void FireUIExtensionEventCallback(uint32_t eventId);
|
||||
void FireAccessibilityEventCallback(uint32_t eventId, int64_t parameter);
|
||||
|
||||
private:
|
||||
virtual bool MaybeRelease() override;
|
||||
|
@ -95,6 +95,7 @@
|
||||
#include "core/components_ng/base/inspector.h"
|
||||
#include "core/components_ng/base/view_abstract.h"
|
||||
#include "core/components_ng/pattern/text_field/text_field_manager.h"
|
||||
#include "core/components_ng/pattern/ui_extension/ui_extension_config.h"
|
||||
#include "core/image/image_file_cache.h"
|
||||
#include "core/pipeline_ng/pipeline_context.h"
|
||||
#ifdef FORM_SUPPORTED
|
||||
@ -2575,13 +2576,8 @@ void UIContentImpl::UpdateViewportConfigWithAnimation(const ViewportConfig& conf
|
||||
container->SetWindowPos(config.Left(), config.Top());
|
||||
auto pipelineContext = container->GetPipelineContext();
|
||||
if (pipelineContext) {
|
||||
auto uiExtensionFlushFinishCallback = [rsWindow]() {
|
||||
CHECK_NULL_VOID(rsWindow);
|
||||
rsWindow->NotifyExtensionEventAsync(0);
|
||||
};
|
||||
if (container->IsUIExtensionWindow()) {
|
||||
pipelineContext->EnWaitFlushFinish();
|
||||
pipelineContext->SetUIExtensionFlushFinishCallback(uiExtensionFlushFinishCallback);
|
||||
pipelineContext->AddUIExtensionCallbackEvent(NG::UIExtCallbackEventId::ON_AREA_CHANGED);
|
||||
}
|
||||
UpdateSafeArea(pipelineContext, avoidAreas, config, container);
|
||||
pipelineContext->SetDisplayWindowRectInfo(
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "core/pipeline/pipeline_context.h"
|
||||
#include "core/pipeline_ng/pipeline_context.h"
|
||||
#include "frameworks/bridge/common/dom/dom_type.h"
|
||||
#include "frameworks/core/components_ng/pattern/ui_extension/ui_extension_config.h"
|
||||
#include "frameworks/core/components_ng/pattern/web/web_pattern.h"
|
||||
#include "js_third_provider_interaction_operation.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
@ -65,8 +66,9 @@ constexpr int32_t ROOT_DECOR_BASE = 3100000;
|
||||
constexpr int32_t CARD_NODE_ID_RATION = 10000;
|
||||
constexpr int32_t CARD_ROOT_NODE_ID_RATION = 1000;
|
||||
constexpr int32_t CARD_BASE = 100000;
|
||||
constexpr int32_t UEC_EVENT_TASK_DELAY_MILLISECOND = 200;
|
||||
constexpr int32_t DELAY_SEND_EVENT_MILLISECOND = 20;
|
||||
constexpr uint32_t SUB_TREE_OFFSET_IN_PAGE_ID = 16;
|
||||
constexpr int32_t MAX_PAGE_ID_WITH_SUB_TREE = (1 << SUB_TREE_OFFSET_IN_PAGE_ID);
|
||||
|
||||
const std::string ACTION_ARGU_SCROLL_STUB = "scrolltype"; // wait for change
|
||||
const std::string ACTION_DEFAULT_PARAM = "ACCESSIBILITY_ACTION_INVALID";
|
||||
@ -1242,6 +1244,18 @@ bool IsUserCheckedOrSelected(const RefPtr<NG::FrameNode> frameNode)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UpdateElementInfoPageIdWithTreeId(Accessibility::AccessibilityElementInfo& info, int32_t treeId)
|
||||
{
|
||||
int32_t pageId = info.GetPageId();
|
||||
if ((pageId >= MAX_PAGE_ID_WITH_SUB_TREE) || (pageId < 0)) {
|
||||
TAG_LOGE(AceLogTag::ACE_ACCESSIBILITY, "pageId %{public}d cannot set tree id", pageId);
|
||||
} else {
|
||||
uint32_t unsignedPageId = static_cast<uint32_t>(pageId);
|
||||
uint32_t unsignedTreeId = static_cast<uint32_t>(treeId);
|
||||
info.SetPageId((unsignedTreeId << SUB_TREE_OFFSET_IN_PAGE_ID) | unsignedPageId);
|
||||
}
|
||||
}
|
||||
}
|
||||
void UpdateAccessibilityTextValueInfo(
|
||||
RefPtr<NG::AccessibilityProperty>& accessibilityProperty, AccessibilityElementInfo& nodeInfo)
|
||||
@ -2436,6 +2450,7 @@ void JsAccessibilityManager::InitializeCallback()
|
||||
|
||||
auto container = Platform::AceContainer::GetContainer(pipelineContext->GetInstanceId());
|
||||
if (container != nullptr && container->IsUIExtensionWindow()) {
|
||||
pipelineContext->AddUIExtensionCallbackEvent(OHOS::Ace::NG::UIExtCallbackEventId::ON_UEA_ACCESSIBILITY_READY);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2466,6 +2481,7 @@ bool JsAccessibilityManager::SendAccessibilitySyncEvent(
|
||||
eventInfo.SetSource(elementId);
|
||||
UpdateElementInfoTreeId(info);
|
||||
eventInfo.SetElementInfo(info);
|
||||
eventInfo.SetPageId(info.GetPageId());
|
||||
TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY,
|
||||
"send accessibility componentType:%{public}s event:%{public}d accessibilityId:%{public}" PRId64,
|
||||
eventInfo.GetComponentType().c_str(), eventInfo.GetEventType(), eventInfo.GetAccessibilityId());
|
||||
@ -5217,6 +5233,7 @@ bool JsAccessibilityManager::NeedRegisterChildTree(
|
||||
void JsAccessibilityManager::RegisterInteractionOperationAsChildTree(
|
||||
uint32_t parentWindowId, int32_t parentTreeId, int64_t parentElementId)
|
||||
{
|
||||
AccessibilitySystemAbilityClient::SetSplicElementIdTreeId(parentTreeId, parentElementId);
|
||||
if (!NeedRegisterChildTree(parentWindowId, parentTreeId, parentElementId)) {
|
||||
return;
|
||||
}
|
||||
@ -5231,7 +5248,6 @@ void JsAccessibilityManager::RegisterInteractionOperationAsChildTree(
|
||||
} else if (pipelineContext->IsFormRender()) {
|
||||
windowId_ = parentWindowId;
|
||||
}
|
||||
AccessibilitySystemAbilityClient::SetSplicElementIdTreeId(parentTreeId, parentElementId);
|
||||
|
||||
uint32_t windowId = GetWindowId();
|
||||
auto interactionOperation = std::make_shared<JsInteractionOperation>(windowId);
|
||||
@ -5329,17 +5345,6 @@ void JsAccessibilityManager::JsInteractionOperation::SetChildTreeIdAndWinId(
|
||||
auto jsAccessibilityManager = GetHandler().Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
jsAccessibilityManager->NotifySetChildTreeIdAndWinId(splitElementId, treeId, childWindowId);
|
||||
|
||||
auto context = jsAccessibilityManager->GetPipelineContext().Upgrade();
|
||||
CHECK_NULL_VOID(context);
|
||||
context->GetTaskExecutor()->PostDelayedTask(
|
||||
[weak = GetHandler(), splitElementId] {
|
||||
auto jsAccessibilityManager = weak.Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
ACE_SCOPED_TRACE("SendUecOnTreeEvent");
|
||||
jsAccessibilityManager->SendUecOnTreeEvent(splitElementId);
|
||||
},
|
||||
TaskExecutor::TaskType::UI, UEC_EVENT_TASK_DELAY_MILLISECOND, "ArkUIAccessibilitySendUecOnTreeEvent");
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::JsInteractionOperation::SetBelongTreeId(const int32_t treeId)
|
||||
@ -5377,6 +5382,8 @@ void JsAccessibilityManager::UpdateElementInfoTreeId(Accessibility::Accessibilit
|
||||
info.SetParent(parentId);
|
||||
}
|
||||
|
||||
UpdateElementInfoPageIdWithTreeId(info, treeId);
|
||||
|
||||
std::vector<int64_t> childIds = info.GetChildIds();
|
||||
for (int64_t child : childIds) {
|
||||
info.RemoveChild(child);
|
||||
@ -5403,6 +5410,8 @@ void JsAccessibilityManager::UpdateElementInfosTreeId(std::list<Accessibility::A
|
||||
item.SetParent(parentId);
|
||||
}
|
||||
|
||||
UpdateElementInfoPageIdWithTreeId(item, treeId);
|
||||
|
||||
std::vector<int64_t> childIds = item.GetChildIds();
|
||||
for (int64_t child : childIds) {
|
||||
item.RemoveChild(child);
|
||||
@ -6199,4 +6208,19 @@ void JsAccessibilityManager::GetWebCursorPosition(const int64_t elementId, const
|
||||
callback.SetCursorPositionResult(node->GetSelectionStart(), requestId);
|
||||
}
|
||||
#endif // WEB_SUPPORTED
|
||||
|
||||
void JsAccessibilityManager::FireAccessibilityEventCallback(uint32_t eventId, int64_t parameter)
|
||||
{
|
||||
auto eventType = static_cast<AccessibilityCallbackEventId>(eventId);
|
||||
AccessibilityEvent event;
|
||||
switch (eventType) {
|
||||
case AccessibilityCallbackEventId::ON_LOAD_PAGE:
|
||||
event.nodeId = parameter;
|
||||
event.windowChangeTypes = WindowUpdateType::WINDOW_UPDATE_ACTIVE;
|
||||
event.type = AccessibilityEventType::CHANGE;
|
||||
SendAccessibilityAsyncEvent(event);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Ace::Framework
|
||||
|
@ -252,6 +252,8 @@ public:
|
||||
const std::vector<std::string>& params,
|
||||
std::vector<std::string>& info) override;
|
||||
|
||||
void FireAccessibilityEventCallback(uint32_t eventId, int64_t parameter) override;
|
||||
|
||||
protected:
|
||||
void OnDumpInfoNG(const std::vector<std::string>& params, uint32_t windowId, bool hasJson = false) override;
|
||||
void DumpHandleEvent(const std::vector<std::string>& params) override;
|
||||
|
@ -84,6 +84,22 @@ struct AccessibilityParentRectInfo {
|
||||
int32_t rotateDegree = 0; // final rotate degree of parent interface
|
||||
};
|
||||
|
||||
enum class AccessibilityCallbackEventId : uint32_t {
|
||||
ON_LOAD_PAGE = 0,
|
||||
ON_SHOW = 1,
|
||||
ON_HIDE = 2,
|
||||
};
|
||||
|
||||
struct AccessibilityCallbackEvent {
|
||||
AccessibilityCallbackEventId eventId;
|
||||
int64_t parameter;
|
||||
AccessibilityCallbackEvent(AccessibilityCallbackEventId id, int64_t para) : eventId(id), parameter(para) {}
|
||||
bool operator < (const AccessibilityCallbackEvent& other) const
|
||||
{
|
||||
return eventId < other.eventId;
|
||||
}
|
||||
};
|
||||
|
||||
class AccessibilitySAObserverCallback {
|
||||
public:
|
||||
explicit AccessibilitySAObserverCallback(int64_t accessibilityId) : accessibilityId_(accessibilityId)
|
||||
@ -244,6 +260,8 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void FireAccessibilityEventCallback(uint32_t eventId, int64_t parameter) {}
|
||||
|
||||
bool IsRegister()
|
||||
{
|
||||
return isReg_;
|
||||
|
@ -65,7 +65,6 @@ constexpr char UI_EXTENSION_TYPE_KEY[] = "ability.want.params.uiExtensionType";
|
||||
const std::string EMBEDDED_UI("embeddedUI");
|
||||
constexpr int32_t AVOID_DELAY_TIME = 30;
|
||||
constexpr int32_t INVALID_WINDOW_ID = -1;
|
||||
constexpr uint32_t REMOVE_PLACEHOLDER_DELAY_TIME = 32;
|
||||
} // namespace
|
||||
|
||||
class UIExtensionLifecycleListener : public Rosen::ILifecycleListener {
|
||||
@ -315,9 +314,9 @@ void SessionWrapperImpl::InitAllCallback()
|
||||
return avoidArea;
|
||||
};
|
||||
sessionCallbacks->notifyExtensionEventFunc_ =
|
||||
[weak = hostPattern_, taskExecutor = taskExecutor_, callSessionId](uint32_t event) {
|
||||
taskExecutor->PostDelayedTask(
|
||||
[weak, callSessionId]() {
|
||||
[weak = hostPattern_, taskExecutor = taskExecutor_, callSessionId](uint32_t eventId) {
|
||||
taskExecutor->PostTask(
|
||||
[weak, callSessionId, eventId]() {
|
||||
auto pattern = weak.Upgrade();
|
||||
CHECK_NULL_VOID(pattern);
|
||||
if (callSessionId != pattern->GetSessionId()) {
|
||||
@ -327,9 +326,9 @@ void SessionWrapperImpl::InitAllCallback()
|
||||
callSessionId, pattern->GetSessionId());
|
||||
return;
|
||||
}
|
||||
pattern->OnAreaUpdated();
|
||||
pattern->OnExtensionEvent(static_cast<UIExtCallbackEventId>(eventId));
|
||||
},
|
||||
TaskExecutor::TaskType::UI, REMOVE_PLACEHOLDER_DELAY_TIME, "ArkUIUIExtensionEventCallback");
|
||||
TaskExecutor::TaskType::UI, "ArkUIUIExtensionEventCallback");
|
||||
};
|
||||
}
|
||||
/************************************************ End: Initialization *************************************************/
|
||||
|
@ -26,5 +26,20 @@ enum class PlaceholderType : int32_t {
|
||||
FOLD_TO_EXPAND = 3,
|
||||
INITIAL = 4,
|
||||
};
|
||||
|
||||
enum class UIExtCallbackEventId : uint32_t {
|
||||
ON_AREA_CHANGED = 0,
|
||||
ON_UEA_ACCESSIBILITY_READY = 6,
|
||||
};
|
||||
|
||||
struct UIExtCallbackEvent {
|
||||
UIExtCallbackEventId eventId;
|
||||
bool repeat = false;
|
||||
UIExtCallbackEvent(UIExtCallbackEventId id, bool re = false) : eventId(id), repeat(re) {}
|
||||
bool operator < (const UIExtCallbackEvent& other) const
|
||||
{
|
||||
return eventId < other.eventId;
|
||||
}
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_UIEXTENSION_CONFIG_H
|
||||
|
@ -63,6 +63,8 @@ constexpr char PID_FLAG[] = "pidflag";
|
||||
constexpr char NO_EXTRA_UIE_DUMP[] = "-nouie";
|
||||
constexpr double SHOW_START = 0.0;
|
||||
constexpr double SHOW_FULL = 1.0;
|
||||
constexpr uint32_t REMOVE_PLACEHOLDER_DELAY_TIME = 32;
|
||||
constexpr uint32_t PLACEHOLDER_TIMEOUT = 6000;
|
||||
|
||||
bool StartWith(const std::string &source, const std::string &prefix)
|
||||
{
|
||||
@ -245,8 +247,10 @@ void UIExtensionPattern::MountPlaceholderNode(PlaceholderType type)
|
||||
CHECK_NULL_VOID(host);
|
||||
host->RemoveChildAtIndex(0);
|
||||
host->AddChild(placeholderNode, 0);
|
||||
ACE_SCOPED_TRACE("MountPlaceholderNode type[%d]", static_cast<int32_t>(type));
|
||||
host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
|
||||
SetCurPlaceholderType(type);
|
||||
PostDelayRemovePlaceholder(PLACEHOLDER_TIMEOUT);
|
||||
}
|
||||
|
||||
void UIExtensionPattern::RemovePlaceholderNode()
|
||||
@ -257,6 +261,7 @@ void UIExtensionPattern::RemovePlaceholderNode()
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
host->RemoveChildAtIndex(0);
|
||||
ACE_SCOPED_TRACE("RemovePlaceholderNode type[%d]", static_cast<int32_t>(curPlaceholderType_));
|
||||
host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
|
||||
SetCurPlaceholderType(PlaceholderType::NONE);
|
||||
}
|
||||
@ -405,9 +410,12 @@ void UIExtensionPattern::OnConnect()
|
||||
ReDispatchDisplayArea();
|
||||
}
|
||||
|
||||
void UIExtensionPattern::OnAreaUpdated()
|
||||
void UIExtensionPattern::ReplacePlaceholderByContent()
|
||||
{
|
||||
CHECK_RUN_ON(UI);
|
||||
if (!IsShowPlaceholder()) {
|
||||
return;
|
||||
}
|
||||
RemovePlaceholderNode();
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
@ -415,6 +423,53 @@ void UIExtensionPattern::OnAreaUpdated()
|
||||
host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
|
||||
}
|
||||
|
||||
void UIExtensionPattern::OnAreaUpdated()
|
||||
{
|
||||
PostDelayRemovePlaceholder(REMOVE_PLACEHOLDER_DELAY_TIME);
|
||||
}
|
||||
|
||||
void UIExtensionPattern::PostDelayRemovePlaceholder(uint32_t delay)
|
||||
{
|
||||
ContainerScope scope(instanceId_);
|
||||
auto taskExecutor = Container::CurrentTaskExecutor();
|
||||
CHECK_NULL_VOID(taskExecutor);
|
||||
taskExecutor->PostDelayedTask(
|
||||
[weak = WeakClaim(this)]() {
|
||||
auto pattern = weak.Upgrade();
|
||||
CHECK_NULL_VOID(pattern);
|
||||
pattern->ReplacePlaceholderByContent();
|
||||
},
|
||||
TaskExecutor::TaskType::UI, delay, "ArkUIUIExtensionRemovePlaceholder");
|
||||
}
|
||||
|
||||
void UIExtensionPattern::OnExtensionEvent(UIExtCallbackEventId eventId)
|
||||
{
|
||||
CHECK_RUN_ON(UI);
|
||||
ContainerScope scope(instanceId_);
|
||||
switch (eventId) {
|
||||
case UIExtCallbackEventId::ON_AREA_CHANGED:
|
||||
OnAreaUpdated();
|
||||
break;
|
||||
case UIExtCallbackEventId::ON_UEA_ACCESSIBILITY_READY:
|
||||
OnUeaAccessibilityEventAsync();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void UIExtensionPattern::OnUeaAccessibilityEventAsync()
|
||||
{
|
||||
auto frameNode = frameNode_.Upgrade();
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
|
||||
CHECK_NULL_VOID(accessibilityProperty);
|
||||
if ((accessibilityChildTreeCallback_ != nullptr) && (accessibilityProperty->GetChildTreeId() != -1)) {
|
||||
UIEXT_LOGI("uec need notify register accessibility again %{public}d, %{public}d.",
|
||||
accessibilityProperty->GetChildWindowId(), accessibilityProperty->GetChildTreeId());
|
||||
ResetAccessibilityChildTreeCallback();
|
||||
InitializeAccessibility();
|
||||
}
|
||||
}
|
||||
|
||||
PlaceholderType UIExtensionPattern::GetSizeChangeReason()
|
||||
{
|
||||
CHECK_NULL_RETURN(sessionWrapper_, PlaceholderType::NONE);
|
||||
|
@ -169,6 +169,10 @@ public:
|
||||
{
|
||||
curPlaceholderType_ = type;
|
||||
}
|
||||
void PostDelayRemovePlaceholder(uint32_t delay);
|
||||
void ReplacePlaceholderByContent();
|
||||
void OnExtensionEvent(UIExtCallbackEventId eventId);
|
||||
void OnUeaAccessibilityEventAsync();
|
||||
void OnAreaUpdated();
|
||||
bool IsModalUec();
|
||||
bool IsForeground();
|
||||
|
@ -852,6 +852,70 @@ void PipelineBase::SendEventToAccessibility(const AccessibilityEvent& accessibil
|
||||
accessibilityManager->SendAccessibilityAsyncEvent(accessibilityEvent);
|
||||
}
|
||||
|
||||
bool PipelineBase::FireUIExtensionEventValid()
|
||||
{
|
||||
if (!uiExtensionEventCallback_ || !IsFocusWindowIdSetted()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void PipelineBase::SetUIExtensionEventCallback(std::function<void(uint32_t)>&& callback)
|
||||
{
|
||||
ACE_FUNCTION_TRACE();
|
||||
uiExtensionEventCallback_ = callback;
|
||||
}
|
||||
|
||||
void PipelineBase::AddUIExtensionCallbackEvent(NG::UIExtCallbackEventId eventId)
|
||||
{
|
||||
ACE_SCOPED_TRACE("AddUIExtensionCallbackEvent event[%u]", static_cast<uint32_t>(eventId));
|
||||
uiExtensionEvents_.insert(NG::UIExtCallbackEvent(eventId));
|
||||
}
|
||||
|
||||
void PipelineBase::FireAllUIExtensionEvents()
|
||||
{
|
||||
if (!FireUIExtensionEventValid() || uiExtensionEvents_.empty()) {
|
||||
return;
|
||||
}
|
||||
for (auto it = uiExtensionEvents_.begin(); it != uiExtensionEvents_.end();) {
|
||||
uiExtensionEventCallback_(static_cast<uint32_t>(it->eventId));
|
||||
if (!it->repeat) {
|
||||
it = uiExtensionEvents_.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PipelineBase::FireUIExtensionEventOnceImmediately(NG::UIExtCallbackEventId eventId)
|
||||
{
|
||||
if (!FireUIExtensionEventValid()) {
|
||||
return;
|
||||
}
|
||||
uiExtensionEventCallback_(static_cast<uint32_t>(eventId));
|
||||
}
|
||||
|
||||
void PipelineBase::SetAccessibilityEventCallback(std::function<void(uint32_t, int64_t)>&& callback)
|
||||
{
|
||||
ACE_FUNCTION_TRACE();
|
||||
accessibilityCallback_ = callback;
|
||||
}
|
||||
|
||||
void PipelineBase::AddAccessibilityCallbackEvent(AccessibilityCallbackEventId event, int64_t parameter)
|
||||
{
|
||||
ACE_SCOPED_TRACE("AccessibilityCallbackEvent event[%u]", static_cast<uint32_t>(event));
|
||||
accessibilityEvents_.insert(AccessibilityCallbackEvent(event, parameter));
|
||||
}
|
||||
|
||||
void PipelineBase::FireAccessibilityEvents()
|
||||
{
|
||||
if (!accessibilityCallback_ || accessibilityEvents_.empty()) {
|
||||
return;
|
||||
}
|
||||
for (auto it = accessibilityEvents_.begin(); it != accessibilityEvents_.end();) {
|
||||
accessibilityCallback_(static_cast<uint32_t>(it->eventId), it->parameter);
|
||||
it = accessibilityEvents_.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void PipelineBase::SetSubWindowVsyncCallback(AceVsyncCallback&& callback, int32_t subWindowId)
|
||||
{
|
||||
if (callback) {
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "core/components/common/layout/constants.h"
|
||||
#include "core/components/common/properties/animation_option.h"
|
||||
#include "core/components/theme/theme_manager.h"
|
||||
#include "core/components_ng/pattern/ui_extension/ui_extension_config.h"
|
||||
#include "core/components_ng/property/safe_area_insets.h"
|
||||
#include "core/event/axis_event.h"
|
||||
#include "core/event/key_event.h"
|
||||
@ -1415,32 +1416,11 @@ public:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool IsWaitFlushFinish() const
|
||||
{
|
||||
return isWaitFlushFinish_;
|
||||
}
|
||||
|
||||
void EnWaitFlushFinish()
|
||||
{
|
||||
isWaitFlushFinish_ = true;
|
||||
}
|
||||
|
||||
void UnWaitFlushFinish()
|
||||
{
|
||||
isWaitFlushFinish_ = false;
|
||||
}
|
||||
|
||||
void SetUIExtensionFlushFinishCallback(std::function<void(void)>&& callback)
|
||||
{
|
||||
uiExtensionFlushFinishCallback_ = callback;
|
||||
}
|
||||
|
||||
void FireUIExtensionFlushFinishCallback()
|
||||
{
|
||||
if (uiExtensionFlushFinishCallback_) {
|
||||
uiExtensionFlushFinishCallback_();
|
||||
}
|
||||
}
|
||||
void SetUIExtensionEventCallback(std::function<void(uint32_t)>&& callback);
|
||||
void AddUIExtensionCallbackEvent(NG::UIExtCallbackEventId eventId);
|
||||
void FireAllUIExtensionEvents();
|
||||
void FireUIExtensionEventOnceImmediately(NG::UIExtCallbackEventId eventId);
|
||||
|
||||
void SetOpenInvisibleFreeze(bool isOpenInvisibleFreeze)
|
||||
{
|
||||
@ -1464,6 +1444,13 @@ public:
|
||||
|
||||
// Prints out the count of the unexecuted finish callback
|
||||
std::string GetUnexecutedFinishCount() const;
|
||||
|
||||
void SetAccessibilityEventCallback(std::function<void(uint32_t, int64_t)>&& callback);
|
||||
|
||||
void AddAccessibilityCallbackEvent(AccessibilityCallbackEventId event, int64_t parameter);
|
||||
|
||||
void FireAccessibilityEvents();
|
||||
|
||||
protected:
|
||||
virtual bool MaybeRelease() override;
|
||||
void TryCallNextFrameLayoutCallback()
|
||||
@ -1497,6 +1484,7 @@ protected:
|
||||
{
|
||||
isReloading_ = isReloading;
|
||||
}
|
||||
bool FireUIExtensionEventValid();
|
||||
|
||||
std::function<void()> GetWrappedAnimationCallback(const AnimationOption& option,
|
||||
const std::function<void()>& finishCallback, const std::optional<int32_t>& count = std::nullopt);
|
||||
@ -1651,9 +1639,11 @@ private:
|
||||
std::mutex densityChangeMutex_;
|
||||
int32_t densityChangeCallbackId_ = 0;
|
||||
std::unordered_map<int32_t, std::function<void(double)>> densityChangedCallbacks_;
|
||||
bool isWaitFlushFinish_ = false;
|
||||
std::function<double()> windowDensityCallback_;
|
||||
std::function<void(void)> uiExtensionFlushFinishCallback_;
|
||||
std::function<void(uint32_t)> uiExtensionEventCallback_;
|
||||
std::set<NG::UIExtCallbackEvent> uiExtensionEvents_;
|
||||
std::function<void(uint32_t, int64_t)> accessibilityCallback_;
|
||||
std::set<AccessibilityCallbackEvent> accessibilityEvents_;
|
||||
|
||||
ACE_DISALLOW_COPY_AND_MOVE(PipelineBase);
|
||||
};
|
||||
|
@ -957,10 +957,10 @@ void PipelineContext::FlushVsync(uint64_t nanoTimestamp, uint32_t frameCount)
|
||||
needRenderNode_.clear();
|
||||
taskScheduler_->FlushAfterRenderTask();
|
||||
window_->FlushLayoutSize(width_, height_);
|
||||
if (IsWaitFlushFinish()) {
|
||||
FireUIExtensionFlushFinishCallback();
|
||||
UnWaitFlushFinish();
|
||||
if (IsFocusWindowIdSetted()) {
|
||||
FireAllUIExtensionEvents();
|
||||
}
|
||||
FireAccessibilityEvents();
|
||||
// Keep the call sent at the end of the function
|
||||
ResSchedReport::GetInstance().LoadPageEvent(ResDefine::LOAD_PAGE_COMPLETE_EVENT);
|
||||
window_->Unlock();
|
||||
|
@ -1029,6 +1029,11 @@ bool PipelineBase::HasFloatTitle() const
|
||||
return true;
|
||||
}
|
||||
|
||||
void PipelineBase::AddUIExtensionCallbackEvent(NG::UIExtCallbackEventId eventId)
|
||||
{
|
||||
uiExtensionEvents_.insert(NG::UIExtCallbackEvent(eventId));
|
||||
}
|
||||
|
||||
Dimension NG::PipelineContext::GetCustomTitleHeight()
|
||||
{
|
||||
return Dimension();
|
||||
|
@ -604,7 +604,7 @@ HWTEST_F(JsThirdProviderInteractionOperationTest, JsThirdProviderInteractionOper
|
||||
auto jsInteractionOperation = AceType::MakeRefPtr<Framework::JsThirdProviderInteractionOperation>(
|
||||
ohAccessibilityProvider, jsAccessibilityManager, frameNode);
|
||||
|
||||
int32_t treeId = 3;
|
||||
int32_t treeId = 0;
|
||||
jsInteractionOperation->SetBelongTreeId(treeId);
|
||||
int32_t pageId = 4;
|
||||
frameNode->SetHostPageId(pageId);
|
||||
|
@ -1008,7 +1008,7 @@ HWTEST_F(UIExtensionComponentTestNg, UIExtensionPlaceholderTest, TestSize.Level1
|
||||
pattern->MountPlaceholderNode(PlaceholderType::ROTATION);
|
||||
EXPECT_EQ(pattern->IsShowPlaceholder(), true);
|
||||
EXPECT_EQ(pattern->curPlaceholderType_, PlaceholderType::INITIAL);
|
||||
pattern->OnAreaUpdated();
|
||||
pattern->ReplacePlaceholderByContent();
|
||||
EXPECT_EQ(pattern->IsShowPlaceholder(), false);
|
||||
pattern->MountPlaceholderNode(PlaceholderType::ROTATION);
|
||||
EXPECT_EQ(pattern->IsShowPlaceholder(), true);
|
||||
@ -1017,6 +1017,8 @@ HWTEST_F(UIExtensionComponentTestNg, UIExtensionPlaceholderTest, TestSize.Level1
|
||||
EXPECT_EQ(pattern->IsShowPlaceholder(), false);
|
||||
pattern->RemovePlaceholderNode();
|
||||
EXPECT_EQ(pattern->IsShowPlaceholder(), false);
|
||||
pattern->curPlaceholderType_ = PlaceholderType::NONE;
|
||||
pattern->ReplacePlaceholderByContent();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user