LCOV - code coverage report
Current view: top level - accessible/xpcom - xpcAccessible.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 387 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 39 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "Accessible-inl.h"
       8             : #include "mozilla/a11y/DocAccessibleParent.h"
       9             : #include "nsAccUtils.h"
      10             : #include "nsIAccessibleRelation.h"
      11             : #include "nsIAccessibleRole.h"
      12             : #include "nsAccessibleRelation.h"
      13             : #include "Relation.h"
      14             : #include "Role.h"
      15             : #include "RootAccessible.h"
      16             : #include "xpcAccessibleDocument.h"
      17             : 
      18             : #include "nsIMutableArray.h"
      19             : #include "nsIPersistentProperties2.h"
      20             : 
      21             : using namespace mozilla::a11y;
      22             : 
      23             : NS_IMETHODIMP
      24           0 : xpcAccessible::GetParent(nsIAccessible** aParent)
      25             : {
      26           0 :   NS_ENSURE_ARG_POINTER(aParent);
      27           0 :   *aParent = nullptr;
      28           0 :   if (IntlGeneric().IsNull())
      29           0 :     return NS_ERROR_FAILURE;
      30             : 
      31           0 :   AccessibleOrProxy parent = IntlGeneric().Parent();
      32           0 :   NS_IF_ADDREF(*aParent = ToXPC(parent));
      33           0 :   return NS_OK;
      34             : }
      35             : 
      36             : NS_IMETHODIMP
      37           0 : xpcAccessible::GetNextSibling(nsIAccessible** aNextSibling)
      38             : {
      39           0 :   NS_ENSURE_ARG_POINTER(aNextSibling);
      40           0 :   *aNextSibling = nullptr;
      41           0 :   if (IntlGeneric().IsNull())
      42           0 :     return NS_ERROR_FAILURE;
      43             : 
      44           0 :   if (IntlGeneric().IsAccessible()) {
      45           0 :     nsresult rv = NS_OK;
      46           0 :     NS_IF_ADDREF(*aNextSibling = ToXPC(Intl()->GetSiblingAtOffset(1, &rv)));
      47           0 :     return rv;
      48             :   }
      49             : 
      50           0 :   ProxyAccessible* proxy = IntlGeneric().AsProxy();
      51           0 :   NS_ENSURE_STATE(proxy);
      52             : 
      53           0 :   NS_IF_ADDREF(*aNextSibling = ToXPC(proxy->NextSibling()));
      54           0 :   return *aNextSibling ? NS_OK : NS_ERROR_FAILURE;
      55             : }
      56             : 
      57             : NS_IMETHODIMP
      58           0 : xpcAccessible::GetPreviousSibling(nsIAccessible** aPreviousSibling)
      59             : {
      60           0 :   NS_ENSURE_ARG_POINTER(aPreviousSibling);
      61           0 :   *aPreviousSibling = nullptr;
      62           0 :   if (IntlGeneric().IsNull())
      63           0 :     return NS_ERROR_FAILURE;
      64             : 
      65           0 :   if (IntlGeneric().IsAccessible()) {
      66           0 :     nsresult rv = NS_OK;
      67           0 :     NS_IF_ADDREF(*aPreviousSibling = ToXPC(Intl()->GetSiblingAtOffset(-1, &rv)));
      68           0 :     return rv;
      69             :   }
      70             : 
      71           0 :   ProxyAccessible* proxy = IntlGeneric().AsProxy();
      72           0 :   NS_ENSURE_STATE(proxy);
      73             : 
      74           0 :   NS_IF_ADDREF(*aPreviousSibling = ToXPC(proxy->PrevSibling()));
      75           0 :   return *aPreviousSibling ? NS_OK : NS_ERROR_FAILURE;
      76             : }
      77             : 
      78             : NS_IMETHODIMP
      79           0 : xpcAccessible::GetFirstChild(nsIAccessible** aFirstChild)
      80             : {
      81           0 :   NS_ENSURE_ARG_POINTER(aFirstChild);
      82           0 :   *aFirstChild = nullptr;
      83             : 
      84           0 :   if (IntlGeneric().IsNull())
      85           0 :     return NS_ERROR_FAILURE;
      86             : 
      87           0 :   NS_IF_ADDREF(*aFirstChild = ToXPC(IntlGeneric().FirstChild()));
      88           0 :   return NS_OK;
      89             : }
      90             : 
      91             : NS_IMETHODIMP
      92           0 : xpcAccessible::GetLastChild(nsIAccessible** aLastChild)
      93             : {
      94           0 :   NS_ENSURE_ARG_POINTER(aLastChild);
      95           0 :   *aLastChild = nullptr;
      96             : 
      97           0 :   if (IntlGeneric().IsNull())
      98           0 :     return NS_ERROR_FAILURE;
      99             : 
     100           0 :   NS_IF_ADDREF(*aLastChild = ToXPC(IntlGeneric().LastChild()));
     101           0 :   return NS_OK;
     102             : }
     103             : 
     104             : NS_IMETHODIMP
     105           0 : xpcAccessible::GetChildCount(int32_t* aChildCount)
     106             : {
     107           0 :   NS_ENSURE_ARG_POINTER(aChildCount);
     108             : 
     109           0 :   if (IntlGeneric().IsNull())
     110           0 :     return NS_ERROR_FAILURE;
     111             : 
     112           0 :   *aChildCount = IntlGeneric().ChildCount();
     113           0 :   return NS_OK;
     114             : }
     115             : 
     116             : NS_IMETHODIMP
     117           0 : xpcAccessible::GetChildAt(int32_t aChildIndex, nsIAccessible** aChild)
     118             : {
     119           0 :   NS_ENSURE_ARG_POINTER(aChild);
     120           0 :   *aChild = nullptr;
     121             : 
     122           0 :   if (IntlGeneric().IsNull())
     123           0 :     return NS_ERROR_FAILURE;
     124             : 
     125             :   // If child index is negative, then return last child.
     126             :   // XXX: do we really need this?
     127           0 :   if (aChildIndex < 0)
     128           0 :     aChildIndex = IntlGeneric().ChildCount() - 1;
     129             : 
     130           0 :   AccessibleOrProxy child = IntlGeneric().ChildAt(aChildIndex);
     131           0 :   if (child.IsNull())
     132           0 :     return NS_ERROR_INVALID_ARG;
     133             : 
     134           0 :   NS_ADDREF(*aChild = ToXPC(child));
     135           0 :   return NS_OK;
     136             : }
     137             : 
     138             : NS_IMETHODIMP
     139           0 : xpcAccessible::GetChildren(nsIArray** aChildren)
     140             : {
     141           0 :   NS_ENSURE_ARG_POINTER(aChildren);
     142           0 :   *aChildren = nullptr;
     143             : 
     144           0 :   if (IntlGeneric().IsNull())
     145           0 :     return NS_ERROR_FAILURE;
     146             : 
     147           0 :   nsresult rv = NS_OK;
     148             :   nsCOMPtr<nsIMutableArray> children =
     149           0 :     do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
     150           0 :   NS_ENSURE_SUCCESS(rv, rv);
     151             : 
     152           0 :   uint32_t childCount = IntlGeneric().ChildCount();
     153           0 :   for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
     154           0 :     AccessibleOrProxy child = IntlGeneric().ChildAt(childIdx);
     155           0 :     children->AppendElement(static_cast<nsIAccessible*>(ToXPC(child)), false);
     156             :   }
     157             : 
     158           0 :   children.forget(aChildren);
     159           0 :   return NS_OK;
     160             : }
     161             : 
     162             : NS_IMETHODIMP
     163           0 : xpcAccessible::GetIndexInParent(int32_t* aIndexInParent)
     164             : {
     165           0 :   NS_ENSURE_ARG_POINTER(aIndexInParent);
     166           0 :   *aIndexInParent = -1;
     167           0 :   if (IntlGeneric().IsNull())
     168           0 :     return NS_ERROR_FAILURE;
     169             : 
     170           0 :   if (IntlGeneric().IsAccessible()) {
     171           0 :     *aIndexInParent = Intl()->IndexInParent();
     172           0 :   } else if (IntlGeneric().IsProxy()) {
     173           0 :     *aIndexInParent = IntlGeneric().AsProxy()->IndexInParent();
     174             :   }
     175             : 
     176           0 :   return *aIndexInParent != -1 ? NS_OK : NS_ERROR_FAILURE;
     177             : }
     178             : 
     179             : NS_IMETHODIMP
     180           0 : xpcAccessible::GetDOMNode(nsIDOMNode** aDOMNode)
     181             : {
     182           0 :   NS_ENSURE_ARG_POINTER(aDOMNode);
     183           0 :   *aDOMNode = nullptr;
     184             : 
     185           0 :   if (!Intl())
     186           0 :     return NS_ERROR_FAILURE;
     187             : 
     188           0 :   nsINode* node = Intl()->GetNode();
     189           0 :   if (node)
     190           0 :     CallQueryInterface(node, aDOMNode);
     191             : 
     192           0 :   return NS_OK;
     193             : }
     194             : 
     195             : NS_IMETHODIMP
     196           0 : xpcAccessible::GetId(nsAString& aID)
     197             : {
     198           0 :   ProxyAccessible* proxy = IntlGeneric().AsProxy();
     199           0 :   if (!proxy) {
     200           0 :     return NS_ERROR_FAILURE;
     201             :   }
     202             : 
     203           0 :   nsString id;
     204           0 :   proxy->DOMNodeID(id);
     205           0 :   aID.Assign(id);
     206             : 
     207           0 :   return NS_OK;
     208             : }
     209             : 
     210             : NS_IMETHODIMP
     211           0 : xpcAccessible::GetDocument(nsIAccessibleDocument** aDocument)
     212             : {
     213           0 :   NS_ENSURE_ARG_POINTER(aDocument);
     214           0 :   *aDocument = nullptr;
     215             : 
     216           0 :   if (!Intl())
     217           0 :     return NS_ERROR_FAILURE;
     218             : 
     219           0 :   NS_IF_ADDREF(*aDocument = ToXPCDocument(Intl()->Document()));
     220           0 :   return NS_OK;
     221             : }
     222             : 
     223             : NS_IMETHODIMP
     224           0 : xpcAccessible::GetRootDocument(nsIAccessibleDocument** aRootDocument)
     225             : {
     226           0 :   NS_ENSURE_ARG_POINTER(aRootDocument);
     227           0 :   *aRootDocument = nullptr;
     228             : 
     229           0 :   if (!Intl())
     230           0 :     return NS_ERROR_FAILURE;
     231             : 
     232           0 :   NS_IF_ADDREF(*aRootDocument = ToXPCDocument(Intl()->RootAccessible()));
     233           0 :   return NS_OK;
     234             : }
     235             : 
     236             : NS_IMETHODIMP
     237           0 : xpcAccessible::GetRole(uint32_t* aRole)
     238             : {
     239           0 :   NS_ENSURE_ARG_POINTER(aRole);
     240           0 :   *aRole = nsIAccessibleRole::ROLE_NOTHING;
     241             : 
     242           0 :   if (IntlGeneric().IsNull())
     243           0 :     return NS_ERROR_FAILURE;
     244             : 
     245           0 :   *aRole = IntlGeneric().Role();
     246           0 :   return NS_OK;
     247             : }
     248             : 
     249             : NS_IMETHODIMP
     250           0 : xpcAccessible::GetState(uint32_t* aState, uint32_t* aExtraState)
     251             : {
     252           0 :   NS_ENSURE_ARG_POINTER(aState);
     253             : 
     254           0 :   if (IntlGeneric().IsNull())
     255           0 :     nsAccUtils::To32States(states::DEFUNCT, aState, aExtraState);
     256           0 :   else if (Intl())
     257           0 :     nsAccUtils::To32States(Intl()->State(), aState, aExtraState);
     258             :   else
     259           0 :     nsAccUtils::To32States(IntlGeneric().AsProxy()->State(), aState,
     260           0 :                            aExtraState);
     261             : 
     262           0 :   return NS_OK;
     263             : }
     264             : 
     265             : NS_IMETHODIMP
     266           0 : xpcAccessible::GetName(nsAString& aName)
     267             : {
     268           0 :   aName.Truncate();
     269             : 
     270           0 :   if (IntlGeneric().IsNull())
     271           0 :     return NS_ERROR_FAILURE;
     272             : 
     273           0 :   nsAutoString name;
     274           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     275           0 :     proxy->Name(name);
     276             :   } else {
     277           0 :     Intl()->Name(name);
     278             :   }
     279             : 
     280           0 :   aName.Assign(name);
     281             : 
     282           0 :   return NS_OK;
     283             : }
     284             : 
     285             : NS_IMETHODIMP
     286           0 : xpcAccessible::GetDescription(nsAString& aDescription)
     287             : {
     288           0 :   if (IntlGeneric().IsNull())
     289           0 :     return NS_ERROR_FAILURE;
     290             : 
     291           0 :   nsAutoString desc;
     292           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     293           0 :     proxy->Description(desc);
     294             :   } else {
     295           0 :     Intl()->Description(desc);
     296             :   }
     297             : 
     298           0 :   aDescription.Assign(desc);
     299             : 
     300           0 :   return NS_OK;
     301             : }
     302             : 
     303             : NS_IMETHODIMP
     304           0 : xpcAccessible::GetLanguage(nsAString& aLanguage)
     305             : {
     306           0 :   if (IntlGeneric().IsNull())
     307           0 :     return NS_ERROR_FAILURE;
     308             : 
     309           0 :   nsAutoString lang;
     310           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     311           0 :     proxy->Language(lang);
     312             :   } else {
     313           0 :     Intl()->Language(lang);
     314             :   }
     315             : 
     316           0 :   aLanguage.Assign(lang);
     317           0 :   return NS_OK;
     318             : }
     319             : 
     320             : NS_IMETHODIMP
     321           0 : xpcAccessible::GetValue(nsAString& aValue)
     322             : {
     323           0 :   if (IntlGeneric().IsNull())
     324           0 :     return NS_ERROR_FAILURE;
     325             : 
     326           0 :   nsAutoString value;
     327           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     328           0 :     proxy->Value(value);
     329             :   } else {
     330           0 :     Intl()->Value(value);
     331             :   }
     332             : 
     333           0 :   aValue.Assign(value);
     334             : 
     335           0 :   return NS_OK;
     336             : }
     337             : 
     338             : NS_IMETHODIMP
     339           0 : xpcAccessible::GetHelp(nsAString& aHelp)
     340             : {
     341           0 :   if (IntlGeneric().IsNull())
     342           0 :     return NS_ERROR_FAILURE;
     343             : 
     344           0 :   nsAutoString help;
     345           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     346             : #if defined(XP_WIN)
     347             :     return NS_ERROR_NOT_IMPLEMENTED;
     348             : #else
     349           0 :     proxy->Help(help);
     350             : #endif
     351             :   } else {
     352           0 :     Intl()->Help(help);
     353             :   }
     354             : 
     355           0 :   aHelp.Assign(help);
     356             : 
     357           0 :   return NS_OK;
     358             : }
     359             : 
     360             : NS_IMETHODIMP
     361           0 : xpcAccessible::GetAccessKey(nsAString& aAccessKey)
     362             : {
     363           0 :   aAccessKey.Truncate();
     364             : 
     365           0 :   if (IntlGeneric().IsNull())
     366           0 :     return NS_ERROR_FAILURE;
     367             : 
     368           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     369             : #if defined(XP_WIN)
     370             :     return NS_ERROR_NOT_IMPLEMENTED;
     371             : #else
     372           0 :     proxy->AccessKey().ToString(aAccessKey);
     373             : #endif
     374             :   } else {
     375           0 :     Intl()->AccessKey().ToString(aAccessKey);
     376             :   }
     377             : 
     378           0 :   return NS_OK;
     379             : }
     380             : 
     381             : NS_IMETHODIMP
     382           0 : xpcAccessible::GetKeyboardShortcut(nsAString& aKeyBinding)
     383             : {
     384           0 :   aKeyBinding.Truncate();
     385           0 :   if (IntlGeneric().IsNull())
     386           0 :     return NS_ERROR_FAILURE;
     387             : 
     388           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     389             : #if defined(XP_WIN)
     390             :     return NS_ERROR_NOT_IMPLEMENTED;
     391             : #else
     392           0 :     proxy->KeyboardShortcut().ToString(aKeyBinding);
     393             : #endif
     394             :   } else {
     395           0 :     Intl()->KeyboardShortcut().ToString(aKeyBinding);
     396             :   }
     397           0 :   return NS_OK;
     398             : }
     399             : 
     400             : NS_IMETHODIMP
     401           0 : xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes)
     402             : {
     403           0 :   NS_ENSURE_ARG_POINTER(aAttributes);
     404           0 :   *aAttributes = nullptr;
     405             : 
     406           0 :   if (IntlGeneric().IsNull()) {
     407           0 :     return NS_ERROR_FAILURE;
     408             :   }
     409             : 
     410           0 :   if (Accessible* acc = Intl()) {
     411           0 :     nsCOMPtr<nsIPersistentProperties> attributes = acc->Attributes();
     412           0 :     attributes.swap(*aAttributes);
     413           0 :     return NS_OK;
     414             :   }
     415             : 
     416           0 :   ProxyAccessible* proxy = IntlGeneric().AsProxy();
     417           0 :   AutoTArray<Attribute, 10> attrs;
     418           0 :   proxy->Attributes(&attrs);
     419             : 
     420             :   nsCOMPtr<nsIPersistentProperties> props =
     421           0 :     do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
     422           0 :   uint32_t attrCount = attrs.Length();
     423           0 :   nsAutoString unused;
     424           0 :   for (uint32_t i = 0; i < attrCount; i++) {
     425           0 :     props->SetStringProperty(attrs[i].Name(), attrs[i].Value(), unused);
     426             :   }
     427             : 
     428           0 :   props.forget(aAttributes);
     429           0 :   return NS_OK;
     430             : }
     431             : 
     432             : NS_IMETHODIMP
     433           0 : xpcAccessible::GetBounds(int32_t* aX, int32_t* aY,
     434             :                          int32_t* aWidth, int32_t* aHeight)
     435             : {
     436           0 :   NS_ENSURE_ARG_POINTER(aX);
     437           0 :   *aX = 0;
     438           0 :   NS_ENSURE_ARG_POINTER(aY);
     439           0 :   *aY = 0;
     440           0 :   NS_ENSURE_ARG_POINTER(aWidth);
     441           0 :   *aWidth = 0;
     442           0 :   NS_ENSURE_ARG_POINTER(aHeight);
     443           0 :   *aHeight = 0;
     444             : 
     445           0 :   if (IntlGeneric().IsNull())
     446           0 :     return NS_ERROR_FAILURE;
     447             : 
     448           0 :   nsIntRect rect;
     449           0 :   if (Accessible* acc = IntlGeneric().AsAccessible()) {
     450           0 :     rect = acc->Bounds();
     451             :   } else {
     452           0 :     rect = IntlGeneric().AsProxy()->Bounds();
     453             :   }
     454             : 
     455           0 :   *aX = rect.x;
     456           0 :   *aY = rect.y;
     457           0 :   *aWidth = rect.width;
     458           0 :   *aHeight = rect.height;
     459             : 
     460           0 :   return NS_OK;
     461             : }
     462             : 
     463             : NS_IMETHODIMP
     464           0 : xpcAccessible::GroupPosition(int32_t* aGroupLevel,
     465             :                              int32_t* aSimilarItemsInGroup,
     466             :                              int32_t* aPositionInGroup)
     467             : {
     468           0 :   NS_ENSURE_ARG_POINTER(aGroupLevel);
     469           0 :   *aGroupLevel = 0;
     470             : 
     471           0 :   NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
     472           0 :   *aSimilarItemsInGroup = 0;
     473             : 
     474           0 :   NS_ENSURE_ARG_POINTER(aPositionInGroup);
     475           0 :   *aPositionInGroup = 0;
     476             : 
     477           0 :   if (!Intl())
     478           0 :     return NS_ERROR_FAILURE;
     479             : 
     480           0 :   GroupPos groupPos = Intl()->GroupPosition();
     481             : 
     482           0 :   *aGroupLevel = groupPos.level;
     483           0 :   *aSimilarItemsInGroup = groupPos.setSize;
     484           0 :   *aPositionInGroup = groupPos.posInSet;
     485             : 
     486           0 :   return NS_OK;
     487             : }
     488             : 
     489             : NS_IMETHODIMP
     490           0 : xpcAccessible::GetRelationByType(uint32_t aType,
     491             :                                  nsIAccessibleRelation** aRelation)
     492             : {
     493           0 :   NS_ENSURE_ARG_POINTER(aRelation);
     494           0 :   *aRelation = nullptr;
     495             : 
     496           0 :   NS_ENSURE_ARG(aType <= static_cast<uint32_t>(RelationType::LAST));
     497             : 
     498           0 :   if (IntlGeneric().IsNull())
     499           0 :     return NS_ERROR_FAILURE;
     500             : 
     501           0 :   if (IntlGeneric().IsAccessible()) {
     502           0 :     Relation rel = Intl()->RelationByType(static_cast<RelationType>(aType));
     503           0 :     NS_ADDREF(*aRelation = new nsAccessibleRelation(aType, &rel));
     504           0 :     return NS_OK;
     505             :   }
     506             : 
     507           0 :   ProxyAccessible* proxy = IntlGeneric().AsProxy();
     508             :   nsTArray<ProxyAccessible*> targets =
     509           0 :     proxy->RelationByType(static_cast<RelationType>(aType));
     510           0 :   NS_ADDREF(*aRelation = new nsAccessibleRelation(aType, &targets));
     511             : 
     512           0 :   return NS_OK;
     513             : }
     514             : 
     515             : NS_IMETHODIMP
     516           0 : xpcAccessible::GetRelations(nsIArray** aRelations)
     517             : {
     518           0 :   NS_ENSURE_ARG_POINTER(aRelations);
     519           0 :   *aRelations = nullptr;
     520             : 
     521           0 :   if (IntlGeneric().IsNull())
     522           0 :     return NS_ERROR_FAILURE;
     523             : 
     524           0 :   nsCOMPtr<nsIMutableArray> relations = do_CreateInstance(NS_ARRAY_CONTRACTID);
     525           0 :   NS_ENSURE_TRUE(relations, NS_ERROR_OUT_OF_MEMORY);
     526             : 
     527             :   static const uint32_t relationTypes[] = {
     528             :     nsIAccessibleRelation::RELATION_LABELLED_BY,
     529             :     nsIAccessibleRelation::RELATION_LABEL_FOR,
     530             :     nsIAccessibleRelation::RELATION_DESCRIBED_BY,
     531             :     nsIAccessibleRelation::RELATION_DESCRIPTION_FOR,
     532             :     nsIAccessibleRelation::RELATION_NODE_CHILD_OF,
     533             :     nsIAccessibleRelation::RELATION_NODE_PARENT_OF,
     534             :     nsIAccessibleRelation::RELATION_CONTROLLED_BY,
     535             :     nsIAccessibleRelation::RELATION_CONTROLLER_FOR,
     536             :     nsIAccessibleRelation::RELATION_FLOWS_TO,
     537             :     nsIAccessibleRelation::RELATION_FLOWS_FROM,
     538             :     nsIAccessibleRelation::RELATION_MEMBER_OF,
     539             :     nsIAccessibleRelation::RELATION_SUBWINDOW_OF,
     540             :     nsIAccessibleRelation::RELATION_EMBEDS,
     541             :     nsIAccessibleRelation::RELATION_EMBEDDED_BY,
     542             :     nsIAccessibleRelation::RELATION_POPUP_FOR,
     543             :     nsIAccessibleRelation::RELATION_PARENT_WINDOW_OF,
     544             :     nsIAccessibleRelation::RELATION_DEFAULT_BUTTON,
     545             :     nsIAccessibleRelation::RELATION_CONTAINING_DOCUMENT,
     546             :     nsIAccessibleRelation::RELATION_CONTAINING_TAB_PANE,
     547             :     nsIAccessibleRelation::RELATION_CONTAINING_APPLICATION
     548             :   };
     549             : 
     550           0 :   for (uint32_t idx = 0; idx < ArrayLength(relationTypes); idx++) {
     551           0 :     nsCOMPtr<nsIAccessibleRelation> relation;
     552           0 :     nsresult rv = GetRelationByType(relationTypes[idx], getter_AddRefs(relation));
     553             : 
     554           0 :     if (NS_SUCCEEDED(rv) && relation) {
     555           0 :       uint32_t targets = 0;
     556           0 :       relation->GetTargetsCount(&targets);
     557           0 :       if (targets)
     558           0 :         relations->AppendElement(relation, false);
     559             :     }
     560             :   }
     561             : 
     562           0 :   NS_ADDREF(*aRelations = relations);
     563           0 :   return NS_OK;
     564             : }
     565             : 
     566             : NS_IMETHODIMP
     567           0 : xpcAccessible::GetFocusedChild(nsIAccessible** aChild)
     568             : {
     569           0 :   NS_ENSURE_ARG_POINTER(aChild);
     570           0 :   *aChild = nullptr;
     571             : 
     572           0 :   if (IntlGeneric().IsNull())
     573           0 :     return NS_ERROR_FAILURE;
     574             : 
     575           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     576             : #if defined(XP_WIN)
     577             :     return NS_ERROR_NOT_IMPLEMENTED;
     578             : #else
     579           0 :     NS_IF_ADDREF(*aChild = ToXPC(proxy->FocusedChild()));
     580             : #endif
     581             :   } else {
     582           0 :     NS_IF_ADDREF(*aChild = ToXPC(Intl()->FocusedChild()));
     583             :   }
     584             : 
     585           0 :   return NS_OK;
     586             : }
     587             : 
     588             : NS_IMETHODIMP
     589           0 : xpcAccessible::GetChildAtPoint(int32_t aX, int32_t aY,
     590             :                                nsIAccessible** aAccessible)
     591             : {
     592           0 :   NS_ENSURE_ARG_POINTER(aAccessible);
     593           0 :   *aAccessible = nullptr;
     594             : 
     595           0 :   if (IntlGeneric().IsNull())
     596           0 :     return NS_ERROR_FAILURE;
     597             : 
     598           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     599             : #if defined(XP_WIN)
     600             :     return NS_ERROR_NOT_IMPLEMENTED;
     601             : #else
     602           0 :     NS_IF_ADDREF(*aAccessible =
     603           0 :                  ToXPC(proxy->ChildAtPoint(aX, aY, Accessible::eDirectChild)));
     604             : #endif
     605             :   } else {
     606           0 :     NS_IF_ADDREF(*aAccessible =
     607           0 :                  ToXPC(Intl()->ChildAtPoint(aX, aY, Accessible::eDirectChild)));
     608             :   }
     609             : 
     610           0 :   return NS_OK;
     611             : }
     612             : 
     613             : NS_IMETHODIMP
     614           0 : xpcAccessible::GetDeepestChildAtPoint(int32_t aX, int32_t aY,
     615             :                                       nsIAccessible** aAccessible)
     616             : {
     617           0 :   NS_ENSURE_ARG_POINTER(aAccessible);
     618           0 :   *aAccessible = nullptr;
     619             : 
     620           0 :   if (IntlGeneric().IsNull())
     621           0 :     return NS_ERROR_FAILURE;
     622             : 
     623           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     624             : #if defined(XP_WIN)
     625             :     return NS_ERROR_NOT_IMPLEMENTED;
     626             : #else
     627           0 :     NS_IF_ADDREF(*aAccessible =
     628           0 :                  ToXPC(proxy->ChildAtPoint(aX, aY, Accessible::eDeepestChild)));
     629             : #endif
     630             :   } else {
     631           0 :     NS_IF_ADDREF(*aAccessible =
     632           0 :                  ToXPC(Intl()->ChildAtPoint(aX, aY, Accessible::eDeepestChild)));
     633             :   }
     634             : 
     635           0 :   return NS_OK;
     636             : }
     637             : 
     638             : NS_IMETHODIMP
     639           0 : xpcAccessible::SetSelected(bool aSelect)
     640             : {
     641           0 :   if (IntlGeneric().IsNull())
     642           0 :     return NS_ERROR_FAILURE;
     643             : 
     644           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     645             : #if defined(XP_WIN)
     646             :     return NS_ERROR_NOT_IMPLEMENTED;
     647             : #else
     648           0 :     proxy->SetSelected(aSelect);
     649             : #endif
     650             :   } else {
     651           0 :     Intl()->SetSelected(aSelect);
     652             :   }
     653             : 
     654           0 :   return NS_OK;
     655             : }
     656             : 
     657             : NS_IMETHODIMP
     658           0 : xpcAccessible::TakeSelection()
     659             : {
     660           0 :   if (IntlGeneric().IsNull())
     661           0 :     return NS_ERROR_FAILURE;
     662             : 
     663           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     664             : #if defined(XP_WIN)
     665             :     return NS_ERROR_NOT_IMPLEMENTED;
     666             : #else
     667           0 :     proxy->TakeSelection();
     668             : #endif
     669             :   } else {
     670           0 :     Intl()->TakeSelection();
     671             :   }
     672             : 
     673           0 :   return NS_OK;
     674             : }
     675             : 
     676             : NS_IMETHODIMP
     677           0 : xpcAccessible::TakeFocus()
     678             : {
     679           0 :   if (IntlGeneric().IsNull())
     680           0 :     return NS_ERROR_FAILURE;
     681             : 
     682           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     683             : #if defined(XP_WIN)
     684             :     return NS_ERROR_NOT_IMPLEMENTED;
     685             : #else
     686           0 :     proxy->TakeFocus();
     687             : #endif
     688             :   } else {
     689           0 :     Intl()->TakeFocus();
     690             :   }
     691             : 
     692           0 :   return NS_OK;
     693             : }
     694             : 
     695             : NS_IMETHODIMP
     696           0 : xpcAccessible::GetActionCount(uint8_t* aActionCount)
     697             : {
     698           0 :   NS_ENSURE_ARG_POINTER(aActionCount);
     699           0 :   *aActionCount = 0;
     700           0 :   if (IntlGeneric().IsNull())
     701           0 :     return NS_ERROR_FAILURE;
     702             : 
     703           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     704             : #if defined(XP_WIN)
     705             :     return NS_ERROR_NOT_IMPLEMENTED;
     706             : #else
     707           0 :     *aActionCount = proxy->ActionCount();
     708             : #endif
     709             :   } else {
     710           0 :     *aActionCount = Intl()->ActionCount();
     711             :   }
     712             : 
     713           0 :   return NS_OK;
     714             : }
     715             : 
     716             : NS_IMETHODIMP
     717           0 : xpcAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
     718             : {
     719           0 :   if (IntlGeneric().IsNull())
     720           0 :     return NS_ERROR_FAILURE;
     721             : 
     722           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     723             : #if defined(XP_WIN)
     724             :     return NS_ERROR_NOT_IMPLEMENTED;
     725             : #else
     726           0 :     nsString name;
     727           0 :     proxy->ActionNameAt(aIndex, name);
     728           0 :     aName.Assign(name);
     729             : #endif
     730             :   } else {
     731           0 :     if (aIndex >= Intl()->ActionCount())
     732           0 :       return NS_ERROR_INVALID_ARG;
     733             : 
     734           0 :     Intl()->ActionNameAt(aIndex, aName);
     735             :   }
     736             : 
     737           0 :   return NS_OK;
     738             : }
     739             : 
     740             : NS_IMETHODIMP
     741           0 : xpcAccessible::GetActionDescription(uint8_t aIndex, nsAString& aDescription)
     742             : {
     743           0 :   if (IntlGeneric().IsNull())
     744           0 :     return NS_ERROR_FAILURE;
     745             : 
     746           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     747             : #if defined(XP_WIN)
     748             :     return NS_ERROR_NOT_IMPLEMENTED;
     749             : #else
     750           0 :     nsString description;
     751           0 :     proxy->ActionDescriptionAt(aIndex, description);
     752           0 :     aDescription.Assign(description);
     753             : #endif
     754             :   } else {
     755           0 :     if (aIndex >= Intl()->ActionCount())
     756           0 :       return NS_ERROR_INVALID_ARG;
     757             : 
     758           0 :     Intl()->ActionDescriptionAt(aIndex, aDescription);
     759             :   }
     760             : 
     761           0 :   return NS_OK;
     762             : }
     763             : 
     764             : NS_IMETHODIMP
     765           0 : xpcAccessible::DoAction(uint8_t aIndex)
     766             : {
     767           0 :   if (IntlGeneric().IsNull())
     768           0 :     return NS_ERROR_FAILURE;
     769             : 
     770           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     771             : #if defined(XP_WIN)
     772             :     return NS_ERROR_NOT_IMPLEMENTED;
     773             : #else
     774           0 :     return proxy->DoAction(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
     775             : #endif
     776             :   } else {
     777           0 :     return Intl()->DoAction(aIndex) ?
     778           0 :       NS_OK : NS_ERROR_INVALID_ARG;
     779             :   }
     780             : }
     781             : 
     782             : NS_IMETHODIMP
     783           0 : xpcAccessible::ScrollTo(uint32_t aHow)
     784             : {
     785           0 :   if (IntlGeneric().IsNull())
     786           0 :     return NS_ERROR_FAILURE;
     787             : 
     788           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     789             : #if defined(XP_WIN)
     790             :     return NS_ERROR_NOT_IMPLEMENTED;
     791             : #else
     792           0 :     proxy->ScrollTo(aHow);
     793             : #endif
     794             :   } else {
     795           0 :     Intl()->ScrollTo(aHow);
     796             :   }
     797             : 
     798           0 :   return NS_OK;
     799             : }
     800             : 
     801             : NS_IMETHODIMP
     802           0 : xpcAccessible::ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY)
     803             : {
     804           0 :   if (IntlGeneric().IsNull())
     805           0 :     return NS_ERROR_FAILURE;
     806             : 
     807           0 :   if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
     808             : #if defined(XP_WIN)
     809             :     return NS_ERROR_NOT_IMPLEMENTED;
     810             : #else
     811           0 :     proxy->ScrollToPoint(aCoordinateType, aX, aY);
     812             : #endif
     813             :   } else {
     814           0 :     Intl()->ScrollToPoint(aCoordinateType, aX, aY);
     815             :   }
     816             : 
     817           0 :   return NS_OK;
     818             : }

Generated by: LCOV version 1.13