Back to index

lightning-sunbird  0.9+nobinonly
nsXULAlertAccessible.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is IBM Corporation
00018  * Portions created by the Initial Developer are Copyright (C) 2005
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Author: Aaron Leventhal (aleventh@us.ibm.com)
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include "nsXULAlertAccessible.h"
00039 
00040 
00041 // ------------------------ Alert  -----------------------------
00042 
00043 NS_IMPL_ISUPPORTS_INHERITED0(nsXULAlertAccessible, nsAccessible)
00044 
00045 nsXULAlertAccessible::nsXULAlertAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell) :
00046   nsAccessibleWrap(aNode, aShell)
00047 {
00048 }
00049 
00050 NS_IMETHODIMP nsXULAlertAccessible::GetRole(PRUint32 *aRole)
00051 {
00052   *aRole = ROLE_ALERT;
00053   return NS_OK;
00054 }
00055 
00056 NS_IMETHODIMP nsXULAlertAccessible::GetState(PRUint32 *aState)
00057 {
00058   nsAccessible::GetState(aState);
00059   *aState &= ~STATE_FOCUSABLE;
00060   *aState |= STATE_ALERT_MEDIUM; // XUL has no markup for low, medium or high
00061   return NS_OK;
00062 }
00063 
00064 #if 0
00065 // We don't need this, but the AT will need to read all of the alert's children
00066 // when it receives EVENT_ALERT on a ROLE_ALERT
00067 NS_IMETHODIMP nsXULAlertAccessible::GetName(nsAString &aName)
00068 {
00069   nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
00070   if (!presShell) {
00071     return NS_ERROR_FAILURE; // Node already shut down
00072   }
00073   nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
00074   NS_ASSERTION(content, "Should not be null if we still have a presShell");
00075 
00076   nsCOMPtr<nsIBindingManager> bindingManager = presShell->GetDocument()->BindingManager();
00077   if (!bindingManager) {
00078     return NS_OK;
00079   }
00080 
00081   nsCOMPtr<nsIDOMNodeList> siblingList;
00082   bindingManager->GetXBLChildNodesFor(content, getter_AddRefs(siblingList)); // returns null if no anon nodes
00083   if (siblingList) {
00084     PRUint32 length, count;
00085     siblingList->GetLength(&length);
00086     for (count = 0; count < length; count ++) {
00087       nsCOMPtr<nsIDOMNode> domNode;
00088       siblingList->Item(count, getter_AddRefs(domNode));
00089       nsCOMPtr<nsIDOMXULLabeledControlElement> labeledEl(do_QueryInterface(domNode));
00090       if (labeledEl) {
00091         nsAutoString label;
00092         labeledEl->GetLabel(label);
00093         aName += NS_LITERAL_STRING(" ") + label + NS_LITERAL_STRING(" ");
00094       }
00095       else {
00096         nsCOMPtr<nsIContent> content(do_QueryInterface(domNode));
00097         if (content) {
00098           AppendFlatStringFromSubtree(content, &aName);
00099         }
00100       }
00101     }
00102   }
00103   else {
00104     AppendFlatStringFromSubtree(content, &aName);
00105   }
00106 
00107   return NS_OK;
00108 }
00109 #endif