diff --git a/common/interface/src/parcel/accessibility_element_info_parcel.cpp b/common/interface/src/parcel/accessibility_element_info_parcel.cpp index fb2c117d..071b303d 100644 --- a/common/interface/src/parcel/accessibility_element_info_parcel.cpp +++ b/common/interface/src/parcel/accessibility_element_info_parcel.cpp @@ -169,6 +169,7 @@ bool AccessibilityElementInfoParcel::ReadFromParcelFourthPart(Parcel &parcel) READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isActive_); READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityVisible_); + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, clip_); return true; } @@ -288,6 +289,7 @@ bool AccessibilityElementInfoParcel::MarshallingThirdPart(Parcel &parcel) const WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isActive_); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityVisible_); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, clip_); return true; } diff --git a/frameworks/common/src/accessibility_element_info.cpp b/frameworks/common/src/accessibility_element_info.cpp index 37f0cd83..a5231b79 100644 --- a/frameworks/common/src/accessibility_element_info.cpp +++ b/frameworks/common/src/accessibility_element_info.cpp @@ -947,7 +947,11 @@ const std::string &AccessibilityElementInfo::GetBackgroundColor() const void AccessibilityElementInfo::SetBackgroundImage(const std::string &backgroundImage) { - backgroundImage_ = backgroundImage; + if (backgroundImage.length() > backgroundImageMaxLength) { + backgroundImage_ = "true"; + } else { + backgroundImage_ = backgroundImage; + } } const std::string &AccessibilityElementInfo::GetBackgroundImage() const @@ -1087,5 +1091,15 @@ void AccessibilityElementInfo::SetAccessibilityVisible(const bool accessibilityV { accessibilityVisible_ = accessibilityVisible; } + +bool AccessibilityElementInfo::GetClip() const +{ + return clip_; +} + +void AccessibilityElementInfo::SetClip(const bool clip) +{ + clip_ = clip; +} } // 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 b0f42ab9..5a0520be 100644 --- a/interfaces/innerkits/common/include/accessibility_element_info.h +++ b/interfaces/innerkits/common/include/accessibility_element_info.h @@ -1736,6 +1736,20 @@ public: * @sysCap Accessibility */ void SetAccessibilityVisible(const bool accessibilityVisible); + + /** + * @brief Get the clip to the element info. + * @return clip status. + * @sysCap Accessibility + */ + bool GetClip() const; + + /** + * @brief Set the clip to the element info. + * @param clip The clip of node. + * @sysCap Accessibility + */ + void SetClip(const bool clip); protected: int32_t pageId_ = -1; int32_t windowId_ = -1; @@ -1813,6 +1827,8 @@ protected: std::vector spanList_ {}; bool isActive_ = true; bool accessibilityVisible_ = true; + bool clip_ = false; + static const int backgroundImageMaxLength = 20; }; } // 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 a5147cf7..b37832cf 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 @@ -140,6 +140,7 @@ public: static void GetElementInfoSpan(NAccessibilityElementData *callbackInfo, napi_value &value); static void GetElementInfoIsActive(NAccessibilityElementData *callbackInfo, napi_value &value); static void GetElementInfoAccessibilityVisible(NAccessibilityElementData *callbackInfo, napi_value &value); + static void GetElementInfoClip(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 7485de71..7173e4ec 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 @@ -41,7 +41,7 @@ namespace { "error", "isHint", "pageId", "valueMax", "valueMin", "valueNow", "windowId", "accessibilityText", "textType", "offset", "currentItem", "accessibilityGroup", "accessibilityLevel", "checkboxGroupSelectedStatus", "row", "column", "listItemIndex", "sideBarContainerStates", "span", "isActive", "accessibilityVisible", - "allAttribute"}; + "allAttribute", "clip"}; const std::vector WINDOW_INFO_ATTRIBUTE_NAMES = {"isActive", "screenRect", "layer", "type", "rootElement", "isFocused", "windowId"}; @@ -105,6 +105,7 @@ namespace { {"isActive", &NAccessibilityElement::GetElementInfoIsActive}, {"accessibilityVisible", &NAccessibilityElement::GetElementInfoAccessibilityVisible}, {"allAttribute", &NAccessibilityElement::GetElementInfoAllAttribute}, + {"clip", &NAccessibilityElement::GetElementInfoClip}, }; std::map windowInfoCompleteMap = { {"isActive", &NAccessibilityElement::GetWindowInfoIsActive}, @@ -1097,6 +1098,15 @@ void NAccessibilityElement::GetElementInfoAccessibilityVisible( callbackInfo->accessibilityElement_.elementInfo_->GetAccessibilityVisible(), &value)); } +void NAccessibilityElement::GetElementInfoClip(NAccessibilityElementData *callbackInfo, napi_value &value) +{ + if (!CheckElementInfoParameter(callbackInfo, value)) { + return; + } + NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_int64(callbackInfo->env_, + callbackInfo->accessibilityElement_.elementInfo_->GetClip(), &value)); +} + void NAccessibilityElement::GetElementInfoAllAttribute(NAccessibilityElementData *callbackInfo, napi_value &value) { NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_object(callbackInfo->env_, &value)); @@ -1357,6 +1367,10 @@ void NAccessibilityElement::GetElementInfoAllAttribute5(NAccessibilityElementDat napi_value accessibilityVisible = nullptr; GetElementInfoAccessibilityVisible(callbackInfo, accessibilityVisible); NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "accessibilityVisible", accessibilityVisible)); + + napi_value clip = nullptr; + GetElementInfoClip(callbackInfo, isActive); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "clip", clip)); } void NAccessibilityElement::GetWindowInfoAllAttribute(NAccessibilityElementData *callbackInfo, napi_value &value)