зеркало из https://github.com/mozilla/gecko-dev.git
Bug 357430 New ATK: expose AtkImage interface via nsIAccessibleImage
patch by Mike Gao and Nian Liu r=aaronleventhal,ginn.chen
This commit is contained in:
Родитель
5ec6f0c1f2
Коммит
6c63ab34e6
|
@ -69,6 +69,7 @@ XPIDLSRCS = \
|
|||
nsIAccessibleTable.idl \
|
||||
nsIAccessibleText.idl \
|
||||
nsIAccessibleValue.idl \
|
||||
nsIAccessibleImage.idl \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_XUL
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Original Author: Gao, Ming (gaoming@cn.ibm.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
*
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
[scriptable, uuid(6e80cec3-ff7f-48f2-9823-0b962a0ed508)]
|
||||
interface nsIAccessibleImage: nsISupports
|
||||
{
|
||||
void getImageBounds(out long x,
|
||||
out long y,
|
||||
out long width,
|
||||
out long height);
|
||||
};
|
|
@ -79,6 +79,7 @@ CPPSRCS = \
|
|||
nsMaiInterfaceHyperlinkImpl.cpp \
|
||||
nsMaiInterfaceTable.cpp \
|
||||
nsMaiInterfaceDocument.cpp \
|
||||
nsMaiInterfaceImage.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_XUL
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsIPersistentProperties2.h"
|
||||
#include "nsMaiInterfaceDocument.h"
|
||||
#include "nsMaiInterfaceImage.h"
|
||||
|
||||
extern "C" GType g_atk_hyperlink_impl_type; //defined in nsAppRootAccessible.cpp
|
||||
|
||||
|
@ -87,7 +88,8 @@ enum MaiInterfaceType {
|
|||
MAI_INTERFACE_SELECTION,
|
||||
MAI_INTERFACE_TABLE,
|
||||
MAI_INTERFACE_TEXT,
|
||||
MAI_INTERFACE_DOCUMENT /* 9 */
|
||||
MAI_INTERFACE_DOCUMENT,
|
||||
MAI_INTERFACE_IMAGE /* 10 */
|
||||
};
|
||||
|
||||
static GType GetAtkTypeForMai(MaiInterfaceType type)
|
||||
|
@ -113,6 +115,8 @@ static GType GetAtkTypeForMai(MaiInterfaceType type)
|
|||
return ATK_TYPE_TEXT;
|
||||
case MAI_INTERFACE_DOCUMENT:
|
||||
return ATK_TYPE_DOCUMENT;
|
||||
case MAI_INTERFACE_IMAGE:
|
||||
return ATK_TYPE_IMAGE;
|
||||
}
|
||||
return G_TYPE_INVALID;
|
||||
}
|
||||
|
@ -137,6 +141,8 @@ static const GInterfaceInfo atk_if_infos[] = {
|
|||
{(GInterfaceInitFunc)textInterfaceInitCB,
|
||||
(GInterfaceFinalizeFunc) NULL, NULL},
|
||||
{(GInterfaceInitFunc)documentInterfaceInitCB,
|
||||
(GInterfaceFinalizeFunc) NULL, NULL},
|
||||
{(GInterfaceInitFunc)imageInterfaceInitCB,
|
||||
(GInterfaceFinalizeFunc) NULL, NULL}
|
||||
};
|
||||
|
||||
|
@ -173,7 +179,8 @@ static void finalizeCB(GObject *aObj);
|
|||
|
||||
/* callbacks for AtkObject virtual functions */
|
||||
static const gchar* getNameCB (AtkObject *aAtkObj);
|
||||
static const gchar* getDescriptionCB (AtkObject *aAtkObj);
|
||||
/* getDescriptionCB is also used by image interface */
|
||||
const gchar* getDescriptionCB (AtkObject *aAtkObj);
|
||||
static AtkRole getRoleCB(AtkObject *aAtkObj);
|
||||
static AtkAttributeSet* getAttributesCB(AtkObject *aAtkObj);
|
||||
static AtkObject* getParentCB(AtkObject *aAtkObj);
|
||||
|
@ -405,6 +412,14 @@ nsAccessibleWrap::CreateMaiInterfaces(void)
|
|||
interfacesBits |= 1 << MAI_INTERFACE_DOCUMENT;
|
||||
}
|
||||
|
||||
//nsIAccessibleImage
|
||||
nsCOMPtr<nsIAccessibleImage> accessInterfaceImage;
|
||||
QueryInterface(NS_GET_IID(nsIAccessibleImage),
|
||||
getter_AddRefs(accessInterfaceImage));
|
||||
if (accessInterfaceImage) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_IMAGE;
|
||||
}
|
||||
|
||||
return interfacesBits;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
||||
*/
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gao, Ming (gaoming@cn.ibm.com)
|
||||
* Neo Liu(nian.liu@sun.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsAccessibleWrap.h"
|
||||
#include "nsMaiInterfaceImage.h"
|
||||
|
||||
extern "C" const gchar* getDescriptionCB(AtkObject* aAtkObj);
|
||||
|
||||
void
|
||||
imageInterfaceInitCB(AtkImageIface *aIface)
|
||||
{
|
||||
g_return_if_fail(aIface != NULL);
|
||||
|
||||
aIface->get_image_position = getImagePositionCB;
|
||||
aIface->get_image_description = getImageDescriptionCB;
|
||||
aIface->get_image_size = getImageSizeCB;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
getImagePositionCB(AtkImage *aImage, gint *aAccX, gint *aAccY,
|
||||
AtkCoordType aCoordType)
|
||||
{
|
||||
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
||||
if (!accWrap)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIAccessibleImage> image;
|
||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleImage),
|
||||
getter_AddRefs(image));
|
||||
if (!image)
|
||||
return;
|
||||
|
||||
PRInt32 width, height; // dummy
|
||||
image->GetImageBounds(aAccX, aAccY, &width, &height);
|
||||
// TODO: translate (x,y) accroding aCoordType. see bug 369821
|
||||
}
|
||||
|
||||
const gchar *
|
||||
getImageDescriptionCB(AtkImage *aImage)
|
||||
{
|
||||
return getDescriptionCB(ATK_OBJECT(aImage));
|
||||
}
|
||||
|
||||
void
|
||||
getImageSizeCB(AtkImage *aImage, gint *aAccWidth, gint *aAccHeight)
|
||||
{
|
||||
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
||||
if (!accWrap)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIAccessibleImage> image;
|
||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleImage),
|
||||
getter_AddRefs(image));
|
||||
if (!image)
|
||||
return;
|
||||
|
||||
PRInt32 x,y; // dummy
|
||||
image->GetImageBounds(&x, &y, aAccWidth, aAccHeight);
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
||||
*/
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gao, Ming (gaoming@cn.ibm.com)
|
||||
* Neo Liu(nian.liu@sun.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __MAI_INTERFACE_IMAGE_H__
|
||||
#define __MAI_INTERFACE_IMAGE_H__
|
||||
|
||||
#include "nsMai.h"
|
||||
#include "nsIAccessibleImage.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void imageInterfaceInitCB(AtkImageIface *aIface);
|
||||
|
||||
/* image interface callbacks */
|
||||
void getImagePositionCB(AtkImage *aImage,
|
||||
gint *aAccX,
|
||||
gint *aAccY,
|
||||
AtkCoordType aCoordType);
|
||||
const gchar* getImageDescriptionCB(AtkImage *aImage);
|
||||
void getImageSizeCB(AtkImage *aImage,
|
||||
gint *aAccWidth,
|
||||
gint *aAccHeight);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MAI_INTERFACE_DOCUMENT_H__ */
|
|
@ -75,6 +75,8 @@ nsLinkableAccessible(aDOMNode, aShell)
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLImageAccessible, nsLinkableAccessible, nsIAccessibleImage)
|
||||
|
||||
NS_IMETHODIMP nsHTMLImageAccessible::GetState(PRUint32 *_retval)
|
||||
{
|
||||
// The state is a bitfield, get our inherited state, then logically OR it with STATE_ANIMATED if this
|
||||
|
@ -238,3 +240,7 @@ NS_IMETHODIMP nsHTMLImageAccessible::DoAction(PRUint8 index)
|
|||
return nsLinkableAccessible::DoAction(index);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLImageAccessible::GetImageBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
|
||||
{
|
||||
return GetBounds(x, y, width, height);
|
||||
}
|
||||
|
|
|
@ -41,25 +41,32 @@
|
|||
|
||||
#include "nsBaseWidgetAccessible.h"
|
||||
#include "nsIDOMHTMLMapElement.h"
|
||||
#include "nsIAccessibleImage.h"
|
||||
|
||||
/* Accessible for supporting images
|
||||
* supports:
|
||||
* - gets name, role
|
||||
* - support basic state
|
||||
*/
|
||||
class nsHTMLImageAccessible : public nsLinkableAccessible
|
||||
class nsHTMLImageAccessible : public nsLinkableAccessible,
|
||||
public nsIAccessibleImage
|
||||
{
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
public:
|
||||
//action0 may exist depends on whether an onclick is associated with it
|
||||
enum { eAction_ShowLongDescription = 1 };
|
||||
|
||||
nsHTMLImageAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD GetName(nsAString& _retval);
|
||||
NS_IMETHOD GetState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetRole(PRUint32 *_retval);
|
||||
NS_IMETHOD DoAction(PRUint8 index);
|
||||
|
||||
NS_IMETHOD GetImageBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
|
||||
|
||||
protected:
|
||||
virtual void CacheChildren();
|
||||
already_AddRefed<nsIAccessible> CreateAreaAccessible(PRInt32 areaNum);
|
||||
|
|
Загрузка…
Ссылка в новой задаче