Bug 1068734 - dexpcomify remaining accessible classes, r=tbsaunde

This commit is contained in:
Alexander Surkov 2014-09-23 08:23:02 -04:00
parent 88ced9ca82
commit ed6d525722
20 changed files with 501 additions and 329 deletions

View File

@ -85,7 +85,7 @@ ApplicationAccessibleWrap::Name(nsString& aName)
// Firefox or Thunderbird) like IA2 does. Thus let's return an application
// name as accessible name that was used to get a branding name (for example,
// Minefield aka nightly Firefox or Daily aka nightly Thunderbird).
GetAppName(aName);
AppName(aName);
return eNameOK;
}

View File

@ -79,19 +79,16 @@ getDocumentAttributesCB(AtkDocument *aDocument)
GSList* attributes = nullptr;
DocAccessible* document = accWrap->AsDoc();
nsAutoString aURL;
nsresult rv = document->GetURL(aURL);
if (NS_SUCCEEDED(rv))
attributes = prependToList(attributes, kDocUrlName, aURL);
document->URL(aURL);
attributes = prependToList(attributes, kDocUrlName, aURL);
nsAutoString aW3CDocType;
rv = document->GetDocType(aW3CDocType);
if (NS_SUCCEEDED(rv))
attributes = prependToList(attributes, kDocTypeName, aW3CDocType);
document->GetDocType(aW3CDocType);
attributes = prependToList(attributes, kDocTypeName, aW3CDocType);
nsAutoString aMimeType;
rv = document->GetMimeType(aMimeType);
if (NS_SUCCEEDED(rv))
attributes = prependToList(attributes, kMimeTypeName, aMimeType);
document->MimeType(aMimeType);
attributes = prependToList(attributes, kMimeTypeName, aMimeType);
return attributes;
}
@ -110,9 +107,9 @@ getDocumentAttributeValueCB(AtkDocument *aDocument,
if (!strcasecmp(aAttrName, kDocTypeName))
rv = document->GetDocType(attrValue);
else if (!strcasecmp(aAttrName, kDocUrlName))
rv = document->GetURL(attrValue);
document->URL(attrValue);
else if (!strcasecmp(aAttrName, kMimeTypeName))
rv = document->GetMimeType(attrValue);
document->MimeType(attrValue);
else
return nullptr;

View File

@ -128,64 +128,6 @@ ApplicationAccessible::Bounds() const
return nsIntRect();
}
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleApplication
NS_IMETHODIMP
ApplicationAccessible::GetAppName(nsAString& aName)
{
aName.Truncate();
if (!mAppInfo)
return NS_ERROR_FAILURE;
nsAutoCString cname;
nsresult rv = mAppInfo->GetName(cname);
NS_ENSURE_SUCCESS(rv, rv);
AppendUTF8toUTF16(cname, aName);
return NS_OK;
}
NS_IMETHODIMP
ApplicationAccessible::GetAppVersion(nsAString& aVersion)
{
aVersion.Truncate();
if (!mAppInfo)
return NS_ERROR_FAILURE;
nsAutoCString cversion;
nsresult rv = mAppInfo->GetVersion(cversion);
NS_ENSURE_SUCCESS(rv, rv);
AppendUTF8toUTF16(cversion, aVersion);
return NS_OK;
}
NS_IMETHODIMP
ApplicationAccessible::GetPlatformName(nsAString& aName)
{
aName.AssignLiteral("Gecko");
return NS_OK;
}
NS_IMETHODIMP
ApplicationAccessible::GetPlatformVersion(nsAString& aVersion)
{
aVersion.Truncate();
if (!mAppInfo)
return NS_ERROR_FAILURE;
nsAutoCString cversion;
nsresult rv = mAppInfo->GetPlatformVersion(cversion);
NS_ENSURE_SUCCESS(rv, rv);
AppendUTF8toUTF16(cversion, aVersion);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// Accessible public methods

View File

@ -9,7 +9,7 @@
#define mozilla_a11y_ApplicationAccessible_h__
#include "AccessibleWrap.h"
#include "nsIAccessibleApplication.h"
#include "xpcAccessibleApplication.h"
#include "nsIMutableArray.h"
#include "nsIXULAppInfo.h"
@ -28,7 +28,7 @@ namespace a11y {
*/
class ApplicationAccessible : public AccessibleWrap,
public nsIAccessibleApplication
public xpcAccessibleApplication
{
public:
@ -37,9 +37,6 @@ public:
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessibleApplication
NS_DECL_NSIACCESSIBLEAPPLICATION
// Accessible
virtual void Shutdown();
virtual nsIntRect Bounds() const MOZ_OVERRIDE;
@ -63,6 +60,33 @@ public:
// ActionAccessible
virtual KeyBinding AccessKey() const;
// ApplicationAccessible
void AppName(nsAString& aName) const
{
nsAutoCString cname;
mAppInfo->GetName(cname);
AppendUTF8toUTF16(cname, aName);
}
void AppVersion(nsAString& aVersion) const
{
nsAutoCString cversion;
mAppInfo->GetVersion(cversion);
AppendUTF8toUTF16(cversion, aVersion);
}
void PlatformName(nsAString& aName) const
{
aName.AssignLiteral("Gecko");
}
void PlatformVersion(nsAString& aVersion) const
{
nsAutoCString cversion;
mAppInfo->GetPlatformVersion(cversion);
AppendUTF8toUTF16(cversion, aVersion);
}
protected:
virtual ~ApplicationAccessible() {}

View File

@ -9,6 +9,7 @@
#include "DocAccessible.h"
#include "nsAccessibilityService.h"
#include "nsAccessiblePivot.h"
#include "NotificationController.h"
#include "States.h"
#include "nsIScrollableFrame.h"
@ -20,6 +21,16 @@
namespace mozilla {
namespace a11y {
inline nsIAccessiblePivot*
DocAccessible::VirtualCursor()
{
if (!mVirtualCursor) {
mVirtualCursor = new nsAccessiblePivot(this);
mVirtualCursor->AddObserver(this);
}
return mVirtualCursor;
}
inline void
DocAccessible::FireDelayedEvent(AccEvent* aEvent)
{

View File

@ -40,7 +40,6 @@
#include "nsIURI.h"
#include "nsIWebNavigation.h"
#include "nsFocusManager.h"
#include "nsNameSpaceManager.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/EventStates.h"
@ -76,7 +75,7 @@ static const uint32_t kRelationAttrsLen = ArrayLength(kRelationAttrs);
DocAccessible::
DocAccessible(nsIDocument* aDocument, nsIContent* aRootContent,
nsIPresShell* aPresShell) :
HyperTextAccessibleWrap(aRootContent, this),
HyperTextAccessibleWrap(aRootContent, this), xpcAccessibleDocument(),
// XXX aaronl should we use an algorithm for the initial cache size?
mAccessibleCache(kDefaultCacheLength),
mNodeToAccessibleMap(kDefaultCacheLength),
@ -175,12 +174,12 @@ DocAccessible::Name(nsString& aName)
Accessible::Name(aName);
}
if (aName.IsEmpty()) {
GetTitle(aName); // Try title element
Title(aName); // Try title element
}
if (aName.IsEmpty()) { // Last resort: use URL
GetURL(aName);
URL(aName);
}
return eNameOK;
}
@ -323,174 +322,6 @@ DocAccessible::TakeFocus()
nsFocusManager::MOVEFOCUS_ROOT, 0, getter_AddRefs(newFocus));
}
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleDocument
NS_IMETHODIMP
DocAccessible::GetURL(nsAString& aURL)
{
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsISupports> container = mDocumentNode->GetContainer();
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(container));
nsAutoCString theURL;
if (webNav) {
nsCOMPtr<nsIURI> pURI;
webNav->GetCurrentURI(getter_AddRefs(pURI));
if (pURI)
pURI->GetSpec(theURL);
}
CopyUTF8toUTF16(theURL, aURL);
return NS_OK;
}
NS_IMETHODIMP
DocAccessible::GetTitle(nsAString& aTitle)
{
if (!mDocumentNode) {
return NS_ERROR_FAILURE;
}
nsString title;
mDocumentNode->GetTitle(title);
aTitle = title;
return NS_OK;
}
NS_IMETHODIMP
DocAccessible::GetMimeType(nsAString& aMimeType)
{
if (!mDocumentNode) {
return NS_ERROR_FAILURE;
}
return mDocumentNode->GetContentType(aMimeType);
}
NS_IMETHODIMP
DocAccessible::GetDocType(nsAString& aDocType)
{
#ifdef MOZ_XUL
nsCOMPtr<nsIXULDocument> xulDoc(do_QueryInterface(mDocumentNode));
if (xulDoc) {
aDocType.AssignLiteral("window"); // doctype not implemented for XUL at time of writing - causes assertion
return NS_OK;
} else
#endif
if (mDocumentNode) {
dom::DocumentType* docType = mDocumentNode->GetDoctype();
if (docType) {
return docType->GetPublicId(aDocType);
}
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
DocAccessible::GetNameSpaceURIForID(int16_t aNameSpaceID, nsAString& aNameSpaceURI)
{
if (mDocumentNode) {
nsNameSpaceManager* nameSpaceManager = nsNameSpaceManager::GetInstance();
if (nameSpaceManager)
return nameSpaceManager->GetNameSpaceURI(aNameSpaceID, aNameSpaceURI);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
DocAccessible::GetWindowHandle(void** aWindow)
{
NS_ENSURE_ARG_POINTER(aWindow);
*aWindow = GetNativeWindow();
return NS_OK;
}
NS_IMETHODIMP
DocAccessible::GetWindow(nsIDOMWindow** aDOMWin)
{
*aDOMWin = nullptr;
if (!mDocumentNode) {
return NS_ERROR_FAILURE; // Accessible is Shutdown()
}
*aDOMWin = mDocumentNode->GetWindow();
if (!*aDOMWin)
return NS_ERROR_FAILURE; // No DOM Window
NS_ADDREF(*aDOMWin);
return NS_OK;
}
NS_IMETHODIMP
DocAccessible::GetDOMDocument(nsIDOMDocument** aDOMDocument)
{
NS_ENSURE_ARG_POINTER(aDOMDocument);
*aDOMDocument = nullptr;
if (mDocumentNode)
CallQueryInterface(mDocumentNode, aDOMDocument);
return NS_OK;
}
NS_IMETHODIMP
DocAccessible::GetParentDocument(nsIAccessibleDocument** aDocument)
{
NS_ENSURE_ARG_POINTER(aDocument);
*aDocument = nullptr;
if (!IsDefunct())
NS_IF_ADDREF(*aDocument = ParentDocument());
return NS_OK;
}
NS_IMETHODIMP
DocAccessible::GetChildDocumentCount(uint32_t* aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
if (!IsDefunct())
*aCount = ChildDocumentCount();
return NS_OK;
}
NS_IMETHODIMP
DocAccessible::GetChildDocumentAt(uint32_t aIndex,
nsIAccessibleDocument** aDocument)
{
NS_ENSURE_ARG_POINTER(aDocument);
*aDocument = nullptr;
if (IsDefunct())
return NS_OK;
NS_IF_ADDREF(*aDocument = GetChildDocumentAt(aIndex));
return *aDocument ? NS_OK : NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
DocAccessible::GetVirtualCursor(nsIAccessiblePivot** aVirtualCursor)
{
NS_ENSURE_ARG_POINTER(aVirtualCursor);
*aVirtualCursor = nullptr;
if (IsDefunct())
return NS_ERROR_FAILURE;
if (!mVirtualCursor) {
mVirtualCursor = new nsAccessiblePivot(this);
mVirtualCursor->AddObserver(this);
}
NS_ADDREF(*aVirtualCursor = mVirtualCursor);
return NS_OK;
}
// HyperTextAccessible method
already_AddRefed<nsIEditor>
DocAccessible::GetEditor() const
@ -520,6 +351,37 @@ DocAccessible::GetEditor() const
}
// DocAccessible public method
void
DocAccessible::URL(nsAString& aURL) const
{
nsCOMPtr<nsISupports> container = mDocumentNode->GetContainer();
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(container));
nsAutoCString theURL;
if (webNav) {
nsCOMPtr<nsIURI> pURI;
webNav->GetCurrentURI(getter_AddRefs(pURI));
if (pURI)
pURI->GetSpec(theURL);
}
CopyUTF8toUTF16(theURL, aURL);
}
void
DocAccessible::DocType(nsAString& aType) const
{
#ifdef MOZ_XUL
nsCOMPtr<nsIXULDocument> xulDoc(do_QueryInterface(mDocumentNode));
if (xulDoc) {
aType.AssignLiteral("window"); // doctype not implemented for XUL at time of writing - causes assertion
return;
}
#endif
dom::DocumentType* docType = mDocumentNode->GetDoctype();
if (docType)
docType->GetPublicId(aType);
}
Accessible*
DocAccessible::GetAccessible(nsINode* aNode) const
{

View File

@ -6,7 +6,7 @@
#ifndef mozilla_a11y_DocAccessible_h__
#define mozilla_a11y_DocAccessible_h__
#include "nsIAccessibleDocument.h"
#include "xpcAccessibleDocument.h"
#include "nsIAccessiblePivot.h"
#include "AccEvent.h"
@ -38,7 +38,7 @@ template<class Class, class Arg>
class TNotification;
class DocAccessible : public HyperTextAccessibleWrap,
public nsIAccessibleDocument,
public xpcAccessibleDocument,
public nsIDocumentObserver,
public nsIObserver,
public nsIScrollPositionListener,
@ -48,8 +48,6 @@ class DocAccessible : public HyperTextAccessibleWrap,
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DocAccessible, Accessible)
NS_DECL_NSIACCESSIBLEDOCUMENT
NS_DECL_NSIOBSERVER
NS_DECL_NSIACCESSIBLEPIVOTOBSERVER
@ -96,6 +94,31 @@ public:
// DocAccessible
/**
* Return document URL.
*/
void URL(nsAString& aURL) const;
/**
* Return DOM document title.
*/
void Title(nsString& aTitle) const { mDocumentNode->GetTitle(aTitle); }
/**
* Return DOM document mime type.
*/
void MimeType(nsAString& aType) const { mDocumentNode->GetContentType(aType); }
/**
* Return DOM document type.
*/
void DocType(nsAString& aType) const;
/**
* Return virtual cursor associated with the document.
*/
nsIAccessiblePivot* VirtualCursor();
/**
* Return presentation shell for this document accessible.
*/
@ -105,7 +128,7 @@ public:
* Return the presentation shell's context.
*/
nsPresContext* PresContext() const { return mPresShell->GetPresContext(); }
/**
* Return true if associated DOM document was loaded and isn't unloading.
*/

View File

@ -146,33 +146,20 @@ ImageAccessible::DoAction(uint8_t aIndex)
}
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleImage
// ImageAccessible
NS_IMETHODIMP
ImageAccessible::GetImagePosition(uint32_t aCoordType, int32_t* aX, int32_t* aY)
nsIntPoint
ImageAccessible::Position(uint32_t aCoordType)
{
NS_ENSURE_ARG_POINTER(aX);
NS_ENSURE_ARG_POINTER(aY);
nsIntRect rect = Bounds();
*aX = rect.x;
*aY = rect.y;
nsAccUtils::ConvertScreenCoordsTo(aX, aY, aCoordType, this);
return NS_OK;
nsAccUtils::ConvertScreenCoordsTo(&rect.x, &rect.y, aCoordType, this);
return rect.TopLeft();
}
NS_IMETHODIMP
ImageAccessible::GetImageSize(int32_t* aWidth, int32_t* aHeight)
nsIntSize
ImageAccessible::Size()
{
NS_ENSURE_ARG_POINTER(aWidth);
NS_ENSURE_ARG_POINTER(aHeight);
nsIntRect rect = Bounds();
*aWidth = rect.width;
*aHeight = rect.height;
return NS_OK;
return Bounds().Size();
}
// Accessible

View File

@ -7,7 +7,7 @@
#define mozilla_a11y_ImageAccessible_h__
#include "BaseAccessibles.h"
#include "nsIAccessibleImage.h"
#include "xpcAccessibleImage.h"
class nsGenericHTMLElement;
@ -20,7 +20,7 @@ namespace a11y {
* - support basic state
*/
class ImageAccessible : public LinkableAccessible,
public nsIAccessibleImage
public xpcAccessibleImage
{
public:
ImageAccessible(nsIContent* aContent, DocAccessible* aDoc);
@ -28,9 +28,6 @@ public:
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessibleImage
NS_DECL_NSIACCESSIBLEIMAGE
// Accessible
virtual a11y::role NativeRole() MOZ_OVERRIDE;
virtual uint64_t NativeState() MOZ_OVERRIDE;
@ -41,6 +38,10 @@ public:
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
// ImageAccessible
nsIntPoint Position(uint32_t aCoordType);
nsIntSize Size();
protected:
virtual ~ImageAccessible();

View File

@ -5,10 +5,8 @@
#include "nsISupports.idl"
interface nsIAccessible;
interface nsIAccessiblePivot;
interface nsIDOMDocument;
interface nsIDOMNode;
interface nsIDOMWindow;
/**
@ -18,11 +16,10 @@ interface nsIDOMWindow;
* there is an nsIAccessibleDocument for each document
* whether it is XUL, HTML or whatever.
* You can QueryInterface to nsIAccessibleDocument from the nsIAccessible for
* the root node of a document. You can also get one from
* nsIAccessible::GetAccessibleDocument() or
* nsIAccessibleEvent::GetAccessibleDocument()
* the root node of a document or you can get one from
* nsIAccessible::GetDocument().
*/
[scriptable, uuid(fe5b3886-2b6a-491a-80cd-a3e6342c451d)]
[scriptable, uuid(c80f6600-3210-4893-8f71-fde381ca39c9)]
interface nsIAccessibleDocument : nsISupports
{
/**
@ -55,17 +52,6 @@ interface nsIAccessibleDocument : nsISupports
*/
readonly attribute nsIDOMWindow window;
/**
* The namespace for each ID that is handed back.
*/
AString getNameSpaceURIForID(in short nameSpaceID);
/**
* The window handle for the OS window the document is being displayed in.
* For example, in Windows you can static cast it to an HWND.
*/
[noscript] readonly attribute voidPtr windowHandle;
/**
* Return the parent document accessible.
*/
@ -84,5 +70,6 @@ interface nsIAccessibleDocument : nsISupports
/**
* Return the child document accessible at the given index.
*/
[binaryname(ScriptableGetChildDocumentAt)]
nsIAccessibleDocument getChildDocumentAt(in unsigned long index);
};

View File

@ -79,10 +79,7 @@ ApplicationAccessibleWrap::get_appName(BSTR* aName)
return CO_E_OBJNOTCONNECTED;
nsAutoString name;
nsresult rv = GetAppName(name);
if (NS_FAILED(rv))
return GetHRESULT(rv);
AppName(name);
if (name.IsEmpty())
return S_FALSE;
@ -106,10 +103,7 @@ ApplicationAccessibleWrap::get_appVersion(BSTR* aVersion)
return CO_E_OBJNOTCONNECTED;
nsAutoString version;
nsresult rv = GetAppVersion(version);
if (NS_FAILED(rv))
return GetHRESULT(rv);
AppVersion(version);
if (version.IsEmpty())
return S_FALSE;
@ -131,10 +125,7 @@ ApplicationAccessibleWrap::get_toolkitName(BSTR* aName)
return CO_E_OBJNOTCONNECTED;
nsAutoString name;
nsresult rv = GetPlatformName(name);
if (NS_FAILED(rv))
return GetHRESULT(rv);
PlatformName(name);
if (name.IsEmpty())
return S_FALSE;
@ -158,10 +149,7 @@ ApplicationAccessibleWrap::get_toolkitVersion(BSTR* aVersion)
return CO_E_OBJNOTCONNECTED;
nsAutoString version;
nsresult rv = GetPlatformVersion(version);
if (NS_FAILED(rv))
return GetHRESULT(rv);
PlatformVersion(version);
if (version.IsEmpty())
return S_FALSE;

View File

@ -61,16 +61,16 @@ DocAccessibleWrap::get_accValue(VARIANT aVarChild, BSTR __RPC_FAR* aValue)
// If document is being used to create a widget, don't use the URL hack
roles::Role role = Role();
if (role != roles::DOCUMENT && role != roles::APPLICATION &&
role != roles::DIALOG && role != roles::ALERT)
if (role != roles::DOCUMENT && role != roles::APPLICATION &&
role != roles::DIALOG && role != roles::ALERT)
return hr;
nsAutoString URL;
nsresult rv = GetURL(URL);
if (URL.IsEmpty())
nsAutoString url;
URL(url);
if (url.IsEmpty())
return S_FALSE;
*aValue = ::SysAllocStringLen(URL.get(), URL.Length());
*aValue = ::SysAllocStringLen(url.get(), url.Length());
return *aValue ? S_OK : E_OUTOFMEMORY;
A11Y_TRYBLOCK_END

View File

@ -8,6 +8,8 @@
#include "ISimpleDOMDocument_i.c"
#include "nsNameSpaceManager.h"
using namespace mozilla;
using namespace mozilla::a11y;
@ -32,10 +34,7 @@ sdnDocAccessible::get_URL(BSTR __RPC_FAR* aURL)
return CO_E_OBJNOTCONNECTED;
nsAutoString URL;
nsresult rv = mAccessible->GetURL(URL);
if (NS_FAILED(rv))
return E_FAIL;
mAccessible->URL(URL);
if (URL.IsEmpty())
return S_FALSE;
@ -58,10 +57,7 @@ sdnDocAccessible::get_title(BSTR __RPC_FAR* aTitle)
return CO_E_OBJNOTCONNECTED;
nsAutoString title;
nsresult rv = mAccessible->GetTitle(title);
if (NS_FAILED(rv))
return E_FAIL;
mAccessible->Title(title);
*aTitle = ::SysAllocStringLen(title.get(), title.Length());
return *aTitle ? S_OK : E_OUTOFMEMORY;
@ -137,9 +133,9 @@ sdnDocAccessible::get_nameSpaceURIForID(short aNameSpaceID,
return E_INVALIDARG; // -1 is kNameSpaceID_Unknown
nsAutoString nameSpaceURI;
nsresult rv = mAccessible->GetNameSpaceURIForID(aNameSpaceID, nameSpaceURI);
if (NS_FAILED(rv))
return E_FAIL;
nsNameSpaceManager* nameSpaceManager = nsNameSpaceManager::GetInstance();
if (nameSpaceManager)
nameSpaceManager->GetNameSpaceURI(aNameSpaceID, nameSpaceURI);
if (nameSpaceURI.IsEmpty())
return S_FALSE;

View File

@ -6,6 +6,7 @@
EXPORTS += [
'xpcAccessible.h',
'xpcAccessibleDocument.h',
'xpcAccessibleHyperLink.h',
'xpcAccessibleHyperText.h',
'xpcAccessibleSelectable.h',
@ -15,8 +16,11 @@ EXPORTS += [
UNIFIED_SOURCES += [
'nsAccessibleRelation.cpp',
'xpcAccessible.cpp',
'xpcAccessibleApplication.cpp',
'xpcAccessibleDocument.cpp',
'xpcAccessibleHyperLink.cpp',
'xpcAccessibleHyperText.cpp',
'xpcAccessibleImage.cpp',
'xpcAccessibleSelectable.cpp',
'xpcAccessibleTable.cpp',
'xpcAccessibleTableCell.cpp',

View File

@ -0,0 +1,59 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */
#include "xpcAccessibleApplication.h"
#include "ApplicationAccessible.h"
using namespace mozilla::a11y;
NS_IMETHODIMP
xpcAccessibleApplication::GetAppName(nsAString& aName)
{
aName.Truncate();
if (static_cast<ApplicationAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
static_cast<ApplicationAccessible*>(this)->AppName(aName);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleApplication::GetAppVersion(nsAString& aVersion)
{
aVersion.Truncate();
if (static_cast<ApplicationAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
static_cast<ApplicationAccessible*>(this)->AppVersion(aVersion);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleApplication::GetPlatformName(nsAString& aName)
{
aName.Truncate();
if (static_cast<ApplicationAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
static_cast<ApplicationAccessible*>(this)->PlatformName(aName);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleApplication::GetPlatformVersion(nsAString& aVersion)
{
aVersion.Truncate();
if (static_cast<ApplicationAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
static_cast<ApplicationAccessible*>(this)->PlatformVersion(aVersion);
return NS_OK;
}

View File

@ -0,0 +1,36 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef mozilla_a11y_xpcAccessibleApplication_h_
#define mozilla_a11y_xpcAccessibleApplication_h_
#include "nsIAccessibleApplication.h"
class nsIAccessible;
namespace mozilla {
namespace a11y {
class xpcAccessibleApplication : public nsIAccessibleApplication
{
public:
NS_IMETHOD GetAppName(nsAString& aName) MOZ_FINAL;
NS_IMETHOD GetAppVersion(nsAString& aVersion) MOZ_FINAL;
NS_IMETHOD GetPlatformName(nsAString& aName) MOZ_FINAL;
NS_IMETHOD GetPlatformVersion(nsAString& aVersion) MOZ_FINAL;
private:
xpcAccessibleApplication() { }
friend class ApplicationAccessible;
xpcAccessibleApplication(const xpcAccessibleApplication&) MOZ_DELETE;
xpcAccessibleApplication& operator =(const xpcAccessibleApplication&) MOZ_DELETE;
};
} // namespace a11y
} // namespace mozilla
#endif

View File

@ -0,0 +1,135 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */
#include "xpcAccessibleDocument.h"
#include "DocAccessible-inl.h"
#include "nsIDOMDocument.h"
using namespace mozilla::a11y;
NS_IMETHODIMP
xpcAccessibleDocument::GetURL(nsAString& aURL)
{
if (static_cast<DocAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
static_cast<DocAccessible*>(this)->URL(aURL);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetTitle(nsAString& aTitle)
{
if (static_cast<DocAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
nsAutoString title;
static_cast<DocAccessible*>(this)->Title(title);
aTitle = title;
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetMimeType(nsAString& aType)
{
if (static_cast<DocAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
static_cast<DocAccessible*>(this)->MimeType(aType);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetDocType(nsAString& aType)
{
if (static_cast<DocAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
static_cast<DocAccessible*>(this)->DocType(aType);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetDOMDocument(nsIDOMDocument** aDOMDocument)
{
NS_ENSURE_ARG_POINTER(aDOMDocument);
*aDOMDocument = nullptr;
if (static_cast<DocAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
if (static_cast<DocAccessible*>(this)->DocumentNode())
CallQueryInterface(static_cast<DocAccessible*>(this)->DocumentNode(), aDOMDocument);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetWindow(nsIDOMWindow** aDOMWindow)
{
NS_ENSURE_ARG_POINTER(aDOMWindow);
*aDOMWindow = nullptr;
if (static_cast<DocAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aDOMWindow = static_cast<DocAccessible*>(this)->DocumentNode()->GetWindow());
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetParentDocument(nsIAccessibleDocument** aDocument)
{
NS_ENSURE_ARG_POINTER(aDocument);
*aDocument = nullptr;
if (static_cast<DocAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aDocument = static_cast<DocAccessible*>(this)->ParentDocument());
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetChildDocumentCount(uint32_t* aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
if (static_cast<DocAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
*aCount = static_cast<DocAccessible*>(this)->ChildDocumentCount();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::ScriptableGetChildDocumentAt(uint32_t aIndex,
nsIAccessibleDocument** aDocument)
{
NS_ENSURE_ARG_POINTER(aDocument);
*aDocument = nullptr;
if (static_cast<DocAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aDocument = static_cast<DocAccessible*>(this)->GetChildDocumentAt(aIndex));
return *aDocument ? NS_OK : NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetVirtualCursor(nsIAccessiblePivot** aVirtualCursor)
{
NS_ENSURE_ARG_POINTER(aVirtualCursor);
*aVirtualCursor = nullptr;
if (static_cast<DocAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
NS_ADDREF(*aVirtualCursor = static_cast<DocAccessible*>(this)->VirtualCursor());
return NS_OK;
}

View File

@ -0,0 +1,42 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef mozilla_a11y_xpcAccessibleDocument_h_
#define mozilla_a11y_xpcAccessibleDocument_h_
#include "nsIAccessibleDocument.h"
namespace mozilla {
namespace a11y {
class xpcAccessibleDocument : public nsIAccessibleDocument
{
public:
NS_IMETHOD GetURL(nsAString& aURL) MOZ_FINAL;
NS_IMETHOD GetTitle(nsAString& aTitle) MOZ_FINAL;
NS_IMETHOD GetMimeType(nsAString& aType) MOZ_FINAL;
NS_IMETHOD GetDocType(nsAString& aType) MOZ_FINAL;
NS_IMETHOD GetDOMDocument(nsIDOMDocument** aDOMDocument) MOZ_FINAL;
NS_IMETHOD GetWindow(nsIDOMWindow** aDOMWindow) MOZ_FINAL;
NS_IMETHOD GetParentDocument(nsIAccessibleDocument** aDocument) MOZ_FINAL;
NS_IMETHOD GetChildDocumentCount(uint32_t* aCount) MOZ_FINAL;
NS_IMETHOD ScriptableGetChildDocumentAt(uint32_t aIndex,
nsIAccessibleDocument** aDocument) MOZ_FINAL;
NS_IMETHOD GetVirtualCursor(nsIAccessiblePivot** aVirtualCursor) MOZ_FINAL;
private:
friend class DocAccessible;
xpcAccessibleDocument() { }
xpcAccessibleDocument(const xpcAccessibleDocument&) MOZ_DELETE;
xpcAccessibleDocument& operator =(const xpcAccessibleDocument&) MOZ_DELETE;
};
} // namespace a11y
} // namespace mozilla
#endif

View File

@ -0,0 +1,44 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */
#include "xpcAccessibleImage.h"
#include "ImageAccessible.h"
using namespace mozilla::a11y;
NS_IMETHODIMP
xpcAccessibleImage::GetImagePosition(uint32_t aCoordType, int32_t* aX, int32_t* aY)
{
NS_ENSURE_ARG_POINTER(aX);
*aX = 0;
NS_ENSURE_ARG_POINTER(aY);
*aY = 0;
if (static_cast<ImageAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
nsIntPoint point = static_cast<ImageAccessible*>(this)->Position(aCoordType);
*aX = point.x; *aY = point.y;
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleImage::GetImageSize(int32_t* aWidth, int32_t* aHeight)
{
NS_ENSURE_ARG_POINTER(aWidth);
*aWidth = 0;
NS_ENSURE_ARG_POINTER(aHeight);
*aHeight = 0;
if (static_cast<ImageAccessible*>(this)->IsDefunct())
return NS_ERROR_FAILURE;
nsIntSize size = static_cast<ImageAccessible*>(this)->Size();
*aWidth = size.width;
*aHeight = size.height;
return NS_OK;
}

View File

@ -0,0 +1,34 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef mozilla_a11y_xpcAccessibleImage_h_
#define mozilla_a11y_xpcAccessibleImage_h_
#include "nsIAccessibleImage.h"
namespace mozilla {
namespace a11y {
class xpcAccessibleImage : public nsIAccessibleImage
{
public:
NS_IMETHOD GetImagePosition(uint32_t aCoordType,
int32_t* aX, int32_t* aY) MOZ_FINAL;
NS_IMETHOD GetImageSize(int32_t* aWidth, int32_t* aHeight) MOZ_FINAL;
private:
friend class ImageAccessible;
xpcAccessibleImage() { }
xpcAccessibleImage(const xpcAccessibleImage&) MOZ_DELETE;
xpcAccessibleImage& operator =(const xpcAccessibleImage&) MOZ_DELETE;
};
} // namespace a11y
} // namespace mozilla
#endif