From f345d59ce8796cf7c0a46c585a3784af8a0c966f Mon Sep 17 00:00:00 2001 From: zhanghang Date: Sun, 22 Jun 2025 23:16:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A8=AA=E7=AB=96=E5=B1=8F?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E7=BB=BF=E6=A1=86=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghang --- .../pattern/text/text_pattern.cpp | 1 + .../property/accessibility_property.cpp | 2 +- .../accessibility_property_test_ng.cpp | 24 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/frameworks/core/components_ng/pattern/text/text_pattern.cpp b/frameworks/core/components_ng/pattern/text/text_pattern.cpp index 1ee13b83bb6..577b93656ae 100644 --- a/frameworks/core/components_ng/pattern/text/text_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text/text_pattern.cpp @@ -5296,6 +5296,7 @@ void TextPattern::SetResponseRegion(const SizeF& frameSize, const SizeF& boundsS Dimension(std::max(frameSize.Height(), boundsSize.Height())))); hotZoneRegions.emplace_back(hotZoneRegion); gestureHub->SetResponseRegion(hotZoneRegions); + host->UpdateAccessibilityNodeRect(); } void TextPattern::CreateModifier() diff --git a/frameworks/core/components_ng/property/accessibility_property.cpp b/frameworks/core/components_ng/property/accessibility_property.cpp index 475c6932e1e..7eed56244fb 100755 --- a/frameworks/core/components_ng/property/accessibility_property.cpp +++ b/frameworks/core/components_ng/property/accessibility_property.cpp @@ -308,7 +308,7 @@ bool AccessibilityProperty::IsMatchAccessibilityResponseRegion(bool isAccessibil } auto& rect = responseRegionList.back(); if (rect == origRect) { - return false; + return true; } if (!IsAccessibilityCompInResponseRegion(rect, origRect)) { return false; diff --git a/test/unittest/core/property/accessibility_property_test_ng.cpp b/test/unittest/core/property/accessibility_property_test_ng.cpp index d48068bcd2b..8ba95d8ae16 100644 --- a/test/unittest/core/property/accessibility_property_test_ng.cpp +++ b/test/unittest/core/property/accessibility_property_test_ng.cpp @@ -1260,4 +1260,28 @@ HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest041, TestSize.Lev accessibilityProperty.SetAccessibilityTextPreferred(false); EXPECT_FALSE(accessibilityProperty.IsAccessibilityTextPreferred()); } + +/** + * @tc.name: AccessibilityPropertyTest042 + * @tc.desc: IsMatchAccessibilityResponseRegion + * @tc.type: FUNC + */ +HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest042, TestSize.Level1) +{ + AccessibilityProperty accessibilityProperty; + auto host = FrameNode::GetOrCreateFrameNode( + V2::BUTTON_ETS_TAG, 1, []() { return AceType::MakeRefPtr(); }); + host->isActive_ = true; + auto paintRect = host->GetTransformRectRelativeToWindow(); + auto responseRegionList = host->GetResponseRegionList(paintRect, 2); + EXPECT_FALSE(responseRegionList.size() != 1); + + auto rect = responseRegionList.back(); + EXPECT_TRUE(rect == paintRect); + + WeakPtr hostBak = host; + accessibilityProperty.SetHost(hostBak); + auto result = accessibilityProperty.IsMatchAccessibilityResponseRegion(false); + EXPECT_EQ(result, true); +} } // namespace OHOS::Ace::NG -- Gitee