bug 1192330 - add ia2AccessibleText::UpdateTextChangeData r=surkov
authorTrevor Saunders <tbsaunde@tbsaunde.org>
Thu, 06 Aug 2015 16:57:31 -0400
changeset 286610 1409d0fcea5d0478499480a04b234841d3939323
parent 286609 d5b9c388f05a6ee50e1e5395197c6803f27df51c
child 286611 2f76881caf22b2a2a88422bfc11f50831b40f81b
push id4570
push userdburns@mozilla.com
push dateWed, 19 Aug 2015 19:33:48 +0000
reviewerssurkov
bugs1192330
milestone43.0a1
bug 1192330 - add ia2AccessibleText::UpdateTextChangeData r=surkov Soon we will need to be able to update the text change event data from both HandleAccEvent() and ProxyTextChangeEvent(), so separate out the logic to do that into a function.
accessible/windows/ia2/ia2AccessibleText.cpp
accessible/windows/ia2/ia2AccessibleText.h
accessible/windows/msaa/HyperTextAccessibleWrap.cpp
--- a/accessible/windows/ia2/ia2AccessibleText.cpp
+++ b/accessible/windows/ia2/ia2AccessibleText.cpp
@@ -617,8 +617,23 @@ ia2AccessibleText::GetGeckoTextBoundary(
 }
 
 void
 ia2AccessibleText::InitTextChangeData()
 {
   ClearOnShutdown(&sLastTextChangeAcc);
   ClearOnShutdown(&sLastTextChangeString);
 }
+
+void
+ia2AccessibleText::UpdateTextChangeData(HyperTextAccessibleWrap* aAcc,
+                                        bool aInsert, const nsString& aStr,
+                                        int32_t aStart, uint32_t aLen)
+{
+  if (!sLastTextChangeString)
+    sLastTextChangeString = new nsString();
+
+  sLastTextChangeAcc = aAcc;
+  sLastTextChangeStart = aStart;
+  sLastTextChangeEnd = aStart + aLen;
+  sLastTextChangeWasInsert = aInsert;
+  *sLastTextChangeString = aStr;
+}
--- a/accessible/windows/ia2/ia2AccessibleText.h
+++ b/accessible/windows/ia2/ia2AccessibleText.h
@@ -110,16 +110,19 @@ public:
 
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_newText(
       /* [retval][out] */ IA2TextSegment *newText);
 
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_oldText(
       /* [retval][out] */ IA2TextSegment *oldText);
 
   static void InitTextChangeData();
+  static void UpdateTextChangeData(HyperTextAccessibleWrap* aAcc, bool aInsert,
+                                   const nsString& aStr, int32_t aStart,
+                                   uint32_t aLen);
 
 protected:
   static StaticRefPtr<HyperTextAccessibleWrap> sLastTextChangeAcc;
   static StaticAutoPtr<nsString> sLastTextChangeString;
   static bool sLastTextChangeWasInsert;
   static uint32_t sLastTextChangeStart;
   static uint32_t sLastTextChangeEnd;
 
--- a/accessible/windows/msaa/HyperTextAccessibleWrap.cpp
+++ b/accessible/windows/msaa/HyperTextAccessibleWrap.cpp
@@ -48,23 +48,20 @@ nsresult
 HyperTextAccessibleWrap::HandleAccEvent(AccEvent* aEvent)
 {
   uint32_t eventType = aEvent->GetEventType();
 
   if (eventType == nsIAccessibleEvent::EVENT_TEXT_REMOVED ||
       eventType == nsIAccessibleEvent::EVENT_TEXT_INSERTED) {
     Accessible* accessible = aEvent->GetAccessible();
     if (accessible && accessible->IsHyperText()) {
-      sLastTextChangeAcc =
-        static_cast<HyperTextAccessibleWrap*>(accessible->AsHyperText());
-      if (!sLastTextChangeString)
-        sLastTextChangeString = new nsString();
-
       AccTextChangeEvent* event = downcast_accEvent(aEvent);
-      event->GetModifiedText(*sLastTextChangeString);
-      sLastTextChangeStart = event->GetStartOffset();
-      sLastTextChangeEnd = sLastTextChangeStart + event->GetLength();
-      sLastTextChangeWasInsert = event->IsTextInserted();
+        HyperTextAccessibleWrap* text =
+          static_cast<HyperTextAccessibleWrap*>(accessible->AsHyperText());
+      ia2AccessibleText::UpdateTextChangeData(text, event->IsTextInserted(),
+                                              event->ModifiedText(),
+                                              event->GetStartOffset(),
+                                              event->GetLength());
     }
   }
 
   return HyperTextAccessible::HandleAccEvent(aEvent);
 }