[M120 Migration][VD][AX] Support live region update 50/317250/3
authorfr.fang <fr.fang@samsung.com>
Fri, 6 Sep 2024 15:16:29 +0000 (23:16 +0800)
committerBot Blink <blinkbot@samsung.com>
Mon, 9 Sep 2024 03:32:45 +0000 (03:32 +0000)
Because screen reader does not support children changed signal,
we use text changed signal to to support live region update.
It supports aria-atomic, aria-relevant, aria-live=polite.

Related patch:
https://review.tizen.org/gerrit/292652/

Change-Id: I06c1737483a506a1ea7b2ead10062ae0fe2b6a36
Signed-off-by: fr.fang <fr.fang@samsung.com>
content/browser/accessibility/browser_accessibility_manager_auralinux.cc
tizen_src/chromium_impl/ui/accessibility/platform/ax_platform_node_efl.cc
tizen_src/chromium_impl/ui/accessibility/platform/ax_platform_node_efl.h
ui/accessibility/platform/ax_platform_node_auralinux.cc

index 64c3f938651c75f8933d972900f9682b884b083d..bcc88ad2f576b3da18c1bab4c760514671b158b2 100644 (file)
@@ -328,6 +328,11 @@ void BrowserAccessibilityManagerAuraLinux::FireGeneratedEvent(
         return;  // node no longer editable since event originally fired.
       FireEvent(wrapper, ax::mojom::Event::kValueChanged);
       break;
+#if defined(TIZEN_ATK_FEATURE_VD)
+    case ui::AXEventGenerator::Event::LIVE_REGION_NODE_CHANGED:
+      FireEvent(wrapper, ax::mojom::Event::kLiveRegionChanged);
+      break;
+#endif
 
     // Currently unused events on this platform.
     case ui::AXEventGenerator::Event::NONE:
@@ -359,7 +364,9 @@ void BrowserAccessibilityManagerAuraLinux::FireGeneratedEvent(
     case ui::AXEventGenerator::Event::LAYOUT_INVALIDATED:
     case ui::AXEventGenerator::Event::LIVE_REGION_CHANGED:
     case ui::AXEventGenerator::Event::LIVE_REGION_CREATED:
+#if !defined(TIZEN_ATK_FEATURE_VD)
     case ui::AXEventGenerator::Event::LIVE_REGION_NODE_CHANGED:
+#endif
     case ui::AXEventGenerator::Event::LIVE_RELEVANT_CHANGED:
     case ui::AXEventGenerator::Event::LIVE_STATUS_CHANGED:
     case ui::AXEventGenerator::Event::MULTILINE_STATE_CHANGED:
index c200a80a7f00557b07b03cf3e052ee71d5bd08f9..21efb180ae50dbe75c89bab958623d6dbe4d14ab 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "base/strings/string_util.h"
 #include "tizen/system_info.h"
+#include "ui/accessibility/ax_enum_util.h"
 #include "ui/accessibility/ax_node_data.h"
 #include "ui/display/device_display_info_efl.h"
 #include "ui/display/display.h"
@@ -64,7 +65,7 @@ void AXPlatformNodeEfl::NotifyAccessibilityEvent(ax::mojom::Event event_type) {
   AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(event_type);
 
   switch (event_type) {
-#if defined(TIZEN_ATK_FEATURE_VD) && !defined(EWK_BRINGUP)
+#if defined(TIZEN_ATK_FEATURE_VD)
     case ax::mojom::Event::kLiveRegionChanged:
       OnLiveRegionChanged();
       break;
@@ -336,6 +337,42 @@ bool AXPlatformNodeEfl::IsAccessible() const {
 }
 
 #if defined(TIZEN_ATK_FEATURE_VD)
+void AXPlatformNodeEfl::OnLiveRegionChanged() {
+  gfx::NativeViewAccessible native_object = GetNativeViewAccessible();
+  if (!ATK_IS_OBJECT(native_object))
+    return;
+
+  std::string text_to_emit;
+  int member_of_id = 0;
+  AXPlatformNodeAuraLinux* root_node = nullptr;
+
+  if (GetBoolAttribute(ax::mojom::BoolAttribute::kBusy) ||
+      GetBoolAttribute(ax::mojom::BoolAttribute::kContainerLiveBusy) ||
+      ax::mojom::Role::kLineBreak == GetData().role)
+    return;
+
+  if (GetBoolAttribute(ax::mojom::BoolAttribute::kContainerLiveAtomic)) {
+    if (GetIntAttribute(ax::mojom::IntAttribute::kMemberOfId, &member_of_id))
+      root_node = static_cast<AXPlatformNodeAuraLinux*>(
+          delegate_->GetFromNodeID(member_of_id));
+    if (root_node)
+      text_to_emit = ToAXPlatformNodeEfl(root_node)->GetSubTreeSpeechContent();
+    else
+      LOG(INFO) << "aria live atomic, but can not find live root.";
+  } else {
+    text_to_emit = GetSpeechContent();
+  }
+
+  if (text_to_emit.empty())
+    return;
+
+  LOG(INFO) << "AXPlatformNodeEfl::OnLiveRegionChanged emit "
+            << "text-insert event for node: " << GetData().id
+            << ", text: " << text_to_emit.data();
+  g_signal_emit_by_name(native_object, "text-insert", 0, text_to_emit.length(),
+                        text_to_emit.data());
+}
+
 std::string AXPlatformNodeEfl::GetSupplementaryText() const {
   // name and description have been got from BrowserAccessibilityAuraLinux
   // if return here again, it will be speak twice
index 25d091015ec3822a3b4d18d9591c458416b35668..e3794edb6abae704e99388f5b14929d849ca870d 100644 (file)
@@ -35,6 +35,7 @@ class AX_EXPORT AXPlatformNodeEfl : public AXPlatformNodeAuraLinux {
   gchar* GetObjectText() const;
   bool IsAccessible() const;
 #if defined(TIZEN_ATK_FEATURE_VD)
+  void OnLiveRegionChanged();
   std::string GetSupplementaryText() const;
   std::string GetSubTreeSpeechContent() const;
   std::string GetSpeechContent();
index 589820b1593a4a0d9a1ce2aa58d4e5d101890df4..452b81b50576e477ca5ebfc6cbebd4ca895b9022 100644 (file)
@@ -3785,12 +3785,22 @@ void AXPlatformNodeAuraLinux::OnFocused() {
   SetActiveViewsDialog();
 
   if (g_current_focused) {
+#if defined(TIZEN_ATK_FEATURE_VD)
+    LOG(INFO) << "AXPlatformNodeAuraLinux::OnFocused emit old_focus "
+                 "for node: "
+              << GetData().ToString();
+#endif
     g_signal_emit_by_name(g_current_focused, "focus-event", false);
     atk_object_notify_state_change(ATK_OBJECT(g_current_focused),
                                    ATK_STATE_FOCUSED, false);
   }
 
   SetWeakGPtrToAtkObject(&g_current_focused, atk_object);
+#if defined(TIZEN_ATK_FEATURE_VD)
+  LOG(INFO) << "AXPlatformNodeAuraLinux::OnFocused emit new_focus "
+               "for node: "
+            << GetData().ToString();
+#endif
 
   g_signal_emit_by_name(g_current_focused, "focus-event", true);
   atk_object_notify_state_change(ATK_OBJECT(g_current_focused),
@@ -4335,6 +4345,13 @@ void AXPlatformNodeAuraLinux::UpdateHypertext() {
     return;
   }
 
+#if defined(TIZEN_ATK_FEATURE_VD)
+  // UpdateHypertext() trigger to emit event to screen reader, but for tv,
+  // it conflicts with AXPlatformNodeEfl::OnLiveRegionChanged().
+  if (IsInLiveRegion())
+    return;
+#endif
+
   if (!EmitsAtkTextEvents())
     return;
 
@@ -4350,6 +4367,12 @@ void AXPlatformNodeAuraLinux::UpdateHypertext() {
     size_t shared_unicode_suffix = shared_prefix + old_len;
     base::OffsetAdjuster::AdjustOffset(old_adjustments, &shared_unicode_suffix);
 
+#if defined(TIZEN_ATK_FEATURE_VD)
+    LOG(INFO) << "AXPlatformNodeAuraLinux::UpdateHypertext emit text-remove "
+              << "event and emit string is: "
+              << base::UTF16ToUTF8(removed_substring).c_str();
+#endif
+
     g_signal_emit_by_name(
         atk_object, "text-remove",
         shared_unicode_prefix,                  // position of removal
@@ -4363,6 +4386,11 @@ void AXPlatformNodeAuraLinux::UpdateHypertext() {
     size_t shared_unicode_prefix = UTF16ToUnicodeOffsetInText(shared_prefix);
     size_t shared_unicode_suffix =
         UTF16ToUnicodeOffsetInText(shared_prefix + new_len);
+#if defined(TIZEN_ATK_FEATURE_VD)
+    LOG(INFO) << "AXPlatformNodeAuraLinux::UpdateHypertext emit text-insert "
+              << "event and emit string is: "
+              << base::UTF16ToUTF8(inserted_substring).c_str() << "over";
+#endif
     g_signal_emit_by_name(
         atk_object, "text-insert",
         shared_unicode_prefix,                          // position of insertion