!13010 无障碍performAction组件动作添加及同步supportAction

Merge pull request !13010 from limeng/pr_performAction_pattern
This commit is contained in:
openharmony_ci 2023-05-13 02:56:42 +00:00 committed by Gitee
commit 60f8136b66
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
50 changed files with 454 additions and 61 deletions

View File

@ -2196,13 +2196,8 @@ bool JsAccessibilityManager::AccessibilityActionEvent(const ActionType& action,
void JsAccessibilityManager::SendActionEvent(const Accessibility::ActionType& action, NodeId nodeId)
{
static std::unordered_map<Accessibility::ActionType, std::string> actionToStr {
{ Accessibility::ActionType::ACCESSIBILITY_ACTION_CLICK, DOM_CLICK },
{ Accessibility::ActionType::ACCESSIBILITY_ACTION_LONG_CLICK, DOM_LONG_PRESS },
{ Accessibility::ActionType::ACCESSIBILITY_ACTION_FOCUS, DOM_FOCUS },
{ Accessibility::ActionType::ACCESSIBILITY_ACTION_ACCESSIBILITY_FOCUS, ACCESSIBILITY_FOCUSED_EVENT },
{ Accessibility::ActionType::ACCESSIBILITY_ACTION_CLEAR_ACCESSIBILITY_FOCUS, ACCESSIBILITY_CLEAR_FOCUS_EVENT },
{ Accessibility::ActionType::ACCESSIBILITY_ACTION_SCROLL_FORWARD, SCROLL_END_EVENT },
{ Accessibility::ActionType::ACCESSIBILITY_ACTION_SCROLL_BACKWARD, SCROLL_END_EVENT },
};
if (actionToStr.find(action) == actionToStr.end()) {
return;

View File

@ -583,6 +583,7 @@ bool GestureEventHub::ActClick()
if (clickRecognizer && clickRecognizer->GetFingers() == 1 && clickRecognizer->GetCount() == 1) {
click = clickRecognizer->GetTapActionFunc();
click(info);
host->OnAccessibilityEvent(AccessibilityEventType::CLICK);
return true;
}
}
@ -624,6 +625,7 @@ bool GestureEventHub::ActLongClick()
if (longPressRecognizer && longPressRecognizer->GetFingers() == 1) {
click = longPressRecognizer->GetLongPressActionFunc();
click(info);
host->OnAccessibilityEvent(AccessibilityEventType::LONG_PRESS);
return true;
}
}

View File

@ -17,6 +17,12 @@
#include "base/utils/utils.h"
namespace OHOS::Ace::NG {
void GridItemPattern::OnModifyDone()
{
Pattern::OnModifyDone();
SetAccessibilityAction();
}
void GridItemPattern::MarkIsSelected(bool isSelected)
{
if (isSelected_ != isSelected) {
@ -33,4 +39,29 @@ void GridItemPattern::MarkIsSelected(bool isSelected)
}
}
}
void GridItemPattern::SetAccessibilityAction()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto accessibilityProperty = host->GetAccessibilityProperty<AccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetActionSelect([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (!pattern->Selectable()) {
return;
}
pattern->MarkIsSelected(true);
});
accessibilityProperty->SetActionClearSelection([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (!pattern->Selectable()) {
return;
}
pattern->MarkIsSelected(false);
});
}
} // namespace OHOS::Ace::NG

View File

@ -118,7 +118,10 @@ public:
return isSelected_;
}
protected:
void OnModifyDone() override;
private:
void SetAccessibilityAction();
RefPtr<ShallowBuilder> shallowBuilder_;
bool forceRebuild_ = false;
bool selectable_ = true;

View File

@ -126,6 +126,7 @@ void GridPattern::OnModifyDone()
if (focusHub) {
InitOnKeyEvent(focusHub);
}
SetAccessibilityAction();
}
void GridPattern::UninitMouseEvent()
@ -1125,4 +1126,28 @@ bool GridPattern::OutBoundaryCallback()
return IsOutOfBoundary();
}
void GridPattern::SetAccessibilityAction()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto accessibilityProperty = host->GetAccessibilityProperty<AccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetActionScrollForward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (!pattern->IsScrollable()) {
return;
}
pattern->ScrollPage(false);
});
accessibilityProperty->SetActionScrollBackward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (!pattern->IsScrollable()) {
return;
}
pattern->ScrollPage(true);
});
}
} // namespace OHOS::Ace::NG

View File

@ -196,6 +196,7 @@ private:
void MultiSelectWithoutKeyboard(const RectF& selectedZone);
void UpdateScrollBarOffset() override;
void UpdateRectOfDraggedInItem(int32_t insertIndex);
void SetAccessibilityAction();
GridLayoutInfo gridLayoutInfo_;
RefPtr<GridPositionController> positionController_;

View File

@ -174,6 +174,7 @@ void ListItemPattern::OnModifyDone()
}
panEvent_.Reset();
springController_.Reset();
SetAccessibilityAction();
}
V2::SwipeEdgeEffect ListItemPattern::GetEdgeEffect()
@ -421,4 +422,29 @@ void ListItemPattern::ToJsonValue(std::unique_ptr<JsonValue>& json) const
{
json->Put("selectable", selectable_);
}
void ListItemPattern::SetAccessibilityAction()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto listItemAccessibilityProperty = host->GetAccessibilityProperty<AccessibilityProperty>();
CHECK_NULL_VOID(listItemAccessibilityProperty);
listItemAccessibilityProperty->SetActionSelect([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (!pattern->Selectable()) {
return;
}
pattern->MarkIsSelected(true);
});
listItemAccessibilityProperty->SetActionClearSelection([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (!pattern->Selectable()) {
return;
}
pattern->MarkIsSelected(false);
});
}
} // namespace OHOS::Ace::NG

View File

@ -163,6 +163,7 @@ private:
void InitSwiperAction(bool axisChanged);
float GetFriction();
void StartSpringMotion(float start, float end, float velocity);
void SetAccessibilityAction();
RefPtr<ShallowBuilder> shallowBuilder_;

View File

@ -85,6 +85,7 @@ void ListPattern::OnModifyDone()
auto focusHub = host->GetFocusHub();
CHECK_NULL_VOID_NOLOG(focusHub);
InitOnKeyEvent(focusHub);
SetAccessibilityAction();
}
bool ListPattern::OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config)
@ -1085,4 +1086,29 @@ void ListPattern::ToJsonValue(std::unique_ptr<JsonValue>& json) const
{
json->Put("multiSelectable", multiSelectable_);
}
void ListPattern::SetAccessibilityAction()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto accessibilityProperty = host->GetAccessibilityProperty<AccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetActionScrollForward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (!pattern->IsScrollable()) {
return;
}
pattern->ScrollPage(false);
});
accessibilityProperty->SetActionScrollBackward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (!pattern->IsScrollable()) {
return;
}
pattern->ScrollPage(true);
});
}
} // namespace OHOS::Ace::NG

View File

@ -224,6 +224,7 @@ private:
void MultiSelectWithoutKeyboard(const RectF& selectedZone);
void DrivenRender(const RefPtr<LayoutWrapper>& layoutWrapper);
void SetAccessibilityAction();
RefPtr<ListContentModifier> listContentModifier_;

View File

@ -51,8 +51,5 @@ void MenuAccessibilityProperty::SetSpecificSupportAction()
}
}
}
AddSupportAction(AceAction::ACTION_SELECT);
AddSupportAction(AceAction::ACTION_CLEAR_SELECTION);
}
} // namespace OHOS::Ace::NG

View File

@ -40,6 +40,5 @@ bool MenuItemAccessibilityProperty::IsSelected() const
void MenuItemAccessibilityProperty::SetSpecificSupportAction()
{
AddSupportAction(AceAction::ACTION_SELECT);
AddSupportAction(AceAction::ACTION_CLEAR_SELECTION);
}
} // namespace OHOS::Ace::NG

View File

@ -145,6 +145,7 @@ void MenuItemPattern::OnModifyDone()
CHECK_NULL_VOID(rightRow);
UpdateText(rightRow, menuProperty, true);
UpdateIcon(rightRow, false);
SetAccessibilityAction();
}
RefPtr<FrameNode> MenuItemPattern::GetMenuWrapper()
@ -247,12 +248,15 @@ void MenuItemPattern::RegisterOnClick()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto hub = host->GetEventHub<MenuItemEventHub>();
auto event = [onChange = hub->GetOnChange(), selectedChangeEvent = hub->GetSelectedChangeEvent(),
weak = WeakClaim(this)](GestureEvent& /* info */) {
auto event = [weak = WeakClaim(this)](GestureEvent& /* info */) {
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
auto host = pattern->GetHost();
CHECK_NULL_VOID(host);
auto hub = host->GetEventHub<MenuItemEventHub>();
CHECK_NULL_VOID(hub);
auto onChange = hub->GetOnChange();
auto selectedChangeEvent = hub->GetSelectedChangeEvent();
pattern->SetChange();
if (selectedChangeEvent) {
LOGI("trigger onChangeEvent");
@ -262,8 +266,6 @@ void MenuItemPattern::RegisterOnClick()
LOGI("trigger onChange");
onChange(pattern->IsSelected());
}
auto host = pattern->GetHost();
CHECK_NULL_VOID(host);
host->OnAccessibilityEvent(AccessibilityEventType::SELECTED);
if (pattern->GetSubBuilder() != nullptr) {
@ -592,4 +594,36 @@ void MenuItemPattern::UpdateTextNodes()
CHECK_NULL_VOID(rightRow);
UpdateText(rightRow, menuProperty, true);
}
void MenuItemPattern::SetAccessibilityAction()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto accessibilityProperty = host->GetAccessibilityProperty<AccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetActionSelect([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
auto host = pattern->GetHost();
CHECK_NULL_VOID(host);
auto hub = host->GetEventHub<MenuItemEventHub>();
CHECK_NULL_VOID(hub);
auto onChange = hub->GetOnChange();
auto selectedChangeEvent = hub->GetSelectedChangeEvent();
pattern->SetChange();
if (selectedChangeEvent) {
selectedChangeEvent(pattern->IsSelected());
}
if (onChange) {
onChange(pattern->IsSelected());
}
if (pattern->GetSubBuilder() != nullptr) {
pattern->ShowSubMenu();
return;
}
pattern->CloseMenu();
});
}
} // namespace OHOS::Ace::NG

View File

@ -183,6 +183,7 @@ private:
OffsetF GetSubMenuPostion(const RefPtr<FrameNode>& targetNode);
void AddSelfHoverRegion(const RefPtr<FrameNode>& targetNode);
void SetAccessibilityAction();
std::list<TouchRegion> hoverRegions_;

View File

@ -24,6 +24,7 @@
#include "core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.h"
#include "core/components_ng/pattern/option/option_pattern.h"
#include "core/components_ng/pattern/option/option_view.h"
#include "core/components_ng/pattern/scroll/scroll_pattern.h"
#include "core/components_ng/pattern/text/text_layout_property.h"
#include "core/components_v2/inspector/inspector_constants.h"
#include "core/event/touch_event.h"
@ -121,6 +122,7 @@ void MenuPattern::OnModifyDone()
padding.SetEdges(CalcLength(theme->GetOutPadding()));
host->GetLayoutProperty()->UpdatePadding(padding);
}
SetAccessibilityAction();
}
// close menu on touch up
@ -452,4 +454,37 @@ void MenuPattern::InitTheme(const RefPtr<FrameNode>& host)
borderRadius.SetRadius(theme->GetMenuBorderRadius());
renderContext->UpdateBorderRadius(borderRadius);
}
void MenuPattern::SetAccessibilityAction()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto accessibilityProperty = host->GetAccessibilityProperty<AccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetActionScrollForward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
auto host = pattern->GetHost();
CHECK_NULL_VOID(host);
auto firstChild = DynamicCast<FrameNode>(host->GetChildAtIndex(0));
CHECK_NULL_VOID(firstChild);
if (firstChild && firstChild->GetTag() == V2::SCROLL_ETS_TAG) {
auto scrollPattern = firstChild->GetPattern<ScrollPattern>();
CHECK_NULL_VOID(scrollPattern);
scrollPattern->ScrollPage(false, true);
}
});
accessibilityProperty->SetActionScrollBackward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
auto host = pattern->GetHost();
CHECK_NULL_VOID(host);
auto firstChild = DynamicCast<FrameNode>(host->GetChildAtIndex(0));
CHECK_NULL_VOID(firstChild);
if (firstChild && firstChild->GetTag() == V2::SCROLL_ETS_TAG) {
auto scrollPattern = firstChild->GetPattern<ScrollPattern>();
CHECK_NULL_VOID(scrollPattern);
scrollPattern->ScrollPage(true, true);
}
});
}
} // namespace OHOS::Ace::NG

View File

@ -194,6 +194,7 @@ private:
void DisableTabInMenu();
RefPtr<FrameNode> GetMenuWrapper() const;
void SetAccessibilityAction();
RefPtr<ClickEvent> onClick_;
RefPtr<TouchEventImpl> onTouch_;

View File

@ -32,9 +32,15 @@ public:
std::string GetText() const override;
protected:
void SetSpecificSupportAction() override
{
AddSupportAction(AceAction::ACTION_SELECT);
}
private:
ACE_DISALLOW_COPY_AND_MOVE(OptionAccessibilityProperty);
};
} // namespace OHOS::Ace::NG
#endif
#endif

View File

@ -60,6 +60,7 @@ void OptionPattern::OnModifyDone()
textProperty->UpdateTextColor(selectTheme_->GetDisabledMenuFontColor());
text_->MarkModifyDone();
}
SetAccessibilityAction();
}
void OptionPattern::OnSelectProcess()
@ -447,4 +448,17 @@ void OptionPattern::UpdateIcon(const std::string& src)
icon_->MarkModifyDone();
icon_->MarkDirtyNode();
}
void OptionPattern::SetAccessibilityAction()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto accessibilityProperty = host->GetAccessibilityProperty<AccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetActionSelect([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
pattern->OnSelectProcess();
});
}
} // namespace OHOS::Ace::NG

View File

@ -173,6 +173,7 @@ private:
bool OnKeyEvent(const KeyEvent& event);
void OnSelectProcess();
void SetAccessibilityAction();
std::optional<Color> bgColor_;

View File

@ -81,6 +81,7 @@ void DatePickerColumnPattern::OnModifyDone()
pressColor_ = theme->GetPressColor();
hoverColor_ = theme->GetHoverColor();
InitMouseAndPressEvent();
SetAccessibilityAction();
}
void DatePickerColumnPattern::InitMouseAndPressEvent()
@ -754,4 +755,43 @@ bool DatePickerColumnPattern::CanMove(bool isDown) const
int nextVirtualIndex = isDown ? currentIndex + 1 : currentIndex - 1;
return nextVirtualIndex >= 0 && nextVirtualIndex < totalOptionCount;
}
void DatePickerColumnPattern::SetAccessibilityAction()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto accessibilityProperty = host->GetAccessibilityProperty<AccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetActionScrollForward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (!pattern->CanMove(true)) {
return;
}
CHECK_NULL_VOID(pattern->animationCreated_);
pattern->InnerHandleScroll(true);
pattern->fromController_->ClearInterpolators();
pattern->fromController_->AddInterpolator(pattern->fromTopCurve_);
pattern->fromController_->Play();
auto frameNode = pattern->GetHost();
CHECK_NULL_VOID(frameNode);
frameNode->OnAccessibilityEvent(AccessibilityEventType::SCROLL_END);
});
accessibilityProperty->SetActionScrollBackward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (!pattern->CanMove(false)) {
return;
}
CHECK_NULL_VOID(pattern->animationCreated_);
pattern->InnerHandleScroll(false);
pattern->fromController_->ClearInterpolators();
pattern->fromController_->AddInterpolator(pattern->fromBottomCurve_);
pattern->fromController_->Play();
auto frameNode = pattern->GetHost();
CHECK_NULL_VOID(frameNode);
frameNode->OnAccessibilityEvent(AccessibilityEventType::SCROLL_END);
});
}
} // namespace OHOS::Ace::NG

View File

@ -221,6 +221,7 @@ private:
uint32_t index, uint32_t showCount, bool isDown, double scale);
void FlushAnimationTextProperties(bool isDown);
Dimension LinearFontSize(const Dimension& startFontSize, const Dimension& endFontSize, double percent);
void SetAccessibilityAction();
float localDownDistance_ = 0.0f;
RefPtr<TouchEventImpl> touchListener_;
RefPtr<InputEvent> mouseEvent_;

View File

@ -101,6 +101,7 @@ void RefreshPattern::OnModifyDone()
LoadingProgressExit();
}
}
SetAccessibilityAction();
}
void RefreshPattern::CheckCoordinationEvent()
@ -802,4 +803,25 @@ void RefreshPattern::UpdateLoadingMarginTop(float top)
marginProperty.top = CalcLength(top);
progressLayoutProperty->UpdateMargin(marginProperty);
}
void RefreshPattern::SetAccessibilityAction()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto accessibilityProperty = host->GetAccessibilityProperty<AccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetActionScrollForward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (pattern->IsRefreshing()) {
return;
}
pattern->HandleDragStart();
for (float delta = 0.0f; delta < MAX_SCROLL_DISTANCE.ConvertToPx();
delta += TRIGGER_LOADING_DISTANCE.ConvertToPx()) {
pattern->HandleDragUpdate(delta);
}
pattern->HandleDragEnd();
});
}
} // namespace OHOS::Ace::NG

View File

@ -128,6 +128,7 @@ private:
void ScrollableNodeResetAnimation();
void OnAppearAnimationFinish();
void UpdateLoadingMarginTop(float top);
void SetAccessibilityAction();
RefreshStatus refreshStatus_ = RefreshStatus::INACTIVE;
RefPtr<PanEvent> panEvent_;
OffsetF scrollOffset_;

View File

@ -86,6 +86,7 @@ void ScrollPattern::OnModifyDone()
}
SetEdgeEffect(layoutProperty->GetEdgeEffect().value_or(EdgeEffect::NONE));
SetScrollBar(paintProperty->GetScrollBarProperty());
SetAccessibilityAction();
}
void ScrollPattern::RegisterScrollEventTask()
@ -542,4 +543,26 @@ void ScrollPattern::UpdateScrollBarOffset()
UpdateScrollBarRegion(-currentOffset_, estimatedHeight, size, Offset(0.0, 0.0));
}
void ScrollPattern::SetAccessibilityAction()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto accessibilityProperty = host->GetAccessibilityProperty<AccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetActionScrollForward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (pattern->IsScrollable() && pattern->GetScrollableDistance() > 0.0f) {
pattern->ScrollPage(false, true);
}
});
accessibilityProperty->SetActionScrollBackward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (pattern->IsScrollable() && pattern->GetScrollableDistance() > 0.0f) {
pattern->ScrollPage(true, true);
}
});
}
} // namespace OHOS::Ace::NG

View File

@ -189,6 +189,7 @@ private:
void UpdateScrollBarOffset() override;
void FireOnScrollStart();
void FireOnScrollStop();
void SetAccessibilityAction();
RefPtr<Animator> animator_;
RefPtr<ScrollPositionController> positionController_;

View File

@ -110,6 +110,7 @@ void ScrollBarLayoutAlgorithm::Layout(LayoutWrapper* layoutWrapper)
auto scrollBarPattern = AceType::DynamicCast<ScrollBarPattern>(layoutWrapper->GetHostNode()->GetPattern());
auto controlDistance = scrollBarPattern->GetControlDistance();
auto scrollOffset = scrollBarPattern->GetScrollOffset();
scrollBarPattern->SetChildOffset(GetMainAxisSize(childSize, axis));
float currentOffset = 0.0f;
if (!NearZero(controlDistance)) {
currentOffset = scrollOffset * scrollableDistance_ / controlDistance;

View File

@ -96,6 +96,7 @@ void ScrollBarPattern::OnModifyDone()
scrollableEvent_->SetScrollPositionCallback(std::move(offsetTask));
scrollableEvent_->SetScrollEndCallback(std::move(scrollEndTask));
gestureHub->AddScrollableEvent(scrollableEvent_);
SetAccessibilityAction();
}
bool ScrollBarPattern::OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config)
@ -200,4 +201,36 @@ void ScrollBarPattern::SetOpacity(uint8_t value)
host->MarkNeedRenderOnly();
}
void ScrollBarPattern::SetAccessibilityAction()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto accessibilityProperty = host->GetAccessibilityProperty<AccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetActionScrollForward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (pattern->GetAxis() == Axis::NONE || pattern->GetScrollableDistance() == 0.0f) {
return;
}
auto source = pattern->GetCurrentPosition();
pattern->UpdateCurrentOffset(pattern->GetChildOffset(), source);
auto frameNode = pattern->GetHost();
CHECK_NULL_VOID(frameNode);
frameNode->OnAccessibilityEvent(AccessibilityEventType::SCROLL_END);
});
accessibilityProperty->SetActionScrollBackward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
if (pattern->GetAxis() == Axis::NONE || pattern->GetScrollableDistance() == 0.0f) {
return;
}
auto source = pattern->GetCurrentPosition();
pattern->UpdateCurrentOffset(-pattern->GetChildOffset(), source);
auto frameNode = pattern->GetHost();
CHECK_NULL_VOID(frameNode);
frameNode->OnAccessibilityEvent(AccessibilityEventType::SCROLL_END);
});
}
} // namespace OHOS::Ace::NG

View File

@ -125,11 +125,22 @@ public:
void SetOpacity(uint8_t value);
void SendAccessibilityEvent(AccessibilityEventType eventType);
void SetChildOffset(float childOffset)
{
childOffset_ = childOffset;
};
float GetChildOffset() const
{
return childOffset_;
};
private:
void OnModifyDone() override;
void OnAttachToFrameNode() override;
bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
void ValidateOffset(int32_t source);
void SetAccessibilityAction();
RefPtr<Animator> scrollEndAnimator_;
RefPtr<ScrollBarProxy> scrollBarProxy_;
@ -141,6 +152,8 @@ private:
float scrollableDistance_ = 0.0f;
float controlDistance_ = 0.0f;
float scrollOffset_ = 0.0f;
float childOffset_ = 0.0f;
};
} // namespace OHOS::Ace::NG

View File

@ -41,13 +41,6 @@ public:
int32_t GetCollectionItemCounts() const override;
protected:
void SetSpecificSupportAction() override
{
AddSupportAction(AceAction::ACTION_SELECT);
AddSupportAction(AceAction::ACTION_CLEAR_SELECTION);
}
private:
ACE_DISALLOW_COPY_AND_MOVE(SelectAccessibilityProperty);
};

View File

@ -105,8 +105,5 @@ void SwiperAccessibilityProperty::SetSpecificSupportAction()
AddSupportAction(AceAction::ACTION_SCROLL_BACKWARD);
}
}
AddSupportAction(AceAction::ACTION_SELECT);
AddSupportAction(AceAction::ACTION_CLEAR_SELECTION);
}
} // namespace OHOS::Ace::NG

View File

@ -166,6 +166,7 @@ void SwiperPattern::OnModifyDone()
} else {
translateTask_.Cancel();
}
SetAccessibilityAction();
}
void SwiperPattern::FlushFocus(const RefPtr<FrameNode>& curShowFrame)
@ -1499,4 +1500,35 @@ void SwiperPattern::SaveArrowProperty(const RefPtr<FrameNode>& arrowNode)
arrowLayoutProperty->UpdateArrowColor(layoutProperty->GetArrowColorValue());
arrowLayoutProperty->UpdateIsSiderMiddle(layoutProperty->GetIsSiderMiddleValue());
}
void SwiperPattern::SetAccessibilityAction()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto accessibilityProperty = host->GetAccessibilityProperty<AccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetActionScrollForward(
[weakPtr = WeakClaim(this), accessibility = WeakClaim(RawPtr(accessibilityProperty))]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
const auto& accessibilityProperty = accessibility.Upgrade();
CHECK_NULL_VOID(accessibilityProperty);
if (!accessibilityProperty->IsScrollable()) {
return;
}
pattern->ShowNext();
});
accessibilityProperty->SetActionScrollBackward(
[weakPtr = WeakClaim(this), accessibility = WeakClaim(RawPtr(accessibilityProperty))]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
const auto& accessibilityProperty = accessibility.Upgrade();
CHECK_NULL_VOID(accessibilityProperty);
if (!accessibilityProperty->IsScrollable()) {
return;
}
pattern->ShowPrevious();
});
}
} // namespace OHOS::Ace::NG

View File

@ -436,6 +436,7 @@ private:
bool IsShowArrow() const;
void SaveArrowProperty(const RefPtr<FrameNode>& arrowNode);
int32_t ComputeLoadCount(int32_t cacheCount);
void SetAccessibilityAction();
RefPtr<PanEvent> panEvent_;
RefPtr<TouchEventImpl> touchEvent_;

View File

@ -405,6 +405,7 @@ void TabBarPattern::OnModifyDone()
auto focusHub = host->GetFocusHub();
CHECK_NULL_VOID(focusHub);
InitOnKeyEvent(focusHub);
SetAccessibilityAction();
auto removeEventCallback = [weak = WeakClaim(this)]() {
auto tabBarPattern = weak.Upgrade();
@ -1411,4 +1412,43 @@ bool TabBarPattern::IsOutOfBoundary()
bool outOfEnd = LessNotEqual(tabItemOffsets_.back().GetX(), mainSize) && Negative(tabItemOffsets_.front().GetX());
return outOfStart || outOfEnd;
}
void TabBarPattern::SetAccessibilityAction()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto accessibilityProperty = host->GetAccessibilityProperty<AccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetActionScrollForward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
auto tabBarLayoutProperty = pattern->GetLayoutProperty<TabBarLayoutProperty>();
CHECK_NULL_VOID(tabBarLayoutProperty);
auto frameNode = pattern->GetHost();
CHECK_NULL_VOID(frameNode);
if (tabBarLayoutProperty->GetTabBarMode().value_or(TabBarMode::FIXED) == TabBarMode::SCROLLABLE &&
frameNode->TotalChildCount() > 1) {
auto index = pattern->GetIndicator() + 1;
pattern->PlayTabBarTranslateAnimation(index);
pattern->FocusIndexChange(index);
frameNode->OnAccessibilityEvent(AccessibilityEventType::SCROLL_END);
}
});
accessibilityProperty->SetActionScrollBackward([weakPtr = WeakClaim(this)]() {
const auto& pattern = weakPtr.Upgrade();
CHECK_NULL_VOID(pattern);
auto tabBarLayoutProperty = pattern->GetLayoutProperty<TabBarLayoutProperty>();
CHECK_NULL_VOID(tabBarLayoutProperty);
auto frameNode = pattern->GetHost();
CHECK_NULL_VOID(frameNode);
if (tabBarLayoutProperty->GetTabBarMode().value_or(TabBarMode::FIXED) == TabBarMode::SCROLLABLE &&
frameNode->TotalChildCount() > 1) {
auto index = pattern->GetIndicator() - 1;
pattern->PlayTabBarTranslateAnimation(index);
pattern->FocusIndexChange(index);
frameNode->OnAccessibilityEvent(AccessibilityEventType::SCROLL_END);
}
});
}
} // namespace OHOS::Ace::NG

View File

@ -320,6 +320,7 @@ private:
void SetEdgeEffect(const RefPtr<GestureEventHub>& gestureHub);
void SetEdgeEffectCallback(const RefPtr<ScrollEdgeEffect>& scrollEffect);
bool IsOutOfBoundary();
void SetAccessibilityAction();
RefPtr<ClickEvent> clickEvent_;
RefPtr<TouchEventImpl> touchEvent_;

View File

@ -76,12 +76,12 @@ void TextAccessibilityProperty::SetSpecificSupportAction()
CHECK_NULL_VOID(textLayoutProperty);
if (textLayoutProperty->GetCopyOptionValue(CopyOptions::None) != CopyOptions::None) {
AddSupportAction(AceAction::ACTION_COPY);
AddSupportAction(AceAction::ACTION_SELECT);
AddSupportAction(AceAction::ACTION_SET_SELECTION);
AddSupportAction(AceAction::ACTION_CLEAR_SELECTION);
}
AddSupportAction(AceAction::ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
AddSupportAction(AceAction::ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
if (actionSelectImpl_) {
AddSupportAction(AceAction::ACTION_SELECT);
AddSupportAction(AceAction::ACTION_CLEAR_SELECTION);
}
}
} // namespace OHOS::Ace::NG

View File

@ -176,6 +176,7 @@ void TextFieldAccessibilityProperty::SetSpecificSupportAction()
CHECK_NULL_VOID(textFieldPattern);
if (textFieldPattern->AllowCopy()) {
AddSupportAction(AceAction::ACTION_COPY);
AddSupportAction(AceAction::ACTION_CUT);
}
if (IsScrollable()) {
if (!textFieldPattern->IsAtTop()) {
@ -187,8 +188,6 @@ void TextFieldAccessibilityProperty::SetSpecificSupportAction()
}
AddSupportAction(AceAction::ACTION_PASTE);
AddSupportAction(AceAction::ACTION_CUT);
AddSupportAction(AceAction::ACTION_SELECT);
AddSupportAction(AceAction::ACTION_SET_SELECTION);
AddSupportAction(AceAction::ACTION_CLEAR_SELECTION);
AddSupportAction(AceAction::ACTION_SET_TEXT);

View File

@ -125,6 +125,7 @@ ohos_unittest("custom_dialog_test_ng") {
"$ace_root/frameworks/core/animation/test/mock/mock_scheduler.cpp",
"$ace_root/frameworks/core/common/test/mock/mock_ace_application_info.cpp",
"$ace_root/frameworks/core/components_ng/test/event/mock/mock_touch_event.cpp",
"$ace_root/frameworks/core/components_ng/test/event/scrollable_event/mock_scrollable.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/animation/mock_geometry_transition.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/base/mock_localization.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/base/mock_view_stack_processor.cpp",

View File

@ -74,6 +74,7 @@ ohos_unittest("menu_test_ng") {
"$ace_root/frameworks/core/animation/test/mock/mock_scheduler.cpp",
"$ace_root/frameworks/core/components/test/unittest/mock/mock_icon_theme.cpp",
"$ace_root/frameworks/core/components_ng/test/event/mock/mock_long_press_event.cpp",
"$ace_root/frameworks/core/components_ng/test/event/scrollable_event/mock_scrollable.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/base/mock_stage_manager.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_loading_context.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_painter.cpp",

View File

@ -110,8 +110,6 @@ HWTEST_F(MenuAccessibilityPropertyTestNg, MenuAccessibilityPropertyGetSupportAct
uint64_t actions = 0, expectActions = 0;
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SCROLL_FORWARD);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SCROLL_BACKWARD);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SELECT);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_CLEAR_SELECTION);
for (auto action : supportAceActions) {
actions |= 1UL << static_cast<uint32_t>(action);
}

View File

@ -114,7 +114,6 @@ HWTEST_F(MenuItemAccessibilityPropertyTestNg, MenuItemAccessibilityPropertyGetSu
std::unordered_set<AceAction> supportAceActions = menuItemAccessibilityProperty_->GetSupportAction();
uint64_t actions = 0, expectActions = 0;
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SELECT);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_CLEAR_SELECTION);
for (auto action : supportAceActions) {
actions |= 1UL << static_cast<uint32_t>(action);
}

View File

@ -89,4 +89,22 @@ HWTEST_F(OptionAccessibilityPropertyTestNg, OptionAccessibilityPropertyGetText00
textLayoutProperty->UpdateContent(OPTION_TEST_TEXT);
EXPECT_EQ(optionAccessibilityProperty_->GetText(), OPTION_TEST_TEXT);
}
/**
* @tc.name: OptionAccessibilityPropertyGetSupportAction001
* @tc.desc: Test GetSupportAction of option.
* @tc.type: FUNC
*/
HWTEST_F(OptionAccessibilityPropertyTestNg, OptionAccessibilityPropertyGetSupportAction001, TestSize.Level1)
{
optionAccessibilityProperty_->ResetSupportAction();
std::unordered_set<AceAction> supportAceActions = optionAccessibilityProperty_->GetSupportAction();
uint64_t actions = 0, expectActions = 0;
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SELECT);
for (auto action : supportAceActions) {
actions |= 1UL << static_cast<uint32_t>(action);
}
EXPECT_EQ(actions, expectActions);
}
} // namespace OHOS::Ace::NG

View File

@ -62,6 +62,7 @@ ohos_unittest("overlay_manager_test_ng") {
"$ace_root/frameworks/core/components_ng/pattern/text/text_accessibility_property.cpp",
"$ace_root/frameworks/core/components_ng/pattern/text/text_layout_property.cpp",
"$ace_root/frameworks/core/components_ng/pattern/text/text_paint_method.cpp",
"$ace_root/frameworks/core/components_ng/test/event/scrollable_event/mock_scrollable.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/pattern/flex/mock_flex_layout_algorithm.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/pattern/text/mock_text_layout_algorithm.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/pattern/text/mock_text_pattern.cpp",

View File

@ -135,6 +135,7 @@ ohos_unittest("select_pattern_test_ng") {
"$ace_root/frameworks/core/common/test/mock/mock_ace_application_info.cpp",
"$ace_root/frameworks/core/components/test/unittest/mock/mock_icon_theme.cpp",
"$ace_root/frameworks/core/components_ng/test/event/mock/mock_long_press_event.cpp",
"$ace_root/frameworks/core/components_ng/test/event/scrollable_event/mock_scrollable.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/animation/mock_geometry_transition.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/base/mock_localization.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/base/mock_stage_manager.cpp",

View File

@ -164,24 +164,4 @@ HWTEST_F(SelectAccessibilityPropertyTestNg, SelectAccessibilityPropertyGetCollec
}
EXPECT_EQ(selectAccessibilityProperty_->GetCollectionItemCounts(), CURRENT_INDEX);
}
/**
* @tc.name: SelectAccessibilityPropertyGetSupportAction001
* @tc.desc: Test GetSupportAction of select.
* @tc.type: FUNC
*/
HWTEST_F(SelectAccessibilityPropertyTestNg, SelectAccessibilityPropertyGetSupportAction001, TestSize.Level1)
{
InitSelectTestNg();
selectAccessibilityProperty_->ResetSupportAction();
std::unordered_set<AceAction> supportAceActions = selectAccessibilityProperty_->GetSupportAction();
uint64_t actions = 0, expectActions = 0;
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SELECT);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_CLEAR_SELECTION);
for (auto action : supportAceActions) {
actions |= 1UL << static_cast<uint32_t>(action);
}
EXPECT_EQ(actions, expectActions);
}
} // namespace OHOS::Ace::NG

View File

@ -28,6 +28,7 @@ ohos_unittest("select_overlay_test_ng") {
"$ace_root/frameworks/core/components_ng/pattern/scroll_bar/proxy/scroll_bar_proxy.cpp",
"$ace_root/frameworks/core/components_ng/pattern/scroll_bar/scroll_bar_accessibility_property.cpp",
"$ace_root/frameworks/core/components_ng/pattern/scroll_bar/scroll_bar_pattern.cpp",
"$ace_root/frameworks/core/components_ng/test/event/scrollable_event/mock_scrollable.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_loading_context.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_painter.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_source_info.cpp",

View File

@ -234,8 +234,6 @@ HWTEST_F(SwiperAccessibilityPropertyTestNg, SwiperAccessibilityPropertyGetSuppor
uint64_t actions = 0, expectActions = 0;
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SCROLL_FORWARD);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SCROLL_BACKWARD);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SELECT);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_CLEAR_SELECTION);
for (auto action : supportAceActions) {
actions |= 1UL << static_cast<uint32_t>(action);
}

View File

@ -2461,11 +2461,8 @@ HWTEST_F(TextTestNg, TextAccessibilityPropertyGetSupportAction001, TestSize.Leve
std::unordered_set<AceAction> supportAceActions = textAccessibilityProperty->GetSupportAction();
uint64_t actions = 0, expectActions = 0;
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_COPY);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SELECT);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SET_SELECTION);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_CLEAR_SELECTION);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
for (auto action : supportAceActions) {
actions |= 1UL << static_cast<uint32_t>(action);
}

View File

@ -91,6 +91,7 @@ ohos_unittest("textfield_test_ng") {
"$ace_root/frameworks/core/animation/test/mock/mock_animator.cpp",
"$ace_root/frameworks/core/components_ng/test/event/mock/mock_long_press_event.cpp",
"$ace_root/frameworks/core/components_ng/test/event/mock/mock_scrollable_event.cpp",
"$ace_root/frameworks/core/components_ng/test/event/scrollable_event/mock_scrollable.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_loading_context.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_source_info.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/manager/drag_drop/mock_drag_drop_proxy.cpp",

View File

@ -2436,7 +2436,6 @@ HWTEST_F(TextFieldPatternTestNg, TextFieldAccessibilityPropertyGetSupportAction0
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_COPY);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_PASTE);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_CUT);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SELECT);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SET_SELECTION);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_CLEAR_SELECTION);
expectActions |= 1UL << static_cast<uint32_t>(AceAction::ACTION_SET_TEXT);

View File

@ -228,6 +228,7 @@ ohos_unittest("pipeline_context_test_ng") {
"$ace_root/frameworks/core/common/test/mock/mock_layout_inspector.cpp",
"$ace_root/frameworks/core/common/test/mock/mock_text_editing_value.cpp",
"$ace_root/frameworks/core/common/test/mock/mock_watch_dog.cpp",
"$ace_root/frameworks/core/components_ng/test/event/scrollable_event/mock_scrollable.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/base/mock_localization.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_cache.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_loading_context.cpp",