Back to index

lightning-sunbird  0.9+nobinonly
nsXULSelectAccessible.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; 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
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Original Author: Eric Vaughan (evaughan@netscape.com)
00024  *   Kyle Yuan (kyle.yuan@sun.com)
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #include "nsXULSelectAccessible.h"
00041 #include "nsAccessibilityService.h"
00042 #include "nsArray.h"
00043 #include "nsIContent.h"
00044 #include "nsIDOMXULMenuListElement.h"
00045 #include "nsIDOMXULMultSelectCntrlEl.h"
00046 #include "nsIDOMXULSelectCntrlItemEl.h"
00047 #include "nsIDOMXULSelectCntrlEl.h"
00048 #include "nsIDOMXULTextboxElement.h"
00049 #include "nsIPresShell.h"
00050 #include "nsIServiceManager.h"
00051 
00076 // Helper methos
00077 nsXULSelectableAccessible::nsXULSelectableAccessible(nsIDOMNode* aDOMNode,
00078                                                      nsIWeakReference* aShell):
00079 nsAccessibleWrap(aDOMNode, aShell)
00080 {
00081 }
00082 
00083 NS_IMETHODIMP nsXULSelectableAccessible::GetName(nsAString& aName)
00084 {
00085   return GetXULName(aName, PR_FALSE);
00086 }
00087 
00088 NS_IMPL_ISUPPORTS_INHERITED1(nsXULSelectableAccessible, nsAccessible, nsIAccessibleSelectable)
00089 
00090 NS_IMETHODIMP nsXULSelectableAccessible::ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState)
00091 {
00092   nsCOMPtr<nsIAccessible> childAcc;
00093   GetChildAt(aIndex, getter_AddRefs(childAcc));
00094   nsCOMPtr<nsIAccessNode> accNode = do_QueryInterface(childAcc);
00095   NS_ENSURE_TRUE(accNode, NS_ERROR_FAILURE);
00096 
00097   nsCOMPtr<nsIDOMNode> childNode;
00098   accNode->GetDOMNode(getter_AddRefs(childNode));
00099   nsCOMPtr<nsIDOMXULSelectControlItemElement> item(do_QueryInterface(childNode));
00100   NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
00101 
00102   *aSelState = PR_FALSE;
00103 
00104   nsCOMPtr<nsIDOMXULSelectControlElement> xulSelect(do_QueryInterface(mDOMNode));
00105   nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect(do_QueryInterface(mDOMNode));
00106 
00107   if (xulSelect || xulMultiSelect) {
00108       item->GetSelected(aSelState);
00109       if (eSelection_Add == aMethod && !(*aSelState)) {
00110         if (xulMultiSelect)
00111           return xulMultiSelect->AddItemToSelection(item);
00112         else if (xulSelect)
00113           return xulSelect->SetSelectedItem(item);
00114       }
00115       else if (eSelection_Remove == aMethod && (*aSelState)) {
00116         if (xulMultiSelect)
00117           return xulMultiSelect->RemoveItemFromSelection(item);
00118         else if (xulSelect)
00119           return xulSelect->SetSelectedIndex(-1);
00120       }
00121   }
00122 
00123   return NS_ERROR_FAILURE;
00124 }
00125 
00126 // Interface methods
00127 NS_IMETHODIMP nsXULSelectableAccessible::GetSelectedChildren(nsIArray **_retval)
00128 {
00129   *_retval = nsnull;
00130 
00131   nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
00132   if (!accService)
00133     return NS_ERROR_FAILURE;
00134 
00135   nsCOMPtr<nsIMutableArray> selectedAccessibles;
00136   NS_NewArray(getter_AddRefs(selectedAccessibles));
00137   if (!selectedAccessibles)
00138     return NS_ERROR_OUT_OF_MEMORY;
00139 
00140   // For XUL multi-select control
00141   nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect(do_QueryInterface(mDOMNode));
00142   if (xulMultiSelect) {
00143     PRInt32 length = 0;
00144     xulMultiSelect->GetSelectedCount(&length);
00145     for (PRInt32 index = 0; index < length; index++) {
00146       nsCOMPtr<nsIAccessible> tempAccessible;
00147       nsCOMPtr<nsIDOMXULSelectControlItemElement> tempNode;
00148       xulMultiSelect->GetSelectedItem(index, getter_AddRefs(tempNode));
00149       nsCOMPtr<nsIDOMNode> tempDOMNode (do_QueryInterface(tempNode));
00150       accService->GetAccessibleInWeakShell(tempDOMNode, mWeakShell, getter_AddRefs(tempAccessible));
00151       if (tempAccessible)
00152         selectedAccessibles->AppendElement(tempAccessible, PR_FALSE);
00153     }
00154   }
00155 
00156   PRUint32 uLength = 0;
00157   selectedAccessibles->GetLength(&uLength);
00158   if (uLength != 0) { // length of nsIArray containing selected options
00159     *_retval = selectedAccessibles;
00160     NS_ADDREF(*_retval);
00161   }
00162 
00163   return NS_OK;
00164 }
00165 
00166 // return the nth selected child's nsIAccessible object
00167 NS_IMETHODIMP nsXULSelectableAccessible::RefSelection(PRInt32 aIndex, nsIAccessible **_retval)
00168 {
00169   *_retval = nsnull;
00170 
00171   nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
00172   if (!accService)
00173     return NS_ERROR_FAILURE;
00174 
00175   nsCOMPtr<nsIDOMXULSelectControlItemElement> tempDOMNode;
00176   nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect(do_QueryInterface(mDOMNode));
00177   if (xulMultiSelect)
00178     xulMultiSelect->GetSelectedItem(aIndex, getter_AddRefs(tempDOMNode));
00179 
00180   nsCOMPtr<nsIDOMXULSelectControlElement> xulSelect(do_QueryInterface(mDOMNode));
00181   if (xulSelect && aIndex == 0)
00182     xulSelect->GetSelectedItem(getter_AddRefs(tempDOMNode));
00183 
00184   if (tempDOMNode) {
00185     return accService->GetAccessibleInWeakShell(tempDOMNode, mWeakShell, _retval);
00186   }
00187 
00188   return NS_ERROR_FAILURE;
00189 }
00190 
00191 NS_IMETHODIMP nsXULSelectableAccessible::GetSelectionCount(PRInt32 *aSelectionCount)
00192 {
00193   *aSelectionCount = 0;
00194 
00195   // For XUL multi-select control
00196   nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect(do_QueryInterface(mDOMNode));
00197   if (xulMultiSelect)
00198     return xulMultiSelect->GetSelectedCount(aSelectionCount);
00199 
00200   // For XUL single-select control/menulist
00201   nsCOMPtr<nsIDOMXULSelectControlElement> xulSelect(do_QueryInterface(mDOMNode));
00202   if (xulSelect) {
00203     PRInt32 index;
00204     xulSelect->GetSelectedIndex(&index);
00205     if (index >= 0)
00206       *aSelectionCount = 1;
00207     return NS_OK;
00208   }
00209 
00210   return NS_ERROR_FAILURE;
00211 }
00212 
00213 NS_IMETHODIMP nsXULSelectableAccessible::AddChildToSelection(PRInt32 aIndex)
00214 {
00215   PRBool isSelected;
00216   return ChangeSelection(aIndex, eSelection_Add, &isSelected);
00217 }
00218 
00219 NS_IMETHODIMP nsXULSelectableAccessible::RemoveChildFromSelection(PRInt32 aIndex)
00220 {
00221   PRBool isSelected;
00222   return ChangeSelection(aIndex, eSelection_Remove, &isSelected);
00223 }
00224 
00225 NS_IMETHODIMP nsXULSelectableAccessible::IsChildSelected(PRInt32 aIndex, PRBool *_retval)
00226 {
00227   *_retval = PR_FALSE;
00228   return ChangeSelection(aIndex, eSelection_GetState, _retval);
00229 }
00230 
00231 NS_IMETHODIMP nsXULSelectableAccessible::ClearSelection()
00232 {
00233   nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect(do_QueryInterface(mDOMNode));
00234   if (xulMultiSelect)
00235     return xulMultiSelect->ClearSelection();
00236 
00237   nsCOMPtr<nsIDOMXULSelectControlElement> xulSelect(do_QueryInterface(mDOMNode));
00238   if (xulSelect)
00239     return xulSelect->SetSelectedIndex(-1);
00240 
00241   return NS_ERROR_FAILURE;
00242 }
00243 
00244 NS_IMETHODIMP nsXULSelectableAccessible::SelectAllSelection(PRBool *_retval)
00245 {
00246   *_retval = PR_TRUE;
00247 
00248   nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect(do_QueryInterface(mDOMNode));
00249   if (xulMultiSelect)
00250     return xulMultiSelect->SelectAll();
00251 
00252   // otherwise, don't support this method
00253   *_retval = PR_FALSE;
00254   return NS_OK;
00255 }
00256 
00264 nsXULSelectListAccessible::nsXULSelectListAccessible(nsIDOMNode* aDOMNode,
00265                                                      nsIWeakReference* aShell)
00266 :nsAccessibleWrap(aDOMNode, aShell)
00267 {
00268 }
00269 
00270 NS_IMETHODIMP nsXULSelectListAccessible::GetRole(PRUint32 *_retval)
00271 {
00272   *_retval = ROLE_LIST;
00273   return NS_OK;
00274 }
00275 
00281 NS_IMETHODIMP nsXULSelectListAccessible::GetState(PRUint32 *_retval)
00282 {
00283   *_retval = 0;
00284   nsAutoString selectionTypeString;
00285   nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
00286   NS_ASSERTION(element, "No nsIDOMElement for caption node!");
00287   element->GetAttribute(NS_LITERAL_STRING("seltype"), selectionTypeString) ;
00288   if (selectionTypeString.LowerCaseEqualsLiteral("multiple"))
00289     *_retval |= STATE_MULTISELECTABLE | STATE_EXTSELECTABLE;
00290 
00291   return NS_OK;
00292 }
00293 
00297 nsXULSelectOptionAccessible::nsXULSelectOptionAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
00298 nsXULMenuitemAccessible(aDOMNode, aShell)
00299 {
00300 }
00301 
00302 NS_IMETHODIMP nsXULSelectOptionAccessible::GetRole(PRUint32 *_retval)
00303 {
00304   *_retval = ROLE_LISTITEM;
00305   return NS_OK;
00306 }
00307 
00315 NS_IMETHODIMP nsXULSelectOptionAccessible::GetState(PRUint32 *_retval)
00316 {
00317   nsXULMenuitemAccessible::GetState(_retval);
00318 
00319   nsCOMPtr<nsIDOMXULSelectControlItemElement> item(do_QueryInterface(mDOMNode));
00320   PRBool isSelected = PR_FALSE;
00321   item->GetSelected(&isSelected);
00322   if (isSelected)
00323     *_retval |= STATE_SELECTED;
00324 
00325   return NS_OK;
00326 }
00327 
00328 nsIFrame* nsXULSelectOptionAccessible::GetBoundsFrame()
00329 {
00330   nsCOMPtr<nsIContent> menuListContent(do_QueryInterface(mDOMNode));
00331 
00332   while (menuListContent) {
00333     nsCOMPtr<nsIDOMXULMenuListElement> menuListControl =
00334       do_QueryInterface(menuListContent);
00335     if (menuListControl) {
00336       PRBool isOpen;
00337       menuListControl->GetOpen(&isOpen);
00338       if (!isOpen) {
00339         nsCOMPtr<nsIPresShell> presShell(GetPresShell());
00340         if (!presShell) {
00341           return nsnull;
00342         }
00343         nsIFrame *menuListFrame = nsnull;
00344         presShell->GetPrimaryFrameFor(menuListContent, &menuListFrame);
00345         return menuListFrame;
00346       }
00347       break;
00348     }
00349     menuListContent = menuListContent->GetParent();
00350   }
00351 
00352   return nsXULMenuitemAccessible::GetBoundsFrame();
00353 }
00354 
00362 nsXULListboxAccessible::nsXULListboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
00363 nsXULSelectableAccessible(aDOMNode, aShell)
00364 {
00365 }
00366 
00373 NS_IMETHODIMP nsXULListboxAccessible::GetState(PRUint32 *aState)
00374 {
00375   // Get focus status from base class
00376   nsAccessible::GetState(aState);
00377 
00378 // see if we are multiple select if so set ourselves as such
00379   nsCOMPtr<nsIDOMElement> element (do_QueryInterface(mDOMNode));
00380   if (element) {
00381     nsAutoString selType;
00382     element->GetAttribute(NS_LITERAL_STRING("seltype"), selType);
00383     if (!selType.IsEmpty() && selType.EqualsLiteral("multiple"))
00384       *aState |= STATE_MULTISELECTABLE | STATE_EXTSELECTABLE;
00385   }
00386 
00387   return NS_OK;
00388 }
00389 
00393 NS_IMETHODIMP nsXULListboxAccessible::GetValue(nsAString& _retval)
00394 {
00395   _retval.Truncate();
00396   nsCOMPtr<nsIDOMXULSelectControlElement> select(do_QueryInterface(mDOMNode));
00397   if (select) {
00398     nsCOMPtr<nsIDOMXULSelectControlItemElement> selectedItem;
00399     select->GetSelectedItem(getter_AddRefs(selectedItem));
00400     if (selectedItem)
00401       return selectedItem->GetLabel(_retval);
00402   }
00403   return NS_ERROR_FAILURE;
00404 }
00405 
00406 NS_IMETHODIMP nsXULListboxAccessible::GetRole(PRUint32 *_retval)
00407 {
00408   *_retval = ROLE_LIST;
00409   return NS_OK;
00410 }
00411 
00415 nsXULListitemAccessible::nsXULListitemAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
00416 nsXULMenuitemAccessible(aDOMNode, aShell)
00417 {
00418   mIsCheckbox = PR_FALSE;
00419   nsCOMPtr<nsIDOMElement> listItem (do_QueryInterface(mDOMNode));
00420   if (listItem) {
00421     nsAutoString typeString;
00422     nsresult res = listItem->GetAttribute(NS_LITERAL_STRING("type"), typeString);
00423     if (NS_SUCCEEDED(res) && typeString.Equals(NS_LITERAL_STRING("checkbox")))
00424       mIsCheckbox = PR_TRUE;
00425   }
00426 }
00427 
00429 NS_IMPL_ISUPPORTS_INHERITED0(nsXULListitemAccessible, nsAccessible)
00430 
00431 
00435 NS_IMETHODIMP nsXULListitemAccessible::GetName(nsAString& _retval)
00436 {
00437   nsCOMPtr<nsIDOMNode> child;
00438   if (NS_SUCCEEDED(mDOMNode->GetFirstChild(getter_AddRefs(child)))) {
00439     nsCOMPtr<nsIDOMElement> childElement (do_QueryInterface(child));
00440     if (childElement) {
00441       nsAutoString tagName;
00442       childElement->GetLocalName(tagName);
00443       if (tagName.EqualsLiteral("listcell")) {
00444         childElement->GetAttribute(NS_LITERAL_STRING("label"), _retval);
00445         return NS_OK;
00446       }
00447     }
00448   }
00449   return GetXULName(_retval);
00450 }
00451 
00455 NS_IMETHODIMP nsXULListitemAccessible::GetRole(PRUint32 *_retval)
00456 {
00457   if (mIsCheckbox)
00458     *_retval = ROLE_CHECKBUTTON;
00459   else
00460     *_retval = ROLE_LISTITEM;
00461   return NS_OK;
00462 }
00463 
00467 NS_IMETHODIMP nsXULListitemAccessible::GetState(PRUint32 *_retval)
00468 {
00469   if (mIsCheckbox) {
00470     nsXULMenuitemAccessible::GetState(_retval);
00471     return NS_OK;
00472   }
00473 
00474   *_retval = STATE_FOCUSABLE | STATE_SELECTABLE;
00475   nsCOMPtr<nsIDOMXULSelectControlItemElement> listItem (do_QueryInterface(mDOMNode));
00476   if (listItem) {
00477     PRBool isSelected;
00478     listItem->GetSelected(&isSelected);
00479     if (isSelected)
00480       *_retval |= STATE_SELECTED;
00481 
00482     if (gLastFocusedNode == mDOMNode) {
00483       *_retval |= STATE_FOCUSED;
00484     }
00485   }
00486 
00487   return NS_OK;
00488 }
00489 
00490 NS_IMETHODIMP nsXULListitemAccessible::GetActionName(PRUint8 index, nsAString& _retval)
00491 {
00492   if (index == eAction_Click) {
00493     // check or uncheck
00494     PRUint32 state;
00495     GetState(&state);
00496 
00497     if (state & STATE_CHECKED)
00498       _retval = NS_LITERAL_STRING("uncheck");
00499     else
00500       _retval = NS_LITERAL_STRING("check");
00501 
00502     return NS_OK;
00503   }
00504   return NS_ERROR_INVALID_ARG;
00505 }
00513 nsXULComboboxAccessible::nsXULComboboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
00514 nsXULSelectableAccessible(aDOMNode, aShell)
00515 {
00516 }
00517 
00519 NS_IMETHODIMP nsXULComboboxAccessible::GetRole(PRUint32 *aRole)
00520 {
00521   nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
00522   if (!content) {
00523     return NS_ERROR_FAILURE;
00524   }
00525   nsAutoString type;
00526   content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::type, type);
00527   *aRole = type.EqualsLiteral("autocomplete") ? ROLE_AUTOCOMPLETE : ROLE_COMBOBOX;
00528   return NS_OK;
00529 }
00530 
00540 NS_IMETHODIMP nsXULComboboxAccessible::GetState(PRUint32 *_retval)
00541 {
00542   // Get focus status from base class
00543   nsAccessible::GetState(_retval);
00544 
00545   nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
00546   if (menuList) {
00547     PRBool isOpen;
00548     menuList->GetOpen(&isOpen);
00549     if (isOpen) {
00550       *_retval |= STATE_EXPANDED;
00551     }
00552     else {
00553       *_retval |= STATE_COLLAPSED;
00554     }
00555     PRBool isEditable;
00556     menuList->GetEditable(&isEditable);
00557     if (!isEditable) {
00558       *_retval |= STATE_READONLY;
00559     }
00560   }
00561 
00562   *_retval |= STATE_HASPOPUP | STATE_FOCUSABLE;
00563 
00564   return NS_OK;
00565 }
00566 
00567 NS_IMETHODIMP nsXULComboboxAccessible::GetValue(nsAString& _retval)
00568 {
00569   _retval.Truncate();
00570 
00571   // The MSAA/ATK value is the option or text shown entered in the combobox
00572   nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
00573   if (menuList) {
00574     return menuList->GetLabel(_retval);
00575   }
00576   return NS_ERROR_FAILURE;
00577 }
00578 
00579 NS_IMETHODIMP nsXULComboboxAccessible::GetDescription(nsAString& aDescription)
00580 {
00581   // Use description of currently focused option
00582   aDescription.Truncate();
00583   nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
00584   if (!menuList) {
00585     return NS_ERROR_FAILURE;  // Shut down
00586   }
00587   nsCOMPtr<nsIDOMXULSelectControlItemElement> focusedOption;
00588   menuList->GetSelectedItem(getter_AddRefs(focusedOption));
00589   nsCOMPtr<nsIDOMNode> focusedOptionNode(do_QueryInterface(focusedOption));
00590   if (focusedOptionNode) {
00591     nsCOMPtr<nsIAccessibilityService> accService = 
00592       do_GetService("@mozilla.org/accessibilityService;1");
00593     NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
00594     nsCOMPtr<nsIAccessible> focusedOptionAccessible;
00595     accService->GetAccessibleInWeakShell(focusedOptionNode, mWeakShell, 
00596                                         getter_AddRefs(focusedOptionAccessible));
00597     NS_ENSURE_TRUE(focusedOptionAccessible, NS_ERROR_FAILURE);
00598     return focusedOptionAccessible->GetDescription(aDescription);
00599   }
00600   return NS_OK;
00601 }
00602 
00603 NS_IMETHODIMP nsXULComboboxAccessible::GetChildCount(PRInt32 *aAccChildCount)
00604 {
00605   // Set menugenerated="true" on the menupopup node to generate the
00606   // sub-menu items if they have not been generated
00607   PRUint32 childIndex, numChildren = 0;
00608   nsCOMPtr<nsIDOMNode> childNode;
00609   nsCOMPtr<nsIDOMNodeList> nodeList;
00610   mDOMNode->GetChildNodes(getter_AddRefs(nodeList));
00611   if (nodeList && NS_OK == nodeList->GetLength(&numChildren)) {
00612     for (childIndex = 0; childIndex < numChildren; childIndex++) {
00613       nodeList->Item(childIndex, getter_AddRefs(childNode));
00614       nsAutoString nodeName;
00615       childNode->GetNodeName(nodeName);
00616       if (nodeName.Equals(NS_LITERAL_STRING("menupopup"))) {
00617         break;
00618       }
00619     }
00620 
00621     if (childIndex < numChildren) {
00622       nsCOMPtr<nsIDOMElement> element(do_QueryInterface(childNode));
00623       if (element) {
00624         nsAutoString attr;
00625         element->GetAttribute(NS_LITERAL_STRING("menugenerated"), attr);
00626         if (!attr.Equals(NS_LITERAL_STRING("true"))) {
00627           element->SetAttribute(NS_LITERAL_STRING("menugenerated"), NS_LITERAL_STRING("true"));
00628         }
00629       }
00630     }
00631   }
00632 
00633   nsAutoString boxName;
00634   mDOMNode->GetNodeName(boxName);
00635   if (boxName.Equals(NS_LITERAL_STRING("textbox"))) {
00636     // autocomplete textbox also uses nsXULComboboxAccessible and we need walk anonymous children
00637     CacheChildren(PR_TRUE);
00638   }
00639   else {
00640     // Argument of PR_FALSE indicates we don't walk anonymous children for menuitems
00641     CacheChildren(PR_FALSE);
00642   }
00643   *aAccChildCount = mAccChildCount;
00644   return NS_OK;
00645 }