!1404 elementinfo新增属性isActive

Merge pull request !1404 from 姚子鹏/isActive
This commit is contained in:
openharmony_ci 2024-09-07 04:23:43 +00:00 committed by Gitee
commit 3020ac60df
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 44 additions and 1 deletions

View File

@ -166,6 +166,8 @@ bool AccessibilityElementInfoParcel::ReadFromParcelFourthPart(Parcel &parcel)
}
spanList_.emplace_back(*spanList);
}
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isActive_);
return true;
}
@ -283,6 +285,7 @@ bool AccessibilityElementInfoParcel::MarshallingThirdPart(Parcel &parcel) const
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &spanList);
}
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isActive_);
return true;
}

View File

@ -1067,5 +1067,15 @@ const std::string &SpanInfo::GetAccessibilityLevel() const
{
return accessibilityLevel_;
}
bool AccessibilityElementInfo::GetIsActive() const
{
return isActive_;
}
void AccessibilityElementInfo::SetIsActive(const bool isActive)
{
isActive_ = isActive;
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -1709,6 +1709,20 @@ public:
*/
const std::vector<SpanInfo> &GetSpanList() const;
/**
* @brief Get the isActive to the element info.
* @return isActive status.
* @sysCap Accessibility
*/
bool GetIsActive() const;
/**
* @brief Set the isActive to the element info.
* @param isActive The isActive of node.
* @sysCap Accessibility
*/
void SetIsActive(const bool isActive);
protected:
int32_t pageId_ = -1;
int32_t windowId_ = -1;
@ -1784,6 +1798,7 @@ protected:
std::string hitTestBehavior_ = "";
int64_t navDestinationId_ = -1;
std::vector<SpanInfo> spanList_ {};
bool isActive_ = false;
};
} // namespace Accessibility
} // namespace OHOS

View File

@ -138,6 +138,7 @@ public:
static void GetElementInfoAccessibilityLevel(NAccessibilityElementData *callbackInfo, napi_value &value);
static void GetElementInfoNavDestinationId(NAccessibilityElementData *callbackInfo, napi_value &value);
static void GetElementInfoSpan(NAccessibilityElementData *callbackInfo, napi_value &value);
static void GetElementInfoIsActive(NAccessibilityElementData *callbackInfo, napi_value &value);
// Window info
static void GetWindowInfoIsActive(NAccessibilityElementData *callbackInfo, napi_value &value);

View File

@ -40,7 +40,7 @@ namespace {
"editable", "pluralLineSupported", "parent", "children", "isFocused", "accessibilityFocused",
"error", "isHint", "pageId", "valueMax", "valueMin", "valueNow", "windowId", "accessibilityText",
"textType", "offset", "currentItem", "accessibilityGroup", "accessibilityLevel", "checkboxGroupSelectedStatus",
"row", "column", "listItemIndex", "sideBarContainerStates", "span", "allAttribute"};
"row", "column", "listItemIndex", "sideBarContainerStates", "span", "isActive", "allAttribute"};
const std::vector<std::string> WINDOW_INFO_ATTRIBUTE_NAMES = {"isActive", "screenRect", "layer", "type",
"rootElement", "isFocused", "windowId"};
@ -101,6 +101,7 @@ namespace {
{"listItemIndex", &NAccessibilityElement::GetElementInfoListItemIndex},
{"sideBarContainerStates", &NAccessibilityElement::GetElementInfoSideBarContainer},
{"span", &NAccessibilityElement::GetElementInfoSpan},
{"isActive", &NAccessibilityElement::GetElementInfoIsActive},
{"allAttribute", &NAccessibilityElement::GetElementInfoAllAttribute},
};
std::map<std::string, AttributeNamesFunc> windowInfoCompleteMap = {
@ -1075,6 +1076,15 @@ void NAccessibilityElement::GetElementInfoSpan(NAccessibilityElementData *callba
}
}
void NAccessibilityElement::GetElementInfoIsActive(NAccessibilityElementData *callbackInfo, napi_value &value)
{
if (!CheckElementInfoParameter(callbackInfo, value)) {
return;
}
NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_int64(callbackInfo->env_,
callbackInfo->accessibilityElement_.elementInfo_->GetIsActive(), &value));
}
void NAccessibilityElement::GetElementInfoAllAttribute(NAccessibilityElementData *callbackInfo, napi_value &value)
{
NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_object(callbackInfo->env_, &value));
@ -1327,6 +1337,10 @@ void NAccessibilityElement::GetElementInfoAllAttribute5(NAccessibilityElementDat
napi_value span = nullptr;
GetElementInfoSpan(callbackInfo, span);
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "span", span));
napi_value isActive = nullptr;
GetElementInfoIsActive(callbackInfo, isActive);
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "isActive", isActive));
}
void NAccessibilityElement::GetWindowInfoAllAttribute(NAccessibilityElementData *callbackInfo, napi_value &value)