Bug 1145292 - IPC Proxy for ImageAccessible, r=tbsaunde

This commit is contained in:
Olli Pettay 2015-03-22 23:44:12 +02:00
parent 0326e5b8f2
commit dca3be308d
7 changed files with 109 additions and 14 deletions

View File

@ -12,6 +12,7 @@
#include "nsMai.h"
#include "nsIAccessibleTypes.h"
#include "nsIURI.h"
#include "ProxyAccessible.h"
using namespace mozilla;
using namespace mozilla::a11y;
@ -23,15 +24,19 @@ static void
getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
AtkCoordType aCoordType)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
if (!accWrap || !accWrap->IsImage())
return;
ImageAccessible* image = accWrap->AsImage();
nsIntPoint pos;
uint32_t geckoCoordType = (aCoordType == ATK_XY_WINDOW) ?
nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE :
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
nsIntPoint pos = image->Position(geckoCoordType);
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
if (accWrap && accWrap->IsImage()) {
ImageAccessible* image = accWrap->AsImage();
pos = image->Position(geckoCoordType);
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aImage))) {
pos = proxy->ImagePosition(geckoCoordType);
}
*aAccX = pos.x;
*aAccY = pos.y;
}
@ -45,11 +50,14 @@ getImageDescriptionCB(AtkImage* aImage)
static void
getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
{
nsIntSize size;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
if (!accWrap || !accWrap->IsImage())
return;
if (accWrap && accWrap->IsImage()) {
size = accWrap->AsImage()->Size();
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aImage))) {
size = proxy->ImageSize();
}
nsIntSize size = accWrap->AsImage()->Size();
*aAccWidth = size.width;
*aAccHeight = size.height;
}

View File

@ -10,6 +10,7 @@
#include "ProxyAccessible.h"
#include "Relation.h"
#include "HyperTextAccessible-inl.h"
#include "ImageAccessible.h"
#include "nsIPersistentProperties2.h"
#include "nsISimpleEnumerator.h"
@ -46,19 +47,26 @@ SerializeTree(Accessible* aRoot, nsTArray<AccessibleData>& aTree)
}
Accessible*
DocAccessibleChild::IdToAccessible(const uint64_t& aID)
DocAccessibleChild::IdToAccessible(const uint64_t& aID) const
{
return mDoc->GetAccessibleByUniqueID(reinterpret_cast<void*>(aID));
}
HyperTextAccessible*
DocAccessibleChild::IdToHyperTextAccessible(const uint64_t& aID)
DocAccessibleChild::IdToHyperTextAccessible(const uint64_t& aID) const
{
Accessible* acc = IdToAccessible(aID);
MOZ_ASSERT(!acc || acc->IsHyperText());
return acc ? acc->AsHyperText() : nullptr;
}
ImageAccessible*
DocAccessibleChild::IdToImageAccessible(const uint64_t& aID) const
{
Accessible* acc = IdToAccessible(aID);
return (acc && acc->IsImage()) ? acc->AsImage() : nullptr;
}
void
DocAccessibleChild::ShowEvent(AccShowEvent* aShowEvent)
{
@ -584,5 +592,31 @@ DocAccessibleChild::RecvPasteText(const uint64_t& aID,
return true;
}
bool
DocAccessibleChild::RecvImagePosition(const uint64_t& aID,
const uint32_t& aCoordType,
nsIntPoint* aRetVal)
{
ImageAccessible* acc = IdToImageAccessible(aID);
if (acc) {
*aRetVal = acc->Position(aCoordType);
}
return true;
}
bool
DocAccessibleChild::RecvImageSize(const uint64_t& aID,
nsIntSize* aRetVal)
{
ImageAccessible* acc = IdToImageAccessible(aID);
if (acc) {
*aRetVal = acc->Size();
}
return true;
}
}
}

View File

@ -15,6 +15,7 @@ namespace mozilla {
namespace a11y {
class Accessible;
class HyperTextAccessible;
class ImageAccessible;
class AccShowEvent;
@ -34,9 +35,6 @@ public:
MOZ_COUNT_DTOR(DocAccessibleChild);
}
Accessible* IdToAccessible(const uint64_t& aID);
HyperTextAccessible* IdToHyperTextAccessible(const uint64_t& aID);
void ShowEvent(AccShowEvent* aShowEvent);
/*
@ -184,7 +182,19 @@ public:
virtual bool RecvPasteText(const uint64_t& aID,
const int32_t& aPosition) override;
virtual bool RecvImagePosition(const uint64_t& aID,
const uint32_t& aCoordType,
nsIntPoint* aRetVal) override;
virtual bool RecvImageSize(const uint64_t& aID,
nsIntSize* aRetVal) override;
private:
Accessible* IdToAccessible(const uint64_t& aID) const;
HyperTextAccessible* IdToHyperTextAccessible(const uint64_t& aID) const;
ImageAccessible* IdToImageAccessible(const uint64_t& aID) const;
bool PersistentPropertiesToArray(nsIPersistentProperties* aProps,
nsTArray<Attribute>* aAttributes);

View File

@ -8,6 +8,8 @@ include protocol PContent;
include "mozilla/GfxMessageUtils.h";
using struct nsIntPoint from "nsRect.h";
using struct nsIntSize from "nsRect.h";
using struct nsIntRect from "nsRect.h";
namespace mozilla {
@ -121,6 +123,9 @@ child:
prio(high) sync CutText(uint64_t aID, int32_t aStartPos, int32_t aEndPos);
prio(high) sync DeleteText(uint64_t aID, int32_t aStartPos, int32_t aEndPos);
prio(high) sync PasteText(uint64_t aID, int32_t aPosition);
prio(high) sync ImagePosition(uint64_t aID, uint32_t aCoordType) returns(nsIntPoint aRetVal);
prio(high) sync ImageSize(uint64_t aID) returns(nsIntSize aRetVal);
};
}

View File

@ -363,5 +363,21 @@ ProxyAccessible::PasteText(int32_t aPosition)
unused << mDoc->SendPasteText(mID, aPosition);
}
nsIntPoint
ProxyAccessible::ImagePosition(uint32_t aCoordType)
{
nsIntPoint retVal;
unused << mDoc->SendImagePosition(mID, aCoordType, &retVal);
return retVal;
}
nsIntSize
ProxyAccessible::ImageSize()
{
nsIntSize retVal;
unused << mDoc->SendImageSize(mID, &retVal);
return retVal;
}
}
}

View File

@ -177,6 +177,10 @@ public:
void PasteText(int32_t aPosition);
nsIntPoint ImagePosition(uint32_t aCoordType);
nsIntSize ImageSize();
/**
* Allow the platform to store a pointers worth of data on us.
*/

View File

@ -26,6 +26,24 @@ if CONFIG['ACCESSIBILITY']:
'../generic',
]
if CONFIG['MOZ_ENABLE_GTK']:
LOCAL_INCLUDES += [
'/accessible/atk',
]
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
LOCAL_INCLUDES += [
'/accessible/windows/ia2',
'/accessible/windows/msaa',
]
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
LOCAL_INCLUDES += [
'/accessible/mac',
]
else:
LOCAL_INCLUDES += [
'/accessible/other',
]
FINAL_LIBRARY = 'xul'
include('/ipc/chromium/chromium-config.mozbuild')