LCOV - code coverage report
Current view: directory - accessible/src/xforms - nsXFormsWidgetsAccessible.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 62 0 0.0 %
Date: 2012-06-02 Functions: 15 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Mozilla Foundation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2006
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Alexander Surkov <surkov.alexander@gmail.com> (original author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      27                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #include "nsXFormsWidgetsAccessible.h"
      40                 : 
      41                 : #include "Role.h"
      42                 : #include "States.h"
      43                 : 
      44                 : using namespace mozilla::a11y;
      45                 : 
      46                 : ////////////////////////////////////////////////////////////////////////////////
      47                 : // nsXFormsDropmarkerWidgetAccessible
      48                 : ////////////////////////////////////////////////////////////////////////////////
      49                 : 
      50               0 : nsXFormsDropmarkerWidgetAccessible::
      51                 :   nsXFormsDropmarkerWidgetAccessible(nsIContent* aContent,
      52                 :                                      nsDocAccessible* aDoc) :
      53               0 :   nsLeafAccessible(aContent, aDoc)
      54                 : {
      55               0 : }
      56                 : 
      57                 : role
      58               0 : nsXFormsDropmarkerWidgetAccessible::NativeRole()
      59                 : {
      60               0 :   return roles::PUSHBUTTON;
      61                 : }
      62                 : 
      63                 : PRUint64
      64               0 : nsXFormsDropmarkerWidgetAccessible::NativeState()
      65                 : {
      66               0 :   bool isOpen = false;
      67               0 :   nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
      68               0 :   nsresult rv = sXFormsService->IsDropmarkerOpen(DOMNode, &isOpen);
      69               0 :   NS_ENSURE_SUCCESS(rv, 0);
      70                 : 
      71               0 :   return isOpen ? states::PRESSED: 0;
      72                 : }
      73                 : 
      74                 : PRUint8
      75               0 : nsXFormsDropmarkerWidgetAccessible::ActionCount()
      76                 : {
      77               0 :   return 1;
      78                 : }
      79                 : 
      80                 : NS_IMETHODIMP
      81               0 : nsXFormsDropmarkerWidgetAccessible::GetActionName(PRUint8 aIndex,
      82                 :                                                   nsAString& aName)
      83                 : {
      84               0 :   if (aIndex != eAction_Click)
      85               0 :     return NS_ERROR_INVALID_ARG;
      86                 : 
      87               0 :   bool isOpen = false;
      88               0 :   nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
      89               0 :   nsresult rv = sXFormsService->IsDropmarkerOpen(DOMNode, &isOpen);
      90               0 :   NS_ENSURE_SUCCESS(rv, rv);
      91                 : 
      92               0 :   if (isOpen)
      93               0 :     aName.AssignLiteral("close");
      94                 :   else
      95               0 :     aName.AssignLiteral("open");
      96                 : 
      97               0 :   return NS_OK;
      98                 : }
      99                 : 
     100                 : NS_IMETHODIMP
     101               0 : nsXFormsDropmarkerWidgetAccessible::DoAction(PRUint8 aIndex)
     102                 : {
     103               0 :   if (aIndex != eAction_Click)
     104               0 :     return NS_ERROR_INVALID_ARG;
     105                 : 
     106               0 :   nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
     107               0 :   return sXFormsService->ToggleDropmarkerState(DOMNode);
     108                 : }
     109                 : 
     110                 : 
     111                 : ////////////////////////////////////////////////////////////////////////////////
     112                 : // nsXFormsCalendarWidgetAccessible
     113                 : ////////////////////////////////////////////////////////////////////////////////
     114                 : 
     115               0 : nsXFormsCalendarWidgetAccessible::
     116                 :   nsXFormsCalendarWidgetAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
     117               0 :   nsAccessibleWrap(aContent, aDoc)
     118                 : {
     119               0 : }
     120                 : 
     121                 : role
     122               0 : nsXFormsCalendarWidgetAccessible::NativeRole()
     123                 : {
     124               0 :   return roles::CALENDAR;
     125                 : }
     126                 : 
     127                 : 
     128                 : ////////////////////////////////////////////////////////////////////////////////
     129                 : // nsXFormsComboboxPopupWidgetAccessible
     130                 : ////////////////////////////////////////////////////////////////////////////////
     131                 : 
     132               0 : nsXFormsComboboxPopupWidgetAccessible::
     133                 :   nsXFormsComboboxPopupWidgetAccessible(nsIContent* aContent,
     134                 :                                         nsDocAccessible* aDoc) :
     135               0 :   nsXFormsAccessible(aContent, aDoc)
     136                 : {
     137               0 : }
     138                 : 
     139                 : role
     140               0 : nsXFormsComboboxPopupWidgetAccessible::NativeRole()
     141                 : {
     142               0 :   return roles::LIST;
     143                 : }
     144                 : 
     145                 : PRUint64
     146               0 : nsXFormsComboboxPopupWidgetAccessible::NativeState()
     147                 : {
     148               0 :   PRUint64 state = nsXFormsAccessible::NativeState();
     149                 : 
     150               0 :   bool isOpen = false;
     151               0 :   nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
     152               0 :   nsresult rv = sXFormsService->IsDropmarkerOpen(DOMNode, &isOpen);
     153               0 :   NS_ENSURE_SUCCESS(rv, state);
     154                 : 
     155               0 :   state |= states::FOCUSABLE;
     156                 : 
     157               0 :   if (isOpen)
     158               0 :     state = states::FLOATING;
     159                 :   else
     160               0 :     state = states::INVISIBLE;
     161                 : 
     162               0 :   return state;
     163                 : }
     164                 : 
     165                 : NS_IMETHODIMP
     166               0 : nsXFormsComboboxPopupWidgetAccessible::GetValue(nsAString& aValue)
     167                 : {
     168               0 :   aValue.Truncate();
     169               0 :   return NS_OK;
     170                 : }
     171                 : 
     172                 : nsresult
     173               0 : nsXFormsComboboxPopupWidgetAccessible::GetNameInternal(nsAString& aName)
     174                 : {
     175                 :   // Override nsXFormsAccessible::GetName() to prevent name calculation by
     176                 :   // XForms rules.
     177               0 :   return NS_OK;
     178                 : }
     179                 : 
     180                 : void
     181               0 : nsXFormsComboboxPopupWidgetAccessible::Description(nsString& aDescription)
     182                 : {
     183               0 :   aDescription.Truncate();
     184               0 : }
     185                 : 
     186                 : void
     187               0 : nsXFormsComboboxPopupWidgetAccessible::CacheChildren()
     188                 : {
     189               0 :   nsCOMPtr<nsIDOMNode> parent = do_QueryInterface(mContent->GetNodeParent());
     190                 :   // Parent node must be an xforms:select1 element.
     191               0 :   CacheSelectChildren(parent);
     192               0 : }
     193                 : 

Generated by: LCOV version 1.7