2011-04-27 13:42:18 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2011-05-27 22:37:24 +00:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2003-05-06 02:23:50 +00:00
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
#include "InterfaceInitFuncs.h"
|
2010-04-27 06:52:03 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
#include "AccessibleWrap.h"
|
2010-04-27 06:52:03 +00:00
|
|
|
#include "nsAccUtils.h"
|
|
|
|
#include "nsCoreUtils.h"
|
2012-03-20 04:02:50 +00:00
|
|
|
#include "nsMai.h"
|
2012-10-26 13:32:10 +00:00
|
|
|
#include "mozilla/Likely.h"
|
2010-04-27 06:52:03 +00:00
|
|
|
|
2012-11-18 02:01:44 +00:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
extern "C" {
|
2003-05-06 02:23:50 +00:00
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static AtkObject*
|
2011-04-27 13:42:18 +00:00
|
|
|
refAccessibleAtPointCB(AtkComponent* aComponent, gint aAccX, gint aAccY,
|
2003-05-06 02:23:50 +00:00
|
|
|
AtkCoordType aCoordType)
|
|
|
|
{
|
2011-04-27 13:42:18 +00:00
|
|
|
return refAccessibleAtPointHelper(GetAccessibleWrap(ATK_OBJECT(aComponent)),
|
|
|
|
aAccX, aAccY, aCoordType);
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static void
|
2011-04-27 13:42:18 +00:00
|
|
|
getExtentsCB(AtkComponent* aComponent, gint* aX, gint* aY,
|
|
|
|
gint* aWidth, gint* aHeight, AtkCoordType aCoordType)
|
2003-05-06 02:23:50 +00:00
|
|
|
{
|
2011-04-27 13:42:18 +00:00
|
|
|
getExtentsHelper(GetAccessibleWrap(ATK_OBJECT(aComponent)),
|
|
|
|
aX, aY, aWidth, aHeight, aCoordType);
|
|
|
|
}
|
2007-01-16 18:37:21 +00:00
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static gboolean
|
2011-04-27 13:42:18 +00:00
|
|
|
grabFocusCB(AtkComponent* aComponent)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
|
2011-04-27 13:42:18 +00:00
|
|
|
if (!accWrap)
|
|
|
|
return FALSE;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
2011-04-27 13:42:18 +00:00
|
|
|
nsresult rv = accWrap->TakeFocus();
|
|
|
|
return (NS_FAILED(rv)) ? FALSE : TRUE;
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
2012-03-20 04:02:50 +00:00
|
|
|
}
|
2003-05-06 02:23:50 +00:00
|
|
|
|
2011-04-27 13:42:18 +00:00
|
|
|
AtkObject*
|
2012-05-29 01:18:45 +00:00
|
|
|
refAccessibleAtPointHelper(AccessibleWrap* aAccWrap, gint aX, gint aY,
|
2011-04-27 13:42:18 +00:00
|
|
|
AtkCoordType aCoordType)
|
|
|
|
{
|
|
|
|
if (!aAccWrap || aAccWrap->IsDefunct() || nsAccUtils::MustPrune(aAccWrap))
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-04-27 13:42:18 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
// Accessible::ChildAtPoint(x,y) is in screen pixels.
|
2011-04-27 13:42:18 +00:00
|
|
|
if (aCoordType == ATK_XY_WINDOW) {
|
|
|
|
nsIntPoint winCoords =
|
|
|
|
nsCoreUtils::GetScreenCoordsForWindow(aAccWrap->GetNode());
|
|
|
|
aX += winCoords.x;
|
|
|
|
aY += winCoords.y;
|
|
|
|
}
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* accAtPoint = aAccWrap->ChildAtPoint(aX, aY,
|
|
|
|
Accessible::eDirectChild);
|
2011-04-27 13:42:18 +00:00
|
|
|
if (!accAtPoint)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-04-27 13:42:18 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
AtkObject* atkObj = AccessibleWrap::GetAtkObject(accAtPoint);
|
2011-04-27 13:42:18 +00:00
|
|
|
if (atkObj)
|
|
|
|
g_object_ref(atkObj);
|
|
|
|
return atkObj;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-29 01:18:45 +00:00
|
|
|
getExtentsHelper(AccessibleWrap* aAccWrap,
|
2011-04-27 13:42:18 +00:00
|
|
|
gint* aX, gint* aY, gint* aWidth, gint* aHeight,
|
|
|
|
AtkCoordType aCoordType)
|
2003-05-06 02:23:50 +00:00
|
|
|
{
|
2011-04-27 13:42:18 +00:00
|
|
|
*aX = *aY = *aWidth = *aHeight = 0;
|
|
|
|
|
|
|
|
if (!aAccWrap || aAccWrap->IsDefunct())
|
|
|
|
return;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t x = 0, y = 0, width = 0, height = 0;
|
2011-04-27 13:42:18 +00:00
|
|
|
// Returned in screen coordinates
|
|
|
|
nsresult rv = aAccWrap->GetBounds(&x, &y, &width, &height);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (aCoordType == ATK_XY_WINDOW) {
|
|
|
|
nsIntPoint winCoords =
|
|
|
|
nsCoreUtils::GetScreenCoordsForWindow(aAccWrap->GetNode());
|
|
|
|
x -= winCoords.x;
|
|
|
|
y -= winCoords.y;
|
|
|
|
}
|
2003-05-06 02:23:50 +00:00
|
|
|
|
2011-04-27 13:42:18 +00:00
|
|
|
*aX = x;
|
|
|
|
*aY = y;
|
|
|
|
*aWidth = width;
|
|
|
|
*aHeight = height;
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
2012-03-20 04:02:50 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
componentInterfaceInitCB(AtkComponentIface* aIface)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aIface, "Invalid Interface");
|
2012-10-26 13:32:10 +00:00
|
|
|
if(MOZ_UNLIKELY(!aIface))
|
2012-03-20 04:02:50 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use default implementation in atk for contains, get_position,
|
|
|
|
* and get_size
|
|
|
|
*/
|
|
|
|
aIface->ref_accessible_at_point = refAccessibleAtPointCB;
|
|
|
|
aIface->get_extents = getExtentsCB;
|
|
|
|
aIface->grab_focus = grabFocusCB;
|
|
|
|
}
|