Bug 1286952 - Make xpcAccessibleHyperText work with proxied accessibles. r=tbsaunde
authorMichael Li <michael.li11702@gmail.com>
Fri, 22 Jul 2016 12:07:41 -0400
changeset 349466 0bf6ee84ac6fdb8af1f433de4241dc39b11c74bb
parent 349465 6d35194aa0f1b5618283503ec4aee73891e45f81
child 349467 d69343be1c2416a33595f78190a41d13c9bcc284
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs1286952
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1286952 - Make xpcAccessibleHyperText work with proxied accessibles. r=tbsaunde MozReview-Commit-ID: 1E81sAlOIs1
accessible/xpcom/xpcAccessibleHyperText.cpp
--- a/accessible/xpcom/xpcAccessibleHyperText.cpp
+++ b/accessible/xpcom/xpcAccessibleHyperText.cpp
@@ -36,158 +36,225 @@ NS_IMPL_RELEASE_INHERITED(xpcAccessibleH
 // nsIAccessibleText
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetCharacterCount(int32_t* aCharacterCount)
 {
   NS_ENSURE_ARG_POINTER(aCharacterCount);
   *aCharacterCount = 0;
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  *aCharacterCount = Intl()->CharacterCount();
+  if (mIntl.IsAccessible()) {
+    *aCharacterCount = Intl()->CharacterCount();
+  } else {
+    *aCharacterCount = mIntl.AsProxy()->CharacterCount();
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetText(int32_t aStartOffset, int32_t aEndOffset,
                                 nsAString& aText)
 {
   aText.Truncate();
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->TextSubstring(aStartOffset, aEndOffset, aText);
+  if (mIntl.IsAccessible()) {
+    Intl()->TextSubstring(aStartOffset, aEndOffset, aText);
+  } else {
+    nsString text;
+    mIntl.AsProxy()->TextSubstring(aStartOffset, aEndOffset, text);
+    aText = text;
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetTextBeforeOffset(int32_t aOffset,
                                             AccessibleTextBoundary aBoundaryType,
                                             int32_t* aStartOffset,
                                             int32_t* aEndOffset,
                                             nsAString& aText)
 {
   NS_ENSURE_ARG_POINTER(aStartOffset);
   NS_ENSURE_ARG_POINTER(aEndOffset);
   *aStartOffset = *aEndOffset = 0;
   aText.Truncate();
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->TextBeforeOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
+  if (mIntl.IsAccessible()) {
+    Intl()->TextBeforeOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, 
+                             aText);
+  } else {
+    nsString text;
+    mIntl.AsProxy()->GetTextBeforeOffset(aOffset, aBoundaryType, text,
+                                         aStartOffset, aEndOffset);
+    aText = text;
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetTextAtOffset(int32_t aOffset,
                                         AccessibleTextBoundary aBoundaryType,
                                         int32_t* aStartOffset,
                                         int32_t* aEndOffset, nsAString& aText)
 {
   NS_ENSURE_ARG_POINTER(aStartOffset);
   NS_ENSURE_ARG_POINTER(aEndOffset);
   *aStartOffset = *aEndOffset = 0;
   aText.Truncate();
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->TextAtOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
+  if (mIntl.IsAccessible()) {
+    Intl()->TextAtOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, 
+                         aText);
+  } else {
+    nsString text;
+    mIntl.AsProxy()->GetTextAtOffset(aOffset, aBoundaryType, text, 
+                                     aStartOffset, aEndOffset);
+    aText = text;
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetTextAfterOffset(int32_t aOffset,
                                            AccessibleTextBoundary aBoundaryType,
                                            int32_t* aStartOffset,
                                            int32_t* aEndOffset, nsAString& aText)
 {
   NS_ENSURE_ARG_POINTER(aStartOffset);
   NS_ENSURE_ARG_POINTER(aEndOffset);
   *aStartOffset = *aEndOffset = 0;
   aText.Truncate();
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->TextAfterOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
+  if (mIntl.IsAccessible()) {
+    Intl()->TextAfterOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, 
+                            aText);
+  } else {
+    nsString text;
+    mIntl.AsProxy()->GetTextAfterOffset(aOffset, aBoundaryType, text, 
+                                        aStartOffset, aEndOffset);
+    aText = text;
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetCharacterAtOffset(int32_t aOffset,
                                              char16_t* aCharacter)
 {
   NS_ENSURE_ARG_POINTER(aCharacter);
   *aCharacter = L'\0';
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  *aCharacter = Intl()->CharAt(aOffset);
+  if (mIntl.IsAccessible()) {
+    *aCharacter = Intl()->CharAt(aOffset);
+  } else {
+    *aCharacter = mIntl.AsProxy()->CharAt(aOffset);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetTextAttributes(bool aIncludeDefAttrs,
                                           int32_t aOffset,
                                           int32_t* aStartOffset,
                                           int32_t* aEndOffset,
                                           nsIPersistentProperties** aAttributes)
 {
   NS_ENSURE_ARG_POINTER(aStartOffset);
   NS_ENSURE_ARG_POINTER(aEndOffset);
   NS_ENSURE_ARG_POINTER(aAttributes);
   *aStartOffset = *aEndOffset = 0;
   *aAttributes = nullptr;
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  nsCOMPtr<nsIPersistentProperties> attrs =
-   Intl()->TextAttributes(aIncludeDefAttrs, aOffset, aStartOffset, aEndOffset);
-  attrs.swap(*aAttributes);
+  nsCOMPtr<nsIPersistentProperties> props;
+  if (mIntl.IsAccessible()) {
+    props = Intl()->TextAttributes(aIncludeDefAttrs, aOffset, aStartOffset,
+                                   aEndOffset);
+  } else {
+    AutoTArray<Attribute, 10> attrs;
+    mIntl.AsProxy()->TextAttributes(aIncludeDefAttrs, aOffset, &attrs,
+        aStartOffset, aEndOffset);
+    uint32_t attrCount = attrs.Length();
+    nsAutoString unused;
+    for (uint32_t i = 0; i < attrCount; i++) {
+      props->SetStringProperty(attrs[i].Name(), attrs[i].Value(), unused);
+    }
+  }
+  props.forget(aAttributes);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetDefaultTextAttributes(nsIPersistentProperties** aAttributes)
 {
   NS_ENSURE_ARG_POINTER(aAttributes);
   *aAttributes = nullptr;
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  nsCOMPtr<nsIPersistentProperties> attrs = Intl()->DefaultTextAttributes();
-  attrs.swap(*aAttributes);
+  nsCOMPtr<nsIPersistentProperties> props;
+  if (mIntl.IsAccessible()) {
+    props = Intl()->DefaultTextAttributes();
+  } else {
+    AutoTArray<Attribute, 10> attrs;
+    mIntl.AsProxy()->DefaultTextAttributes(&attrs);
+    uint32_t attrCount = attrs.Length();
+    nsAutoString unused;
+    for (uint32_t i = 0; i < attrCount; i++) {
+      props->SetStringProperty(attrs[i].Name(), attrs[i].Value(), unused);
+    }
+  }
+  props.forget(aAttributes);
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetCharacterExtents(int32_t aOffset,
                                             int32_t* aX, int32_t* aY,
                                             int32_t* aWidth, int32_t* aHeight,
                                             uint32_t aCoordType)
 {
   NS_ENSURE_ARG_POINTER(aX);
   NS_ENSURE_ARG_POINTER(aY);
   NS_ENSURE_ARG_POINTER(aWidth);
   NS_ENSURE_ARG_POINTER(aHeight);
   *aX = *aY = *aWidth = *aHeight;
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  nsIntRect rect = Intl()->CharBounds(aOffset, aCoordType);
+  nsIntRect rect;
+  if (mIntl.IsAccessible()) {
+    rect = Intl()->CharBounds(aOffset, aCoordType);
+  } else {
+    rect = mIntl.AsProxy()->CharBounds(aOffset, aCoordType);
+  }
   *aX = rect.x; *aY = rect.y;
   *aWidth = rect.width; *aHeight = rect.height;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetRangeExtents(int32_t aStartOffset, int32_t aEndOffset,
                                         int32_t* aX, int32_t* aY,
@@ -195,151 +262,209 @@ xpcAccessibleHyperText::GetRangeExtents(
                                         uint32_t aCoordType)
 {
   NS_ENSURE_ARG_POINTER(aX);
   NS_ENSURE_ARG_POINTER(aY);
   NS_ENSURE_ARG_POINTER(aWidth);
   NS_ENSURE_ARG_POINTER(aHeight);
   *aX = *aY = *aWidth = *aHeight = 0;
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  nsIntRect rect = Intl()->TextBounds(aStartOffset, aEndOffset, aCoordType);
+  nsIntRect rect;
+  if (mIntl.IsAccessible()) {
+    rect = Intl()->TextBounds(aStartOffset, aEndOffset, aCoordType);
+  } else {
+    rect = mIntl.AsProxy()->TextBounds(aStartOffset, aEndOffset, aCoordType);
+  }
   *aX = rect.x; *aY = rect.y;
   *aWidth = rect.width; *aHeight = rect.height;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetOffsetAtPoint(int32_t aX, int32_t aY,
                                          uint32_t aCoordType, int32_t* aOffset)
 {
   NS_ENSURE_ARG_POINTER(aOffset);
   *aOffset = -1;
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  *aOffset = Intl()->OffsetAtPoint(aX, aY, aCoordType);
+  if (mIntl.IsAccessible()) {
+    *aOffset = Intl()->OffsetAtPoint(aX, aY, aCoordType);
+  } else {
+    *aOffset = mIntl.AsProxy()->OffsetAtPoint(aX, aY, aCoordType);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetCaretOffset(int32_t* aCaretOffset)
 {
   NS_ENSURE_ARG_POINTER(aCaretOffset);
   *aCaretOffset = -1;
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  *aCaretOffset = Intl()->CaretOffset();
+  if (mIntl.IsAccessible()) {
+    *aCaretOffset = Intl()->CaretOffset();
+  } else {
+    *aCaretOffset = mIntl.AsProxy()->CaretOffset();
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::SetCaretOffset(int32_t aCaretOffset)
 {
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->SetCaretOffset(aCaretOffset);
+  if (mIntl.IsAccessible()) {
+    Intl()->SetCaretOffset(aCaretOffset);
+  } else {
+    mIntl.AsProxy()->SetCaretOffset(aCaretOffset);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetSelectionCount(int32_t* aSelectionCount)
 {
   NS_ENSURE_ARG_POINTER(aSelectionCount);
   *aSelectionCount = 0;
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  *aSelectionCount = Intl()->SelectionCount();
+  if (mIntl.IsAccessible()) {
+    *aSelectionCount = Intl()->SelectionCount();
+  } else {
+    *aSelectionCount = mIntl.AsProxy()->SelectionCount();
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetSelectionBounds(int32_t aSelectionNum,
                                            int32_t* aStartOffset,
                                            int32_t* aEndOffset)
 {
   NS_ENSURE_ARG_POINTER(aStartOffset);
   NS_ENSURE_ARG_POINTER(aEndOffset);
   *aStartOffset = *aEndOffset = 0;
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  if (aSelectionNum < 0 || aSelectionNum >= Intl()->SelectionCount())
+  if (aSelectionNum < 0)
     return NS_ERROR_INVALID_ARG;
 
-  Intl()->SelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset);
+  if (mIntl.IsAccessible()) {
+    if (aSelectionNum >= Intl()->SelectionCount())
+      return NS_ERROR_INVALID_ARG;
+      
+    Intl()->SelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset);
+  } else {
+    nsString unused;
+    mIntl.AsProxy()->SelectionBoundsAt(aSelectionNum, unused, aStartOffset, 
+                                       aEndOffset);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::SetSelectionBounds(int32_t aSelectionNum,
                                            int32_t aStartOffset,
                                            int32_t aEndOffset)
 {
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  if (aSelectionNum < 0 ||
-      !Intl()->SetSelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset))
+  if (aSelectionNum < 0)
     return NS_ERROR_INVALID_ARG;
 
+  if (mIntl.IsAccessible()) {
+      if (!Intl()->SetSelectionBoundsAt(aSelectionNum, aStartOffset, 
+                                        aEndOffset)) {
+        return NS_ERROR_INVALID_ARG;
+      }
+  } else {
+      if (!mIntl.AsProxy()->SetSelectionBoundsAt(aSelectionNum, aStartOffset, 
+                                                aEndOffset)) {
+        return NS_ERROR_INVALID_ARG;
+      }
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::AddSelection(int32_t aStartOffset, int32_t aEndOffset)
 {
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->AddToSelection(aStartOffset, aEndOffset);
+  if (mIntl.IsAccessible()) {
+    Intl()->AddToSelection(aStartOffset, aEndOffset);
+  } else {
+    mIntl.AsProxy()->AddToSelection(aStartOffset, aEndOffset);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::RemoveSelection(int32_t aSelectionNum)
 {
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->RemoveFromSelection(aSelectionNum);
+  if (mIntl.IsAccessible()) {
+    Intl()->RemoveFromSelection(aSelectionNum);
+  } else {
+    mIntl.AsProxy()->RemoveFromSelection(aSelectionNum);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::ScrollSubstringTo(int32_t aStartOffset,
                                           int32_t aEndOffset,
                                           uint32_t aScrollType)
 {
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->ScrollSubstringTo(aStartOffset, aEndOffset, aScrollType);
+  if (mIntl.IsAccessible()) {
+    Intl()->ScrollSubstringTo(aStartOffset, aEndOffset, aScrollType);
+  } else {
+    mIntl.AsProxy()->ScrollSubstringTo(aStartOffset, aEndOffset, aScrollType);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::ScrollSubstringToPoint(int32_t aStartOffset,
                                                int32_t aEndOffset,
                                                uint32_t aCoordinateType,
                                                int32_t aX, int32_t aY)
 {
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->ScrollSubstringToPoint(aStartOffset, aEndOffset, aCoordinateType, aX, aY);
+  if (mIntl.IsAccessible()) {
+    Intl()->ScrollSubstringToPoint(aStartOffset, aEndOffset, aCoordinateType,
+                                   aX, aY);
+  } else {
+    mIntl.AsProxy()->ScrollSubstringToPoint(aStartOffset, aEndOffset,
+                                            aCoordinateType, aX, aY);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetEnclosingRange(nsIAccessibleTextRange** aRange)
 {
   NS_ENSURE_ARG_POINTER(aRange);
   *aRange = nullptr;
@@ -447,126 +572,171 @@ xpcAccessibleHyperText::GetRangeAtPoint(
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIAccessibleEditableText
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::SetTextContents(const nsAString& aText)
 {
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->ReplaceText(aText);
+  if (mIntl.IsAccessible()) {
+    Intl()->ReplaceText(aText);
+  } else {
+    nsString text(aText);
+    mIntl.AsProxy()->ReplaceText(text);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::InsertText(const nsAString& aText, int32_t aOffset)
 {
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->InsertText(aText, aOffset);
+  if (mIntl.IsAccessible()) {
+    Intl()->InsertText(aText, aOffset);
+  } else {
+    nsString text(aText);
+    mIntl.AsProxy()->InsertText(text, aOffset);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::CopyText(int32_t aStartOffset, int32_t aEndOffset)
 {
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->CopyText(aStartOffset, aEndOffset);
+  if (mIntl.IsAccessible()) {
+    Intl()->CopyText(aStartOffset, aEndOffset);
+  } else {
+    mIntl.AsProxy()->CopyText(aStartOffset, aEndOffset);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::CutText(int32_t aStartOffset, int32_t aEndOffset)
 {
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->CutText(aStartOffset, aEndOffset);
+  if (mIntl.IsAccessible()) {
+    Intl()->CutText(aStartOffset, aEndOffset);
+  } else {
+    mIntl.AsProxy()->CutText(aStartOffset, aEndOffset);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::DeleteText(int32_t aStartOffset, int32_t aEndOffset)
 {
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->DeleteText(aStartOffset, aEndOffset);
+  if (mIntl.IsAccessible()) {
+    Intl()->DeleteText(aStartOffset, aEndOffset);
+  } else {
+    mIntl.AsProxy()->DeleteText(aStartOffset, aEndOffset);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::PasteText(int32_t aOffset)
 {
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  Intl()->PasteText(aOffset);
+  if (mIntl.IsAccessible()) {
+    Intl()->PasteText(aOffset);
+  } else {
+    mIntl.AsProxy()->PasteText(aOffset);
+  }
   return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIAccessibleHyperText
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetLinkCount(int32_t* aLinkCount)
 {
   NS_ENSURE_ARG_POINTER(aLinkCount);
   *aLinkCount = 0;
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  *aLinkCount = Intl()->LinkCount();
+  if (mIntl.IsAccessible()) {
+    *aLinkCount = Intl()->LinkCount();
+  } else {
+    *aLinkCount = mIntl.AsProxy()->LinkCount();
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetLinkAt(int32_t aIndex, nsIAccessibleHyperLink** aLink)
 {
   NS_ENSURE_ARG_POINTER(aLink);
   *aLink = nullptr;
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  NS_IF_ADDREF(*aLink = ToXPC(Intl()->LinkAt(aIndex)));
+  if (mIntl.IsAccessible()) {
+    NS_IF_ADDREF(*aLink = ToXPC(Intl()->LinkAt(aIndex)));
+  } else {
+    NS_IF_ADDREF(*aLink = ToXPC(mIntl.AsProxy()->LinkAt(aIndex)));
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetLinkIndex(nsIAccessibleHyperLink* aLink,
                                      int32_t* aIndex)
 {
   NS_ENSURE_ARG_POINTER(aLink);
   NS_ENSURE_ARG_POINTER(aIndex);
   *aIndex = -1;
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIAccessible> xpcLink(do_QueryInterface(aLink));
-  Accessible* link = xpcLink->ToInternalAccessible();
-  if (link)
-    *aIndex = Intl()->LinkIndexOf(link);
+  if (Accessible* accLink = xpcLink->ToInternalAccessible()) {
+    *aIndex = Intl()->LinkIndexOf(accLink);
+  } else {
+    xpcAccessibleHyperText* linkHyperText =
+      static_cast<xpcAccessibleHyperText*>(xpcLink.get());
+    ProxyAccessible* proxyLink = linkHyperText->mIntl.AsProxy();
+    if (proxyLink) {
+      *aIndex = mIntl.AsProxy()->LinkIndexOf(proxyLink);
+    }
+  }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::GetLinkIndexAtOffset(int32_t aOffset,
                                              int32_t* aLinkIndex)
 {
   NS_ENSURE_ARG_POINTER(aLinkIndex);
   *aLinkIndex = -1; // API says this magic value means 'not found'
 
-  if (!Intl())
+  if (mIntl.IsNull())
     return NS_ERROR_FAILURE;
 
-  *aLinkIndex = Intl()->LinkIndexAtOffset(aOffset);
+  if (mIntl.IsAccessible()) {
+    *aLinkIndex = Intl()->LinkIndexAtOffset(aOffset);
+  } else {
+    *aLinkIndex = mIntl.AsProxy()->LinkIndexAtOffset(aOffset);
+  }
   return NS_OK;
 }