static AtkAttributeSet*
getRunAttributesCB(AtkText *aText, gint aOffset,
                   gint *aStartOffset,
                   gint *aEndOffset)
{
  *aStartOffset = -1;
  *aEndOffset = -1;

  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return nullptr;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return nullptr;

    nsCOMPtr<nsIPersistentProperties> attributes;
    int32_t startOffset = 0, endOffset = 0;
    nsresult rv = text->GetTextAttributes(false, aOffset,
                                          &startOffset, &endOffset,
                                          getter_AddRefs(attributes));
    NS_ENSURE_SUCCESS(rv, nullptr);

    *aStartOffset = startOffset;
    *aEndOffset = endOffset;

    return ConvertToAtkAttributeSet(attributes);
}
static void
getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
                  AtkCoordType aCoords, AtkTextRectangle *aRect)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if(!accWrap || !aRect)
    return;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return;

    int32_t extY = 0, extX = 0;
    int32_t extWidth = 0, extHeight = 0;

    uint32_t geckoCoordType;
    if (aCoords == ATK_XY_SCREEN)
        geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
    else
        geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;

#ifdef DEBUG
    nsresult rv =
#endif
    text->GetRangeExtents(aStartOffset, aEndOffset,
                          &extX, &extY,
                          &extWidth, &extHeight,
                          geckoCoordType);
    aRect->x = extX;
    aRect->y = extY;
    aRect->width = extWidth;
    aRect->height = extHeight;
    NS_ASSERTION(NS_SUCCEEDED(rv),
                 "MaiInterfaceText::GetRangeExtents, failed\n");
}
Exemplo n.º 3
0
static gchar*
getTextSelectionCB(AtkText *aText, gint aSelectionNum,
                   gint *aStartOffset, gint *aEndOffset)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  int32_t startOffset = 0, endOffset = 0;
  if (accWrap) {
    HyperTextAccessible* text = accWrap->AsHyperText();
    if (!text || !text->IsTextRole()) {
      return nullptr;
    }

    text->SelectionBoundsAt(aSelectionNum, &startOffset, &endOffset);
    *aStartOffset = startOffset;
    *aEndOffset = endOffset;

    return getTextCB(aText, *aStartOffset, *aEndOffset);
  } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
    nsString data;
    proxy->SelectionBoundsAt(aSelectionNum, data, &startOffset, &endOffset);
    *aStartOffset = startOffset;
    *aEndOffset = endOffset;

    NS_ConvertUTF16toUTF8 dataAsUTF8(data);
    return (dataAsUTF8.get()) ? g_strdup(dataAsUTF8.get()) : nullptr;
  }
  return nullptr;
}
static gchar*
getTextAtOffsetCB(AtkText *aText, gint aOffset,
                  AtkTextBoundary aBoundaryType,
                  gint *aStartOffset, gint *aEndOffset)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return nullptr;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return nullptr;

    nsAutoString autoStr;
    int32_t startOffset = 0, endOffset = 0;
    nsresult rv =
        text->GetTextAtOffset(aOffset, aBoundaryType,
                              &startOffset, &endOffset, autoStr);
    *aStartOffset = startOffset;
    *aEndOffset = endOffset;

    NS_ENSURE_SUCCESS(rv, nullptr);

    ConvertTexttoAsterisks(accWrap, autoStr);
    NS_ConvertUTF16toUTF8 cautoStr(autoStr);
    return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr;
}
Exemplo n.º 5
0
static gint
getOffsetAtPointCB(AtkText *aText,
                   gint aX, gint aY,
                   AtkCoordType aCoords)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (accWrap) {
    HyperTextAccessible* text = accWrap->AsHyperText();
    if (!text || !text->IsTextRole()) {
      return -1;
    }

    return static_cast<gint>(
      text->OffsetAtPoint(aX, aY,
                          (aCoords == ATK_XY_SCREEN ?
                           nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
                           nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE)));
  }

  if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
    return static_cast<gint>(
      proxy->OffsetAtPoint(aX, aY,
                           (aCoords == ATK_XY_SCREEN ?
                            nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
                            nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE)));
  }

  return -1;
}
Exemplo n.º 6
0
static void
getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
                  AtkCoordType aCoords, AtkTextRectangle *aRect)
{
  if (!aRect) {
    return;
  }

  nsIntRect rect;
  uint32_t geckoCoordType;
  if (aCoords == ATK_XY_SCREEN) {
    geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
  } else {
    geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
  }

  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if(accWrap) {
    HyperTextAccessible* text = accWrap->AsHyperText();
    if (!text || !text->IsTextRole()) {
      return;
    }

    rect = text->TextBounds(aStartOffset, aEndOffset, geckoCoordType);
  } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
    rect = proxy->TextBounds(aStartOffset, aEndOffset, geckoCoordType);
  } else {
    return;
  }

  aRect->x = rect.x;
  aRect->y = rect.y;
  aRect->width = rect.width;
  aRect->height = rect.height;
}
Exemplo n.º 7
0
static gchar*
getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
                      AtkTextBoundary aBoundaryType,
                      gint *aStartOffset, gint *aEndOffset)
{
  nsAutoString autoStr;
  int32_t startOffset = 0, endOffset = 0;
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (accWrap) {
    HyperTextAccessible* text = accWrap->AsHyperText();
    if (!text || !text->IsTextRole())
      return nullptr;

    text->TextBeforeOffset(aOffset, aBoundaryType,
                           &startOffset, &endOffset, autoStr);
    ConvertTexttoAsterisks(accWrap, autoStr);
  } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
    proxy->GetTextBeforeOffset(aOffset, aBoundaryType, autoStr, &startOffset,
                               &endOffset);
  }

  *aStartOffset = startOffset;
  *aEndOffset = endOffset;

  NS_ConvertUTF16toUTF8 cautoStr(autoStr);
  return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr;
}
Exemplo n.º 8
0
void
a11y::ProxyTextChangeEvent(ProxyAccessible* aText, const nsString& aStr,
                           int32_t aStart, uint32_t aLen, bool aInsert, bool)
{
  AccessibleWrap* wrapper = WrapperFor(aText);
  MOZ_ASSERT(wrapper);
  if (!wrapper) {
    return;
  }

  static const bool useHandler =
    Preferences::GetBool("accessibility.handler.enabled", false);

  if (useHandler) {
    wrapper->DispatchTextChangeToHandler(aInsert, aStr, aStart, aLen);
    return;
  }

  auto text = static_cast<HyperTextAccessibleWrap*>(wrapper->AsHyperText());
  if (text) {
    ia2AccessibleText::UpdateTextChangeData(text, aInsert, aStr, aStart, aLen);
  }

  uint32_t eventType = aInsert ? nsIAccessibleEvent::EVENT_TEXT_INSERTED :
    nsIAccessibleEvent::EVENT_TEXT_REMOVED;
  AccessibleWrap::FireWinEvent(wrapper, eventType);
}
Exemplo n.º 9
0
void
a11y::ProxyTextChangeEvent(ProxyAccessible* aText, const nsString& aStr,
                           int32_t aStart, uint32_t aLen, bool aInsert, bool)
{
  AccessibleWrap* wrapper = WrapperFor(aText);
  auto text = static_cast<HyperTextAccessibleWrap*>(wrapper->AsHyperText());
  if (text) {
    ia2AccessibleText::UpdateTextChangeData(text, aInsert, aStr, aStart, aLen);
  }
}
static gint
getCharacterCountCB(AtkText *aText)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return 0;

  HyperTextAccessible* textAcc = accWrap->AsHyperText();
  return textAcc->IsDefunct() ?
    0 : static_cast<gint>(textAcc->CharacterCount());
}
static gboolean
setCaretOffsetCB(AtkText *aText, gint aOffset)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return FALSE;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return false;

    nsresult rv = text->SetCaretOffset(aOffset);
    return NS_SUCCEEDED(rv) ? TRUE : FALSE;
}
static void
pasteTextCB(AtkEditableText *aText, gint aPosition)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return;

  MAI_LOG_DEBUG(("EditableText: pasteTextCB, aPosition=%d", aPosition));
  text->PasteText(aPosition);
}
static gint
getCaretOffsetCB(AtkText *aText)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return 0;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return 0;

    int32_t offset;
    nsresult rv = text->GetCaretOffset(&offset);
    return (NS_FAILED(rv)) ? 0 : static_cast<gint>(offset);
}
static void
deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return;

  MAI_LOG_DEBUG(("EditableText: deleteTextCB, aStartPos=%d, aEndPos=%d",
                 aStartPos, aEndPos));
  text->DeleteText(aStartPos, aEndPos);
}
Exemplo n.º 15
0
static gint
getCharacterCountCB(AtkText *aText)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (accWrap) {
    HyperTextAccessible* textAcc = accWrap->AsHyperText();
    return
      textAcc->IsDefunct() ? 0 : static_cast<gint>(textAcc->CharacterCount());
  }

  if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
    return proxy->CharacterCount();
  }

  return 0;
}
static void
setTextContentsCB(AtkEditableText *aText, const gchar *aString)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return;

  MAI_LOG_DEBUG(("EditableText: setTextContentsCB, aString=%s", aString));

  NS_ConvertUTF8toUTF16 strContent(aString);
  text->SetTextContents(strContent);
}
static gboolean
removeTextSelectionCB(AtkText *aText,
                      gint aSelectionNum)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return FALSE;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return false;

    nsresult rv = text->RemoveSelection(aSelectionNum);

    return NS_SUCCEEDED(rv) ? TRUE : FALSE;
}
static gboolean
setTextSelectionCB(AtkText *aText, gint aSelectionNum,
                   gint aStartOffset, gint aEndOffset)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return FALSE;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return false;

    nsresult rv = text->SetSelectionBounds(aSelectionNum,
                                           aStartOffset, aEndOffset);
    return NS_SUCCEEDED(rv) ? TRUE : FALSE;
}
static gint
getTextSelectionCountCB(AtkText *aText)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return 0;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return 0;

    int32_t selectionCount;
    nsresult rv = text->GetSelectionCount(&selectionCount);
 
    return NS_FAILED(rv) ? 0 : selectionCount;
}
static AtkAttributeSet*
getDefaultAttributesCB(AtkText *aText)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return nullptr;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return nullptr;

    nsCOMPtr<nsIPersistentProperties> attributes;
    nsresult rv = text->GetDefaultTextAttributes(getter_AddRefs(attributes));
    if (NS_FAILED(rv))
        return nullptr;

    return ConvertToAtkAttributeSet(attributes);
}
Exemplo n.º 21
0
static gboolean
removeTextSelectionCB(AtkText *aText,
                      gint aSelectionNum)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (accWrap) {
    HyperTextAccessible* text = accWrap->AsHyperText();
    if (!text || !text->IsTextRole()) {
      return FALSE;
    }

    return text->RemoveFromSelection(aSelectionNum);
  } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
    return proxy->RemoveFromSelection(aSelectionNum);
  }

  return FALSE;
}
Exemplo n.º 22
0
static gboolean
setTextSelectionCB(AtkText *aText, gint aSelectionNum,
                   gint aStartOffset, gint aEndOffset)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (accWrap) {
    HyperTextAccessible* text = accWrap->AsHyperText();
    if (!text || !text->IsTextRole()) {
      return FALSE;
    }

    return text->SetSelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset);
  } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
    return proxy->SetSelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset);
  }

  return FALSE;
}
static void
insertTextCB(AtkEditableText *aText,
             const gchar *aString, gint aLength, gint *aPosition)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return;

  NS_ConvertUTF8toUTF16 strContent(aString, aLength);
  text->InsertText(strContent, *aPosition);

  MAI_LOG_DEBUG(("EditableText: insert aString=%s, aLength=%d, aPosition=%d",
                 aString, aLength, *aPosition));
}
Exemplo n.º 24
0
static gint
getCaretOffsetCB(AtkText *aText)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (accWrap) {
    HyperTextAccessible* text = accWrap->AsHyperText();
    if (!text || !text->IsTextRole()) {
      return 0;
    }

    return static_cast<gint>(text->CaretOffset());
  }

  if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
    return static_cast<gint>(proxy->CaretOffset());
  }

  return 0;
}
Exemplo n.º 25
0
static gint
getTextSelectionCountCB(AtkText *aText)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (accWrap) {
    HyperTextAccessible* text = accWrap->AsHyperText();
    if (!text || !text->IsTextRole()) {
      return 0;
    }

    return text->SelectionCount();
  }

  if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
    return proxy->SelectionCount();
  }

  return 0;
}
Exemplo n.º 26
0
void
a11y::ProxyTextChangeEvent(ProxyAccessible* aText, const nsString& aStr,
                           int32_t aStart, uint32_t aLen, bool aInsert, bool)
{
  AccessibleWrap* wrapper = WrapperFor(aText);
  MOZ_ASSERT(wrapper);
  if (!wrapper) {
    return;
  }

  auto text = static_cast<HyperTextAccessibleWrap*>(wrapper->AsHyperText());
  if (text) {
    ia2AccessibleText::UpdateTextChangeData(text, aInsert, aStr, aStart, aLen);
  }

  uint32_t eventType = aInsert ? nsIAccessibleEvent::EVENT_TEXT_INSERTED :
    nsIAccessibleEvent::EVENT_TEXT_REMOVED;
  AccessibleWrap::FireWinEvent(wrapper, eventType);
}
Exemplo n.º 27
0
static gunichar
getCharacterAtOffsetCB(AtkText* aText, gint aOffset)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (accWrap) {
    HyperTextAccessible* text = accWrap->AsHyperText();
    if (!text || !text->IsTextRole()) {
      return 0;
    }

    // char16_t is unsigned short in Mozilla, gnuichar is guint32 in glib.
    return static_cast<gunichar>(text->CharAt(aOffset));
  }

  if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
    return static_cast<gunichar>(proxy->CharAt(aOffset));
  }

  return 0;
}
static gchar*
getTextCB(AtkText *aText, gint aStartOffset, gint aEndOffset)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return nullptr;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return nullptr;

    nsAutoString autoStr;
    nsresult rv = text->GetText(aStartOffset, aEndOffset, autoStr);
    NS_ENSURE_SUCCESS(rv, nullptr);

    ConvertTexttoAsterisks(accWrap, autoStr);
    NS_ConvertUTF16toUTF8 cautoStr(autoStr);

    //copy and return, libspi will free it.
    return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr;
}
Exemplo n.º 29
0
static gboolean
setCaretOffsetCB(AtkText *aText, gint aOffset)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (accWrap) {
    HyperTextAccessible* text = accWrap->AsHyperText();
    if (!text || !text->IsTextRole() || !text->IsValidOffset(aOffset)) {
      return FALSE;
    }

    text->SetCaretOffset(aOffset);
    return TRUE;
  }

  if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
    if (proxy->SetCaretOffset(aOffset)) {
      return TRUE;
    }
  }

  return FALSE;
}
Exemplo n.º 30
0
static gchar*
getTextCB(AtkText *aText, gint aStartOffset, gint aEndOffset)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  nsAutoString autoStr;
  if (accWrap) {
    HyperTextAccessible* text = accWrap->AsHyperText();
    if (!text || !text->IsTextRole())
      return nullptr;

    text->TextSubstring(aStartOffset, aEndOffset, autoStr);

    ConvertTexttoAsterisks(accWrap, autoStr);
  } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
    proxy->TextSubstring(aStartOffset, aEndOffset, autoStr);
  }

  NS_ConvertUTF16toUTF8 cautoStr(autoStr);

  //copy and return, libspi will free it.
  return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr;
}