Bug 630841 - update text offsets when remove child from hypertext accessible, r=surkov, a=final
authorFernando Herrera <fherrera@onirica.com>
Thu, 03 Feb 2011 01:02:48 +0800
changeset 61784 6cb543f7d5b0613aacffbb115ba392851ca5259c
parent 61783 95b2986b495e2877f98be1d82d389d5c78e98924
child 61785 04a3cfea8e20be68b31ca430661e07bf1d0ac66c
push idunknown
push userunknown
push dateunknown
reviewerssurkov, final
bugs630841
milestone2.0b11pre
Bug 630841 - update text offsets when remove child from hypertext accessible, r=surkov, a=final
accessible/src/html/nsHyperTextAccessible.cpp
accessible/src/html/nsHyperTextAccessible.h
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -2088,16 +2088,27 @@ nsHyperTextAccessible::ScrollSubstringTo
 void
 nsHyperTextAccessible::InvalidateChildren()
 {
   mOffsets.Clear();
 
   nsAccessibleWrap::InvalidateChildren();
 }
 
+PRBool
+nsHyperTextAccessible::RemoveChild(nsAccessible* aAccessible)
+{
+  PRInt32 childIndex = aAccessible->GetIndexInParent();
+  PRInt32 count = mOffsets.Length() - childIndex;
+  if (count > 0)
+    mOffsets.RemoveElementsAt(childIndex, count);
+
+  return nsAccessible::RemoveChild(aAccessible);
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // nsHyperTextAccessible public static
 
 nsresult nsHyperTextAccessible::ContentToRenderedOffset(nsIFrame *aFrame, PRInt32 aContentOffset,
                                                         PRUint32 *aRenderedOffset)
 {
   if (!aFrame) {
     // Current frame not rendered -- this can happen if text is set on
--- a/accessible/src/html/nsHyperTextAccessible.h
+++ b/accessible/src/html/nsHyperTextAccessible.h
@@ -85,16 +85,17 @@ public:
 
   // nsAccessible
   virtual PRInt32 GetLevelInternal();
   virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
   virtual PRUint32 NativeRole();
   virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
 
   virtual void InvalidateChildren();
+  virtual PRBool RemoveChild(nsAccessible* aAccessible);
 
   // nsHyperTextAccessible (static helper method)
 
   // Convert content offset to rendered text offset  
   static nsresult ContentToRenderedOffset(nsIFrame *aFrame, PRInt32 aContentOffset,
                                           PRUint32 *aRenderedOffset);
   
   // Convert rendered text offset to content offset