1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 XULMAP_TYPE(browser, OuterDocAccessible) 6 XULMAP_TYPE(button, XULButtonAccessible) 7 XULMAP_TYPE(checkbox, CheckboxAccessible) 8 XULMAP_TYPE(dropMarker, XULDropmarkerAccessible) 9 XULMAP_TYPE(editor, OuterDocAccessible) 10 XULMAP_TYPE(findbar, XULToolbarAccessible) 11 XULMAP_TYPE(groupbox, XULGroupboxAccessible) 12 XULMAP_TYPE(iframe, OuterDocAccessible) 13 XULMAP_TYPE(listheader, XULColumAccessible) 14 XULMAP_TYPE(menu, XULMenuitemAccessibleWrap) 15 XULMAP_TYPE(menubar, XULMenubarAccessible) 16 XULMAP_TYPE(menucaption, XULMenuitemAccessibleWrap) 17 XULMAP_TYPE(menuitem, XULMenuitemAccessibleWrap) 18 XULMAP_TYPE(menulist, XULComboboxAccessible) 19 XULMAP_TYPE(menuseparator, XULMenuSeparatorAccessible) 20 XULMAP_TYPE(notification, XULAlertAccessible) 21 XULMAP_TYPE(radio, XULRadioButtonAccessible) 22 XULMAP_TYPE(radiogroup, XULRadioGroupAccessible) 23 XULMAP_TYPE(richlistbox, XULListboxAccessibleWrap) 24 XULMAP_TYPE(richlistitem, XULListitemAccessible) 25 XULMAP_TYPE(statusbar, XULStatusBarAccessible) 26 XULMAP_TYPE(tab, XULTabAccessible) 27 XULMAP_TYPE(tabpanels, XULTabpanelsAccessible) 28 XULMAP_TYPE(tabs, XULTabsAccessible) 29 XULMAP_TYPE(toolbarseparator, XULToolbarSeparatorAccessible) 30 XULMAP_TYPE(toolbarspacer, XULToolbarSeparatorAccessible) 31 XULMAP_TYPE(toolbarspring, XULToolbarSeparatorAccessible) 32 XULMAP_TYPE(treecol, XULColumnItemAccessible) 33 XULMAP_TYPE(treecolpicker, XULButtonAccessible) 34 XULMAP_TYPE(treecols, XULTreeColumAccessible) 35 XULMAP_TYPE(toolbar, XULToolbarAccessible) 36 XULMAP_TYPE(toolbarbutton, XULToolbarButtonAccessible) 37 38 XULMAP(description, 39 [](Element* aElement, LocalAccessible* aContext) -> LocalAccessible* { 40 if (aElement->ClassList()->Contains(u"tooltip-label"_ns)) { 41 return nullptr; 42 } 43 44 return new XULLabelAccessible(aElement, aContext->Document()); 45 }) 46 47 XULMAP(tooltip, 48 [](Element* aElement, LocalAccessible* aContext) -> LocalAccessible* { 49 nsIFrame* frame = aElement->GetPrimaryFrame(); 50 if (!frame) { 51 return nullptr; 52 } 53 54 nsMenuPopupFrame* popupFrame = do_QueryFrame(frame); 55 if (!popupFrame) { 56 return nullptr; 57 } 58 59 nsPopupState popupState = popupFrame->PopupState(); 60 if (popupState == ePopupHiding || popupState == ePopupInvisible || 61 popupState == ePopupClosed) { 62 return nullptr; 63 } 64 65 return new XULTooltipAccessible(aElement, aContext->Document()); 66 }) 67 68 XULMAP(label, 69 [](Element* aElement, LocalAccessible* aContext) -> LocalAccessible* { 70 if (aElement->ClassList()->Contains(u"text-link"_ns)) { 71 return new XULLinkAccessible(aElement, aContext->Document()); 72 } 73 return new XULLabelAccessible(aElement, aContext->Document()); 74 }) 75 76 XULMAP(image, 77 [](Element* aElement, LocalAccessible* aContext) -> LocalAccessible* { 78 // Don't include nameless images in accessible tree. 79 if (!aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::tooltiptext)) { 80 return nullptr; 81 } 82 83 return new ImageAccessibleWrap(aElement, aContext->Document()); 84 }) 85 86 XULMAP(menupopup, [](Element* aElement, LocalAccessible* aContext) { 87 return CreateMenupopupAccessible(aElement, aContext); 88 }) 89 90 XULMAP(panel, 91 [](Element* aElement, LocalAccessible* aContext) -> LocalAccessible* { 92 static const Element::AttrValuesArray sIgnoreTypeVals[] = { 93 nsGkAtoms::autocomplete_richlistbox, nsGkAtoms::autocomplete, 94 nullptr}; 95 96 if (aElement->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::type, 97 sIgnoreTypeVals, eIgnoreCase) >= 0) { 98 return nullptr; 99 } 100 101 if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::noautofocus, 102 nsGkAtoms::_true, eCaseMatters)) { 103 return new XULAlertAccessible(aElement, aContext->Document()); 104 } 105 106 return new EnumRoleAccessible<roles::PANE>(aElement, 107 aContext->Document()); 108 }) 109 110 XULMAP(popup, [](Element* aElement, LocalAccessible* aContext) { 111 return CreateMenupopupAccessible(aElement, aContext); 112 }) 113 114 XULMAP(tree, 115 [](Element* aElement, LocalAccessible* aContext) -> LocalAccessible* { 116 nsIContent* child = 117 nsTreeUtils::GetDescendantChild(aElement, nsGkAtoms::treechildren); 118 if (!child) return nullptr; 119 120 nsTreeBodyFrame* treeFrame = do_QueryFrame(child->GetPrimaryFrame()); 121 if (!treeFrame) return nullptr; 122 123 RefPtr<nsTreeColumns> treeCols = treeFrame->Columns(); 124 uint32_t count = treeCols->Count(); 125 126 // Outline of list accessible. 127 if (count == 1) { 128 return new XULTreeAccessible(aElement, aContext->Document(), 129 treeFrame); 130 } 131 132 // Table or tree table accessible. 133 return new XULTreeGridAccessibleWrap(aElement, aContext->Document(), 134 treeFrame); 135 }) 136