diff --git a/common/interface/src/parcel/accessibility_element_info_parcel.cpp b/common/interface/src/parcel/accessibility_element_info_parcel.cpp index e276fbe0..7602fea7 100644 --- a/common/interface/src/parcel/accessibility_element_info_parcel.cpp +++ b/common/interface/src/parcel/accessibility_element_info_parcel.cpp @@ -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; } diff --git a/frameworks/common/src/accessibility_element_info.cpp b/frameworks/common/src/accessibility_element_info.cpp index 8bfcc5e0..a276a729 100644 --- a/frameworks/common/src/accessibility_element_info.cpp +++ b/frameworks/common/src/accessibility_element_info.cpp @@ -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 \ No newline at end of file diff --git a/interfaces/innerkits/common/include/accessibility_element_info.h b/interfaces/innerkits/common/include/accessibility_element_info.h index 074e1458..c6bb98fd 100644 --- a/interfaces/innerkits/common/include/accessibility_element_info.h +++ b/interfaces/innerkits/common/include/accessibility_element_info.h @@ -1709,6 +1709,20 @@ public: */ const std::vector &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 spanList_ {}; + bool isActive_ = false; }; } // namespace Accessibility } // namespace OHOS diff --git a/interfaces/kits/napi/accessibility_extension_module_loader/include/napi_accessibility_element.h b/interfaces/kits/napi/accessibility_extension_module_loader/include/napi_accessibility_element.h index 7867c88d..4078730c 100644 --- a/interfaces/kits/napi/accessibility_extension_module_loader/include/napi_accessibility_element.h +++ b/interfaces/kits/napi/accessibility_extension_module_loader/include/napi_accessibility_element.h @@ -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); diff --git a/interfaces/kits/napi/accessibility_extension_module_loader/src/napi_accessibility_element.cpp b/interfaces/kits/napi/accessibility_extension_module_loader/src/napi_accessibility_element.cpp index b6d51e74..e0fe350e 100644 --- a/interfaces/kits/napi/accessibility_extension_module_loader/src/napi_accessibility_element.cpp +++ b/interfaces/kits/napi/accessibility_extension_module_loader/src/napi_accessibility_element.cpp @@ -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 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 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)