LCOV - code coverage report
Current view: directory - accessible/src/atk - nsStateMap.h (source / functions) Found Hit Coverage
Test: app.info Lines: 6 0 0.0 %
Date: 2012-06-02 Functions: 1 0 0.0 %

       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                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is mozilla.org code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is IBM Corporation
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2007
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Aaron Leventhal (aleventh@us.ibm.com)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * 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 <atk/atk.h>
      40                 : #include "nsAccessibleWrap.h"
      41                 : 
      42                 : /******************************************************************************
      43                 : The following nsIAccessible states aren't translated, just ignored:
      44                 :   STATE_READONLY:        Supported indirectly via EXT_STATE_EDITABLE
      45                 :   STATE_HOTTRACKED:      No ATK equivalent.  No known use case.
      46                 :                          The nsIAccessible state is not currently supported.
      47                 :   STATE_FLOATING:        No ATK equivalent.  No known use case.
      48                 :                          The nsIAccessible state is not currently supported.
      49                 :   STATE_MOVEABLE:        No ATK equivalent.  No known use case.
      50                 :                          The nsIAccessible state is not currently supported.
      51                 :   STATE_SELFVOICING:     No ATK equivalent -- the object has self-TTS.
      52                 :                          The nsIAccessible state is not currently supported.
      53                 :   STATE_LINKED:          The object is formatted as a hyperlink. Supported via ATK_ROLE_LINK.
      54                 :   STATE_EXTSELECTABLE:   Indicates that an object extends its selection.
      55                 :                          This is supported via STATE_MULTISELECTABLE.
      56                 :   STATE_PROTECTED:       The object is a password-protected edit control.
      57                 :                          Supported via ATK_ROLE_PASSWORD_TEXT
      58                 :   STATE_HASPOPUP:        Object displays a pop-up menu or window when invoked.
      59                 :                          No ATK equivalent.  The nsIAccessible state is not currently supported.
      60                 : 
      61                 : The following ATK states are not supported:
      62                 :   ATK_STATE_ARMED:       No clear use case, used briefly when button is activated
      63                 :   ATK_STATE_HAS_TOOLTIP: No clear use case, no IA2 equivalent
      64                 :   ATK_STATE_ICONIFIED:   Mozilla does not have elements which are collapsable into icons
      65                 :   ATK_STATE_TRUNCATED:   No clear use case. Indicates that an object's onscreen content is truncated, 
      66                 :                          e.g. a text value in a spreadsheet cell. No IA2 state.
      67                 : ******************************************************************************/
      68                 : 
      69                 : enum EStateMapEntryType {
      70                 :   kMapDirectly,
      71                 :   kMapOpposite,   // For example, UNAVAILABLE is the opposite of ENABLED
      72                 :   kNoStateChange, // Don't fire state change event
      73                 :   kNoSuchState
      74                 : };
      75                 : 
      76                 : const AtkStateType kNone = ATK_STATE_INVALID;
      77                 : 
      78                 : struct AtkStateMap {
      79                 :   AtkStateType atkState;
      80                 :   EStateMapEntryType stateMapEntryType;
      81                 : 
      82               0 :   static PRInt32 GetStateIndexFor(PRUint64 aState)
      83                 :   {
      84               0 :     PRInt32 stateIndex = -1;
      85               0 :     while (aState > 0) {
      86               0 :       ++ stateIndex;
      87               0 :       aState >>= 1;
      88                 :     }
      89               0 :     return stateIndex;  // Returns -1 if not mapped
      90                 :   }
      91                 : };
      92                 : 
      93                 : 
      94                 : // Map array from cross platform roles to  ATK roles
      95                 : static const AtkStateMap gAtkStateMap[] = {                     // Cross Platform States
      96                 :   { kNone,                                    kMapOpposite },   // states::UNAVAILABLE             = 1 << 0
      97                 :   { ATK_STATE_SELECTED,                       kMapDirectly },   // states::SELECTED                = 1 << 1
      98                 :   { ATK_STATE_FOCUSED,                        kMapDirectly },   // states::FOCUSED                 = 1 << 2
      99                 :   { ATK_STATE_PRESSED,                        kMapDirectly },   // states::PRESSED                 = 1 << 3
     100                 :   { ATK_STATE_CHECKED,                        kMapDirectly },   // states::CHECKED                 = 1 << 4
     101                 :   { ATK_STATE_INDETERMINATE,                  kMapDirectly },   // states::MIXED                   = 1 << 5
     102                 :   { kNone,                                    kMapDirectly },   // states::READONLY                = 1 << 6
     103                 :   { kNone,                                    kMapDirectly },   // states::HOTTRACKED              = 1 << 7
     104                 :   { ATK_STATE_DEFAULT,                        kMapDirectly },   // states::DEFAULT                 = 1 << 8
     105                 :   { ATK_STATE_EXPANDED,                       kMapDirectly },   // states::EXPANDED                = 1 << 9
     106                 :   { kNone,                                    kNoStateChange }, // states::COLLAPSED               = 1 << 10
     107                 :   { ATK_STATE_BUSY,                           kMapDirectly },   // states::BUSY                    = 1 << 11
     108                 :   { kNone,                                    kMapDirectly },   // states::FLOATING                = 1 << 12
     109                 :   { kNone,                                    kMapDirectly },   // states::CHECKABLE               = 1 << 13
     110                 :   { ATK_STATE_ANIMATED,                       kMapDirectly },   // states::ANIMATED                = 1 << 14
     111                 :   { ATK_STATE_VISIBLE,                        kMapOpposite },   // states::INVISIBLE               = 1 << 15
     112                 :   { ATK_STATE_SHOWING,                        kMapOpposite },   // states::OFFSCREEN               = 1 << 16
     113                 :   { ATK_STATE_RESIZABLE,                      kMapDirectly },   // states::SIZEABLE                = 1 << 17
     114                 :   { kNone,                                    kMapDirectly },   // states::MOVEABLE                = 1 << 18
     115                 :   { kNone,                                    kMapDirectly },   // states::SELFVOICING             = 1 << 19
     116                 :   { ATK_STATE_FOCUSABLE,                      kMapDirectly },   // states::FOCUSABLE               = 1 << 20
     117                 :   { ATK_STATE_SELECTABLE,                     kMapDirectly },   // states::SELECTABLE              = 1 << 21
     118                 :   { kNone,                                    kMapDirectly },   // states::LINKED                  = 1 << 22
     119                 :   { ATK_STATE_VISITED,                        kMapDirectly },   // states::TRAVERSED               = 1 << 23
     120                 :   { ATK_STATE_MULTISELECTABLE,                kMapDirectly },   // states::MULTISELECTABLE         = 1 << 24
     121                 :   { kNone,                                    kMapDirectly },   // states::EXTSELECTABLE           = 1 << 25
     122                 :   { ATK_STATE_REQUIRED,                       kMapDirectly },   // states::STATE_REQUIRED          = 1 << 26
     123                 :   { kNone,                                    kMapDirectly },   // states::ALERT_MEDIUM            = 1 << 27
     124                 :   { ATK_STATE_INVALID_ENTRY,                  kMapDirectly },   // states::INVALID                 = 1 << 28
     125                 :   { kNone,                                    kMapDirectly },   // states::PROTECTED               = 1 << 29
     126                 :   { kNone,                                    kMapDirectly },   // states::HASPOPUP                = 1 << 30
     127                 :   { ATK_STATE_SUPPORTS_AUTOCOMPLETION,        kMapDirectly },   // states::SUPPORTS_AUTOCOMPLETION = 1 << 31
     128                 :   { ATK_STATE_DEFUNCT,                        kMapDirectly },   // states::DEFUNCT                 = 1 << 32
     129                 :   { ATK_STATE_SELECTABLE_TEXT,                kMapDirectly },   // states::SELECTABLE_TEXT         = 1 << 33
     130                 :   { ATK_STATE_EDITABLE,                       kMapDirectly },   // states::EDITABLE                = 1 << 34
     131                 :   { ATK_STATE_ACTIVE,                         kMapDirectly },   // states::ACTIVE                  = 1 << 35
     132                 :   { ATK_STATE_MODAL,                          kMapDirectly },   // states::MODAL                   = 1 << 36
     133                 :   { ATK_STATE_MULTI_LINE,                     kMapDirectly },   // states::MULTI_LINE              = 1 << 37
     134                 :   { ATK_STATE_HORIZONTAL,                     kMapDirectly },   // states::HORIZONTAL              = 1 << 38
     135                 :   { ATK_STATE_OPAQUE,                         kMapDirectly },   // states::OPAQUE                  = 1 << 39
     136                 :   { ATK_STATE_SINGLE_LINE,                    kMapDirectly },   // states::SINGLE_LINE             = 1 << 40
     137                 :   { ATK_STATE_TRANSIENT,                      kMapDirectly },   // states::TRANSIENT               = 1 << 41
     138                 :   { ATK_STATE_VERTICAL,                       kMapDirectly },   // states::VERTICAL                = 1 << 42
     139                 :   { ATK_STATE_STALE,                          kMapDirectly },   // states::STALE                   = 1 << 43
     140                 :   { ATK_STATE_ENABLED,                        kMapDirectly },   // states::ENABLED                 = 1 << 44
     141                 :   { ATK_STATE_SENSITIVE,                      kMapDirectly },   // states::SENSITIVE               = 1 << 45
     142                 :   { ATK_STATE_EXPANDABLE,                     kMapDirectly },   // states::EXPANDABLE              = 1 << 46
     143                 :   { kNone,                                    kNoSuchState },   //                                 = 1 << 47
     144                 : };

Generated by: LCOV version 1.7