mirror of
https://gitee.com/openharmony/accessibility
synced 2024-11-23 06:50:30 +00:00
新增属性
Signed-off-by: 13359243081 <lanshulei@huawei.com>
This commit is contained in:
parent
04450c2aee
commit
aa6c90d067
@ -166,6 +166,10 @@ bool AccessibilityElementInfoParcel::ReadFromParcelFourthPart(Parcel &parcel)
|
||||
}
|
||||
spanList_.emplace_back(*spanList);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -283,6 +287,9 @@ 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_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, accessibilityVisible_);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, clip_);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
@ -1067,5 +1071,35 @@ const std::string &SpanInfo::GetAccessibilityLevel() const
|
||||
{
|
||||
return accessibilityLevel_;
|
||||
}
|
||||
|
||||
bool AccessibilityElementInfo::GetIsActive() const
|
||||
{
|
||||
return isActive_;
|
||||
}
|
||||
|
||||
void AccessibilityElementInfo::SetIsActive(const bool isActive)
|
||||
{
|
||||
isActive_ = isActive;
|
||||
}
|
||||
|
||||
bool AccessibilityElementInfo::GetAccessibilityVisible() const
|
||||
{
|
||||
return accessibilityVisible_;
|
||||
}
|
||||
|
||||
void AccessibilityElementInfo::SetAccessibilityVisible(const bool accessibilityVisible)
|
||||
{
|
||||
accessibilityVisible_ = accessibilityVisible;
|
||||
}
|
||||
|
||||
bool AccessibilityElementInfo::GetClip() const
|
||||
{
|
||||
return clip_;
|
||||
}
|
||||
|
||||
void AccessibilityElementInfo::SetClip(const bool clip)
|
||||
{
|
||||
clip_ = clip;
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -1709,6 +1709,47 @@ 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);
|
||||
|
||||
/**
|
||||
* @brief Get the accessibilityVisible to the element info.
|
||||
* @return accessibilityVisible status.
|
||||
* @sysCap Accessibility
|
||||
*/
|
||||
bool GetAccessibilityVisible() const;
|
||||
|
||||
/**
|
||||
* @brief Set the accessibilityVisible to the element info.
|
||||
* @param accessibilityVisible The accessibilityVisible of node.
|
||||
* @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;
|
||||
@ -1784,6 +1825,10 @@ protected:
|
||||
std::string hitTestBehavior_ = "";
|
||||
int64_t navDestinationId_ = -1;
|
||||
std::vector<SpanInfo> spanList_ {};
|
||||
bool isActive_ = true;
|
||||
bool accessibilityVisible_ = true;
|
||||
bool clip_ = false;
|
||||
static const int backgroundImageMaxLength = 20;
|
||||
};
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
@ -138,6 +138,9 @@ 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);
|
||||
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);
|
||||
|
@ -35,7 +35,8 @@ 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", "accessibilityVisible",
|
||||
"allAttribute", "clip"};
|
||||
const std::vector<std::string> WINDOW_INFO_ATTRIBUTE_NAMES = {"isActive", "screenRect", "layer", "type",
|
||||
"rootElement", "isFocused", "windowId"};
|
||||
|
||||
@ -96,7 +97,10 @@ namespace {
|
||||
{"listItemIndex", &NAccessibilityElement::GetElementInfoListItemIndex},
|
||||
{"sideBarContainerStates", &NAccessibilityElement::GetElementInfoSideBarContainer},
|
||||
{"span", &NAccessibilityElement::GetElementInfoSpan},
|
||||
{"isActive", &NAccessibilityElement::GetElementInfoIsActive},
|
||||
{"accessibilityVisible", &NAccessibilityElement::GetElementInfoAccessibilityVisible},
|
||||
{"allAttribute", &NAccessibilityElement::GetElementInfoAllAttribute},
|
||||
{"clip", &NAccessibilityElement::GetElementInfoClip},
|
||||
};
|
||||
std::map<std::string, AttributeNamesFunc> windowInfoCompleteMap = {
|
||||
{"isActive", &NAccessibilityElement::GetWindowInfoIsActive},
|
||||
@ -1061,6 +1065,34 @@ 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::GetElementInfoAccessibilityVisible(
|
||||
NAccessibilityElementData *callbackInfo, napi_value &value)
|
||||
{
|
||||
if (!CheckElementInfoParameter(callbackInfo, value)) {
|
||||
return;
|
||||
}
|
||||
NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_int64(callbackInfo->env_,
|
||||
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));
|
||||
@ -1313,6 +1345,18 @@ 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;
|
||||
GetElementInfoSpan(callbackInfo, isActive);
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "isActive", isActive));
|
||||
|
||||
napi_value accessibilityVisible = nullptr;
|
||||
GetElementInfoSpan(callbackInfo, accessibilityVisible);
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "accessibilityVisible", accessibilityVisible));
|
||||
|
||||
napi_value clip = nullptr;
|
||||
GetElementInfoSpan(callbackInfo, clip);
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "clip", clip));
|
||||
}
|
||||
|
||||
void NAccessibilityElement::GetWindowInfoAllAttribute(NAccessibilityElementData *callbackInfo, napi_value &value)
|
||||
|
Loading…
Reference in New Issue
Block a user