Bug 630841 - Crash in nsHyperTextAccessible::GetText(), r=surkov, a=blocking GECKO20b11_2011020209_RELBRANCH
authorFernando Herrera <fherrera@onirica.com>
Thu, 03 Feb 2011 18:59:14 +0100
branchGECKO20b11_2011020209_RELBRANCH
changeset 61866 6d9ac157fc84be6c489ecfcdc6a4dfb5fc3b8b0d
parent 61811 139845554a62308fd65911d6ba5e34cdc1840e5e
child 61867 bb8247382c3e27be839e83eec90e946eb9209f48
push idunknown
push userunknown
push dateunknown
reviewerssurkov, blocking
bugs630841
milestone2.0b11
Bug 630841 - Crash in nsHyperTextAccessible::GetText(), r=surkov, a=blocking
accessible/src/html/nsHyperTextAccessible.cpp
accessible/src/html/nsHyperTextAccessible.h
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -199,16 +199,27 @@ nsHyperTextAccessible::GetStateInternal(
   GetChildCount(&childCount);
   if (childCount > 0) {
     *aExtraState |= nsIAccessibleStates::EXT_STATE_SELECTABLE_TEXT;
   }
 
   return NS_OK;
 }
 
+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);
+}
+
 // Substring must be entirely within the same text node
 nsIntRect nsHyperTextAccessible::GetBoundsForString(nsIFrame *aFrame, PRUint32 aStartRenderedOffset,
                                                     PRUint32 aEndRenderedOffset)
 {
   nsIntRect screenRect;
   NS_ENSURE_TRUE(aFrame, screenRect);
   if (aFrame->GetType() != nsAccessibilityAtoms::textFrame) {
     // XXX fallback for non-text frames, happens for bullets right now
--- a/accessible/src/html/nsHyperTextAccessible.h
+++ b/accessible/src/html/nsHyperTextAccessible.h
@@ -83,16 +83,17 @@ public:
   NS_DECL_NSIACCESSIBLEEDITABLETEXT
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_HYPERTEXTACCESSIBLE_IMPL_CID)
 
   // nsAccessible
   virtual PRInt32 GetLevelInternal();
   virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
   virtual PRUint32 NativeRole();
   virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
+  virtual PRBool RemoveChild(nsAccessible *aAccessible);
 
   virtual void InvalidateChildren();
 
   // nsHyperTextAccessible (static helper method)
 
   // Convert content offset to rendered text offset  
   static nsresult ContentToRenderedOffset(nsIFrame *aFrame, PRInt32 aContentOffset,
                                           PRUint32 *aRenderedOffset);