From cb4acc863c165c22f5a860b1dff91970dca106e4 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Thu, 24 Mar 2011 18:03:14 -0400 Subject: [PATCH] Bug 619002 - When deleting text from edit fields the wrong text is reported through at-spi r=fernando,ginn.chen f=surkov --- accessible/src/atk/nsAccessNodeWrap.cpp | 4 ++++ accessible/src/atk/nsAccessNodeWrap.h | 7 +++++++ accessible/src/atk/nsAccessibleWrap.cpp | 23 ++++++++++++++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/accessible/src/atk/nsAccessNodeWrap.cpp b/accessible/src/atk/nsAccessNodeWrap.cpp index 446cbfe6c4af..8c4b6463169a 100644 --- a/accessible/src/atk/nsAccessNodeWrap.cpp +++ b/accessible/src/atk/nsAccessNodeWrap.cpp @@ -38,6 +38,9 @@ #include "nsAccessNodeWrap.h" #include "nsApplicationAccessibleWrap.h" +#include "nsMaiInterfaceText.h" + +PRBool nsAccessNodeWrap::gHaveNewTextSignals = PR_FALSE; /* For documentation of the accessibility architecture, * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html @@ -68,6 +71,7 @@ nsAccessNodeWrap::~nsAccessNodeWrap() void nsAccessNodeWrap::InitAccessibility() { nsAccessNode::InitXPAccessibility(); + gHaveNewTextSignals = g_signal_lookup("text-insert", ATK_TYPE_TEXT); } void nsAccessNodeWrap::ShutdownAccessibility() diff --git a/accessible/src/atk/nsAccessNodeWrap.h b/accessible/src/atk/nsAccessNodeWrap.h index 22ceab81bb57..6ee2215a8505 100644 --- a/accessible/src/atk/nsAccessNodeWrap.h +++ b/accessible/src/atk/nsAccessNodeWrap.h @@ -53,6 +53,13 @@ public: // construction, destruction static void InitAccessibility(); static void ShutdownAccessibility(); + + /* + * do we have text-remove and text-insert signals if not we need to use + * text-changed see nsAccessibleWrap::FireAtkTextChangedEvent() and + * bug 619002 + */ + static PRBool gHaveNewTextSignals; }; #endif diff --git a/accessible/src/atk/nsAccessibleWrap.cpp b/accessible/src/atk/nsAccessibleWrap.cpp index e1137ff0139c..7473d71d2836 100644 --- a/accessible/src/atk/nsAccessibleWrap.cpp +++ b/accessible/src/atk/nsAccessibleWrap.cpp @@ -1361,14 +1361,27 @@ nsAccessibleWrap::FireAtkTextChangedEvent(AccEvent* aEvent, PRInt32 start = event->GetStartOffset(); PRUint32 length = event->GetLength(); PRBool isInserted = event->IsTextInserted(); - PRBool isFromUserInput = aEvent->IsFromUserInput(); + char* signal_name = nsnull; - char *signal_name = g_strconcat(isInserted ? "text_changed::insert" : "text_changed::delete", - isFromUserInput ? "" : kNonUserInputEvent, NULL); - g_signal_emit_by_name(aObject, signal_name, start, length); - g_free (signal_name); + if (gHaveNewTextSignals) { + nsAutoString text; + event->GetModifiedText(text); + signal_name = g_strconcat(isInserted ? "text-insert" : "text-remove", + isFromUserInput ? "" : "::system", NULL); + g_signal_emit_by_name(aObject, signal_name, start, length, + NS_ConvertUTF16toUTF8(text).get()); + } else { + // XXX remove this code and the gHaveNewTextSignals check when we can + // stop supporting old atk since it doesn't really work anyway + // see bug 619002 + signal_name = g_strconcat(isInserted ? "text_changed::insert" : + "text_changed::delete", + isFromUserInput ? "" : kNonUserInputEvent, NULL); + g_signal_emit_by_name(aObject, signal_name, start, length); + } + g_free(signal_name); return NS_OK; }