コード例 #1
0
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;

  HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
  if (text->IsDefunct())
    return NS_ERROR_FAILURE;

  nsIntRect rect = text->CharBounds(aOffset, aCoordType);
  *aX = rect.x; *aY = rect.y;
  *aWidth = rect.width; *aHeight = rect.height;
  return NS_OK;
}
コード例 #2
0
static void
getCharacterExtentsCB(AtkText *aText, gint aOffset,
                      gint *aX, gint *aY,
                      gint *aWidth, gint *aHeight,
                      AtkCoordType aCoords)
{
  if(!aX || !aY || !aWidth || !aHeight) {
    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->CharBounds(aOffset, geckoCoordType);
  } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
    rect = proxy->CharBounds(aOffset, geckoCoordType);
  } else {
    return;
  }

  *aX = rect.x;
  *aY = rect.y;
  *aWidth = rect.width;
  *aHeight = rect.height;
}