1 /* 2 * Copyright (c) 2022-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_COMPONENTS_NG_PROPERTIES_ACCESSIBILITY_PROPERTY_H 17 #define FOUNDATION_ACE_FRAMEWORKS_COMPONENTS_NG_PROPERTIES_ACCESSIBILITY_PROPERTY_H 18 19 #include <cstdint> 20 #include <string> 21 #include <unordered_set> 22 23 #include "base/memory/ace_type.h" 24 #include "interfaces/native/native_type.h" 25 #include "core/accessibility/accessibility_utils.h" 26 #include "core/components_ng/base/inspector_filter.h" 27 #include "core/components_ng/base/ui_node.h" 28 29 namespace OHOS::Accessibility { 30 class ExtraElementInfo; 31 } 32 33 namespace OHOS::Ace::NG { 34 struct WindowSceneInfo { 35 int32_t left = 0; 36 int32_t top = 0; 37 int32_t innerWindowId = -1; 38 float_t scaleX = 1.0f; 39 float_t scaleY = 1.0f; 40 }; 41 using ActionNoParam = std::function<void()>; 42 using ActionSetTextImpl = std::function<void(const std::string&)>; 43 using ActionScrollForwardImpl = ActionNoParam; 44 using ActionScrollForwardWithParamImpl = std::function<void(AccessibilityScrollType scrollType)>;; 45 using ActionScrollBackwardImpl = ActionNoParam; 46 using ActionScrollBackwardWithParamImpl = std::function<void(AccessibilityScrollType scrollType)>;; 47 using ActionSetSelectionImpl = std::function<void(int32_t start, int32_t end, bool isForward)>; 48 using ActionCopyImpl = ActionNoParam; 49 using ActionCutImpl = ActionNoParam; 50 using ActionPasteImpl = ActionNoParam; 51 using ActionSelectImpl = ActionNoParam; 52 using ActionClearSelectionImpl = ActionNoParam; 53 using ActionMoveTextImpl = std::function<void(int32_t moveUnit, bool forward)>; 54 using ActionSetCursorIndexImpl = std::function<void(int32_t index)>; 55 using ActionExecSubComponentImpl = std::function<bool(int32_t spanId)>; 56 using ActionGetCursorIndexImpl = std::function<int32_t(void)>; 57 using ActionClickImpl = ActionNoParam; 58 using ActionLongClickImpl = ActionNoParam; 59 using ActionsImpl = std::function<void((uint32_t actionType))>; 60 using GetRelatedElementInfoImpl = std::function<void(Accessibility::ExtraElementInfo& extraElementInfo)>; 61 using OnAccessibilityFocusCallbackImpl = std::function<void((bool isFocus))>; 62 63 using GetWindowScenePositionImpl = std::function<void((WindowSceneInfo& windowSceneInfo))>; 64 65 using OnAccessibilityHoverConsumeCheckImpl = std::function<bool(const NG::PointF& point)>; 66 67 class FrameNode; 68 using AccessibilityHoverTestPath = std::vector<RefPtr<FrameNode>>; 69 70 class ACE_FORCE_EXPORT AccessibilityProperty : public virtual AceType { 71 DECLARE_ACE_TYPE(AccessibilityProperty, AceType); 72 73 public: 74 AccessibilityProperty() = default; 75 76 ~AccessibilityProperty() override = default; 77 78 virtual std::string GetText() const; 79 80 virtual std::string GetGroupText(bool forceGetChildren = false) const; 81 82 virtual std::string GetGroupPreferAccessibilityText(bool forceGetChildren = false) const; 83 SetText(const std::string & text)84 virtual void SetText(const std::string& text) 85 { 86 propText_ = text; 87 } 88 IsCheckable()89 virtual bool IsCheckable() const 90 { 91 return false; 92 } 93 IsChecked()94 virtual bool IsChecked() const 95 { 96 return false; 97 } 98 IsSelected()99 virtual bool IsSelected() const 100 { 101 return false; 102 } 103 IsPassword()104 virtual bool IsPassword() const 105 { 106 return false; 107 } 108 IsEditable()109 virtual bool IsEditable() const 110 { 111 return false; 112 } 113 IsMultiLine()114 virtual bool IsMultiLine() const 115 { 116 return false; 117 } 118 IsDeletable()119 virtual bool IsDeletable() const 120 { 121 return false; 122 } 123 IsHint()124 virtual bool IsHint() const 125 { 126 return false; 127 } 128 IsScrollable()129 virtual bool IsScrollable() const 130 { 131 return false; 132 } 133 GetCurrentIndex()134 virtual int32_t GetCurrentIndex() const 135 { 136 return -1; 137 } 138 GetBeginIndex()139 virtual int32_t GetBeginIndex() const 140 { 141 return -1; 142 } 143 GetEndIndex()144 virtual int32_t GetEndIndex() const 145 { 146 return -1; 147 } 148 ToJsonValue(std::unique_ptr<JsonValue> & json,const InspectorFilter & filter)149 virtual void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const 150 { 151 json->PutFixedAttr("scrollable", IsScrollable(), filter, FIXED_ATTR_SCROLLABLE); 152 json->PutExtAttr("accessibilityLevel", GetAccessibilityLevel().c_str(), filter); 153 json->PutExtAttr("accessibilityGroup", IsAccessibilityGroup(), filter); 154 json->PutExtAttr("accessibilityVirtualNode", HasAccessibilityVirtualNode(), filter); 155 json->PutExtAttr("accessibilityText", GetAccessibilityText().c_str(), filter); 156 json->PutExtAttr("accessibilityTextHint", GetTextType().c_str(), filter); 157 json->PutExtAttr("accessibilityDescription", GetAccessibilityDescription().c_str(), filter); 158 } 159 FromJson(const std::unique_ptr<JsonValue> & json)160 virtual void FromJson(const std::unique_ptr<JsonValue>& json) {} 161 HasRange()162 virtual bool HasRange() const 163 { 164 return false; 165 } 166 HasSubComponent()167 virtual bool HasSubComponent() const 168 { 169 return false; 170 } 171 GetSubComponentInfo(std::vector<SubComponentInfo> & subComponentInfos)172 virtual void GetSubComponentInfo(std::vector<SubComponentInfo>& subComponentInfos) const {} 173 GetAccessibilityValue()174 virtual AccessibilityValue GetAccessibilityValue() const 175 { 176 return AccessibilityValue(); 177 } 178 SetHost(const WeakPtr<FrameNode> & host)179 void SetHost(const WeakPtr<FrameNode>& host) 180 { 181 host_ = host; 182 } 183 GetHintText()184 virtual std::string GetHintText() const 185 { 186 return ""; 187 } 188 GetTextLengthLimit()189 virtual int32_t GetTextLengthLimit() const 190 { 191 return -1; 192 } 193 GetCollectionInfo()194 virtual AceCollectionInfo GetCollectionInfo() const 195 { 196 return AceCollectionInfo(); 197 } 198 GetCollectionItemInfo()199 virtual AceCollectionItemInfo GetCollectionItemInfo() const 200 { 201 return AceCollectionItemInfo(); 202 } 203 GetErrorText()204 virtual std::string GetErrorText() const 205 { 206 return ""; 207 } 208 GetTextSelectionStart()209 virtual int32_t GetTextSelectionStart() const 210 { 211 return 0; 212 } 213 GetTextSelectionEnd()214 virtual int32_t GetTextSelectionEnd() const 215 { 216 return 0; 217 } 218 GetTextInputType()219 virtual AceTextCategory GetTextInputType() const 220 { 221 return AceTextCategory::INPUT_TYPE_DEFAULT; 222 } 223 GetCollectionItemCounts()224 virtual int32_t GetCollectionItemCounts() const 225 { 226 return 0; 227 } 228 GetContentInvalid()229 virtual bool GetContentInvalid() const 230 { 231 return true; 232 } 233 234 virtual float GetScrollOffSet() const; 235 AddSupportAction(AceAction action)236 void AddSupportAction(AceAction action) 237 { 238 supportActions_ |= (1UL << static_cast<uint32_t>(action)); 239 } 240 241 std::unordered_set<AceAction> GetSupportAction() const; 242 ResetSupportAction()243 void ResetSupportAction() 244 { 245 supportActions_ = 0; 246 SetSpecificSupportAction(); 247 }; 248 SetActionSetText(const ActionSetTextImpl & actionSetTextImpl)249 void SetActionSetText(const ActionSetTextImpl& actionSetTextImpl) 250 { 251 actionSetTextImpl_ = actionSetTextImpl; 252 } 253 ActActionSetText(const std::string & text)254 bool ActActionSetText(const std::string& text) 255 { 256 if (actionSetTextImpl_) { 257 actionSetTextImpl_(text); 258 return true; 259 } 260 return false; 261 } 262 SetActionSetSelection(const ActionSetSelectionImpl & actionSetSelection)263 void SetActionSetSelection(const ActionSetSelectionImpl& actionSetSelection) 264 { 265 actionSetSelectionImpl_ = actionSetSelection; 266 } 267 268 bool ActActionSetSelection(int32_t start, int32_t end, bool isForward = false) 269 { 270 if (actionSetSelectionImpl_) { 271 actionSetSelectionImpl_(start, end, isForward); 272 return true; 273 } 274 return false; 275 } 276 SetActionSetIndex(const ActionSetCursorIndexImpl & actionSetCursorIndexImpl)277 void SetActionSetIndex(const ActionSetCursorIndexImpl& actionSetCursorIndexImpl) 278 { 279 actionSetCursorIndexImpl_ = actionSetCursorIndexImpl; 280 } 281 ActActionSetIndex(int32_t index)282 bool ActActionSetIndex(int32_t index) 283 { 284 if (actionSetCursorIndexImpl_) { 285 actionSetCursorIndexImpl_(index); 286 return true; 287 } 288 return false; 289 } 290 SetActionExecSubComponent(const ActionExecSubComponentImpl & actionExecSubComponentImpl)291 void SetActionExecSubComponent(const ActionExecSubComponentImpl& actionExecSubComponentImpl) 292 { 293 actionExecSubComponentImpl_ = actionExecSubComponentImpl; 294 } 295 ActActionExecSubComponent(int32_t spanId)296 bool ActActionExecSubComponent(int32_t spanId) 297 { 298 if (actionExecSubComponentImpl_) { 299 return actionExecSubComponentImpl_(spanId); 300 } 301 return false; 302 } 303 SetActionGetIndex(const ActionGetCursorIndexImpl & actionGetCursorIndexImpl)304 void SetActionGetIndex(const ActionGetCursorIndexImpl& actionGetCursorIndexImpl) 305 { 306 actionGetCursorIndexImpl_ = actionGetCursorIndexImpl; 307 } 308 ActActionGetIndex()309 int32_t ActActionGetIndex() 310 { 311 if (actionGetCursorIndexImpl_) { 312 return actionGetCursorIndexImpl_(); 313 } 314 return -1; 315 } 316 SetActionMoveText(const ActionMoveTextImpl & actionMoveText)317 void SetActionMoveText(const ActionMoveTextImpl& actionMoveText) 318 { 319 actionMoveTextImpl_ = actionMoveText; 320 } 321 ActActionMoveText(int32_t moveUnit,bool forward)322 bool ActActionMoveText(int32_t moveUnit, bool forward) 323 { 324 if (actionMoveTextImpl_) { 325 actionMoveTextImpl_(moveUnit, forward); 326 return true; 327 } 328 return false; 329 } 330 SetActionScrollForward(const ActionScrollForwardImpl & actionScrollForwardImpl)331 void SetActionScrollForward(const ActionScrollForwardImpl& actionScrollForwardImpl) 332 { 333 actionScrollForwardImpl_ = actionScrollForwardImpl; 334 } 335 SetActionScrollForward(const ActionScrollForwardWithParamImpl & actionScrollForwardImpl)336 void SetActionScrollForward(const ActionScrollForwardWithParamImpl& actionScrollForwardImpl) 337 { 338 actionScrollForwardWithParamImpl_ = actionScrollForwardImpl; 339 } 340 341 bool ActActionScrollForward(AccessibilityScrollType scrollType = AccessibilityScrollType::SCROLL_DEFAULT) 342 { 343 if (actionScrollForwardWithParamImpl_ == nullptr) { 344 scrollType = AccessibilityScrollType::SCROLL_DEFAULT; 345 } 346 347 if ((scrollType == AccessibilityScrollType::SCROLL_DEFAULT) && (actionScrollForwardImpl_)) { 348 actionScrollForwardImpl_(); 349 return true; 350 } 351 352 if (actionScrollForwardWithParamImpl_) { 353 actionScrollForwardWithParamImpl_(scrollType); 354 return true; 355 } 356 return false; 357 } 358 SetActionScrollBackward(const ActionScrollBackwardImpl & actionScrollBackwardImpl)359 void SetActionScrollBackward(const ActionScrollBackwardImpl& actionScrollBackwardImpl) 360 { 361 actionScrollBackwardImpl_ = actionScrollBackwardImpl; 362 } 363 SetActionScrollBackward(const ActionScrollBackwardWithParamImpl & actionScrollBackwardImpl)364 void SetActionScrollBackward(const ActionScrollBackwardWithParamImpl& actionScrollBackwardImpl) 365 { 366 actionScrollBackwardWithParamImpl_ = actionScrollBackwardImpl; 367 } 368 369 bool ActActionScrollBackward(AccessibilityScrollType scrollType = AccessibilityScrollType::SCROLL_DEFAULT) 370 { 371 if (actionScrollBackwardWithParamImpl_ == nullptr) { 372 scrollType = AccessibilityScrollType::SCROLL_DEFAULT; 373 } 374 375 if ((scrollType == AccessibilityScrollType::SCROLL_DEFAULT) && (actionScrollBackwardImpl_)) { 376 actionScrollBackwardImpl_(); 377 return true; 378 } 379 380 if (actionScrollBackwardWithParamImpl_) { 381 actionScrollBackwardWithParamImpl_(scrollType); 382 return true; 383 } 384 return false; 385 } 386 SetActionCopy(const ActionCopyImpl & actionCopyImpl)387 void SetActionCopy(const ActionCopyImpl& actionCopyImpl) 388 { 389 actionCopyImpl_ = actionCopyImpl; 390 } 391 392 bool ActActionCopy(); 393 394 void SetActionCut(const ActionCutImpl& actionCutImpl); 395 396 bool ActActionCut(); 397 398 void SetActionPaste(const ActionPasteImpl& actionPasteImpl); 399 400 bool ActActionPaste(); 401 402 void SetActionLongClick(const ActionLongClickImpl& actionLongClickImpl); 403 404 bool ActActionLongClick(); 405 406 void SetActionClick(const ActionClickImpl& actionClickImpl); 407 408 bool ActActionClick(); 409 410 void SetActionSelect(const ActionSelectImpl& actionSelectImpl); 411 412 bool ActActionSelect(); 413 414 void SetActionClearSelection(const ActionClearSelectionImpl& actionClearSelectionImpl); 415 416 bool ActActionClearSelection(); 417 418 void SetOnAccessibilityFocusCallback(const OnAccessibilityFocusCallbackImpl& onAccessibilityFocusCallbackImpl); 419 void ResetUserOnAccessibilityFocusCallback(); 420 421 void SetUserOnAccessibilityFocusCallback( 422 const OnAccessibilityFocusCallbackImpl& onUserAccessibilityFocusCallbackImpl); 423 424 void OnAccessibilityFocusCallback(bool isFocus); 425 426 void SetGetWindowScenePosition(const GetWindowScenePositionImpl& getWindowScenePositionImpl); 427 428 void GetWindowScenePosition(WindowSceneInfo& windowSceneInfo); 429 430 bool GetAccessibilityFocusState() const; 431 432 void SetAccessibilityFocusState(bool state); 433 434 void SetAccessibilityGroup(bool accessibilityGroup); 435 436 void SetAccessibilityTextPreferred(bool accessibilityTextPreferred); 437 438 void SetChildTreeId(int32_t childTreeId); 439 440 void SetChildWindowId(int32_t childWindowId); 441 442 void SetAccessibilityText(const std::string& text); 443 444 void SetAccessibilityNextFocusInspectorKey(const std::string& accessibilityNextFocusInspectorKey); 445 446 void SetAccessibilityTextWithEvent(const std::string& text); 447 448 void SetAccessibilityTextHint(const std::string& text); 449 450 void SetAccessibilityDescription(const std::string& accessibilityDescription); 451 452 void SetAccessibilityDescriptionWithEvent(const std::string& accessibilityDescription); 453 454 void OnAccessibilityDetachFromMainTree(); 455 456 bool IsMatchAccessibilityResponseRegion(bool isAccessibilityVirtualNode); 457 458 bool IsAccessibilityCompInResponseRegion(const RectF& rect, const RectF& origRect); 459 460 static NG::RectF UpdateHoverTestRect(const RefPtr<FrameNode>& node); 461 462 NG::RectT<int32_t> GetAccessibilityResponseRegionRect(bool isAccessibilityVirtualNode); 463 464 bool IsAccessibilityGroup() const; 465 466 bool IsAccessibilityTextPreferred() const; 467 468 void NotifyComponentChangeEvent(AccessibilityEventType eventType); 469 470 int32_t GetChildTreeId() const; 471 472 int32_t GetChildWindowId() const; 473 474 void SaveAccessibilityVirtualNode(const RefPtr<UINode>& node); 475 476 const RefPtr<UINode>& GetAccessibilityVirtualNode() const; 477 478 bool HasAccessibilityVirtualNode() const; 479 GetAccessibilityText()480 virtual std::string GetAccessibilityText() const 481 { 482 return accessibilityText_.value_or(""); 483 } 484 GetAccessibilityNextFocusInspectorKey()485 virtual std::string GetAccessibilityNextFocusInspectorKey() const 486 { 487 return accessibilityNextFocusInspectorKey_.value_or(""); 488 } 489 490 std::string GetAccessibilityDescription() const; 491 492 std::string GetTextType() const; 493 494 // true means self and descendants will consume hover, do not search brothers 495 // false means self and descendants no need to be hovered, should search brothers SetAccessibilityHoverConsume(const OnAccessibilityHoverConsumeCheckImpl & accessibilityHoverConsumeCheckImpl)496 void SetAccessibilityHoverConsume(const OnAccessibilityHoverConsumeCheckImpl& accessibilityHoverConsumeCheckImpl) 497 { 498 accessibilityHoverConsumeCheckImpl_ = accessibilityHoverConsumeCheckImpl; 499 } 500 IsAccessibilityHoverConsume(const NG::PointF & point)501 bool IsAccessibilityHoverConsume(const NG::PointF& point) const 502 { 503 if (!accessibilityHoverConsumeCheckImpl_) { 504 return true; 505 } 506 507 return accessibilityHoverConsumeCheckImpl_(point); 508 } 509 510 class Level { 511 public: 512 inline static const std::string AUTO = "auto"; 513 inline static const std::string YES_STR = "yes"; 514 inline static const std::string NO_STR = "no"; 515 inline static const std::string NO_HIDE_DESCENDANTS = "no-hide-descendants"; 516 }; 517 GetAccessibilityLevel()518 virtual std::string GetAccessibilityLevel() const 519 { 520 if (!accessibilityLevel_.has_value()) { 521 return Level::AUTO; 522 } 523 return accessibilityLevel_.value(); 524 } 525 526 void SetAccessibilityLevel(const std::string& accessibilityLevel); 527 528 529 struct HoverTestDebugTraceInfo { 530 std::vector<std::unique_ptr<JsonValue>> trace; 531 }; 532 533 534 /* 535 * Get path from root to node which hit the hoverPoint. 536 * return: path contains nodes whose border cover the hoverPoint. 537 */ 538 static AccessibilityHoverTestPath HoverTest( 539 const PointF& point, 540 const RefPtr<FrameNode>& root, 541 std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo 542 ); 543 544 /* 545 * Judge whether a node can be accessibility focused. 546 * return: if node is accessibility focusable, return true. 547 * param: {node} should be not-null 548 */ 549 static bool IsAccessibilityFocusable(const RefPtr<FrameNode>& node); 550 551 /* 552 * param: {node}, {info} should be not-null 553 */ 554 static bool IsAccessibilityFocusableDebug(const RefPtr<FrameNode>& node, std::unique_ptr<JsonValue>& info); 555 556 /* 557 * Judge whether a node's tag is default accessibility focusable. 558 * return: if a node's tag is default accessibility focusable, return true. 559 * param: {tag} should be not-null 560 */ 561 static bool IsAccessibilityFocusableTag(const std::string &tag); 562 563 static bool IsTagInSubTreeComponent(const std::string& tag); 564 565 static bool IsTagInModalDialog(const RefPtr<FrameNode>& node); 566 567 static bool HitAccessibilityHoverPriority(const RefPtr<FrameNode>& node); 568 GetExtraElementInfo(Accessibility::ExtraElementInfo & extraElementInfo)569 virtual void GetExtraElementInfo(Accessibility::ExtraElementInfo& extraElementInfo) {} 570 571 void SetRelatedElementInfoCallback(const GetRelatedElementInfoImpl& getRelatedElementInfoImpl); 572 573 void GetAllExtraElementInfo(Accessibility::ExtraElementInfo& extraElementInfo); 574 575 void SetAccessibilityActions(uint32_t actions); 576 void ResetAccessibilityActions(); 577 bool HasAccessibilityActions(); 578 uint32_t GetAccessibilityActions() const; 579 580 void SetAccessibilityRole(const std::string& role); 581 void ResetAccessibilityRole(); 582 bool HasAccessibilityRole(); 583 std::string GetAccessibilityRole() const; 584 void SetAccessibilityCustomRole(const std::string& role); 585 void ResetAccessibilityCustomRole(); 586 bool HasAccessibilityCustomRole(); 587 std::string GetAccessibilityCustomRole() const; 588 589 void SetAccessibilitySamePage(const std::string& pageMode); 590 bool HasAccessibilitySamePage(); 591 std::string GetAccessibilitySamePage(); 592 593 void SetActions(const ActionsImpl& actionsImpl); 594 bool ActionsDefined(uint32_t action); 595 596 void SetUserDisabled(const bool& isDisabled); 597 bool HasUserDisabled(); 598 bool IsUserDisabled(); 599 600 void SetUserSelected(const bool& isSelected); 601 bool HasUserSelected(); 602 bool IsUserSelected(); 603 void ResetUserSelected(); 604 605 void SetUserCheckedType(const int32_t& checkedType); 606 bool HasUserCheckedType(); 607 int32_t GetUserCheckedType(); 608 void ResetUserCheckedType(); 609 610 void SetUserMinValue(const int32_t& minValue); 611 bool HasUserMinValue(); 612 int32_t GetUserMinValue(); 613 614 void SetUserMaxValue(const int32_t& maxValue); 615 bool HasUserMaxValue(); 616 int32_t GetUserMaxValue(); 617 618 void SetUserCurrentValue(const int32_t& currentValue); 619 bool HasUserCurrentValue(); 620 int32_t GetUserCurrentValue(); 621 622 void SetUserRangeMinValue(const int32_t rangeMinValue); 623 bool HasUserRangeMinValue() const; 624 int32_t GetUserRangeMinValue() const; 625 626 void SetUserRangeMaxValue(const int32_t rangeMaxValue); 627 bool HasUserRangeMaxValue() const; 628 int32_t GetUserRangeMaxValue() const; 629 630 void SetUserRangeCurrentValue(const int32_t rangeCurrentValue); 631 bool HasUserRangeCurrentValue() const; 632 int32_t GetUserRangeCurrentValue() const; 633 634 void SetUserTextValue(const std::string& textValue); 635 bool HasUserTextValue(); 636 std::string GetUserTextValue(); 637 638 void SetUserCheckable(const bool& checkable); 639 bool HasUserCheckable(); 640 bool IsUserCheckable(); 641 void ResetUserCheckable(); 642 643 virtual bool IsAccessibilityHoverPriority() const; 644 void SetAccessibilityHoverPriority(bool hoverPriority); 645 646 void SetUserScrollTriggerable(const bool& triggerable); 647 bool HasUserScrollTriggerable(); 648 bool IsUserScrollTriggerable(); 649 void ResetUserScrollTriggerable(); 650 void SetFocusDrawLevel(int32_t drawLevel); 651 int32_t GetFocusDrawLevel(); 652 653 654 void SetAccessibilityZIndex(const int32_t& accessibilityZIndex); 655 int32_t GetAccessibilityZIndex() const; 656 657 private: 658 // node should be not-null 659 static bool HoverTestRecursive( 660 const PointF& parentPoint, 661 const RefPtr<FrameNode>& node, 662 AccessibilityHoverTestPath& path, 663 std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo, 664 bool& ancestorGroupFlag 665 ); 666 667 struct RecursiveParam { 668 bool hitTarget; 669 bool ancestorGroupFlag; 670 }; 671 672 static bool ProcessHoverTestRecursive(const PointF& noOffsetPoint, const RefPtr<FrameNode>& node, 673 AccessibilityHoverTestPath& path, std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo, 674 RecursiveParam recursiveParam); 675 676 static std::unique_ptr<JsonValue> CreateNodeSearchInfo(const RefPtr<FrameNode>& node, const PointF& parentPoint, 677 bool& ancestorGroupFlag); 678 679 /* 680 * Get whether node and its children should be searched. 681 * return: first: node itself should be searched. 682 * second: children of node should be searched. 683 * param: {node} should be not-null 684 */ 685 static std::tuple<bool, bool, bool> GetSearchStrategy(const RefPtr<FrameNode>& node, bool& ancestorGroupFlag); 686 687 void GetGroupTextRecursive(bool forceGetChildren, std::string& text, bool preferAccessibilityText) const; 688 689 bool HasAccessibilityTextOrDescription() const; 690 691 bool HasAction() const; 692 693 static bool CheckHoverConsumeByAccessibility(const RefPtr<FrameNode>& node); 694 695 static bool CheckHoverConsumeByComponent(const RefPtr<FrameNode>& node, const NG::PointF& point); 696 697 protected: SetSpecificSupportAction()698 virtual void SetSpecificSupportAction() {} 699 std::optional<std::string> propText_; 700 WeakPtr<FrameNode> host_; 701 uint64_t supportActions_ = 0; 702 ActionSetTextImpl actionSetTextImpl_; 703 ActionSetSelectionImpl actionSetSelectionImpl_; 704 ActionMoveTextImpl actionMoveTextImpl_; 705 ActionScrollForwardImpl actionScrollForwardImpl_; 706 ActionScrollForwardWithParamImpl actionScrollForwardWithParamImpl_; 707 ActionScrollBackwardImpl actionScrollBackwardImpl_; 708 ActionScrollBackwardWithParamImpl actionScrollBackwardWithParamImpl_; 709 ActionCopyImpl actionCopyImpl_; 710 ActionCutImpl actionCutImpl_; 711 ActionPasteImpl actionPasteImpl_; 712 ActionSelectImpl actionSelectImpl_; 713 ActionClearSelectionImpl actionClearSelectionImpl_; 714 ActionSetCursorIndexImpl actionSetCursorIndexImpl_; 715 ActionExecSubComponentImpl actionExecSubComponentImpl_; 716 ActionGetCursorIndexImpl actionGetCursorIndexImpl_; 717 ActionClickImpl actionClickImpl_; 718 ActionLongClickImpl actionLongClickImpl_; 719 ActionsImpl actionsImpl_; 720 GetRelatedElementInfoImpl getRelatedElementInfoImpl_; 721 OnAccessibilityFocusCallbackImpl onAccessibilityFocusCallbackImpl_; 722 GetWindowScenePositionImpl getWindowScenePositionImpl_; 723 OnAccessibilityFocusCallbackImpl onUserAccessibilityFocusCallbackImpl_; 724 OnAccessibilityHoverConsumeCheckImpl accessibilityHoverConsumeCheckImpl_; 725 726 bool isAccessibilityFocused_ = false; 727 bool accessibilityGroup_ = false; 728 bool accessibilityTextPreferred_ = false; 729 bool accessibilityHoverPriority_ = false; 730 int32_t childTreeId_ = -1; 731 int32_t childWindowId_ = 0; 732 RefPtr<UINode> accessibilityVirtualNode_; 733 std::optional<std::string> accessibilityText_; 734 std::optional<std::string> accessibilityDescription_; 735 std::optional<std::string> accessibilityLevel_; 736 std::optional<std::string> textTypeHint_; 737 std::optional<std::string> accessibilityNextFocusInspectorKey_; 738 std::optional<uint32_t> accessibilityActions_; 739 std::optional<std::string> accessibilityRole_; 740 std::optional<std::string> accessibilityCustomRole_; 741 std::optional<std::string> accessibilityUseSamePage_; 742 ACE_DISALLOW_COPY_AND_MOVE(AccessibilityProperty); 743 744 std::optional<bool> isDisabled_; 745 std::optional<bool> isSelected_; 746 std::optional<int32_t> checkedType_; 747 std::optional<bool> isUserCheckable_; 748 std::optional<bool> isUserScrollTriggerable_ = true; 749 750 std::optional<int32_t> minValue_; 751 std::optional<int32_t> maxValue_; 752 std::optional<int32_t> currentValue_; 753 std::optional<int32_t> rangeMinValue_; 754 std::optional<int32_t> rangeMaxValue_; 755 std::optional<int32_t> rangeCurrentValue_; 756 std::optional<std::string> textValue_; 757 FocusDrawLevel focusDrawLevel_ = FocusDrawLevel::SELF; 758 // used to modify the hierarchical relation ship between sibling nodes the same level in barrierfree tree 759 // only affects the barrierfree tree presentation, does not affect the zindex in barrierfree hover 760 int32_t accessibilityZIndex_ = -1; 761 }; 762 } // namespace OHOS::Ace::NG 763 764 #endif 765