LCOV - code coverage report
Current view: directory - accessible/src/xul - nsXULColorPickerAccessible.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 54 0 0.0 %
Date: 2012-06-02 Functions: 12 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                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Author: John Gaunt (jgaunt@netscape.com)
      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 "nsXULColorPickerAccessible.h"
      40                 : 
      41                 : #include "nsAccUtils.h"
      42                 : #include "nsAccTreeWalker.h"
      43                 : #include "nsCoreUtils.h"
      44                 : #include "nsDocAccessible.h"
      45                 : #include "Role.h"
      46                 : #include "States.h"
      47                 : 
      48                 : #include "nsIDOMElement.h"
      49                 : #include "nsMenuPopupFrame.h"
      50                 : 
      51                 : using namespace mozilla::a11y;
      52                 : 
      53                 : ////////////////////////////////////////////////////////////////////////////////
      54                 : // nsXULColorPickerTileAccessible
      55                 : ////////////////////////////////////////////////////////////////////////////////
      56                 : 
      57               0 : nsXULColorPickerTileAccessible::
      58                 :   nsXULColorPickerTileAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
      59               0 :   nsAccessibleWrap(aContent, aDoc)
      60                 : {
      61               0 : }
      62                 : 
      63                 : ////////////////////////////////////////////////////////////////////////////////
      64                 : // nsXULColorPickerTileAccessible: nsIAccessible
      65                 : 
      66                 : NS_IMETHODIMP
      67               0 : nsXULColorPickerTileAccessible::GetValue(nsAString& aValue)
      68                 : {
      69               0 :   aValue.Truncate();
      70                 : 
      71               0 :   if (IsDefunct())
      72               0 :     return NS_ERROR_FAILURE;
      73                 : 
      74               0 :   mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::color, aValue);
      75               0 :   return NS_OK;
      76                 : }
      77                 : 
      78                 : ////////////////////////////////////////////////////////////////////////////////
      79                 : // nsXULColorPickerTileAccessible: nsAccessible
      80                 : 
      81                 : role
      82               0 : nsXULColorPickerTileAccessible::NativeRole()
      83                 : {
      84               0 :   return roles::PUSHBUTTON;
      85                 : }
      86                 : 
      87                 : PRUint64
      88               0 : nsXULColorPickerTileAccessible::NativeState()
      89                 : {
      90               0 :   PRUint64 state = nsAccessibleWrap::NativeState();
      91               0 :   if (!(state & states::UNAVAILABLE))
      92               0 :     state |= states::FOCUSABLE | states::SELECTABLE;
      93                 : 
      94               0 :   if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::selected))
      95               0 :     state |= states::SELECTED;
      96                 : 
      97               0 :   return state;
      98                 : }
      99                 : 
     100                 : ////////////////////////////////////////////////////////////////////////////////
     101                 : // nsXULColorPickerTileAccessible: Widgets
     102                 : 
     103                 : nsAccessible*
     104               0 : nsXULColorPickerTileAccessible::ContainerWidget() const
     105                 : {
     106               0 :   nsAccessible* parent = Parent();
     107               0 :   if (parent) {
     108               0 :     nsAccessible* grandParent = parent->Parent();
     109               0 :     if (grandParent && grandParent->IsMenuButton())
     110               0 :       return grandParent;
     111                 :   }
     112               0 :   return nsnull;
     113                 : }
     114                 : 
     115                 : ////////////////////////////////////////////////////////////////////////////////
     116                 : // nsXULColorPickerAccessible
     117                 : ////////////////////////////////////////////////////////////////////////////////
     118                 : 
     119               0 : nsXULColorPickerAccessible::
     120                 :   nsXULColorPickerAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
     121               0 :   nsXULColorPickerTileAccessible(aContent, aDoc)
     122                 : {
     123               0 :   mFlags |= eMenuButtonAccessible;
     124               0 : }
     125                 : 
     126                 : ////////////////////////////////////////////////////////////////////////////////
     127                 : // nsXULColorPickerAccessible: nsAccessible
     128                 : 
     129                 : PRUint64
     130               0 : nsXULColorPickerAccessible::NativeState()
     131                 : {
     132                 :   // Possible states: focused, focusable, unavailable(disabled).
     133                 : 
     134                 :   // get focus and disable status from base class
     135               0 :   PRUint64 states = nsAccessibleWrap::NativeState();
     136                 : 
     137               0 :   states |= states::FOCUSABLE | states::HASPOPUP;
     138                 : 
     139               0 :   return states;
     140                 : }
     141                 : 
     142                 : role
     143               0 : nsXULColorPickerAccessible::NativeRole()
     144                 : {
     145               0 :   return roles::BUTTONDROPDOWNGRID;
     146                 : }
     147                 : 
     148                 : ////////////////////////////////////////////////////////////////////////////////
     149                 : // nsXULColorPickerAccessible: Widgets
     150                 : 
     151                 : bool
     152               0 : nsXULColorPickerAccessible::IsWidget() const
     153                 : {
     154               0 :   return true;
     155                 : }
     156                 : 
     157                 : bool
     158               0 : nsXULColorPickerAccessible::IsActiveWidget() const
     159                 : {
     160               0 :   return FocusMgr()->HasDOMFocus(mContent);
     161                 : }
     162                 : 
     163                 : bool
     164               0 : nsXULColorPickerAccessible::AreItemsOperable() const
     165                 : {
     166               0 :   nsAccessible* menuPopup = mChildren.SafeElementAt(0, nsnull);
     167               0 :   if (menuPopup) {
     168               0 :     nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(menuPopup->GetFrame());
     169               0 :     return menuPopupFrame && menuPopupFrame->IsOpen();
     170                 :   }
     171               0 :   return false;
     172                 : }
     173                 : 
     174                 : ////////////////////////////////////////////////////////////////////////////////
     175                 : // nsXULColorPickerAccessible: protected nsAccessible
     176                 : 
     177                 : void
     178               0 : nsXULColorPickerAccessible::CacheChildren()
     179                 : {
     180               0 :   NS_ENSURE_TRUE(mDoc,);
     181                 : 
     182               0 :   nsAccTreeWalker walker(mDoc, mContent, true);
     183                 : 
     184               0 :   nsAccessible* child = nsnull;
     185               0 :   while ((child = walker.NextChild())) {
     186               0 :     PRUint32 role = child->Role();
     187                 : 
     188                 :     // Get an accessible for menupopup or panel elements.
     189               0 :     if (role == roles::ALERT) {
     190               0 :       AppendChild(child);
     191                 :       return;
     192                 :     }
     193                 : 
     194                 :     // Unbind rejected accessibles from the document.
     195               0 :     Document()->UnbindFromDocument(child);
     196                 :   }
     197                 : }

Generated by: LCOV version 1.7