DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (e2b0e792967f)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

XULMAP_TYPE(browser, OuterDocAccessible)
XULMAP_TYPE(button, XULButtonAccessible)
XULMAP_TYPE(checkbox, XULCheckboxAccessible)
XULMAP_TYPE(description, XULLabelAccessible)
XULMAP_TYPE(dropMarker, XULDropmarkerAccessible)
XULMAP_TYPE(editor, OuterDocAccessible)
XULMAP_TYPE(findbar, XULToolbarAccessible)
XULMAP_TYPE(groupbox, XULGroupboxAccessible)
XULMAP_TYPE(iframe, OuterDocAccessible)
XULMAP_TYPE(listbox, XULListboxAccessibleWrap)
XULMAP_TYPE(listhead, XULColumAccessible)
XULMAP_TYPE(listheader, XULColumnItemAccessible)
XULMAP_TYPE(listitem, XULListitemAccessible)
XULMAP_TYPE(menu, XULMenuitemAccessibleWrap)
XULMAP_TYPE(menubar, XULMenubarAccessible)
XULMAP_TYPE(menucaption, XULMenuitemAccessibleWrap)
XULMAP_TYPE(menuitem, XULMenuitemAccessibleWrap)
XULMAP_TYPE(menulist, XULComboboxAccessible)
XULMAP_TYPE(menuseparator, XULMenuSeparatorAccessible)
XULMAP_TYPE(notification, XULAlertAccessible)
XULMAP_TYPE(progressmeter, XULProgressMeterAccessible)
XULMAP_TYPE(radio, XULRadioButtonAccessible)
XULMAP_TYPE(radiogroup, XULRadioGroupAccessible)
XULMAP_TYPE(richlistbox, XULListboxAccessibleWrap)
XULMAP_TYPE(richlistitem, XULListitemAccessible)
XULMAP_TYPE(scale, XULSliderAccessible)
XULMAP_TYPE(statusbar, XULStatusBarAccessible)
XULMAP_TYPE(tab, XULTabAccessible)
XULMAP_TYPE(tabpanels, XULTabpanelsAccessible)
XULMAP_TYPE(tabs, XULTabsAccessible)
XULMAP_TYPE(toolbarseparator, XULToolbarSeparatorAccessible)
XULMAP_TYPE(toolbarspacer, XULToolbarSeparatorAccessible)
XULMAP_TYPE(toolbarspring, XULToolbarSeparatorAccessible)
XULMAP_TYPE(treecol, XULColumnItemAccessible)
XULMAP_TYPE(treecolpicker, XULButtonAccessible)
XULMAP_TYPE(treecols, XULTreeColumAccessible)
XULMAP_TYPE(toolbar, XULToolbarAccessible)
XULMAP_TYPE(toolbarbutton, XULToolbarButtonAccessible)
XULMAP_TYPE(tooltip, XULTooltipAccessible)

XULMAP(
  colorpicker,
  [](Element* aElement, Accessible* aContext) -> Accessible* {
    if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
                              nsGkAtoms::button, eIgnoreCase)) {
      return new XULColorPickerAccessible(aElement, aContext->Document());
    }
    return nullptr;
  }
)

XULMAP(
  label,
  [](Element* aElement, Accessible* aContext) -> Accessible* {
    if (aElement->ClassList()->Contains(NS_LITERAL_STRING("text-link"))) {
      return new XULLinkAccessible(aElement, aContext->Document());
    }
    return new XULLabelAccessible(aElement, aContext->Document());
  }
)

XULMAP(
  image,
  [](Element* aElement, Accessible* aContext) -> Accessible* {
    if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::onclick)) {
      return new XULToolbarButtonAccessible(aElement, aContext->Document());
    }

    if (aElement->ClassList()->Contains(NS_LITERAL_STRING("colorpickertile"))) {
      return new XULColorPickerTileAccessible(aElement, aContext->Document());
    }

    // Don't include nameless images in accessible tree.
    if (!aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::tooltiptext)) {
      return nullptr;
    }

    return new ImageAccessibleWrap(aElement, aContext->Document());
  }
)

XULMAP(
  listcell,
  [](Element* aElement, Accessible* aContext) -> Accessible* {
    // Only create cells if there's more than one per row.
    nsIContent* listItem = aElement->GetParent();
    if (!listItem) {
      return nullptr;
    }

    for (nsIContent* child = listItem->GetFirstChild(); child;
         child = child->GetNextSibling()) {
      if (child->IsXULElement(nsGkAtoms::listcell) && child != aElement) {
        return new XULListCellAccessibleWrap(aElement, aContext->Document());
      }
    }

    return nullptr;
  }
)

XULMAP(
  menupopup,
  [](Element* aElement, Accessible* aContext) {
    return CreateMenupopupAccessible(aElement, aContext);
  }
)

XULMAP(
  panel,
  [](Element* aElement, Accessible* aContext) -> Accessible* {
    static const Element::AttrValuesArray sIgnoreTypeVals[] =
      { &nsGkAtoms::autocomplete_richlistbox, &nsGkAtoms::autocomplete, nullptr };

    if (aElement->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::type,
                                  sIgnoreTypeVals, eIgnoreCase) >= 0) {
      return nullptr;
    }

    if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::noautofocus,
                              nsGkAtoms::_true, eCaseMatters)) {
      return new XULAlertAccessible(aElement, aContext->Document());
    }

    return new EnumRoleAccessible<roles::PANE>(aElement, aContext->Document());
  }
)

XULMAP(
  popup,
  [](Element* aElement, Accessible* aContext) {
    return CreateMenupopupAccessible(aElement, aContext);
  }
)

XULMAP(
  textbox,
  [](Element* aElement, Accessible* aContext) -> Accessible* {
    if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
                              nsGkAtoms::autocomplete, eIgnoreCase)) {
      return new XULComboboxAccessible(aElement, aContext->Document());
    }

    return new EnumRoleAccessible<roles::SECTION>(aElement, aContext->Document());
  }
)

XULMAP(
  thumb,
  [](Element* aElement, Accessible* aContext) -> Accessible* {
    if (aElement->ClassList()->Contains(NS_LITERAL_STRING("scale-thumb"))) {
      return new XULThumbAccessible(aElement, aContext->Document());
    }
    return nullptr;
  }
)

XULMAP(
  tree,
  [](Element* aElement, Accessible* aContext) -> Accessible* {
    nsIContent* child = nsTreeUtils::GetDescendantChild(aElement,
                                                        nsGkAtoms::treechildren);
    if (!child)
      return nullptr;

    nsTreeBodyFrame* treeFrame = do_QueryFrame(child->GetPrimaryFrame());
    if (!treeFrame)
      return nullptr;

    RefPtr<nsTreeColumns> treeCols = treeFrame->Columns();
    int32_t count = 0;
    treeCols->GetCount(&count);

    // Outline of list accessible.
    if (count == 1) {
      return new XULTreeAccessible(aElement, aContext->Document(), treeFrame);
    }

    // Table or tree table accessible.
    return new XULTreeGridAccessibleWrap(aElement, aContext->Document(), treeFrame);
  }
)